diff --git a/Vlimport/Form1.Designer.cs b/Vlimport/Form1.Designer.cs index 7a9abe7..486b2de 100644 --- a/Vlimport/Form1.Designer.cs +++ b/Vlimport/Form1.Designer.cs @@ -62,6 +62,7 @@ this.AcceptButton.TabIndex = 2; this.AcceptButton.Text = "Добавить значения"; this.AcceptButton.UseVisualStyleBackColor = true; + this.AcceptButton.Click += new System.EventHandler(this.AcceptButton_Click); // // FilePathBox // diff --git a/Vlimport/Form1.cs b/Vlimport/Form1.cs index 0acb707..f3b1190 100644 --- a/Vlimport/Form1.cs +++ b/Vlimport/Form1.cs @@ -39,5 +39,11 @@ namespace Vlimport Transporter tr = new Transporter(); tr.CollectItems(filename, ItemList); } + + private void AcceptButton_Click(object sender, EventArgs e) + { + Transporter trr = new Transporter(); + trr.addItems(); + } } } diff --git a/Vlimport/Transporter.cs b/Vlimport/Transporter.cs index 1c64b0a..b82daf7 100644 --- a/Vlimport/Transporter.cs +++ b/Vlimport/Transporter.cs @@ -14,6 +14,8 @@ namespace Vlimport { public class Transporter { + static List operations = new List(); //Объявляю список + public void CollectItems(string filePath, ListBox Itemlist) { @@ -28,7 +30,6 @@ namespace Vlimport foreach (XmlNode oper in mySearch) { - List operations = new List(); //Объявляю список //Operations operation = new Operations(); @@ -37,8 +38,6 @@ namespace Vlimport var operId = oper.XPath2SelectSingleNode("//Attribute[@Name='indexoper']").Attributes["Value"].Value; var operName = oper.XPath2SelectSingleNode("//Attribute[@Name='nameoper']").Attributes["Value"].Value; - //Itemlist.Items.Add($"{operId} {operName}"); // Тут мы добавляем название операций прямо в листвью - operations.Add(new Operations(operId, operName)); foreach (XmlNode step in oper.XPath2SelectNodes("//Object[ends-with(@Name,'_step')]")) @@ -46,18 +45,28 @@ namespace Vlimport var stepNum = step.XPath2SelectSingleNode("//Attribute[@Name='numstep']").Attributes["Value"].Value; var stepName = step.XPath2SelectSingleNode("//Attribute[@Name='name']").Attributes["Value"].Value; - //Itemlist.Items.Add($" {stepNum}. {stepName}"); // Тут добавляем название переходов в листвью - operations.Add(new Operations(stepNum, stepName)); } - foreach (Operations op in operations) - { - Itemlist.Items.Add(op); - } + + } + foreach (Operations op in operations) + { + Itemlist.Items.Add(op); + } + + } + + public void addItems() + { + using (TextWriter tw = new StreamWriter("SavedList.txt")) + { + foreach (Operations oop in operations) + tw.WriteLine(oop); } } + } }