From d27022c940270e0446ec4e1ae2da9f72ad9c7f02 Mon Sep 17 00:00:00 2001 From: devil_1nc Date: Mon, 7 Nov 2022 22:09:26 +0400 Subject: [PATCH 1/5] commit 1 --- ProjectPlane/ProjectPlane/ExtentionPlane.cs | 58 ++++++++++++ .../ProjectPlane/MapWithSetPlanesGeneric.cs | 25 +++++ ProjectPlane/ProjectPlane/MapsCollection.cs | 94 ++++++++++++++++++- 3 files changed, 172 insertions(+), 5 deletions(-) create mode 100644 ProjectPlane/ProjectPlane/ExtentionPlane.cs diff --git a/ProjectPlane/ProjectPlane/ExtentionPlane.cs b/ProjectPlane/ProjectPlane/ExtentionPlane.cs new file mode 100644 index 0000000..22720af --- /dev/null +++ b/ProjectPlane/ProjectPlane/ExtentionPlane.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPlane +{ + internal static class ExtentionPlane + { + + /// + /// Разделитель для записи информации по объекту в файл + /// + private static readonly char _separatorForObject = ':'; + /// + /// Создание объекта из строки + /// + /// + /// + public static DrawingPlane CreateDrawingplane(this string info) + { + string[] strs = info.Split(_separatorForObject); + if (strs.Length == 3) + { + return new DrawingPlane(Convert.ToInt32(strs[0]), + Convert.ToInt32(strs[1]), Color.FromName(strs[2])); + } + if (strs.Length == 6) + { + return new DrawingWarPlane(Convert.ToInt32(strs[0]), + Convert.ToInt32(strs[1]), Color.FromName(strs[2]), + Color.FromName(strs[3]), Convert.ToBoolean(strs[4]), + Convert.ToBoolean(strs[5])); + } + return null; + } + /// + /// Получение данных для сохранения в файл + /// + /// + /// + public static string GetDataForSave(this DrawingPlane drawingplane) + { + var plane = drawingplane.Plane; + var str = + $"{plane.Speed}{_separatorForObject}{plane.Weight}{_separatorForObject}{plane.BodyColor.Name}"; + if (plane is not EntityWarPlane warPlane) + { + return str; + } + return + $"{str}{_separatorForObject}{warPlane.DopColor.Name}{_separatorForObject}{warPlane.extraCell}" + + $"{_separatorForObject}{warPlane.SuperTurbine}{_separatorForObject}"; + } + + } +} diff --git a/ProjectPlane/ProjectPlane/MapWithSetPlanesGeneric.cs b/ProjectPlane/ProjectPlane/MapWithSetPlanesGeneric.cs index 1ded118..d03b30f 100644 --- a/ProjectPlane/ProjectPlane/MapWithSetPlanesGeneric.cs +++ b/ProjectPlane/ProjectPlane/MapWithSetPlanesGeneric.cs @@ -108,6 +108,31 @@ namespace ProjectPlane return new(_pictureWidth, _pictureHeight); } /// + /// Получение данных в виде строки + /// + /// + /// + public string GetData(char separatorType, char separatorData) + { + string data = $"{_map.GetType().Name}{separatorType}"; + foreach (var car in _setPlanes.GetPlanes()) + { + data += $"{car.GetInfo()}{separatorData}"; + } + return data; + } + /// + /// Загрузка списка из массива строк + /// + /// + public void LoadData(string[] records) + { + foreach (var rec in records) + { + _setPlanes.Insert(DrawingObject.Create(rec) as T); + } + } + /// /// "Взбалтываем" набор, чтобы все элементы оказались в начале /// private void Shaking() diff --git a/ProjectPlane/ProjectPlane/MapsCollection.cs b/ProjectPlane/ProjectPlane/MapsCollection.cs index bab6984..491c9f5 100644 --- a/ProjectPlane/ProjectPlane/MapsCollection.cs +++ b/ProjectPlane/ProjectPlane/MapsCollection.cs @@ -1,4 +1,5 @@ -namespace ProjectPlane +using System.Text; +namespace ProjectPlane { /// /// Класс для хранения коллекции карт @@ -8,7 +9,7 @@ /// /// Словарь (хранилище) с картами /// - readonly Dictionary> _mapStorages; + readonly Dictionary> _mapStorages; /// /// Возвращение списка названий карт /// @@ -26,9 +27,18 @@ /// /// /// + /// /// + /// Разделитель для записи информации по элементу словаря в файл + /// + private readonly char separatorDict = '|'; + /// + /// Разделитель для записей коллекции данных в файл + /// + private readonly char separatorData = ';'; + public MapsCollection(int pictureWidth, int pictureHeight) { - _mapStorages = new Dictionary>(); + _mapStorages = new Dictionary>(); _pictureWidth = pictureWidth; _pictureHeight = pictureHeight; } @@ -40,7 +50,7 @@ public void AddMap(string name, AbstractMap map) { if (!_mapStorages.ContainsKey(name)) - _mapStorages.Add(name, new MapWithSetPlanesGeneric(_pictureWidth, _pictureHeight, map)); + _mapStorages.Add(name, new MapWithSetPlanesGeneric(_pictureWidth, _pictureHeight, map)); } /// /// Удаление карты @@ -56,7 +66,7 @@ /// /// /// - public MapWithSetPlanesGeneric this[string ind] + public MapWithSetPlanesGeneric this[string ind] { get { @@ -64,5 +74,79 @@ return null; } } + /// + /// Метод записи информации в файл + /// + /// Строка, которую следует записать + /// Поток для записи + private static void WriteToFile(string text, FileStream stream) + { + byte[] info = new UTF8Encoding(true).GetBytes(text); + stream.Write(info, 0, info.Length); + } + public bool SaveData(string filename) + { + if (File.Exists(filename)) + { + File.Delete(filename); + } + using (FileStream fs = new(filename, FileMode.Create)) + { + WriteToFile($"MapsCollection{Environment.NewLine}", fs); + foreach (var storage in _mapStorages) + { + WriteToFile($"{storage.Key}{separatorDict}{storage.Value.GetData(separatorDict, separatorData)}{Environment.NewLine}", fs); + } + } + 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[0].Contains("MapsCollection")) + { + //если нет такой записи, то это не те данные + return false; + } + //очищаем записи + _mapStorages.Clear(); + for (int i = 1; i < strs.Length; ++i) + { + var elem = strs[i].Split(separatorDict); + AbstractMap map = null; + switch (elem[1]) + { + case "SimpleMap": + map = new SimpleMap(); + break; + case "SkyMap": + map = new SkyMap(); + break; + } + _mapStorages.Add(elem[0], new MapWithSetPlanesGeneric(_pictureWidth, _pictureHeight, map)); + _mapStorages[elem[0]].LoadData(elem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries)); + } + return true; + } } } \ No newline at end of file -- 2.25.1 From 88dcfeef927e69c04b82d691a0c6e9f5f087cf8d Mon Sep 17 00:00:00 2001 From: devil_1nc Date: Mon, 7 Nov 2022 23:23:09 +0400 Subject: [PATCH 2/5] commit 2 --- ProjectPlane/ProjectPlane/DrawingObject.cs | 6 ++ ProjectPlane/ProjectPlane/ExtentionPlane.cs | 2 +- .../FormMapWithSetPlanes.Designer.cs | 72 ++++++++++++++++--- .../ProjectPlane/FormMapWithSetPlanes.cs | 32 +++++++++ .../ProjectPlane/FormMapWithSetPlanes.resx | 9 +++ ProjectPlane/ProjectPlane/FormPlaneConfig.cs | 2 + ProjectPlane/ProjectPlane/IDrawingObject.cs | 7 ++ 7 files changed, 121 insertions(+), 9 deletions(-) diff --git a/ProjectPlane/ProjectPlane/DrawingObject.cs b/ProjectPlane/ProjectPlane/DrawingObject.cs index 18e6766..d228a40 100644 --- a/ProjectPlane/ProjectPlane/DrawingObject.cs +++ b/ProjectPlane/ProjectPlane/DrawingObject.cs @@ -36,5 +36,11 @@ namespace ProjectPlane { _plane.DrawTransport(g); } + + public string GetInfo() => _plane?.GetDataForSave(); + public static IDrawingObject Create(string data) => new DrawingObject(data.CreateDrawingPlane()); + } + } + diff --git a/ProjectPlane/ProjectPlane/ExtentionPlane.cs b/ProjectPlane/ProjectPlane/ExtentionPlane.cs index 22720af..dc6260c 100644 --- a/ProjectPlane/ProjectPlane/ExtentionPlane.cs +++ b/ProjectPlane/ProjectPlane/ExtentionPlane.cs @@ -18,7 +18,7 @@ namespace ProjectPlane /// /// /// - public static DrawingPlane CreateDrawingplane(this string info) + public static DrawingPlane CreateDrawingPlane(this string info) { string[] strs = info.Split(_separatorForObject); if (strs.Length == 3) diff --git a/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.Designer.cs b/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.Designer.cs index 239d1ca..7a40ffc 100644 --- a/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.Designer.cs +++ b/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.Designer.cs @@ -46,9 +46,16 @@ this.ButtonAddMap = new System.Windows.Forms.Button(); this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox(); this.pictureBox = new System.Windows.Forms.PictureBox(); + this.menuStrip = new System.Windows.Forms.MenuStrip(); + this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.loadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); + this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); this.groupBoxTools.SuspendLayout(); this.groupBoxMaps.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); + this.menuStrip.SuspendLayout(); this.SuspendLayout(); // // groupBoxTools @@ -64,9 +71,9 @@ this.groupBoxTools.Controls.Add(this.buttonAddPlane); this.groupBoxTools.Controls.Add(this.groupBoxMaps); this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right; - this.groupBoxTools.Location = new System.Drawing.Point(680, 0); + this.groupBoxTools.Location = new System.Drawing.Point(680, 24); this.groupBoxTools.Name = "groupBoxTools"; - this.groupBoxTools.Size = new System.Drawing.Size(204, 590); + this.groupBoxTools.Size = new System.Drawing.Size(204, 566); this.groupBoxTools.TabIndex = 0; this.groupBoxTools.TabStop = false; this.groupBoxTools.Text = "Tools"; @@ -76,7 +83,7 @@ this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonRight.BackgroundImage = global::ProjectPlane.Properties.Resources.right; this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonRight.Location = new System.Drawing.Point(133, 529); + this.buttonRight.Location = new System.Drawing.Point(133, 505); this.buttonRight.Name = "buttonRight"; this.buttonRight.Size = new System.Drawing.Size(50, 49); this.buttonRight.TabIndex = 14; @@ -88,7 +95,7 @@ this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonDown.BackgroundImage = global::ProjectPlane.Properties.Resources.down; this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonDown.Location = new System.Drawing.Point(77, 529); + this.buttonDown.Location = new System.Drawing.Point(77, 505); this.buttonDown.Name = "buttonDown"; this.buttonDown.Size = new System.Drawing.Size(50, 49); this.buttonDown.TabIndex = 13; @@ -100,7 +107,7 @@ this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonLeft.BackgroundImage = global::ProjectPlane.Properties.Resources.left; this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonLeft.Location = new System.Drawing.Point(21, 529); + this.buttonLeft.Location = new System.Drawing.Point(21, 505); this.buttonLeft.Name = "buttonLeft"; this.buttonLeft.Size = new System.Drawing.Size(50, 49); this.buttonLeft.TabIndex = 12; @@ -112,7 +119,7 @@ this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonUp.BackgroundImage = global::ProjectPlane.Properties.Resources.up; this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonUp.Location = new System.Drawing.Point(77, 472); + this.buttonUp.Location = new System.Drawing.Point(77, 448); this.buttonUp.Name = "buttonUp"; this.buttonUp.Size = new System.Drawing.Size(50, 49); this.buttonUp.TabIndex = 11; @@ -234,12 +241,50 @@ // pictureBox // this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.pictureBox.Location = new System.Drawing.Point(0, 0); + this.pictureBox.Location = new System.Drawing.Point(0, 24); this.pictureBox.Name = "pictureBox"; - this.pictureBox.Size = new System.Drawing.Size(680, 590); + this.pictureBox.Size = new System.Drawing.Size(680, 566); this.pictureBox.TabIndex = 1; this.pictureBox.TabStop = false; // + // menuStrip + // + this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.fileToolStripMenuItem}); + this.menuStrip.Location = new System.Drawing.Point(0, 0); + this.menuStrip.Name = "menuStrip"; + this.menuStrip.Size = new System.Drawing.Size(884, 24); + this.menuStrip.TabIndex = 2; + this.menuStrip.Text = "menuStrip1"; + // + // fileToolStripMenuItem + // + this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.saveToolStripMenuItem, + this.loadToolStripMenuItem}); + this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; + this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); + this.fileToolStripMenuItem.Text = "File"; + // + // saveToolStripMenuItem + // + this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; + this.saveToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.saveToolStripMenuItem.Text = "Save"; + this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click); + // + // loadToolStripMenuItem + // + this.loadToolStripMenuItem.Name = "loadToolStripMenuItem"; + this.loadToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.loadToolStripMenuItem.Text = "Load"; + this.loadToolStripMenuItem.Click += new System.EventHandler(this.loadToolStripMenuItem_Click); + // + // openFileDialog + // + this.openFileDialog.FileName = "openFileDialog1"; + this.openFileDialog.Filter = "text file | *.txt"; + // // FormMapWithSetPlanes // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -247,6 +292,8 @@ this.ClientSize = new System.Drawing.Size(884, 590); this.Controls.Add(this.pictureBox); this.Controls.Add(this.groupBoxTools); + this.Controls.Add(this.menuStrip); + this.MainMenuStrip = this.menuStrip; this.Name = "FormMapWithSetPlanes"; this.Text = "Map with object sets"; this.groupBoxTools.ResumeLayout(false); @@ -254,7 +301,10 @@ this.groupBoxMaps.ResumeLayout(false); this.groupBoxMaps.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); + this.menuStrip.ResumeLayout(false); + this.menuStrip.PerformLayout(); this.ResumeLayout(false); + this.PerformLayout(); } @@ -277,5 +327,11 @@ private Button buttonDown; private Button buttonLeft; private Button buttonUp; + private MenuStrip menuStrip; + private ToolStripMenuItem fileToolStripMenuItem; + private ToolStripMenuItem saveToolStripMenuItem; + private ToolStripMenuItem loadToolStripMenuItem; + private OpenFileDialog openFileDialog; + private SaveFileDialog saveFileDialog; } } \ No newline at end of file diff --git a/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.cs b/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.cs index 619fb67..aa927a9 100644 --- a/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.cs +++ b/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.cs @@ -231,5 +231,37 @@ namespace ProjectPlane } } + private void loadToolStripMenuItem_Click(object sender, EventArgs e) + { + if (openFileDialog.ShowDialog() == DialogResult.OK) + { + if (_mapsCollection.LoadData(openFileDialog.FileName)) + { + MessageBox.Show("Succesfull loading", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + else + { + MessageBox.Show("Loading failed", "Result", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + ReloadMaps(); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + } + } + + private void saveToolStripMenuItem_Click(object sender, EventArgs e) + { + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + if (_mapsCollection.SaveData(saveFileDialog.FileName)) + { + MessageBox.Show("Succesfull saving", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + else + { + MessageBox.Show("Savingfailed", "Result", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + } } } diff --git a/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.resx b/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.resx index f298a7b..1d824c7 100644 --- a/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.resx +++ b/ProjectPlane/ProjectPlane/FormMapWithSetPlanes.resx @@ -57,4 +57,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + 125, 17 + + + 258, 17 + \ No newline at end of file diff --git a/ProjectPlane/ProjectPlane/FormPlaneConfig.cs b/ProjectPlane/ProjectPlane/FormPlaneConfig.cs index 72a7bce..71897fb 100644 --- a/ProjectPlane/ProjectPlane/FormPlaneConfig.cs +++ b/ProjectPlane/ProjectPlane/FormPlaneConfig.cs @@ -23,6 +23,8 @@ namespace ProjectPlane /// /// Конструктор /// + + delegate void MessageHandler(string message); public FormPlaneConfig() { InitializeComponent(); diff --git a/ProjectPlane/ProjectPlane/IDrawingObject.cs b/ProjectPlane/ProjectPlane/IDrawingObject.cs index 7e27543..097c15a 100644 --- a/ProjectPlane/ProjectPlane/IDrawingObject.cs +++ b/ProjectPlane/ProjectPlane/IDrawingObject.cs @@ -36,5 +36,12 @@ namespace ProjectPlane /// /// (float Left, float Right, float Top, float Bottom) GetCurrentPosition(); + + /// + /// Получение информации по объекту + /// + /// + string GetInfo(); + } } -- 2.25.1 From b516a248df2d898324b8c516aa56d39a403193a5 Mon Sep 17 00:00:00 2001 From: devil_1nc Date: Tue, 8 Nov 2022 17:27:10 +0400 Subject: [PATCH 3/5] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB(?= =?UTF-8?q?=D0=B0)=20=D0=BD=D0=B0=20'ProjectPlane/ProjectPlane/MapsCollect?= =?UTF-8?q?ion.cs'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectPlane/ProjectPlane/MapsCollection.cs | 60 +++++++++------------ 1 file changed, 24 insertions(+), 36 deletions(-) diff --git a/ProjectPlane/ProjectPlane/MapsCollection.cs b/ProjectPlane/ProjectPlane/MapsCollection.cs index 491c9f5..24d9226 100644 --- a/ProjectPlane/ProjectPlane/MapsCollection.cs +++ b/ProjectPlane/ProjectPlane/MapsCollection.cs @@ -84,20 +84,13 @@ namespace ProjectPlane byte[] info = new UTF8Encoding(true).GetBytes(text); stream.Write(info, 0, info.Length); } - public bool SaveData(string filename) + + public bool SaveDict(string filename) { if (File.Exists(filename)) { File.Delete(filename); } - using (FileStream fs = new(filename, FileMode.Create)) - { - WriteToFile($"MapsCollection{Environment.NewLine}", fs); - foreach (var storage in _mapStorages) - { - WriteToFile($"{storage.Key}{separatorDict}{storage.Value.GetData(separatorDict, separatorData)}{Environment.NewLine}", fs); - } - } return true; } @@ -114,39 +107,34 @@ namespace ProjectPlane } string bufferTextFromFile = ""; using (FileStream fs = new(filename, FileMode.Open)) + using (StreamReader sr = new StreamReader(fs, Encoding.UTF8)) { - byte[] b = new byte[fs.Length]; - UTF8Encoding temp = new(true); - while (fs.Read(b, 0, b.Length) > 0) + string curLine = sr.ReadLine(); + + if (!curLine.Contains("MapsCollection")) { - bufferTextFromFile += temp.GetString(b); + return false; } - } - var strs = bufferTextFromFile.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); - if (!strs[0].Contains("MapsCollection")) - { - //если нет такой записи, то это не те данные - return false; - } - //очищаем записи - _mapStorages.Clear(); - for (int i = 1; i < strs.Length; ++i) - { - var elem = strs[i].Split(separatorDict); - AbstractMap map = null; - switch (elem[1]) + + _mapStorages.Clear(); + while ((curLine = sr.ReadLine()) != null) { - case "SimpleMap": - map = new SimpleMap(); - break; - case "SkyMap": - map = new SkyMap(); - break; + var elem = curLine.Split(separatorDict); + AbstractMap map = null; + switch (elem[1]) + { + case "SimpleMap": + map = new SimpleMap(); + break; + case "SkyMap": + map = new SkyMap(); + break; + } + _mapStorages.Add(elem[0], new MapWithSetPlanesGeneric(_pictureWidth, _pictureHeight, map)); + _mapStorages[elem[0]].LoadData(elem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries)); } - _mapStorages.Add(elem[0], new MapWithSetPlanesGeneric(_pictureWidth, _pictureHeight, map)); - _mapStorages[elem[0]].LoadData(elem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries)); + return true; } - return true; } } } \ No newline at end of file -- 2.25.1 From 270dda1a8fd590d2b81107665303e6ba00fb3814 Mon Sep 17 00:00:00 2001 From: devil_1nc Date: Tue, 8 Nov 2022 17:28:32 +0400 Subject: [PATCH 4/5] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB(?= =?UTF-8?q?=D0=B0)=20=D0=BD=D0=B0=20'ProjectPlane/ProjectPlane/ExtentionPl?= =?UTF-8?q?ane.cs'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectPlane/ProjectPlane/ExtentionPlane.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProjectPlane/ProjectPlane/ExtentionPlane.cs b/ProjectPlane/ProjectPlane/ExtentionPlane.cs index dc6260c..b8199f0 100644 --- a/ProjectPlane/ProjectPlane/ExtentionPlane.cs +++ b/ProjectPlane/ProjectPlane/ExtentionPlane.cs @@ -51,7 +51,7 @@ namespace ProjectPlane } return $"{str}{_separatorForObject}{warPlane.DopColor.Name}{_separatorForObject}{warPlane.extraCell}" + - $"{_separatorForObject}{warPlane.SuperTurbine}{_separatorForObject}"; + $"{_separatorForObject}{warPlane.SuperTurbine}"; } } -- 2.25.1 From 0379590e6461afcd9a1ca80fe93fa4ff1e6ad8b6 Mon Sep 17 00:00:00 2001 From: devil_1nc Date: Tue, 8 Nov 2022 17:31:30 +0400 Subject: [PATCH 5/5] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB(?= =?UTF-8?q?=D0=B0)=20=D0=BD=D0=B0=20'ProjectPlane/ProjectPlane/MapsCollect?= =?UTF-8?q?ion.cs'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectPlane/ProjectPlane/MapsCollection.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ProjectPlane/ProjectPlane/MapsCollection.cs b/ProjectPlane/ProjectPlane/MapsCollection.cs index 24d9226..891400b 100644 --- a/ProjectPlane/ProjectPlane/MapsCollection.cs +++ b/ProjectPlane/ProjectPlane/MapsCollection.cs @@ -84,16 +84,28 @@ namespace ProjectPlane byte[] info = new UTF8Encoding(true).GetBytes(text); stream.Write(info, 0, info.Length); } - - public bool SaveDict(string filename) + public bool SaveData(string filename) { if (File.Exists(filename)) { File.Delete(filename); } + using (FileStream fs = new(filename, FileMode.Create)) + using (StreamWriter sw = new StreamWriter(fs, Encoding.UTF8)) + { + sw.WriteLine("MapsCollection"); + foreach (var storage in _mapStorages) + { + + sw.WriteLine( + $"{storage.Key}{separatorDict}{storage.Value.GetData(separatorDict, separatorData)}" + ); + } + } return true; } + /// /// Загрузка нформации по автомобилям на парковках из файла /// -- 2.25.1