diff --git a/CobXmlSupport/CobXmlSupport.csproj b/CobXmlSupport/CobXmlSupport.csproj index 812df95..35b34a7 100644 --- a/CobXmlSupport/CobXmlSupport.csproj +++ b/CobXmlSupport/CobXmlSupport.csproj @@ -62,6 +62,7 @@ GenCobCode.cs + @@ -69,6 +70,7 @@ + Form diff --git a/CobXmlSupport/GenCobCode.cs b/CobXmlSupport/GenCobCode.cs index cf8c55f..71c2a51 100644 --- a/CobXmlSupport/GenCobCode.cs +++ b/CobXmlSupport/GenCobCode.cs @@ -20,6 +20,7 @@ using System.Resources; // // // ====== BEFORE IMPLEMENTATION OF SAVER ============== +// ====== IMPLEMENTATION OF SAVER STARTED ============= //---------------------------------------------------------------------- namespace CobXmlSupport { @@ -1197,6 +1198,9 @@ namespace CobXmlSupport 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; @@ -1214,6 +1218,7 @@ namespace CobXmlSupport setWindow.ChkBackupOwnCode = S.ettingUserCodeBcup; setWindow.ShowDialog(); + S.ettingUserName = setWindow.UserName; S.ettingCompany = setWindow.CompanyName; S.ettingNoNsRef = setWindow.ChkNoNsRef; diff --git a/CobXmlSupport/GenSetting.cs b/CobXmlSupport/GenSetting.cs new file mode 100644 index 0000000..a1db6d9 --- /dev/null +++ b/CobXmlSupport/GenSetting.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CobXmlSupport +{ + public class GenSetting + { + 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 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; + + if (evSave != null) + { + evSave(this, e); + } + } + + 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.ettingBackupOwnCode = this.BcupOwnCode; + } + } +} diff --git a/CobXmlSupport/S.cs b/CobXmlSupport/S.cs index e658e4b..9aa22a2 100644 --- a/CobXmlSupport/S.cs +++ b/CobXmlSupport/S.cs @@ -27,5 +27,11 @@ namespace CobXmlSupport public static bool ettingSpecials; public static bool ettingUserCodeBcup; //------------------------- + // public static bool ettingShowTestbtns; + public static bool ettingBackupOwnCode; + public static string ettingActualFile; + public static string ettingFilePath; + //------------------------- + } } diff --git a/CobXmlSupport/SaverListener.cs b/CobXmlSupport/SaverListener.cs new file mode 100644 index 0000000..c754673 --- /dev/null +++ b/CobXmlSupport/SaverListener.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CobXmlSupport +{ + public class SaverListener + { + + public Dictionary dict { get; set; } + + public void Subscribe(GenSetting G) + { + G.evSave += new GenSetting.SaveHandler(SaveMethod); + } + + public void UnSubscribe(GenSetting G) + { + G.evSave -= new GenSetting.SaveHandler(SaveMethod); + } + + private void SaveMethod(GenSetting G, EventArgs e) + { + dict.Add(G.ActualFile, G); + } + } +} diff --git a/CobXmlSupport/frmSettings.Designer.cs b/CobXmlSupport/frmSettings.Designer.cs index 71eda9d..e336508 100644 --- a/CobXmlSupport/frmSettings.Designer.cs +++ b/CobXmlSupport/frmSettings.Designer.cs @@ -57,8 +57,12 @@ this.txtLogSection = new System.Windows.Forms.TextBox(); this.label7 = new System.Windows.Forms.Label(); this.specials = new System.Windows.Forms.GroupBox(); - this.chkShowTestbtns = new System.Windows.Forms.CheckBox(); this.chkBackupOwnCode = new System.Windows.Forms.CheckBox(); + this.chkShowTestbtns = new System.Windows.Forms.CheckBox(); + this.txtActualFile = new System.Windows.Forms.TextBox(); + this.txtFilePath = new System.Windows.Forms.TextBox(); + this.label9 = new System.Windows.Forms.Label(); + this.label10 = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.specials.SuspendLayout(); @@ -67,7 +71,7 @@ // btnCancel // this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnCancel.Location = new System.Drawing.Point(487, 370); + this.btnCancel.Location = new System.Drawing.Point(467, 416); this.btnCancel.Margin = new System.Windows.Forms.Padding(2); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(79, 24); @@ -79,7 +83,7 @@ // btnSave // this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnSave.Location = new System.Drawing.Point(403, 370); + this.btnSave.Location = new System.Drawing.Point(383, 416); this.btnSave.Margin = new System.Windows.Forms.Padding(2); this.btnSave.Name = "btnSave"; this.btnSave.Size = new System.Drawing.Size(79, 24); @@ -110,7 +114,7 @@ // // txtUserName // - this.txtUserName.Location = new System.Drawing.Point(101, 42); + this.txtUserName.Location = new System.Drawing.Point(108, 41); this.txtUserName.Margin = new System.Windows.Forms.Padding(2); this.txtUserName.Name = "txtUserName"; this.txtUserName.Size = new System.Drawing.Size(195, 20); @@ -118,7 +122,7 @@ // // txtCompanyName // - this.txtCompanyName.Location = new System.Drawing.Point(101, 62); + this.txtCompanyName.Location = new System.Drawing.Point(108, 61); this.txtCompanyName.Margin = new System.Windows.Forms.Padding(2); this.txtCompanyName.Name = "txtCompanyName"; this.txtCompanyName.Size = new System.Drawing.Size(195, 20); @@ -254,6 +258,8 @@ // // groupBox1 // + this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.groupBox1.Controls.Add(this.txtExpPrefix); this.groupBox1.Controls.Add(this.label8); this.groupBox1.Controls.Add(this.label5); @@ -268,9 +274,9 @@ this.groupBox1.Controls.Add(this.chkWrap); this.groupBox1.Controls.Add(this.label4); this.groupBox1.Controls.Add(this.chkUnique); - this.groupBox1.Location = new System.Drawing.Point(15, 110); + this.groupBox1.Location = new System.Drawing.Point(15, 157); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(304, 255); + this.groupBox1.Size = new System.Drawing.Size(287, 260); this.groupBox1.TabIndex = 39; this.groupBox1.TabStop = false; this.groupBox1.Text = "Utgångs inställningar"; @@ -294,13 +300,14 @@ // // groupBox2 // + this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.groupBox2.Controls.Add(this.label6); this.groupBox2.Controls.Add(this.txtLogPost); this.groupBox2.Controls.Add(this.txtLogSection); this.groupBox2.Controls.Add(this.label7); - this.groupBox2.Location = new System.Drawing.Point(325, 110); + this.groupBox2.Location = new System.Drawing.Point(306, 157); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(240, 99); + this.groupBox2.Size = new System.Drawing.Size(240, 104); this.groupBox2.TabIndex = 40; this.groupBox2.TabStop = false; this.groupBox2.Text = "Namn på generella variabler och procedurer"; @@ -340,25 +347,16 @@ // // specials // + this.specials.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.specials.Controls.Add(this.chkBackupOwnCode); this.specials.Controls.Add(this.chkShowTestbtns); - this.specials.Location = new System.Drawing.Point(325, 216); + this.specials.Location = new System.Drawing.Point(305, 263); this.specials.Name = "specials"; this.specials.Size = new System.Drawing.Size(240, 149); this.specials.TabIndex = 41; this.specials.TabStop = false; this.specials.Text = "specialla inställningar"; // - // chkShowTestbtns - // - this.chkShowTestbtns.AutoSize = true; - this.chkShowTestbtns.Location = new System.Drawing.Point(7, 20); - this.chkShowTestbtns.Name = "chkShowTestbtns"; - this.chkShowTestbtns.Size = new System.Drawing.Size(95, 17); - this.chkShowTestbtns.TabIndex = 0; - this.chkShowTestbtns.Text = "visa testknapp"; - this.chkShowTestbtns.UseVisualStyleBackColor = true; - // // chkBackupOwnCode // this.chkBackupOwnCode.AutoSize = true; @@ -369,11 +367,63 @@ this.chkBackupOwnCode.Text = "Backup av Egna vars"; this.chkBackupOwnCode.UseVisualStyleBackColor = true; // + // chkShowTestbtns + // + this.chkShowTestbtns.AutoSize = true; + this.chkShowTestbtns.Location = new System.Drawing.Point(7, 20); + this.chkShowTestbtns.Name = "chkShowTestbtns"; + this.chkShowTestbtns.Size = new System.Drawing.Size(95, 17); + this.chkShowTestbtns.TabIndex = 0; + this.chkShowTestbtns.Text = "visa testknapp"; + this.chkShowTestbtns.UseVisualStyleBackColor = true; + // + // txtActualFile + // + this.txtActualFile.ForeColor = System.Drawing.SystemColors.WindowFrame; + this.txtActualFile.Location = new System.Drawing.Point(108, 82); + this.txtActualFile.Name = "txtActualFile"; + this.txtActualFile.ReadOnly = true; + this.txtActualFile.Size = new System.Drawing.Size(425, 20); + this.txtActualFile.TabIndex = 42; + // + // txtFilePath + // + this.txtFilePath.ForeColor = System.Drawing.SystemColors.WindowFrame; + this.txtFilePath.Location = new System.Drawing.Point(108, 103); + this.txtFilePath.Name = "txtFilePath"; + this.txtFilePath.ReadOnly = true; + this.txtFilePath.Size = new System.Drawing.Size(425, 20); + this.txtFilePath.TabIndex = 43; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(14, 107); + this.label9.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(93, 13); + this.label9.TabIndex = 45; + this.label9.Text = "Urspr Filens Path :"; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(12, 86); + this.label10.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(83, 13); + this.label10.TabIndex = 44; + this.label10.Text = "Aktuell Urspr Fil:"; + // // frmSettings // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(577, 399); + this.ClientSize = new System.Drawing.Size(557, 445); + this.Controls.Add(this.label9); + this.Controls.Add(this.label10); + this.Controls.Add(this.txtFilePath); + this.Controls.Add(this.txtActualFile); this.Controls.Add(this.specials); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); @@ -432,5 +482,9 @@ private System.Windows.Forms.GroupBox specials; private System.Windows.Forms.CheckBox chkShowTestbtns; private System.Windows.Forms.CheckBox chkBackupOwnCode; + private System.Windows.Forms.TextBox txtActualFile; + private System.Windows.Forms.TextBox txtFilePath; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.Label label10; } } \ No newline at end of file diff --git a/CobXmlSupport/frmSettings.cs b/CobXmlSupport/frmSettings.cs index 71c34e7..128d096 100644 --- a/CobXmlSupport/frmSettings.cs +++ b/CobXmlSupport/frmSettings.cs @@ -29,7 +29,61 @@ namespace CobXmlSupport private string txtLogVarNameTmp; private string txtLogVarSectTmp; + //------------ + private GenSetting genSet; + // private string aktualFile; + // private string filePath; + private SaverListener sl; + public string AktualFile + { + get + { + return txtActualFile.Text; + } + set + { + txtActualFile.Text = value; + } + } + + public string FilePath + { + get + { + return txtFilePath.Text; + } + set + { + txtFilePath.Text = value; + } + } + + public GenSetting SettingObj + { + get + { + return genSet; + } + set + { + genSet = value; + } + } + + public SaverListener SL + { + get + { + return sl; + } + set + { + sl = value; + } + } + + //------------ public frmSettings() { InitializeComponent(); @@ -235,23 +289,30 @@ namespace CobXmlSupport private void btnSave_Click(object sender, EventArgs e) { - Properties.Settings.Default.AnaTag = chkAnaTag.Checked; - Properties.Settings.Default.CountVars = chkCountVars.Checked; - Properties.Settings.Default.MaxOcc = txtMaxOcc.Text; - Properties.Settings.Default.NoNsRef = chkNoNsRef.Checked; - Properties.Settings.Default.Prefix = txtPrefix.Text; - Properties.Settings.Default.ExpPrefix = txtExpPrefix.Text; - Properties.Settings.Default.Unique = chkUnique.Checked; - Properties.Settings.Default.UniqueAttrVars = chkUniqueAttrVars.Checked; - Properties.Settings.Default.UniqueVars = chkUniqueVars.Checked; - Properties.Settings.Default.Values = chkValues.Checked; - Properties.Settings.Default.Wrap = chkWrap.Checked; - Properties.Settings.Default.ShowTestbtns= chkShowTestbtns.Checked; - Properties.Settings.Default.BackupOwnCode = chkBackupOwnCode.Checked; - Properties.Settings.Default.LogVarName = txtLogPost.Text; - Properties.Settings.Default.LogSectName = txtLogSection.Text; - Properties.Settings.Default.Save(); + sl.Subscribe(this.genSet); + S.ettingActualFile = this.AktualFile; + S.ettingFilePath = this.FilePath; + S.ettingAnaTag = Properties.Settings.Default.AnaTag = chkAnaTag.Checked; + S.ettingCountVars = Properties.Settings.Default.CountVars = chkCountVars.Checked; + S.ettingMaxOcc = Properties.Settings.Default.MaxOcc = txtMaxOcc.Text; + S.ettingNoNsRef = Properties.Settings.Default.NoNsRef = chkNoNsRef.Checked; + S.ettingPrefix = Properties.Settings.Default.Prefix = txtPrefix.Text; + S.ettingExpPrefix = Properties.Settings.Default.ExpPrefix = txtExpPrefix.Text; + S.ettingUnique = Properties.Settings.Default.Unique = chkUnique.Checked; + S.ettingUniqueAttrVars = Properties.Settings.Default.UniqueAttrVars = chkUniqueAttrVars.Checked; + 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.ettingBackupOwnCode = Properties.Settings.Default.BackupOwnCode = chkBackupOwnCode.Checked; + S.ettingLogVarName = Properties.Settings.Default.LogVarName = txtLogPost.Text; + S.ettingLogSectName = Properties.Settings.Default.LogSectName = txtLogSection.Text; + Properties.Settings.Default.Save(); + + this.genSet.GetSettings(); + + this.sl.UnSubscribe(this.genSet); this.Close(); }