Info per file implemented (more testing required)

This commit is contained in:
2015-07-16 00:37:11 +02:00
parent a06104a7cc
commit 92c5165035
6 changed files with 244 additions and 89 deletions

View File

@ -175,12 +175,13 @@
this.txtPrefix.Size = new System.Drawing.Size(57, 20);
this.txtPrefix.TabIndex = 10;
this.txtPrefix.Text = "GWM_";
this.txtPrefix.TextChanged += new System.EventHandler(this.txtPrefix_TextChanged);
//
// chkWrap
//
this.chkWrap.AutoSize = true;
this.chkWrap.Location = new System.Drawing.Point(389, 73);
this.chkWrap.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.chkWrap.Margin = new System.Windows.Forms.Padding(2);
this.chkWrap.Name = "chkWrap";
this.chkWrap.Size = new System.Drawing.Size(79, 17);
this.chkWrap.TabIndex = 11;
@ -193,7 +194,7 @@
this.btnGenICode.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnGenICode.Enabled = false;
this.btnGenICode.Location = new System.Drawing.Point(410, 616);
this.btnGenICode.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.btnGenICode.Margin = new System.Windows.Forms.Padding(2);
this.btnGenICode.Name = "btnGenICode";
this.btnGenICode.Size = new System.Drawing.Size(81, 23);
this.btnGenICode.TabIndex = 12;
@ -205,7 +206,7 @@
//
this.chkUnique.AutoSize = true;
this.chkUnique.Location = new System.Drawing.Point(503, 74);
this.chkUnique.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.chkUnique.Margin = new System.Windows.Forms.Padding(2);
this.chkUnique.Name = "chkUnique";
this.chkUnique.Size = new System.Drawing.Size(95, 17);
this.chkUnique.TabIndex = 13;
@ -218,7 +219,7 @@
this.btnMoves.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnMoves.Enabled = false;
this.btnMoves.Location = new System.Drawing.Point(495, 616);
this.btnMoves.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.btnMoves.Margin = new System.Windows.Forms.Padding(2);
this.btnMoves.Name = "btnMoves";
this.btnMoves.Size = new System.Drawing.Size(93, 23);
this.btnMoves.TabIndex = 14;
@ -350,7 +351,7 @@
//
this.btnSettings.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnSettings.Location = new System.Drawing.Point(20, 616);
this.btnSettings.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.btnSettings.Margin = new System.Windows.Forms.Padding(2);
this.btnSettings.Name = "btnSettings";
this.btnSettings.Size = new System.Drawing.Size(81, 23);
this.btnSettings.TabIndex = 26;
@ -409,6 +410,7 @@
this.txtExpPrefix.Size = new System.Drawing.Size(57, 20);
this.txtExpPrefix.TabIndex = 31;
this.txtExpPrefix.Text = "GWX_";
this.txtExpPrefix.TextChanged += new System.EventHandler(this.txtExpPrefix_TextChanged);
//
// chkAttribs
//

View File

@ -14,6 +14,7 @@ using System.Text.RegularExpressions;
using System.Reflection;
using System.IO;
using System.Resources;
using System.Xml.Serialization;
//---------------------------förändrings krav---------------------------
// 1.) Indexerande mellannivåer där count-måste sättas får inte hoppas över !
@ -39,6 +40,9 @@ namespace CobXmlSupport
private string indTemp = "";
private char[] splitChars = { '#' };
Dictionary<string, GenSetting> setObjs; // = new Dictionary<string, GenSetting>();
SaverListener sl;
//private string SettingUserName, SettingCompany;
////-------------------------
//private bool SettingNoNsRef;
@ -79,10 +83,21 @@ namespace CobXmlSupport
public GenCobCode()
{
InitializeComponent();
setObjs = new Dictionary<string, GenSetting>();
sl = new SaverListener();
sl.dict = setObjs;
}
private void button1_Click(object sender, EventArgs e)
{
S.ettingActualFile = cmbLastFile.Text.Substring(cmbLastFile.Text.LastIndexOf("\\") + 1);
GenSetting tmpGS = null;
sl.dict.TryGetValue(S.ettingActualFile, out tmpGS);
if (tmpGS != null)
{
tmpGS.SetSettings();
setLocalValues();
}
runXMLgen();
}
@ -100,6 +115,16 @@ namespace CobXmlSupport
if (cmbLastFile.Text.Length > 0)
{
S.ettingActualFile = cmbLastFile.Text.Substring(cmbLastFile.Text.LastIndexOf("\\") + 1);
//GenSetting tmpGS=null;
//sl.dict.TryGetValue(S.ettingActualFile, out tmpGS);
//if (tmpGS != null)
//{
// tmpGS.SetSettings();
// setLocalValues();
//}
S.ettingFilePath = cmbLastFile.Text.Substring(0,cmbLastFile.Text.LastIndexOf("\\"));
uniqueTags = new Dictionary<string, string>();
uniqueAttr = new Dictionary<string, string>();
uniqueVars = new Dictionary<string, string>();
@ -683,6 +708,29 @@ namespace CobXmlSupport
}
}
private void DeserializeMetaData()
{
string SavePath = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]).ToString();
GenSetting[] saveColl = null;
setObjs = new Dictionary<string, GenSetting>();
if (File.Exists(SavePath + "\\FilnamnsDict.xml"))
{
XmlSerializer x = new XmlSerializer(typeof(GenSetting[]));
StreamReader reader = new StreamReader(SavePath + "\\FilnamnsDict.xml");
saveColl = (GenSetting[])x.Deserialize(reader);
foreach (GenSetting g in saveColl)
{
setObjs.Add(g.ActualFile, g);
}
}
sl.dict = setObjs;
}
private void Form1_Load(object sender, EventArgs e)
{
@ -697,11 +745,24 @@ namespace CobXmlSupport
chkWrap.Checked = true;
chkNewArea.Checked = false;
cmbLastFile.Items.Clear();
foreach (string usedFile in Properties.Settings.Default.LastFile)
{
cmbLastFile.Items.Add(usedFile);
}
DeserializeMetaData();
if (sl.dict.Count > 0)
{
cmbLastFile.Items.Clear();
foreach (GenSetting x in sl.dict.Values)
{
cmbLastFile.Items.Add(x.FilePath + "\\" + x.ActualFile);
}
}
S.ettingUserName = Properties.Settings.Default.UserName;
S.ettingCompany = Properties.Settings.Default.CompanyName;
@ -741,6 +802,7 @@ namespace CobXmlSupport
{
cmbLastFile.Text = cmbLastFile.Items[0].ToString();
}
}
private void btnClose_Click(object sender, EventArgs e)
@ -1132,8 +1194,36 @@ namespace CobXmlSupport
Properties.Settings.Default.CompanyName = S.ettingCompany;
Properties.Settings.Default.UserName = S.ettingUserName;
Properties.Settings.Default.Save();
SerializeMetadata();
}
private void SerializeMetadata()
{
string SavePath = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]).ToString();
GenSetting[] saveColl = new GenSetting[setObjs.Count];
int i = 0;
foreach (GenSetting x in setObjs.Values)
{
saveColl[i++] = x;
}
try
{
XmlSerializer x = new XmlSerializer(saveColl.GetType());
StreamWriter writer = new StreamWriter(SavePath + "\\FilnamnsDict.xml", false);
x.Serialize(writer, saveColl);
MessageBox.Show("Objektet är serialiserat !(" + SavePath + "\\FilnamnsDict.xml)");
}
catch (Exception ex)
{
MessageBox.Show("Serialisering : " + ex.Message);
}
}
private void btnClearSettings_Click(object sender, EventArgs e)
{
cmbLastFile.Items.Clear();
@ -1142,11 +1232,13 @@ namespace CobXmlSupport
private void chkWrap_CheckedChanged(object sender, EventArgs e)
{
S.ettingWrap = chkWrap.Checked;
if (!eventRun) runXMLgen();
}
private void chkNoNsRef_CheckedChanged(object sender, EventArgs e)
{
S.ettingNoNsRef = chkNoNsRef.Checked;
if (!eventRun)
{
eventRun = true;
@ -1158,31 +1250,37 @@ namespace CobXmlSupport
private void chkAnaTag_CheckedChanged(object sender, EventArgs e)
{
S.ettingAnaTag = chkAnaTag.Checked;
if (!eventRun) runXMLgen();
}
private void chkValues_CheckedChanged(object sender, EventArgs e)
{
S.ettingValues = chkValues.Checked;
if (!eventRun) runXMLgen();
}
private void chkUniqueAttrVars_CheckedChanged(object sender, EventArgs e)
{
S.ettingUniqueAttrVars = chkUniqueAttrVars.Checked;
if (!eventRun) runXMLgen();
}
private void chkUnique_CheckedChanged(object sender, EventArgs e)
{
S.ettingUnique = chkUnique.Checked;
if (!eventRun) runXMLgen();
}
private void chkUniqueVars_CheckedChanged(object sender, EventArgs e)
{
S.ettingUniqueVars = chkUniqueVars.Checked;
if (!eventRun) runXMLgen();
}
private void chkCountVars_CheckedChanged(object sender, EventArgs e)
{
S.ettingCountVars = chkCountVars.Checked;
if (!eventRun) runXMLgen();
}
@ -1191,52 +1289,79 @@ namespace CobXmlSupport
if (setWindow == null)
{
setWindow = new frmSettings();
setWindow.SL = this.sl;
setWindow.SettingObj = new GenSetting();
}
eventRun = true;
setWindow.UserName = S.ettingUserName;
setWindow.CompanyName = S.ettingCompany;
//setWindow.UserName = S.ettingUserName;
//setWindow.CompanyName = S.ettingCompany;
setWindow.AktualFile = S.ettingActualFile;
setWindow.FilePath = S.ettingFilePath;
//setWindow.AktualFile = S.ettingActualFile;
//setWindow.FilePath = S.ettingFilePath;
setWindow.ChkNoNsRef = S.ettingNoNsRef;
setWindow.ChkUniqueVars = S.ettingUniqueVars;
setWindow.ChkUniqueAttrVars = S.ettingUniqueAttrVars;
setWindow.ChkUnique = S.ettingUnique;
setWindow.ChkWrap = S.ettingWrap;
setWindow.ChkValues = S.ettingValues;
setWindow.ChkAnaTag = S.ettingAnaTag;
setWindow.TxtPrefix = S.ettingPrefix;
setWindow.TxtExpPrefix = S.ettingExpPrefix;
setWindow.TxtMaxOcc = S.ettingMaxOcc;
setWindow.ChkCountVars = S.ettingCountVars;
setWindow.LogPost = S.ettingLogVarName;
setWindow.LogSection = S.ettingLogSectName;
setWindow.ChkShowTestbtns = S.ettingSpecials;
setWindow.ChkBackupOwnCode = S.ettingUserCodeBcup;
//setWindow.ChkNoNsRef = S.ettingNoNsRef;
//setWindow.ChkUniqueVars = S.ettingUniqueVars;
//setWindow.ChkUniqueAttrVars = S.ettingUniqueAttrVars;
//setWindow.ChkUnique = S.ettingUnique;
//setWindow.ChkWrap = S.ettingWrap;
//setWindow.ChkValues = S.ettingValues;
//setWindow.ChkAnaTag = S.ettingAnaTag;
//setWindow.TxtPrefix = S.ettingPrefix;
//setWindow.TxtExpPrefix = S.ettingExpPrefix;
//setWindow.TxtMaxOcc = S.ettingMaxOcc;
//setWindow.ChkCountVars = S.ettingCountVars;
//setWindow.LogPost = S.ettingLogVarName;
//setWindow.LogSection = S.ettingLogSectName;
//setWindow.ChkShowTestbtns = S.ettingSpecials;
//setWindow.ChkBackupOwnCode = S.ettingUserCodeBcup;
setWindow.ShowDialog();
S.ettingUserName = setWindow.UserName;
S.ettingCompany = setWindow.CompanyName;
S.ettingNoNsRef = setWindow.ChkNoNsRef;
S.ettingUniqueVars = setWindow.ChkUniqueVars;
S.ettingUniqueAttrVars = setWindow.ChkUniqueAttrVars;
S.ettingUnique = setWindow.ChkUnique;
S.ettingWrap = setWindow.ChkWrap;
S.ettingValues = setWindow.ChkValues;
S.ettingAnaTag = setWindow.ChkAnaTag;
S.ettingPrefix = setWindow.TxtPrefix;
S.ettingExpPrefix = setWindow.TxtExpPrefix;
S.ettingMaxOcc = setWindow.TxtMaxOcc;
S.ettingCountVars = setWindow.ChkCountVars;
S.ettingLogVarName = setWindow.LogPost;
S.ettingLogSectName = setWindow.LogSection;
S.ettingSpecials = setWindow.ChkShowTestbtns;
S.ettingUserCodeBcup = setWindow.ChkBackupOwnCode;
//S.ettingUserName = setWindow.UserName;
//S.ettingCompany = setWindow.CompanyName;
//S.ettingNoNsRef = setWindow.ChkNoNsRef;
//S.ettingUniqueVars = setWindow.ChkUniqueVars;
//S.ettingUniqueAttrVars = setWindow.ChkUniqueAttrVars;
//S.ettingUnique = setWindow.ChkUnique;
//S.ettingWrap = setWindow.ChkWrap;
//S.ettingValues = setWindow.ChkValues;
//S.ettingAnaTag = setWindow.ChkAnaTag;
//S.ettingPrefix = setWindow.TxtPrefix;
//S.ettingExpPrefix = setWindow.TxtExpPrefix;
//S.ettingMaxOcc = setWindow.TxtMaxOcc;
//S.ettingCountVars = setWindow.ChkCountVars;
//S.ettingLogVarName = setWindow.LogPost;
//S.ettingLogSectName = setWindow.LogSection;
//S.ettingSpecials = setWindow.ChkShowTestbtns;
//S.ettingUserCodeBcup = setWindow.ChkBackupOwnCode;
setLocalValues();
//chkAnaTag.Checked = S.ettingAnaTag;
//chkCountVars.Checked = S.ettingCountVars;
//chkDisplays.Checked = true;
//chkNoNsRef.Checked = S.ettingNoNsRef;
//chkUnique.Checked = S.ettingUnique;
//chkUniqueAttrVars.Checked = S.ettingUniqueAttrVars;
//chkUniqueVars.Checked = S.ettingUniqueVars;
//chkValues.Checked = S.ettingValues;
//chkWrap.Checked = S.ettingWrap;
//txtMaxOcc.Text = S.ettingMaxOcc;
//txtPrefix.Text = S.ettingPrefix;
//txtExpPrefix.Text = S.ettingExpPrefix;
//btnTestThings.Visible = S.ettingSpecials;
//chkBackupVars.Checked = S.ettingUserCodeBcup;
eventRun = false;
runXMLgen();
}
private void setLocalValues()
{
eventRun = true;
chkAnaTag.Checked = S.ettingAnaTag;
chkCountVars.Checked = S.ettingCountVars;
chkDisplays.Checked = true;
@ -1251,10 +1376,7 @@ namespace CobXmlSupport
txtExpPrefix.Text = S.ettingExpPrefix;
btnTestThings.Visible = S.ettingSpecials;
chkBackupVars.Checked = S.ettingUserCodeBcup;
eventRun = false;
runXMLgen();
}
@ -2166,5 +2288,16 @@ namespace CobXmlSupport
}
private void txtPrefix_TextChanged(object sender, EventArgs e)
{
S.ettingPrefix = txtPrefix.Text;
}
private void txtExpPrefix_TextChanged(object sender, EventArgs e)
{
S.ettingExpPrefix = txtExpPrefix.Text;
}
}
}

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace CobXmlSupport
{
public class GenSetting
public class GenSetting:ICloneable
{
public event SaveHandler evSave;
public EventArgs e = null;
@ -88,5 +88,13 @@ namespace CobXmlSupport
S.ettingUserCodeBcup = this.UserCodeBcup;
S.ettingBackupOwnCode = this.BcupOwnCode;
}
public object Clone()
{
GenSetting tmpGenSetting = new GenSetting();
tmpGenSetting = (GenSetting)this.MemberwiseClone();
return tmpGenSetting;
}
}
}

View File

@ -27,11 +27,11 @@ namespace CobXmlSupport
public static bool ettingSpecials;
public static bool ettingUserCodeBcup;
//-------------------------
// public static bool ettingShowTestbtns;
// public static bool ettingShowTestbtns;
//-------------------------
public static bool ettingBackupOwnCode;
public static string ettingActualFile;
public static string ettingFilePath;
//-------------------------
}
}
}

View File

@ -23,7 +23,13 @@ namespace CobXmlSupport
private void SaveMethod(GenSetting G, EventArgs e)
{
dict.Add(G.ActualFile, G);
GenSetting tmpGS = (GenSetting)G.Clone();
GenSetting tmpSett;
if (dict.TryGetValue(tmpGS.ActualFile, out tmpSett))
{
dict[tmpGS.ActualFile] = tmpGS;
}
else dict.Add(tmpGS.ActualFile, tmpGS);
}
}
}

View File

@ -31,8 +31,8 @@ namespace CobXmlSupport
//------------
private GenSetting genSet;
// private string aktualFile;
// private string filePath;
// private string aktualFile;
// private string filePath;
private SaverListener sl;
public string AktualFile
@ -43,7 +43,7 @@ namespace CobXmlSupport
}
set
{
txtActualFile.Text = value;
txtActualFile.Text = value;
}
}
@ -55,7 +55,7 @@ namespace CobXmlSupport
}
set
{
txtFilePath.Text = value;
txtFilePath.Text = value;
}
}
@ -240,7 +240,7 @@ namespace CobXmlSupport
}
public bool ChkBackupOwnCode
{
{
get
{
return chkBackupOwnCode.Checked;
@ -308,6 +308,9 @@ namespace CobXmlSupport
S.ettingBackupOwnCode = Properties.Settings.Default.BackupOwnCode = chkBackupOwnCode.Checked;
S.ettingLogVarName = Properties.Settings.Default.LogVarName = txtLogPost.Text;
S.ettingLogSectName = Properties.Settings.Default.LogSectName = txtLogSection.Text;
S.ettingUserName = Properties.Settings.Default.UserName = txtUserName.Text;
S.ettingCompany = Properties.Settings.Default.CompanyName = txtCompanyName.Text;
Properties.Settings.Default.Save();
this.genSet.GetSettings();
@ -318,45 +321,48 @@ namespace CobXmlSupport
private void frmSettings_Load(object sender, EventArgs e)
{
UserTmp = txtUserName.Text;
CompanyTmp = txtCompanyName.Text;
tmpChkNoNsRef = chkNoNsRef.Checked;
tmpChkUniqueVars = chkUniqueVars.Checked;
tmpChkUniqueAttrVars = chkUniqueAttrVars.Checked;
tmpChkUnique = chkUnique.Checked;
tmpChkWrap = chkWrap.Checked;
tmpChkValues = chkValues.Checked;
tmpChkAnaTag = chkAnaTag.Checked;
tmpShowTestBtns = chkShowTestbtns.Checked;
tmpBackupOwnCode = chkBackupOwnCode.Checked;
tmpTxtPrefix = txtPrefix.Text;
tmpTxtExpPrefix = txtExpPrefix.Text;
tmpTxtMaxOcc = txtMaxOcc.Text;
txtLogVarNameTmp = txtLogPost.Text ;
txtLogVarSectTmp = txtLogSection.Text;
this.AktualFile = S.ettingActualFile;
this.FilePath = S.ettingFilePath;
tmpChkAnaTag = chkAnaTag.Checked = S.ettingAnaTag;
tmpChkCountVars = chkCountVars.Checked = S.ettingCountVars;
tmpTxtMaxOcc = txtMaxOcc.Text = S.ettingMaxOcc;
tmpChkNoNsRef = chkNoNsRef.Checked = S.ettingNoNsRef;
tmpTxtPrefix = txtPrefix.Text = S.ettingPrefix;
tmpTxtExpPrefix = txtExpPrefix.Text = S.ettingExpPrefix;
tmpChkUnique = chkUnique.Checked = S.ettingUnique;
tmpChkUniqueAttrVars = chkUniqueAttrVars.Checked = S.ettingUniqueAttrVars;
tmpChkUniqueVars = chkUniqueVars.Checked = S.ettingUniqueVars;
tmpChkValues = chkValues.Checked = S.ettingValues;
tmpChkWrap = chkWrap.Checked = S.ettingWrap;
tmpShowTestBtns = chkShowTestbtns.Checked = S.ettingSpecials;
tmpBackupOwnCode = chkBackupOwnCode.Checked = S.ettingBackupOwnCode;
txtLogVarNameTmp = txtLogPost.Text = S.ettingLogVarName;
txtLogVarSectTmp = txtLogSection.Text = S.ettingLogSectName;
tmpChkCountVars = chkCountVars.Checked;
UserTmp = txtUserName.Text = S.ettingUserName;
CompanyTmp = txtCompanyName.Text = S.ettingCompany;
}
private void btnCancel_Click(object sender, EventArgs e)
{
txtUserName.Text = UserTmp;
txtCompanyName.Text = CompanyTmp;
chkNoNsRef.Checked= tmpChkNoNsRef;
chkUniqueVars.Checked= tmpChkUniqueVars;
chkUniqueAttrVars.Checked= tmpChkUniqueAttrVars ;
chkUnique.Checked= tmpChkUnique;
chkWrap.Checked= tmpChkWrap;
chkValues.Checked= tmpChkValues;
chkAnaTag.Checked= tmpChkAnaTag;
chkShowTestbtns.Checked = tmpShowTestBtns;
chkBackupOwnCode.Checked = tmpBackupOwnCode;
chkAnaTag.Checked = tmpChkAnaTag;
chkCountVars.Checked = tmpChkCountVars;
txtMaxOcc.Text = tmpTxtMaxOcc;
chkNoNsRef.Checked = tmpChkNoNsRef;
txtPrefix.Text = tmpTxtPrefix;
txtExpPrefix.Text = tmpTxtExpPrefix;
txtMaxOcc.Text = tmpTxtMaxOcc;
txtLogPost.Text= txtLogVarNameTmp;
txtLogSection.Text= txtLogVarSectTmp;
chkCountVars.Checked = tmpChkCountVars;
chkUnique.Checked = tmpChkUnique;
chkUniqueAttrVars.Checked = tmpChkUniqueAttrVars;
chkUniqueVars.Checked = tmpChkUniqueVars;
chkValues.Checked = tmpChkValues;
chkWrap.Checked = tmpChkWrap;
chkShowTestbtns.Checked = tmpShowTestBtns;
chkBackupOwnCode.Checked = tmpBackupOwnCode;
txtLogPost.Text = txtLogVarNameTmp;
txtLogSection.Text = txtLogVarSectTmp;
txtUserName.Text = UserTmp;
txtCompanyName.Text = CompanyTmp;
this.Close();
}