From 691cbf23e37cab2763e001b29af2c508d3c7ea85 Mon Sep 17 00:00:00 2001 From: tfoman Date: Fri, 17 Jul 2015 15:19:11 +0200 Subject: [PATCH] Generated files saves and registers --- CobXmlSupport/CobXmlSupport.csproj | 9 ++ CobXmlSupport/GenCobCode.cs | 54 +++++++- CobXmlSupport/GenSetting.cs | 11 +- CobXmlSupport/S.cs | 65 ++++++++-- CobXmlSupport/SaveRegCopyFile.Designer.cs | 147 ++++++++++++++++++++++ CobXmlSupport/SaveRegCopyFile.cs | 69 ++++++++++ CobXmlSupport/SaveRegCopyFile.resx | 123 ++++++++++++++++++ CobXmlSupport/ShowCode.Designer.cs | 13 ++ CobXmlSupport/ShowCode.cs | 10 ++ 9 files changed, 487 insertions(+), 14 deletions(-) create mode 100644 CobXmlSupport/SaveRegCopyFile.Designer.cs create mode 100644 CobXmlSupport/SaveRegCopyFile.cs create mode 100644 CobXmlSupport/SaveRegCopyFile.resx diff --git a/CobXmlSupport/CobXmlSupport.csproj b/CobXmlSupport/CobXmlSupport.csproj index 35b34a7..060c2de 100644 --- a/CobXmlSupport/CobXmlSupport.csproj +++ b/CobXmlSupport/CobXmlSupport.csproj @@ -70,6 +70,12 @@ + + Form + + + SaveRegCopyFile.cs + Form @@ -93,6 +99,9 @@ Resources.resx True + + SaveRegCopyFile.cs + ShowCode.cs diff --git a/CobXmlSupport/GenCobCode.cs b/CobXmlSupport/GenCobCode.cs index 15e6f96..0f8ee1a 100644 --- a/CobXmlSupport/GenCobCode.cs +++ b/CobXmlSupport/GenCobCode.cs @@ -98,6 +98,10 @@ namespace CobXmlSupport tmpGS.SetSettings(); setLocalValues(); } + else + { + S.ettingList = null; + } runXMLgen(); } @@ -822,6 +826,13 @@ namespace CobXmlSupport genCode = new ShowCode(); genCode.Parent = this; genCode.Labeltext = "Creating Initialization Code"; + + savedFile SF = new savedFile(); + SF.idConnect = "A472C801-2A7A-4A09-B432-8F16504964C3"; + SF.usageName = "Usage007.cpy"; + genCode.SavedFile = SF; + + string inFile = cmbLastFile.Text.Substring(cmbLastFile.Text.LastIndexOf("\\") + 1); CreateComment(genCode.CodeShower, "Initializer", S.ettingUserName, S.ettingCompany, inFile); foreach (CobRow cr in rowList) @@ -871,6 +882,12 @@ namespace CobXmlSupport genCode = new ShowCode(); genCode.Parent = this; genCode.Labeltext = "Creating Initialization Code"; + + savedFile SF = new savedFile(); + SF.idConnect = "15E1040B-2206-4F02-8212-FE9DF6B209B8"; + SF.usageName = "Usage008.cpy"; + genCode.SavedFile = SF; + string inFile = cmbLastFile.Text.Substring(cmbLastFile.Text.LastIndexOf("\\") + 1); CreateComment(genCode.CodeShower, "Initializer", S.ettingUserName, S.ettingCompany, inFile); genCode.CodeShower.Text += "\r\n"; @@ -1408,6 +1425,12 @@ namespace CobXmlSupport genExtMoves = new ShowCode(); genExtMoves.Parent = this; genExtMoves.Labeltext = "Creating \"move to (with loop)\" Code"; + + savedFile SF = new savedFile(); + SF.idConnect = "6EFF8B31-7F88-4A81-B94E-41D54A3D3197"; + SF.usageName = "Usage001.cpy"; + genExtMoves.SavedFile = SF; + bool adj = false; int prfNiv = 0; @@ -1646,6 +1669,12 @@ namespace CobXmlSupport fromMoves = new ShowCode(); fromMoves.Parent = this; fromMoves.Labeltext = "Creating \"move from\" Code"; + + savedFile SF = new savedFile(); + SF.idConnect = "9C3E8CC7-FA20-4E11-8E81-73BE8D2E9CFB"; + SF.usageName = "Usage002.cpy"; + fromMoves.SavedFile = SF; + bool adj = false; foreach (CobRow cr in rowList) @@ -1817,6 +1846,12 @@ namespace CobXmlSupport fromToMoves = new ShowCode(); fromToMoves.Parent = this; fromToMoves.Labeltext = "Creating \"move From - To\" Code"; + + savedFile SF = new savedFile(); + SF.idConnect = "0A975654-75C6-4A8C-8534-AA16F46BC740"; + SF.usageName = "Usage003.cpy"; + fromMoves.SavedFile = SF; + bool adj = false; bool valueSwitch = false; @@ -2067,6 +2102,12 @@ namespace CobXmlSupport fromToMoves.Parent = this; fromToMoves.Labeltext = "Created \"move From \" Code"; + savedFile SF = new savedFile(); + SF.idConnect = "598A5F20-9A8A-415D-81B2-BBFE04465381"; + SF.usageName = "Usage004.cpy"; + fromToMoves.SavedFile = SF; + + //Dictionary for indexes, init IndexState class and list for qualifiedHelper class Dictionary testIndexes = new Dictionary(); IndexState lIs = new IndexState(testIndexes, rowList); @@ -2195,12 +2236,17 @@ namespace CobXmlSupport private void btnTestThings_Click(object sender, EventArgs e) { - //Create showing window + //Create showing window loadResWords(); fromToMoves = new ShowCode(); fromToMoves.Parent = this; fromToMoves.Labeltext = "Cobol \"reserved\" Words"; + savedFile SF = new savedFile(); + SF.idConnect = "DD5A8C24-C322-4901-85B5-776DD6E21FB9"; + SF.usageName = "Usage005.cpy"; + fromToMoves.SavedFile = SF; + foreach (string str in CobResWords.ToArray()) { if (fromToMoves.CodeShower.Text == "") { } @@ -2210,6 +2256,7 @@ namespace CobXmlSupport fromToMoves.Show(); //createXMLMoveCode(); + func_exit:; } private void loadResWords() @@ -2234,6 +2281,11 @@ namespace CobXmlSupport fromToMoves.BSynch = true; fromToMoves.Labeltext = "Cobol \"CrossRef\" List"; + savedFile SF = new savedFile(); + SF.idConnect = "1C1FAE9D-39DD-4A24-A6C2-8696EAE3CB32"; + SF.usageName = "Usage006.cpy"; + fromToMoves.SavedFile = SF; + foreach (CobRow cr in rowList) { if (cr.CobLevel < 2) diff --git a/CobXmlSupport/GenSetting.cs b/CobXmlSupport/GenSetting.cs index e31abb2..fe62df3 100644 --- a/CobXmlSupport/GenSetting.cs +++ b/CobXmlSupport/GenSetting.cs @@ -34,6 +34,7 @@ namespace CobXmlSupport public bool Values { get; set; } public bool Wrap { get; set; } public bool ShowTestbtns { get; set; } + public savedFile[] fileList { get; set; } public void GetSettings() { @@ -59,6 +60,7 @@ namespace CobXmlSupport this.Values = S.ettingValues; this.Wrap = S.ettingWrap; this.ShowTestbtns = S.ettingShowTestbtns; + this.fileList = S.ettingList==null?null:S.ettingList.ToArray(); if (evSave != null) { @@ -91,7 +93,14 @@ namespace CobXmlSupport S.ettingValues = this.Values; S.ettingWrap = this.Wrap; S.ettingShowTestbtns = this.ShowTestbtns; - + if (this.fileList != null) + { + foreach (savedFile locSF in this.fileList) + { + S.ettingListAdd(locSF); + } + } + else S.ettingList = null; } public object Clone() diff --git a/CobXmlSupport/S.cs b/CobXmlSupport/S.cs index ade04a4..9181f13 100644 --- a/CobXmlSupport/S.cs +++ b/CobXmlSupport/S.cs @@ -9,27 +9,68 @@ namespace CobXmlSupport { public static class S { - public static string ettingActualFile; public static bool ettingAnaTag; - public static string ettingCompany; public static bool ettingCountVars; public static bool ettingDisplays; + public static bool ettingMvToDisp; + public static bool ettingNoNsRef; + public static bool ettingPerform; + public static bool ettingShowTestbtns; + public static bool ettingUnique; + public static bool ettingUniqueAttrVars; + public static bool ettingUniqueVars; + public static bool ettingUserCodeBcup; + public static bool ettingValues; + public static bool ettingWrap; + public static string ettingActualFile; + public static string ettingCompany; public static string ettingExpPrefix; public static string ettingFilePath; public static string ettingLogSectName; public static string ettingLogVarName; public static string ettingMaxOcc; - public static bool ettingMvToDisp; - public static bool ettingNoNsRef; - public static bool ettingPerform; 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; + public static List ettingList; + + public static void ettingListAdd(savedFile f) + { + bool upd = false; + if (S.ettingList == null) + { + S.ettingList = new List(); + S.ettingList.Add(f); + upd = true; + } + else + { + for (int i = 0; i < S.ettingList.Count; i++) + { + if (S.ettingList.ToArray()[i].idConnect == f.idConnect) + { + S.ettingList[i] = f; + upd = true; + } + } + } + if (!upd) S.ettingList.Add(f); + } } + + public class savedFile : ICloneable + { + public string idConnect; + public string usageName; + public string directorySaved; + public string fNameSaved; + + + public object Clone() + { + savedFile tmpSF = new savedFile(); + tmpSF = (savedFile)this.MemberwiseClone(); + return tmpSF; + } + } + } \ No newline at end of file diff --git a/CobXmlSupport/SaveRegCopyFile.Designer.cs b/CobXmlSupport/SaveRegCopyFile.Designer.cs new file mode 100644 index 0000000..6a83a13 --- /dev/null +++ b/CobXmlSupport/SaveRegCopyFile.Designer.cs @@ -0,0 +1,147 @@ +namespace CobXmlSupport +{ + partial class SaveRegCopyFile + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.txtUsageName = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.btnChooseFnameAndPlace = new System.Windows.Forms.Button(); + this.txtChosenDirectory = new System.Windows.Forms.TextBox(); + this.txtFileName = new System.Windows.Forms.TextBox(); + this.btnSave = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.Location = new System.Drawing.Point(29, 26); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(134, 20); + this.label1.TabIndex = 0; + this.label1.Text = "Spara aktuell fil"; + // + // txtUsageName + // + this.txtUsageName.Location = new System.Drawing.Point(167, 68); + this.txtUsageName.Name = "txtUsageName"; + this.txtUsageName.Size = new System.Drawing.Size(308, 20); + this.txtUsageName.TabIndex = 1; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(30, 71); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(95, 13); + this.label2.TabIndex = 2; + this.label2.Text = "Användningsnamn"; + // + // btnChooseFnameAndPlace + // + this.btnChooseFnameAndPlace.Location = new System.Drawing.Point(33, 104); + this.btnChooseFnameAndPlace.Name = "btnChooseFnameAndPlace"; + this.btnChooseFnameAndPlace.Size = new System.Drawing.Size(92, 23); + this.btnChooseFnameAndPlace.TabIndex = 3; + this.btnChooseFnameAndPlace.Text = "Välj sparplats"; + this.btnChooseFnameAndPlace.UseVisualStyleBackColor = true; + this.btnChooseFnameAndPlace.Click += new System.EventHandler(this.btnChooseFnameAndPlace_Click); + // + // txtChosenDirectory + // + this.txtChosenDirectory.Location = new System.Drawing.Point(167, 104); + this.txtChosenDirectory.Name = "txtChosenDirectory"; + this.txtChosenDirectory.ReadOnly = true; + this.txtChosenDirectory.Size = new System.Drawing.Size(308, 20); + this.txtChosenDirectory.TabIndex = 4; + // + // txtFileName + // + this.txtFileName.Location = new System.Drawing.Point(167, 142); + this.txtFileName.Name = "txtFileName"; + this.txtFileName.ReadOnly = true; + this.txtFileName.Size = new System.Drawing.Size(308, 20); + this.txtFileName.TabIndex = 5; + // + // btnSave + // + this.btnSave.Location = new System.Drawing.Point(400, 183); + this.btnSave.Name = "btnSave"; + this.btnSave.Size = new System.Drawing.Size(75, 23); + this.btnSave.TabIndex = 6; + this.btnSave.Text = "Spara"; + this.btnSave.UseVisualStyleBackColor = true; + this.btnSave.Click += new System.EventHandler(this.btnSave_Click); + // + // btnCancel + // + this.btnCancel.Location = new System.Drawing.Point(319, 183); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 23); + this.btnCancel.TabIndex = 7; + this.btnCancel.Text = "Avbryt"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // SaveRegCopyFile + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(503, 233); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnSave); + this.Controls.Add(this.txtFileName); + this.Controls.Add(this.txtChosenDirectory); + this.Controls.Add(this.btnChooseFnameAndPlace); + this.Controls.Add(this.label2); + this.Controls.Add(this.txtUsageName); + this.Controls.Add(this.label1); + this.Name = "SaveRegCopyFile"; + this.Text = "Spara och Registrera skapad fil"; + this.Load += new System.EventHandler(this.SaveRegCopyFile_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox txtUsageName; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button btnChooseFnameAndPlace; + private System.Windows.Forms.TextBox txtChosenDirectory; + private System.Windows.Forms.TextBox txtFileName; + private System.Windows.Forms.Button btnSave; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.SaveFileDialog saveFileDialog; + } +} \ No newline at end of file diff --git a/CobXmlSupport/SaveRegCopyFile.cs b/CobXmlSupport/SaveRegCopyFile.cs new file mode 100644 index 0000000..1c1b16b --- /dev/null +++ b/CobXmlSupport/SaveRegCopyFile.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.IO; +using System.Windows.Forms; + +namespace CobXmlSupport +{ + public partial class SaveRegCopyFile : Form + { + public savedFile SavedFile { get; set; } + public string FileData { get; set; } + + public SaveRegCopyFile() + { + InitializeComponent(); + } + + private void btnChooseFnameAndPlace_Click(object sender, EventArgs e) + { + saveFileDialog.Title = "Välj plats för den aktuella filen !"; + saveFileDialog.Filter = "Copy files (*.cpy)|*.cpy|Text Files (*.txt)|*.txt|All files (*.*)|*.*"; + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + SavedFile.fNameSaved = txtFileName.Text = saveFileDialog.FileName.Substring(saveFileDialog.FileName.LastIndexOf("\\") + 1); ; + SavedFile.directorySaved = txtChosenDirectory.Text = saveFileDialog.FileName.Substring(0, saveFileDialog.FileName.LastIndexOf("\\")); + if (SavedFile.idConnect.Length > 0) + { + btnSave.Enabled = true; + } + else MessageBox.Show("idConnect för filtypen saknas !"); + } + } + + private void btnSave_Click(object sender, EventArgs e) + { + try + { + File.WriteAllText(saveFileDialog.FileName, FileData); + savedFile tmpSF = new savedFile(); + tmpSF = (savedFile)SavedFile.Clone(); + S.ettingListAdd(tmpSF); + this.Close(); + } + catch (Exception ex) + { + MessageBox.Show("Problem att spara :\r\n" + ex.Message); + } + } + + private void btnCancel_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void SaveRegCopyFile_Load(object sender, EventArgs e) + { + txtUsageName.Text = SavedFile.usageName; + txtChosenDirectory.Text = ""; + txtFileName.Text = ""; + btnSave.Enabled = false; + + } + } +} diff --git a/CobXmlSupport/SaveRegCopyFile.resx b/CobXmlSupport/SaveRegCopyFile.resx new file mode 100644 index 0000000..5e7f0a6 --- /dev/null +++ b/CobXmlSupport/SaveRegCopyFile.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/CobXmlSupport/ShowCode.Designer.cs b/CobXmlSupport/ShowCode.Designer.cs index e7aa6a8..eb55c64 100644 --- a/CobXmlSupport/ShowCode.Designer.cs +++ b/CobXmlSupport/ShowCode.Designer.cs @@ -34,6 +34,7 @@ this.lblCodeType = new System.Windows.Forms.Label(); this.btnSynch = new System.Windows.Forms.Button(); this.btnSynchOut = new System.Windows.Forms.Button(); + this.btnSaveAktualText = new System.Windows.Forms.Button(); this.SuspendLayout(); // // btnClose @@ -99,11 +100,22 @@ this.btnSynchOut.Visible = false; this.btnSynchOut.Click += new System.EventHandler(this.btnSynchOut_Click); // + // btnSaveAktualText + // + this.btnSaveAktualText.Location = new System.Drawing.Point(12, 642); + this.btnSaveAktualText.Name = "btnSaveAktualText"; + this.btnSaveAktualText.Size = new System.Drawing.Size(83, 23); + this.btnSaveAktualText.TabIndex = 5; + this.btnSaveAktualText.Text = "Spara Copy"; + this.btnSaveAktualText.UseVisualStyleBackColor = true; + this.btnSaveAktualText.Click += new System.EventHandler(this.btnSaveAktualText_Click); + // // ShowCode // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(670, 674); + this.Controls.Add(this.btnSaveAktualText); this.Controls.Add(this.btnSynchOut); this.Controls.Add(this.btnSynch); this.Controls.Add(this.lblCodeType); @@ -125,5 +137,6 @@ private System.Windows.Forms.Label lblCodeType; private System.Windows.Forms.Button btnSynch; private System.Windows.Forms.Button btnSynchOut; + private System.Windows.Forms.Button btnSaveAktualText; } } \ No newline at end of file diff --git a/CobXmlSupport/ShowCode.cs b/CobXmlSupport/ShowCode.cs index 8ce5d36..69acb2b 100644 --- a/CobXmlSupport/ShowCode.cs +++ b/CobXmlSupport/ShowCode.cs @@ -24,6 +24,8 @@ namespace CobXmlSupport string oldTxt; bool bSynch; + public savedFile SavedFile { get; set; } + public ShowCode() { InitializeComponent(); @@ -328,5 +330,13 @@ namespace CobXmlSupport this.CodeShower.Text = " InPath = " + Cc.PathId + "\r\n InFile = " + Cc.FileId + "\r\n codeFile = " + Cc.CcFileOutId + "\r\n codePath = " + Cc.PathId + Cc.CcFileOutId + "\r\n -------------- \r\n" + this.CodeShower.Text; } + private void btnSaveAktualText_Click(object sender, EventArgs e) + { + SaveRegCopyFile saveWin = new SaveRegCopyFile(); + saveWin.SavedFile = this.SavedFile; + saveWin.FileData = this.txtCode.Text; + saveWin.ShowDialog(); + } + } }