From f5856902f02b4151b1de44d82be866188596f954 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Thu, 20 Oct 2022 11:03:46 +0400 Subject: [PATCH 01/11] Add config form. --- Airbus/Airbus/FormPlaneConfig.Designer.cs | 367 ++++++++++++++++++++++ Airbus/Airbus/FormPlaneConfig.cs | 108 +++++++ Airbus/Airbus/FormPlaneConfig.resx | 60 ++++ 3 files changed, 535 insertions(+) create mode 100644 Airbus/Airbus/FormPlaneConfig.Designer.cs create mode 100644 Airbus/Airbus/FormPlaneConfig.cs create mode 100644 Airbus/Airbus/FormPlaneConfig.resx diff --git a/Airbus/Airbus/FormPlaneConfig.Designer.cs b/Airbus/Airbus/FormPlaneConfig.Designer.cs new file mode 100644 index 0000000..9d8717e --- /dev/null +++ b/Airbus/Airbus/FormPlaneConfig.Designer.cs @@ -0,0 +1,367 @@ +namespace Airbus +{ + 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() + { + 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.panelWhite = new System.Windows.Forms.Panel(); + this.panelGray = new System.Windows.Forms.Panel(); + this.panelBlack = new System.Windows.Forms.Panel(); + this.panelPurple = new System.Windows.Forms.Panel(); + this.panelYellow = new System.Windows.Forms.Panel(); + this.panelBlue = new System.Windows.Forms.Panel(); + this.panelGreen = new System.Windows.Forms.Panel(); + this.panelRed = new System.Windows.Forms.Panel(); + this.checkBoxAddEngine = new System.Windows.Forms.CheckBox(); + this.checkBoxAddСompartment = 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.pictureBoxObject = new System.Windows.Forms.PictureBox(); + this.panelObject = new System.Windows.Forms.Panel(); + this.labelAddColor = new System.Windows.Forms.Label(); + this.labelBaseColor = new System.Windows.Forms.Label(); + this.buttonAddObject = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.groupBoxConfig.SuspendLayout(); + this.groupBoxColors.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit(); + this.panelObject.SuspendLayout(); + 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.checkBoxAddEngine); + this.groupBoxConfig.Controls.Add(this.checkBoxAddСompartment); + 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(12, 12); + this.groupBoxConfig.Name = "groupBoxConfig"; + this.groupBoxConfig.Size = new System.Drawing.Size(720, 245); + 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(595, 154); + this.labelModifiedObject.Name = "labelModifiedObject"; + this.labelModifiedObject.Size = new System.Drawing.Size(114, 58); + this.labelModifiedObject.TabIndex = 8; + 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(471, 154); + this.labelSimpleObject.Name = "labelSimpleObject"; + this.labelSimpleObject.Size = new System.Drawing.Size(112, 58); + this.labelSimpleObject.TabIndex = 7; + 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.panelWhite); + this.groupBoxColors.Controls.Add(this.panelGray); + this.groupBoxColors.Controls.Add(this.panelBlack); + this.groupBoxColors.Controls.Add(this.panelPurple); + this.groupBoxColors.Controls.Add(this.panelYellow); + this.groupBoxColors.Controls.Add(this.panelBlue); + this.groupBoxColors.Controls.Add(this.panelGreen); + this.groupBoxColors.Controls.Add(this.panelRed); + this.groupBoxColors.Location = new System.Drawing.Point(471, 17); + this.groupBoxColors.Name = "groupBoxColors"; + this.groupBoxColors.Size = new System.Drawing.Size(238, 125); + this.groupBoxColors.TabIndex = 6; + this.groupBoxColors.TabStop = false; + this.groupBoxColors.Text = "Цвета"; + // + // panelWhite + // + this.panelWhite.BackColor = System.Drawing.Color.White; + this.panelWhite.Location = new System.Drawing.Point(6, 79); + this.panelWhite.Name = "panelWhite"; + this.panelWhite.Size = new System.Drawing.Size(40, 40); + this.panelWhite.TabIndex = 7; + this.panelWhite.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelGray + // + this.panelGray.BackColor = System.Drawing.Color.Gray; + this.panelGray.Location = new System.Drawing.Point(67, 79); + this.panelGray.Name = "panelGray"; + this.panelGray.Size = new System.Drawing.Size(40, 40); + this.panelGray.TabIndex = 6; + this.panelGray.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelBlack + // + this.panelBlack.BackColor = System.Drawing.Color.Black; + this.panelBlack.Location = new System.Drawing.Point(130, 79); + this.panelBlack.Name = "panelBlack"; + this.panelBlack.Size = new System.Drawing.Size(40, 40); + this.panelBlack.TabIndex = 5; + this.panelBlack.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelPurple + // + this.panelPurple.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(192))))); + this.panelPurple.Location = new System.Drawing.Point(192, 79); + this.panelPurple.Name = "panelPurple"; + this.panelPurple.Size = new System.Drawing.Size(40, 40); + this.panelPurple.TabIndex = 4; + 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(192, 26); + this.panelYellow.Name = "panelYellow"; + this.panelYellow.Size = new System.Drawing.Size(40, 40); + this.panelYellow.TabIndex = 3; + this.panelYellow.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelBlue + // + this.panelBlue.BackColor = System.Drawing.Color.Blue; + this.panelBlue.Location = new System.Drawing.Point(130, 26); + this.panelBlue.Name = "panelBlue"; + this.panelBlue.Size = new System.Drawing.Size(40, 40); + this.panelBlue.TabIndex = 2; + this.panelBlue.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelGreen + // + this.panelGreen.BackColor = System.Drawing.Color.Lime; + this.panelGreen.Location = new System.Drawing.Point(67, 26); + this.panelGreen.Name = "panelGreen"; + this.panelGreen.Size = new System.Drawing.Size(40, 40); + this.panelGreen.TabIndex = 1; + this.panelGreen.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // panelRed + // + this.panelRed.BackColor = System.Drawing.Color.Red; + this.panelRed.Location = new System.Drawing.Point(6, 26); + this.panelRed.Name = "panelRed"; + this.panelRed.Size = new System.Drawing.Size(40, 40); + this.panelRed.TabIndex = 0; + this.panelRed.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown); + // + // checkBoxAddEngine + // + this.checkBoxAddEngine.AutoSize = true; + this.checkBoxAddEngine.Location = new System.Drawing.Point(19, 188); + this.checkBoxAddEngine.Name = "checkBoxAddEngine"; + this.checkBoxAddEngine.Size = new System.Drawing.Size(355, 24); + this.checkBoxAddEngine.TabIndex = 5; + this.checkBoxAddEngine.Text = "Признак наличия дополнительного двигателя"; + this.checkBoxAddEngine.UseVisualStyleBackColor = true; + // + // checkBoxAddСompartment + // + this.checkBoxAddСompartment.AutoSize = true; + this.checkBoxAddСompartment.Location = new System.Drawing.Point(19, 146); + this.checkBoxAddСompartment.Name = "checkBoxAddСompartment"; + this.checkBoxAddСompartment.Size = new System.Drawing.Size(441, 24); + this.checkBoxAddСompartment.TabIndex = 4; + this.checkBoxAddСompartment.Text = "Признак наличия дополнительного пассажирского отсека"; + this.checkBoxAddСompartment.UseVisualStyleBackColor = true; + // + // numericUpDownWeight + // + this.numericUpDownWeight.Location = new System.Drawing.Point(114, 97); + this.numericUpDownWeight.Name = "numericUpDownWeight"; + this.numericUpDownWeight.Size = new System.Drawing.Size(103, 27); + this.numericUpDownWeight.TabIndex = 3; + this.numericUpDownWeight.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + // + // labelWeight + // + this.labelWeight.AutoSize = true; + this.labelWeight.Location = new System.Drawing.Point(19, 99); + this.labelWeight.Name = "labelWeight"; + this.labelWeight.Size = new System.Drawing.Size(36, 20); + this.labelWeight.TabIndex = 2; + this.labelWeight.Text = "Вес:"; + // + // numericUpDownSpeed + // + this.numericUpDownSpeed.Location = new System.Drawing.Point(114, 37); + this.numericUpDownSpeed.Name = "numericUpDownSpeed"; + this.numericUpDownSpeed.Size = new System.Drawing.Size(103, 27); + this.numericUpDownSpeed.TabIndex = 1; + this.numericUpDownSpeed.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + // + // labelSpeed + // + this.labelSpeed.AutoSize = true; + this.labelSpeed.Location = new System.Drawing.Point(19, 39); + this.labelSpeed.Name = "labelSpeed"; + this.labelSpeed.Size = new System.Drawing.Size(76, 20); + this.labelSpeed.TabIndex = 0; + this.labelSpeed.Text = "Скорость:"; + // + // pictureBoxObject + // + this.pictureBoxObject.Location = new System.Drawing.Point(16, 51); + this.pictureBoxObject.Name = "pictureBoxObject"; + this.pictureBoxObject.Size = new System.Drawing.Size(239, 136); + this.pictureBoxObject.TabIndex = 1; + this.pictureBoxObject.TabStop = false; + // + // panelObject + // + this.panelObject.AllowDrop = true; + this.panelObject.Controls.Add(this.labelAddColor); + this.panelObject.Controls.Add(this.labelBaseColor); + this.panelObject.Controls.Add(this.pictureBoxObject); + this.panelObject.Location = new System.Drawing.Point(738, 23); + this.panelObject.Name = "panelObject"; + this.panelObject.Size = new System.Drawing.Size(268, 190); + 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); + // + // labelAddColor + // + this.labelAddColor.AllowDrop = true; + this.labelAddColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelAddColor.Location = new System.Drawing.Point(141, 6); + this.labelAddColor.Name = "labelAddColor"; + this.labelAddColor.Size = new System.Drawing.Size(114, 42); + this.labelAddColor.TabIndex = 3; + this.labelAddColor.Text = "Доп. цвет"; + this.labelAddColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.labelAddColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelAddColor_DragDrop); + // + // labelBaseColor + // + this.labelBaseColor.AllowDrop = true; + this.labelBaseColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelBaseColor.Location = new System.Drawing.Point(16, 6); + this.labelBaseColor.Name = "labelBaseColor"; + this.labelBaseColor.Size = new System.Drawing.Size(119, 42); + this.labelBaseColor.TabIndex = 2; + 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.LabelBaseColor_DragEnter); + // + // buttonAddObject + // + this.buttonAddObject.Location = new System.Drawing.Point(754, 219); + this.buttonAddObject.Name = "buttonAddObject"; + this.buttonAddObject.Size = new System.Drawing.Size(119, 38); + this.buttonAddObject.TabIndex = 3; + this.buttonAddObject.Text = "Добавить"; + this.buttonAddObject.UseVisualStyleBackColor = true; + // + // buttonCancel + // + this.buttonCancel.Location = new System.Drawing.Point(879, 219); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(114, 38); + this.buttonCancel.TabIndex = 4; + this.buttonCancel.Text = "Отмена"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // FormPlaneConfig + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1017, 273); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonAddObject); + this.Controls.Add(this.panelObject); + this.Controls.Add(this.groupBoxConfig); + this.Name = "FormPlaneConfig"; + 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(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit(); + this.panelObject.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private GroupBox groupBoxConfig; + private CheckBox checkBoxAddСompartment; + private NumericUpDown numericUpDownWeight; + private Label labelWeight; + private NumericUpDown numericUpDownSpeed; + private Label labelSpeed; + private CheckBox checkBoxAddEngine; + private Label labelModifiedObject; + private Label labelSimpleObject; + private GroupBox groupBoxColors; + private Panel panelWhite; + private Panel panelGray; + private Panel panelBlack; + private Panel panelPurple; + private Panel panelYellow; + private Panel panelBlue; + private Panel panelGreen; + private Panel panelRed; + private PictureBox pictureBoxObject; + private Panel panelObject; + private Label labelAddColor; + private Label labelBaseColor; + private Button buttonAddObject; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/Airbus/Airbus/FormPlaneConfig.cs b/Airbus/Airbus/FormPlaneConfig.cs new file mode 100644 index 0000000..782f697 --- /dev/null +++ b/Airbus/Airbus/FormPlaneConfig.cs @@ -0,0 +1,108 @@ +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 Airbus +{ + public partial class FormPlaneConfig : Form + { + //переменная-выбранная машина + DrawningAirbus _plane = null; + + //конструктор + public FormPlaneConfig() + { + 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; + } + + private void DrawPlane() + { + Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); + Graphics gr = Graphics.FromImage(bmp); + _plane?.SetPosition(5, 5, pictureBoxObject.Width, pictureBoxObject.Height); + _plane?.DrawTransport(gr); + pictureBoxObject.Image = bmp; + } + + 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": + _plane = new DrawningAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White); + break; + case "labelModifiedObject": + _plane = new DrawningSuperAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, + checkBoxAddСompartment.Checked, checkBoxAddEngine.Checked); + break; + } + + DrawPlane(); + } + + //отправляем цвет с панели + private void PanelColor_MouseDown(object sender, MouseEventArgs e) + { + (sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy); + } + + //проверка получаемой информации (её типа на соответсвие требуемому) + private void LabelBaseColor_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) + { + //TODO Call method from object _plane and set Color + } + + //принимаем дополнительный цвет + private void labelAddColor_DragDrop(object sender, DragEventArgs e) + { + //TODO Call method from object _plane is DrawningSuperAirbus and set add color + } + + } +} diff --git a/Airbus/Airbus/FormPlaneConfig.resx b/Airbus/Airbus/FormPlaneConfig.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Airbus/Airbus/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 -- 2.25.1 From 18aa8f88dcb20a65ce26082899671fc7c9429802 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Thu, 20 Oct 2022 11:35:08 +0400 Subject: [PATCH 02/11] Event. --- Airbus/Airbus/FormMapWithSetPlanes.cs | 26 ++++++++++++++------- Airbus/Airbus/FormPlaneConfig.Designer.cs | 2 ++ Airbus/Airbus/FormPlaneConfig.cs | 28 +++++++++++++++++++++++ Airbus/Airbus/PlaneDelegate.cs | 5 ++++ 4 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 Airbus/Airbus/PlaneDelegate.cs diff --git a/Airbus/Airbus/FormMapWithSetPlanes.cs b/Airbus/Airbus/FormMapWithSetPlanes.cs index b411b67..69dc45f 100644 --- a/Airbus/Airbus/FormMapWithSetPlanes.cs +++ b/Airbus/Airbus/FormMapWithSetPlanes.cs @@ -103,18 +103,27 @@ namespace Airbus //добавление объекта private void ButtonAddPlane_Click(object sender, EventArgs e) { - if(_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty] == null) + var formPlaneConfig = new FormPlaneConfig(); + + //TODO Call method AvvEvent from formPlaneConfig + + formPlaneConfig.Show(); + + ////////////// ЭТО + /*if(_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty] == null) { return; - } - - Form1 form = new(); + }*/ + ////////////// + + /*Form1 form = new(); if(form.ShowDialog() == DialogResult.OK) { - DrawningObjectPlane plane = new(form.SelectedPlane); + DrawningObjectPlane plane = new(form.SelectedPlane);*/ - if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty] + plane != -1) + /////////////////// И ЭТО В ОТДЕЛЬНЫЙ МЕТОД + /*if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty] + plane != -1) { MessageBox.Show("Объект добавлен"); pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty].ShowSet(); @@ -122,8 +131,9 @@ namespace Airbus else { MessageBox.Show("Не удалось добавить объект"); - } - } + }*/ + ////////////////// + //} } //удаление объекта diff --git a/Airbus/Airbus/FormPlaneConfig.Designer.cs b/Airbus/Airbus/FormPlaneConfig.Designer.cs index 9d8717e..7dd58f1 100644 --- a/Airbus/Airbus/FormPlaneConfig.Designer.cs +++ b/Airbus/Airbus/FormPlaneConfig.Designer.cs @@ -305,6 +305,7 @@ this.buttonAddObject.TabIndex = 3; this.buttonAddObject.Text = "Добавить"; this.buttonAddObject.UseVisualStyleBackColor = true; + this.buttonAddObject.Click += new System.EventHandler(this.ButtonAddObject_Click); // // buttonCancel // @@ -314,6 +315,7 @@ this.buttonCancel.TabIndex = 4; this.buttonCancel.Text = "Отмена"; this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); // // FormPlaneConfig // diff --git a/Airbus/Airbus/FormPlaneConfig.cs b/Airbus/Airbus/FormPlaneConfig.cs index 782f697..0ddae29 100644 --- a/Airbus/Airbus/FormPlaneConfig.cs +++ b/Airbus/Airbus/FormPlaneConfig.cs @@ -15,6 +15,9 @@ namespace Airbus //переменная-выбранная машина DrawningAirbus _plane = null; + //событие + private event PlaneDelegate EventAddPlane; + //конструктор public FormPlaneConfig() { @@ -29,6 +32,7 @@ namespace Airbus panelBlue.MouseDown += PanelColor_MouseDown; } + //отрисовка самолёт private void DrawPlane() { Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height); @@ -38,6 +42,19 @@ namespace Airbus pictureBoxObject.Image = bmp; } + //добавление события + public void AddEvent(PlaneDelegate ev) + { + if(EventAddPlane == null) + { + EventAddPlane = new PlaneDelegate(ev); + } + else + { + EventAddPlane += ev; + } + } + private void LabelObject_MouseDown(object sender, MouseEventArgs e) { (sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy); @@ -104,5 +121,16 @@ namespace Airbus //TODO Call method from object _plane is DrawningSuperAirbus and set add color } + //добавление машины + private void ButtonAddObject_Click(object sender, EventArgs e) + { + EventAddPlane?.Invoke(_plane); + Close(); + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + Close(); + } } } diff --git a/Airbus/Airbus/PlaneDelegate.cs b/Airbus/Airbus/PlaneDelegate.cs new file mode 100644 index 0000000..1ceb27d --- /dev/null +++ b/Airbus/Airbus/PlaneDelegate.cs @@ -0,0 +1,5 @@ +namespace Airbus +{ + //делегат для передачи объекта-самолёта + public delegate void PlaneDelegate(DrawningAirbus plane); +} -- 2.25.1 From 3d5347983a3337f2aa730e64adff04d03ccefe34 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Thu, 20 Oct 2022 16:27:38 +0400 Subject: [PATCH 03/11] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE?= =?UTF-8?q?=D0=B9=D0=BA=D0=B0=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20?= =?UTF-8?q?=D1=86=D0=B2=D0=B5=D1=82=D0=BE=D0=B2=20=D0=BD=D0=B0=20=D0=BF?= =?UTF-8?q?=D0=B0=D0=BD=D0=B5=D0=BB=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus/Airbus/FormMapWithSetPlanes.cs | 8 +- Airbus/Airbus/FormPlaneConfig.Designer.cs | 21 ++++- Airbus/Airbus/FormPlaneConfig.cs | 102 ++++++++++++++++++---- 3 files changed, 109 insertions(+), 22 deletions(-) diff --git a/Airbus/Airbus/FormMapWithSetPlanes.cs b/Airbus/Airbus/FormMapWithSetPlanes.cs index 69dc45f..6e5c46f 100644 --- a/Airbus/Airbus/FormMapWithSetPlanes.cs +++ b/Airbus/Airbus/FormMapWithSetPlanes.cs @@ -105,16 +105,15 @@ namespace Airbus { var formPlaneConfig = new FormPlaneConfig(); - //TODO Call method AvvEvent from formPlaneConfig + //TODO Call method AddEvent from formPlaneConfig formPlaneConfig.Show(); - ////////////// ЭТО + // ЭТО /*if(_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty] == null) { return; }*/ - ////////////// /*Form1 form = new(); @@ -122,7 +121,7 @@ namespace Airbus { DrawningObjectPlane plane = new(form.SelectedPlane);*/ - /////////////////// И ЭТО В ОТДЕЛЬНЫЙ МЕТОД + // И ЭТО В ОТДЕЛЬНЫЙ МЕТОД /*if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty] + plane != -1) { MessageBox.Show("Объект добавлен"); @@ -132,7 +131,6 @@ namespace Airbus { MessageBox.Show("Не удалось добавить объект"); }*/ - ////////////////// //} } diff --git a/Airbus/Airbus/FormPlaneConfig.Designer.cs b/Airbus/Airbus/FormPlaneConfig.Designer.cs index 7dd58f1..bb0cb06 100644 --- a/Airbus/Airbus/FormPlaneConfig.Designer.cs +++ b/Airbus/Airbus/FormPlaneConfig.Designer.cs @@ -120,6 +120,7 @@ // panelWhite // this.panelWhite.BackColor = System.Drawing.Color.White; + this.panelWhite.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panelWhite.Location = new System.Drawing.Point(6, 79); this.panelWhite.Name = "panelWhite"; this.panelWhite.Size = new System.Drawing.Size(40, 40); @@ -129,6 +130,7 @@ // panelGray // this.panelGray.BackColor = System.Drawing.Color.Gray; + this.panelGray.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panelGray.Location = new System.Drawing.Point(67, 79); this.panelGray.Name = "panelGray"; this.panelGray.Size = new System.Drawing.Size(40, 40); @@ -138,6 +140,7 @@ // panelBlack // this.panelBlack.BackColor = System.Drawing.Color.Black; + this.panelBlack.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panelBlack.Location = new System.Drawing.Point(130, 79); this.panelBlack.Name = "panelBlack"; this.panelBlack.Size = new System.Drawing.Size(40, 40); @@ -147,6 +150,7 @@ // panelPurple // this.panelPurple.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(192))))); + this.panelPurple.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panelPurple.Location = new System.Drawing.Point(192, 79); this.panelPurple.Name = "panelPurple"; this.panelPurple.Size = new System.Drawing.Size(40, 40); @@ -156,6 +160,7 @@ // panelYellow // this.panelYellow.BackColor = System.Drawing.Color.Yellow; + this.panelYellow.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panelYellow.Location = new System.Drawing.Point(192, 26); this.panelYellow.Name = "panelYellow"; this.panelYellow.Size = new System.Drawing.Size(40, 40); @@ -165,6 +170,7 @@ // panelBlue // this.panelBlue.BackColor = System.Drawing.Color.Blue; + this.panelBlue.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panelBlue.Location = new System.Drawing.Point(130, 26); this.panelBlue.Name = "panelBlue"; this.panelBlue.Size = new System.Drawing.Size(40, 40); @@ -174,6 +180,7 @@ // panelGreen // this.panelGreen.BackColor = System.Drawing.Color.Lime; + this.panelGreen.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panelGreen.Location = new System.Drawing.Point(67, 26); this.panelGreen.Name = "panelGreen"; this.panelGreen.Size = new System.Drawing.Size(40, 40); @@ -183,6 +190,7 @@ // panelRed // this.panelRed.BackColor = System.Drawing.Color.Red; + this.panelRed.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panelRed.Location = new System.Drawing.Point(6, 26); this.panelRed.Name = "panelRed"; this.panelRed.Size = new System.Drawing.Size(40, 40); @@ -212,6 +220,11 @@ // numericUpDownWeight // this.numericUpDownWeight.Location = new System.Drawing.Point(114, 97); + this.numericUpDownWeight.Maximum = new decimal(new int[] { + 10000, + 0, + 0, + 0}); this.numericUpDownWeight.Name = "numericUpDownWeight"; this.numericUpDownWeight.Size = new System.Drawing.Size(103, 27); this.numericUpDownWeight.TabIndex = 3; @@ -233,6 +246,11 @@ // numericUpDownSpeed // this.numericUpDownSpeed.Location = new System.Drawing.Point(114, 37); + this.numericUpDownSpeed.Maximum = new decimal(new int[] { + 2000, + 0, + 0, + 0}); this.numericUpDownSpeed.Name = "numericUpDownSpeed"; this.numericUpDownSpeed.Size = new System.Drawing.Size(103, 27); this.numericUpDownSpeed.TabIndex = 1; @@ -282,7 +300,8 @@ this.labelAddColor.TabIndex = 3; this.labelAddColor.Text = "Доп. цвет"; this.labelAddColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.labelAddColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelAddColor_DragDrop); + this.labelAddColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelAddColor_DragDrop); + this.labelAddColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelAddColor_DragEnter); // // labelBaseColor // diff --git a/Airbus/Airbus/FormPlaneConfig.cs b/Airbus/Airbus/FormPlaneConfig.cs index 0ddae29..5fdce60 100644 --- a/Airbus/Airbus/FormPlaneConfig.cs +++ b/Airbus/Airbus/FormPlaneConfig.cs @@ -55,6 +55,7 @@ namespace Airbus } } + //передаем информацию при нажатии на Label private void LabelObject_MouseDown(object sender, MouseEventArgs e) { (sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy); @@ -79,10 +80,10 @@ namespace Airbus switch (e.Data.GetData(DataFormats.Text).ToString()) { case "labelSimpleObject": - _plane = new DrawningAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White); + _plane = new DrawningAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelBaseColor.BackColor); break; case "labelModifiedObject": - _plane = new DrawningSuperAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, + _plane = new DrawningSuperAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelBaseColor.BackColor, labelAddColor.BackColor, checkBoxAddСompartment.Checked, checkBoxAddEngine.Checked); break; } @@ -93,32 +94,101 @@ namespace Airbus //отправляем цвет с панели private void PanelColor_MouseDown(object sender, MouseEventArgs e) { - (sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy); + (sender as Control).DoDragDrop((sender as Control).Name, DragDropEffects.Move | DragDropEffects.Copy); } //проверка получаемой информации (её типа на соответсвие требуемому) private void LabelBaseColor_DragEnter(object sender, DragEventArgs e) - { - if (e.Data.GetDataPresent(typeof(Color))) - { - e.Effect = DragDropEffects.Copy; - } - else - { - e.Effect = DragDropEffects.None; - } - } + { + if (e.Data.GetDataPresent(DataFormats.Text)) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } //принимаем основной цвет private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) { - //TODO Call method from object _plane and set Color + switch (e.Data.GetData(DataFormats.Text).ToString()) + { + case "panelRed": + labelBaseColor.BackColor = Color.Red; + break; + case "panelBlack": + labelBaseColor.BackColor = Color.Black; + break; + case "panelGreen": + labelBaseColor.BackColor = Color.Green; + break; + case "panelBlue": + labelBaseColor.BackColor = Color.Blue; + break; + case "panelYellow": + labelBaseColor.BackColor = Color.Yellow; + break; + case "panelPurple": + labelBaseColor.BackColor = Color.Purple; + break; + case "panelWhite": + labelBaseColor.BackColor = Color.White; + break; + case "panelGray": + labelBaseColor.BackColor = Color.DarkGray; + break; + } + + DrawPlane(); + } + + //проверка получаемой информации (её типа на соответсвие требуемому) + private void LabelAddColor_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.Text)) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } } //принимаем дополнительный цвет - private void labelAddColor_DragDrop(object sender, DragEventArgs e) + private void LabelAddColor_DragDrop(object sender, DragEventArgs e) { - //TODO Call method from object _plane is DrawningSuperAirbus and set add color + switch (e.Data.GetData(DataFormats.Text).ToString()) + { + case "panelRed": + labelAddColor.BackColor = Color.Red; + break; + case "panelBlack": + labelAddColor.BackColor = Color.Black; + break; + case "panelGreen": + labelAddColor.BackColor = Color.Green; + break; + case "panelBlue": + labelAddColor.BackColor = Color.Blue; + break; + case "panelYellow": + labelAddColor.BackColor = Color.Yellow; + break; + case "panelPurple": + labelAddColor.BackColor = Color.Purple; + break; + case "panelWhite": + labelAddColor.BackColor = Color.White; + break; + case "panelGray": + labelAddColor.BackColor = Color.DarkGray; + break; + } + + DrawPlane(); } //добавление машины -- 2.25.1 From 678d7108c8f7c687064fa09c8f7fea88bfd31035 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Thu, 20 Oct 2022 16:28:19 +0400 Subject: [PATCH 04/11] =?UTF-8?q?Revert=20"=D0=9D=D0=B0=D1=81=D1=82=D1=80?= =?UTF-8?q?=D0=BE=D0=B9=D0=BA=D0=B0=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B?= =?UTF-8?q?=20=D1=86=D0=B2=D0=B5=D1=82=D0=BE=D0=B2=20=D0=BD=D0=B0=20=D0=BF?= =?UTF-8?q?=D0=B0=D0=BD=D0=B5=D0=BB=D0=B8."?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 3d5347983a3337f2aa730e64adff04d03ccefe34. --- Airbus/Airbus/FormMapWithSetPlanes.cs | 8 +- Airbus/Airbus/FormPlaneConfig.Designer.cs | 21 +---- Airbus/Airbus/FormPlaneConfig.cs | 102 ++++------------------ 3 files changed, 22 insertions(+), 109 deletions(-) diff --git a/Airbus/Airbus/FormMapWithSetPlanes.cs b/Airbus/Airbus/FormMapWithSetPlanes.cs index 6e5c46f..69dc45f 100644 --- a/Airbus/Airbus/FormMapWithSetPlanes.cs +++ b/Airbus/Airbus/FormMapWithSetPlanes.cs @@ -105,15 +105,16 @@ namespace Airbus { var formPlaneConfig = new FormPlaneConfig(); - //TODO Call method AddEvent from formPlaneConfig + //TODO Call method AvvEvent from formPlaneConfig formPlaneConfig.Show(); - // ЭТО + ////////////// ЭТО /*if(_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty] == null) { return; }*/ + ////////////// /*Form1 form = new(); @@ -121,7 +122,7 @@ namespace Airbus { DrawningObjectPlane plane = new(form.SelectedPlane);*/ - // И ЭТО В ОТДЕЛЬНЫЙ МЕТОД + /////////////////// И ЭТО В ОТДЕЛЬНЫЙ МЕТОД /*if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty] + plane != -1) { MessageBox.Show("Объект добавлен"); @@ -131,6 +132,7 @@ namespace Airbus { MessageBox.Show("Не удалось добавить объект"); }*/ + ////////////////// //} } diff --git a/Airbus/Airbus/FormPlaneConfig.Designer.cs b/Airbus/Airbus/FormPlaneConfig.Designer.cs index bb0cb06..7dd58f1 100644 --- a/Airbus/Airbus/FormPlaneConfig.Designer.cs +++ b/Airbus/Airbus/FormPlaneConfig.Designer.cs @@ -120,7 +120,6 @@ // panelWhite // this.panelWhite.BackColor = System.Drawing.Color.White; - this.panelWhite.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panelWhite.Location = new System.Drawing.Point(6, 79); this.panelWhite.Name = "panelWhite"; this.panelWhite.Size = new System.Drawing.Size(40, 40); @@ -130,7 +129,6 @@ // panelGray // this.panelGray.BackColor = System.Drawing.Color.Gray; - this.panelGray.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panelGray.Location = new System.Drawing.Point(67, 79); this.panelGray.Name = "panelGray"; this.panelGray.Size = new System.Drawing.Size(40, 40); @@ -140,7 +138,6 @@ // panelBlack // this.panelBlack.BackColor = System.Drawing.Color.Black; - this.panelBlack.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panelBlack.Location = new System.Drawing.Point(130, 79); this.panelBlack.Name = "panelBlack"; this.panelBlack.Size = new System.Drawing.Size(40, 40); @@ -150,7 +147,6 @@ // panelPurple // this.panelPurple.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(192))))); - this.panelPurple.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panelPurple.Location = new System.Drawing.Point(192, 79); this.panelPurple.Name = "panelPurple"; this.panelPurple.Size = new System.Drawing.Size(40, 40); @@ -160,7 +156,6 @@ // panelYellow // this.panelYellow.BackColor = System.Drawing.Color.Yellow; - this.panelYellow.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panelYellow.Location = new System.Drawing.Point(192, 26); this.panelYellow.Name = "panelYellow"; this.panelYellow.Size = new System.Drawing.Size(40, 40); @@ -170,7 +165,6 @@ // panelBlue // this.panelBlue.BackColor = System.Drawing.Color.Blue; - this.panelBlue.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panelBlue.Location = new System.Drawing.Point(130, 26); this.panelBlue.Name = "panelBlue"; this.panelBlue.Size = new System.Drawing.Size(40, 40); @@ -180,7 +174,6 @@ // panelGreen // this.panelGreen.BackColor = System.Drawing.Color.Lime; - this.panelGreen.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panelGreen.Location = new System.Drawing.Point(67, 26); this.panelGreen.Name = "panelGreen"; this.panelGreen.Size = new System.Drawing.Size(40, 40); @@ -190,7 +183,6 @@ // panelRed // this.panelRed.BackColor = System.Drawing.Color.Red; - this.panelRed.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panelRed.Location = new System.Drawing.Point(6, 26); this.panelRed.Name = "panelRed"; this.panelRed.Size = new System.Drawing.Size(40, 40); @@ -220,11 +212,6 @@ // numericUpDownWeight // this.numericUpDownWeight.Location = new System.Drawing.Point(114, 97); - this.numericUpDownWeight.Maximum = new decimal(new int[] { - 10000, - 0, - 0, - 0}); this.numericUpDownWeight.Name = "numericUpDownWeight"; this.numericUpDownWeight.Size = new System.Drawing.Size(103, 27); this.numericUpDownWeight.TabIndex = 3; @@ -246,11 +233,6 @@ // numericUpDownSpeed // this.numericUpDownSpeed.Location = new System.Drawing.Point(114, 37); - this.numericUpDownSpeed.Maximum = new decimal(new int[] { - 2000, - 0, - 0, - 0}); this.numericUpDownSpeed.Name = "numericUpDownSpeed"; this.numericUpDownSpeed.Size = new System.Drawing.Size(103, 27); this.numericUpDownSpeed.TabIndex = 1; @@ -300,8 +282,7 @@ this.labelAddColor.TabIndex = 3; this.labelAddColor.Text = "Доп. цвет"; this.labelAddColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.labelAddColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelAddColor_DragDrop); - this.labelAddColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelAddColor_DragEnter); + this.labelAddColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelAddColor_DragDrop); // // labelBaseColor // diff --git a/Airbus/Airbus/FormPlaneConfig.cs b/Airbus/Airbus/FormPlaneConfig.cs index 5fdce60..0ddae29 100644 --- a/Airbus/Airbus/FormPlaneConfig.cs +++ b/Airbus/Airbus/FormPlaneConfig.cs @@ -55,7 +55,6 @@ namespace Airbus } } - //передаем информацию при нажатии на Label private void LabelObject_MouseDown(object sender, MouseEventArgs e) { (sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy); @@ -80,10 +79,10 @@ namespace Airbus switch (e.Data.GetData(DataFormats.Text).ToString()) { case "labelSimpleObject": - _plane = new DrawningAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelBaseColor.BackColor); + _plane = new DrawningAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White); break; case "labelModifiedObject": - _plane = new DrawningSuperAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelBaseColor.BackColor, labelAddColor.BackColor, + _plane = new DrawningSuperAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxAddСompartment.Checked, checkBoxAddEngine.Checked); break; } @@ -94,101 +93,32 @@ namespace Airbus //отправляем цвет с панели private void PanelColor_MouseDown(object sender, MouseEventArgs e) { - (sender as Control).DoDragDrop((sender as Control).Name, DragDropEffects.Move | DragDropEffects.Copy); + (sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy); } //проверка получаемой информации (её типа на соответсвие требуемому) private void LabelBaseColor_DragEnter(object sender, DragEventArgs e) - { - if (e.Data.GetDataPresent(DataFormats.Text)) - { - e.Effect = DragDropEffects.Copy; - } - else - { - e.Effect = DragDropEffects.None; - } - } + { + if (e.Data.GetDataPresent(typeof(Color))) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } //принимаем основной цвет private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) { - switch (e.Data.GetData(DataFormats.Text).ToString()) - { - case "panelRed": - labelBaseColor.BackColor = Color.Red; - break; - case "panelBlack": - labelBaseColor.BackColor = Color.Black; - break; - case "panelGreen": - labelBaseColor.BackColor = Color.Green; - break; - case "panelBlue": - labelBaseColor.BackColor = Color.Blue; - break; - case "panelYellow": - labelBaseColor.BackColor = Color.Yellow; - break; - case "panelPurple": - labelBaseColor.BackColor = Color.Purple; - break; - case "panelWhite": - labelBaseColor.BackColor = Color.White; - break; - case "panelGray": - labelBaseColor.BackColor = Color.DarkGray; - break; - } - - DrawPlane(); - } - - //проверка получаемой информации (её типа на соответсвие требуемому) - private void LabelAddColor_DragEnter(object sender, DragEventArgs e) - { - if (e.Data.GetDataPresent(DataFormats.Text)) - { - e.Effect = DragDropEffects.Copy; - } - else - { - e.Effect = DragDropEffects.None; - } + //TODO Call method from object _plane and set Color } //принимаем дополнительный цвет - private void LabelAddColor_DragDrop(object sender, DragEventArgs e) + private void labelAddColor_DragDrop(object sender, DragEventArgs e) { - switch (e.Data.GetData(DataFormats.Text).ToString()) - { - case "panelRed": - labelAddColor.BackColor = Color.Red; - break; - case "panelBlack": - labelAddColor.BackColor = Color.Black; - break; - case "panelGreen": - labelAddColor.BackColor = Color.Green; - break; - case "panelBlue": - labelAddColor.BackColor = Color.Blue; - break; - case "panelYellow": - labelAddColor.BackColor = Color.Yellow; - break; - case "panelPurple": - labelAddColor.BackColor = Color.Purple; - break; - case "panelWhite": - labelAddColor.BackColor = Color.White; - break; - case "panelGray": - labelAddColor.BackColor = Color.DarkGray; - break; - } - - DrawPlane(); + //TODO Call method from object _plane is DrawningSuperAirbus and set add color } //добавление машины -- 2.25.1 From 969ab084ec186a2fa2a348eae8671852a20edab3 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Thu, 20 Oct 2022 16:39:22 +0400 Subject: [PATCH 05/11] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE?= =?UTF-8?q?=D0=B9=D0=BA=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B0=D1=87?= =?UTF-8?q?=D0=B8=20=D1=86=D0=B2=D0=B5=D1=82=D0=BE=D0=B2=20=D0=B2=20FormPl?= =?UTF-8?q?aneConfig.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus/Airbus/FormPlaneConfig.Designer.cs | 1 + Airbus/Airbus/FormPlaneConfig.cs | 98 +++++++++++++++++++---- 2 files changed, 84 insertions(+), 15 deletions(-) diff --git a/Airbus/Airbus/FormPlaneConfig.Designer.cs b/Airbus/Airbus/FormPlaneConfig.Designer.cs index 7dd58f1..9afa622 100644 --- a/Airbus/Airbus/FormPlaneConfig.Designer.cs +++ b/Airbus/Airbus/FormPlaneConfig.Designer.cs @@ -283,6 +283,7 @@ this.labelAddColor.Text = "Доп. цвет"; this.labelAddColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.labelAddColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelAddColor_DragDrop); + this.labelAddColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelAddColor_DragEnter); // // labelBaseColor // diff --git a/Airbus/Airbus/FormPlaneConfig.cs b/Airbus/Airbus/FormPlaneConfig.cs index 0ddae29..e614095 100644 --- a/Airbus/Airbus/FormPlaneConfig.cs +++ b/Airbus/Airbus/FormPlaneConfig.cs @@ -79,10 +79,10 @@ namespace Airbus switch (e.Data.GetData(DataFormats.Text).ToString()) { case "labelSimpleObject": - _plane = new DrawningAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White); + _plane = new DrawningAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelBaseColor.BackColor); break; case "labelModifiedObject": - _plane = new DrawningSuperAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, + _plane = new DrawningSuperAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelBaseColor.BackColor, labelAddColor.BackColor, checkBoxAddСompartment.Checked, checkBoxAddEngine.Checked); break; } @@ -93,32 +93,97 @@ namespace Airbus //отправляем цвет с панели private void PanelColor_MouseDown(object sender, MouseEventArgs e) { - (sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy); + (sender as Control).DoDragDrop((sender as Control).Name, DragDropEffects.Move | DragDropEffects.Copy); } //проверка получаемой информации (её типа на соответсвие требуемому) private void LabelBaseColor_DragEnter(object sender, DragEventArgs e) - { - if (e.Data.GetDataPresent(typeof(Color))) - { - e.Effect = DragDropEffects.Copy; - } - else - { - e.Effect = DragDropEffects.None; - } - } + { + if (e.Data.GetDataPresent(DataFormats.Text)) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } //принимаем основной цвет private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) { - //TODO Call method from object _plane and set Color + switch (e.Data.GetData(DataFormats.Text).ToString()) + { + case "panelRed": + labelBaseColor.BackColor = Color.Red; + break; + case "panelBlack": + labelBaseColor.BackColor = Color.Black; + break; + case "panelGreen": + labelBaseColor.BackColor = Color.Green; + break; + case "panelYellow": + labelBaseColor.BackColor = Color.Yellow; + break; + case "panelBlue": + labelBaseColor.BackColor = Color.Blue; + break; + case "panelPurple": + labelBaseColor.BackColor = Color.Purple; + break; + case "panelGray": + labelBaseColor.BackColor = Color.DarkGray; + break; + case "panelWhite": + labelBaseColor.BackColor = Color.White; + break; + } + } + + //проверка получаемой информации (её типа на соответсвие требуемому) + private void LabelAddColor_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.Text)) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } } //принимаем дополнительный цвет private void labelAddColor_DragDrop(object sender, DragEventArgs e) { - //TODO Call method from object _plane is DrawningSuperAirbus and set add color + switch (e.Data.GetData(DataFormats.Text).ToString()) + { + case "panelRed": + labelAddColor.BackColor = Color.Red; + break; + case "panelBlack": + labelAddColor.BackColor = Color.Black; + break; + case "panelGreen": + labelAddColor.BackColor = Color.Green; + break; + case "panelYellow": + labelAddColor.BackColor = Color.Yellow; + break; + case "panelBlue": + labelAddColor.BackColor = Color.Blue; + break; + case "panelPurple": + labelAddColor.BackColor = Color.Purple; + break; + case "panelGray": + labelAddColor.BackColor = Color.DarkGray; + break; + case "panelWhite": + labelAddColor.BackColor = Color.White; + break; + } } //добавление машины @@ -128,9 +193,12 @@ namespace Airbus Close(); } + //закрытие формы конфигурации private void ButtonCancel_Click(object sender, EventArgs e) { Close(); } + + } } -- 2.25.1 From 7b57c35b71bb972dd8494e20b8ef801c4ddfa237 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Mon, 24 Oct 2022 22:11:35 +0400 Subject: [PATCH 06/11] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=B0?= =?UTF-8?q?=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA=D1=82=D0=BE=D0=B2=20=D0=B2=20?= =?UTF-8?q?=D1=85=D1=80=D0=B0=D0=BD=D0=B8=D0=BB=D0=B8=D1=89=D0=B5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus/Airbus/FormMapWithSetPlanes.cs | 47 +++++++++++---------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/Airbus/Airbus/FormMapWithSetPlanes.cs b/Airbus/Airbus/FormMapWithSetPlanes.cs index 69dc45f..84dfb58 100644 --- a/Airbus/Airbus/FormMapWithSetPlanes.cs +++ b/Airbus/Airbus/FormMapWithSetPlanes.cs @@ -100,40 +100,31 @@ namespace Airbus } } + private void AddPlane(DrawningAirbus plane) + { + if (listBoxMaps.SelectedIndex == -1) + { + return; + } + if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawningObjectPlane(plane) != -1) + { + MessageBox.Show("Объект добавлен"); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + + } + //добавление объекта private void ButtonAddPlane_Click(object sender, EventArgs e) { var formPlaneConfig = new FormPlaneConfig(); - //TODO Call method AvvEvent from formPlaneConfig - + formPlaneConfig.AddEvent(AddPlane); formPlaneConfig.Show(); - - ////////////// ЭТО - /*if(_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty] == null) - { - return; - }*/ - ////////////// - - /*Form1 form = new(); - - if(form.ShowDialog() == DialogResult.OK) - { - DrawningObjectPlane plane = new(form.SelectedPlane);*/ - - /////////////////// И ЭТО В ОТДЕЛЬНЫЙ МЕТОД - /*if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty] + plane != -1) - { - MessageBox.Show("Объект добавлен"); - pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? String.Empty].ShowSet(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - }*/ - ////////////////// - //} } //удаление объекта -- 2.25.1 From a740b44232fba116a9e5247d86e986945a65f95b Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Tue, 25 Oct 2022 14:49:52 +0400 Subject: [PATCH 07/11] =?UTF-8?q?=D0=98=D1=82=D0=BE=D0=B3=D0=BE=D0=B2?= =?UTF-8?q?=D1=8B=D0=B5=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus/Airbus/EntityAirbus.cs | 2 +- Airbus/Airbus/EntitySuperAirbus.cs | 2 +- Airbus/Airbus/FormPlaneConfig.Designer.cs | 1 - Airbus/Airbus/FormPlaneConfig.cs | 90 +++++++---------------- 4 files changed, 28 insertions(+), 67 deletions(-) diff --git a/Airbus/Airbus/EntityAirbus.cs b/Airbus/Airbus/EntityAirbus.cs index 3b63b0d..fda3f48 100644 --- a/Airbus/Airbus/EntityAirbus.cs +++ b/Airbus/Airbus/EntityAirbus.cs @@ -13,7 +13,7 @@ namespace Airbus public float Weight { get; private set; } //вес - public Color CorpusColor { get; private set; } //цвет корпуса + public Color CorpusColor { get; set; } //цвет корпуса public float Step => Speed * 100 / Weight; //шаг перемещения самолёта diff --git a/Airbus/Airbus/EntitySuperAirbus.cs b/Airbus/Airbus/EntitySuperAirbus.cs index 264d36d..dc9d9d7 100644 --- a/Airbus/Airbus/EntitySuperAirbus.cs +++ b/Airbus/Airbus/EntitySuperAirbus.cs @@ -10,7 +10,7 @@ namespace Airbus internal class EntitySuperAirbus : EntityAirbus { //Дополнительный цвет - public Color AddColor { get; private set; } + public Color AddColor { get; set; } //Признак наличия дополнительно пассажирского отсека public bool AddСompartment { get; private set; } diff --git a/Airbus/Airbus/FormPlaneConfig.Designer.cs b/Airbus/Airbus/FormPlaneConfig.Designer.cs index 9afa622..d38013e 100644 --- a/Airbus/Airbus/FormPlaneConfig.Designer.cs +++ b/Airbus/Airbus/FormPlaneConfig.Designer.cs @@ -316,7 +316,6 @@ this.buttonCancel.TabIndex = 4; this.buttonCancel.Text = "Отмена"; this.buttonCancel.UseVisualStyleBackColor = true; - this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); // // FormPlaneConfig // diff --git a/Airbus/Airbus/FormPlaneConfig.cs b/Airbus/Airbus/FormPlaneConfig.cs index e614095..e011714 100644 --- a/Airbus/Airbus/FormPlaneConfig.cs +++ b/Airbus/Airbus/FormPlaneConfig.cs @@ -30,6 +30,8 @@ namespace Airbus panelWhite.MouseDown += PanelColor_MouseDown; panelYellow.MouseDown += PanelColor_MouseDown; panelBlue.MouseDown += PanelColor_MouseDown; + + buttonCancel.Click += (object sender, EventArgs e) => Close(); } //отрисовка самолёт @@ -45,10 +47,10 @@ namespace Airbus //добавление события public void AddEvent(PlaneDelegate ev) { - if(EventAddPlane == null) + if (EventAddPlane == null) { EventAddPlane = new PlaneDelegate(ev); - } + } else { EventAddPlane += ev; @@ -82,7 +84,7 @@ namespace Airbus _plane = new DrawningAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelBaseColor.BackColor); break; case "labelModifiedObject": - _plane = new DrawningSuperAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelBaseColor.BackColor, labelAddColor.BackColor, + _plane = new DrawningSuperAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelBaseColor.BackColor, labelAddColor.BackColor, checkBoxAddСompartment.Checked, checkBoxAddEngine.Checked); break; } @@ -93,13 +95,13 @@ namespace Airbus //отправляем цвет с панели private void PanelColor_MouseDown(object sender, MouseEventArgs e) { - (sender as Control).DoDragDrop((sender as Control).Name, DragDropEffects.Move | DragDropEffects.Copy); + (sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy); } //проверка получаемой информации (её типа на соответсвие требуемому) private void LabelBaseColor_DragEnter(object sender, DragEventArgs e) { - if (e.Data.GetDataPresent(DataFormats.Text)) + if (e.Data.GetDataPresent(typeof(Color))) { e.Effect = DragDropEffects.Copy; } @@ -112,39 +114,20 @@ namespace Airbus //принимаем основной цвет private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) { - switch (e.Data.GetData(DataFormats.Text).ToString()) + if (_plane != null) { - case "panelRed": - labelBaseColor.BackColor = Color.Red; - break; - case "panelBlack": - labelBaseColor.BackColor = Color.Black; - break; - case "panelGreen": - labelBaseColor.BackColor = Color.Green; - break; - case "panelYellow": - labelBaseColor.BackColor = Color.Yellow; - break; - case "panelBlue": - labelBaseColor.BackColor = Color.Blue; - break; - case "panelPurple": - labelBaseColor.BackColor = Color.Purple; - break; - case "panelGray": - labelBaseColor.BackColor = Color.DarkGray; - break; - case "panelWhite": - labelBaseColor.BackColor = Color.White; - break; + if (e.Data.GetDataPresent(typeof(Color))) + { + _plane.Airbus.CorpusColor = (Color)e.Data.GetData(typeof(Color)); + } + DrawPlane(); } } //проверка получаемой информации (её типа на соответсвие требуемому) private void LabelAddColor_DragEnter(object sender, DragEventArgs e) { - if (e.Data.GetDataPresent(DataFormats.Text)) + if (e.Data.GetDataPresent(typeof(Color))) { e.Effect = DragDropEffects.Copy; } @@ -157,48 +140,27 @@ namespace Airbus //принимаем дополнительный цвет private void labelAddColor_DragDrop(object sender, DragEventArgs e) { - switch (e.Data.GetData(DataFormats.Text).ToString()) + if (_plane != null && _plane is DrawningSuperAirbus airbus) { - case "panelRed": - labelAddColor.BackColor = Color.Red; - break; - case "panelBlack": - labelAddColor.BackColor = Color.Black; - break; - case "panelGreen": - labelAddColor.BackColor = Color.Green; - break; - case "panelYellow": - labelAddColor.BackColor = Color.Yellow; - break; - case "panelBlue": - labelAddColor.BackColor = Color.Blue; - break; - case "panelPurple": - labelAddColor.BackColor = Color.Purple; - break; - case "panelGray": - labelAddColor.BackColor = Color.DarkGray; - break; - case "panelWhite": - labelAddColor.BackColor = Color.White; - break; + if (e.Data.GetDataPresent(typeof(Color))) + { + if (airbus.Airbus is EntitySuperAirbus entityAirbus) + { + entityAirbus.AddColor = (Color)e.Data.GetData(typeof(Color)); + } + } + DrawPlane(); } } + + + //добавление машины private void ButtonAddObject_Click(object sender, EventArgs e) { EventAddPlane?.Invoke(_plane); Close(); } - - //закрытие формы конфигурации - private void ButtonCancel_Click(object sender, EventArgs e) - { - Close(); - } - - } } -- 2.25.1 From 2d2c30de539a414b533ac214f8b49ef1bb95416a Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Wed, 2 Nov 2022 22:24:43 +0400 Subject: [PATCH 08/11] =?UTF-8?q?=D0=A4=D0=B8=D0=BD=D0=B0=D0=BB=D1=8C?= =?UTF-8?q?=D0=BD=D1=8B=D0=B5=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus/Airbus/FormMapWithSetPlanes.cs | 2 ++ Airbus/Airbus/FormPlaneConfig.Designer.cs | 16 +++++++++++++--- Airbus/Airbus/FormPlaneConfig.cs | 7 ++----- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Airbus/Airbus/FormMapWithSetPlanes.cs b/Airbus/Airbus/FormMapWithSetPlanes.cs index 84dfb58..e097b0f 100644 --- a/Airbus/Airbus/FormMapWithSetPlanes.cs +++ b/Airbus/Airbus/FormMapWithSetPlanes.cs @@ -24,6 +24,7 @@ namespace Airbus //объект от коллекции карт private readonly MapsCollection _mapsCollection; + //конструктор public FormMapWithSetPlanes() { InitializeComponent(); @@ -100,6 +101,7 @@ namespace Airbus } } + //отрисовка добавленного объекта в хранилище private void AddPlane(DrawningAirbus plane) { if (listBoxMaps.SelectedIndex == -1) diff --git a/Airbus/Airbus/FormPlaneConfig.Designer.cs b/Airbus/Airbus/FormPlaneConfig.Designer.cs index d38013e..c2b2ff0 100644 --- a/Airbus/Airbus/FormPlaneConfig.Designer.cs +++ b/Airbus/Airbus/FormPlaneConfig.Designer.cs @@ -212,11 +212,16 @@ // numericUpDownWeight // this.numericUpDownWeight.Location = new System.Drawing.Point(114, 97); + this.numericUpDownWeight.Maximum = new decimal(new int[] { + 1500, + 0, + 0, + 0}); this.numericUpDownWeight.Name = "numericUpDownWeight"; this.numericUpDownWeight.Size = new System.Drawing.Size(103, 27); this.numericUpDownWeight.TabIndex = 3; this.numericUpDownWeight.Value = new decimal(new int[] { - 100, + 750, 0, 0, 0}); @@ -233,11 +238,16 @@ // numericUpDownSpeed // this.numericUpDownSpeed.Location = new System.Drawing.Point(114, 37); + this.numericUpDownSpeed.Maximum = new decimal(new int[] { + 2000, + 0, + 0, + 0}); this.numericUpDownSpeed.Name = "numericUpDownSpeed"; this.numericUpDownSpeed.Size = new System.Drawing.Size(103, 27); this.numericUpDownSpeed.TabIndex = 1; this.numericUpDownSpeed.Value = new decimal(new int[] { - 100, + 1000, 0, 0, 0}); @@ -282,7 +292,7 @@ this.labelAddColor.TabIndex = 3; this.labelAddColor.Text = "Доп. цвет"; this.labelAddColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.labelAddColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelAddColor_DragDrop); + this.labelAddColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelAddColor_DragDrop); this.labelAddColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelAddColor_DragEnter); // // labelBaseColor diff --git a/Airbus/Airbus/FormPlaneConfig.cs b/Airbus/Airbus/FormPlaneConfig.cs index e011714..a26e523 100644 --- a/Airbus/Airbus/FormPlaneConfig.cs +++ b/Airbus/Airbus/FormPlaneConfig.cs @@ -12,7 +12,7 @@ namespace Airbus { public partial class FormPlaneConfig : Form { - //переменная-выбранная машина + //переменная-выбранный самолёт DrawningAirbus _plane = null; //событие @@ -138,7 +138,7 @@ namespace Airbus } //принимаем дополнительный цвет - private void labelAddColor_DragDrop(object sender, DragEventArgs e) + private void LabelAddColor_DragDrop(object sender, DragEventArgs e) { if (_plane != null && _plane is DrawningSuperAirbus airbus) { @@ -153,9 +153,6 @@ namespace Airbus } } - - - //добавление машины private void ButtonAddObject_Click(object sender, EventArgs e) { -- 2.25.1 From bc439e0a8745b6fb767105bce45670243c5afb44 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Wed, 2 Nov 2022 22:57:01 +0400 Subject: [PATCH 09/11] =?UTF-8?q?=D0=A2=D0=BE=D1=87=D0=BD=D0=BE=20=D1=84?= =?UTF-8?q?=D0=B8=D0=BD=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B=D0=B5=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BA=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus/Airbus/FormPlaneConfig.cs | 6 +++--- Airbus/Airbus/PlaneDelegate.cs | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) delete mode 100644 Airbus/Airbus/PlaneDelegate.cs diff --git a/Airbus/Airbus/FormPlaneConfig.cs b/Airbus/Airbus/FormPlaneConfig.cs index a26e523..2180561 100644 --- a/Airbus/Airbus/FormPlaneConfig.cs +++ b/Airbus/Airbus/FormPlaneConfig.cs @@ -16,7 +16,7 @@ namespace Airbus DrawningAirbus _plane = null; //событие - private event PlaneDelegate EventAddPlane; + private event Action EventAddPlane; //конструктор public FormPlaneConfig() @@ -45,11 +45,11 @@ namespace Airbus } //добавление события - public void AddEvent(PlaneDelegate ev) + public void AddEvent(Action ev) { if (EventAddPlane == null) { - EventAddPlane = new PlaneDelegate(ev); + EventAddPlane = new Action(ev); } else { diff --git a/Airbus/Airbus/PlaneDelegate.cs b/Airbus/Airbus/PlaneDelegate.cs deleted file mode 100644 index 1ceb27d..0000000 --- a/Airbus/Airbus/PlaneDelegate.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Airbus -{ - //делегат для передачи объекта-самолёта - public delegate void PlaneDelegate(DrawningAirbus plane); -} -- 2.25.1 From 5666738dbe0a0b6fb5e0e16de3cfec089504c93e Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Wed, 2 Nov 2022 23:02:33 +0400 Subject: [PATCH 10/11] =?UTF-8?q?=D0=A4=D0=B8=D0=BD=D0=B0=D0=BB=D1=8C?= =?UTF-8?q?=D0=BD=D1=8B=D0=B5=20=D1=84=D0=B8=D0=BD=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D1=8B=D0=B5=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus/Airbus/FormPlaneConfig.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Airbus/Airbus/FormPlaneConfig.cs b/Airbus/Airbus/FormPlaneConfig.cs index 2180561..57ee7bc 100644 --- a/Airbus/Airbus/FormPlaneConfig.cs +++ b/Airbus/Airbus/FormPlaneConfig.cs @@ -114,12 +114,14 @@ namespace Airbus //принимаем основной цвет private void LabelBaseColor_DragDrop(object sender, DragEventArgs e) { + //проверка на пустоту объекта if (_plane != null) { if (e.Data.GetDataPresent(typeof(Color))) { _plane.Airbus.CorpusColor = (Color)e.Data.GetData(typeof(Color)); } + DrawPlane(); } } @@ -140,6 +142,7 @@ namespace Airbus //принимаем дополнительный цвет private void LabelAddColor_DragDrop(object sender, DragEventArgs e) { + //проверка на пустоту объекта и правильную сущноть if (_plane != null && _plane is DrawningSuperAirbus airbus) { if (e.Data.GetDataPresent(typeof(Color))) @@ -149,6 +152,7 @@ namespace Airbus entityAirbus.AddColor = (Color)e.Data.GetData(typeof(Color)); } } + DrawPlane(); } } -- 2.25.1 From 8f4f105b75dd0aa5ad0eb50c9b38542a58931b70 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Thu, 3 Nov 2022 16:33:06 +0400 Subject: [PATCH 11/11] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BB=D0=B8=D1=88=D0=BD=D0=B8=D1=85=20=D1=84?= =?UTF-8?q?=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B9=20=D0=B8=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B5=D1=80=D0=BE=D0=BA.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus/Airbus/FormPlaneConfig.Designer.cs | 4 +-- Airbus/Airbus/FormPlaneConfig.cs | 30 +++-------------------- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/Airbus/Airbus/FormPlaneConfig.Designer.cs b/Airbus/Airbus/FormPlaneConfig.Designer.cs index c2b2ff0..a1a98b6 100644 --- a/Airbus/Airbus/FormPlaneConfig.Designer.cs +++ b/Airbus/Airbus/FormPlaneConfig.Designer.cs @@ -293,7 +293,7 @@ this.labelAddColor.Text = "Доп. цвет"; this.labelAddColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.labelAddColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelAddColor_DragDrop); - this.labelAddColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelAddColor_DragEnter); + this.labelAddColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter); // // labelBaseColor // @@ -306,7 +306,7 @@ 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.LabelBaseColor_DragEnter); + this.labelBaseColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter); // // buttonAddObject // diff --git a/Airbus/Airbus/FormPlaneConfig.cs b/Airbus/Airbus/FormPlaneConfig.cs index 57ee7bc..c5303de 100644 --- a/Airbus/Airbus/FormPlaneConfig.cs +++ b/Airbus/Airbus/FormPlaneConfig.cs @@ -99,7 +99,7 @@ namespace Airbus } //проверка получаемой информации (её типа на соответсвие требуемому) - private void LabelBaseColor_DragEnter(object sender, DragEventArgs e) + private void LabelColor_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(Color))) { @@ -117,41 +117,19 @@ namespace Airbus //проверка на пустоту объекта if (_plane != null) { - if (e.Data.GetDataPresent(typeof(Color))) - { - _plane.Airbus.CorpusColor = (Color)e.Data.GetData(typeof(Color)); - } + _plane.Airbus.CorpusColor = (Color)e.Data.GetData(typeof(Color)); DrawPlane(); } } - //проверка получаемой информации (её типа на соответсвие требуемому) - private void LabelAddColor_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 (_plane != null && _plane is DrawningSuperAirbus airbus) + if (_plane != null && _plane.Airbus is EntitySuperAirbus entityAirbus) { - if (e.Data.GetDataPresent(typeof(Color))) - { - if (airbus.Airbus is EntitySuperAirbus entityAirbus) - { - entityAirbus.AddColor = (Color)e.Data.GetData(typeof(Color)); - } - } + entityAirbus.AddColor = (Color)e.Data.GetData(typeof(Color)); DrawPlane(); } -- 2.25.1