From 48da802add4e090335ef46c3c299ff1081d307b8 Mon Sep 17 00:00:00 2001 From: katana Date: Sun, 19 Nov 2023 21:14:51 +0400 Subject: [PATCH] =?UTF-8?q?5=20=D0=B1=D0=B0=D0=B7=D0=BE=D0=B2=D0=B0=D1=8F?= =?UTF-8?q?=20=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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectSeaplane/DrawingPlane.cs | 9 +- .../ProjectSeaplane/DrawingSeaplane.cs | 4 + .../ProjectSeaplane/EntityPlane.cs | 2 +- .../ProjectSeaplane/EntitySeaplane.cs | 4 +- .../ProjectSeaplane/FormPlaneCollection.cs | 14 +- .../FormPlaneConfig.Designer.cs | 372 ++++++++++++++++++ .../ProjectSeaplane/FormPlaneConfig.cs | 163 ++++++++ .../ProjectSeaplane/FormPlaneConfig.resx | 60 +++ .../ProjectSeaplane/PlaneDelegate.cs | 15 + .../PlanesGenericCollection.cs | 2 + 10 files changed, 635 insertions(+), 10 deletions(-) create mode 100644 ProjectSeaplane/ProjectSeaplane/FormPlaneConfig.Designer.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/FormPlaneConfig.cs create mode 100644 ProjectSeaplane/ProjectSeaplane/FormPlaneConfig.resx create mode 100644 ProjectSeaplane/ProjectSeaplane/PlaneDelegate.cs diff --git a/ProjectSeaplane/ProjectSeaplane/DrawingPlane.cs b/ProjectSeaplane/ProjectSeaplane/DrawingPlane.cs index e1ed025..7abbd97 100644 --- a/ProjectSeaplane/ProjectSeaplane/DrawingPlane.cs +++ b/ProjectSeaplane/ProjectSeaplane/DrawingPlane.cs @@ -21,11 +21,11 @@ namespace ProjectSeaplane.DrawningObjects /// /// Ширина окна /// - private int _pictureWidth; + public int _pictureWidth; /// /// Высота окна /// - private int _pictureHeight; + public int _pictureHeight; /// /// Левая координата прорисовки автомобиля /// @@ -177,6 +177,11 @@ namespace ProjectSeaplane.DrawningObjects } } + public void setBodyColor(Color color) + { + EntityPlane.BodyColor = color; + } + /// /// Получение объекта IMoveableObject из объекта DrawningCar /// diff --git a/ProjectSeaplane/ProjectSeaplane/DrawingSeaplane.cs b/ProjectSeaplane/ProjectSeaplane/DrawingSeaplane.cs index 3536d6b..d74c4a8 100644 --- a/ProjectSeaplane/ProjectSeaplane/DrawingSeaplane.cs +++ b/ProjectSeaplane/ProjectSeaplane/DrawingSeaplane.cs @@ -12,6 +12,10 @@ namespace ProjectSeaplane.DrawningObjects /// public class DrawningSeaplane : DrawningPlane { + public void setAdditionalColor(Color color) + { + (EntityPlane as EntitySeaplane).AdditionalColor = color; + } /// /// Инициализация свойств /// diff --git a/ProjectSeaplane/ProjectSeaplane/EntityPlane.cs b/ProjectSeaplane/ProjectSeaplane/EntityPlane.cs index d0e43a0..dbe7b33 100644 --- a/ProjectSeaplane/ProjectSeaplane/EntityPlane.cs +++ b/ProjectSeaplane/ProjectSeaplane/EntityPlane.cs @@ -22,7 +22,7 @@ namespace ProjectSeaplane.Entities /// /// Основной цвет /// - public Color BodyColor { get; private set; } + public Color BodyColor { get; set; } /// /// Шаг перемещения автомобиля /// diff --git a/ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs b/ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs index 6687a65..9cd768d 100644 --- a/ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs +++ b/ProjectSeaplane/ProjectSeaplane/EntitySeaplane.cs @@ -19,9 +19,9 @@ namespace ProjectSeaplane.Entities /// /// Дополнительный цвет (для опциональных элементов) /// - public Color AdditionalColor { get; private set; } + public Color AdditionalColor { get; set; } /// - /// Инициализация полей объекта-класса спортивного автомобиля + /// Инициализация полей объекта-класса водного самолета /// /// Скорость /// Вес автомобиля diff --git a/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs index e9001dc..5a0dd88 100644 --- a/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs +++ b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs @@ -96,6 +96,7 @@ namespace ProjectSeaplane ReloadObjects(); } } + /// /// Добавление объекта в набор @@ -113,10 +114,11 @@ namespace ProjectSeaplane { return; } - FormSeaplane form = new FormSeaplane(); - if (form.ShowDialog() == DialogResult.OK) - { - if (obj + form.SelectedPlane) + FormPlaneConfig form = new FormPlaneConfig(); + + Action? planeDelegate = new((m) => { + bool q = (obj + m); + if (q) { MessageBox.Show("Объект добавлен"); pictureBoxCollection.Image = obj.ShowPlanes(); @@ -125,7 +127,9 @@ namespace ProjectSeaplane { MessageBox.Show("Не удалось добавить объект"); } - } + }); + form.AddEvent(planeDelegate); + form.Show(); } /// /// Удаление объекта из набора diff --git a/ProjectSeaplane/ProjectSeaplane/FormPlaneConfig.Designer.cs b/ProjectSeaplane/ProjectSeaplane/FormPlaneConfig.Designer.cs new file mode 100644 index 0000000..82fe3a0 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/FormPlaneConfig.Designer.cs @@ -0,0 +1,372 @@ +namespace ProjectSeaplane +{ + partial class FormPlaneConfig + { + /// + /// 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() + { + pictureBox = new PictureBox(); + groupBoxParams = new GroupBox(); + labelModifiedObject = new Label(); + labelSimpleObject = new Label(); + groupBoxColors = new GroupBox(); + panelPurple = new Panel(); + panelYellow = new Panel(); + panelBlack = new Panel(); + panelBlue = new Panel(); + panelGray = new Panel(); + panelGreen = new Panel(); + panelWhite = new Panel(); + panelRed = new Panel(); + checkBoxFloater = new CheckBox(); + checkBoxBoat = new CheckBox(); + numericUpDownWeight = new NumericUpDown(); + labelWeight = new Label(); + numericUpDownSpeed = new NumericUpDown(); + labelSpeed = new Label(); + panelReciever = new Panel(); + labelAdditionalColor = new Label(); + pictureBoxObject = new PictureBox(); + labelColor = new Label(); + buttonAddObj = new Button(); + buttonCancelObj = new Button(); + ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit(); + groupBoxParams.SuspendLayout(); + groupBoxColors.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit(); + panelReciever.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit(); + SuspendLayout(); + // + // pictureBox + // + pictureBox.Dock = DockStyle.Fill; + pictureBox.Location = new Point(0, 0); + pictureBox.Name = "pictureBox"; + pictureBox.Size = new Size(876, 286); + pictureBox.TabIndex = 0; + pictureBox.TabStop = false; + // + // groupBoxParams + // + groupBoxParams.Controls.Add(labelModifiedObject); + groupBoxParams.Controls.Add(labelSimpleObject); + groupBoxParams.Controls.Add(groupBoxColors); + groupBoxParams.Controls.Add(checkBoxFloater); + groupBoxParams.Controls.Add(checkBoxBoat); + groupBoxParams.Controls.Add(numericUpDownWeight); + groupBoxParams.Controls.Add(labelWeight); + groupBoxParams.Controls.Add(numericUpDownSpeed); + groupBoxParams.Controls.Add(labelSpeed); + groupBoxParams.Location = new Point(12, 12); + groupBoxParams.Name = "groupBoxParams"; + groupBoxParams.Size = new Size(492, 256); + groupBoxParams.TabIndex = 1; + groupBoxParams.TabStop = false; + groupBoxParams.Text = "Параметры"; + // + // labelModifiedObject + // + labelModifiedObject.BorderStyle = BorderStyle.FixedSingle; + labelModifiedObject.Location = new Point(363, 199); + labelModifiedObject.Name = "labelModifiedObject"; + labelModifiedObject.Size = new Size(113, 34); + labelModifiedObject.TabIndex = 8; + labelModifiedObject.Text = "Продвинутый"; + labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter; + labelModifiedObject.DragDrop += PanelObject_DragDrop; + labelModifiedObject.MouseDown += LabelObject_MouseDown; + // + // labelSimpleObject + // + labelSimpleObject.BorderStyle = BorderStyle.FixedSingle; + labelSimpleObject.Location = new Point(223, 199); + labelSimpleObject.Name = "labelSimpleObject"; + labelSimpleObject.Size = new Size(105, 34); + labelSimpleObject.TabIndex = 7; + labelSimpleObject.Text = "Простой"; + labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter; + labelSimpleObject.DragDrop += PanelObject_DragDrop; + labelSimpleObject.MouseDown += LabelObject_MouseDown; + // + // groupBoxColors + // + groupBoxColors.Controls.Add(panelPurple); + groupBoxColors.Controls.Add(panelYellow); + groupBoxColors.Controls.Add(panelBlack); + groupBoxColors.Controls.Add(panelBlue); + groupBoxColors.Controls.Add(panelGray); + groupBoxColors.Controls.Add(panelGreen); + groupBoxColors.Controls.Add(panelWhite); + groupBoxColors.Controls.Add(panelRed); + groupBoxColors.Location = new Point(223, 22); + groupBoxColors.Name = "groupBoxColors"; + groupBoxColors.Size = new Size(253, 138); + groupBoxColors.TabIndex = 6; + groupBoxColors.TabStop = false; + groupBoxColors.Text = "Цвета"; + // + // panelPurple + // + panelPurple.BackColor = Color.Purple; + panelPurple.Location = new Point(202, 87); + panelPurple.Name = "panelPurple"; + panelPurple.Size = new Size(45, 45); + panelPurple.TabIndex = 3; + // + // panelYellow + // + panelYellow.BackColor = Color.Yellow; + panelYellow.Location = new Point(202, 22); + panelYellow.Name = "panelYellow"; + panelYellow.Size = new Size(45, 45); + panelYellow.TabIndex = 1; + // + // panelBlack + // + panelBlack.BackColor = Color.Black; + panelBlack.Location = new Point(134, 87); + panelBlack.Name = "panelBlack"; + panelBlack.Size = new Size(45, 45); + panelBlack.TabIndex = 4; + // + // panelBlue + // + panelBlue.BackColor = Color.FromArgb(0, 0, 192); + panelBlue.Location = new Point(134, 22); + panelBlue.Name = "panelBlue"; + panelBlue.Size = new Size(45, 45); + panelBlue.TabIndex = 1; + // + // panelGray + // + panelGray.BackColor = Color.Gray; + panelGray.Location = new Point(68, 87); + panelGray.Name = "panelGray"; + panelGray.Size = new Size(45, 45); + panelGray.TabIndex = 5; + // + // panelGreen + // + panelGreen.BackColor = Color.FromArgb(0, 192, 0); + panelGreen.Location = new Point(68, 22); + panelGreen.Name = "panelGreen"; + panelGreen.Size = new Size(45, 45); + panelGreen.TabIndex = 1; + // + // panelWhite + // + panelWhite.BackColor = Color.White; + panelWhite.Location = new Point(6, 87); + panelWhite.Name = "panelWhite"; + panelWhite.Size = new Size(45, 45); + panelWhite.TabIndex = 2; + // + // panelRed + // + panelRed.BackColor = Color.Red; + panelRed.Location = new Point(6, 22); + panelRed.Name = "panelRed"; + panelRed.Size = new Size(45, 45); + panelRed.TabIndex = 0; + // + // checkBoxFloater + // + checkBoxFloater.AutoSize = true; + checkBoxFloater.Location = new Point(6, 117); + checkBoxFloater.Name = "checkBoxFloater"; + checkBoxFloater.Size = new Size(137, 19); + checkBoxFloater.TabIndex = 5; + checkBoxFloater.Text = "Наличие поплавков"; + checkBoxFloater.UseVisualStyleBackColor = true; + // + // checkBoxBoat + // + checkBoxBoat.AutoSize = true; + checkBoxBoat.Location = new Point(6, 92); + checkBoxBoat.Name = "checkBoxBoat"; + checkBoxBoat.Size = new Size(166, 19); + checkBoxBoat.TabIndex = 4; + checkBoxBoat.Text = "Наличие надувной лодки"; + checkBoxBoat.UseVisualStyleBackColor = true; + // + // numericUpDownWeight + // + numericUpDownWeight.Location = new Point(80, 53); + 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(58, 23); + numericUpDownWeight.TabIndex = 3; + numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // labelWeight + // + labelWeight.AutoSize = true; + labelWeight.Location = new Point(6, 55); + labelWeight.Name = "labelWeight"; + labelWeight.Size = new Size(29, 15); + labelWeight.TabIndex = 2; + labelWeight.Text = "Вес:"; + // + // numericUpDownSpeed + // + numericUpDownSpeed.Location = new Point(80, 19); + 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(58, 23); + numericUpDownSpeed.TabIndex = 1; + numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // labelSpeed + // + labelSpeed.AutoSize = true; + labelSpeed.Location = new Point(6, 21); + labelSpeed.Name = "labelSpeed"; + labelSpeed.Size = new Size(62, 15); + labelSpeed.TabIndex = 0; + labelSpeed.Text = "Скорость:"; + // + // panelReciever + // + panelReciever.AllowDrop = true; + panelReciever.Controls.Add(labelAdditionalColor); + panelReciever.Controls.Add(pictureBoxObject); + panelReciever.Controls.Add(labelColor); + panelReciever.Location = new Point(555, 12); + panelReciever.Name = "panelReciever"; + panelReciever.Size = new Size(300, 220); + panelReciever.TabIndex = 3; + panelReciever.DragDrop += PanelObject_DragDrop; + panelReciever.DragEnter += PanelObject_DragEnter; + // + // labelAdditionalColor + // + labelAdditionalColor.AllowDrop = true; + labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle; + labelAdditionalColor.Location = new Point(172, 19); + labelAdditionalColor.Name = "labelAdditionalColor"; + labelAdditionalColor.Size = new Size(114, 28); + labelAdditionalColor.TabIndex = 2; + labelAdditionalColor.Text = "Доп. цвет"; + labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter; + labelAdditionalColor.DragDrop += labelColor_DragDrop; + labelAdditionalColor.DragEnter += labelColor_DragEnter; + // + // pictureBoxObject + // + pictureBoxObject.Location = new Point(18, 53); + pictureBoxObject.Name = "pictureBoxObject"; + pictureBoxObject.Size = new Size(268, 150); + pictureBoxObject.TabIndex = 0; + pictureBoxObject.TabStop = false; + // + // labelColor + // + labelColor.AllowDrop = true; + labelColor.BorderStyle = BorderStyle.FixedSingle; + labelColor.Location = new Point(18, 19); + labelColor.Name = "labelColor"; + labelColor.Size = new Size(115, 28); + labelColor.TabIndex = 1; + labelColor.Text = "Цвет"; + labelColor.TextAlign = ContentAlignment.MiddleCenter; + labelColor.DragDrop += labelColor_DragDrop; + labelColor.DragEnter += labelColor_DragEnter; + // + // buttonAddObj + // + buttonAddObj.Location = new Point(555, 239); + buttonAddObj.Name = "buttonAddObj"; + buttonAddObj.Size = new Size(129, 32); + buttonAddObj.TabIndex = 4; + buttonAddObj.Text = "Добавить"; + buttonAddObj.UseVisualStyleBackColor = true; + buttonAddObj.Click += ButtonOk_Click; + // + // buttonCancelObj + // + buttonCancelObj.Location = new Point(723, 239); + buttonCancelObj.Name = "buttonCancelObj"; + buttonCancelObj.Size = new Size(132, 32); + buttonCancelObj.TabIndex = 5; + buttonCancelObj.Text = "Отмена"; + buttonCancelObj.UseVisualStyleBackColor = true; + // + // FormPlaneConfig + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(876, 286); + Controls.Add(buttonCancelObj); + Controls.Add(buttonAddObj); + Controls.Add(panelReciever); + Controls.Add(groupBoxParams); + Controls.Add(pictureBox); + Name = "FormPlaneConfig"; + Text = "FormPlaneConfig"; + ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit(); + groupBoxParams.ResumeLayout(false); + groupBoxParams.PerformLayout(); + groupBoxColors.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit(); + panelReciever.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit(); + ResumeLayout(false); + } + + #endregion + + private PictureBox pictureBox; + private GroupBox groupBoxParams; + 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 CheckBox checkBoxFloater; + private CheckBox checkBoxBoat; + private Panel panelReciever; + private Label labelAdditionalColor; + private Label labelColor; + private PictureBox pictureBoxObject; + private Button buttonAddObj; + private Button buttonCancelObj; + } +} \ No newline at end of file diff --git a/ProjectSeaplane/ProjectSeaplane/FormPlaneConfig.cs b/ProjectSeaplane/ProjectSeaplane/FormPlaneConfig.cs new file mode 100644 index 0000000..b229ec2 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/FormPlaneConfig.cs @@ -0,0 +1,163 @@ +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; +using ProjectSeaplane.DrawningObjects; + + +namespace ProjectSeaplane +{ + public partial class FormPlaneConfig : Form + { + Color defaultColor; + /// + /// Переменная-выбранная машина + /// + DrawningPlane? _plane = null; + /// + /// Событие + /// + private event Action? EventAddPlane; + /// Добавление события + /// + /// Привязанный метод + public void AddEvent(Action ev) + { + if (EventAddPlane == null) + { + EventAddPlane = ev; + } + else + { + EventAddPlane += ev; + } + } + /// + /// Добавление самолета + /// + /// + /// + private void ButtonOk_Click(object sender, EventArgs e) + { + EventAddPlane?.Invoke(_plane); + Close(); + } + /// + /// Конструктор + /// + public FormPlaneConfig() + { + InitializeComponent(); + defaultColor = labelColor.BackColor; + buttonCancelObj.Click += (s, e) => Close(); + + 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; + } + /// + /// Отрисовать машину + /// + private void DrawPlane() + { + Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); + Graphics gr = Graphics.FromImage(bmp); + _plane?.SetPosition(5, 5); + _plane?.DrawTransport(gr); + pictureBoxObject.Image = bmp; + } + /// + /// Передаем информацию при нажатии на Label + /// + /// + /// + 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) ?? 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 "labelSimpleObject": + _plane = new DrawningPlane((int)numericUpDownSpeed.Value, + (int)numericUpDownWeight.Value, Color.White, pictureBox.Width, + pictureBox.Height); + break; + case "labelModifiedObject": + _plane = new DrawningSeaplane((int)numericUpDownSpeed.Value, + (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxFloater.Checked, + checkBoxBoat.Checked, pictureBox.Width, pictureBox.Height); + break; + } + DrawPlane(); + } + private void PanelColor_MouseDown(object sender, MouseEventArgs e) + { + (sender as Panel)?.DoDragDrop((sender as Panel)?.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 labelColor_DragDrop(object sender, DragEventArgs e) + { + if (_plane == null) + return; + ((Label)sender).BackColor = (Color)e.Data.GetData(typeof(Color)); + switch (((Label)sender).Name) + { + case "labelColor": + _plane.setBodyColor((Color)e.Data.GetData(typeof(Color))); + break; + case "labelAdditionalColor": + if (!(_plane is DrawningSeaplane)) + return; + (_plane as DrawningSeaplane).setAdditionalColor((Color)e.Data.GetData(typeof(Color))); + break; + } + DrawPlane(); + } + } +} diff --git a/ProjectSeaplane/ProjectSeaplane/FormPlaneConfig.resx b/ProjectSeaplane/ProjectSeaplane/FormPlaneConfig.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/FormPlaneConfig.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 diff --git a/ProjectSeaplane/ProjectSeaplane/PlaneDelegate.cs b/ProjectSeaplane/ProjectSeaplane/PlaneDelegate.cs new file mode 100644 index 0000000..4c4ae11 --- /dev/null +++ b/ProjectSeaplane/ProjectSeaplane/PlaneDelegate.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ProjectSeaplane.DrawningObjects; + +namespace ProjectSeaplane +{ + /// + /// Делегат для передачи объекта-самолета + /// + /// + public delegate void PlaneDelegate(DrawningPlane plane); +} diff --git a/ProjectSeaplane/ProjectSeaplane/PlanesGenericCollection.cs b/ProjectSeaplane/ProjectSeaplane/PlanesGenericCollection.cs index b88025f..7c000d2 100644 --- a/ProjectSeaplane/ProjectSeaplane/PlanesGenericCollection.cs +++ b/ProjectSeaplane/ProjectSeaplane/PlanesGenericCollection.cs @@ -130,6 +130,8 @@ namespace ProjectSeaplane.Generics { if (plane != null) { + plane._pictureHeight = _pictureHeight; + plane._pictureWidth = _pictureWidth; plane.SetPosition((width - 1 - (i % width)) * _placeSizeWidth, (width - (i / width) - 1) * _placeSizeHeight); plane.DrawTransport(g); }