From 1dedcb6bc1e777d8c458a290d7a2753c9f21e7ba Mon Sep 17 00:00:00 2001 From: antoc0der <1@DESKTOP-K1L8ND3> Date: Thu, 23 Nov 2023 11:43:43 +0300 Subject: [PATCH 1/3] =?UTF-8?q?=D1=82=D0=B0=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AirplanesGenericCollection.cs | 1 + .../AirplanesGenericStorage.cs | 114 +++++++++++++++--- .../ExtentionDrawningAirplane.cs | 53 ++++++++ .../FormAirplanesCollection.Designer.cs | 44 ++++++- .../FormAirplanesCollection.cs | 3 +- 5 files changed, 196 insertions(+), 19 deletions(-) create mode 100644 ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/ExtentionDrawningAirplane.cs diff --git a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/AirplanesGenericCollection.cs b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/AirplanesGenericCollection.cs index b7600f7..a1fba9a 100644 --- a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/AirplanesGenericCollection.cs +++ b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/AirplanesGenericCollection.cs @@ -21,6 +21,7 @@ namespace ProjectAirplaneWithRadar.Generics _pictureHeight = picHeight; _collection = new SetGeneric(width * height); } + public IEnumerable GetAirplanes => _collection.GetAirplanes(); public static bool operator +(AirplanesGenericCollection collect, T? obj) { if (obj == null || collect == null) diff --git a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/AirplanesGenericStorage.cs b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/AirplanesGenericStorage.cs index b9c169d..91c2fe2 100644 --- a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/AirplanesGenericStorage.cs +++ b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/AirplanesGenericStorage.cs @@ -15,30 +15,114 @@ namespace ProjectAirplaneWithRadar.Generics public List Keys => _airplanesStorages.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 AirplanesGenericStorage(int pictureWidth, int pictureHeight) { _airplanesStorages = new Dictionary>(); _pictureWidth = pictureWidth; _pictureHeight = pictureHeight; } - public void AddSet(string name) + public bool SaveData(string filename) { - _airplanesStorages.Add(name, new AirplanesGenericCollection(_pictureWidth, _pictureHeight)); - } - public void DelSet(string name) - { - if (!_airplanesStorages.ContainsKey(name)) - return; - _airplanesStorages.Remove(name); - } - public AirplanesGenericCollection?this[string ind] - { - get + if (File.Exists(filename)) { - if (_airplanesStorages.ContainsKey(ind)) - return _airplanesStorages[ind]; - return null; + File.Delete(filename); } + StringBuilder data = new(); + foreach (KeyValuePair> record in _airplanesStorages) + { + StringBuilder records = new(); + foreach (DrawningAirplane? elem in record.Value.GetAirplanes) + { + records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}"); + } + data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}"); + } + if (data.Length == 0) + { + return false; + } + string toWrite = $"AirplanesStorage{Environment.NewLine}{data}"; + var strs = toWrite.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); + using (StreamWriter sw = new(filename)) + { + foreach (var str in strs) + { + sw.WriteLine(str); + } + } + return true; } + public bool LoadData(string filename) + { + if (!File.Exists(filename)) + { + return false; + } + using (StreamReader sr = new(filename)) + { + string str = sr.ReadLine(); + var strs = str.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); + if (strs == null || strs.Length == 0) + { + return false; + } + if (!strs[0].StartsWith("AirplanesStorage")) + { + //если нет такой записи, то это не те данные + return false; + } + _airplanesStorages.Clear(); + do + { + string[] record = str.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries); + if (record.Length != 2) + { + str = sr.ReadLine(); + continue; + } + AirplanesGenericCollection + collection = new(_pictureWidth, _pictureHeight); + string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries); + foreach (string elem in set) + { + DrawningAirplane? airplane = + elem?.CreateDrawningAirplane(_separatorForObject, _pictureWidth, _pictureHeight); + if (airplane != null) + { + if (!(collection + airplane)) + { + return false; + } + } + } + _airplanesStorages.Add(record[0], collection); + str = sr.ReadLine(); + } while (str != null); + } + return true; + } + public void AddSet(string name) + { + _airplanesStorages.Add(name, new AirplanesGenericCollection(_pictureWidth, _pictureHeight)); + } + public void DelSet(string name) + { + if (!_airplanesStorages.ContainsKey(name)) + return; + _airplanesStorages.Remove(name); + } + public AirplanesGenericCollection?this[string ind] + { + get + { + if (_airplanesStorages.ContainsKey(ind)) + return _airplanesStorages[ind]; + return null; + } + } } } diff --git a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/ExtentionDrawningAirplane.cs b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/ExtentionDrawningAirplane.cs new file mode 100644 index 0000000..b1ccb88 --- /dev/null +++ b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/ExtentionDrawningAirplane.cs @@ -0,0 +1,53 @@ +using ProjectAirplaneWithRadar.Entities; +using ProjectAirplaneWithRadar.DrawningObjects; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectAirplaneWithRadar +{ + public static class ExtentionDrawningAirplane + { + public static DrawningAirplane? CreateDrawningAirplane(this string info, char separatorForObject, int width, int height) + { + string[] strs = info.Split(separatorForObject); + if (strs.Length == 3) + { + return new DrawningAirplane(Convert.ToInt32(strs[0]), + Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height); + } + if (strs.Length == 6) + { + return new DrawningAirplaneWithRadar(Convert.ToInt32(strs[0]), + Convert.ToInt32(strs[1]), + Color.FromName(strs[2]), + Color.FromName(strs[3]), + Convert.ToBoolean(strs[4]), + Convert.ToBoolean(strs[6]), width, height); + } + return null; + } + public static string GetDataForSave(this DrawningAirplane drawningAirplane, + char separatorForObject) + { + var car = drawningAirplane.EntityAirplane; + if (car == null) + { + return string.Empty; + } + var str = + $"{car.Speed}{separatorForObject}{car.Weight}{separatorForObject}{car.BodyColor.Name}"; + if (car is not EntityAirplaneWithRadar airplaneWithRadar) + { + return str; + } + return + $"{str}{separatorForObject}{airplaneWithRadar.AdditionalColor.Name}" + + $"{separatorForObject}{airplaneWithRadar.Radar}" + + $"{separatorForObject}{airplaneWithRadar.DopBak}"; + } + } +} + diff --git a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.Designer.cs b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.Designer.cs index 21b5bdb..25d2754 100644 --- a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.Designer.cs +++ b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.Designer.cs @@ -39,9 +39,13 @@ buttonDeleteAirplane = new Button(); buttonAddAirplane = new Button(); maskedTextBoxNumber = new MaskedTextBox(); + groupBoxRecord = new GroupBox(); + LoadToolStripMenuItem = new Button(); + SaveToolStripMenuItem = new Button(); ((System.ComponentModel.ISupportInitialize)pictureBoxAirplanesCollection).BeginInit(); groupBoxAirplaneWithRadar.SuspendLayout(); groupBoxCollection.SuspendLayout(); + groupBoxRecord.SuspendLayout(); SuspendLayout(); // // pictureBoxAirplanesCollection @@ -56,15 +60,16 @@ // // groupBoxAirplaneWithRadar // + groupBoxAirplaneWithRadar.Controls.Add(groupBoxRecord); groupBoxAirplaneWithRadar.Controls.Add(groupBoxCollection); groupBoxAirplaneWithRadar.Controls.Add(buttonUpdateCollection); groupBoxAirplaneWithRadar.Controls.Add(buttonDeleteAirplane); groupBoxAirplaneWithRadar.Controls.Add(buttonAddAirplane); groupBoxAirplaneWithRadar.Controls.Add(maskedTextBoxNumber); groupBoxAirplaneWithRadar.Dock = DockStyle.Right; - groupBoxAirplaneWithRadar.Location = new Point(640, 0); + groupBoxAirplaneWithRadar.Location = new Point(643, 0); groupBoxAirplaneWithRadar.Name = "groupBoxAirplaneWithRadar"; - groupBoxAirplaneWithRadar.Size = new Size(250, 453); + groupBoxAirplaneWithRadar.Size = new Size(460, 453); groupBoxAirplaneWithRadar.TabIndex = 1; groupBoxAirplaneWithRadar.TabStop = false; groupBoxAirplaneWithRadar.Text = "Инструменты"; @@ -156,11 +161,40 @@ maskedTextBoxNumber.Size = new Size(125, 27); maskedTextBoxNumber.TabIndex = 0; // + // groupBoxRecord + // + groupBoxRecord.Controls.Add(SaveToolStripMenuItem); + groupBoxRecord.Controls.Add(LoadToolStripMenuItem); + groupBoxRecord.Location = new Point(250, 26); + groupBoxRecord.Name = "groupBoxRecord"; + groupBoxRecord.Size = new Size(204, 103); + groupBoxRecord.TabIndex = 5; + groupBoxRecord.TabStop = false; + groupBoxRecord.Text = "Запись"; + // + // LoadToolStripMenuItem + // + LoadToolStripMenuItem.Location = new Point(6, 61); + LoadToolStripMenuItem.Name = "LoadToolStripMenuItem"; + LoadToolStripMenuItem.Size = new Size(192, 29); + LoadToolStripMenuItem.TabIndex = 0; + LoadToolStripMenuItem.Text = "Загрузить"; + LoadToolStripMenuItem.UseVisualStyleBackColor = true; + // + // SaveToolStripMenuItem + // + SaveToolStripMenuItem.Location = new Point(6, 26); + SaveToolStripMenuItem.Name = "SaveToolStripMenuItem"; + SaveToolStripMenuItem.Size = new Size(192, 29); + SaveToolStripMenuItem.TabIndex = 1; + SaveToolStripMenuItem.Text = "Сохранить"; + SaveToolStripMenuItem.UseVisualStyleBackColor = true; + // // FormAirplanesCollection // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(890, 453); + ClientSize = new Size(1103, 453); Controls.Add(groupBoxAirplaneWithRadar); Controls.Add(pictureBoxAirplanesCollection); Name = "FormAirplanesCollection"; @@ -170,6 +204,7 @@ groupBoxAirplaneWithRadar.PerformLayout(); groupBoxCollection.ResumeLayout(false); groupBoxCollection.PerformLayout(); + groupBoxRecord.ResumeLayout(false); ResumeLayout(false); PerformLayout(); } @@ -187,5 +222,8 @@ private ListBox listBoxStorages; private Button buttonAddObject; private TextBox textBoxStorageName; + private GroupBox groupBoxRecord; + private Button SaveToolStripMenuItem; + private Button LoadToolStripMenuItem; } } \ No newline at end of file diff --git a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.cs b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.cs index a3ea417..47bf300 100644 --- a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.cs +++ b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.cs @@ -47,7 +47,8 @@ namespace ProjectAirplaneWithRadar } FormAirplaneConfig form = new(pictureBoxAirplanesCollection.Width, pictureBoxAirplanesCollection.Height); form.Show(); - Action < DrawningAirplane >? airplaneDelegate = new((m) => { + Action? airplaneDelegate = new((m) => + { bool q = (obj + m); if (q) { -- 2.25.1 From cd50b5bf7ad760da2776be4b16024000022d1278 Mon Sep 17 00:00:00 2001 From: antoc0der <1@DESKTOP-K1L8ND3> Date: Thu, 23 Nov 2023 12:14:41 +0300 Subject: [PATCH 2/3] =?UTF-8?q?=D1=82=D0=B0=D0=BA=20=D1=82=D0=B0=D0=BA=20?= =?UTF-8?q?=D1=82=D0=B0=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormAirplanesCollection.Designer.cs | 79 +++++++++++-------- .../FormAirplanesCollection.cs | 37 +++++++++ .../FormAirplanesCollection.resx | 9 +++ 3 files changed, 92 insertions(+), 33 deletions(-) diff --git a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.Designer.cs b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.Designer.cs index 25d2754..4496e0a 100644 --- a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.Designer.cs +++ b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.Designer.cs @@ -39,18 +39,21 @@ buttonDeleteAirplane = new Button(); buttonAddAirplane = new Button(); maskedTextBoxNumber = new MaskedTextBox(); - groupBoxRecord = new GroupBox(); - LoadToolStripMenuItem = new Button(); - SaveToolStripMenuItem = new Button(); + menuStrip1 = new MenuStrip(); + файлToolStripMenuItem = new ToolStripMenuItem(); + SaveToolStripMenuItem = new ToolStripMenuItem(); + LoadToolStripMenuItem = new ToolStripMenuItem(); + openFileDialog = new OpenFileDialog(); + saveFileDialog = new SaveFileDialog(); ((System.ComponentModel.ISupportInitialize)pictureBoxAirplanesCollection).BeginInit(); groupBoxAirplaneWithRadar.SuspendLayout(); groupBoxCollection.SuspendLayout(); - groupBoxRecord.SuspendLayout(); + menuStrip1.SuspendLayout(); SuspendLayout(); // // pictureBoxAirplanesCollection // - pictureBoxAirplanesCollection.Location = new Point(-9, 0); + pictureBoxAirplanesCollection.Location = new Point(0, 38); pictureBoxAirplanesCollection.Name = "pictureBoxAirplanesCollection"; pictureBoxAirplanesCollection.Size = new Size(650, 454); pictureBoxAirplanesCollection.SizeMode = PictureBoxSizeMode.AutoSize; @@ -60,16 +63,15 @@ // // groupBoxAirplaneWithRadar // - groupBoxAirplaneWithRadar.Controls.Add(groupBoxRecord); groupBoxAirplaneWithRadar.Controls.Add(groupBoxCollection); groupBoxAirplaneWithRadar.Controls.Add(buttonUpdateCollection); groupBoxAirplaneWithRadar.Controls.Add(buttonDeleteAirplane); groupBoxAirplaneWithRadar.Controls.Add(buttonAddAirplane); groupBoxAirplaneWithRadar.Controls.Add(maskedTextBoxNumber); groupBoxAirplaneWithRadar.Dock = DockStyle.Right; - groupBoxAirplaneWithRadar.Location = new Point(643, 0); + groupBoxAirplaneWithRadar.Location = new Point(650, 28); groupBoxAirplaneWithRadar.Name = "groupBoxAirplaneWithRadar"; - groupBoxAirplaneWithRadar.Size = new Size(460, 453); + groupBoxAirplaneWithRadar.Size = new Size(251, 464); groupBoxAirplaneWithRadar.TabIndex = 1; groupBoxAirplaneWithRadar.TabStop = false; groupBoxAirplaneWithRadar.Text = "Инструменты"; @@ -161,42 +163,49 @@ maskedTextBoxNumber.Size = new Size(125, 27); maskedTextBoxNumber.TabIndex = 0; // - // groupBoxRecord + // menuStrip1 // - groupBoxRecord.Controls.Add(SaveToolStripMenuItem); - groupBoxRecord.Controls.Add(LoadToolStripMenuItem); - groupBoxRecord.Location = new Point(250, 26); - groupBoxRecord.Name = "groupBoxRecord"; - groupBoxRecord.Size = new Size(204, 103); - groupBoxRecord.TabIndex = 5; - groupBoxRecord.TabStop = false; - groupBoxRecord.Text = "Запись"; + 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(901, 28); + menuStrip1.TabIndex = 2; + menuStrip1.Text = "menuStrip1"; // - // LoadToolStripMenuItem + // файлToolStripMenuItem // - LoadToolStripMenuItem.Location = new Point(6, 61); - LoadToolStripMenuItem.Name = "LoadToolStripMenuItem"; - LoadToolStripMenuItem.Size = new Size(192, 29); - LoadToolStripMenuItem.TabIndex = 0; - LoadToolStripMenuItem.Text = "Загрузить"; - LoadToolStripMenuItem.UseVisualStyleBackColor = true; + файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SaveToolStripMenuItem, LoadToolStripMenuItem }); + файлToolStripMenuItem.Name = "файлToolStripMenuItem"; + файлToolStripMenuItem.Size = new Size(59, 24); + файлToolStripMenuItem.Text = "Файл"; // // SaveToolStripMenuItem // - SaveToolStripMenuItem.Location = new Point(6, 26); SaveToolStripMenuItem.Name = "SaveToolStripMenuItem"; - SaveToolStripMenuItem.Size = new Size(192, 29); - SaveToolStripMenuItem.TabIndex = 1; + SaveToolStripMenuItem.Size = new Size(224, 26); SaveToolStripMenuItem.Text = "Сохранить"; - SaveToolStripMenuItem.UseVisualStyleBackColor = true; + SaveToolStripMenuItem.Click += SaveToolStripMenuItem_Click_1; + // + // LoadToolStripMenuItem + // + LoadToolStripMenuItem.Name = "LoadToolStripMenuItem"; + LoadToolStripMenuItem.Size = new Size(224, 26); + LoadToolStripMenuItem.Text = "Загрузить"; + LoadToolStripMenuItem.Click += LoadToolStripMenuItem_Click; + // + // openFileDialog + // + openFileDialog.FileName = "openFileDialog1"; // // FormAirplanesCollection // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1103, 453); + ClientSize = new Size(901, 492); Controls.Add(groupBoxAirplaneWithRadar); Controls.Add(pictureBoxAirplanesCollection); + Controls.Add(menuStrip1); Name = "FormAirplanesCollection"; Text = "FormAirplaneWithRadar"; ((System.ComponentModel.ISupportInitialize)pictureBoxAirplanesCollection).EndInit(); @@ -204,7 +213,8 @@ groupBoxAirplaneWithRadar.PerformLayout(); groupBoxCollection.ResumeLayout(false); groupBoxCollection.PerformLayout(); - groupBoxRecord.ResumeLayout(false); + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); ResumeLayout(false); PerformLayout(); } @@ -222,8 +232,11 @@ private ListBox listBoxStorages; private Button buttonAddObject; private TextBox textBoxStorageName; - private GroupBox groupBoxRecord; - private Button SaveToolStripMenuItem; - private Button LoadToolStripMenuItem; + private MenuStrip menuStrip1; + private ToolStripMenuItem файлToolStripMenuItem; + private ToolStripMenuItem SaveToolStripMenuItem; + private ToolStripMenuItem LoadToolStripMenuItem; + private OpenFileDialog openFileDialog; + private SaveFileDialog saveFileDialog; } } \ No newline at end of file diff --git a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.cs b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.cs index 47bf300..f6b043d 100644 --- a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.cs +++ b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.cs @@ -2,6 +2,7 @@ using ProjectAirplaneWithRadar.DrawningObjects; using ProjectAirplaneWithRadar.MovementStrategy; using ProjectAirplaneWithRadar.Generics; using System.Diagnostics.Metrics; +using System.Windows.Forms; namespace ProjectAirplaneWithRadar { @@ -139,5 +140,41 @@ namespace ProjectAirplaneWithRadar { } + private void SaveToolStripMenuItem_Click_1(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)) + { + MessageBox.Show(" ", + "", MessageBoxButtons.OK, MessageBoxIcon.Information); + foreach (var collection in _storage.Keys) + { + listBoxStorages.Items.Add(collection); + } + } + else + { + MessageBox.Show(" ", "", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } } } \ No newline at end of file diff --git a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.resx b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.resx index af32865..b9db4d6 100644 --- a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.resx +++ b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplanesCollection.resx @@ -117,4 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + 153, 17 + + + 323, 17 + \ No newline at end of file -- 2.25.1 From cf00e1bcc28a315d453c962174409ae3c5362e79 Mon Sep 17 00:00:00 2001 From: antoc0der <1@DESKTOP-K1L8ND3> Date: Fri, 24 Nov 2023 08:53:01 +0300 Subject: [PATCH 3/3] =?UTF-8?q?6=20=D0=BB=D0=B0=D0=B1=D0=B0=20-=20=D0=92?= =?UTF-8?q?=20=D0=A1=20=D0=81=20!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExtentionDrawningAirplane.cs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/ExtentionDrawningAirplane.cs b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/ExtentionDrawningAirplane.cs index b1ccb88..1b014fc 100644 --- a/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/ExtentionDrawningAirplane.cs +++ b/ProjectAirplaneWithRadar/ProjectAirplaneWithRadar/ExtentionDrawningAirplane.cs @@ -15,8 +15,7 @@ namespace ProjectAirplaneWithRadar string[] strs = info.Split(separatorForObject); if (strs.Length == 3) { - return new DrawningAirplane(Convert.ToInt32(strs[0]), - Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height); + return new DrawningAirplane(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height); } if (strs.Length == 6) { @@ -25,21 +24,19 @@ namespace ProjectAirplaneWithRadar Color.FromName(strs[2]), Color.FromName(strs[3]), Convert.ToBoolean(strs[4]), - Convert.ToBoolean(strs[6]), width, height); + Convert.ToBoolean(strs[5]), width, height); } return null; } - public static string GetDataForSave(this DrawningAirplane drawningAirplane, - char separatorForObject) + public static string GetDataForSave(this DrawningAirplane drawningAirplane,char separatorForObject) { - var car = drawningAirplane.EntityAirplane; - if (car == null) + var airplane = drawningAirplane.EntityAirplane; + if (airplane == null) { return string.Empty; } - var str = - $"{car.Speed}{separatorForObject}{car.Weight}{separatorForObject}{car.BodyColor.Name}"; - if (car is not EntityAirplaneWithRadar airplaneWithRadar) + var str = $"{airplane.Speed}{separatorForObject}{airplane.Weight}{separatorForObject}{airplane.BodyColor.Name}"; + if (airplane is not EntityAirplaneWithRadar airplaneWithRadar) { return str; } -- 2.25.1