laba 5
This commit is contained in:
parent
31f294023d
commit
45f44fe42f
@ -73,5 +73,9 @@ additionalColor, bool additionalEngine, bool additionalPassengerCompartment, int
|
||||
g.DrawLine(pen, _startPosX + 130, _startPosY + 15, _startPosX + 140, _startPosY + 30);
|
||||
}
|
||||
}
|
||||
public void SetAddColor(Color color)
|
||||
{
|
||||
((EntityAirbus)EntityAirplane).AdditionalColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -230,5 +230,19 @@ namespace Airbus_Base.DrawningObjects
|
||||
g.DrawLine(pen, _startPosX + 45, _startPosY + 100, _startPosX + 100, _startPosY + 60);
|
||||
g.FillEllipse(brBlack, _startPosX + 16, _startPosY + 27, 30, 6);
|
||||
}
|
||||
public void SetColor(Color color)
|
||||
{
|
||||
if (EntityAirplane == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
EntityAirplane.BodyColor = color;
|
||||
}
|
||||
|
||||
public void ChangePictureBoxSize(int pictureBoxWidth, int pictureBoxHeight)
|
||||
{
|
||||
_pictureWidth = pictureBoxWidth;
|
||||
_pictureHeight = pictureBoxHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace Airbus_Base.Entities
|
||||
/// <summary>
|
||||
/// Дополнительный цвет (для опциональных элементов)
|
||||
/// </summary>
|
||||
public Color AdditionalColor { get; private set; }
|
||||
public Color AdditionalColor { get; set; }
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия двигателей
|
||||
/// </summary>
|
||||
|
@ -22,7 +22,7 @@ namespace Airbus_Base.Entities
|
||||
/// <summary>
|
||||
/// Основной цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
public Color BodyColor { get; set; }
|
||||
/// <summary>
|
||||
/// Шаг перемещения самолёта
|
||||
/// </summary>
|
||||
|
2
Airbus_Base/FormAirplaneCollection.Designer.cs
generated
2
Airbus_Base/FormAirplaneCollection.Designer.cs
generated
@ -86,7 +86,7 @@
|
||||
this.listBoxObjects.Name = "listBoxObjects";
|
||||
this.listBoxObjects.Size = new System.Drawing.Size(190, 64);
|
||||
this.listBoxObjects.TabIndex = 11;
|
||||
this.listBoxObjects.Click += new System.EventHandler(this.listBoxObjects_SelectedIndexChanged);
|
||||
this.listBoxObjects.SelectedIndexChanged += new System.EventHandler(this.listBoxObjects_SelectedIndexChanged);
|
||||
//
|
||||
// ButtonAddObject
|
||||
//
|
||||
|
@ -119,19 +119,23 @@ namespace Airbus_Base
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormAirbus form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
FormAirplaneConfig form = new();
|
||||
form.Show();
|
||||
Action<DrawningAirplane>? airplaneDelegate = new((m) =>
|
||||
{
|
||||
if (obj + form.SelectedAirplane)
|
||||
bool isAdditionSuccessful = (obj + m);
|
||||
if (isAdditionSuccessful)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
m.ChangePictureBoxSize(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
pictureBoxCollection.Image = obj.ShowTheAirplanes();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
});
|
||||
form.AddEvent(airplaneDelegate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
379
Airbus_Base/FormAirplaneConfig.Designer.cs
generated
Normal file
379
Airbus_Base/FormAirplaneConfig.Designer.cs
generated
Normal file
@ -0,0 +1,379 @@
|
||||
namespace Airbus_Base
|
||||
{
|
||||
partial class FormAirplaneConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.groupBoxParameters = new System.Windows.Forms.GroupBox();
|
||||
this.labelModifiedObject = new System.Windows.Forms.Label();
|
||||
this.labelSimpleObject = new System.Windows.Forms.Label();
|
||||
this.groupBoxColor = new System.Windows.Forms.GroupBox();
|
||||
this.panelPurple = new System.Windows.Forms.Panel();
|
||||
this.panelBlack = new System.Windows.Forms.Panel();
|
||||
this.panelYellow = new System.Windows.Forms.Panel();
|
||||
this.panelGray = new System.Windows.Forms.Panel();
|
||||
this.panelBlue = new System.Windows.Forms.Panel();
|
||||
this.panelGreen = new System.Windows.Forms.Panel();
|
||||
this.panelWhite = new System.Windows.Forms.Panel();
|
||||
this.panelRed = new System.Windows.Forms.Panel();
|
||||
this.checkBoxPassengerCompartment = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoxEngine = new System.Windows.Forms.CheckBox();
|
||||
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
|
||||
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
|
||||
this.labelWeight = new System.Windows.Forms.Label();
|
||||
this.labelSpeed = new System.Windows.Forms.Label();
|
||||
this.panelObject = new System.Windows.Forms.Panel();
|
||||
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
|
||||
this.labelExtraColor = new System.Windows.Forms.Label();
|
||||
this.labelColor = new System.Windows.Forms.Label();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.groupBoxParameters.SuspendLayout();
|
||||
this.groupBoxColor.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
|
||||
this.panelObject.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBoxParameters
|
||||
//
|
||||
this.groupBoxParameters.Controls.Add(this.labelModifiedObject);
|
||||
this.groupBoxParameters.Controls.Add(this.labelSimpleObject);
|
||||
this.groupBoxParameters.Controls.Add(this.groupBoxColor);
|
||||
this.groupBoxParameters.Controls.Add(this.checkBoxPassengerCompartment);
|
||||
this.groupBoxParameters.Controls.Add(this.checkBoxEngine);
|
||||
this.groupBoxParameters.Controls.Add(this.numericUpDownWeight);
|
||||
this.groupBoxParameters.Controls.Add(this.numericUpDownSpeed);
|
||||
this.groupBoxParameters.Controls.Add(this.labelWeight);
|
||||
this.groupBoxParameters.Controls.Add(this.labelSpeed);
|
||||
this.groupBoxParameters.Location = new System.Drawing.Point(25, 12);
|
||||
this.groupBoxParameters.Name = "groupBoxParameters";
|
||||
this.groupBoxParameters.Size = new System.Drawing.Size(673, 280);
|
||||
this.groupBoxParameters.TabIndex = 0;
|
||||
this.groupBoxParameters.TabStop = false;
|
||||
this.groupBoxParameters.Text = "Параметры";
|
||||
//
|
||||
// labelModifiedObject
|
||||
//
|
||||
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelModifiedObject.Location = new System.Drawing.Point(528, 196);
|
||||
this.labelModifiedObject.Name = "labelModifiedObject";
|
||||
this.labelModifiedObject.Size = new System.Drawing.Size(101, 43);
|
||||
this.labelModifiedObject.TabIndex = 9;
|
||||
this.labelModifiedObject.Text = "Сложный";
|
||||
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelSimpleObject.Location = new System.Drawing.Point(412, 196);
|
||||
this.labelSimpleObject.Name = "labelSimpleObject";
|
||||
this.labelSimpleObject.Size = new System.Drawing.Size(101, 43);
|
||||
this.labelSimpleObject.TabIndex = 8;
|
||||
this.labelSimpleObject.Text = "Простой";
|
||||
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// groupBoxColor
|
||||
//
|
||||
this.groupBoxColor.Controls.Add(this.panelPurple);
|
||||
this.groupBoxColor.Controls.Add(this.panelBlack);
|
||||
this.groupBoxColor.Controls.Add(this.panelYellow);
|
||||
this.groupBoxColor.Controls.Add(this.panelGray);
|
||||
this.groupBoxColor.Controls.Add(this.panelBlue);
|
||||
this.groupBoxColor.Controls.Add(this.panelGreen);
|
||||
this.groupBoxColor.Controls.Add(this.panelWhite);
|
||||
this.groupBoxColor.Controls.Add(this.panelRed);
|
||||
this.groupBoxColor.Location = new System.Drawing.Point(385, 32);
|
||||
this.groupBoxColor.Name = "groupBoxColor";
|
||||
this.groupBoxColor.Size = new System.Drawing.Size(272, 151);
|
||||
this.groupBoxColor.TabIndex = 7;
|
||||
this.groupBoxColor.TabStop = false;
|
||||
this.groupBoxColor.Text = "Цвета";
|
||||
//
|
||||
// panelPurple
|
||||
//
|
||||
this.panelPurple.BackColor = System.Drawing.Color.Purple;
|
||||
this.panelPurple.Location = new System.Drawing.Point(207, 92);
|
||||
this.panelPurple.Name = "panelPurple";
|
||||
this.panelPurple.Size = new System.Drawing.Size(47, 47);
|
||||
this.panelPurple.TabIndex = 4;
|
||||
//
|
||||
// panelBlack
|
||||
//
|
||||
this.panelBlack.BackColor = System.Drawing.Color.Black;
|
||||
this.panelBlack.Location = new System.Drawing.Point(143, 92);
|
||||
this.panelBlack.Name = "panelBlack";
|
||||
this.panelBlack.Size = new System.Drawing.Size(47, 47);
|
||||
this.panelBlack.TabIndex = 4;
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
|
||||
this.panelYellow.Location = new System.Drawing.Point(207, 32);
|
||||
this.panelYellow.Name = "panelYellow";
|
||||
this.panelYellow.Size = new System.Drawing.Size(47, 47);
|
||||
this.panelYellow.TabIndex = 3;
|
||||
//
|
||||
// panelGray
|
||||
//
|
||||
this.panelGray.BackColor = System.Drawing.Color.Gray;
|
||||
this.panelGray.Location = new System.Drawing.Point(81, 92);
|
||||
this.panelGray.Name = "panelGray";
|
||||
this.panelGray.Size = new System.Drawing.Size(47, 47);
|
||||
this.panelGray.TabIndex = 2;
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
this.panelBlue.BackColor = System.Drawing.Color.Blue;
|
||||
this.panelBlue.Location = new System.Drawing.Point(143, 32);
|
||||
this.panelBlue.Name = "panelBlue";
|
||||
this.panelBlue.Size = new System.Drawing.Size(47, 47);
|
||||
this.panelBlue.TabIndex = 3;
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
this.panelGreen.BackColor = System.Drawing.Color.Green;
|
||||
this.panelGreen.Location = new System.Drawing.Point(81, 32);
|
||||
this.panelGreen.Name = "panelGreen";
|
||||
this.panelGreen.Size = new System.Drawing.Size(47, 47);
|
||||
this.panelGreen.TabIndex = 1;
|
||||
//
|
||||
// panelWhite
|
||||
//
|
||||
this.panelWhite.BackColor = System.Drawing.Color.White;
|
||||
this.panelWhite.Location = new System.Drawing.Point(18, 92);
|
||||
this.panelWhite.Name = "panelWhite";
|
||||
this.panelWhite.Size = new System.Drawing.Size(47, 47);
|
||||
this.panelWhite.TabIndex = 1;
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
this.panelRed.BackColor = System.Drawing.Color.Red;
|
||||
this.panelRed.Location = new System.Drawing.Point(18, 32);
|
||||
this.panelRed.Name = "panelRed";
|
||||
this.panelRed.Size = new System.Drawing.Size(47, 47);
|
||||
this.panelRed.TabIndex = 0;
|
||||
//
|
||||
// checkBoxPassengerCompartment
|
||||
//
|
||||
this.checkBoxPassengerCompartment.AutoSize = true;
|
||||
this.checkBoxPassengerCompartment.Location = new System.Drawing.Point(17, 184);
|
||||
this.checkBoxPassengerCompartment.Name = "checkBoxPassengerCompartment";
|
||||
this.checkBoxPassengerCompartment.Size = new System.Drawing.Size(320, 24);
|
||||
this.checkBoxPassengerCompartment.TabIndex = 5;
|
||||
this.checkBoxPassengerCompartment.Text = "Признак наличия отсека для пассажиров";
|
||||
this.checkBoxPassengerCompartment.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxEngine
|
||||
//
|
||||
this.checkBoxEngine.AutoSize = true;
|
||||
this.checkBoxEngine.Location = new System.Drawing.Point(17, 138);
|
||||
this.checkBoxEngine.Name = "checkBoxEngine";
|
||||
this.checkBoxEngine.Size = new System.Drawing.Size(236, 24);
|
||||
this.checkBoxEngine.TabIndex = 4;
|
||||
this.checkBoxEngine.Text = "Признак наличия двигателей";
|
||||
this.checkBoxEngine.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
this.numericUpDownWeight.Location = new System.Drawing.Point(108, 94);
|
||||
this.numericUpDownWeight.Maximum = new decimal(new int[] {
|
||||
1000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownWeight.Minimum = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownWeight.Name = "numericUpDownWeight";
|
||||
this.numericUpDownWeight.Size = new System.Drawing.Size(86, 27);
|
||||
this.numericUpDownWeight.TabIndex = 3;
|
||||
this.numericUpDownWeight.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
this.numericUpDownSpeed.Location = new System.Drawing.Point(108, 44);
|
||||
this.numericUpDownSpeed.Maximum = new decimal(new int[] {
|
||||
1000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownSpeed.Minimum = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||
this.numericUpDownSpeed.Size = new System.Drawing.Size(86, 27);
|
||||
this.numericUpDownSpeed.TabIndex = 2;
|
||||
this.numericUpDownSpeed.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// labelWeight
|
||||
//
|
||||
this.labelWeight.AutoSize = true;
|
||||
this.labelWeight.Location = new System.Drawing.Point(17, 94);
|
||||
this.labelWeight.Name = "labelWeight";
|
||||
this.labelWeight.Size = new System.Drawing.Size(36, 20);
|
||||
this.labelWeight.TabIndex = 1;
|
||||
this.labelWeight.Text = "Вес:";
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
this.labelSpeed.AutoSize = true;
|
||||
this.labelSpeed.Location = new System.Drawing.Point(17, 44);
|
||||
this.labelSpeed.Name = "labelSpeed";
|
||||
this.labelSpeed.Size = new System.Drawing.Size(76, 20);
|
||||
this.labelSpeed.TabIndex = 0;
|
||||
this.labelSpeed.Text = "Скорость:";
|
||||
//
|
||||
// panelObject
|
||||
//
|
||||
this.panelObject.AllowDrop = true;
|
||||
this.panelObject.Controls.Add(this.pictureBoxObject);
|
||||
this.panelObject.Controls.Add(this.labelExtraColor);
|
||||
this.panelObject.Controls.Add(this.labelColor);
|
||||
this.panelObject.Location = new System.Drawing.Point(714, 12);
|
||||
this.panelObject.Name = "panelObject";
|
||||
this.panelObject.Size = new System.Drawing.Size(338, 228);
|
||||
this.panelObject.TabIndex = 1;
|
||||
this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
|
||||
this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
this.pictureBoxObject.Location = new System.Drawing.Point(0, 52);
|
||||
this.pictureBoxObject.Name = "pictureBoxObject";
|
||||
this.pictureBoxObject.Size = new System.Drawing.Size(331, 167);
|
||||
this.pictureBoxObject.TabIndex = 2;
|
||||
this.pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// labelExtraColor
|
||||
//
|
||||
this.labelExtraColor.AllowDrop = true;
|
||||
this.labelExtraColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelExtraColor.Location = new System.Drawing.Point(169, 14);
|
||||
this.labelExtraColor.Name = "labelExtraColor";
|
||||
this.labelExtraColor.Size = new System.Drawing.Size(150, 35);
|
||||
this.labelExtraColor.TabIndex = 1;
|
||||
this.labelExtraColor.Text = "Доп. цвет";
|
||||
this.labelExtraColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelExtraColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragDrop);
|
||||
this.labelExtraColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
|
||||
//
|
||||
// labelColor
|
||||
//
|
||||
this.labelColor.AllowDrop = true;
|
||||
this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelColor.Location = new System.Drawing.Point(13, 14);
|
||||
this.labelColor.Name = "labelColor";
|
||||
this.labelColor.Size = new System.Drawing.Size(150, 35);
|
||||
this.labelColor.TabIndex = 0;
|
||||
this.labelColor.Text = "Цвет";
|
||||
this.labelColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop);
|
||||
this.labelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(717, 246);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(160, 46);
|
||||
this.buttonAdd.TabIndex = 2;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(883, 246);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(160, 46);
|
||||
this.buttonCancel.TabIndex = 3;
|
||||
this.buttonCancel.Text = "Отменить";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormAirplaneConfig
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1059, 304);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonAdd);
|
||||
this.Controls.Add(this.panelObject);
|
||||
this.Controls.Add(this.groupBoxParameters);
|
||||
this.Name = "FormAirplaneConfig";
|
||||
this.Text = "Создание объекта";
|
||||
this.groupBoxParameters.ResumeLayout(false);
|
||||
this.groupBoxParameters.PerformLayout();
|
||||
this.groupBoxColor.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
|
||||
this.panelObject.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxParameters;
|
||||
private Label labelWeight;
|
||||
private Label labelSpeed;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private CheckBox checkBoxEngine;
|
||||
private CheckBox checkBoxPassengerCompartment;
|
||||
private GroupBox groupBoxColor;
|
||||
private Panel panelGreen;
|
||||
private Panel panelWhite;
|
||||
private Panel panelRed;
|
||||
private Panel panelPurple;
|
||||
private Panel panelBlack;
|
||||
private Panel panelYellow;
|
||||
private Panel panelGray;
|
||||
private Panel panelBlue;
|
||||
private Label labelSimpleObject;
|
||||
private Label labelModifiedObject;
|
||||
private Panel panelObject;
|
||||
private Button buttonAdd;
|
||||
private Button buttonCancel;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Label labelExtraColor;
|
||||
private Label labelColor;
|
||||
}
|
||||
}
|
199
Airbus_Base/FormAirplaneConfig.cs
Normal file
199
Airbus_Base/FormAirplaneConfig.cs
Normal file
@ -0,0 +1,199 @@
|
||||
using Airbus_Base.DrawningObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Text;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Airbus_Base
|
||||
{
|
||||
/// <summary>
|
||||
/// Форма создания объекта
|
||||
/// </summary>
|
||||
public partial class FormAirplaneConfig : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Переменная-выбранный самолёт
|
||||
/// </summary>
|
||||
DrawningAirplane? _airplane = null;
|
||||
|
||||
/// <summary>
|
||||
/// Событие
|
||||
/// </summary>
|
||||
private event Action<DrawningAirplane>? EventAddAirplane;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormAirplaneConfig()
|
||||
{
|
||||
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;
|
||||
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
||||
buttonCancel.Click += (s, e) => Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Отрисовать самолёт
|
||||
/// </summary>
|
||||
private void DrawAirplane()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_airplane?.SetPosition(5, 5);
|
||||
_airplane?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление события
|
||||
/// </summary>
|
||||
/// <param name="ev">Привязанный метод</param>
|
||||
public void AddEvent(Action<DrawningAirplane> ev)
|
||||
{
|
||||
if (EventAddAirplane == null)
|
||||
{
|
||||
EventAddAirplane = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddAirplane += ev;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Передаем информацию при нажатии на Label
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Действия при приеме перетаскиваемой информации
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "labelSimpleObject":
|
||||
_airplane = new DrawningAirplane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value,
|
||||
Color.White, pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
break;
|
||||
case "labelModifiedObject":
|
||||
_airplane = new DrawningAirbus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value,
|
||||
Color.White, Color.Black, checkBoxEngine.Checked, checkBoxPassengerCompartment.Checked,
|
||||
pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
break;
|
||||
}
|
||||
labelColor.BackColor = Color.Empty;
|
||||
labelExtraColor.BackColor = Color.Empty;
|
||||
DrawAirplane();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Отправляем цвет с панели
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Control)?.DoDragDrop((sender as Control)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Принимаем основной цвет
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_airplane == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
labelColor.BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||
_airplane.SetColor(labelColor.BackColor);
|
||||
DrawAirplane();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Принимаем дополнительный цвет
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if ((_airplane == null) || (_airplane is DrawningAirbus == false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
labelExtraColor.BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||
((DrawningAirbus)_airplane).SetAddColor(labelExtraColor.BackColor);
|
||||
DrawAirplane();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление самолёта
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddAirplane?.Invoke(_airplane);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
60
Airbus_Base/FormAirplaneConfig.resx
Normal file
60
Airbus_Base/FormAirplaneConfig.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user