From 21ea2ca455b0823cf4234657fbf2e7479cde581e Mon Sep 17 00:00:00 2001
From: MariaBelkina <89656988623@mail.ru>
Date: Sat, 8 Jun 2024 20:58:52 +0400
Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=B0=206,=20=D0=B3=D0=B3?=
=?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../AbstractCompany.cs | 2 +-
.../ICollectoinGenericObjects.cs | 6 +-
.../ListGenericObjects.cs | 27 ++-
.../MassiveGenericObject.cs | 10 +-
.../StorageCollection.cs | 154 +++++++++++++++++-
.../Drawnings/DrawningBulldozer.cs | 15 ++
.../Drawnings/DrawningDozer.cs | 21 ++-
.../Entities/EntityBulldozer.cs | 26 ++-
.../FormBulldozerCollection.Designer.cs | 133 +++++++++++----
.../FormBulldozerCollection.cs | 48 ++++++
.../FormBulldozerCollection.resx | 9 +
11 files changed, 401 insertions(+), 50 deletions(-)
diff --git a/ProjectBulldozer/ProjectBulldozer/CollectionGenericObjects/AbstractCompany.cs b/ProjectBulldozer/ProjectBulldozer/CollectionGenericObjects/AbstractCompany.cs
index eec22a2..e974703 100644
--- a/ProjectBulldozer/ProjectBulldozer/CollectionGenericObjects/AbstractCompany.cs
+++ b/ProjectBulldozer/ProjectBulldozer/CollectionGenericObjects/AbstractCompany.cs
@@ -54,7 +54,7 @@ public abstract class AbstractCompany
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_collection = collectoin;
- _collection.SetMaxCount = GetMaxCount;
+ _collection.MaxCount = GetMaxCount;
}
///
diff --git a/ProjectBulldozer/ProjectBulldozer/CollectionGenericObjects/ICollectoinGenericObjects.cs b/ProjectBulldozer/ProjectBulldozer/CollectionGenericObjects/ICollectoinGenericObjects.cs
index ac2b282..e60fcae 100644
--- a/ProjectBulldozer/ProjectBulldozer/CollectionGenericObjects/ICollectoinGenericObjects.cs
+++ b/ProjectBulldozer/ProjectBulldozer/CollectionGenericObjects/ICollectoinGenericObjects.cs
@@ -21,7 +21,7 @@ public interface ICollectoinGenericObjects
///
/// Установка максимального колличества элементов
///
- int SetMaxCount { set; }
+ int MaxCount { get; set; }
///
/// Добавление элемента в коллекцию
@@ -55,10 +55,10 @@ public interface ICollectoinGenericObjects
///
/// Получение типа коллекции
///
- CollectionType GetCollecctionType { get; }
+ CollectionType GetCollectionType { get; }
///
- /// Получение объектов коллекции по одному.
+ /// Получение объектов коллекции по одному
///
/// Поэлементный вывод элементов коллекции
IEnumerable GetItems();
diff --git a/ProjectBulldozer/ProjectBulldozer/CollectionGenericObjects/ListGenericObjects.cs b/ProjectBulldozer/ProjectBulldozer/CollectionGenericObjects/ListGenericObjects.cs
index 29d6338..4f02aeb 100644
--- a/ProjectBulldozer/ProjectBulldozer/CollectionGenericObjects/ListGenericObjects.cs
+++ b/ProjectBulldozer/ProjectBulldozer/CollectionGenericObjects/ListGenericObjects.cs
@@ -25,7 +25,22 @@ public class ListGenericObjects : ICollectoinGenericObjects
public int Count => _collection.Count;
- public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } }
+ public int MaxCount {
+ get
+ {
+ return _collection.Count;
+ }
+
+ set
+ {
+ if (value > 0)
+ {
+ _maxCount = value;
+ }
+ }
+ }
+
+ public CollectionType GetCollectionType => CollectionType.List;
///
/// Конструктор
@@ -90,6 +105,12 @@ public class ListGenericObjects : ICollectoinGenericObjects
_collection[position] = null;
return obj;
}
-
- // TODO та же фигня, что и в MassiveGenericObject
+
+ public IEnumerable GetItems()
+ {
+ for (int i = 0; i < _collection.Count; ++i)
+ {
+ yield return _collection[i];
+ }
+ }
}
diff --git a/ProjectBulldozer/ProjectBulldozer/CollectionGenericObjects/MassiveGenericObject.cs b/ProjectBulldozer/ProjectBulldozer/CollectionGenericObjects/MassiveGenericObject.cs
index ecfc45d..2cc83b0 100644
--- a/ProjectBulldozer/ProjectBulldozer/CollectionGenericObjects/MassiveGenericObject.cs
+++ b/ProjectBulldozer/ProjectBulldozer/CollectionGenericObjects/MassiveGenericObject.cs
@@ -16,8 +16,12 @@ public class MassiveGenericObject : ICollectoinGenericObjects
public int Count => _collection.Length;
- public int SetMaxCount
- {
+ public int MaxCount
+ {
+ get
+ {
+ return _collection.Length;
+ }
set
{
if (value > 0)
@@ -34,6 +38,8 @@ public class MassiveGenericObject : ICollectoinGenericObjects
}
}
+ public CollectionType GetCollectionType => CollectionType.Massive;
+
///
/// Конструктор
///
diff --git a/ProjectBulldozer/ProjectBulldozer/CollectionGenericObjects/StorageCollection.cs b/ProjectBulldozer/ProjectBulldozer/CollectionGenericObjects/StorageCollection.cs
index 8e54847..8e934f3 100644
--- a/ProjectBulldozer/ProjectBulldozer/CollectionGenericObjects/StorageCollection.cs
+++ b/ProjectBulldozer/ProjectBulldozer/CollectionGenericObjects/StorageCollection.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using ProjectBulldozer.Drawnings;
namespace ProjectBulldozer.CollectionGenericObjects;
@@ -11,7 +12,7 @@ namespace ProjectBulldozer.CollectionGenericObjects;
///
///
public class StorageCollection
- where T : class
+ where T : DrawningDozer
{
///
/// Словарь (хранилище) с коллекциями
@@ -23,6 +24,21 @@ public class StorageCollection
///
public List Keys => _storages.Keys.ToList();
+ ///
+ /// Ключевое слово, с которого должен начианться файл
+ ///
+ private readonly string _collectionKey = "CollectionStorage";
+
+ ///
+ /// Разделитель для записи ключа и значения элемента словаря
+ ///
+ private readonly string _separatorForKeyValue = "|";
+
+ ///
+ /// Разделительдля записи коллекций данных в файл
+ ///
+ private readonly string _separatorItems = ";";
+
///
/// Конструктор
///
@@ -84,4 +100,140 @@ public class StorageCollection
return null;
}
}
+
+ ///
+ /// Сохранение информации по бульдозерам в хранилище в файла
+ ///
+ /// Путь и имя файла
+ /// true - сохранение прошло успешно, false - ошибка при сохранении данных
+ public bool SaveData(string filename)
+ {
+ if (_storages.Count == 0)
+ {
+ return false;
+ }
+
+ if (File.Exists(filename))
+ {
+ File.Delete(filename);
+ }
+
+ StringBuilder stringBuilder = new();
+
+ stringBuilder.Append(_collectionKey);
+ foreach (KeyValuePair> value in _storages)
+ {
+ stringBuilder.Append(Environment.NewLine);
+ // не сохраняем пустые коллекции.
+ if (value.Value.Count == 0)
+ {
+ continue;
+ }
+
+ stringBuilder.Append(value.Key);
+ stringBuilder.Append(_separatorForKeyValue);
+ stringBuilder.Append(value.Value.GetCollectionType);
+ stringBuilder.Append(_separatorForKeyValue);
+ stringBuilder.Append(value.Value.MaxCount);
+ stringBuilder.Append(_separatorForKeyValue);
+
+ foreach (T? item in value.Value.GetItems())
+ {
+ string data = item?.GetDataForSave() ?? string.Empty;
+ if (string.IsNullOrEmpty(data))
+ {
+ continue;
+ }
+
+ stringBuilder.Append(data);
+ stringBuilder.Append(_separatorItems);
+ }
+ }
+
+ using FileStream fileStream = new(filename, FileMode.Create);
+ byte[] info = new UTF8Encoding(true).GetBytes(stringBuilder.ToString());
+ fileStream.Write(info, 0, info.Length);
+ return true;
+ }
+
+ ///
+ /// Загрузка информации по бульдозерам в хранилище из файла
+ ///
+ /// Путь и имя файла
+ /// true- загрузка прошла успешно, false - ошибка при загрузке данных
+ public bool LoadData(string filename)
+ {
+ if (!File.Exists(filename)) return false;
+
+ string bufferTextfromFile = "";
+ using (FileStream fileStream = new(filename, FileMode.Open))
+ {
+ byte[] bytes = new byte[fileStream.Length];
+ UTF8Encoding temp = new(true);
+ while (fileStream.Read(bytes, 0, bytes.Length) > 0)
+ {
+ bufferTextfromFile += temp.GetString(bytes);
+ }
+ }
+
+ string[] strs = bufferTextfromFile.Split(new char[] { '\r', '\n'},
+ StringSplitOptions.RemoveEmptyEntries);
+ if (strs == null || strs.Length == 0)
+ {
+ return false;
+ }
+
+ if (!strs[0].Equals(_collectionKey))
+ {
+ // если нет такой записи, то это не те данные.
+ return false;
+ }
+
+ _storages.Clear();
+ foreach (string data in strs)
+ {
+ string[] record = data.Split(_separatorForKeyValue,
+ StringSplitOptions.RemoveEmptyEntries);
+ if (record.Length != 4)
+ {
+ continue;
+ }
+
+ CollectionType collectionType = (CollectionType)Enum.Parse(typeof(CollectionType), record[1]);
+ ICollectoinGenericObjects? collectoin = StorageCollection.CreateCollection(collectionType);
+
+ if (collectoin == null)
+ {
+ return false;
+ }
+
+ collectoin.MaxCount = Convert.ToInt32(record[2]);
+
+ string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
+
+ foreach (string elem in set)
+ {
+ if (elem?.CreateDrawningDozer() is T dozer)
+ {
+ if (collectoin.Insert(dozer) == -1)
+ {
+ return false;
+ }
+ }
+ }
+ _storages.Add(record[0], collectoin);
+ }
+ return true;
+ }
+
+
+ private static ICollectoinGenericObjects? CreateCollection(CollectionType collectionType)
+ {
+ return collectionType switch
+ {
+ CollectionType.Massive => new MassiveGenericObject(),
+ CollectionType.List => new ListGenericObjects(),
+ _ => null,
+ };
+ }
}
diff --git a/ProjectBulldozer/ProjectBulldozer/Drawnings/DrawningBulldozer.cs b/ProjectBulldozer/ProjectBulldozer/Drawnings/DrawningBulldozer.cs
index 49f71ab..00fe3da 100644
--- a/ProjectBulldozer/ProjectBulldozer/Drawnings/DrawningBulldozer.cs
+++ b/ProjectBulldozer/ProjectBulldozer/Drawnings/DrawningBulldozer.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using ProjectBulldozer.Entities;
@@ -12,6 +13,20 @@ namespace ProjectBulldozer.Drawnings;
///
public class DrawningBulldozer : DrawningDozer
{
+ private EntityDozer dozer;
+
+ ///
+ /// Другой конструктор.
+ ///
+ ///
+ public DrawningBulldozer(EntityDozer? entityDozer) : base(150, 90)
+ {
+ if (entityDozer != null)
+ {
+ EntityDozer = entityDozer;
+ }
+ }
+
///
///Конструктор
///
diff --git a/ProjectBulldozer/ProjectBulldozer/Drawnings/DrawningDozer.cs b/ProjectBulldozer/ProjectBulldozer/Drawnings/DrawningDozer.cs
index 4715602..807a58b 100644
--- a/ProjectBulldozer/ProjectBulldozer/Drawnings/DrawningDozer.cs
+++ b/ProjectBulldozer/ProjectBulldozer/Drawnings/DrawningDozer.cs
@@ -36,6 +36,7 @@ public class DrawningDozer
/// Верхнаяя координата прорисовки бульдозера
///
protected int? _startPosY;
+ private EntityDozer dozer;
///
///Ширина прорисовки бульдозера
@@ -102,6 +103,16 @@ public class DrawningDozer
_pictureHeight = drawningBulldozerHeigh;
}
+ ///
+ /// Другой конструктор.
+ ///
+ ///
+ public DrawningDozer(EntityDozer? entityDozer)
+ {
+ if (entityDozer == null) return;
+ EntityDozer = entityDozer;
+ }
+
///
///Установка границ поля
///
@@ -243,19 +254,19 @@ public class DrawningDozer
Pen pen = new(Color.Black);
Brush bodyBrush = new SolidBrush(EntityDozer.BodyColor);
- Brush wheelsBrush = new SolidBrush(Color.FromArgb(60, 60, 60));
+ Brush wheelstringBuilderrush = new SolidBrush(Color.FromArgb(60, 60, 60));
//BULDOZER
//body
g.FillRectangle(bodyBrush, _startPosX.Value + 10, _startPosY.Value + 15, _drawningBulldozerWidth - 20, _drawningBulldozerHeight - 30);
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 15, _drawningBulldozerWidth - 20, _drawningBulldozerHeight - 30);
//wheels
- g.FillRectangle(wheelsBrush, _startPosX.Value, _startPosY.Value + _drawningBulldozerHeight - 15, 50, 15);
+ g.FillRectangle(wheelstringBuilderrush, _startPosX.Value, _startPosY.Value + _drawningBulldozerHeight - 15, 50, 15);
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + _drawningBulldozerHeight - 15, 50, 15);
- g.FillRectangle(wheelsBrush, _startPosX.Value + _drawningBulldozerWidth - 50, _startPosY.Value + _drawningBulldozerHeight - 15, 50, 15);
+ g.FillRectangle(wheelstringBuilderrush, _startPosX.Value + _drawningBulldozerWidth - 50, _startPosY.Value + _drawningBulldozerHeight - 15, 50, 15);
g.DrawRectangle(pen, _startPosX.Value + _drawningBulldozerWidth - 50, _startPosY.Value + _drawningBulldozerHeight - 15, 50, 15);
- g.FillRectangle(wheelsBrush, _startPosX.Value, _startPosY.Value, 50, 15);
+ g.FillRectangle(wheelstringBuilderrush, _startPosX.Value, _startPosY.Value, 50, 15);
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value, 50, 15);
- g.FillRectangle(wheelsBrush, _startPosX.Value + _drawningBulldozerWidth - 50, _startPosY.Value, 50, 15);
+ g.FillRectangle(wheelstringBuilderrush, _startPosX.Value + _drawningBulldozerWidth - 50, _startPosY.Value, 50, 15);
g.DrawRectangle(pen, _startPosX.Value + _drawningBulldozerWidth - 50, _startPosY.Value, 50, 15);
//strange rectangles
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 25, 3, _drawningBulldozerHeight - 50);
diff --git a/ProjectBulldozer/ProjectBulldozer/Entities/EntityBulldozer.cs b/ProjectBulldozer/ProjectBulldozer/Entities/EntityBulldozer.cs
index c750552..a0769d0 100644
--- a/ProjectBulldozer/ProjectBulldozer/Entities/EntityBulldozer.cs
+++ b/ProjectBulldozer/ProjectBulldozer/Entities/EntityBulldozer.cs
@@ -50,5 +50,29 @@ public class EntityBulldozer : EntityDozer
Caterpillar = caterpillar;
}
- // TODO то же, что и в EntityDozer.
+
+ ///
+ /// Получение строк со значениями свойств объекта класса-сущности.
+ ///
+ ///
+ public override string[] GetStringRepresentation()
+ {
+ return new[] { nameof(EntityBulldozer), Speed.ToString(), Weight.ToString(), Weight.ToString(), BodyColor.Name,
+ AdditionalColor.Name, Blade.ToString(), Caterpillar.ToString() };
+ }
+
+ ///
+ /// Создание объекта из массива строк.
+ ///
+ ///
+ ///
+ public static EntityBulldozer? CreateEntityBulldozer(string[] strs)
+ {
+ if (strs.Length != 7 || strs[0] != nameof(EntityBulldozer))
+ {
+ return null;
+ }
+ return new EntityBulldozer(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]),
+ Color.FromName(strs[4]), Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]));
+ }
}
diff --git a/ProjectBulldozer/ProjectBulldozer/FormBulldozerCollection.Designer.cs b/ProjectBulldozer/ProjectBulldozer/FormBulldozerCollection.Designer.cs
index feb3d4a..d54eb9a 100644
--- a/ProjectBulldozer/ProjectBulldozer/FormBulldozerCollection.Designer.cs
+++ b/ProjectBulldozer/ProjectBulldozer/FormBulldozerCollection.Designer.cs
@@ -46,10 +46,17 @@
buttonCreateCompany = new Button();
comboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox();
+ menuStrip = new MenuStrip();
+ fileToolStripMenuItem = new ToolStripMenuItem();
+ saveToolStripMenuItem = new ToolStripMenuItem();
+ loadToolStripMenuItem = new ToolStripMenuItem();
+ saveFileDialog = new SaveFileDialog();
+ openFileDialog = new OpenFileDialog();
groupBoxTools.SuspendLayout();
panelCompanyTools.SuspendLayout();
panelStorage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
+ menuStrip.SuspendLayout();
SuspendLayout();
//
// groupBoxTools
@@ -60,9 +67,9 @@
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point);
- groupBoxTools.Location = new Point(1290, 0);
+ groupBoxTools.Location = new Point(1489, 41);
groupBoxTools.Name = "groupBoxTools";
- groupBoxTools.Size = new Size(358, 968);
+ groupBoxTools.Size = new Size(413, 963);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
@@ -75,18 +82,18 @@
panelCompanyTools.Controls.Add(buttonGoToCheck);
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Enabled = false;
- panelCompanyTools.Location = new Point(3, 624);
+ panelCompanyTools.Location = new Point(3, 602);
panelCompanyTools.Name = "panelCompanyTools";
- panelCompanyTools.Size = new Size(400, 345);
+ panelCompanyTools.Size = new Size(406, 356);
panelCompanyTools.TabIndex = 7;
//
// buttonAddDozer
//
buttonAddDozer.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddDozer.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point);
- buttonAddDozer.Location = new Point(11, 14);
+ buttonAddDozer.Location = new Point(13, 14);
buttonAddDozer.Name = "buttonAddDozer";
- buttonAddDozer.Size = new Size(332, 64);
+ buttonAddDozer.Size = new Size(383, 66);
buttonAddDozer.TabIndex = 2;
buttonAddDozer.Text = "Добавление бульдозера";
buttonAddDozer.UseVisualStyleBackColor = true;
@@ -96,9 +103,9 @@
//
buttonDelBulldozer.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonDelBulldozer.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point);
- buttonDelBulldozer.Location = new Point(11, 131);
+ buttonDelBulldozer.Location = new Point(13, 135);
buttonDelBulldozer.Name = "buttonDelBulldozer";
- buttonDelBulldozer.Size = new Size(332, 63);
+ buttonDelBulldozer.Size = new Size(383, 65);
buttonDelBulldozer.TabIndex = 3;
buttonDelBulldozer.Text = "Удаленить бульдозер";
buttonDelBulldozer.UseVisualStyleBackColor = true;
@@ -107,9 +114,10 @@
// maskedTextBox
//
maskedTextBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- maskedTextBox.Location = new Point(11, 84);
+ maskedTextBox.Location = new Point(13, 87);
+ maskedTextBox.Mask = "00";
maskedTextBox.Name = "maskedTextBox";
- maskedTextBox.Size = new Size(332, 41);
+ maskedTextBox.Size = new Size(382, 41);
maskedTextBox.TabIndex = 5;
maskedTextBox.ValidatingType = typeof(int);
//
@@ -117,9 +125,9 @@
//
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonGoToCheck.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point);
- buttonGoToCheck.Location = new Point(11, 200);
+ buttonGoToCheck.Location = new Point(13, 206);
buttonGoToCheck.Name = "buttonGoToCheck";
- buttonGoToCheck.Size = new Size(332, 63);
+ buttonGoToCheck.Size = new Size(383, 65);
buttonGoToCheck.TabIndex = 3;
buttonGoToCheck.Text = "Передать на тесты";
buttonGoToCheck.UseVisualStyleBackColor = true;
@@ -129,9 +137,9 @@
//
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point);
- buttonRefresh.Location = new Point(11, 269);
+ buttonRefresh.Location = new Point(13, 277);
buttonRefresh.Name = "buttonRefresh";
- buttonRefresh.Size = new Size(332, 63);
+ buttonRefresh.Size = new Size(383, 65);
buttonRefresh.TabIndex = 3;
buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true;
@@ -149,23 +157,23 @@
panelStorage.Dock = DockStyle.Top;
panelStorage.Location = new Point(3, 37);
panelStorage.Name = "panelStorage";
- panelStorage.Size = new Size(352, 465);
+ panelStorage.Size = new Size(407, 448);
panelStorage.TabIndex = 6;
//
// listBoxCollection
//
listBoxCollection.FormattingEnabled = true;
listBoxCollection.ItemHeight = 33;
- listBoxCollection.Location = new Point(11, 219);
+ listBoxCollection.Location = new Point(13, 209);
listBoxCollection.Name = "listBoxCollection";
- listBoxCollection.Size = new Size(332, 169);
+ listBoxCollection.Size = new Size(382, 169);
listBoxCollection.TabIndex = 5;
//
// buttonCollectionDel
//
- buttonCollectionDel.Location = new Point(11, 407);
+ buttonCollectionDel.Location = new Point(13, 394);
buttonCollectionDel.Name = "buttonCollectionDel";
- buttonCollectionDel.Size = new Size(332, 46);
+ buttonCollectionDel.Size = new Size(383, 47);
buttonCollectionDel.TabIndex = 4;
buttonCollectionDel.Text = "Удалить коллекцию";
buttonCollectionDel.UseVisualStyleBackColor = true;
@@ -173,9 +181,9 @@
//
// buttonCollectionAdd
//
- buttonCollectionAdd.Location = new Point(11, 157);
+ buttonCollectionAdd.Location = new Point(13, 144);
buttonCollectionAdd.Name = "buttonCollectionAdd";
- buttonCollectionAdd.Size = new Size(332, 46);
+ buttonCollectionAdd.Size = new Size(383, 47);
buttonCollectionAdd.TabIndex = 4;
buttonCollectionAdd.Text = "Добавить коллекцию";
buttonCollectionAdd.UseVisualStyleBackColor = true;
@@ -184,7 +192,7 @@
// radioButtonList
//
radioButtonList.AutoSize = true;
- radioButtonList.Location = new Point(183, 115);
+ radioButtonList.Location = new Point(211, 99);
radioButtonList.Name = "radioButtonList";
radioButtonList.Size = new Size(129, 37);
radioButtonList.TabIndex = 3;
@@ -195,7 +203,7 @@
// radioButtonMassive
//
radioButtonMassive.AutoSize = true;
- radioButtonMassive.Location = new Point(38, 115);
+ radioButtonMassive.Location = new Point(44, 99);
radioButtonMassive.Name = "radioButtonMassive";
radioButtonMassive.Size = new Size(130, 37);
radioButtonMassive.TabIndex = 2;
@@ -205,15 +213,15 @@
//
// textBoxCollectionName
//
- textBoxCollectionName.Location = new Point(11, 59);
+ textBoxCollectionName.Location = new Point(13, 48);
textBoxCollectionName.Name = "textBoxCollectionName";
- textBoxCollectionName.Size = new Size(332, 41);
+ textBoxCollectionName.Size = new Size(382, 41);
textBoxCollectionName.TabIndex = 1;
//
// labelCollectionName
//
labelCollectionName.AutoSize = true;
- labelCollectionName.Location = new Point(57, 13);
+ labelCollectionName.Location = new Point(54, 5);
labelCollectionName.Name = "labelCollectionName";
labelCollectionName.Size = new Size(263, 33);
labelCollectionName.TabIndex = 0;
@@ -221,9 +229,9 @@
//
// buttonCreateCompany
//
- buttonCreateCompany.Location = new Point(14, 572);
+ buttonCreateCompany.Location = new Point(16, 547);
buttonCreateCompany.Name = "buttonCreateCompany";
- buttonCreateCompany.Size = new Size(332, 46);
+ buttonCreateCompany.Size = new Size(383, 47);
buttonCreateCompany.TabIndex = 4;
buttonCreateCompany.Text = "Создать компанию";
buttonCreateCompany.UseVisualStyleBackColor = true;
@@ -236,28 +244,76 @@
comboBoxSelectorCompany.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point);
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
- comboBoxSelectorCompany.Location = new Point(14, 525);
+ comboBoxSelectorCompany.Location = new Point(16, 498);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
- comboBoxSelectorCompany.Size = new Size(332, 41);
+ comboBoxSelectorCompany.Size = new Size(382, 41);
comboBoxSelectorCompany.TabIndex = 1;
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
//
// pictureBox
//
pictureBox.Dock = DockStyle.Fill;
- pictureBox.Location = new Point(0, 0);
+ pictureBox.Location = new Point(0, 41);
pictureBox.Name = "pictureBox";
- pictureBox.Size = new Size(1290, 968);
+ pictureBox.Size = new Size(1489, 963);
pictureBox.TabIndex = 4;
pictureBox.TabStop = false;
//
+ // menuStrip
+ //
+ menuStrip.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point);
+ menuStrip.ImageScalingSize = new Size(32, 32);
+ menuStrip.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem });
+ menuStrip.Location = new Point(0, 0);
+ menuStrip.Name = "menuStrip";
+ menuStrip.Padding = new Padding(7, 2, 0, 2);
+ menuStrip.Size = new Size(1902, 41);
+ menuStrip.TabIndex = 5;
+ menuStrip.Text = "menuStrip";
+ //
+ // fileToolStripMenuItem
+ //
+ fileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem });
+ fileToolStripMenuItem.Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point);
+ fileToolStripMenuItem.Name = "fileToolStripMenuItem";
+ fileToolStripMenuItem.Size = new Size(93, 37);
+ fileToolStripMenuItem.Text = "Файл";
+ //
+ // saveToolStripMenuItem
+ //
+ saveToolStripMenuItem.Name = "saveToolStripMenuItem";
+ saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
+ saveToolStripMenuItem.Size = new Size(369, 44);
+ saveToolStripMenuItem.Text = "Сохранение";
+ saveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
+ //
+ // loadToolStripMenuItem
+ //
+ loadToolStripMenuItem.Name = "loadToolStripMenuItem";
+ loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
+ loadToolStripMenuItem.Size = new Size(369, 44);
+ loadToolStripMenuItem.Text = "Загрузка";
+ loadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
+ //
+ // saveFileDialog
+ //
+ saveFileDialog.Filter = "txt file | *.txt";
+ //
+ // openFileDialog
+ //
+ openFileDialog.FileName = "openFileDialog";
+ openFileDialog.Filter = "txt file | *.txt";
+ //
// FormBulldozerCollection
//
- AutoScaleDimensions = new SizeF(13F, 32F);
+ AutoScaleDimensions = new SizeF(15F, 33F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(1648, 968);
+ ClientSize = new Size(1902, 1004);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
+ Controls.Add(menuStrip);
+ Font = new Font("Comic Sans MS", 9F, FontStyle.Regular, GraphicsUnit.Point);
+ MainMenuStrip = menuStrip;
Name = "FormBulldozerCollection";
Text = "Коллекция бульдозеров";
groupBoxTools.ResumeLayout(false);
@@ -266,7 +322,10 @@
panelStorage.ResumeLayout(false);
panelStorage.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
+ menuStrip.ResumeLayout(false);
+ menuStrip.PerformLayout();
ResumeLayout(false);
+ PerformLayout();
}
#endregion
@@ -289,5 +348,11 @@
private Button buttonCollectionDel;
private Button buttonCreateCompany;
private Panel panelCompanyTools;
+ private MenuStrip menuStrip;
+ private ToolStripMenuItem fileToolStripMenuItem;
+ private ToolStripMenuItem saveToolStripMenuItem;
+ private ToolStripMenuItem loadToolStripMenuItem;
+ private SaveFileDialog saveFileDialog;
+ private OpenFileDialog openFileDialog;
}
}
\ No newline at end of file
diff --git a/ProjectBulldozer/ProjectBulldozer/FormBulldozerCollection.cs b/ProjectBulldozer/ProjectBulldozer/FormBulldozerCollection.cs
index a747f11..8fbbb24 100644
--- a/ProjectBulldozer/ProjectBulldozer/FormBulldozerCollection.cs
+++ b/ProjectBulldozer/ProjectBulldozer/FormBulldozerCollection.cs
@@ -10,6 +10,8 @@ using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
+using ProjectBulldozer.CollectionGenericObjects;
+using ProjectBulldozer.Drawnings;
namespace ProjectBulldozer;
@@ -359,4 +361,50 @@ public partial class FormBulldozerCollection : Form
panelCompanyTools.Enabled = true;
RefreshListBoxItems();
}
+
+ ///
+ /// Обработка нажатия "Сохранить"
+ ///
+ ///
+ ///
+ private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ if (saveFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ if (_storageCollection.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 (_storageCollection.LoadData(openFileDialog.FileName))
+ {
+ MessageBox.Show("Загрузка прошла успешно.", "Результат",
+ MessageBoxButtons.OK, MessageBoxIcon.Information);
+ RefreshListBoxItems();
+ }
+ else
+ {
+ MessageBox.Show("Загрузка не удалась!", "Результат",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
}
diff --git a/ProjectBulldozer/ProjectBulldozer/FormBulldozerCollection.resx b/ProjectBulldozer/ProjectBulldozer/FormBulldozerCollection.resx
index af32865..7fe5c91 100644
--- a/ProjectBulldozer/ProjectBulldozer/FormBulldozerCollection.resx
+++ b/ProjectBulldozer/ProjectBulldozer/FormBulldozerCollection.resx
@@ -117,4 +117,13 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ 17, 17
+
+
+ 204, 17
+
+
+ 447, 17
+
\ No newline at end of file