From 8079e18f752fd3885338398cf05c13efc96aa24d Mon Sep 17 00:00:00 2001 From: Sergey Kozyrev Date: Wed, 15 Nov 2023 10:25:49 +0400 Subject: [PATCH 1/4] FirstCommit --- Lab/CarsGenericCollection.cs | 2 + Lab/CarsGenericStorage.cs | 85 ++++++++++++++++++++++++++++++++ Lab/CollectionsFrame.Designer.cs | 42 ++++++++++++++-- Lab/CollectionsFrame.cs | 70 ++++++++++++-------------- Lab/CollectionsFrame.resx | 6 +++ Lab/ExtentionDrawingTanker.cs | 50 +++++++++++++++++++ 6 files changed, 213 insertions(+), 42 deletions(-) create mode 100644 Lab/ExtentionDrawingTanker.cs diff --git a/Lab/CarsGenericCollection.cs b/Lab/CarsGenericCollection.cs index e9a87a8..ab86536 100644 --- a/Lab/CarsGenericCollection.cs +++ b/Lab/CarsGenericCollection.cs @@ -18,6 +18,8 @@ namespace Lab.Generics private readonly int _placeSizeWidth = 110; private readonly int _placeSizeHeight = 80; private readonly SetGeneric _collection; + + public IEnumerable GetCars => _collection.GetCars(); public CarsGenericCollection(int picWidth, int picHeight) { int width = picWidth / _placeSizeWidth; diff --git a/Lab/CarsGenericStorage.cs b/Lab/CarsGenericStorage.cs index 4ae6a5b..ea2296b 100644 --- a/Lab/CarsGenericStorage.cs +++ b/Lab/CarsGenericStorage.cs @@ -15,6 +15,11 @@ namespace Lab.Generics public List Keys => _carStorages.Keys.ToList(); private readonly int _pictureWidth; private readonly int _pictureHeight; + + private static readonly char _separatorForKeyValue = '|'; + private readonly char _separatorRecords = ';'; + private static readonly char _separatorForObject = ':'; + public CarsGenericStorage(int pictureWidth, int pictureHeight) { _carStorages = new Dictionary>(); @@ -43,5 +48,85 @@ namespace Lab.Generics } } + public bool SaveData(string filename) + { + if (File.Exists(filename)) + { + File.Delete(filename); + } + StringBuilder data = new(); + foreach (KeyValuePair> record in _carStorages) + { + StringBuilder records = new(); + foreach (DrawTanker? elem in record.Value.GetCars) + { + records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}"); + } + data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}"); + } + if (data.Length == 0) + { + return false; + } + using FileStream fs = new(filename, FileMode.Create); + byte[] info = new + UTF8Encoding(true).GetBytes($"CarStorage{Environment.NewLine}{data}"); + fs.Write(info, 0, info.Length); + return true; + } + + public bool LoadData(string filename) + { + if (!File.Exists(filename)) + { + return false; + } + string bufferTextFromFile = ""; + using (FileStream fs = new(filename, FileMode.Open)) + { + byte[] b = new byte[fs.Length]; + UTF8Encoding temp = new(true); + while (fs.Read(b, 0, b.Length) > 0) + { + bufferTextFromFile += temp.GetString(b); + } + } + var strs = bufferTextFromFile.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); + if (strs == null || strs.Length == 0) + { + return false; + } + if (!strs[0].StartsWith("CarStorage")) + { + return false; + } + _carStorages.Clear(); + foreach (string data in strs) + { + string[] record = data.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries); + if (record.Length != 2) + { + continue; + } + CarsGenericCollection collection = new(_pictureWidth, _pictureHeight); + string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries); + foreach (string elem in set) + { + DrawTanker? car = + elem?.CreateDrawTanker(_separatorForObject, _pictureWidth, _pictureHeight); + if (car != null) + { + if (!(collection + car)) + { + return false; + } + } + } + _carStorages.Add(record[0], collection); + } + return true; + } + + } } diff --git a/Lab/CollectionsFrame.Designer.cs b/Lab/CollectionsFrame.Designer.cs index 5971286..7267d81 100644 --- a/Lab/CollectionsFrame.Designer.cs +++ b/Lab/CollectionsFrame.Designer.cs @@ -41,6 +41,10 @@ CarTextBox = new TextBox(); label1 = new Label(); DrawTank = new PictureBox(); + openFileDialog = new OpenFileDialog(); + saveFileDialog = new SaveFileDialog(); + SaveButton = new Button(); + LoadButton = new Button(); panel1.SuspendLayout(); panel2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)DrawTank).BeginInit(); @@ -48,6 +52,8 @@ // // panel1 // + panel1.Controls.Add(LoadButton); + panel1.Controls.Add(SaveButton); panel1.Controls.Add(panel2); panel1.Controls.Add(UpdateButton); panel1.Controls.Add(DeleteButton); @@ -120,7 +126,7 @@ // // UpdateButton // - UpdateButton.Location = new Point(10, 401); + UpdateButton.Location = new Point(6, 383); UpdateButton.Name = "UpdateButton"; UpdateButton.Size = new Size(228, 37); UpdateButton.TabIndex = 4; @@ -130,7 +136,7 @@ // // DeleteButton // - DeleteButton.Location = new Point(10, 358); + DeleteButton.Location = new Point(6, 340); DeleteButton.Name = "DeleteButton"; DeleteButton.Size = new Size(228, 37); DeleteButton.TabIndex = 3; @@ -140,7 +146,7 @@ // // AddButton // - AddButton.Location = new Point(10, 282); + AddButton.Location = new Point(6, 264); AddButton.Name = "AddButton"; AddButton.Size = new Size(228, 37); AddButton.TabIndex = 2; @@ -150,7 +156,7 @@ // // CarTextBox // - CarTextBox.Location = new Point(10, 325); + CarTextBox.Location = new Point(6, 307); CarTextBox.Name = "CarTextBox"; CarTextBox.Size = new Size(228, 27); CarTextBox.TabIndex = 1; @@ -173,6 +179,30 @@ DrawTank.TabIndex = 1; DrawTank.TabStop = false; // + // openFileDialog + // + openFileDialog.FileName = "openFileDialog1"; + // + // SaveButton + // + SaveButton.Location = new Point(6, 426); + SaveButton.Name = "SaveButton"; + SaveButton.Size = new Size(109, 44); + SaveButton.TabIndex = 6; + SaveButton.Text = "Сохранить"; + SaveButton.UseVisualStyleBackColor = true; + SaveButton.Click += SaveToolStripMenuItem_Click; + // + // LoadButton + // + LoadButton.Location = new Point(121, 426); + LoadButton.Name = "LoadButton"; + LoadButton.Size = new Size(113, 44); + LoadButton.TabIndex = 7; + LoadButton.Text = "Загрузить"; + LoadButton.UseVisualStyleBackColor = true; + LoadButton.Click += LoadToolStripMenuItem_Click; + // // CollectionsFrame // AutoScaleDimensions = new SizeF(8F, 20F); @@ -205,5 +235,9 @@ private Button AddCollectButton; private TextBox SetTextBox; private Label label2; + private OpenFileDialog openFileDialog; + private SaveFileDialog saveFileDialog; + private Button LoadButton; + private Button SaveButton; } } \ No newline at end of file diff --git a/Lab/CollectionsFrame.cs b/Lab/CollectionsFrame.cs index 93f3118..4feb258 100644 --- a/Lab/CollectionsFrame.cs +++ b/Lab/CollectionsFrame.cs @@ -16,17 +16,11 @@ namespace Lab public partial class CollectionsFrame : Form { private readonly CarsGenericStorage _storage; - /// - /// Конструктор - /// public CollectionsFrame() { InitializeComponent(); _storage = new CarsGenericStorage(DrawTank.Width, DrawTank.Height); } - /// - /// Заполнение listBoxObjects - /// private void ReloadObjects() { int index = CollectionListBox.SelectedIndex; @@ -46,11 +40,6 @@ namespace Lab CollectionListBox.SelectedIndex = index; } } - /// - /// Добавление набора в коллекцию - /// - /// - /// private void ButtonAddObject_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(SetTextBox.Text)) @@ -62,22 +51,12 @@ namespace Lab _storage.AddSet(SetTextBox.Text); ReloadObjects(); } - /// - /// Выбор набора - /// - /// - /// private void ListBoxObjects_SelectedIndexChanged(object sender, EventArgs e) { DrawTank.Image = _storage[CollectionListBox.SelectedItem?.ToString() ?? string.Empty]?.ShowCars(); } - /// - /// Удаление набора - /// - /// - /// private void ButtonDelObject_Click(object sender, EventArgs e) { if (CollectionListBox.SelectedIndex == -1) @@ -92,15 +71,10 @@ namespace Lab ReloadObjects(); } } - /// - /// Добавление объекта в набор - /// - /// - /// - + private void AddTanker(DrawTanker tanker) { - + var obj = _storage[CollectionListBox.SelectedItem.ToString() ?? string.Empty]; if (obj == null) { @@ -126,11 +100,6 @@ namespace Lab form.Show(); form.AddEvent(AddTanker); } - /// - /// Удаление объекта из набора - /// - /// - /// private void ButtonRemoveCar_Click(object sender, EventArgs e) { if (CollectionListBox.SelectedIndex == -1) @@ -159,11 +128,6 @@ namespace Lab MessageBox.Show("Не удалось удалить объект"); } } - /// - /// Обновление рисунка по набору - /// - /// - /// private void ButtonRefreshCollection_Click(object sender, EventArgs e) { @@ -179,5 +143,35 @@ namespace Lab } DrawTank.Image = obj.ShowCars(); } + private void SaveToolStripMenuItem_Click(object sender, EventArgs e) + { + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + if (_storage.SaveData(saveFileDialog.FileName)) + { + MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + else + { + MessageBox.Show("Не сохранилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void LoadToolStripMenuItem_Click(object sender, EventArgs e) + { + + if (openFileDialog.ShowDialog() == DialogResult.OK) + { + if (_storage.LoadData(openFileDialog.FileName)) + { + ReloadObjects(); + MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + else + { + MessageBox.Show("Не загрузилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } } } diff --git a/Lab/CollectionsFrame.resx b/Lab/CollectionsFrame.resx index af32865..ceedf48 100644 --- a/Lab/CollectionsFrame.resx +++ b/Lab/CollectionsFrame.resx @@ -117,4 +117,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + 187, 17 + \ No newline at end of file diff --git a/Lab/ExtentionDrawingTanker.cs b/Lab/ExtentionDrawingTanker.cs new file mode 100644 index 0000000..05a42b5 --- /dev/null +++ b/Lab/ExtentionDrawingTanker.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Lab.Entities; +using Lab.DrawningObjects; + +namespace Lab +{ + public static class ExtentionDrawingTanker + { + public static DrawTanker? CreateDrawTanker(this string info, char separatorForObject, int width, int height) + { + string[] strs = info.Split(separatorForObject); + if (strs.Length == 3) + { + return new DrawTanker(Convert.ToInt32(strs[0]), + Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height); + } + if (strs.Length == 7) + { + return new DrawGasolineTanker(Convert.ToInt32(strs[0]), + Convert.ToInt32(strs[1]), + Color.FromName(strs[2]), + Color.FromName(strs[3]), + Convert.ToBoolean(strs[4]), + Convert.ToBoolean(strs[5]), + Convert.ToBoolean(strs[6]), width, height); + } + return null; + } + + public static string GetDataForSave(this DrawTanker tanker, char separatorForObject) + { + var Tanker = tanker._gasolineTanker; + if (Tanker == null) + { + return string.Empty; + } + var str = $"{Tanker.Speed}{separatorForObject}{Tanker.Weight}{separatorForObject}{Tanker.BodyColor.Name}"; + if (Tanker is not GasolineTanker gasTanker) + { + return str; + } + return $"{str}{separatorForObject}{gasTanker.AdditionalColor.Name}{separatorForObject}{gasTanker.BodyKit}{separatorForObject}{gasTanker.Wing}{separatorForObject}{gasTanker.SportLine}"; + } + + } +} -- 2.25.1 From 3fb85c16dd69f75b099814658470f4486edbe398 Mon Sep 17 00:00:00 2001 From: Sergey Kozyrev Date: Wed, 15 Nov 2023 11:34:08 +0400 Subject: [PATCH 2/4] FileSave --- Lab/CarsGenericStorage.cs | 75 +++++++++++++++-------------------- Lab/ExtentionDrawingTanker.cs | 4 +- Lab/SetGeneric.cs | 4 ++ 3 files changed, 39 insertions(+), 44 deletions(-) diff --git a/Lab/CarsGenericStorage.cs b/Lab/CarsGenericStorage.cs index ea2296b..a15aa7b 100644 --- a/Lab/CarsGenericStorage.cs +++ b/Lab/CarsGenericStorage.cs @@ -68,11 +68,13 @@ namespace Lab.Generics { return false; } - using FileStream fs = new(filename, FileMode.Create); - byte[] info = new - UTF8Encoding(true).GetBytes($"CarStorage{Environment.NewLine}{data}"); - fs.Write(info, 0, info.Length); - return true; + using (StreamWriter writer = new StreamWriter(filename)) + { + writer.WriteLine("CarStorage"); + writer.Write(data.ToString()); + return true; + } + } public bool LoadData(string filename) @@ -81,52 +83,41 @@ namespace Lab.Generics { return false; } - string bufferTextFromFile = ""; - using (FileStream fs = new(filename, FileMode.Open)) + using (StreamReader reader = new StreamReader(filename)) { - byte[] b = new byte[fs.Length]; - UTF8Encoding temp = new(true); - while (fs.Read(b, 0, b.Length) > 0) + string checker = reader.ReadLine(); + if (checker == null) + return false; + string strs = reader.ReadLine(); + if (!checker.StartsWith("CarStorage")) + return false; + _carStorages.Clear(); + foreach (string data in strs.Split(';')) { - bufferTextFromFile += temp.GetString(b); - } - } - var strs = bufferTextFromFile.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); - if (strs == null || strs.Length == 0) - { - return false; - } - if (!strs[0].StartsWith("CarStorage")) - { - return false; - } - _carStorages.Clear(); - foreach (string data in strs) - { - string[] record = data.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries); - if (record.Length != 2) - { - continue; - } - CarsGenericCollection collection = new(_pictureWidth, _pictureHeight); - string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries); - foreach (string elem in set) - { - DrawTanker? car = - elem?.CreateDrawTanker(_separatorForObject, _pictureWidth, _pictureHeight); - if (car != null) + string[] record = data.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries); + if (record.Length != 2) { - if (!(collection + car)) + continue; + } + CarsGenericCollection collection = new(_pictureWidth, _pictureHeight); + string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries); + foreach (string elem in set) + { + DrawTanker? car = + elem?.CreateDrawTanker(_separatorForObject, _pictureWidth, _pictureHeight); + if (car != null) { - return false; + if (!(collection + car)) + { + return false; + } } } + _carStorages.Add(record[0], collection); } - _carStorages.Add(record[0], collection); + return true; } - return true; } - } } diff --git a/Lab/ExtentionDrawingTanker.cs b/Lab/ExtentionDrawingTanker.cs index 05a42b5..a94774d 100644 --- a/Lab/ExtentionDrawingTanker.cs +++ b/Lab/ExtentionDrawingTanker.cs @@ -38,12 +38,12 @@ namespace Lab { return string.Empty; } - var str = $"{Tanker.Speed}{separatorForObject}{Tanker.Weight}{separatorForObject}{Tanker.BodyColor.Name}"; + var str = $"{Tanker.Speed}{separatorForObject}{Tanker.Weight}{separatorForObject}{Tanker.BodyColor}"; if (Tanker is not GasolineTanker gasTanker) { return str; } - return $"{str}{separatorForObject}{gasTanker.AdditionalColor.Name}{separatorForObject}{gasTanker.BodyKit}{separatorForObject}{gasTanker.Wing}{separatorForObject}{gasTanker.SportLine}"; + return $"{str}{separatorForObject}{gasTanker.AdditionalColor}{separatorForObject}{gasTanker.BodyKit}{separatorForObject}{gasTanker.Wing}{separatorForObject}{gasTanker.SportLine}"; } } diff --git a/Lab/SetGeneric.cs b/Lab/SetGeneric.cs index 7e73e02..48cd770 100644 --- a/Lab/SetGeneric.cs +++ b/Lab/SetGeneric.cs @@ -49,12 +49,16 @@ namespace Lab.Generics { if (position < 0 || position > _maxCount) return null; + if (_places.Count <= position) + return null; return _places[position]; } set { if (position < 0 || position > _maxCount) return; + if (_places.Count <= position) + return; _places[position] = value; } } -- 2.25.1 From ab6ad40fb393443e401c028c8665c9666e72593a Mon Sep 17 00:00:00 2001 From: Sergey Kozyrev Date: Wed, 15 Nov 2023 13:46:17 +0400 Subject: [PATCH 3/4] DrawUpdate --- Lab/CarsGenericStorage.cs | 29 ++++++++------- Lab/CollectionsFrame.Designer.cs | 64 ++++++++++++++++++++------------ Lab/CollectionsFrame.resx | 3 ++ Lab/ExtentionDrawingTanker.cs | 6 +-- Lab/FormTankerConfig.Designer.cs | 4 +- 5 files changed, 65 insertions(+), 41 deletions(-) diff --git a/Lab/CarsGenericStorage.cs b/Lab/CarsGenericStorage.cs index a15aa7b..96b7a22 100644 --- a/Lab/CarsGenericStorage.cs +++ b/Lab/CarsGenericStorage.cs @@ -47,7 +47,6 @@ namespace Lab.Generics return null; } } - public bool SaveData(string filename) { if (File.Exists(filename)) @@ -63,6 +62,7 @@ namespace Lab.Generics records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}"); } data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}"); + } if (data.Length == 0) { @@ -88,23 +88,24 @@ namespace Lab.Generics string checker = reader.ReadLine(); if (checker == null) return false; - string strs = reader.ReadLine(); if (!checker.StartsWith("CarStorage")) return false; _carStorages.Clear(); - foreach (string data in strs.Split(';')) + string strs; + bool firstinit = true; + while ((strs = reader.ReadLine()) != null) { - string[] record = data.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries); - if (record.Length != 2) - { - continue; - } + if (strs == null && firstinit) + return false; + if (strs == null ) + break; + firstinit = false; + string name = strs.Split('|')[0]; CarsGenericCollection collection = new(_pictureWidth, _pictureHeight); - string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries); - foreach (string elem in set) - { + foreach (string data in strs.Split('|')[1].Split(';')) + { DrawTanker? car = - elem?.CreateDrawTanker(_separatorForObject, _pictureWidth, _pictureHeight); + data?.CreateDrawTanker(_separatorForObject, _pictureWidth, _pictureHeight); if (car != null) { if (!(collection + car)) @@ -112,8 +113,10 @@ namespace Lab.Generics return false; } } + + } - _carStorages.Add(record[0], collection); + _carStorages.Add(name, collection); } return true; } diff --git a/Lab/CollectionsFrame.Designer.cs b/Lab/CollectionsFrame.Designer.cs index 7267d81..a8760c8 100644 --- a/Lab/CollectionsFrame.Designer.cs +++ b/Lab/CollectionsFrame.Designer.cs @@ -43,23 +43,25 @@ DrawTank = new PictureBox(); openFileDialog = new OpenFileDialog(); saveFileDialog = new SaveFileDialog(); - SaveButton = new Button(); - LoadButton = new Button(); + menuStrip1 = new MenuStrip(); + StripMenu = new ToolStripMenuItem(); + SaveItem = new ToolStripMenuItem(); + LoadItem = new ToolStripMenuItem(); panel1.SuspendLayout(); panel2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)DrawTank).BeginInit(); + menuStrip1.SuspendLayout(); SuspendLayout(); // // panel1 // - panel1.Controls.Add(LoadButton); - panel1.Controls.Add(SaveButton); panel1.Controls.Add(panel2); panel1.Controls.Add(UpdateButton); panel1.Controls.Add(DeleteButton); panel1.Controls.Add(AddButton); panel1.Controls.Add(CarTextBox); panel1.Controls.Add(label1); + panel1.Controls.Add(menuStrip1); panel1.Dock = DockStyle.Right; panel1.Location = new Point(550, 0); panel1.Name = "panel1"; @@ -164,7 +166,7 @@ // label1 // label1.AutoSize = true; - label1.Location = new Point(2, 2); + label1.Location = new Point(144, 0); label1.Name = "label1"; label1.Size = new Size(103, 20); label1.TabIndex = 0; @@ -183,25 +185,36 @@ // openFileDialog.FileName = "openFileDialog1"; // - // SaveButton + // menuStrip1 // - SaveButton.Location = new Point(6, 426); - SaveButton.Name = "SaveButton"; - SaveButton.Size = new Size(109, 44); - SaveButton.TabIndex = 6; - SaveButton.Text = "Сохранить"; - SaveButton.UseVisualStyleBackColor = true; - SaveButton.Click += SaveToolStripMenuItem_Click; + menuStrip1.ImageScalingSize = new Size(20, 20); + menuStrip1.Items.AddRange(new ToolStripItem[] { StripMenu }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Size = new Size(250, 28); + menuStrip1.TabIndex = 6; + menuStrip1.Text = "menuStrip1"; // - // LoadButton + // StripMenu // - LoadButton.Location = new Point(121, 426); - LoadButton.Name = "LoadButton"; - LoadButton.Size = new Size(113, 44); - LoadButton.TabIndex = 7; - LoadButton.Text = "Загрузить"; - LoadButton.UseVisualStyleBackColor = true; - LoadButton.Click += LoadToolStripMenuItem_Click; + StripMenu.DropDownItems.AddRange(new ToolStripItem[] { SaveItem, LoadItem }); + StripMenu.Name = "StripMenu"; + StripMenu.Size = new Size(59, 24); + StripMenu.Text = "Файл"; + // + // SaveItem + // + SaveItem.Name = "SaveItem"; + SaveItem.Size = new Size(224, 26); + SaveItem.Text = "Сохранить"; + SaveItem.Click += SaveToolStripMenuItem_Click; + // + // LoadItem + // + LoadItem.Name = "LoadItem"; + LoadItem.Size = new Size(224, 26); + LoadItem.Text = "Загрузить"; + LoadItem.Click += LoadToolStripMenuItem_Click; // // CollectionsFrame // @@ -210,6 +223,7 @@ ClientSize = new Size(800, 514); Controls.Add(DrawTank); Controls.Add(panel1); + MainMenuStrip = menuStrip1; Name = "CollectionsFrame"; Text = "Гаражи бензовозов"; panel1.ResumeLayout(false); @@ -217,6 +231,8 @@ panel2.ResumeLayout(false); panel2.PerformLayout(); ((System.ComponentModel.ISupportInitialize)DrawTank).EndInit(); + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); ResumeLayout(false); } @@ -237,7 +253,9 @@ private Label label2; private OpenFileDialog openFileDialog; private SaveFileDialog saveFileDialog; - private Button LoadButton; - private Button SaveButton; + private MenuStrip menuStrip1; + private ToolStripMenuItem StripMenu; + private ToolStripMenuItem SaveItem; + private ToolStripMenuItem LoadItem; } } \ No newline at end of file diff --git a/Lab/CollectionsFrame.resx b/Lab/CollectionsFrame.resx index ceedf48..797c78c 100644 --- a/Lab/CollectionsFrame.resx +++ b/Lab/CollectionsFrame.resx @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 344, 17 + 17, 17 diff --git a/Lab/ExtentionDrawingTanker.cs b/Lab/ExtentionDrawingTanker.cs index a94774d..7c37740 100644 --- a/Lab/ExtentionDrawingTanker.cs +++ b/Lab/ExtentionDrawingTanker.cs @@ -16,14 +16,14 @@ namespace Lab if (strs.Length == 3) { return new DrawTanker(Convert.ToInt32(strs[0]), - Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height); + Convert.ToInt32(strs[1]), Color.FromName(strs[2].Replace("Color [", "").Replace("]", "")), width, height); } if (strs.Length == 7) { return new DrawGasolineTanker(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), - Color.FromName(strs[2]), - Color.FromName(strs[3]), + Color.FromName(strs[2].Replace("Color [", "").Replace("]","")), + Color.FromName(strs[3].Replace("Color [", "").Replace("]","")), Convert.ToBoolean(strs[4]), Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]), width, height); diff --git a/Lab/FormTankerConfig.Designer.cs b/Lab/FormTankerConfig.Designer.cs index ffed2a1..4e7416c 100644 --- a/Lab/FormTankerConfig.Designer.cs +++ b/Lab/FormTankerConfig.Designer.cs @@ -131,7 +131,7 @@ // // PurplePanel // - PurplePanel.BackColor = Color.FromArgb(192, 0, 192); + PurplePanel.BackColor = Color.Purple; PurplePanel.Location = new Point(182, 65); PurplePanel.Name = "PurplePanel"; PurplePanel.Size = new Size(50, 50); @@ -179,7 +179,7 @@ // // GreenPanel // - GreenPanel.BackColor = Color.FromArgb(0, 192, 0); + GreenPanel.BackColor = Color.Green; GreenPanel.Location = new Point(70, 9); GreenPanel.Name = "GreenPanel"; GreenPanel.Size = new Size(50, 50); -- 2.25.1 From 123978bbf80be4dd2124a953d033558ea61d60de Mon Sep 17 00:00:00 2001 From: Sergey Kozyrev Date: Fri, 17 Nov 2023 19:29:08 +0400 Subject: [PATCH 4/4] NameUpdate --- Lab/ExtentionDrawingTanker.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Lab/ExtentionDrawingTanker.cs b/Lab/ExtentionDrawingTanker.cs index 7c37740..05a42b5 100644 --- a/Lab/ExtentionDrawingTanker.cs +++ b/Lab/ExtentionDrawingTanker.cs @@ -16,14 +16,14 @@ namespace Lab if (strs.Length == 3) { return new DrawTanker(Convert.ToInt32(strs[0]), - Convert.ToInt32(strs[1]), Color.FromName(strs[2].Replace("Color [", "").Replace("]", "")), width, height); + Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height); } if (strs.Length == 7) { return new DrawGasolineTanker(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), - Color.FromName(strs[2].Replace("Color [", "").Replace("]","")), - Color.FromName(strs[3].Replace("Color [", "").Replace("]","")), + Color.FromName(strs[2]), + Color.FromName(strs[3]), Convert.ToBoolean(strs[4]), Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]), width, height); @@ -38,12 +38,12 @@ namespace Lab { return string.Empty; } - var str = $"{Tanker.Speed}{separatorForObject}{Tanker.Weight}{separatorForObject}{Tanker.BodyColor}"; + var str = $"{Tanker.Speed}{separatorForObject}{Tanker.Weight}{separatorForObject}{Tanker.BodyColor.Name}"; if (Tanker is not GasolineTanker gasTanker) { return str; } - return $"{str}{separatorForObject}{gasTanker.AdditionalColor}{separatorForObject}{gasTanker.BodyKit}{separatorForObject}{gasTanker.Wing}{separatorForObject}{gasTanker.SportLine}"; + return $"{str}{separatorForObject}{gasTanker.AdditionalColor.Name}{separatorForObject}{gasTanker.BodyKit}{separatorForObject}{gasTanker.Wing}{separatorForObject}{gasTanker.SportLine}"; } } -- 2.25.1