From 0b264223c2f7c206527a0b6a61484e8fba52b6a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Sun, 20 Nov 2022 22:07:29 +0400 Subject: [PATCH 01/13] =?UTF-8?q?=D0=A8=D0=B5=D1=81=D1=82=D0=B0=D1=8F=20?= =?UTF-8?q?=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DrawingObjectHoistingCrane.cs | 2 + .../HoistingCrane/ExtentionHoistingCrane.cs | 53 ++++++++++++++++++ HoistingCrane/HoistingCrane/IDrawingObject.cs | 1 + .../MapWithSetHoistingCraneGeneric.cs | 54 +++++++++++++------ .../HoistingCrane/SetHoistingCraneGeneric.cs | 2 +- 5 files changed, 94 insertions(+), 18 deletions(-) create mode 100644 HoistingCrane/HoistingCrane/ExtentionHoistingCrane.cs diff --git a/HoistingCrane/HoistingCrane/DrawingObjectHoistingCrane.cs b/HoistingCrane/HoistingCrane/DrawingObjectHoistingCrane.cs index 22138d0..2648791 100644 --- a/HoistingCrane/HoistingCrane/DrawingObjectHoistingCrane.cs +++ b/HoistingCrane/HoistingCrane/DrawingObjectHoistingCrane.cs @@ -30,5 +30,7 @@ namespace HoistingCrane { _hoistingCrane?.DrawTransport(g); } + public string GetInfo() => _hoistingCrane?.GetDataForSave(); + public static IDrawingObject Create(string data) => new DrawingObjectHoistingCrane(data.CreateDrawingHoistingCrane()); } } diff --git a/HoistingCrane/HoistingCrane/ExtentionHoistingCrane.cs b/HoistingCrane/HoistingCrane/ExtentionHoistingCrane.cs new file mode 100644 index 0000000..89f1b80 --- /dev/null +++ b/HoistingCrane/HoistingCrane/ExtentionHoistingCrane.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HoistingCrane +{ + internal static class ExtentionHoistingCrane + { + /// + /// Разделитель для записи информации по объекту в файл + /// + private static readonly char _separatorForObject = ':'; + /// + /// Создание объекта из строки + /// + /// + /// + public static DrawingHoistingCrane CreateDrawingHoistingCrane(this string info) + { + string[] strs = info.Split(_separatorForObject); + if (strs.Length == 3) + { + return new DrawingHoistingCrane(Convert.ToInt32(strs[0]), + Convert.ToInt32(strs[1]), Color.FromName(strs[2])); + } + if (strs.Length == 6) + { + return new DrawingAdvancedHoistingCrane(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 DrawingHoistingCrane DrawingHoistingCrane) + { + var hoistingCrane = DrawingHoistingCrane.HoistingCrane; + var str = $"{hoistingCrane.Speed}{_separatorForObject}{hoistingCrane.Weight}{_separatorForObject}{hoistingCrane.BodyColor.Name}"; + if (!(hoistingCrane is EntityAdvancedHoistingCrane HoistingCrane)) + { + return str; + } + return $"{str}{_separatorForObject}{HoistingCrane.DopColor.Name}{_separatorForObject}{HoistingCrane.Crane}{_separatorForObject}{HoistingCrane.Сounterweight}"; + } + } +} diff --git a/HoistingCrane/HoistingCrane/IDrawingObject.cs b/HoistingCrane/HoistingCrane/IDrawingObject.cs index cbdd2ac..9c0c409 100644 --- a/HoistingCrane/HoistingCrane/IDrawingObject.cs +++ b/HoistingCrane/HoistingCrane/IDrawingObject.cs @@ -13,5 +13,6 @@ namespace HoistingCrane void MoveObject(Direction direction); void DrawingObject(Graphics g); (float Left, float Right, float Top, float Bottom) GetCurrentPosition(); + string GetInfo(); } } diff --git a/HoistingCrane/HoistingCrane/MapWithSetHoistingCraneGeneric.cs b/HoistingCrane/HoistingCrane/MapWithSetHoistingCraneGeneric.cs index 4b1fb1d..d598f56 100644 --- a/HoistingCrane/HoistingCrane/MapWithSetHoistingCraneGeneric.cs +++ b/HoistingCrane/HoistingCrane/MapWithSetHoistingCraneGeneric.cs @@ -14,27 +14,27 @@ namespace HoistingCrane private readonly int _pictureHeight; private readonly int _placeSizeWidth = 200; private readonly int _placeSizeHeight = 120; - private readonly SetHoistingCraneGeneric _setHoistingCrane; + private readonly SetHoistingCraneGeneric _setHoistingCranes; private readonly U _map; public MapWithSetHoistingCraneGeneric(int picWidth, int picHeight, U map) { int width = picWidth / _placeSizeWidth; int height = picHeight / _placeSizeHeight; - _setHoistingCrane = new SetHoistingCraneGeneric(width * height); + _setHoistingCranes = new SetHoistingCraneGeneric(width * height); _pictureWidth = picWidth; _pictureHeight = picHeight; _map = map; } - public static int operator +(MapWithSetHoistingCraneGeneric map, T bulldozer) + public static int operator +(MapWithSetHoistingCraneGeneric map, T hoistingcrane) { - return map._setHoistingCrane.Insert(bulldozer); + return map._setHoistingCranes.Insert(hoistingcrane); } public static T operator -(MapWithSetHoistingCraneGeneric map, int position) { - return map._setHoistingCrane.Remove(position); + return map._setHoistingCranes.Remove(position); } public Bitmap ShowSet() @@ -42,14 +42,14 @@ namespace HoistingCrane Bitmap bmp = new(_pictureWidth, _pictureWidth); Graphics gr = Graphics.FromImage(bmp); DrawBackground(gr); - DrawBulldozers(gr); + DrawHoistingCranes(gr); return bmp; } public Bitmap ShowOnMap() { Shaking(); - foreach (var hoistingCrane in _setHoistingCrane.GetHoistingCrane()) + foreach (var hoistingCrane in _setHoistingCranes.GetHoistingCranes()) { return _map.CreateMap(_pictureWidth, _pictureHeight, hoistingCrane); } @@ -67,18 +67,18 @@ namespace HoistingCrane public void Shaking() { - int j = _setHoistingCrane.Count - 1; - for (int i = 0; i < _setHoistingCrane.Count; i++) + int j = _setHoistingCranes.Count - 1; + for (int i = 0; i < _setHoistingCranes.Count; i++) { - if (_setHoistingCrane[i] == null) + if (_setHoistingCranes[i] == null) { for (; j > i; j--) { - var warship = _setHoistingCrane[j]; + var warship = _setHoistingCranes[j]; if (warship != null) { - _setHoistingCrane.Insert(warship, i); - _setHoistingCrane.Remove(j); + _setHoistingCranes.Insert(warship, i); + _setHoistingCranes.Remove(j); break; } } @@ -103,22 +103,22 @@ namespace HoistingCrane } } - private void DrawBulldozers(Graphics gr) + private void DrawHoistingCranes(Graphics gr) { int heightEl = _pictureHeight / _placeSizeHeight; int widthEl = _pictureWidth / _placeSizeWidth; int curWidth = 3; int curHeight = 3; - for (int i = 0; i < _setHoistingCrane.Count; i++) + for (int i = 0; i < _setHoistingCranes.Count; i++) { if (curHeight < 0) { return; } - _setHoistingCrane[i]?.SetObject(curWidth * _placeSizeWidth + 10, + _setHoistingCranes[i]?.SetObject(curWidth * _placeSizeWidth + 10, curHeight * _placeSizeHeight + 10, _pictureWidth, _pictureHeight); - _setHoistingCrane[i]?.DrawingObject(gr); + _setHoistingCranes[i]?.DrawingObject(gr); if (curWidth == 0) { @@ -129,5 +129,25 @@ namespace HoistingCrane curWidth--; } } + public string GetData(char separatorType, char separatorData) + { + string data = $"{_map.GetType().Name}{separatorType}"; + foreach (var Boat in _setHoistingCranes.GetHoistingCranes()) + { + data += $"{Boat.GetInfo()}{separatorData}"; + } + return data; + } + /// + /// Загрузка списка из массива строк + /// + /// + public void LoadData(string[] records) + { + foreach (var rec in records) + { + _setHoistingCranes.Insert(DrawingObjectHoistingCrane.Create(rec) as T); + } + } } } diff --git a/HoistingCrane/HoistingCrane/SetHoistingCraneGeneric.cs b/HoistingCrane/HoistingCrane/SetHoistingCraneGeneric.cs index d44591d..bc14a0d 100644 --- a/HoistingCrane/HoistingCrane/SetHoistingCraneGeneric.cs +++ b/HoistingCrane/HoistingCrane/SetHoistingCraneGeneric.cs @@ -63,7 +63,7 @@ namespace HoistingCrane Insert(value, position); } } - public IEnumerable GetHoistingCrane() + public IEnumerable GetHoistingCranes() { foreach (var hoistingcrane in _places) { -- 2.25.1 From ec3080e9fdde986467ed79ca1960ff0ce69d45e6 Mon Sep 17 00:00:00 2001 From: RomanovEgor Date: Mon, 10 Oct 2022 20:03:36 +0400 Subject: [PATCH 02/13] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=BB(=D0=B0)=20=D0=BD=D0=B0=20'HoistingCrane/HoistingCrane/Fo?= =?UTF-8?q?rmHoistingCrane.cs'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HoistingCrane/HoistingCrane/EntityAdvancedHoistingCrane.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HoistingCrane/HoistingCrane/EntityAdvancedHoistingCrane.cs b/HoistingCrane/HoistingCrane/EntityAdvancedHoistingCrane.cs index 5d5baa9..8cbfa2b 100644 --- a/HoistingCrane/HoistingCrane/EntityAdvancedHoistingCrane.cs +++ b/HoistingCrane/HoistingCrane/EntityAdvancedHoistingCrane.cs @@ -14,11 +14,11 @@ namespace HoistingCrane public bool Сounterweight { get; private set; } public Color DopColor { get; set; } - public EntityAdvancedHoistingCrane(int speed, float weight, Color bodyColor, Color dopColor, bool crane, bool counterweight) : + public EntityAdvancedHoistingCrane(int speed, float weight, Color bodyColor, Color dopColor, bool crane, bool counterWeight) : base(speed, weight, bodyColor) { Crane = crane; - Сounterweight = counterweight; + Сounterweight = counterWeight; DopColor = dopColor; } } -- 2.25.1 From ad4adeb2628c57435e9706f56f68ce9cf238aacc Mon Sep 17 00:00:00 2001 From: RomanovEgor Date: Mon, 10 Oct 2022 20:03:36 +0400 Subject: [PATCH 03/13] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=BB(=D0=B0)=20=D0=BD=D0=B0=20'HoistingCrane/HoistingCrane/Fo?= =?UTF-8?q?rmHoistingCrane.cs'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HoistingCrane/FormHoistingCrane.cs | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/HoistingCrane/HoistingCrane/FormHoistingCrane.cs b/HoistingCrane/HoistingCrane/FormHoistingCrane.cs index a31b615..11440a2 100644 --- a/HoistingCrane/HoistingCrane/FormHoistingCrane.cs +++ b/HoistingCrane/HoistingCrane/FormHoistingCrane.cs @@ -68,26 +68,14 @@ Draw(); } - private void ButtonCreateModify_Click(object sender, EventArgs e) + /// + /// Èçìåíåíèå ðàçìåðîâ ôîðìû + /// + /// + /// + private void pictureBoxHoistingCrane_Resize(object sender, EventArgs e) { - Random rnd = new(); - Color selectedColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), - rnd.Next(0, 256)); - ColorDialog dialog = new(); - if (dialog.ShowDialog() == DialogResult.OK) - { - selectedColor = dialog.Color; - } - Color advancedSelectedColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), - rnd.Next(0, 256)); - ColorDialog dialogDop = new(); - if (dialogDop.ShowDialog() == DialogResult.OK) - { - advancedSelectedColor = dialogDop.Color; - } - _HoistingCrane = new DrawingAdvancedHoistingCrane(rnd.Next(30, 100), rnd.Next(300, 500), - selectedColor, advancedSelectedColor, Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2))); - SetData(); + _hoistingCrane?.ChangeBorders(pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height); Draw(); } -- 2.25.1 From 1dd50a48f4e77ff9c45af800b63aa038727906f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Sun, 4 Dec 2022 17:37:55 +0400 Subject: [PATCH 04/13] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HoistingCrane/HoistingCrane/AbstractMap.cs | 1 - .../HoistingCrane/DrawingHoistingCrane.cs | 4 - .../HoistingCrane/EntityHoistingCrane.cs | 4 - .../FormHoistingCrane.Designer.cs | 2 - .../HoistingCrane/FormHoistingCrane.cs | 13 +- .../FormHoistingCraneConfig.Designer.cs | 1 - .../HoistingCrane/FormHoistingCraneConfig.cs | 16 -- .../HoistingCrane/FormMap.Designer.cs | 208 ------------------ HoistingCrane/HoistingCrane/FormMap.cs | 88 -------- HoistingCrane/HoistingCrane/FormMap.resx | 60 ----- .../FormMapWithSetHoistingCrane.Designer.cs | 1 - .../FormMapWithSetHoistingCrane.cs | 14 -- .../HoistingCrane/HoistingCraneDelegate.cs | 2 +- .../MapWithSetHoistingCraneGeneric.cs | 9 - .../HoistingCrane/SetHoistingCraneGeneric.cs | 7 - 15 files changed, 2 insertions(+), 428 deletions(-) delete mode 100644 HoistingCrane/HoistingCrane/FormMap.Designer.cs delete mode 100644 HoistingCrane/HoistingCrane/FormMap.cs delete mode 100644 HoistingCrane/HoistingCrane/FormMap.resx diff --git a/HoistingCrane/HoistingCrane/AbstractMap.cs b/HoistingCrane/HoistingCrane/AbstractMap.cs index bf5f15c..43db729 100644 --- a/HoistingCrane/HoistingCrane/AbstractMap.cs +++ b/HoistingCrane/HoistingCrane/AbstractMap.cs @@ -103,7 +103,6 @@ namespace HoistingCrane else _drawingObject.MoveObject(SetOppositDirection(direction)); return DrawMapWithObject(); } - private Direction SetOppositDirection(Direction dir) { switch (dir) diff --git a/HoistingCrane/HoistingCrane/DrawingHoistingCrane.cs b/HoistingCrane/HoistingCrane/DrawingHoistingCrane.cs index abe97e9..0f0bea2 100644 --- a/HoistingCrane/HoistingCrane/DrawingHoistingCrane.cs +++ b/HoistingCrane/HoistingCrane/DrawingHoistingCrane.cs @@ -9,14 +9,12 @@ namespace HoistingCrane public class DrawingHoistingCrane { public EntityHoistingCrane HoistingCrane { get; protected set; } - protected float _startPosX; protected float _startPosY; private int? _pictureWidth = null; private int? _pictureHeight = null; private readonly int _hoistingCraneWidth = 80; private readonly int _hoistingCraneHeight = 50; - protected DrawingHoistingCrane(int speed, float weight, Color bodyColor, int hoistingCraneWidth, int hoistingCraneHeigth) : this(speed, weight, bodyColor) { @@ -27,7 +25,6 @@ namespace HoistingCrane { HoistingCrane = new EntityHoistingCrane(speed, weight, bodyColor); } - public void SetPosition(int x, int y, int width, int height) { // TODO checks @@ -36,7 +33,6 @@ namespace HoistingCrane _pictureWidth = width; _pictureHeight = height; } - public void MoveTransport(Direction direction) { if (!_pictureWidth.HasValue || !_pictureHeight.HasValue) diff --git a/HoistingCrane/HoistingCrane/EntityHoistingCrane.cs b/HoistingCrane/HoistingCrane/EntityHoistingCrane.cs index a02c614..cb0bd99 100644 --- a/HoistingCrane/HoistingCrane/EntityHoistingCrane.cs +++ b/HoistingCrane/HoistingCrane/EntityHoistingCrane.cs @@ -9,13 +9,9 @@ namespace HoistingCrane public class EntityHoistingCrane { public int Speed { get; private set; } - public float Weight { get; private set; } - public Color BodyColor { get; set; } - public float Step => Speed * 100 / Weight; - public EntityHoistingCrane(int speed, float weight, Color bodyColor) { Random rnd = new(); diff --git a/HoistingCrane/HoistingCrane/FormHoistingCrane.Designer.cs b/HoistingCrane/HoistingCrane/FormHoistingCrane.Designer.cs index 3a48eba..1286494 100644 --- a/HoistingCrane/HoistingCrane/FormHoistingCrane.Designer.cs +++ b/HoistingCrane/HoistingCrane/FormHoistingCrane.Designer.cs @@ -150,7 +150,6 @@ this.pictureBoxHoistingCrane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.pictureBoxHoistingCrane.TabIndex = 6; this.pictureBoxHoistingCrane.TabStop = false; - this.pictureBoxHoistingCrane.Click += new System.EventHandler(this.pictureBoxHoistingCrane_Click); this.pictureBoxHoistingCrane.Resize += new System.EventHandler(this.PictureBoxHoistingCrane_Resize); // // buttonCreateModify @@ -163,7 +162,6 @@ this.buttonCreateModify.TabIndex = 7; this.buttonCreateModify.Text = "Модификация"; this.buttonCreateModify.UseVisualStyleBackColor = true; - this.buttonCreateModify.Click += new System.EventHandler(this.ButtonCreateModify_Click); // // buttonSelect // diff --git a/HoistingCrane/HoistingCrane/FormHoistingCrane.cs b/HoistingCrane/HoistingCrane/FormHoistingCrane.cs index 11440a2..87d05c4 100644 --- a/HoistingCrane/HoistingCrane/FormHoistingCrane.cs +++ b/HoistingCrane/HoistingCrane/FormHoistingCrane.cs @@ -8,7 +8,6 @@ { InitializeComponent(); } - private void Draw() { Bitmap bmp = new(pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height); @@ -16,7 +15,6 @@ _HoistingCrane?.DrawTransport(gr); pictureBoxHoistingCrane.Image = bmp; } - private void SetData() { Random rnd = new(); @@ -25,7 +23,6 @@ toolStripStatusLabelWeight.Text = $"Вес: {_HoistingCrane.HoistingCrane.Weight}"; toolStripStatusLabelBodyColor.Text = $"Цвет:{_HoistingCrane.HoistingCrane.BodyColor.Name}"; } - private void ButtonCreate_Click(object sender, EventArgs e) { Random rnd = new(); @@ -40,7 +37,6 @@ SetData(); Draw(); } - private void ButtonMove_Click(object sender, EventArgs e) { string name = ((Button)sender)?.Name ?? string.Empty; @@ -61,13 +57,11 @@ } Draw(); } - private void PictureBoxHoistingCrane_Resize(object sender, EventArgs e) { _HoistingCrane?.ChangeBorders(pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height); Draw(); } - /// /// Èçìåíåíèå ðàçìåðîâ ôîðìû /// @@ -75,14 +69,9 @@ /// private void pictureBoxHoistingCrane_Resize(object sender, EventArgs e) { - _hoistingCrane?.ChangeBorders(pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height); + _HoistingCrane?.ChangeBorders(pictureBoxHoistingCrane.Width, pictureBoxHoistingCrane.Height); Draw(); } - - private void pictureBoxHoistingCrane_Click(object sender, EventArgs e) - { - - } private void ButtonSelect_Click(object sender, EventArgs e) { SelectedHoistingCrane = _HoistingCrane; diff --git a/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.Designer.cs b/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.Designer.cs index 384f26b..01eea5d 100644 --- a/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.Designer.cs +++ b/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.Designer.cs @@ -369,7 +369,6 @@ this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.Name = "FormHoistingCraneConfig"; this.Text = "Создание объекта"; - this.Load += new System.EventHandler(this.FormHoistingCraneConfig_Load); this.groupBoxConfig.ResumeLayout(false); this.groupBoxConfig.PerformLayout(); this.groupBoxColors.ResumeLayout(false); diff --git a/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs b/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs index f66c00b..0a24cae 100644 --- a/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs +++ b/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs @@ -15,10 +15,8 @@ namespace HoistingCrane //переменная-выбранный кран DrawingHoistingCrane _hoistingCrane = null; public DrawingHoistingCrane SelectedHoistingCrane { get; private set; } - //событие private event HoistingCraneDelegate EventAddHoistingCrane; - //конструктор public FormHoistingCraneConfig() { @@ -33,7 +31,6 @@ namespace HoistingCrane panelBlue.MouseDown += PanelColor_MouseDown; buttonCancel.Click += (object sender, EventArgs e) => Close(); } - //отрисовка кран private void DrawHoistingCrane() { @@ -43,7 +40,6 @@ namespace HoistingCrane _hoistingCrane?.DrawTransport(gr); pictureBoxObject.Image = bmp; } - //добавление события public void AddEvent(HoistingCraneDelegate ev) { @@ -56,7 +52,6 @@ namespace HoistingCrane EventAddHoistingCrane += ev; } } - private void LabelObject_MouseDown(object sender, MouseEventArgs e) { (sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy); @@ -74,7 +69,6 @@ namespace HoistingCrane e.Effect = DragDropEffects.None; } } - //действия при приеме перетаскиваемой информации private void PanelObject_DragDrop(object sender, DragEventArgs e) { @@ -91,13 +85,11 @@ namespace HoistingCrane DrawHoistingCrane(); } - //отправляем цвет с панели private void PanelColor_MouseDown(object sender, MouseEventArgs e) { (sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy); } - //проверка получаемой информации (её типа на соответсвие требуемому) private void LabelColor_DragEnter(object sender, DragEventArgs e) { @@ -110,7 +102,6 @@ namespace HoistingCrane e.Effect = DragDropEffects.None; } } - //принимаем основной цвет private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) { @@ -122,7 +113,6 @@ namespace HoistingCrane DrawHoistingCrane(); } } - //принимаем дополнительный цвет private void LabelDopColor_DragDrop(object sender, DragEventArgs e) { @@ -133,18 +123,12 @@ namespace HoistingCrane DrawHoistingCrane(); } } - //добавление крана private void ButtonAddObject_Click(object sender, EventArgs e) { EventAddHoistingCrane?.Invoke(_hoistingCrane); Close(); } - - private void FormHoistingCraneConfig_Load(object sender, EventArgs e) - { - - } } } diff --git a/HoistingCrane/HoistingCrane/FormMap.Designer.cs b/HoistingCrane/HoistingCrane/FormMap.Designer.cs deleted file mode 100644 index ba07c1c..0000000 --- a/HoistingCrane/HoistingCrane/FormMap.Designer.cs +++ /dev/null @@ -1,208 +0,0 @@ -namespace HoistingCrane -{ - partial class FormMap - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.buttonUp = new System.Windows.Forms.Button(); - this.buttonLeft = new System.Windows.Forms.Button(); - this.buttonRight = new System.Windows.Forms.Button(); - this.buttonDown = new System.Windows.Forms.Button(); - this.buttonCreate = new System.Windows.Forms.Button(); - this.statusStrip = new System.Windows.Forms.StatusStrip(); - this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel(); - this.pictureBoxHoistingCrane = new System.Windows.Forms.PictureBox(); - this.buttonCreateModify = new System.Windows.Forms.Button(); - this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox(); - this.statusStrip.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxHoistingCrane)).BeginInit(); - this.SuspendLayout(); - // - // buttonUp - // - this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonUp.BackgroundImage = global::HoistingCrane.Properties.Resources.up; - this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonUp.Location = new System.Drawing.Point(722, 353); - this.buttonUp.Name = "buttonUp"; - this.buttonUp.Size = new System.Drawing.Size(30, 30); - this.buttonUp.TabIndex = 0; - this.buttonUp.UseVisualStyleBackColor = true; - this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonLeft - // - this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonLeft.BackgroundImage = global::HoistingCrane.Properties.Resources.left; - this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonLeft.Location = new System.Drawing.Point(686, 389); - this.buttonLeft.Name = "buttonLeft"; - this.buttonLeft.Size = new System.Drawing.Size(30, 30); - this.buttonLeft.TabIndex = 1; - this.buttonLeft.UseVisualStyleBackColor = true; - this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonRight - // - this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonRight.BackgroundImage = global::HoistingCrane.Properties.Resources.right; - this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonRight.Location = new System.Drawing.Point(758, 389); - this.buttonRight.Name = "buttonRight"; - this.buttonRight.Size = new System.Drawing.Size(30, 30); - this.buttonRight.TabIndex = 2; - this.buttonRight.UseVisualStyleBackColor = true; - this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonDown - // - this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonDown.BackgroundImage = global::HoistingCrane.Properties.Resources.down; - this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonDown.Location = new System.Drawing.Point(722, 389); - this.buttonDown.Name = "buttonDown"; - this.buttonDown.Size = new System.Drawing.Size(30, 30); - this.buttonDown.TabIndex = 3; - this.buttonDown.UseVisualStyleBackColor = true; - this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click); - // - // buttonCreate - // - this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonCreate.Location = new System.Drawing.Point(12, 393); - this.buttonCreate.Name = "buttonCreate"; - this.buttonCreate.Size = new System.Drawing.Size(75, 23); - this.buttonCreate.TabIndex = 4; - this.buttonCreate.Text = "Создать"; - this.buttonCreate.UseVisualStyleBackColor = true; - this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click); - // - // statusStrip - // - this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripStatusLabelSpeed, - this.toolStripStatusLabelWeight, - this.toolStripStatusLabelBodyColor}); - this.statusStrip.Location = new System.Drawing.Point(0, 428); - this.statusStrip.Name = "statusStrip"; - this.statusStrip.Size = new System.Drawing.Size(800, 22); - this.statusStrip.TabIndex = 5; - this.statusStrip.Text = "statusStrip"; - // - // toolStripStatusLabelSpeed - // - this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed"; - this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(62, 17); - this.toolStripStatusLabelSpeed.Text = "Скорость:"; - // - // toolStripStatusLabelWeight - // - this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight"; - this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(29, 17); - this.toolStripStatusLabelWeight.Text = "Вес:"; - // - // toolStripStatusLabelBodyColor - // - this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor"; - this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(36, 17); - this.toolStripStatusLabelBodyColor.Text = "Цвет:"; - // - // pictureBoxBulldozer - // - this.pictureBoxHoistingCrane.Dock = System.Windows.Forms.DockStyle.Fill; - this.pictureBoxHoistingCrane.Location = new System.Drawing.Point(0, 0); - this.pictureBoxHoistingCrane.Name = "pictureBoxHoistingCrane"; - this.pictureBoxHoistingCrane.Size = new System.Drawing.Size(800, 428); - this.pictureBoxHoistingCrane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; - this.pictureBoxHoistingCrane.TabIndex = 6; - this.pictureBoxHoistingCrane.TabStop = false; - this.pictureBoxHoistingCrane.Click += new System.EventHandler(this.pictureBoxHoistingCrane_Click); - // - // buttonCreateModify - // - this.buttonCreateModify.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonCreateModify.Location = new System.Drawing.Point(93, 393); - this.buttonCreateModify.Name = "buttonCreateModify"; - this.buttonCreateModify.Size = new System.Drawing.Size(100, 23); - this.buttonCreateModify.TabIndex = 7; - this.buttonCreateModify.Text = "Модификация"; - this.buttonCreateModify.UseVisualStyleBackColor = true; - this.buttonCreateModify.Click += new System.EventHandler(this.ButtonCreateModify_Click); - // - // comboBoxSelectorMap - // - this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxSelectorMap.FormattingEnabled = true; - this.comboBoxSelectorMap.Items.AddRange(new object[] { - "Простая карта", - "Вторая карта"}); - this.comboBoxSelectorMap.Location = new System.Drawing.Point(12, 12); - this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; - this.comboBoxSelectorMap.Size = new System.Drawing.Size(121, 23); - this.comboBoxSelectorMap.TabIndex = 8; - this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged); - // - // FormMap - // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Controls.Add(this.comboBoxSelectorMap); - this.Controls.Add(this.buttonCreateModify); - this.Controls.Add(this.buttonCreate); - this.Controls.Add(this.buttonDown); - this.Controls.Add(this.buttonRight); - this.Controls.Add(this.buttonLeft); - this.Controls.Add(this.buttonUp); - this.Controls.Add(this.pictureBoxHoistingCrane); - this.Controls.Add(this.statusStrip); - this.Name = "FormMap"; - this.Text = "FormMap"; - this.statusStrip.ResumeLayout(false); - this.statusStrip.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxHoistingCrane)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - private Button buttonUp; - private Button buttonLeft; - private Button buttonRight; - private Button buttonDown; - private Button buttonCreate; - private StatusStrip statusStrip; - private ToolStripStatusLabel toolStripStatusLabelSpeed; - private ToolStripStatusLabel toolStripStatusLabelWeight; - private ToolStripStatusLabel toolStripStatusLabelBodyColor; - private PictureBox pictureBoxHoistingCrane; - private Button buttonCreateModify; - private ComboBox comboBoxSelectorMap; - } -} \ No newline at end of file diff --git a/HoistingCrane/HoistingCrane/FormMap.cs b/HoistingCrane/HoistingCrane/FormMap.cs deleted file mode 100644 index 35f3052..0000000 --- a/HoistingCrane/HoistingCrane/FormMap.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace HoistingCrane -{ - public partial class FormMap : Form - { - private AbstractMap _abstractMap; - public FormMap() - { - InitializeComponent(); - _abstractMap = new SimpleMap(); - _abstractMap = new SecondMap(); - } - - private void SetData(DrawingHoistingCrane hoistingCrane) - { - toolStripStatusLabelSpeed.Text = $"Скорость: {hoistingCrane.HoistingCrane.Speed}"; - toolStripStatusLabelWeight.Text = $"Вес: {hoistingCrane.HoistingCrane.Weight}"; - toolStripStatusLabelBodyColor.Text = $"Цвет:{hoistingCrane.HoistingCrane.BodyColor.Name}"; - pictureBoxHoistingCrane.Image = _abstractMap.CreateMap(pictureBoxHoistingCrane.Width, - pictureBoxHoistingCrane.Height, new DrawingObjectHoistingCrane(hoistingCrane)); - } - - private void ButtonCreate_Click(object sender, EventArgs e) - { - Random rnd = new(); - var bulldozer = new DrawingHoistingCrane(rnd.Next(30, 100), rnd.Next(300, 500), - Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); - SetData(bulldozer); - } - - private void ButtonMove_Click(object sender, EventArgs e) - { - string name = ((Button)sender)?.Name ?? string.Empty; - Direction dir = Direction.None; - switch (name) - { - case "buttonUp": - dir = Direction.Up; - break; - case "buttonDown": - dir = Direction.Down; - break; - case "buttonLeft": - dir = Direction.Left; - break; - case "buttonRight": - dir = Direction.Right; - break; - } - pictureBoxHoistingCrane.Image = _abstractMap.MoveObject(dir); - } - private void ButtonCreateModify_Click(object sender, EventArgs e) - { - Random rnd = new(); - var hoistingCrane = new DrawingAdvancedHoistingCrane(rnd.Next(30, 100), rnd.Next(300, 500), - Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), Color.FromArgb(rnd.Next(0, 256), - rnd.Next(0, 256), rnd.Next(0, 256)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2))); - SetData(hoistingCrane); - } - - private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e) - { - switch (comboBoxSelectorMap.Text) - { - case "Простая карта": - _abstractMap = new SimpleMap(); - break; - case "Вторая карта": - _abstractMap = new SecondMap(); - break; - } - } - - private void pictureBoxHoistingCrane_Click(object sender, EventArgs e) - { - - } - } -} diff --git a/HoistingCrane/HoistingCrane/FormMap.resx b/HoistingCrane/HoistingCrane/FormMap.resx deleted file mode 100644 index f298a7b..0000000 --- a/HoistingCrane/HoistingCrane/FormMap.resx +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.Designer.cs b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.Designer.cs index 11ed709..0409949 100644 --- a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.Designer.cs +++ b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.Designer.cs @@ -262,7 +262,6 @@ this.pictureBox.Size = new System.Drawing.Size(927, 782); this.pictureBox.TabIndex = 1; this.pictureBox.TabStop = false; - this.pictureBox.Click += new System.EventHandler(this.pictureBox_Click); // // FormMapWithSetHoistingCrane // diff --git a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs index 82acb96..6a2e386 100644 --- a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs +++ b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs @@ -24,9 +24,7 @@ namespace HoistingCrane /// private readonly MapsCollection _mapsCollection; /// - private MapWithSetHoistingCraneGeneric _mapHoistingCraneCollectionGeneric; - public FormMapWithSetHoistingCrane() { InitializeComponent(); @@ -102,7 +100,6 @@ namespace HoistingCrane _mapsCollection.AddMap(textBoxNewMapName.Text, _mapsDict[comboBoxSelectorMap.Text]); ReloadMaps(); } - private void ListBoxMaps_SelectedIndexChanged(object sender, EventArgs e) { pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); @@ -118,14 +115,12 @@ namespace HoistingCrane { return; } - if (MessageBox.Show($"Удалить карту {listBoxMaps.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _mapsCollection.DelMap(listBoxMaps.SelectedItem?.ToString() ?? string.Empty); ReloadMaps(); } } - private void ButtonAddHoistingCrane_Click(object sender, EventArgs e) { if (listBoxMaps.SelectedIndex == -1) @@ -135,7 +130,6 @@ namespace HoistingCrane var formHoistingCraneConfig = new FormHoistingCraneConfig(); formHoistingCraneConfig.AddEvent(AddHoistingCrane); formHoistingCraneConfig.Show(); - } private void AddHoistingCrane(DrawingHoistingCrane drawingHoistingCrane) { @@ -171,7 +165,6 @@ namespace HoistingCrane MessageBox.Show("Не удалось удалить объект"); } } - private void ButtonShowStorage_Click(object sender, EventArgs e) { if (listBoxMaps.SelectedIndex == -1) @@ -180,7 +173,6 @@ namespace HoistingCrane } pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } - private void ButtonShowOnMap_Click(object sender, EventArgs e) { if (listBoxMaps.SelectedIndex == -1) @@ -189,7 +181,6 @@ namespace HoistingCrane } pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap(); } - private void ButtonMove_Click(object sender, EventArgs e) { if (listBoxMaps.SelectedIndex == -1) @@ -215,10 +206,5 @@ namespace HoistingCrane } pictureBox.Image = _mapHoistingCraneCollectionGeneric.MoveObject(enums); } - - private void pictureBox_Click(object sender, EventArgs e) - { - - } } } diff --git a/HoistingCrane/HoistingCrane/HoistingCraneDelegate.cs b/HoistingCrane/HoistingCrane/HoistingCraneDelegate.cs index 02eb7e6..8f2107d 100644 --- a/HoistingCrane/HoistingCrane/HoistingCraneDelegate.cs +++ b/HoistingCrane/HoistingCrane/HoistingCraneDelegate.cs @@ -2,7 +2,7 @@ namespace HoistingCrane { /// - /// Делегат для передачи объекта-корабля + /// Делегат для передачи объекта /// /// public delegate void HoistingCraneDelegate(DrawingHoistingCrane hoistingCrane); diff --git a/HoistingCrane/HoistingCrane/MapWithSetHoistingCraneGeneric.cs b/HoistingCrane/HoistingCrane/MapWithSetHoistingCraneGeneric.cs index d598f56..d288a7c 100644 --- a/HoistingCrane/HoistingCrane/MapWithSetHoistingCraneGeneric.cs +++ b/HoistingCrane/HoistingCrane/MapWithSetHoistingCraneGeneric.cs @@ -16,7 +16,6 @@ namespace HoistingCrane private readonly int _placeSizeHeight = 120; private readonly SetHoistingCraneGeneric _setHoistingCranes; private readonly U _map; - public MapWithSetHoistingCraneGeneric(int picWidth, int picHeight, U map) { int width = picWidth / _placeSizeWidth; @@ -26,17 +25,14 @@ namespace HoistingCrane _pictureHeight = picHeight; _map = map; } - public static int operator +(MapWithSetHoistingCraneGeneric map, T hoistingcrane) { return map._setHoistingCranes.Insert(hoistingcrane); } - public static T operator -(MapWithSetHoistingCraneGeneric map, int position) { return map._setHoistingCranes.Remove(position); } - public Bitmap ShowSet() { Bitmap bmp = new(_pictureWidth, _pictureWidth); @@ -45,7 +41,6 @@ namespace HoistingCrane DrawHoistingCranes(gr); return bmp; } - public Bitmap ShowOnMap() { Shaking(); @@ -55,7 +50,6 @@ namespace HoistingCrane } return new(_pictureWidth, _pictureHeight); } - public Bitmap MoveObject(Direction direction) { if (_map != null) @@ -64,7 +58,6 @@ namespace HoistingCrane } return new(_pictureWidth, _pictureHeight); } - public void Shaking() { int j = _setHoistingCranes.Count - 1; @@ -89,7 +82,6 @@ namespace HoistingCrane } } } - private void DrawBackground(Graphics gr) { Pen pen = new(Color.Black, 3); @@ -102,7 +94,6 @@ namespace HoistingCrane gr.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, (_pictureHeight / _placeSizeHeight) * _placeSizeHeight); } } - private void DrawHoistingCranes(Graphics gr) { int heightEl = _pictureHeight / _placeSizeHeight; diff --git a/HoistingCrane/HoistingCrane/SetHoistingCraneGeneric.cs b/HoistingCrane/HoistingCrane/SetHoistingCraneGeneric.cs index bc14a0d..73c0856 100644 --- a/HoistingCrane/HoistingCrane/SetHoistingCraneGeneric.cs +++ b/HoistingCrane/HoistingCrane/SetHoistingCraneGeneric.cs @@ -10,22 +10,17 @@ namespace HoistingCrane where T : class { private readonly List _places; - public int Count => _places.Count; - private readonly int _maxCount; - public SetHoistingCraneGeneric(int count) { _maxCount = count; _places = new List(); } - public int Insert(T hoistingCrane) { return Insert(hoistingCrane, 0); } - public int Insert(T hoistingCrane, int position) { if (position < 0 || position > Count || _maxCount == Count) @@ -35,7 +30,6 @@ namespace HoistingCrane _places.Insert(position, hoistingCrane); return position; } - public T Remove(int position) { if (position < Count && position >= 0 && _places[position] != null) @@ -47,7 +41,6 @@ namespace HoistingCrane return null; } - public T this[int position] { get -- 2.25.1 From b4ed17d72353ae996395a726fb22800513e3933d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Sun, 4 Dec 2022 21:08:38 +0400 Subject: [PATCH 05/13] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DrawingObjectHoistingCrane.cs | 10 +-- .../FormMapWithSetHoistingCrane.Designer.cs | 73 ++++++++++++++--- .../FormMapWithSetHoistingCrane.cs | 34 ++++++++ .../FormMapWithSetHoistingCrane.resx | 9 +++ HoistingCrane/HoistingCrane/MapsCollection.cs | 81 +++++++++++++++++-- 5 files changed, 183 insertions(+), 24 deletions(-) diff --git a/HoistingCrane/HoistingCrane/DrawingObjectHoistingCrane.cs b/HoistingCrane/HoistingCrane/DrawingObjectHoistingCrane.cs index 2648791..cca8e8f 100644 --- a/HoistingCrane/HoistingCrane/DrawingObjectHoistingCrane.cs +++ b/HoistingCrane/HoistingCrane/DrawingObjectHoistingCrane.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - + namespace HoistingCrane { internal class DrawingObjectHoistingCrane : IDrawingObject @@ -24,7 +19,7 @@ namespace HoistingCrane } public void SetObject(int x, int y, int width, int height) { - _hoistingCrane.SetPosition(x, y, width, height); + _hoistingCrane?.SetPosition(x, y, width, height); } public void DrawingObject(Graphics g) { @@ -32,5 +27,6 @@ namespace HoistingCrane } public string GetInfo() => _hoistingCrane?.GetDataForSave(); public static IDrawingObject Create(string data) => new DrawingObjectHoistingCrane(data.CreateDrawingHoistingCrane()); + } } diff --git a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.Designer.cs b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.Designer.cs index 0409949..7523fe8 100644 --- a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.Designer.cs +++ b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.Designer.cs @@ -48,9 +48,16 @@ this.buttonShowOnMap = new System.Windows.Forms.Button(); this.buttonAddHoistingCrane = new System.Windows.Forms.Button(); 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.groupBoxMaps.SuspendLayout(); this.groupBoxTools.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); + this.menuStrip.SuspendLayout(); this.SuspendLayout(); // // groupBoxMaps @@ -115,7 +122,6 @@ this.comboBoxSelectorMap.Size = new System.Drawing.Size(200, 28); this.comboBoxSelectorMap.TabIndex = 0; this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged); - // // textBoxNewMapName // @@ -138,11 +144,11 @@ this.groupBoxTools.Controls.Add(this.buttonShowOnMap); this.groupBoxTools.Controls.Add(this.buttonAddHoistingCrane); this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right; - this.groupBoxTools.Location = new System.Drawing.Point(927, 0); + this.groupBoxTools.Location = new System.Drawing.Point(927, 28); this.groupBoxTools.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.groupBoxTools.Name = "groupBoxTools"; this.groupBoxTools.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.groupBoxTools.Size = new System.Drawing.Size(233, 782); + this.groupBoxTools.Size = new System.Drawing.Size(233, 754); this.groupBoxTools.TabIndex = 0; this.groupBoxTools.TabStop = false; this.groupBoxTools.Text = "Инструменты"; @@ -184,7 +190,7 @@ this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonDown.BackgroundImage = global::HoistingCrane.Properties.Resources.down; this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonDown.Location = new System.Drawing.Point(104, 715); + this.buttonDown.Location = new System.Drawing.Point(104, 687); this.buttonDown.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonDown.Name = "buttonDown"; this.buttonDown.Size = new System.Drawing.Size(34, 40); @@ -197,7 +203,7 @@ this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonRight.BackgroundImage = global::HoistingCrane.Properties.Resources.right; this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonRight.Location = new System.Drawing.Point(145, 715); + this.buttonRight.Location = new System.Drawing.Point(145, 687); this.buttonRight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonRight.Name = "buttonRight"; this.buttonRight.Size = new System.Drawing.Size(34, 40); @@ -210,7 +216,7 @@ this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonLeft.BackgroundImage = global::HoistingCrane.Properties.Resources.left; this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonLeft.Location = new System.Drawing.Point(63, 715); + this.buttonLeft.Location = new System.Drawing.Point(63, 687); this.buttonLeft.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonLeft.Name = "buttonLeft"; this.buttonLeft.Size = new System.Drawing.Size(34, 40); @@ -223,7 +229,7 @@ this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonUp.BackgroundImage = global::HoistingCrane.Properties.Resources.up; this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonUp.Location = new System.Drawing.Point(104, 667); + this.buttonUp.Location = new System.Drawing.Point(104, 639); this.buttonUp.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonUp.Name = "buttonUp"; this.buttonUp.Size = new System.Drawing.Size(34, 40); @@ -256,13 +262,51 @@ // 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, 28); this.pictureBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.pictureBox.Name = "pictureBox"; - this.pictureBox.Size = new System.Drawing.Size(927, 782); + this.pictureBox.Size = new System.Drawing.Size(927, 754); this.pictureBox.TabIndex = 1; this.pictureBox.TabStop = false; // + // menuStrip + // + this.menuStrip.ImageScalingSize = new System.Drawing.Size(24, 24); + 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(1160, 28); + this.menuStrip.TabIndex = 2; + this.menuStrip.Text = "menuStrip"; + // + // 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(54, 29); + this.fileToolStripMenuItem.Text = "File"; + // + // saveToolStripMenuItem + // + this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; + this.saveToolStripMenuItem.Size = new System.Drawing.Size(125, 26); + 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(125, 26); + this.loadToolStripMenuItem.Text = "Load"; + this.loadToolStripMenuItem.Click += new System.EventHandler(this.loadToolStripMenuItem_Click); + // + // openFileDialog + // + this.openFileDialog.Filter = "txt file | *.txt"; + // // FormMapWithSetHoistingCrane // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); @@ -270,6 +314,8 @@ this.ClientSize = new System.Drawing.Size(1160, 782); this.Controls.Add(this.pictureBox); this.Controls.Add(this.groupBoxTools); + this.Controls.Add(this.menuStrip); + this.MainMenuStrip = this.menuStrip; this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.Name = "FormMapWithSetHoistingCrane"; this.Text = "Карта с набором объектов"; @@ -278,7 +324,10 @@ this.groupBoxTools.ResumeLayout(false); this.groupBoxTools.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); + this.menuStrip.ResumeLayout(false); + this.menuStrip.PerformLayout(); this.ResumeLayout(false); + this.PerformLayout(); } @@ -301,5 +350,11 @@ private Button buttonDeleteMap; private ListBox listBoxMaps; private Button buttonAddMap; + private System.Windows.Forms.MenuStrip menuStrip; + private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem loadToolStripMenuItem; + private System.Windows.Forms.OpenFileDialog openFileDialog; + private System.Windows.Forms.SaveFileDialog saveFileDialog; } } \ No newline at end of file diff --git a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs index 6a2e386..6a9c813 100644 --- a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs +++ b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs @@ -206,5 +206,39 @@ namespace HoistingCrane } pictureBox.Image = _mapHoistingCraneCollectionGeneric.MoveObject(enums); } + private void saveToolStripMenuItem_Click(object sender, EventArgs e) + { + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + if (_mapsCollection.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 (_mapsCollection.LoadData(openFileDialog.FileName)) + { + MessageBox.Show("Открытие прошло успешно", "Результат", + MessageBoxButtons.OK, MessageBoxIcon.Information); + ReloadMaps(); + } + else + { + MessageBox.Show("Не удалось открыть", "Результат", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } } } diff --git a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.resx b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.resx index f298a7b..5e83204 100644 --- a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.resx +++ b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.resx @@ -57,4 +57,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + 144, 17 + + + 303, 17 + \ No newline at end of file diff --git a/HoistingCrane/HoistingCrane/MapsCollection.cs b/HoistingCrane/HoistingCrane/MapsCollection.cs index 3e42343..bfefcfd 100644 --- a/HoistingCrane/HoistingCrane/MapsCollection.cs +++ b/HoistingCrane/HoistingCrane/MapsCollection.cs @@ -1,8 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; + + using System.Text; -using System.Threading.Tasks; namespace HoistingCrane { @@ -11,7 +9,7 @@ namespace HoistingCrane /// /// Словарь (хранилище) с картами /// - readonly Dictionary> _mapStorages; + readonly Dictionary> _mapStorages; /// /// Возвращение списка названий карт /// @@ -29,9 +27,12 @@ namespace HoistingCrane /// /// /// + /// private readonly char separatorDict = '|'; + private readonly char separatorData = ';'; + private readonly char separatorDict = '|'; public MapsCollection(int pictureWidth, int pictureHeight) { - _mapStorages = new Dictionary>(); + _mapStorages = new Dictionary>(); _pictureWidth = pictureWidth; _pictureHeight = pictureHeight; } @@ -61,13 +62,13 @@ namespace HoistingCrane /// /// /// - public MapWithSetHoistingCraneGeneric this[string ind] + public MapWithSetHoistingCraneGeneric this[string ind] { get { if (ind != String.Empty) { - MapWithSetHoistingCraneGeneric value; + MapWithSetHoistingCraneGeneric value; if (_mapStorages.TryGetValue(ind, out value)) { return value; @@ -76,5 +77,69 @@ namespace HoistingCrane return null; } } + /// + /// Сохранение информации про лодки м в хранилище в файл + /// + /// Путь и имя файла + 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; + } + + /// Загрузка информации по локомотивам в депо из файла + public bool LoadData(string filename) + { + if (!File.Exists(filename)) + { + return false; + } + using (FileStream fs = new(filename, FileMode.Open)) + using (StreamReader sr = new StreamReader(fs, Encoding.UTF8)) + { + string curLine = sr.ReadLine(); + + if (!curLine.Contains("MapsCollection")) + { + return false; + } + _mapStorages.Clear(); + while ((curLine = sr.ReadLine()) != null) + { + var elems = curLine.Split(separatorDict); + AbstractMap map = null; + + switch (elems[1]) + { + case "SimpleMap": + map = new SimpleMap(); + break; + case "SecondMap": + map = new SecondMap(); + break; + + } + + _mapStorages.Add(elems[0], new MapWithSetHoistingCraneGeneric(_pictureWidth, _pictureHeight, map)); + _mapStorages[elems[0]].LoadData(elems[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries)); + } + return true; + } + } } } -- 2.25.1 From 929614d9e3ea8d55070327804d6c3f3adadc96fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Sun, 4 Dec 2022 21:18:39 +0400 Subject: [PATCH 06/13] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs | 6 +++--- HoistingCrane/HoistingCrane/HoistingCraneDelegate.cs | 9 --------- 2 files changed, 3 insertions(+), 12 deletions(-) delete mode 100644 HoistingCrane/HoistingCrane/HoistingCraneDelegate.cs diff --git a/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs b/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs index 0a24cae..6566f0e 100644 --- a/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs +++ b/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs @@ -16,7 +16,7 @@ namespace HoistingCrane DrawingHoistingCrane _hoistingCrane = null; public DrawingHoistingCrane SelectedHoistingCrane { get; private set; } //событие - private event HoistingCraneDelegate EventAddHoistingCrane; + private event Action EventAddHoistingCrane; //конструктор public FormHoistingCraneConfig() { @@ -41,11 +41,11 @@ namespace HoistingCrane pictureBoxObject.Image = bmp; } //добавление события - public void AddEvent(HoistingCraneDelegate ev) + public void AddEvent(Action ev) { if (EventAddHoistingCrane == null) { - EventAddHoistingCrane = new HoistingCraneDelegate(ev); + EventAddHoistingCrane = new Action(ev); } else { diff --git a/HoistingCrane/HoistingCrane/HoistingCraneDelegate.cs b/HoistingCrane/HoistingCrane/HoistingCraneDelegate.cs deleted file mode 100644 index 8f2107d..0000000 --- a/HoistingCrane/HoistingCrane/HoistingCraneDelegate.cs +++ /dev/null @@ -1,9 +0,0 @@ - -namespace HoistingCrane -{ - /// - /// Делегат для передачи объекта - /// - /// - public delegate void HoistingCraneDelegate(DrawingHoistingCrane hoistingCrane); -} -- 2.25.1 From 2dfd2b33bb9abf00732540aede6b6e60a65f32ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Sun, 25 Dec 2022 12:32:11 +0400 Subject: [PATCH 07/13] gg --- .../HoistingCrane/FormMapWithSetHoistingCrane.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs index 6a9c813..202453e 100644 --- a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs +++ b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs @@ -26,6 +26,20 @@ namespace HoistingCrane /// private MapWithSetHoistingCraneGeneric _mapHoistingCraneCollectionGeneric; public FormMapWithSetHoistingCrane() + { + { "Простая карта", new SimpleMap() }, + { "Вторая карта", new SecondMap() }, + }; + /// + /// Объект от коллекции карт + /// Логер + /// + private readonly ILogger _logger; + /// + private readonly MapsCollection _mapsCollection; + /// + public FormMapWithSetHoistingCrane(ILogger logger) + { { InitializeComponent(); _mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height); -- 2.25.1 From a91a4b3a627d690e1344ce4525ca240cd6b23c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Sun, 25 Dec 2022 12:50:07 +0400 Subject: [PATCH 08/13] =?UTF-8?q?=D1=80=D0=B5=D1=88=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BA=D0=BE=D0=BD=D1=84=D0=BB=D0=B8=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormHoistingCraneConfig.resx | 62 ++++++++++++++++++- HoistingCrane/HoistingCrane/MapsCollection.cs | 6 +- 2 files changed, 65 insertions(+), 3 deletions(-) diff --git a/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.resx b/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.resx index f298a7b..1af7de1 100644 --- a/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.resx +++ b/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.resx @@ -1,4 +1,64 @@ - + + + diff --git a/HoistingCrane/HoistingCrane/MapsCollection.cs b/HoistingCrane/HoistingCrane/MapsCollection.cs index bfefcfd..8bec1b8 100644 --- a/HoistingCrane/HoistingCrane/MapsCollection.cs +++ b/HoistingCrane/HoistingCrane/MapsCollection.cs @@ -1,6 +1,8 @@ - - +using System; +using System.Collections.Generic; +using System.Linq; using System.Text; +using System.Threading.Tasks; namespace HoistingCrane { -- 2.25.1 From 84e48de951d76221d08bb0687a69464b20675d72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Sun, 25 Dec 2022 12:32:11 +0400 Subject: [PATCH 09/13] gg --- .../HoistingCrane/FormMapWithSetHoistingCrane.cs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs index 202453e..b262736 100644 --- a/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs +++ b/HoistingCrane/HoistingCrane/FormMapWithSetHoistingCrane.cs @@ -24,20 +24,6 @@ namespace HoistingCrane /// private readonly MapsCollection _mapsCollection; /// - private MapWithSetHoistingCraneGeneric _mapHoistingCraneCollectionGeneric; - public FormMapWithSetHoistingCrane() - { - { "Простая карта", new SimpleMap() }, - { "Вторая карта", new SecondMap() }, - }; - /// - /// Объект от коллекции карт - /// Логер - /// - private readonly ILogger _logger; - /// - private readonly MapsCollection _mapsCollection; - /// public FormMapWithSetHoistingCrane(ILogger logger) { { -- 2.25.1 From 4dc4d778293d705b34c7474b882d581308b9c7ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Sun, 25 Dec 2022 12:50:07 +0400 Subject: [PATCH 10/13] =?UTF-8?q?=D1=80=D0=B5=D1=88=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BA=D0=BE=D0=BD=D1=84=D0=BB=D0=B8=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HoistingCrane/HoistingCrane/MapsCollection.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/HoistingCrane/HoistingCrane/MapsCollection.cs b/HoistingCrane/HoistingCrane/MapsCollection.cs index 8bec1b8..1604f42 100644 --- a/HoistingCrane/HoistingCrane/MapsCollection.cs +++ b/HoistingCrane/HoistingCrane/MapsCollection.cs @@ -10,6 +10,8 @@ namespace HoistingCrane { /// /// Словарь (хранилище) с картами + + readonly Dictionary> _mapStorages; /// readonly Dictionary> _mapStorages; /// -- 2.25.1 From b6ba510a08cc3c74d4af280a7bc0df82eaa3601e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Sun, 25 Dec 2022 13:38:26 +0400 Subject: [PATCH 11/13] gg --- .../HoistingCrane/FormHoistingCraneConfig.cs | 134 ------------------ .../FormHoistingCraneConfig.resx | 120 ---------------- 2 files changed, 254 deletions(-) delete mode 100644 HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs delete mode 100644 HoistingCrane/HoistingCrane/FormHoistingCraneConfig.resx diff --git a/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs b/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs deleted file mode 100644 index 6566f0e..0000000 --- a/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace HoistingCrane -{ - public partial class FormHoistingCraneConfig : Form - { - //переменная-выбранный кран - DrawingHoistingCrane _hoistingCrane = null; - public DrawingHoistingCrane SelectedHoistingCrane { get; private set; } - //событие - private event Action EventAddHoistingCrane; - //конструктор - public FormHoistingCraneConfig() - { - InitializeComponent(); - panelBlack.MouseDown += PanelColor_MouseDown; - panelPurple.MouseDown += PanelColor_MouseDown; - panelGray.MouseDown += PanelColor_MouseDown; - panelGreen.MouseDown += PanelColor_MouseDown; - panelRed.MouseDown += PanelColor_MouseDown; - panelWhite.MouseDown += PanelColor_MouseDown; - panelYellow.MouseDown += PanelColor_MouseDown; - panelBlue.MouseDown += PanelColor_MouseDown; - buttonCancel.Click += (object sender, EventArgs e) => Close(); - } - //отрисовка кран - private void DrawHoistingCrane() - { - Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); - Graphics gr = Graphics.FromImage(bmp); - _hoistingCrane?.SetPosition(5, 5, pictureBoxObject.Width, pictureBoxObject.Height); - _hoistingCrane?.DrawTransport(gr); - pictureBoxObject.Image = bmp; - } - //добавление события - public void AddEvent(Action ev) - { - if (EventAddHoistingCrane == null) - { - EventAddHoistingCrane = new Action(ev); - } - else - { - EventAddHoistingCrane += ev; - } - } - private void LabelObject_MouseDown(object sender, MouseEventArgs e) - { - (sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy); - } - - //проверка получаемой информации (ее типа на соответствие требуемому) - private void PanelObject_DragEnter(object sender, DragEventArgs e) - { - if (e.Data.GetDataPresent(DataFormats.Text)) - { - e.Effect = DragDropEffects.Copy; - } - else - { - e.Effect = DragDropEffects.None; - } - } - //действия при приеме перетаскиваемой информации - private void PanelObject_DragDrop(object sender, DragEventArgs e) - { - switch (e.Data.GetData(DataFormats.Text).ToString()) - { - case "labelSimpleObject": - _hoistingCrane = new DrawingHoistingCrane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelBaseColor.BackColor); - break; - case "labelModifiedObject": - _hoistingCrane = new DrawingAdvancedHoistingCrane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelBaseColor.BackColor, labelDopColor.BackColor, - checkBoxCounterweight.Checked, checkBoxCrane.Checked); - break; - } - - DrawHoistingCrane(); - } - //отправляем цвет с панели - private void PanelColor_MouseDown(object sender, MouseEventArgs e) - { - (sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy); - } - //проверка получаемой информации (её типа на соответсвие требуемому) - private void LabelColor_DragEnter(object sender, DragEventArgs e) - { - if (e.Data.GetDataPresent(typeof(Color))) - { - e.Effect = DragDropEffects.Copy; - } - else - { - e.Effect = DragDropEffects.None; - } - } - //принимаем основной цвет - private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) - { - //проверка на пустоту объекта - if (_hoistingCrane != null) - { - _hoistingCrane.HoistingCrane.BodyColor = (Color)e.Data.GetData(typeof(Color)); - - DrawHoistingCrane(); - } - } - //принимаем дополнительный цвет - private void LabelDopColor_DragDrop(object sender, DragEventArgs e) - { - //проверка на пустоту объекта и правильную сущноть - if (_hoistingCrane != null && _hoistingCrane.HoistingCrane is EntityAdvancedHoistingCrane entityHoistingCrane) - { - entityHoistingCrane.DopColor = (Color)e.Data.GetData(typeof(Color)); - DrawHoistingCrane(); - } - } - //добавление крана - private void ButtonAddObject_Click(object sender, EventArgs e) - { - EventAddHoistingCrane?.Invoke(_hoistingCrane); - Close(); - } - } -} - diff --git a/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.resx b/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.resx deleted file mode 100644 index 1af7de1..0000000 --- a/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file -- 2.25.1 From ceaccff176712cff87d40dd8be6d9e4d83aa98d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Sun, 25 Dec 2022 13:56:36 +0400 Subject: [PATCH 12/13] gg --- .../FormHoistingCraneConfig.Designer.cs | 410 ------------------ 1 file changed, 410 deletions(-) delete mode 100644 HoistingCrane/HoistingCrane/FormHoistingCraneConfig.Designer.cs diff --git a/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.Designer.cs b/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.Designer.cs deleted file mode 100644 index 01eea5d..0000000 --- a/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.Designer.cs +++ /dev/null @@ -1,410 +0,0 @@ -namespace HoistingCrane -{ - partial class FormHoistingCraneConfig - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.groupBoxConfig = new System.Windows.Forms.GroupBox(); - this.labelModifiedObject = new System.Windows.Forms.Label(); - this.labelSimpleObject = new System.Windows.Forms.Label(); - this.groupBoxColors = new System.Windows.Forms.GroupBox(); - this.panelPurple = new System.Windows.Forms.Panel(); - this.panelYellow = new System.Windows.Forms.Panel(); - this.panelBlack = new System.Windows.Forms.Panel(); - this.panelBlue = new System.Windows.Forms.Panel(); - this.panelGray = new System.Windows.Forms.Panel(); - this.panelGreen = new System.Windows.Forms.Panel(); - this.panelWhite = new System.Windows.Forms.Panel(); - this.panelRed = new System.Windows.Forms.Panel(); - this.checkBoxCounterweight = new System.Windows.Forms.CheckBox(); - this.checkBoxCrane = new System.Windows.Forms.CheckBox(); - this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown(); - this.labelWeight = new System.Windows.Forms.Label(); - this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown(); - this.labelSpeed = new System.Windows.Forms.Label(); - this.panelObject = new System.Windows.Forms.Panel(); - this.labelDopColor = new System.Windows.Forms.Label(); - this.labelBaseColor = new System.Windows.Forms.Label(); - this.pictureBoxObject = new System.Windows.Forms.PictureBox(); - this.buttonCancel = new System.Windows.Forms.Button(); - this.buttonOk = new System.Windows.Forms.Button(); - this.groupBoxConfig.SuspendLayout(); - this.groupBoxColors.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit(); - this.panelObject.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit(); - this.SuspendLayout(); - // - // groupBoxConfig - // - this.groupBoxConfig.Controls.Add(this.labelModifiedObject); - this.groupBoxConfig.Controls.Add(this.labelSimpleObject); - this.groupBoxConfig.Controls.Add(this.groupBoxColors); - this.groupBoxConfig.Controls.Add(this.checkBoxCounterweight); - this.groupBoxConfig.Controls.Add(this.checkBoxCrane); - this.groupBoxConfig.Controls.Add(this.numericUpDownWeight); - this.groupBoxConfig.Controls.Add(this.labelWeight); - this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed); - this.groupBoxConfig.Controls.Add(this.labelSpeed); - this.groupBoxConfig.Location = new System.Drawing.Point(14, 16); - this.groupBoxConfig.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.groupBoxConfig.Name = "groupBoxConfig"; - this.groupBoxConfig.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.groupBoxConfig.Size = new System.Drawing.Size(594, 293); - this.groupBoxConfig.TabIndex = 0; - this.groupBoxConfig.TabStop = false; - this.groupBoxConfig.Text = "Параметры"; - // - // labelModifiedObject - // - this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.labelModifiedObject.Location = new System.Drawing.Point(450, 216); - this.labelModifiedObject.Name = "labelModifiedObject"; - this.labelModifiedObject.Size = new System.Drawing.Size(111, 50); - this.labelModifiedObject.TabIndex = 16; - this.labelModifiedObject.Text = "Продвинутый"; - this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown); - // - // labelSimpleObject - // - this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.labelSimpleObject.Location = new System.Drawing.Point(322, 216); - this.labelSimpleObject.Name = "labelSimpleObject"; - this.labelSimpleObject.Size = new System.Drawing.Size(111, 50); - this.labelSimpleObject.TabIndex = 15; - this.labelSimpleObject.Text = "Простой"; - this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown); - // - // groupBoxColors - // - this.groupBoxColors.Controls.Add(this.panelPurple); - this.groupBoxColors.Controls.Add(this.panelYellow); - this.groupBoxColors.Controls.Add(this.panelBlack); - this.groupBoxColors.Controls.Add(this.panelBlue); - this.groupBoxColors.Controls.Add(this.panelGray); - this.groupBoxColors.Controls.Add(this.panelGreen); - this.groupBoxColors.Controls.Add(this.panelWhite); - this.groupBoxColors.Controls.Add(this.panelRed); - this.groupBoxColors.Location = new System.Drawing.Point(305, 29); - this.groupBoxColors.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.groupBoxColors.Name = "groupBoxColors"; - this.groupBoxColors.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.groupBoxColors.Size = new System.Drawing.Size(275, 169); - this.groupBoxColors.TabIndex = 14; - this.groupBoxColors.TabStop = false; - this.groupBoxColors.Text = "Цвета"; - // - // panelPurple - // - this.panelPurple.BackColor = System.Drawing.Color.Purple; - this.panelPurple.Location = new System.Drawing.Point(210, 97); - this.panelPurple.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.panelPurple.Name = "panelPurple"; - this.panelPurple.Size = new System.Drawing.Size(46, 53); - this.panelPurple.TabIndex = 3; - this.panelPurple.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); - // - // panelYellow - // - this.panelYellow.BackColor = System.Drawing.Color.Yellow; - this.panelYellow.Location = new System.Drawing.Point(210, 29); - this.panelYellow.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.panelYellow.Name = "panelYellow"; - this.panelYellow.Size = new System.Drawing.Size(46, 53); - this.panelYellow.TabIndex = 1; - this.panelYellow.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); - // - // panelBlack - // - this.panelBlack.BackColor = System.Drawing.Color.Black; - this.panelBlack.Location = new System.Drawing.Point(145, 97); - this.panelBlack.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.panelBlack.Name = "panelBlack"; - this.panelBlack.Size = new System.Drawing.Size(46, 53); - this.panelBlack.TabIndex = 4; - this.panelBlack.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); - // - // panelBlue - // - this.panelBlue.BackColor = System.Drawing.Color.Blue; - this.panelBlue.Location = new System.Drawing.Point(145, 29); - this.panelBlue.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.panelBlue.Name = "panelBlue"; - this.panelBlue.Size = new System.Drawing.Size(46, 53); - this.panelBlue.TabIndex = 1; - this.panelBlue.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); - // - // panelGray - // - this.panelGray.BackColor = System.Drawing.Color.Gray; - this.panelGray.Location = new System.Drawing.Point(82, 97); - this.panelGray.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.panelGray.Name = "panelGray"; - this.panelGray.Size = new System.Drawing.Size(46, 53); - this.panelGray.TabIndex = 5; - this.panelGray.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); - // - // panelGreen - // - this.panelGreen.BackColor = System.Drawing.Color.Green; - this.panelGreen.Location = new System.Drawing.Point(82, 29); - this.panelGreen.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.panelGreen.Name = "panelGreen"; - this.panelGreen.Size = new System.Drawing.Size(46, 53); - this.panelGreen.TabIndex = 1; - this.panelGreen.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); - // - // panelWhite - // - this.panelWhite.BackColor = System.Drawing.Color.White; - this.panelWhite.Location = new System.Drawing.Point(17, 97); - this.panelWhite.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.panelWhite.Name = "panelWhite"; - this.panelWhite.Size = new System.Drawing.Size(46, 53); - this.panelWhite.TabIndex = 2; - this.panelWhite.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); - // - // panelRed - // - this.panelRed.BackColor = System.Drawing.Color.Red; - this.panelRed.Location = new System.Drawing.Point(17, 29); - this.panelRed.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.panelRed.Name = "panelRed"; - this.panelRed.Size = new System.Drawing.Size(46, 53); - this.panelRed.TabIndex = 0; - this.panelRed.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); - // - // checkBoxCounterweight - // - this.checkBoxCounterweight.AutoSize = true; - this.checkBoxCounterweight.Location = new System.Drawing.Point(25, 247); - this.checkBoxCounterweight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.checkBoxCounterweight.Name = "checkBoxCounterweight"; - this.checkBoxCounterweight.Size = new System.Drawing.Size(248, 24); - this.checkBoxCounterweight.TabIndex = 13; - this.checkBoxCounterweight.Text = "Признак наличия противовеса"; - this.checkBoxCounterweight.UseVisualStyleBackColor = true; - // - // checkBoxCrane - // - this.checkBoxCrane.AutoSize = true; - this.checkBoxCrane.Location = new System.Drawing.Point(25, 199); - this.checkBoxCrane.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.checkBoxCrane.Name = "checkBoxCrane"; - this.checkBoxCrane.Size = new System.Drawing.Size(199, 24); - this.checkBoxCrane.TabIndex = 12; - this.checkBoxCrane.Text = "Признак наличия крана"; - this.checkBoxCrane.UseVisualStyleBackColor = true; - // - // numericUpDownWeight - // - this.numericUpDownWeight.Location = new System.Drawing.Point(103, 96); - this.numericUpDownWeight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.numericUpDownWeight.Maximum = new decimal(new int[] { - 1000, - 0, - 0, - 0}); - this.numericUpDownWeight.Minimum = new decimal(new int[] { - 100, - 0, - 0, - 0}); - this.numericUpDownWeight.Name = "numericUpDownWeight"; - this.numericUpDownWeight.Size = new System.Drawing.Size(90, 27); - this.numericUpDownWeight.TabIndex = 10; - this.numericUpDownWeight.Value = new decimal(new int[] { - 100, - 0, - 0, - 0}); - // - // labelWeight - // - this.labelWeight.AutoSize = true; - this.labelWeight.Location = new System.Drawing.Point(25, 99); - this.labelWeight.Name = "labelWeight"; - this.labelWeight.Size = new System.Drawing.Size(36, 20); - this.labelWeight.TabIndex = 9; - this.labelWeight.Text = "Вес:"; - // - // numericUpDownSpeed - // - this.numericUpDownSpeed.Location = new System.Drawing.Point(103, 40); - this.numericUpDownSpeed.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.numericUpDownSpeed.Maximum = new decimal(new int[] { - 1000, - 0, - 0, - 0}); - this.numericUpDownSpeed.Minimum = new decimal(new int[] { - 100, - 0, - 0, - 0}); - this.numericUpDownSpeed.Name = "numericUpDownSpeed"; - this.numericUpDownSpeed.Size = new System.Drawing.Size(90, 27); - this.numericUpDownSpeed.TabIndex = 8; - this.numericUpDownSpeed.Value = new decimal(new int[] { - 100, - 0, - 0, - 0}); - // - // labelSpeed - // - this.labelSpeed.AutoSize = true; - this.labelSpeed.Location = new System.Drawing.Point(25, 43); - this.labelSpeed.Name = "labelSpeed"; - this.labelSpeed.Size = new System.Drawing.Size(76, 20); - this.labelSpeed.TabIndex = 7; - this.labelSpeed.Text = "Скорость:"; - // - // panelObject - // - this.panelObject.AllowDrop = true; - this.panelObject.Controls.Add(this.labelDopColor); - this.panelObject.Controls.Add(this.labelBaseColor); - this.panelObject.Controls.Add(this.pictureBoxObject); - this.panelObject.Location = new System.Drawing.Point(615, 16); - this.panelObject.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.panelObject.Name = "panelObject"; - this.panelObject.Size = new System.Drawing.Size(299, 245); - this.panelObject.TabIndex = 2; - this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop); - this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter); - // - // labelDopColor - // - this.labelDopColor.AllowDrop = true; - this.labelDopColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.labelDopColor.Location = new System.Drawing.Point(161, 12); - this.labelDopColor.Name = "labelDopColor"; - this.labelDopColor.Size = new System.Drawing.Size(119, 42); - this.labelDopColor.TabIndex = 2; - this.labelDopColor.Text = "Доп. цвет"; - this.labelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.labelDopColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragDrop); - this.labelDopColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter); - // - // labelBaseColor - // - this.labelBaseColor.AllowDrop = true; - this.labelBaseColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.labelBaseColor.Location = new System.Drawing.Point(23, 12); - this.labelBaseColor.Name = "labelBaseColor"; - this.labelBaseColor.Size = new System.Drawing.Size(119, 42); - this.labelBaseColor.TabIndex = 1; - this.labelBaseColor.Text = "Цвет"; - this.labelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.labelBaseColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragDrop); - this.labelBaseColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter); - // - // pictureBoxObject - // - this.pictureBoxObject.Location = new System.Drawing.Point(23, 59); - this.pictureBoxObject.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.pictureBoxObject.Name = "pictureBoxObject"; - this.pictureBoxObject.Size = new System.Drawing.Size(257, 167); - this.pictureBoxObject.TabIndex = 0; - this.pictureBoxObject.TabStop = false; - // - // buttonCancel - // - this.buttonCancel.Location = new System.Drawing.Point(776, 269); - this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(119, 40); - this.buttonCancel.TabIndex = 5; - this.buttonCancel.Text = "Отмена"; - this.buttonCancel.UseVisualStyleBackColor = true; - // - // buttonOk - // - this.buttonOk.Location = new System.Drawing.Point(638, 269); - this.buttonOk.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.buttonOk.Name = "buttonOk"; - this.buttonOk.Size = new System.Drawing.Size(119, 40); - this.buttonOk.TabIndex = 4; - this.buttonOk.Text = "Добавить"; - this.buttonOk.UseVisualStyleBackColor = true; - this.buttonOk.Click += new System.EventHandler(this.ButtonAddObject_Click); - // - // FormHoistingCraneConfig - // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(926, 323); - this.Controls.Add(this.buttonCancel); - this.Controls.Add(this.buttonOk); - this.Controls.Add(this.panelObject); - this.Controls.Add(this.groupBoxConfig); - this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.Name = "FormHoistingCraneConfig"; - this.Text = "Создание объекта"; - this.groupBoxConfig.ResumeLayout(false); - this.groupBoxConfig.PerformLayout(); - this.groupBoxColors.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit(); - this.panelObject.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private GroupBox groupBoxConfig; - private CheckBox checkBoxCounterweight; - private CheckBox checkBoxCrane; - private NumericUpDown numericUpDownWeight; - private Label labelWeight; - private NumericUpDown numericUpDownSpeed; - private Label labelSpeed; - private Label labelModifiedObject; - private Label labelSimpleObject; - private GroupBox groupBoxColors; - private Panel panelPurple; - private Panel panelYellow; - private Panel panelBlack; - private Panel panelBlue; - private Panel panelGray; - private Panel panelGreen; - private Panel panelWhite; - private Panel panelRed; - private Panel panelObject; - private Label labelDopColor; - private Label labelBaseColor; - private PictureBox pictureBoxObject; - private Button buttonCancel; - private Button buttonOk; - } -} \ No newline at end of file -- 2.25.1 From e00014ccf5dc98006183fed3d2e916123bee064a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?10=D0=93=20=D0=95=D0=B3=D0=BE=D1=80=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Sun, 25 Dec 2022 14:05:12 +0400 Subject: [PATCH 13/13] gg --- .../FormHoistingCraneConfig.Designer.cs | 410 ++++++++++++++++++ .../HoistingCrane/FormHoistingCraneConfig.cs | 134 ++++++ .../FormHoistingCraneConfig.resx | 60 +++ 3 files changed, 604 insertions(+) create mode 100644 HoistingCrane/HoistingCrane/FormHoistingCraneConfig.Designer.cs create mode 100644 HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs create mode 100644 HoistingCrane/HoistingCrane/FormHoistingCraneConfig.resx diff --git a/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.Designer.cs b/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.Designer.cs new file mode 100644 index 0000000..01eea5d --- /dev/null +++ b/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.Designer.cs @@ -0,0 +1,410 @@ +namespace HoistingCrane +{ + partial class FormHoistingCraneConfig + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBoxConfig = new System.Windows.Forms.GroupBox(); + this.labelModifiedObject = new System.Windows.Forms.Label(); + this.labelSimpleObject = new System.Windows.Forms.Label(); + this.groupBoxColors = new System.Windows.Forms.GroupBox(); + this.panelPurple = new System.Windows.Forms.Panel(); + this.panelYellow = new System.Windows.Forms.Panel(); + this.panelBlack = new System.Windows.Forms.Panel(); + this.panelBlue = new System.Windows.Forms.Panel(); + this.panelGray = new System.Windows.Forms.Panel(); + this.panelGreen = new System.Windows.Forms.Panel(); + this.panelWhite = new System.Windows.Forms.Panel(); + this.panelRed = new System.Windows.Forms.Panel(); + this.checkBoxCounterweight = new System.Windows.Forms.CheckBox(); + this.checkBoxCrane = new System.Windows.Forms.CheckBox(); + this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown(); + this.labelWeight = new System.Windows.Forms.Label(); + this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown(); + this.labelSpeed = new System.Windows.Forms.Label(); + this.panelObject = new System.Windows.Forms.Panel(); + this.labelDopColor = new System.Windows.Forms.Label(); + this.labelBaseColor = new System.Windows.Forms.Label(); + this.pictureBoxObject = new System.Windows.Forms.PictureBox(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOk = new System.Windows.Forms.Button(); + this.groupBoxConfig.SuspendLayout(); + this.groupBoxColors.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit(); + this.panelObject.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit(); + this.SuspendLayout(); + // + // groupBoxConfig + // + this.groupBoxConfig.Controls.Add(this.labelModifiedObject); + this.groupBoxConfig.Controls.Add(this.labelSimpleObject); + this.groupBoxConfig.Controls.Add(this.groupBoxColors); + this.groupBoxConfig.Controls.Add(this.checkBoxCounterweight); + this.groupBoxConfig.Controls.Add(this.checkBoxCrane); + this.groupBoxConfig.Controls.Add(this.numericUpDownWeight); + this.groupBoxConfig.Controls.Add(this.labelWeight); + this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed); + this.groupBoxConfig.Controls.Add(this.labelSpeed); + this.groupBoxConfig.Location = new System.Drawing.Point(14, 16); + this.groupBoxConfig.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.groupBoxConfig.Name = "groupBoxConfig"; + this.groupBoxConfig.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.groupBoxConfig.Size = new System.Drawing.Size(594, 293); + this.groupBoxConfig.TabIndex = 0; + this.groupBoxConfig.TabStop = false; + this.groupBoxConfig.Text = "Параметры"; + // + // labelModifiedObject + // + this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelModifiedObject.Location = new System.Drawing.Point(450, 216); + this.labelModifiedObject.Name = "labelModifiedObject"; + this.labelModifiedObject.Size = new System.Drawing.Size(111, 50); + this.labelModifiedObject.TabIndex = 16; + this.labelModifiedObject.Text = "Продвинутый"; + this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown); + // + // labelSimpleObject + // + this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelSimpleObject.Location = new System.Drawing.Point(322, 216); + this.labelSimpleObject.Name = "labelSimpleObject"; + this.labelSimpleObject.Size = new System.Drawing.Size(111, 50); + this.labelSimpleObject.TabIndex = 15; + this.labelSimpleObject.Text = "Простой"; + this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown); + // + // groupBoxColors + // + this.groupBoxColors.Controls.Add(this.panelPurple); + this.groupBoxColors.Controls.Add(this.panelYellow); + this.groupBoxColors.Controls.Add(this.panelBlack); + this.groupBoxColors.Controls.Add(this.panelBlue); + this.groupBoxColors.Controls.Add(this.panelGray); + this.groupBoxColors.Controls.Add(this.panelGreen); + this.groupBoxColors.Controls.Add(this.panelWhite); + this.groupBoxColors.Controls.Add(this.panelRed); + this.groupBoxColors.Location = new System.Drawing.Point(305, 29); + this.groupBoxColors.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.groupBoxColors.Name = "groupBoxColors"; + this.groupBoxColors.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.groupBoxColors.Size = new System.Drawing.Size(275, 169); + this.groupBoxColors.TabIndex = 14; + this.groupBoxColors.TabStop = false; + this.groupBoxColors.Text = "Цвета"; + // + // panelPurple + // + this.panelPurple.BackColor = System.Drawing.Color.Purple; + this.panelPurple.Location = new System.Drawing.Point(210, 97); + this.panelPurple.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.panelPurple.Name = "panelPurple"; + this.panelPurple.Size = new System.Drawing.Size(46, 53); + this.panelPurple.TabIndex = 3; + this.panelPurple.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelYellow + // + this.panelYellow.BackColor = System.Drawing.Color.Yellow; + this.panelYellow.Location = new System.Drawing.Point(210, 29); + this.panelYellow.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.panelYellow.Name = "panelYellow"; + this.panelYellow.Size = new System.Drawing.Size(46, 53); + this.panelYellow.TabIndex = 1; + this.panelYellow.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelBlack + // + this.panelBlack.BackColor = System.Drawing.Color.Black; + this.panelBlack.Location = new System.Drawing.Point(145, 97); + this.panelBlack.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.panelBlack.Name = "panelBlack"; + this.panelBlack.Size = new System.Drawing.Size(46, 53); + this.panelBlack.TabIndex = 4; + this.panelBlack.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelBlue + // + this.panelBlue.BackColor = System.Drawing.Color.Blue; + this.panelBlue.Location = new System.Drawing.Point(145, 29); + this.panelBlue.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.panelBlue.Name = "panelBlue"; + this.panelBlue.Size = new System.Drawing.Size(46, 53); + this.panelBlue.TabIndex = 1; + this.panelBlue.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelGray + // + this.panelGray.BackColor = System.Drawing.Color.Gray; + this.panelGray.Location = new System.Drawing.Point(82, 97); + this.panelGray.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.panelGray.Name = "panelGray"; + this.panelGray.Size = new System.Drawing.Size(46, 53); + this.panelGray.TabIndex = 5; + this.panelGray.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelGreen + // + this.panelGreen.BackColor = System.Drawing.Color.Green; + this.panelGreen.Location = new System.Drawing.Point(82, 29); + this.panelGreen.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.panelGreen.Name = "panelGreen"; + this.panelGreen.Size = new System.Drawing.Size(46, 53); + this.panelGreen.TabIndex = 1; + this.panelGreen.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelWhite + // + this.panelWhite.BackColor = System.Drawing.Color.White; + this.panelWhite.Location = new System.Drawing.Point(17, 97); + this.panelWhite.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.panelWhite.Name = "panelWhite"; + this.panelWhite.Size = new System.Drawing.Size(46, 53); + this.panelWhite.TabIndex = 2; + this.panelWhite.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelRed + // + this.panelRed.BackColor = System.Drawing.Color.Red; + this.panelRed.Location = new System.Drawing.Point(17, 29); + this.panelRed.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.panelRed.Name = "panelRed"; + this.panelRed.Size = new System.Drawing.Size(46, 53); + this.panelRed.TabIndex = 0; + this.panelRed.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // checkBoxCounterweight + // + this.checkBoxCounterweight.AutoSize = true; + this.checkBoxCounterweight.Location = new System.Drawing.Point(25, 247); + this.checkBoxCounterweight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.checkBoxCounterweight.Name = "checkBoxCounterweight"; + this.checkBoxCounterweight.Size = new System.Drawing.Size(248, 24); + this.checkBoxCounterweight.TabIndex = 13; + this.checkBoxCounterweight.Text = "Признак наличия противовеса"; + this.checkBoxCounterweight.UseVisualStyleBackColor = true; + // + // checkBoxCrane + // + this.checkBoxCrane.AutoSize = true; + this.checkBoxCrane.Location = new System.Drawing.Point(25, 199); + this.checkBoxCrane.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.checkBoxCrane.Name = "checkBoxCrane"; + this.checkBoxCrane.Size = new System.Drawing.Size(199, 24); + this.checkBoxCrane.TabIndex = 12; + this.checkBoxCrane.Text = "Признак наличия крана"; + this.checkBoxCrane.UseVisualStyleBackColor = true; + // + // numericUpDownWeight + // + this.numericUpDownWeight.Location = new System.Drawing.Point(103, 96); + this.numericUpDownWeight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.numericUpDownWeight.Maximum = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + this.numericUpDownWeight.Minimum = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.numericUpDownWeight.Name = "numericUpDownWeight"; + this.numericUpDownWeight.Size = new System.Drawing.Size(90, 27); + this.numericUpDownWeight.TabIndex = 10; + this.numericUpDownWeight.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + // + // labelWeight + // + this.labelWeight.AutoSize = true; + this.labelWeight.Location = new System.Drawing.Point(25, 99); + this.labelWeight.Name = "labelWeight"; + this.labelWeight.Size = new System.Drawing.Size(36, 20); + this.labelWeight.TabIndex = 9; + this.labelWeight.Text = "Вес:"; + // + // numericUpDownSpeed + // + this.numericUpDownSpeed.Location = new System.Drawing.Point(103, 40); + this.numericUpDownSpeed.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.numericUpDownSpeed.Maximum = new decimal(new int[] { + 1000, + 0, + 0, + 0}); + this.numericUpDownSpeed.Minimum = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.numericUpDownSpeed.Name = "numericUpDownSpeed"; + this.numericUpDownSpeed.Size = new System.Drawing.Size(90, 27); + this.numericUpDownSpeed.TabIndex = 8; + this.numericUpDownSpeed.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + // + // labelSpeed + // + this.labelSpeed.AutoSize = true; + this.labelSpeed.Location = new System.Drawing.Point(25, 43); + this.labelSpeed.Name = "labelSpeed"; + this.labelSpeed.Size = new System.Drawing.Size(76, 20); + this.labelSpeed.TabIndex = 7; + this.labelSpeed.Text = "Скорость:"; + // + // panelObject + // + this.panelObject.AllowDrop = true; + this.panelObject.Controls.Add(this.labelDopColor); + this.panelObject.Controls.Add(this.labelBaseColor); + this.panelObject.Controls.Add(this.pictureBoxObject); + this.panelObject.Location = new System.Drawing.Point(615, 16); + this.panelObject.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.panelObject.Name = "panelObject"; + this.panelObject.Size = new System.Drawing.Size(299, 245); + this.panelObject.TabIndex = 2; + this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop); + this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter); + // + // labelDopColor + // + this.labelDopColor.AllowDrop = true; + this.labelDopColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelDopColor.Location = new System.Drawing.Point(161, 12); + this.labelDopColor.Name = "labelDopColor"; + this.labelDopColor.Size = new System.Drawing.Size(119, 42); + this.labelDopColor.TabIndex = 2; + this.labelDopColor.Text = "Доп. цвет"; + this.labelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelDopColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragDrop); + this.labelDopColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter); + // + // labelBaseColor + // + this.labelBaseColor.AllowDrop = true; + this.labelBaseColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelBaseColor.Location = new System.Drawing.Point(23, 12); + this.labelBaseColor.Name = "labelBaseColor"; + this.labelBaseColor.Size = new System.Drawing.Size(119, 42); + this.labelBaseColor.TabIndex = 1; + this.labelBaseColor.Text = "Цвет"; + this.labelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelBaseColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragDrop); + this.labelBaseColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter); + // + // pictureBoxObject + // + this.pictureBoxObject.Location = new System.Drawing.Point(23, 59); + this.pictureBoxObject.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.pictureBoxObject.Name = "pictureBoxObject"; + this.pictureBoxObject.Size = new System.Drawing.Size(257, 167); + this.pictureBoxObject.TabIndex = 0; + this.pictureBoxObject.TabStop = false; + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(776, 269); + this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(119, 40); + this.buttonCancel.TabIndex = 5; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // buttonOk + // + this.buttonOk.Location = new System.Drawing.Point(638, 269); + this.buttonOk.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(119, 40); + this.buttonOk.TabIndex = 4; + this.buttonOk.Text = "Добавить"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.ButtonAddObject_Click); + // + // FormHoistingCraneConfig + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(926, 323); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.panelObject); + this.Controls.Add(this.groupBoxConfig); + this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.Name = "FormHoistingCraneConfig"; + this.Text = "Создание объекта"; + this.groupBoxConfig.ResumeLayout(false); + this.groupBoxConfig.PerformLayout(); + this.groupBoxColors.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit(); + this.panelObject.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private GroupBox groupBoxConfig; + private CheckBox checkBoxCounterweight; + private CheckBox checkBoxCrane; + private NumericUpDown numericUpDownWeight; + private Label labelWeight; + private NumericUpDown numericUpDownSpeed; + private Label labelSpeed; + private Label labelModifiedObject; + private Label labelSimpleObject; + private GroupBox groupBoxColors; + private Panel panelPurple; + private Panel panelYellow; + private Panel panelBlack; + private Panel panelBlue; + private Panel panelGray; + private Panel panelGreen; + private Panel panelWhite; + private Panel panelRed; + private Panel panelObject; + private Label labelDopColor; + private Label labelBaseColor; + private PictureBox pictureBoxObject; + private Button buttonCancel; + private Button buttonOk; + } +} \ No newline at end of file diff --git a/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs b/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs new file mode 100644 index 0000000..6566f0e --- /dev/null +++ b/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace HoistingCrane +{ + public partial class FormHoistingCraneConfig : Form + { + //переменная-выбранный кран + DrawingHoistingCrane _hoistingCrane = null; + public DrawingHoistingCrane SelectedHoistingCrane { get; private set; } + //событие + private event Action EventAddHoistingCrane; + //конструктор + public FormHoistingCraneConfig() + { + InitializeComponent(); + panelBlack.MouseDown += PanelColor_MouseDown; + panelPurple.MouseDown += PanelColor_MouseDown; + panelGray.MouseDown += PanelColor_MouseDown; + panelGreen.MouseDown += PanelColor_MouseDown; + panelRed.MouseDown += PanelColor_MouseDown; + panelWhite.MouseDown += PanelColor_MouseDown; + panelYellow.MouseDown += PanelColor_MouseDown; + panelBlue.MouseDown += PanelColor_MouseDown; + buttonCancel.Click += (object sender, EventArgs e) => Close(); + } + //отрисовка кран + private void DrawHoistingCrane() + { + Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); + Graphics gr = Graphics.FromImage(bmp); + _hoistingCrane?.SetPosition(5, 5, pictureBoxObject.Width, pictureBoxObject.Height); + _hoistingCrane?.DrawTransport(gr); + pictureBoxObject.Image = bmp; + } + //добавление события + public void AddEvent(Action ev) + { + if (EventAddHoistingCrane == null) + { + EventAddHoistingCrane = new Action(ev); + } + else + { + EventAddHoistingCrane += ev; + } + } + private void LabelObject_MouseDown(object sender, MouseEventArgs e) + { + (sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy); + } + + //проверка получаемой информации (ее типа на соответствие требуемому) + private void PanelObject_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.Text)) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + //действия при приеме перетаскиваемой информации + private void PanelObject_DragDrop(object sender, DragEventArgs e) + { + switch (e.Data.GetData(DataFormats.Text).ToString()) + { + case "labelSimpleObject": + _hoistingCrane = new DrawingHoistingCrane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelBaseColor.BackColor); + break; + case "labelModifiedObject": + _hoistingCrane = new DrawingAdvancedHoistingCrane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelBaseColor.BackColor, labelDopColor.BackColor, + checkBoxCounterweight.Checked, checkBoxCrane.Checked); + break; + } + + DrawHoistingCrane(); + } + //отправляем цвет с панели + private void PanelColor_MouseDown(object sender, MouseEventArgs e) + { + (sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy); + } + //проверка получаемой информации (её типа на соответсвие требуемому) + private void LabelColor_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(typeof(Color))) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + //принимаем основной цвет + private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) + { + //проверка на пустоту объекта + if (_hoistingCrane != null) + { + _hoistingCrane.HoistingCrane.BodyColor = (Color)e.Data.GetData(typeof(Color)); + + DrawHoistingCrane(); + } + } + //принимаем дополнительный цвет + private void LabelDopColor_DragDrop(object sender, DragEventArgs e) + { + //проверка на пустоту объекта и правильную сущноть + if (_hoistingCrane != null && _hoistingCrane.HoistingCrane is EntityAdvancedHoistingCrane entityHoistingCrane) + { + entityHoistingCrane.DopColor = (Color)e.Data.GetData(typeof(Color)); + DrawHoistingCrane(); + } + } + //добавление крана + private void ButtonAddObject_Click(object sender, EventArgs e) + { + EventAddHoistingCrane?.Invoke(_hoistingCrane); + Close(); + } + } +} + diff --git a/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.resx b/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/HoistingCrane/HoistingCrane/FormHoistingCraneConfig.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file -- 2.25.1