From 125709f4ff0a80287d88dfc3fac401107c51ce69 Mon Sep 17 00:00:00 2001 From: tfoman Date: Thu, 16 Jul 2015 20:40:34 +0200 Subject: [PATCH] Completed the S.ettings object with some more fields and checked the use of them --- CobXmlSupport/GenCobCode.Designer.cs | 1 + CobXmlSupport/GenCobCode.cs | 103 +++++++++--------------- CobXmlSupport/GenSetting.cs | 114 ++++++++++++++------------- CobXmlSupport/S.cs | 47 ++++++----- CobXmlSupport/frmSettings.cs | 4 +- 5 files changed, 122 insertions(+), 147 deletions(-) diff --git a/CobXmlSupport/GenCobCode.Designer.cs b/CobXmlSupport/GenCobCode.Designer.cs index 37228b0..a84ef11 100644 --- a/CobXmlSupport/GenCobCode.Designer.cs +++ b/CobXmlSupport/GenCobCode.Designer.cs @@ -271,6 +271,7 @@ this.txtMaxOcc.TabIndex = 18; this.txtMaxOcc.Text = "25"; this.txtMaxOcc.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.txtMaxOcc.TextChanged += new System.EventHandler(this.txtMaxOcc_TextChanged); // // chkUniqueAttrVars // diff --git a/CobXmlSupport/GenCobCode.cs b/CobXmlSupport/GenCobCode.cs index 79d4f49..edff0c7 100644 --- a/CobXmlSupport/GenCobCode.cs +++ b/CobXmlSupport/GenCobCode.cs @@ -735,6 +735,7 @@ namespace CobXmlSupport private void Form1_Load(object sender, EventArgs e) { formLoading = true; + chkValues.Checked = true; chkUnique.Checked = true; chkAnaTag.Checked = true; @@ -765,8 +766,6 @@ namespace CobXmlSupport S.ettingUserName = Properties.Settings.Default.UserName; S.ettingCompany = Properties.Settings.Default.CompanyName; - - S.ettingAnaTag = Properties.Settings.Default.AnaTag; S.ettingCountVars = Properties.Settings.Default.CountVars; S.ettingMaxOcc = Properties.Settings.Default.MaxOcc; @@ -780,7 +779,7 @@ namespace CobXmlSupport S.ettingWrap = Properties.Settings.Default.Wrap; S.ettingLogVarName = Properties.Settings.Default.LogVarName; S.ettingLogSectName = Properties.Settings.Default.LogSectName; - S.ettingSpecials = Properties.Settings.Default.ShowTestbtns; + S.ettingShowTestbtns = Properties.Settings.Default.ShowTestbtns; chkAnaTag.Checked = S.ettingAnaTag; chkCountVars.Checked = S.ettingCountVars; @@ -794,7 +793,7 @@ namespace CobXmlSupport chkUniqueVars.Checked = S.ettingUniqueVars; chkValues.Checked = S.ettingValues; chkWrap.Checked = S.ettingWrap; - btnTestThings.Visible = S.ettingSpecials; + btnTestThings.Visible = S.ettingShowTestbtns; formLoading = false; // cmbLastFile.Text = cmbLastFile.Items[0].ToString(); @@ -1180,6 +1179,22 @@ namespace CobXmlSupport private void cmbLastFile_SelectedIndexChanged(object sender, EventArgs e) { + if ( S.ettingActualFile != null) + { + GenSetting tmpSetting = new GenSetting(); + this.sl.Subscribe(tmpSetting); + tmpSetting.GetSettings(); + this.sl.UnSubscribe(tmpSetting); + } + 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(); } @@ -1295,66 +1310,10 @@ namespace CobXmlSupport eventRun = true; - //setWindow.UserName = S.ettingUserName; - //setWindow.CompanyName = S.ettingCompany; - - //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.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; - 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(); } @@ -1362,20 +1321,32 @@ namespace CobXmlSupport private void setLocalValues() { eventRun = true; - chkAnaTag.Checked = S.ettingAnaTag; - chkCountVars.Checked = S.ettingCountVars; - chkDisplays.Checked = true; + chkAnaTag.Checked = S.ettingAnaTag; chkAnaTag.Refresh(); + chkCountVars.Checked = S.ettingCountVars; chkCountVars.Refresh(); + chkDisplays.Checked = S.ettingDisplays; + chkDisplays.Refresh(); chkNoNsRef.Checked = S.ettingNoNsRef; + chkNoNsRef.Refresh(); chkUnique.Checked = S.ettingUnique; + chkUnique.Refresh(); chkUniqueAttrVars.Checked = S.ettingUniqueAttrVars; + chkUniqueAttrVars.Refresh(); chkUniqueVars.Checked = S.ettingUniqueVars; + chkUniqueVars.Refresh(); chkValues.Checked = S.ettingValues; + chkValues.Refresh(); chkWrap.Checked = S.ettingWrap; + chkWrap.Refresh(); txtMaxOcc.Text = S.ettingMaxOcc; + txtMaxOcc.Refresh(); txtPrefix.Text = S.ettingPrefix; + txtPrefix.Refresh(); txtExpPrefix.Text = S.ettingExpPrefix; - btnTestThings.Visible = S.ettingSpecials; + txtExpPrefix.Refresh(); + btnTestThings.Visible = S.ettingShowTestbtns; + btnTestThings.Refresh(); chkBackupVars.Checked = S.ettingUserCodeBcup; + chkBackupVars.Refresh(); eventRun = false; } @@ -2298,6 +2269,10 @@ namespace CobXmlSupport S.ettingExpPrefix = txtExpPrefix.Text; } + private void txtMaxOcc_TextChanged(object sender, EventArgs e) + { + S.ettingMaxOcc = txtMaxOcc.Text; + } } } diff --git a/CobXmlSupport/GenSetting.cs b/CobXmlSupport/GenSetting.cs index 6747a71..fc9abd5 100644 --- a/CobXmlSupport/GenSetting.cs +++ b/CobXmlSupport/GenSetting.cs @@ -6,57 +6,57 @@ using System.Threading.Tasks; namespace CobXmlSupport { - public class GenSetting:ICloneable + public class GenSetting : ICloneable { public event SaveHandler evSave; public EventArgs e = null; public delegate void SaveHandler(GenSetting G, EventArgs e); public string ActualFile { get; set; } - public string FilePath { get; set; } - - public string UserName { get; set; } - public string Company { get; set; } - public bool NoNsRef { get; set; } - public bool UniqueVars { get; set; } - public bool UniqueAttrVars { get; set; } - public bool Unique { get; set; } - public bool Wrap { get; set; } - public bool Values { get; set; } public bool AnaTag { get; set; } - public string Prefix { get; set; } - public string ExpPrefix { get; set; } - public string MaxOcc { get; set; } - public bool CountVars { get; set; } - public string LogVarName { get; set; } - public string LogSectName { get; set; } - public bool Specials { get; set; } - public bool UserCodeBcup { get; set; } public bool BcupOwnCode { get; set; } + public string Company { get; set; } + public bool CountVars { get; set; } + public bool Displays { get; set; } + public string ExpPrefix { get; set; } + public string FilePath { get; set; } + public string LogSectName { get; set; } + public string LogVarName { get; set; } + public string MaxOcc { get; set; } + public bool NoNsRef { get; set; } + public string Prefix { get; set; } + public bool Unique { get; set; } + public bool UniqueAttrVars { get; set; } + public bool UniqueVars { get; set; } + public bool UserCodeBcup { get; set; } + public string UserName { get; set; } + public bool Values { get; set; } + public bool Wrap { get; set; } + public bool ShowTestbtns { get; set; } public void GetSettings() { this.ActualFile = S.ettingActualFile; - this.FilePath = S.ettingFilePath; - - this.UserName = S.ettingUserName; - this.Company = S.ettingCompany; - this.NoNsRef = S.ettingNoNsRef; - this.UniqueVars = S.ettingUniqueVars; - this.UniqueAttrVars = S.ettingUniqueAttrVars; - this.Unique = S.ettingUnique; - this.Wrap = S.ettingWrap; - this.Values = S.ettingValues; this.AnaTag = S.ettingAnaTag; - this.Prefix = S.ettingPrefix; - this.ExpPrefix = S.ettingExpPrefix; - this.MaxOcc = S.ettingMaxOcc; - this.CountVars = S.ettingCountVars; - this.LogVarName = S.ettingLogVarName; - this.LogSectName = S.ettingLogSectName; - this.Specials = S.ettingSpecials; - this.UserCodeBcup = S.ettingUserCodeBcup; this.BcupOwnCode = S.ettingBackupOwnCode; + this.Company = S.ettingCompany; + this.CountVars = S.ettingCountVars; + this.Displays = S.ettingDisplays; + this.ExpPrefix = S.ettingExpPrefix; + this.FilePath = S.ettingFilePath; + this.LogSectName = S.ettingLogSectName; + this.LogVarName = S.ettingLogVarName; + this.MaxOcc = S.ettingMaxOcc; + this.NoNsRef = S.ettingNoNsRef; + this.Prefix = S.ettingPrefix; + this.Unique = S.ettingUnique; + this.UniqueAttrVars = S.ettingUniqueAttrVars; + this.UniqueVars = S.ettingUniqueVars; + this.UserCodeBcup = S.ettingUserCodeBcup; + this.UserName = S.ettingUserName; + this.Values = S.ettingValues; + this.Wrap = S.ettingWrap; + this.ShowTestbtns = S.ettingShowTestbtns; if (evSave != null) { @@ -66,27 +66,29 @@ namespace CobXmlSupport public void SetSettings() { - S.ettingActualFile =this.ActualFile ; - S.ettingFilePath = this.FilePath; - S.ettingUserName = this.UserName; - S.ettingCompany = this.Company; - S.ettingNoNsRef = this.NoNsRef; - S.ettingUniqueVars = this.UniqueVars; - S.ettingUniqueAttrVars = this.UniqueAttrVars; - S.ettingUnique = this.Unique; - S.ettingWrap = this.Wrap; - S.ettingValues = this.Values; - S.ettingAnaTag = this.AnaTag; - S.ettingPrefix = this.Prefix; - S.ettingExpPrefix = this.ExpPrefix; - S.ettingMaxOcc = this.MaxOcc; - S.ettingCountVars = this.CountVars; - S.ettingLogVarName = this.LogVarName; - S.ettingLogSectName = this.LogSectName; - S.ettingSpecials = this.Specials; - S.ettingUserCodeBcup = this.UserCodeBcup; + S.ettingActualFile = this.ActualFile; + S.ettingAnaTag = this.AnaTag; S.ettingBackupOwnCode = this.BcupOwnCode; + S.ettingCompany = this.Company; + S.ettingCountVars = this.CountVars; + S.ettingDisplays = this.Displays; + S.ettingExpPrefix = this.ExpPrefix; + S.ettingFilePath = this.FilePath; + S.ettingLogSectName = this.LogSectName; + S.ettingLogVarName = this.LogVarName; + S.ettingMaxOcc = this.MaxOcc; + S.ettingNoNsRef = this.NoNsRef; + S.ettingPrefix = this.Prefix; + S.ettingUnique = this.Unique; + S.ettingUniqueAttrVars = this.UniqueAttrVars; + S.ettingUniqueVars = this.UniqueVars; + S.ettingUserCodeBcup = this.UserCodeBcup; + S.ettingUserName = this.UserName; + S.ettingValues = this.Values; + S.ettingWrap = this.Wrap; + S.ettingShowTestbtns = this.ShowTestbtns; + } public object Clone() diff --git a/CobXmlSupport/S.cs b/CobXmlSupport/S.cs index f77a1e6..2cddf2a 100644 --- a/CobXmlSupport/S.cs +++ b/CobXmlSupport/S.cs @@ -7,31 +7,28 @@ using System.Xml.Serialization; namespace CobXmlSupport { - public static class S + public static class S { - public static string ettingUserName; - public static string ettingCompany; - public static bool ettingNoNsRef; - public static bool ettingUniqueVars; - public static bool ettingUniqueAttrVars; - public static bool ettingUnique; - public static bool ettingWrap; - public static bool ettingValues; - public static bool ettingAnaTag; - public static string ettingPrefix; - public static string ettingExpPrefix; - public static string ettingMaxOcc; - public static bool ettingCountVars; - public static string ettingLogVarName; - public static string ettingLogSectName; - public static bool ettingSpecials; - public static bool ettingUserCodeBcup; - //------------------------- - // public static bool ettingShowTestbtns; - //------------------------- - public static bool ettingBackupOwnCode; public static string ettingActualFile; + public static bool ettingAnaTag; + public static bool ettingBackupOwnCode; + public static string ettingCompany; + public static bool ettingCountVars; + public static bool ettingDisplays; + public static string ettingExpPrefix; public static string ettingFilePath; - //------------------------- - } -} + public static string ettingLogSectName; + public static string ettingLogVarName; + public static string ettingMaxOcc; + public static bool ettingNoNsRef; + public static string ettingPrefix; + public static bool ettingUnique; + public static bool ettingUniqueAttrVars; + public static bool ettingUniqueVars; + public static bool ettingUserCodeBcup; + public static string ettingUserName; + public static bool ettingValues; + public static bool ettingWrap; + public static bool ettingShowTestbtns; + } +} \ No newline at end of file diff --git a/CobXmlSupport/frmSettings.cs b/CobXmlSupport/frmSettings.cs index cc3330f..192cd4d 100644 --- a/CobXmlSupport/frmSettings.cs +++ b/CobXmlSupport/frmSettings.cs @@ -304,7 +304,7 @@ namespace CobXmlSupport S.ettingUniqueVars = Properties.Settings.Default.UniqueVars = chkUniqueVars.Checked; S.ettingValues = Properties.Settings.Default.Values = chkValues.Checked; S.ettingWrap = Properties.Settings.Default.Wrap = chkWrap.Checked; - S.ettingSpecials = Properties.Settings.Default.ShowTestbtns = chkShowTestbtns.Checked; + S.ettingShowTestbtns = Properties.Settings.Default.ShowTestbtns = chkShowTestbtns.Checked; S.ettingBackupOwnCode = Properties.Settings.Default.BackupOwnCode = chkBackupOwnCode.Checked; S.ettingLogVarName = Properties.Settings.Default.LogVarName = txtLogPost.Text; S.ettingLogSectName = Properties.Settings.Default.LogSectName = txtLogSection.Text; @@ -334,7 +334,7 @@ namespace CobXmlSupport tmpChkUniqueVars = chkUniqueVars.Checked = S.ettingUniqueVars; tmpChkValues = chkValues.Checked = S.ettingValues; tmpChkWrap = chkWrap.Checked = S.ettingWrap; - tmpShowTestBtns = chkShowTestbtns.Checked = S.ettingSpecials; + tmpShowTestBtns = chkShowTestbtns.Checked = S.ettingShowTestbtns; tmpBackupOwnCode = chkBackupOwnCode.Checked = S.ettingBackupOwnCode; txtLogVarNameTmp = txtLogPost.Text = S.ettingLogVarName; txtLogVarSectTmp = txtLogSection.Text = S.ettingLogSectName;