diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.Designer.cs b/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.Designer.cs index 29e2812..ae11658 100644 --- a/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.Designer.cs +++ b/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.Designer.cs @@ -28,229 +28,224 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - this.maskedTextBoxNumber = new System.Windows.Forms.MaskedTextBox(); - this.ButtonRefreshCollection = new System.Windows.Forms.Button(); - this.ButtonRemoveLocomotive = new System.Windows.Forms.Button(); - this.ButtonAddLocomotive = new System.Windows.Forms.Button(); - this.pictureBoxCollections = new System.Windows.Forms.PictureBox(); - this.textBoxStorageName = new System.Windows.Forms.TextBox(); - this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components); - this.bindingSource2 = new System.Windows.Forms.BindingSource(this.components); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.listBoxStorage = new System.Windows.Forms.ListBox(); - this.ButtonAddObject = new System.Windows.Forms.Button(); - this.ButtonRemoveObject = new System.Windows.Forms.Button(); - this.Instruments = new System.Windows.Forms.GroupBox(); - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); - this.файлToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.SaveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.LoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); - this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollections)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.bindingSource2)).BeginInit(); - this.groupBox1.SuspendLayout(); - this.Instruments.SuspendLayout(); - this.menuStrip1.SuspendLayout(); - this.SuspendLayout(); + components = new System.ComponentModel.Container(); + maskedTextBoxNumber = new MaskedTextBox(); + ButtonRefreshCollection = new Button(); + ButtonRemoveLocomotive = new Button(); + ButtonAddLocomotive = new Button(); + pictureBoxCollections = new PictureBox(); + textBoxStorageName = new TextBox(); + bindingSource1 = new BindingSource(components); + bindingSource2 = new BindingSource(components); + groupBox1 = new GroupBox(); + listBoxStorage = new ListBox(); + ButtonAddObject = new Button(); + ButtonRemoveObject = new Button(); + Instruments = new GroupBox(); + menuStrip1 = new MenuStrip(); + файлToolStripMenuItem = new ToolStripMenuItem(); + SaveToolStripMenuItem = new ToolStripMenuItem(); + LoadToolStripMenuItem = new ToolStripMenuItem(); + saveFileDialog = new SaveFileDialog(); + openFileDialog = new OpenFileDialog(); + ((System.ComponentModel.ISupportInitialize)pictureBoxCollections).BeginInit(); + ((System.ComponentModel.ISupportInitialize)bindingSource1).BeginInit(); + ((System.ComponentModel.ISupportInitialize)bindingSource2).BeginInit(); + groupBox1.SuspendLayout(); + Instruments.SuspendLayout(); + menuStrip1.SuspendLayout(); + SuspendLayout(); // // maskedTextBoxNumber // - this.maskedTextBoxNumber.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.maskedTextBoxNumber.Location = new System.Drawing.Point(38, 532); - this.maskedTextBoxNumber.Mask = "0"; - this.maskedTextBoxNumber.Name = "maskedTextBoxNumber"; - this.maskedTextBoxNumber.Size = new System.Drawing.Size(156, 27); - this.maskedTextBoxNumber.TabIndex = 4; + maskedTextBoxNumber.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + maskedTextBoxNumber.Location = new Point(38, 532); + maskedTextBoxNumber.Mask = "0"; + maskedTextBoxNumber.Name = "maskedTextBoxNumber"; + maskedTextBoxNumber.Size = new Size(156, 27); + maskedTextBoxNumber.TabIndex = 4; // // ButtonRefreshCollection // - this.ButtonRefreshCollection.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.ButtonRefreshCollection.Font = new System.Drawing.Font("Candara Light", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.ButtonRefreshCollection.Location = new System.Drawing.Point(45, 663); - this.ButtonRefreshCollection.Name = "ButtonRefreshCollection"; - this.ButtonRefreshCollection.Size = new System.Drawing.Size(150, 41); - this.ButtonRefreshCollection.TabIndex = 2; - this.ButtonRefreshCollection.Text = "Обновить все"; - this.ButtonRefreshCollection.UseVisualStyleBackColor = true; + ButtonRefreshCollection.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + ButtonRefreshCollection.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point); + ButtonRefreshCollection.Location = new Point(45, 663); + ButtonRefreshCollection.Name = "ButtonRefreshCollection"; + ButtonRefreshCollection.Size = new Size(150, 41); + ButtonRefreshCollection.TabIndex = 2; + ButtonRefreshCollection.Text = "Обновить все"; + ButtonRefreshCollection.UseVisualStyleBackColor = true; // // ButtonRemoveLocomotive // - this.ButtonRemoveLocomotive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.ButtonRemoveLocomotive.Font = new System.Drawing.Font("Candara Light", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.ButtonRemoveLocomotive.Location = new System.Drawing.Point(45, 590); - this.ButtonRemoveLocomotive.Name = "ButtonRemoveLocomotive"; - this.ButtonRemoveLocomotive.Size = new System.Drawing.Size(150, 44); - this.ButtonRemoveLocomotive.TabIndex = 1; - this.ButtonRemoveLocomotive.Text = "Удалить локо"; - this.ButtonRemoveLocomotive.UseVisualStyleBackColor = true; - this.ButtonRemoveLocomotive.Click += new System.EventHandler(this.ButtonRemoveLocomotive_Click); + ButtonRemoveLocomotive.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + ButtonRemoveLocomotive.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point); + ButtonRemoveLocomotive.Location = new Point(45, 590); + ButtonRemoveLocomotive.Name = "ButtonRemoveLocomotive"; + ButtonRemoveLocomotive.Size = new Size(150, 44); + ButtonRemoveLocomotive.TabIndex = 1; + ButtonRemoveLocomotive.Text = "Удалить локо"; + ButtonRemoveLocomotive.UseVisualStyleBackColor = true; + ButtonRemoveLocomotive.Click += ButtonRemoveLocomotive_Click; // // ButtonAddLocomotive // - this.ButtonAddLocomotive.Anchor = System.Windows.Forms.AnchorStyles.Top; - this.ButtonAddLocomotive.Font = new System.Drawing.Font("Candara Light", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.ButtonAddLocomotive.Location = new System.Drawing.Point(42, 461); - this.ButtonAddLocomotive.Name = "ButtonAddLocomotive"; - this.ButtonAddLocomotive.Size = new System.Drawing.Size(150, 39); - this.ButtonAddLocomotive.TabIndex = 0; - this.ButtonAddLocomotive.Text = "Добавить локо"; - this.ButtonAddLocomotive.UseVisualStyleBackColor = true; - this.ButtonAddLocomotive.Click += new System.EventHandler(this.ButtonAddLocomotive_Click); + ButtonAddLocomotive.Anchor = AnchorStyles.Top; + ButtonAddLocomotive.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point); + ButtonAddLocomotive.Location = new Point(42, 461); + ButtonAddLocomotive.Name = "ButtonAddLocomotive"; + ButtonAddLocomotive.Size = new Size(150, 39); + ButtonAddLocomotive.TabIndex = 0; + ButtonAddLocomotive.Text = "Добавить локо"; + ButtonAddLocomotive.UseVisualStyleBackColor = true; + ButtonAddLocomotive.Click += ButtonAddLocomotive_Click; // // pictureBoxCollections // - this.pictureBoxCollections.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.pictureBoxCollections.Location = new System.Drawing.Point(-1, 27); - this.pictureBoxCollections.Name = "pictureBoxCollections"; - this.pictureBoxCollections.Size = new System.Drawing.Size(1104, 692); - this.pictureBoxCollections.TabIndex = 1; - this.pictureBoxCollections.TabStop = false; + pictureBoxCollections.Anchor = AnchorStyles.Left; + pictureBoxCollections.Location = new Point(-1, 27); + pictureBoxCollections.Name = "pictureBoxCollections"; + pictureBoxCollections.Size = new Size(1104, 692); + pictureBoxCollections.TabIndex = 1; + pictureBoxCollections.TabStop = false; // // textBoxStorageName // - this.textBoxStorageName.Location = new System.Drawing.Point(31, 43); - this.textBoxStorageName.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.textBoxStorageName.Name = "textBoxStorageName"; - this.textBoxStorageName.Size = new System.Drawing.Size(149, 27); - this.textBoxStorageName.TabIndex = 5; + textBoxStorageName.Location = new Point(31, 43); + textBoxStorageName.Margin = new Padding(3, 4, 3, 4); + textBoxStorageName.Name = "textBoxStorageName"; + textBoxStorageName.Size = new Size(149, 27); + textBoxStorageName.TabIndex = 5; // // groupBox1 // - this.groupBox1.Controls.Add(this.listBoxStorage); - this.groupBox1.Controls.Add(this.ButtonAddObject); - this.groupBox1.Controls.Add(this.ButtonRemoveObject); - this.groupBox1.Controls.Add(this.textBoxStorageName); - this.groupBox1.Location = new System.Drawing.Point(7, 29); - this.groupBox1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.groupBox1.Size = new System.Drawing.Size(216, 395); - this.groupBox1.TabIndex = 5; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Наборы"; + groupBox1.Controls.Add(listBoxStorage); + groupBox1.Controls.Add(ButtonAddObject); + groupBox1.Controls.Add(ButtonRemoveObject); + groupBox1.Controls.Add(textBoxStorageName); + groupBox1.Location = new Point(7, 29); + groupBox1.Margin = new Padding(3, 4, 3, 4); + groupBox1.Name = "groupBox1"; + groupBox1.Padding = new Padding(3, 4, 3, 4); + groupBox1.Size = new Size(216, 395); + groupBox1.TabIndex = 5; + groupBox1.TabStop = false; + groupBox1.Text = "Наборы"; // // listBoxStorage // - this.listBoxStorage.FormattingEnabled = true; - this.listBoxStorage.ItemHeight = 20; - this.listBoxStorage.Location = new System.Drawing.Point(31, 163); - this.listBoxStorage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.listBoxStorage.Name = "listBoxStorage"; - this.listBoxStorage.Size = new System.Drawing.Size(149, 124); - this.listBoxStorage.TabIndex = 9; - this.listBoxStorage.SelectedIndexChanged += new System.EventHandler(this.listBoxStorage_SelectedIndexChanged); + listBoxStorage.FormattingEnabled = true; + listBoxStorage.ItemHeight = 20; + listBoxStorage.Location = new Point(31, 163); + listBoxStorage.Margin = new Padding(3, 4, 3, 4); + listBoxStorage.Name = "listBoxStorage"; + listBoxStorage.Size = new Size(149, 124); + listBoxStorage.TabIndex = 9; + listBoxStorage.SelectedIndexChanged += listBoxStorage_SelectedIndexChanged; // // ButtonAddObject // - this.ButtonAddObject.Anchor = System.Windows.Forms.AnchorStyles.Top; - this.ButtonAddObject.Font = new System.Drawing.Font("Candara Light", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.ButtonAddObject.Location = new System.Drawing.Point(31, 96); - this.ButtonAddObject.Name = "ButtonAddObject"; - this.ButtonAddObject.Size = new System.Drawing.Size(150, 39); - this.ButtonAddObject.TabIndex = 7; - this.ButtonAddObject.Text = "Добавить набор"; - this.ButtonAddObject.UseVisualStyleBackColor = true; - this.ButtonAddObject.Click += new System.EventHandler(this.ButtonAddObject_Click); + ButtonAddObject.Anchor = AnchorStyles.Top; + ButtonAddObject.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point); + ButtonAddObject.Location = new Point(31, 96); + ButtonAddObject.Name = "ButtonAddObject"; + ButtonAddObject.Size = new Size(150, 39); + ButtonAddObject.TabIndex = 7; + ButtonAddObject.Text = "Добавить набор"; + ButtonAddObject.UseVisualStyleBackColor = true; + ButtonAddObject.Click += ButtonAddObject_Click; // // ButtonRemoveObject // - this.ButtonRemoveObject.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.ButtonRemoveObject.Font = new System.Drawing.Font("Candara Light", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.ButtonRemoveObject.Location = new System.Drawing.Point(31, 325); - this.ButtonRemoveObject.Name = "ButtonRemoveObject"; - this.ButtonRemoveObject.Size = new System.Drawing.Size(150, 44); - this.ButtonRemoveObject.TabIndex = 8; - this.ButtonRemoveObject.Text = "Удалить набор"; - this.ButtonRemoveObject.UseVisualStyleBackColor = true; - this.ButtonRemoveObject.Click += new System.EventHandler(this.ButtonRemoveObject_Click); + ButtonRemoveObject.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + ButtonRemoveObject.Font = new Font("Candara Light", 9F, FontStyle.Regular, GraphicsUnit.Point); + ButtonRemoveObject.Location = new Point(31, 325); + ButtonRemoveObject.Name = "ButtonRemoveObject"; + ButtonRemoveObject.Size = new Size(150, 44); + ButtonRemoveObject.TabIndex = 8; + ButtonRemoveObject.Text = "Удалить набор"; + ButtonRemoveObject.UseVisualStyleBackColor = true; + ButtonRemoveObject.Click += ButtonRemoveObject_Click; // // Instruments // - this.Instruments.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.Instruments.Controls.Add(this.ButtonRefreshCollection); - this.Instruments.Controls.Add(this.groupBox1); - this.Instruments.Controls.Add(this.maskedTextBoxNumber); - this.Instruments.Controls.Add(this.ButtonAddLocomotive); - this.Instruments.Controls.Add(this.ButtonRemoveLocomotive); - this.Instruments.Location = new System.Drawing.Point(1102, 0); - this.Instruments.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.Instruments.Name = "Instruments"; - this.Instruments.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.Instruments.Size = new System.Drawing.Size(236, 719); - this.Instruments.TabIndex = 6; - this.Instruments.TabStop = false; - this.Instruments.Text = "Инструменты"; + Instruments.Anchor = AnchorStyles.Right; + Instruments.Controls.Add(ButtonRefreshCollection); + Instruments.Controls.Add(groupBox1); + Instruments.Controls.Add(maskedTextBoxNumber); + Instruments.Controls.Add(ButtonAddLocomotive); + Instruments.Controls.Add(ButtonRemoveLocomotive); + Instruments.Location = new Point(1102, 0); + Instruments.Margin = new Padding(3, 4, 3, 4); + Instruments.Name = "Instruments"; + Instruments.Padding = new Padding(3, 4, 3, 4); + Instruments.Size = new Size(236, 719); + Instruments.TabIndex = 6; + Instruments.TabStop = false; + Instruments.Text = "Инструменты"; // // menuStrip1 // - this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.файлToolStripMenuItem}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(1338, 28); - this.menuStrip1.TabIndex = 7; - this.menuStrip1.Text = "menuStrip1"; + menuStrip1.ImageScalingSize = new Size(20, 20); + menuStrip1.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Size = new Size(1338, 28); + menuStrip1.TabIndex = 7; + menuStrip1.Text = "menuStrip1"; // // файлToolStripMenuItem // - this.файлToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.SaveToolStripMenuItem, - this.LoadToolStripMenuItem}); - this.файлToolStripMenuItem.Name = "файлToolStripMenuItem"; - this.файлToolStripMenuItem.Size = new System.Drawing.Size(59, 24); - this.файлToolStripMenuItem.Text = "Файл"; + файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SaveToolStripMenuItem, LoadToolStripMenuItem }); + файлToolStripMenuItem.Name = "файлToolStripMenuItem"; + файлToolStripMenuItem.Size = new Size(59, 24); + файлToolStripMenuItem.Text = "Файл"; // // SaveToolStripMenuItem // - this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem"; - this.SaveToolStripMenuItem.Size = new System.Drawing.Size(224, 26); - this.SaveToolStripMenuItem.Text = "Сохранить"; - this.SaveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click); + SaveToolStripMenuItem.Name = "SaveToolStripMenuItem"; + SaveToolStripMenuItem.Size = new Size(166, 26); + SaveToolStripMenuItem.Text = "Сохранить"; + SaveToolStripMenuItem.Click += SaveToolStripMenuItem_Click; // // LoadToolStripMenuItem // - this.LoadToolStripMenuItem.Name = "LoadToolStripMenuItem"; - this.LoadToolStripMenuItem.Size = new System.Drawing.Size(224, 26); - this.LoadToolStripMenuItem.Text = "Загрузить"; - this.LoadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click); + LoadToolStripMenuItem.Name = "LoadToolStripMenuItem"; + LoadToolStripMenuItem.Size = new Size(166, 26); + LoadToolStripMenuItem.Text = "Загрузить"; + LoadToolStripMenuItem.Click += LoadToolStripMenuItem_Click; // // saveFileDialog // - this.saveFileDialog.Filter = "txt file | *.txt"; + saveFileDialog.Filter = "txt file | *.txt"; // // openFileDialog // - this.openFileDialog.FileName = "openFileDialog1"; - this.openFileDialog.Filter = "txt file | *.txt"; + openFileDialog.FileName = "openFileDialog1"; + openFileDialog.Filter = "txt file | *.txt"; // // FormLocomotiveCollections // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1338, 724); - this.Controls.Add(this.Instruments); - this.Controls.Add(this.pictureBoxCollections); - this.Controls.Add(this.menuStrip1); - this.MainMenuStrip = this.menuStrip1; - this.Name = "FormLocomotiveCollections"; - this.Text = "Набор локомотивов"; - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollections)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.bindingSource2)).EndInit(); - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); - this.Instruments.ResumeLayout(false); - this.Instruments.PerformLayout(); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1338, 724); + Controls.Add(Instruments); + Controls.Add(pictureBoxCollections); + Controls.Add(menuStrip1); + MainMenuStrip = menuStrip1; + Name = "FormLocomotiveCollections"; + Text = "Набор локомотивов"; + ((System.ComponentModel.ISupportInitialize)pictureBoxCollections).EndInit(); + ((System.ComponentModel.ISupportInitialize)bindingSource1).EndInit(); + ((System.ComponentModel.ISupportInitialize)bindingSource2).EndInit(); + groupBox1.ResumeLayout(false); + groupBox1.PerformLayout(); + Instruments.ResumeLayout(false); + Instruments.PerformLayout(); + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ResumeLayout(false); + PerformLayout(); } #endregion diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.resx b/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.resx index 170c13e..f2c8442 100644 --- a/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.resx +++ b/ProjectElectricLocomotive/ProjectElectricLocomotive/FormLocomotiveCollections.resx @@ -1,4 +1,64 @@ - + + + @@ -73,6 +133,6 @@ 615, 17 - 144 + 84 \ No newline at end of file diff --git a/ProjectElectricLocomotive/ProjectElectricLocomotive/LocomotiveGenericStorage.cs b/ProjectElectricLocomotive/ProjectElectricLocomotive/LocomotiveGenericStorage.cs index b0bf07c..70be0c9 100644 --- a/ProjectElectricLocomotive/ProjectElectricLocomotive/LocomotiveGenericStorage.cs +++ b/ProjectElectricLocomotive/ProjectElectricLocomotive/LocomotiveGenericStorage.cs @@ -119,10 +119,9 @@ namespace ProjectElectricLocomotive.Generics return false; } using StreamWriter fs = new StreamWriter(filename); - - foreach(var str in _locomotivesStorage) { - fs.WriteLine($"LocomotiveStorage{Environment.NewLine}{data}"); + fs.WriteLine($"LocomotiveStorage{Environment.NewLine}"); + fs.WriteLine(data); } return true; } @@ -137,60 +136,53 @@ namespace ProjectElectricLocomotive.Generics { return false; } - //string bufferTextFromFile = ""; - //using (FileStream fs = new(filename, FileMode.Open)) + using (StreamReader fs = File.OpenText(filename)) - { - /* byte[] b = new byte[fs.Length]; - UTF8Encoding temp = new(true);*/ - /*while (fs.Read(b, 0, b.Length) > 0) - { - bufferTextFromFile += temp.GetString(b); - }*//* - List strsh = new List(); - - string str; - while ((str = fs.ReadLine()) != null) - { - Console.WriteLine(str); - strsh.Add(str); - }*/ - string? str = fs.ReadLine(); + string str = fs.ReadLine(); if (str == null || str.Length == 0) { return false; } - if (!str.Contains("LocomotiveStorage")) + if (!str.StartsWith("LocomotiveStorage")) { //если нет такой записи, то это не те данные return false; } _locomotivesStorage.Clear(); + string strs = ""; - foreach(string data in str) + bool firstinit = true; + + while ((strs = fs.ReadLine()) != null) { - string[] record = data.Split(_separatorForKeyValue, - StringSplitOptions.RemoveEmptyEntries); + if (strs == null && firstinit) + { + return false; + } + else if (strs == null) + { + break; + } + firstinit = false; + + string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries); if (record.Length != 2) { continue; } - LocomotiveGenericCollection - collection = new(_pictureWidth, _pictureHeight); - string[] set = record[1].Split(_separatorRecords, - StringSplitOptions.RemoveEmptyEntries); + LocomotiveGenericCollection collection = new(_pictureWidth, _pictureHeight); + string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries); foreach (string elem in set) { - DrawingLocomotive? loco = - elem?.CreateDrawingLocomotive(_separatorForObject, _pictureWidth, _pictureHeight); + DrawingLocomotive? loco = elem?.CreateDrawingLocomotive(_separatorForObject, _pictureWidth, _pictureHeight); if (loco != null) { - if ((collection + loco) != -1) // or vice versa + if ((collection + loco) == -1) // or vice versa { return false; } @@ -201,6 +193,36 @@ namespace ProjectElectricLocomotive.Generics return true; } + + /*foreach(string data in str) + { + string[] record = data.Split(_separatorForKeyValue, + StringSplitOptions.RemoveEmptyEntries); + if (record.Length != 2) + { + continue; + } + LocomotiveGenericCollection + collection = new(_pictureWidth, _pictureHeight); + string[] set = record[1].Split(_separatorRecords, + StringSplitOptions.RemoveEmptyEntries); + foreach (string elem in set) + { + DrawingLocomotive? loco = + elem?.CreateDrawingLocomotive(_separatorForObject, _pictureWidth, _pictureHeight); + if (loco != null) + { + if ((collection + loco) != -1) // or vice versa + { + return false; + } + } + } + _locomotivesStorage.Add(record[0], collection); + } + return true; + + }*/ /*var strs = bufferTextFromFile.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); if (str == null || str.Length == 0)