diff --git a/Cruiser/Cruiser/CruiserGenericCollection.cs b/Cruiser/Cruiser/CruiserGenericCollection.cs index 41fe331..f4a3994 100644 --- a/Cruiser/Cruiser/CruiserGenericCollection.cs +++ b/Cruiser/Cruiser/CruiserGenericCollection.cs @@ -14,7 +14,7 @@ namespace Cruiser.Generics where T : DrawningCruiser where U : IMoveableObject { - public IEnumerable GetTheBuses => _collection.GetCruiser(); + public IEnumerable GetCruiser => _collection.GetCruiser(); private readonly int _pictureWidth; private readonly int _pictureHeight; private readonly int _placeSizeWidth = 210; diff --git a/Cruiser/Cruiser/CruiserGenericStorage.cs b/Cruiser/Cruiser/CruiserGenericStorage.cs index 58e7994..f4e03dd 100644 --- a/Cruiser/Cruiser/CruiserGenericStorage.cs +++ b/Cruiser/Cruiser/CruiserGenericStorage.cs @@ -16,13 +16,7 @@ namespace Cruiser.Generics private readonly int _pictureWidth; private readonly int _pictureHeight; private static readonly char _separatorForKeyValue = '|'; - /// - /// Разделитель для записей коллекции данных в файл - /// private readonly char _separatorRecords = ';'; - /// - /// Разделитель для записи информации по объекту в файл - /// private static readonly char _separatorForObject = ':'; public CruiserGenericStorage(int pictureWidth, int pictureHeight) { @@ -64,7 +58,7 @@ namespace Cruiser.Generics foreach (KeyValuePair> record in _cruiserStorages) { StringBuilder records = new(); - foreach (DrawningCruiser? elem in record.Value.GetTheBuses) + foreach (DrawningCruiser? elem in record.Value.GetCruiser) { records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}"); } @@ -75,7 +69,7 @@ namespace Cruiser.Generics { return false; } - string toWrite = $"BusStorage{Environment.NewLine}{data}"; + string toWrite = $"CruiserStorage{Environment.NewLine}{data}"; var strs = toWrite.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); using (StreamWriter sw = new(filename)) @@ -88,11 +82,6 @@ namespace Cruiser.Generics return true; } - /// - /// Загрузка информации по автобусам в хранилище из файла - /// - /// Путь и имя файла - /// true - загрузка прошла успешно, false - ошибка при загрузке данных public bool LoadData(string filename) { if (!File.Exists(filename)) @@ -107,7 +96,7 @@ namespace Cruiser.Generics { return false; } - if (!strs[0].StartsWith("BusStorage")) + if (!strs[0].StartsWith("CruiserStorage")) { return false; } @@ -124,11 +113,11 @@ namespace Cruiser.Generics string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries); foreach (string elem in set) { - DrawningCruiser? bus = + DrawningCruiser? cruiser = elem?.CreateDrawningCruiser(_separatorForObject, _pictureWidth, _pictureHeight); - if (bus != null) + if (cruiser != null) { - if (!(collection + bus)) + if (!(collection + cruiser)) { return false; } @@ -141,7 +130,5 @@ namespace Cruiser.Generics } return true; } - } -} - +} \ No newline at end of file diff --git a/Cruiser/Cruiser/ExtentionDrawingCruiser.cs b/Cruiser/Cruiser/ExtentionDrawingCruiser.cs index 3593048..30d2cac 100644 --- a/Cruiser/Cruiser/ExtentionDrawingCruiser.cs +++ b/Cruiser/Cruiser/ExtentionDrawingCruiser.cs @@ -40,5 +40,4 @@ namespace Cruiser.DrawningObjects $"{separatorForObject}{advancedCruiser.HelicopterPad}{separatorForObject}{advancedCruiser.Coating}"; } } -} - +} \ No newline at end of file diff --git a/Cruiser/Cruiser/FormCruiserCollection.Designer.cs b/Cruiser/Cruiser/FormCruiserCollection.Designer.cs index 881a8d2..653c0f0 100644 --- a/Cruiser/Cruiser/FormCruiserCollection.Designer.cs +++ b/Cruiser/Cruiser/FormCruiserCollection.Designer.cs @@ -148,6 +148,11 @@ // openFileDialog // this.openFileDialog.FileName = "openFileDialog"; + this.openFileDialog.Filter = "txt file | *.txt"; + // + // saveFileDialog + // + this.saveFileDialog.Filter = "txt file | *.txt"; // // menuStrip // @@ -158,7 +163,7 @@ this.menuStrip.Name = "menuStrip"; this.menuStrip.Size = new System.Drawing.Size(904, 33); this.menuStrip.TabIndex = 2; - this.menuStrip.Text = "menuStrip1"; + this.menuStrip.Text = "menuStrip"; // // FileToolStripMenuItem // @@ -172,14 +177,16 @@ // SaveToolStripMenuItem // this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem"; - this.SaveToolStripMenuItem.Size = new System.Drawing.Size(273, 34); + this.SaveToolStripMenuItem.Size = new System.Drawing.Size(270, 34); this.SaveToolStripMenuItem.Text = "Сохранить"; + this.SaveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click); // // LoadToolStripMenuItem // this.LoadToolStripMenuItem.Name = "LoadToolStripMenuItem"; this.LoadToolStripMenuItem.Size = new System.Drawing.Size(270, 34); this.LoadToolStripMenuItem.Text = "Загрузить"; + this.LoadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click); // // FormCruiserCollection // diff --git a/Cruiser/Cruiser/FormCruiserCollection.cs b/Cruiser/Cruiser/FormCruiserCollection.cs index ab0bd06..8b2a637 100644 --- a/Cruiser/Cruiser/FormCruiserCollection.cs +++ b/Cruiser/Cruiser/FormCruiserCollection.cs @@ -155,11 +155,6 @@ namespace Cruiser } } - /// - /// Обработка нажатия "Загрузка" - /// - /// - /// private void LoadToolStripMenuItem_Click(object sender, EventArgs e) { if (openFileDialog.ShowDialog() == DialogResult.OK) diff --git a/Cruiser/Cruiser/FormCruiserConfig.Designer.cs b/Cruiser/Cruiser/FormCruiserConfig.Designer.cs index 340c5f2..86f1a3c 100644 --- a/Cruiser/Cruiser/FormCruiserConfig.Designer.cs +++ b/Cruiser/Cruiser/FormCruiserConfig.Designer.cs @@ -120,6 +120,8 @@ this.panelOrchid.Name = "panelOrchid"; this.panelOrchid.Size = new System.Drawing.Size(312, 261); this.panelOrchid.TabIndex = 9; + this.panelOrchid.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop); + this.panelOrchid.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter); // // label_addit_color // @@ -204,7 +206,7 @@ // // panelPink // - this.panelPink.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(255))))); + this.panelPink.BackColor = System.Drawing.Color.Violet; this.panelPink.Location = new System.Drawing.Point(180, 153); this.panelPink.Name = "panelPink"; this.panelPink.Size = new System.Drawing.Size(53, 49); @@ -212,7 +214,7 @@ // // panelViolet // - this.panelViolet.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255))))); + this.panelViolet.BackColor = System.Drawing.Color.DarkTurquoise; this.panelViolet.Location = new System.Drawing.Point(108, 153); this.panelViolet.Name = "panelViolet"; this.panelViolet.Size = new System.Drawing.Size(53, 49); @@ -220,7 +222,7 @@ // // panelBlue // - this.panelBlue.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255))))); + this.panelBlue.BackColor = System.Drawing.Color.PaleTurquoise; this.panelBlue.Location = new System.Drawing.Point(34, 153); this.panelBlue.Name = "panelBlue"; this.panelBlue.Size = new System.Drawing.Size(53, 49);