From ec901ec71452081356fc39fc5e081a64f997b980 Mon Sep 17 00:00:00 2001 From: Ivan_Starostin Date: Tue, 19 Dec 2023 19:24:25 +0400 Subject: [PATCH 1/4] =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=BB?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD=D0=BE?= =?UTF-8?q?=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lainer/Lainer1/EntityLainer.cs | 4 + lainer/Lainer1/EntitySuperLainer.cs | 4 + lainer/Lainer1/FormLainerConfig.Designer.cs | 367 ++++++++++++++++++++ lainer/Lainer1/FormLainerConfig.cs | 114 ++++++ lainer/Lainer1/FormLainerConfig.resx | 120 +++++++ 5 files changed, 609 insertions(+) create mode 100644 lainer/Lainer1/FormLainerConfig.Designer.cs create mode 100644 lainer/Lainer1/FormLainerConfig.cs create mode 100644 lainer/Lainer1/FormLainerConfig.resx diff --git a/lainer/Lainer1/EntityLainer.cs b/lainer/Lainer1/EntityLainer.cs index ac2bc91..f61a385 100644 --- a/lainer/Lainer1/EntityLainer.cs +++ b/lainer/Lainer1/EntityLainer.cs @@ -12,5 +12,9 @@ namespace ProjectLainer.Entities Weight = weight; BodyColor = bodyColor; } + public void ChangeColor(Color bodyColor) + { + BodyColor = bodyColor; + } } } \ No newline at end of file diff --git a/lainer/Lainer1/EntitySuperLainer.cs b/lainer/Lainer1/EntitySuperLainer.cs index 73771d5..e8e9712 100644 --- a/lainer/Lainer1/EntitySuperLainer.cs +++ b/lainer/Lainer1/EntitySuperLainer.cs @@ -12,5 +12,9 @@ namespace ProjectLainer.Entities Pools = pools; Decks = decks; } + public void ChangeAddColor(Color additionalColor) + { + AdditionalColor = additionalColor; + } } } diff --git a/lainer/Lainer1/FormLainerConfig.Designer.cs b/lainer/Lainer1/FormLainerConfig.Designer.cs new file mode 100644 index 0000000..a3613c3 --- /dev/null +++ b/lainer/Lainer1/FormLainerConfig.Designer.cs @@ -0,0 +1,367 @@ +namespace ProjectLainer +{ + partial class FormLainerConfig + { + /// + /// 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() + { + groupBoxParameters = new GroupBox(); + labelSuper = new Label(); + labelBase = new Label(); + groupBoxColors = new GroupBox(); + panelColorCyan = new Panel(); + panelColorGray = new Panel(); + panelColorBlue = new Panel(); + panelColorGreen = new Panel(); + panelColorBlack = new Panel(); + panelColorPurple = new Panel(); + panelColorYellow = new Panel(); + panelColorRed = new Panel(); + checkBoxPool = new CheckBox(); + checkBoxDecks = new CheckBox(); + numericUpDownWeight = new NumericUpDown(); + numericUpDownSpeed = new NumericUpDown(); + labelweight = new Label(); + labelspeed = new Label(); + pictureBoxDragAndDrop = new PictureBox(); + panelDragAndDrop = new Panel(); + labelAddColor = new Label(); + labelColor = new Label(); + buttonDone = new Button(); + buttonCancel = new Button(); + groupBoxParameters.SuspendLayout(); + groupBoxColors.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit(); + ((System.ComponentModel.ISupportInitialize)pictureBoxDragAndDrop).BeginInit(); + panelDragAndDrop.SuspendLayout(); + SuspendLayout(); + // + // groupBoxParameters + // + groupBoxParameters.Controls.Add(labelSuper); + groupBoxParameters.Controls.Add(labelBase); + groupBoxParameters.Controls.Add(groupBoxColors); + groupBoxParameters.Controls.Add(checkBoxPool); + groupBoxParameters.Controls.Add(checkBoxDecks); + groupBoxParameters.Controls.Add(numericUpDownWeight); + groupBoxParameters.Controls.Add(numericUpDownSpeed); + groupBoxParameters.Controls.Add(labelweight); + groupBoxParameters.Controls.Add(labelspeed); + groupBoxParameters.Location = new Point(12, 12); + groupBoxParameters.Name = "groupBoxParameters"; + groupBoxParameters.Size = new Size(682, 426); + groupBoxParameters.TabIndex = 0; + groupBoxParameters.TabStop = false; + groupBoxParameters.Text = "параметры"; + // + // labelSuper + // + labelSuper.BorderStyle = BorderStyle.FixedSingle; + labelSuper.Location = new Point(489, 269); + labelSuper.Name = "labelSuper"; + labelSuper.Size = new Size(124, 43); + labelSuper.TabIndex = 8; + labelSuper.Text = "продвинутый"; + labelSuper.TextAlign = ContentAlignment.MiddleCenter; + labelSuper.MouseDown += labelObject_mouseDown; + // + // labelBase + // + labelBase.BorderStyle = BorderStyle.FixedSingle; + labelBase.Location = new Point(322, 269); + labelBase.Name = "labelBase"; + labelBase.Size = new Size(116, 40); + labelBase.TabIndex = 7; + labelBase.Text = "простой"; + labelBase.TextAlign = ContentAlignment.MiddleCenter; + labelBase.MouseDown += labelObject_mouseDown; + // + // groupBoxColors + // + groupBoxColors.Controls.Add(panelColorCyan); + groupBoxColors.Controls.Add(panelColorGray); + groupBoxColors.Controls.Add(panelColorBlue); + groupBoxColors.Controls.Add(panelColorGreen); + groupBoxColors.Controls.Add(panelColorBlack); + groupBoxColors.Controls.Add(panelColorPurple); + groupBoxColors.Controls.Add(panelColorYellow); + groupBoxColors.Controls.Add(panelColorRed); + groupBoxColors.Location = new Point(322, 26); + groupBoxColors.Name = "groupBoxColors"; + groupBoxColors.Size = new Size(354, 228); + groupBoxColors.TabIndex = 6; + groupBoxColors.TabStop = false; + groupBoxColors.Text = "цвета"; + // + // panelColorCyan + // + panelColorCyan.BackColor = Color.Cyan; + panelColorCyan.Location = new Point(256, 124); + panelColorCyan.Name = "panelColorCyan"; + panelColorCyan.Size = new Size(54, 57); + panelColorCyan.TabIndex = 7; + panelColorCyan.MouseDown += PanelColor_MouseDown; + // + // panelColorGray + // + panelColorGray.BackColor = SystemColors.ButtonShadow; + panelColorGray.Location = new Point(178, 124); + panelColorGray.Name = "panelColorGray"; + panelColorGray.Size = new Size(53, 55); + panelColorGray.TabIndex = 6; + panelColorGray.MouseDown += PanelColor_MouseDown; + // + // panelColorBlue + // + panelColorBlue.BackColor = Color.DarkBlue; + panelColorBlue.Location = new Point(107, 126); + panelColorBlue.Name = "panelColorBlue"; + panelColorBlue.Size = new Size(51, 53); + panelColorBlue.TabIndex = 5; + panelColorBlue.MouseDown += PanelColor_MouseDown; + // + // panelColorGreen + // + panelColorGreen.BackColor = Color.Green; + panelColorGreen.Location = new Point(28, 129); + panelColorGreen.Name = "panelColorGreen"; + panelColorGreen.Size = new Size(50, 50); + panelColorGreen.TabIndex = 4; + panelColorGreen.MouseDown += PanelColor_MouseDown; + // + // panelColorBlack + // + panelColorBlack.BackColor = SystemColors.ActiveCaptionText; + panelColorBlack.Location = new Point(256, 37); + panelColorBlack.Name = "panelColorBlack"; + panelColorBlack.Size = new Size(54, 50); + panelColorBlack.TabIndex = 3; + panelColorBlack.MouseDown += PanelColor_MouseDown; + // + // panelColorPurple + // + panelColorPurple.BackColor = Color.DarkOrchid; + panelColorPurple.Location = new Point(178, 35); + panelColorPurple.Name = "panelColorPurple"; + panelColorPurple.Size = new Size(53, 52); + panelColorPurple.TabIndex = 2; + panelColorPurple.MouseDown += PanelColor_MouseDown; + // + // panelColorYellow + // + panelColorYellow.BackColor = Color.Yellow; + panelColorYellow.Location = new Point(107, 35); + panelColorYellow.Name = "panelColorYellow"; + panelColorYellow.Size = new Size(51, 50); + panelColorYellow.TabIndex = 1; + panelColorYellow.MouseDown += PanelColor_MouseDown; + // + // panelColorRed + // + panelColorRed.BackColor = Color.IndianRed; + panelColorRed.Location = new Point(28, 34); + panelColorRed.Name = "panelColorRed"; + panelColorRed.Size = new Size(50, 51); + panelColorRed.TabIndex = 0; + panelColorRed.MouseDown += PanelColor_MouseDown; + // + // checkBoxPool + // + checkBoxPool.AutoSize = true; + checkBoxPool.Location = new Point(34, 230); + checkBoxPool.Name = "checkBoxPool"; + checkBoxPool.Size = new Size(88, 24); + checkBoxPool.TabIndex = 5; + checkBoxPool.Text = "бассейн"; + checkBoxPool.UseVisualStyleBackColor = true; + // + // checkBoxDecks + // + checkBoxDecks.AutoSize = true; + checkBoxDecks.Location = new Point(34, 172); + checkBoxDecks.Name = "checkBoxDecks"; + checkBoxDecks.Size = new Size(181, 24); + checkBoxDecks.TabIndex = 4; + checkBoxDecks.Text = "новый вид доп палуб"; + checkBoxDecks.UseVisualStyleBackColor = true; + // + // numericUpDownWeight + // + numericUpDownWeight.Location = new Point(129, 91); + numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); + numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 }); + numericUpDownWeight.Name = "numericUpDownWeight"; + numericUpDownWeight.Size = new Size(150, 27); + numericUpDownWeight.TabIndex = 3; + numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // numericUpDownSpeed + // + numericUpDownSpeed.Location = new Point(129, 47); + numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); + numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 }); + numericUpDownSpeed.Name = "numericUpDownSpeed"; + numericUpDownSpeed.Size = new Size(150, 27); + numericUpDownSpeed.TabIndex = 2; + numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // labelweight + // + labelweight.AutoSize = true; + labelweight.Location = new Point(19, 91); + labelweight.Name = "labelweight"; + labelweight.Size = new Size(32, 20); + labelweight.TabIndex = 1; + labelweight.Text = "вес"; + // + // labelspeed + // + labelspeed.AutoSize = true; + labelspeed.Location = new Point(19, 43); + labelspeed.Name = "labelspeed"; + labelspeed.Size = new Size(71, 20); + labelspeed.TabIndex = 0; + labelspeed.Text = "скорость"; + // + // pictureBoxDragAndDrop + // + pictureBoxDragAndDrop.Location = new Point(13, 79); + pictureBoxDragAndDrop.Name = "pictureBoxDragAndDrop"; + pictureBoxDragAndDrop.Size = new Size(355, 150); + pictureBoxDragAndDrop.TabIndex = 1; + pictureBoxDragAndDrop.TabStop = false; + //pictureBoxDragAndDrop.Click += pictureBoxDragAndDrop_Click; + // + // panelDragAndDrop + // + panelDragAndDrop.AllowDrop = true; + panelDragAndDrop.Controls.Add(labelAddColor); + panelDragAndDrop.Controls.Add(labelColor); + panelDragAndDrop.Controls.Add(pictureBoxDragAndDrop); + panelDragAndDrop.Location = new Point(711, 24); + panelDragAndDrop.Name = "panelDragAndDrop"; + panelDragAndDrop.Size = new Size(387, 242); + panelDragAndDrop.TabIndex = 2; + panelDragAndDrop.DragDrop += panelObject_DragDrop; + panelDragAndDrop.DragEnter += panelObject_DragEnter; + // + // labelAddColor + // + labelAddColor.AllowDrop = true; + labelAddColor.BorderStyle = BorderStyle.FixedSingle; + labelAddColor.Location = new Point(189, 14); + labelAddColor.Name = "labelAddColor"; + labelAddColor.Size = new Size(179, 40); + labelAddColor.TabIndex = 9; + labelAddColor.Text = "дополнительный цвет"; + labelAddColor.TextAlign = ContentAlignment.MiddleCenter; + labelAddColor.DragDrop += labelAddColor_DragDrop; + labelAddColor.DragEnter += labelColor_DragEnter; + // + // labelColor + // + labelColor.AllowDrop = true; + labelColor.BorderStyle = BorderStyle.FixedSingle; + labelColor.Location = new Point(13, 14); + labelColor.Name = "labelColor"; + labelColor.Size = new Size(116, 40); + labelColor.TabIndex = 8; + labelColor.Text = "цвет"; + labelColor.TextAlign = ContentAlignment.MiddleCenter; + labelColor.DragDrop += labelColor_DragDrop; + labelColor.DragEnter += labelColor_DragEnter; + // + // buttonDone + // + buttonDone.Location = new Point(700, 397); + buttonDone.Name = "buttonDone"; + buttonDone.Size = new Size(152, 41); + buttonDone.TabIndex = 3; + buttonDone.Text = "готово"; + buttonDone.UseVisualStyleBackColor = true; + buttonDone.Click += buttonDone_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(900, 397); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(169, 41); + buttonCancel.TabIndex = 4; + buttonCancel.Text = "отмена"; + buttonCancel.UseVisualStyleBackColor = true; + // + // FormLainerConfig + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1110, 450); + Controls.Add(buttonCancel); + Controls.Add(buttonDone); + Controls.Add(panelDragAndDrop); + Controls.Add(groupBoxParameters); + Name = "FormLainerConfig"; + Text = "FormLainerConfig"; + DragDrop += panelObject_DragDrop; + DragEnter += panelObject_DragEnter; + groupBoxParameters.ResumeLayout(false); + groupBoxParameters.PerformLayout(); + groupBoxColors.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit(); + ((System.ComponentModel.ISupportInitialize)pictureBoxDragAndDrop).EndInit(); + panelDragAndDrop.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private GroupBox groupBoxParameters; + private CheckBox checkBoxPool; + private CheckBox checkBoxDecks; + private NumericUpDown numericUpDownWeight; + private NumericUpDown numericUpDownSpeed; + private Label labelweight; + private Label labelspeed; + private GroupBox groupBoxColors; + private Panel panelColorPurple; + private Panel panelColorYellow; + private Panel panelColorRed; + private Label labelSuper; + private Label labelBase; + private Panel panelColorCyan; + private Panel panelColorGray; + private Panel panelColorBlue; + private Panel panelColorGreen; + private Panel panelColorBlack; + private PictureBox pictureBoxDragAndDrop; + private Panel panelDragAndDrop; + private Label labelAddColor; + private Label labelColor; + private Button buttonDone; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/lainer/Lainer1/FormLainerConfig.cs b/lainer/Lainer1/FormLainerConfig.cs new file mode 100644 index 0000000..5df6d1e --- /dev/null +++ b/lainer/Lainer1/FormLainerConfig.cs @@ -0,0 +1,114 @@ +using ProjectLainer.DrawningObjects; +using ProjectLainer.Entities; + +namespace ProjectLainer +{ + public partial class FormLainerConfig : Form + { + DrawingEntity? _lainer = null; + Action? EventAddLainer; + public FormLainerConfig() + { + InitializeComponent(); + panelColorBlack.MouseDown += PanelColor_MouseDown; + panelColorPurple.MouseDown += PanelColor_MouseDown; + panelColorGray.MouseDown += PanelColor_MouseDown; + panelColorGreen.MouseDown += PanelColor_MouseDown; + panelColorRed.MouseDown += PanelColor_MouseDown; + panelColorCyan.MouseDown += PanelColor_MouseDown; + panelColorYellow.MouseDown += PanelColor_MouseDown; + panelColorBlue.MouseDown += PanelColor_MouseDown; + + buttonCancel.Click += (sender, e) => Close(); + } + private void PanelColor_MouseDown(object? sender, MouseEventArgs e) + { + (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, + DragDropEffects.Move | DragDropEffects.Copy); + } + private void DrawLainer() + { + Bitmap bmp = new(pictureBoxDragAndDrop.Width, pictureBoxDragAndDrop.Height); + Graphics gr = Graphics.FromImage(bmp); + _lainer?.SetPosition(5, 5); + _lainer?.DrawTransport(gr); + pictureBoxDragAndDrop.Image = bmp; + } + public void AddEvent(Action ev) + { + if (EventAddLainer == null) + { + EventAddLainer = ev; + } + else + { + EventAddLainer += ev; + } + } + private void labelObject_mouseDown(object sender, MouseEventArgs e) + { + (sender as Label)?.DoDragDrop((sender as Label)?.Name, + DragDropEffects.Move | DragDropEffects.Copy); + } + private void buttonDone_Click(object sender, EventArgs e) + { + if (_lainer == null) + return; + EventAddLainer?.Invoke(_lainer); + Close(); + } + private void panelObject_DragEnter(object sender, DragEventArgs e) + { + if (e.Data?.GetDataPresent(DataFormats.Text) ?? false) + { + 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 "labelBase": + _lainer = new DrawingEntity((int)numericUpDownSpeed.Value, + (int)numericUpDownWeight.Value, Color.White, 729, 397); + break; + case "labelSuper": + _lainer = new DrawningSuperLainer((int)numericUpDownSpeed.Value, + (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxPool.Checked, checkBoxDecks.Checked, pictureBoxDragAndDrop.Width, pictureBoxDragAndDrop.Height); + break; + } + DrawLainer(); + } + private void labelColor_DragDrop(object sender, DragEventArgs e) + { + if (_lainer?.EntityLainer == null) + return; + Color bodyColor = (Color)e.Data.GetData(typeof(Color)); + _lainer.EntityLainer.ChangeColor(bodyColor); + DrawLainer(); + } + 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 labelAddColor_DragDrop(object sender, DragEventArgs e) + { + if ((_lainer?.EntityLainer == null) || (_lainer is DrawningSuperLainer == false)) + return; + Color additionalColor = (Color)e.Data.GetData(typeof(Color)); + ((EntitySuperLainer)_lainer.EntityLainer).ChangeAddColor(additionalColor); + DrawLainer(); + } + } +} diff --git a/lainer/Lainer1/FormLainerConfig.resx b/lainer/Lainer1/FormLainerConfig.resx new file mode 100644 index 0000000..0f362c9 --- /dev/null +++ b/lainer/Lainer1/FormLainerConfig.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 a29254945dcc9d279cdce058d0c8bb8685dedcbe Mon Sep 17 00:00:00 2001 From: Ivan_Starostin Date: Tue, 19 Dec 2023 19:26:32 +0400 Subject: [PATCH 2/4] =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=BB?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD=D0=BE?= =?UTF-8?q?=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lainer/Lainer1/FormLainerCollection.cs | 79 ++++++++++++++++---------- lainer/Lainer1/LainerDelegate.cs | 12 ++++ 2 files changed, 61 insertions(+), 30 deletions(-) create mode 100644 lainer/Lainer1/LainerDelegate.cs diff --git a/lainer/Lainer1/FormLainerCollection.cs b/lainer/Lainer1/FormLainerCollection.cs index 07372e7..2c3c800 100644 --- a/lainer/Lainer1/FormLainerCollection.cs +++ b/lainer/Lainer1/FormLainerCollection.cs @@ -1,4 +1,15 @@ -using ProjectLainer.DrawningObjects; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Reflection.Metadata.Ecma335; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +using ProjectLainer.DrawningObjects; using ProjectLainer.Generics; using ProjectLainer.MovementStrategy; @@ -10,26 +21,24 @@ namespace ProjectLainer public FormLainerCollection() { InitializeComponent(); - _storage = new LainersGenericStorage(pictureBoxCollection.Width, - pictureBoxCollection.Height); + _storage = new LainersGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height); } private void ReloadObjects() { int index = listBoxStorages.SelectedIndex; listBoxStorages.Items.Clear(); - - foreach (string key in _storage.Keys) + for (int i = 0; i < _storage.Keys.Count; i++) { - listBoxStorages.Items.Add(key); - if (listBoxStorages.Items.Count > 0 && (index == -1 || index >= listBoxStorages.Items.Count)) - { - listBoxStorages.SelectedIndex = 0; - } - else if (listBoxStorages.Items.Count > 0 && index > -1 && index < listBoxStorages.Items.Count) - { - listBoxStorages.SelectedIndex = index; - } - } + listBoxStorages.Items.Add(_storage.Keys[i]); + } + if (listBoxStorages.Items.Count > 0 && (index == -1 || index >= listBoxStorages.Items.Count)) + { + listBoxStorages.SelectedIndex = 0; + } + else if (listBoxStorages.Items.Count > 0 && index > -1 && index < listBoxStorages.Items.Count) + { + listBoxStorages.SelectedIndex = index; + } } private void ButtonAddObject_Click(object sender, EventArgs e) { @@ -66,19 +75,9 @@ namespace ProjectLainer { return; } - LainerForm form = new(); - if (form.ShowDialog() == DialogResult.OK) - { - if (obj + form.SelectedLainer) - { - MessageBox.Show("Объект добавлен"); - pictureBoxCollection.Image = obj.ShowLainers(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } - } + var formLinerConfig = new FormLainerConfig(); + formLinerConfig.AddEvent(AddLainer); + formLinerConfig.Show(); } private void ButtonRemove_Click(object sender, EventArgs e) { @@ -86,8 +85,7 @@ namespace ProjectLainer { return; } - var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? - string.Empty]; + var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; if (obj == null) { return; @@ -126,5 +124,26 @@ namespace ProjectLainer { pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowLainers(); } + private void AddLainer(DrawingEntity lainer) + { + if (listBoxStorages.SelectedIndex == -1) + { + return; + } + var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; + if (obj == null) + { + return; + } + if (obj + lainer) + { + MessageBox.Show("Объект добавлен"); + pictureBoxCollection.Image = obj.ShowLainers(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } } } diff --git a/lainer/Lainer1/LainerDelegate.cs b/lainer/Lainer1/LainerDelegate.cs new file mode 100644 index 0000000..933999d --- /dev/null +++ b/lainer/Lainer1/LainerDelegate.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ProjectLainer.DrawningObjects; + +namespace Lainers +{ + public delegate void LainerDelegate(DrawingEntity car); + +} -- 2.25.1 From 60f34c49b3b291eda0d07260efec25e2e07aeac9 Mon Sep 17 00:00:00 2001 From: Ivan_Starostin Date: Tue, 19 Dec 2023 19:31:20 +0400 Subject: [PATCH 3/4] =?UTF-8?q?revert=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5?= =?UTF-8?q?=D0=B4=D0=BD=D0=B8=D0=B9=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit revert файлы лабораторной --- lainer/Lainer1/FormLainerCollection.cs | 77 ++++++++++---------------- lainer/Lainer1/LainerDelegate.cs | 12 ---- 2 files changed, 29 insertions(+), 60 deletions(-) delete mode 100644 lainer/Lainer1/LainerDelegate.cs diff --git a/lainer/Lainer1/FormLainerCollection.cs b/lainer/Lainer1/FormLainerCollection.cs index 2c3c800..75fc4cf 100644 --- a/lainer/Lainer1/FormLainerCollection.cs +++ b/lainer/Lainer1/FormLainerCollection.cs @@ -1,15 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Reflection.Metadata.Ecma335; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -using ProjectLainer.DrawningObjects; +using ProjectLainer.DrawningObjects; using ProjectLainer.Generics; using ProjectLainer.MovementStrategy; @@ -21,23 +10,25 @@ namespace ProjectLainer public FormLainerCollection() { InitializeComponent(); - _storage = new LainersGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height); + _storage = new LainersGenericStorage(pictureBoxCollection.Width, + pictureBoxCollection.Height); } private void ReloadObjects() { int index = listBoxStorages.SelectedIndex; listBoxStorages.Items.Clear(); - for (int i = 0; i < _storage.Keys.Count; i++) + + foreach (string key in _storage.Keys) { - listBoxStorages.Items.Add(_storage.Keys[i]); - } - if (listBoxStorages.Items.Count > 0 && (index == -1 || index >= listBoxStorages.Items.Count)) - { - listBoxStorages.SelectedIndex = 0; - } - else if (listBoxStorages.Items.Count > 0 && index > -1 && index < listBoxStorages.Items.Count) - { - listBoxStorages.SelectedIndex = index; + listBoxStorages.Items.Add(key); + if (listBoxStorages.Items.Count > 0 && (index == -1 || index >= listBoxStorages.Items.Count)) + { + listBoxStorages.SelectedIndex = 0; + } + else if (listBoxStorages.Items.Count > 0 && index > -1 && index < listBoxStorages.Items.Count) + { + listBoxStorages.SelectedIndex = index; + } } } private void ButtonAddObject_Click(object sender, EventArgs e) @@ -75,9 +66,19 @@ namespace ProjectLainer { return; } - var formLinerConfig = new FormLainerConfig(); - formLinerConfig.AddEvent(AddLainer); - formLinerConfig.Show(); + LainerForm form = new(); + if (form.ShowDialog() == DialogResult.OK) + { + if (obj + form.SelectedLainer) + { + MessageBox.Show("Объект добавлен"); + pictureBoxCollection.Image = obj.ShowLainers(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } } private void ButtonRemove_Click(object sender, EventArgs e) { @@ -85,7 +86,8 @@ namespace ProjectLainer { return; } - var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; + var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? + string.Empty]; if (obj == null) { return; @@ -124,26 +126,5 @@ namespace ProjectLainer { pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowLainers(); } - private void AddLainer(DrawingEntity lainer) - { - if (listBoxStorages.SelectedIndex == -1) - { - return; - } - var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; - if (obj == null) - { - return; - } - if (obj + lainer) - { - MessageBox.Show("Объект добавлен"); - pictureBoxCollection.Image = obj.ShowLainers(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } - } } } diff --git a/lainer/Lainer1/LainerDelegate.cs b/lainer/Lainer1/LainerDelegate.cs deleted file mode 100644 index 933999d..0000000 --- a/lainer/Lainer1/LainerDelegate.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ProjectLainer.DrawningObjects; - -namespace Lainers -{ - public delegate void LainerDelegate(DrawingEntity car); - -} -- 2.25.1 From 0208828b09e5df96ade327fc621e9eaea7616c38 Mon Sep 17 00:00:00 2001 From: Ivan_Starostin Date: Tue, 19 Dec 2023 19:32:23 +0400 Subject: [PATCH 4/4] =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=BB?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD=D0=BE?= =?UTF-8?q?=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lainer/Lainer1/FormLainerCollection.cs | 41 ++++++++++++++++---------- lainer/Lainer1/LainerDelegate.cs | 11 +++++++ 2 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 lainer/Lainer1/LainerDelegate.cs diff --git a/lainer/Lainer1/FormLainerCollection.cs b/lainer/Lainer1/FormLainerCollection.cs index 75fc4cf..5ad33d9 100644 --- a/lainer/Lainer1/FormLainerCollection.cs +++ b/lainer/Lainer1/FormLainerCollection.cs @@ -17,7 +17,7 @@ namespace ProjectLainer { int index = listBoxStorages.SelectedIndex; listBoxStorages.Items.Clear(); - + foreach (string key in _storage.Keys) { listBoxStorages.Items.Add(key); @@ -29,7 +29,7 @@ namespace ProjectLainer { listBoxStorages.SelectedIndex = index; } - } + } } private void ButtonAddObject_Click(object sender, EventArgs e) { @@ -66,19 +66,9 @@ namespace ProjectLainer { return; } - LainerForm form = new(); - if (form.ShowDialog() == DialogResult.OK) - { - if (obj + form.SelectedLainer) - { - MessageBox.Show("Объект добавлен"); - pictureBoxCollection.Image = obj.ShowLainers(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } - } + var formLinerConfig = new FormLainerConfig(); + formLinerConfig.AddEvent(AddLainer); + formLinerConfig.Show(); } private void ButtonRemove_Click(object sender, EventArgs e) { @@ -126,5 +116,26 @@ namespace ProjectLainer { pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowLainers(); } + private void AddLainer(DrawingEntity lainer) + { + if (listBoxStorages.SelectedIndex == -1) + { + return; + } + var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; + if (obj == null) + { + return; + } + if (obj + lainer) + { + MessageBox.Show("Объект добавлен"); + pictureBoxCollection.Image = obj.ShowLainers(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } } } diff --git a/lainer/Lainer1/LainerDelegate.cs b/lainer/Lainer1/LainerDelegate.cs new file mode 100644 index 0000000..588bcf2 --- /dev/null +++ b/lainer/Lainer1/LainerDelegate.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ProjectLainer.DrawningObjects; + +namespace Lainers +{ + public delegate void LainerDelegate(DrawingEntity lainer); +} -- 2.25.1