From 3f999ba21f3328f8cc61032f1b7b7260dd2180e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BE=D1=84=D1=8C=D1=8F=20=D0=AF=D0=BA=D0=BE=D0=B1?= =?UTF-8?q?=D1=87=D1=83=D0=BA?= Date: Tue, 12 Dec 2023 05:49:34 +0400 Subject: [PATCH 01/10] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D1=91?= =?UTF-8?q?=D0=BC=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D1=8B-=D1=80=D0=B0?= =?UTF-8?q?=D1=81=D1=88=D0=B8=D1=80=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA=D1=82=D0=B0=20=D0=B8=D0=B7=20?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B8=20=D0=B8=20=D1=81=D1=82?= =?UTF-8?q?=D1=80=D0=BE=D0=BA=D1=83=20=D0=B8=D0=B7=20=D0=B8=D0=BD=D1=84?= =?UTF-8?q?=D0=BE=D1=80=D0=BC=D0=B0=D1=86=D0=B8=D0=B8=20=D0=BE=D0=B1=D1=8A?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sailboat/Sailboat/ExtentionDrawingBoat.cs | 64 +++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Sailboat/Sailboat/ExtentionDrawingBoat.cs diff --git a/Sailboat/Sailboat/ExtentionDrawingBoat.cs b/Sailboat/Sailboat/ExtentionDrawingBoat.cs new file mode 100644 index 0000000..d23753c --- /dev/null +++ b/Sailboat/Sailboat/ExtentionDrawingBoat.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using Sailboat.Entities; + +namespace Sailboat.DrawingObjects +{ + public static class ExtentionDrawingBoat + { + /// + /// Создание объекта из строки + /// + /// Строка с данными для создания объекта + /// Разделитель даннных + /// Ширина + /// Высота + /// Объект + public static DrawingBoat? CreateDrawingBoat(this string info, char separatorForObject, int width, int height) + { + string[] strs = info.Split(separatorForObject); + if (strs.Length == 3) + { + return new DrawingBoat(Convert.ToInt32(strs[0]), + Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height); + } + if (strs.Length == 6) + { + return new DrawingSailboat(Convert.ToInt32(strs[0]), + Convert.ToInt32(strs[1]), + Color.FromName(strs[2]), + Color.FromName(strs[3]), + Convert.ToBoolean(strs[4]), + Convert.ToBoolean(strs[5]), + width, height); + } + return null; + } + /// + /// Получение данных для сохранения в файл + /// + /// Сохраняемый объект + /// Разделитель даннных + /// Строка с данными по объекту + public static string GetDataForSave(this DrawingBoat drawingBoat, char separatorForObject) + { + var boat = drawingBoat.EntityBoat; + if (boat == null) + { + return string.Empty; + } + + var str = $"{boat.Speed}{separatorForObject}{boat.Weight}{separatorForObject}{boat.BodyColor.Name}"; + + if (boat is not EntitySailboat sailboat) + { + return str; + } + return $"{str}{separatorForObject}{sailboat.AdditionalColor.Name}{separatorForObject}{sailboat.Hull}{separatorForObject}{sailboat.Sail}"; + } + } +} \ No newline at end of file -- 2.25.1 From 63b089ed0316f211b58cb28bc8cc088b058c5ef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BE=D1=84=D1=8C=D1=8F=20=D0=AF=D0=BA=D0=BE=D0=B1?= =?UTF-8?q?=D1=87=D1=83=D0=BA?= Date: Tue, 12 Dec 2023 05:55:48 +0400 Subject: [PATCH 02/10] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D0=BC=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=20=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B0=D1=81=D1=81-=D0=BA=D0=BE=D0=BB=D0=BB=D0=B5?= =?UTF-8?q?=D0=BA=D1=86=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sailboat/Sailboat/BoatsGenericCollection.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sailboat/Sailboat/BoatsGenericCollection.cs b/Sailboat/Sailboat/BoatsGenericCollection.cs index 2597c5d..d167081 100644 --- a/Sailboat/Sailboat/BoatsGenericCollection.cs +++ b/Sailboat/Sailboat/BoatsGenericCollection.cs @@ -38,6 +38,10 @@ namespace Sailboat.Generics /// private readonly SetGeneric _collection; /// + /// Получение объектов коллекции + /// + public IEnumerable GetBoats => _collection.GetBoats(); + /// /// Конструктор /// /// -- 2.25.1 From 11d3f27aa5796a9ee5822555d14f2e7f5e184070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BE=D1=84=D1=8C=D1=8F=20=D0=AF=D0=BA=D0=BE=D0=B1?= =?UTF-8?q?=D1=87=D1=83=D0=BA?= Date: Tue, 12 Dec 2023 05:56:50 +0400 Subject: [PATCH 03/10] =?UTF-8?q?Revert=20"=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D1=8F=D0=B5=D0=BC=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=20?= =?UTF-8?q?=D0=B2=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81-=D0=BA=D0=BE=D0=BB?= =?UTF-8?q?=D0=BB=D0=B5=D0=BA=D1=86=D0=B8=D1=8E"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 63b089ed0316f211b58cb28bc8cc088b058c5ef5. --- Sailboat/Sailboat/BoatsGenericCollection.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Sailboat/Sailboat/BoatsGenericCollection.cs b/Sailboat/Sailboat/BoatsGenericCollection.cs index d167081..2597c5d 100644 --- a/Sailboat/Sailboat/BoatsGenericCollection.cs +++ b/Sailboat/Sailboat/BoatsGenericCollection.cs @@ -38,10 +38,6 @@ namespace Sailboat.Generics /// private readonly SetGeneric _collection; /// - /// Получение объектов коллекции - /// - public IEnumerable GetBoats => _collection.GetBoats(); - /// /// Конструктор /// /// -- 2.25.1 From fa32576f0725b5c1de7b749618f1d9463ad48167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BE=D1=84=D1=8C=D1=8F=20=D0=AF=D0=BA=D0=BE=D0=B1?= =?UTF-8?q?=D1=87=D1=83=D0=BA?= Date: Tue, 12 Dec 2023 05:56:58 +0400 Subject: [PATCH 04/10] =?UTF-8?q?Revert=20"=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0?= =?UTF-8?q?=D1=91=D0=BC=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D1=8B-=D1=80?= =?UTF-8?q?=D0=B0=D1=81=D1=88=D0=B8=D1=80=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 3f999ba21f3328f8cc61032f1b7b7260dd2180e7. --- Sailboat/Sailboat/ExtentionDrawingBoat.cs | 64 ----------------------- 1 file changed, 64 deletions(-) delete mode 100644 Sailboat/Sailboat/ExtentionDrawingBoat.cs diff --git a/Sailboat/Sailboat/ExtentionDrawingBoat.cs b/Sailboat/Sailboat/ExtentionDrawingBoat.cs deleted file mode 100644 index d23753c..0000000 --- a/Sailboat/Sailboat/ExtentionDrawingBoat.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using Sailboat.Entities; - -namespace Sailboat.DrawingObjects -{ - public static class ExtentionDrawingBoat - { - /// - /// Создание объекта из строки - /// - /// Строка с данными для создания объекта - /// Разделитель даннных - /// Ширина - /// Высота - /// Объект - public static DrawingBoat? CreateDrawingBoat(this string info, char separatorForObject, int width, int height) - { - string[] strs = info.Split(separatorForObject); - if (strs.Length == 3) - { - return new DrawingBoat(Convert.ToInt32(strs[0]), - Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height); - } - if (strs.Length == 6) - { - return new DrawingSailboat(Convert.ToInt32(strs[0]), - Convert.ToInt32(strs[1]), - Color.FromName(strs[2]), - Color.FromName(strs[3]), - Convert.ToBoolean(strs[4]), - Convert.ToBoolean(strs[5]), - width, height); - } - return null; - } - /// - /// Получение данных для сохранения в файл - /// - /// Сохраняемый объект - /// Разделитель даннных - /// Строка с данными по объекту - public static string GetDataForSave(this DrawingBoat drawingBoat, char separatorForObject) - { - var boat = drawingBoat.EntityBoat; - if (boat == null) - { - return string.Empty; - } - - var str = $"{boat.Speed}{separatorForObject}{boat.Weight}{separatorForObject}{boat.BodyColor.Name}"; - - if (boat is not EntitySailboat sailboat) - { - return str; - } - return $"{str}{separatorForObject}{sailboat.AdditionalColor.Name}{separatorForObject}{sailboat.Hull}{separatorForObject}{sailboat.Sail}"; - } - } -} \ No newline at end of file -- 2.25.1 From 6354bb8bd09572b686cd77f1ba2adada9cd411a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BE=D1=84=D1=8C=D1=8F=20=D0=AF=D0=BA=D0=BE=D0=B1?= =?UTF-8?q?=D1=87=D1=83=D0=BA?= Date: Tue, 12 Dec 2023 05:59:56 +0400 Subject: [PATCH 05/10] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D1=91?= =?UTF-8?q?=D0=BC=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D1=8B-=D1=80=D0=B0?= =?UTF-8?q?=D1=81=D1=88=D0=B8=D1=80=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA=D1=82=D0=B0=20=D0=B8=D0=B7=20?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B8=20=D0=B8=20=D1=81=D1=82?= =?UTF-8?q?=D1=80=D0=BE=D0=BA=D1=83=20=D0=B8=D0=B7=20=D0=B8=D0=BD=D1=84?= =?UTF-8?q?=D0=BE=D1=80=D0=BC=D0=B0=D1=86=D0=B8=D0=B8=20=D0=BE=D0=B1=D1=8A?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sailboat/Sailboat/ExtentionDrawingBoat.cs | 64 +++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Sailboat/Sailboat/ExtentionDrawingBoat.cs diff --git a/Sailboat/Sailboat/ExtentionDrawingBoat.cs b/Sailboat/Sailboat/ExtentionDrawingBoat.cs new file mode 100644 index 0000000..d23753c --- /dev/null +++ b/Sailboat/Sailboat/ExtentionDrawingBoat.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using Sailboat.Entities; + +namespace Sailboat.DrawingObjects +{ + public static class ExtentionDrawingBoat + { + /// + /// Создание объекта из строки + /// + /// Строка с данными для создания объекта + /// Разделитель даннных + /// Ширина + /// Высота + /// Объект + public static DrawingBoat? CreateDrawingBoat(this string info, char separatorForObject, int width, int height) + { + string[] strs = info.Split(separatorForObject); + if (strs.Length == 3) + { + return new DrawingBoat(Convert.ToInt32(strs[0]), + Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height); + } + if (strs.Length == 6) + { + return new DrawingSailboat(Convert.ToInt32(strs[0]), + Convert.ToInt32(strs[1]), + Color.FromName(strs[2]), + Color.FromName(strs[3]), + Convert.ToBoolean(strs[4]), + Convert.ToBoolean(strs[5]), + width, height); + } + return null; + } + /// + /// Получение данных для сохранения в файл + /// + /// Сохраняемый объект + /// Разделитель даннных + /// Строка с данными по объекту + public static string GetDataForSave(this DrawingBoat drawingBoat, char separatorForObject) + { + var boat = drawingBoat.EntityBoat; + if (boat == null) + { + return string.Empty; + } + + var str = $"{boat.Speed}{separatorForObject}{boat.Weight}{separatorForObject}{boat.BodyColor.Name}"; + + if (boat is not EntitySailboat sailboat) + { + return str; + } + return $"{str}{separatorForObject}{sailboat.AdditionalColor.Name}{separatorForObject}{sailboat.Hull}{separatorForObject}{sailboat.Sail}"; + } + } +} \ No newline at end of file -- 2.25.1 From 9922330fe62bad4b436b4f2588759c6b6c55fd1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BE=D1=84=D1=8C=D1=8F=20=D0=AF=D0=BA=D0=BE=D0=B1?= =?UTF-8?q?=D1=87=D1=83=D0=BA?= Date: Tue, 12 Dec 2023 06:01:50 +0400 Subject: [PATCH 06/10] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D0=BC=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=20=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B0=D1=81=D1=81-=D0=BA=D0=BE=D0=BB=D0=BB=D0=B5?= =?UTF-8?q?=D0=BA=D1=86=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sailboat/Sailboat/BoatsGenericCollection.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sailboat/Sailboat/BoatsGenericCollection.cs b/Sailboat/Sailboat/BoatsGenericCollection.cs index 2597c5d..d167081 100644 --- a/Sailboat/Sailboat/BoatsGenericCollection.cs +++ b/Sailboat/Sailboat/BoatsGenericCollection.cs @@ -38,6 +38,10 @@ namespace Sailboat.Generics /// private readonly SetGeneric _collection; /// + /// Получение объектов коллекции + /// + public IEnumerable GetBoats => _collection.GetBoats(); + /// /// Конструктор /// /// -- 2.25.1 From 0a8063ab9ecfb4ad8954a9cc2c4d4faee18fb81e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BE=D1=84=D1=8C=D1=8F=20=D0=AF=D0=BA=D0=BE=D0=B1?= =?UTF-8?q?=D1=87=D1=83=D0=BA?= Date: Tue, 12 Dec 2023 06:11:47 +0400 Subject: [PATCH 07/10] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D1=91?= =?UTF-8?q?=D0=BC=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D1=8B=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B8=20=D0=B8=20=D1=81=D0=BE?= =?UTF-8?q?=D1=85=D1=80=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2=20?= =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sailboat/Sailboat/BoatsGenericStorage.cs | 101 +++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/Sailboat/Sailboat/BoatsGenericStorage.cs b/Sailboat/Sailboat/BoatsGenericStorage.cs index 8702e41..9e83887 100644 --- a/Sailboat/Sailboat/BoatsGenericStorage.cs +++ b/Sailboat/Sailboat/BoatsGenericStorage.cs @@ -28,6 +28,18 @@ namespace Sailboat.Generics /// private readonly int _pictureHeight; /// + /// Разделитель для записи ключа и значения элемента словаря + /// + private static readonly char _separatorForKeyValue = '|'; + /// + /// Разделитель для записей коллекции данных в файл + /// + private readonly char _separatorRecords = ';'; + /// + /// Разделитель для записи информации по объекту в файл + /// + private static readonly char _separatorForObject = ':'; + /// /// Конструктор /// /// @@ -80,5 +92,94 @@ namespace Sailboat.Generics return null; } } + + /// + /// Сохранение информации по автомобилям в хранилище в файл + /// + /// Путь и имя файла + /// true - сохранение прошло успешно, false - ошибка при сохранении данных + public bool SaveData(string filename) + { + if (File.Exists(filename)) + { + File.Delete(filename); + } + StringBuilder data = new(); + foreach (KeyValuePair> record in _boatStorages) + { + StringBuilder records = new(); + foreach (DrawingBoat? elem in record.Value.GetBoats) + { + records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}"); + } + data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}"); + } + if (data.Length == 0) + { + return false; + } + using (StreamWriter writer = new StreamWriter(filename)) + { + writer.Write($"PlaneStorage{Environment.NewLine}{data}"); + } + return true; + } + /// + /// Загрузка информации по автомобилям в хранилище из файла + /// + /// Путь и имя файла + /// true - загрузка прошла успешно, false - ошибка призагрузке данных + public bool LoadData(string filename) + { + if (!File.Exists(filename)) + { + return false; + } + + using (StreamReader fs = File.OpenText(filename)) + { + string str = fs.ReadLine(); + if (str == null || str.Length == 0) + { + return false; + } + if (!str.StartsWith("BoatStorage")) + { + return false; + } + + _boatStorages.Clear(); + string strs = ""; + + while ((strs = fs.ReadLine()) != null) + { + if (strs == null) + { + return false; + } + + string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries); + if (record.Length != 2) + { + continue; + } + BoatsGenericCollection collection = new(_pictureWidth, _pictureHeight); + string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries); + foreach (string elem in set) + { + DrawingBoat? boat = elem?.CreateDrawingBoat(_separatorForObject, _pictureWidth, _pictureHeight); + if (boat != null) + { + if (!(collection + boat)) + { + return false; + } + } + } + _boatStorages.Add(record[0], collection); + } + return true; + } + } } } \ No newline at end of file -- 2.25.1 From f27e269a996ad260d1dfc3e2b36f605199419f0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BE=D1=84=D1=8C=D1=8F=20=D0=AF=D0=BA=D0=BE=D0=B1?= =?UTF-8?q?=D1=87=D1=83=D0=BA?= Date: Tue, 12 Dec 2023 07:05:21 +0400 Subject: [PATCH 08/10] =?UTF-8?q?=D0=9E=D0=B1=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D0=B0=20=D0=B2=D1=8B=D0=B7=D0=BE=D0=B2=D0=BE=D0=B2?= =?UTF-8?q?=20=D0=BF=D1=83=D0=BD=D0=BA=D1=82=D0=BE=D0=B2=20=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sailboat/FormBoatCollection.Designer.cs | 64 +++++++++++++++++-- Sailboat/Sailboat/FormBoatCollection.cs | 35 ++++++++++ Sailboat/Sailboat/FormBoatCollection.resx | 9 +++ 3 files changed, 104 insertions(+), 4 deletions(-) diff --git a/Sailboat/Sailboat/FormBoatCollection.Designer.cs b/Sailboat/Sailboat/FormBoatCollection.Designer.cs index 8c18720..7968f58 100644 --- a/Sailboat/Sailboat/FormBoatCollection.Designer.cs +++ b/Sailboat/Sailboat/FormBoatCollection.Designer.cs @@ -39,9 +39,16 @@ listBoxStorages = new ListBox(); buttonDelObject = new Button(); buttonAddObject = new Button(); + menuStrip = new MenuStrip(); + ToolStripMenuItem = new ToolStripMenuItem(); + SaveToolStripMenuItem = new ToolStripMenuItem(); + LoadToolStripMenuItem = new ToolStripMenuItem(); + openFileDialog = new OpenFileDialog(); + saveFileDialog = new SaveFileDialog(); ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit(); groupBoxTools.SuspendLayout(); groupBoxCollection.SuspendLayout(); + menuStrip.SuspendLayout(); SuspendLayout(); // // pictureBoxCollection @@ -55,7 +62,7 @@ // // buttonAddBoat // - buttonAddBoat.Location = new Point(5, 345); + buttonAddBoat.Location = new Point(5, 402); buttonAddBoat.Name = "buttonAddBoat"; buttonAddBoat.Size = new Size(197, 45); buttonAddBoat.TabIndex = 1; @@ -65,7 +72,7 @@ // // buttonRemoveBoat // - buttonRemoveBoat.Location = new Point(5, 462); + buttonRemoveBoat.Location = new Point(5, 486); buttonRemoveBoat.Name = "buttonRemoveBoat"; buttonRemoveBoat.Size = new Size(197, 45); buttonRemoveBoat.TabIndex = 2; @@ -85,7 +92,7 @@ // // maskedTextBoxNumber // - maskedTextBoxNumber.Location = new Point(39, 429); + maskedTextBoxNumber.Location = new Point(39, 453); maskedTextBoxNumber.Name = "maskedTextBoxNumber"; maskedTextBoxNumber.Size = new Size(138, 27); maskedTextBoxNumber.TabIndex = 4; @@ -97,6 +104,7 @@ groupBoxTools.Controls.Add(buttonRefreshCollection); groupBoxTools.Controls.Add(maskedTextBoxNumber); groupBoxTools.Controls.Add(buttonRemoveBoat); + groupBoxTools.Controls.Add(menuStrip); groupBoxTools.Location = new Point(756, 12); groupBoxTools.Name = "groupBoxTools"; groupBoxTools.Size = new Size(209, 588); @@ -110,7 +118,7 @@ groupBoxCollection.Controls.Add(listBoxStorages); groupBoxCollection.Controls.Add(buttonDelObject); groupBoxCollection.Controls.Add(buttonAddObject); - groupBoxCollection.Location = new Point(6, 26); + groupBoxCollection.Location = new Point(6, 75); groupBoxCollection.Name = "groupBoxCollection"; groupBoxCollection.Size = new Size(196, 299); groupBoxCollection.TabIndex = 5; @@ -154,6 +162,46 @@ buttonAddObject.UseVisualStyleBackColor = true; buttonAddObject.Click += buttonAddObject_Click; // + // menuStrip + // + menuStrip.ImageScalingSize = new Size(20, 20); + menuStrip.Items.AddRange(new ToolStripItem[] { ToolStripMenuItem }); + menuStrip.Location = new Point(3, 23); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(203, 28); + menuStrip.TabIndex = 6; + menuStrip.Text = "menuStrip"; + // + // ToolStripMenuItem + // + ToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SaveToolStripMenuItem, LoadToolStripMenuItem }); + ToolStripMenuItem.Name = "ToolStripMenuItem"; + ToolStripMenuItem.Size = new Size(59, 24); + ToolStripMenuItem.Text = "Файл"; + // + // SaveToolStripMenuItem + // + SaveToolStripMenuItem.Name = "SaveToolStripMenuItem"; + SaveToolStripMenuItem.Size = new Size(224, 26); + SaveToolStripMenuItem.Text = "Сохранение"; + SaveToolStripMenuItem.Click += SaveToolStripMenuItem_Click; + // + // LoadToolStripMenuItem + // + LoadToolStripMenuItem.Name = "LoadToolStripMenuItem"; + LoadToolStripMenuItem.Size = new Size(224, 26); + LoadToolStripMenuItem.Text = "Загрузка"; + LoadToolStripMenuItem.Click += LoadToolStripMenuItem_Click; + // + // openFileDialog + // + openFileDialog.FileName = "openFileDialog"; + openFileDialog.Filter = "txt file | *.txt"; + // + // saveFileDialog + // + saveFileDialog.Filter = "txt file | *.txt"; + // // FormBoatCollection // AutoScaleDimensions = new SizeF(8F, 20F); @@ -168,6 +216,8 @@ groupBoxTools.PerformLayout(); groupBoxCollection.ResumeLayout(false); groupBoxCollection.PerformLayout(); + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); ResumeLayout(false); PerformLayout(); } @@ -185,5 +235,11 @@ private Button buttonDelObject; private Button buttonAddObject; private TextBox textBoxStorageName; + private MenuStrip menuStrip; + private ToolStripMenuItem ToolStripMenuItem; + private ToolStripMenuItem SaveToolStripMenuItem; + private ToolStripMenuItem LoadToolStripMenuItem; + private OpenFileDialog openFileDialog; + private SaveFileDialog saveFileDialog; } } \ No newline at end of file diff --git a/Sailboat/Sailboat/FormBoatCollection.cs b/Sailboat/Sailboat/FormBoatCollection.cs index 8a14039..ad3b6a0 100644 --- a/Sailboat/Sailboat/FormBoatCollection.cs +++ b/Sailboat/Sailboat/FormBoatCollection.cs @@ -148,5 +148,40 @@ namespace Sailboat ReloadObjects(); } } + + 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)) + { + MessageBox.Show("Загрузка прошла успешно", + "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + else + { + MessageBox.Show("Не загрузилось", "Результат", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + ReloadObjects(); + } } } diff --git a/Sailboat/Sailboat/FormBoatCollection.resx b/Sailboat/Sailboat/FormBoatCollection.resx index af32865..2f735f9 100644 --- a/Sailboat/Sailboat/FormBoatCollection.resx +++ b/Sailboat/Sailboat/FormBoatCollection.resx @@ -117,4 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 480, 17 + + + 608, 17 + + + 778, 17 + \ No newline at end of file -- 2.25.1 From c7f88176851a183aa8112772c6f875dfbc9c5c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BE=D1=84=D1=8C=D1=8F=20=D0=AF=D0=BA=D0=BE=D0=B1?= =?UTF-8?q?=D1=87=D1=83=D0=BA?= Date: Tue, 12 Dec 2023 07:35:17 +0400 Subject: [PATCH 09/10] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sailboat/Sailboat/BoatsGenericStorage.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sailboat/Sailboat/BoatsGenericStorage.cs b/Sailboat/Sailboat/BoatsGenericStorage.cs index 9e83887..b9e421f 100644 --- a/Sailboat/Sailboat/BoatsGenericStorage.cs +++ b/Sailboat/Sailboat/BoatsGenericStorage.cs @@ -94,7 +94,7 @@ namespace Sailboat.Generics } /// - /// Сохранение информации по автомобилям в хранилище в файл + /// Сохранение информации по лодкам в хранилище в файл /// /// Путь и имя файла /// true - сохранение прошло успешно, false - ошибка при сохранении данных @@ -125,7 +125,7 @@ namespace Sailboat.Generics return true; } /// - /// Загрузка информации по автомобилям в хранилище из файла + /// Загрузка информации по лодкам в хранилище из файла /// /// Путь и имя файла /// true - загрузка прошла успешно, false - ошибка призагрузке данных -- 2.25.1 From 77510e0be1e054b22309318bef50d1bf2b6a7c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BE=D1=84=D1=8C=D1=8F=20=D0=AF=D0=BA=D0=BE=D0=B1?= =?UTF-8?q?=D1=87=D1=83=D0=BA?= Date: Tue, 12 Dec 2023 12:22:36 +0400 Subject: [PATCH 10/10] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D1=8F=20=D0=BB=D0=B0=D0=B1=D0=B0=20=E2=84=966?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sailboat/Sailboat/BoatsGenericStorage.cs | 2 +- Sailboat/Sailboat/FormBoatCollection.Designer.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Sailboat/Sailboat/BoatsGenericStorage.cs b/Sailboat/Sailboat/BoatsGenericStorage.cs index b9e421f..a1f376b 100644 --- a/Sailboat/Sailboat/BoatsGenericStorage.cs +++ b/Sailboat/Sailboat/BoatsGenericStorage.cs @@ -120,7 +120,7 @@ namespace Sailboat.Generics } using (StreamWriter writer = new StreamWriter(filename)) { - writer.Write($"PlaneStorage{Environment.NewLine}{data}"); + writer.Write($"BoatStorage{Environment.NewLine}{data}"); } return true; } diff --git a/Sailboat/Sailboat/FormBoatCollection.Designer.cs b/Sailboat/Sailboat/FormBoatCollection.Designer.cs index 7968f58..0de397b 100644 --- a/Sailboat/Sailboat/FormBoatCollection.Designer.cs +++ b/Sailboat/Sailboat/FormBoatCollection.Designer.cs @@ -182,24 +182,24 @@ // SaveToolStripMenuItem // SaveToolStripMenuItem.Name = "SaveToolStripMenuItem"; - SaveToolStripMenuItem.Size = new Size(224, 26); + SaveToolStripMenuItem.Size = new Size(177, 26); SaveToolStripMenuItem.Text = "Сохранение"; SaveToolStripMenuItem.Click += SaveToolStripMenuItem_Click; // // LoadToolStripMenuItem // LoadToolStripMenuItem.Name = "LoadToolStripMenuItem"; - LoadToolStripMenuItem.Size = new Size(224, 26); + LoadToolStripMenuItem.Size = new Size(177, 26); LoadToolStripMenuItem.Text = "Загрузка"; LoadToolStripMenuItem.Click += LoadToolStripMenuItem_Click; // // openFileDialog // - openFileDialog.FileName = "openFileDialog"; openFileDialog.Filter = "txt file | *.txt"; // // saveFileDialog // + saveFileDialog.FileName = "BoatSave"; saveFileDialog.Filter = "txt file | *.txt"; // // FormBoatCollection -- 2.25.1