в процессе

This commit is contained in:
a.puchkina 2023-11-08 11:23:47 +04:00
parent c5550d73e2
commit 07cc928cb7
2 changed files with 351 additions and 61 deletions

View File

@ -29,91 +29,158 @@
private void InitializeComponent()
{
groupBoxParameters = new GroupBox();
labelSpeed = new Label();
labelWeight = new Label();
numericUpDown1 = new NumericUpDown();
numericUpDown2 = new NumericUpDown();
checkBoxRadar = new CheckBox();
checkBoxTank = new CheckBox();
labelModifiedObject = new Label();
labelSimpleObject = new Label();
groupBoxColors = new GroupBox();
panelPurple = new Panel();
panelYellow = new Panel();
panelBlack = new Panel();
panelBlue = new Panel();
panelGrey = new Panel();
panelGreen = new Panel();
panelWhite = new Panel();
panelRed = new Panel();
checkBoxPin = new CheckBox();
checkBoxTank = new CheckBox();
checkBoxRadar = new CheckBox();
numericUpDownWeight = new NumericUpDown();
numericUpDownSpeed = new NumericUpDown();
labelWeight = new Label();
labelSpeed = new Label();
panelObject = new Panel();
labelAdditionalColor = new Label();
labelBodyColor = new Label();
pictureBoxObject = new PictureBox();
buttonOk = new Button();
button2 = new Button();
groupBoxParameters.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDown1).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDown2).BeginInit();
groupBoxColors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
panelObject.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
SuspendLayout();
//
// groupBoxParameters
//
groupBoxParameters.Controls.Add(labelModifiedObject);
groupBoxParameters.Controls.Add(labelSimpleObject);
groupBoxParameters.Controls.Add(groupBoxColors);
groupBoxParameters.Controls.Add(checkBoxPin);
groupBoxParameters.Controls.Add(checkBoxTank);
groupBoxParameters.Controls.Add(checkBoxRadar);
groupBoxParameters.Controls.Add(numericUpDown2);
groupBoxParameters.Controls.Add(numericUpDown1);
groupBoxParameters.Controls.Add(numericUpDownWeight);
groupBoxParameters.Controls.Add(numericUpDownSpeed);
groupBoxParameters.Controls.Add(labelWeight);
groupBoxParameters.Controls.Add(labelSpeed);
groupBoxParameters.Location = new Point(12, 12);
groupBoxParameters.Name = "groupBoxParameters";
groupBoxParameters.Size = new Size(776, 254);
groupBoxParameters.Size = new Size(499, 254);
groupBoxParameters.TabIndex = 0;
groupBoxParameters.TabStop = false;
groupBoxParameters.Text = "Параметры";
//
// labelSpeed
// labelModifiedObject
//
labelSpeed.AutoSize = true;
labelSpeed.Location = new Point(6, 44);
labelSpeed.Name = "labelSpeed";
labelSpeed.Size = new Size(76, 20);
labelSpeed.TabIndex = 0;
labelSpeed.Text = "Скорость:";
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
labelModifiedObject.Location = new Point(363, 192);
labelModifiedObject.Name = "labelModifiedObject";
labelModifiedObject.Size = new Size(111, 36);
labelModifiedObject.TabIndex = 10;
labelModifiedObject.Text = "Продвинутый";
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
//
// labelWeight
// labelSimpleObject
//
labelWeight.AutoSize = true;
labelWeight.Location = new Point(6, 87);
labelWeight.Name = "labelWeight";
labelWeight.Size = new Size(36, 20);
labelWeight.TabIndex = 1;
labelWeight.Text = "Вес:";
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
labelSimpleObject.Location = new Point(264, 192);
labelSimpleObject.Name = "labelSimpleObject";
labelSimpleObject.Size = new Size(97, 36);
labelSimpleObject.TabIndex = 9;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
labelSimpleObject.MouseDown += LabelObject_MouseDown;
//
// numericUpDown1
// groupBoxColors
//
numericUpDown1.Location = new Point(88, 42);
numericUpDown1.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDown1.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDown1.Name = "numericUpDown1";
numericUpDown1.Size = new Size(102, 27);
numericUpDown1.TabIndex = 2;
numericUpDown1.Value = new decimal(new int[] { 1000, 0, 0, 0 });
groupBoxColors.Controls.Add(panelPurple);
groupBoxColors.Controls.Add(panelYellow);
groupBoxColors.Controls.Add(panelBlack);
groupBoxColors.Controls.Add(panelBlue);
groupBoxColors.Controls.Add(panelGrey);
groupBoxColors.Controls.Add(panelGreen);
groupBoxColors.Controls.Add(panelWhite);
groupBoxColors.Controls.Add(panelRed);
groupBoxColors.Location = new Point(248, 42);
groupBoxColors.Name = "groupBoxColors";
groupBoxColors.Size = new Size(232, 125);
groupBoxColors.TabIndex = 8;
groupBoxColors.TabStop = false;
groupBoxColors.Text = "Цвета";
//
// numericUpDown2
// panelPurple
//
numericUpDown2.Location = new Point(88, 85);
numericUpDown2.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDown2.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDown2.Name = "numericUpDown2";
numericUpDown2.Size = new Size(102, 27);
numericUpDown2.TabIndex = 3;
numericUpDown2.Value = new decimal(new int[] { 1000, 0, 0, 0 });
panelPurple.BackColor = Color.Orchid;
panelPurple.Location = new Point(186, 79);
panelPurple.Name = "panelPurple";
panelPurple.Size = new Size(40, 40);
panelPurple.TabIndex = 7;
//
// checkBoxRadar
// panelYellow
//
checkBoxRadar.AutoSize = true;
checkBoxRadar.Location = new Point(6, 132);
checkBoxRadar.Name = "checkBoxRadar";
checkBoxRadar.Size = new Size(208, 24);
checkBoxRadar.TabIndex = 4;
checkBoxRadar.Text = "Признак наличия радара";
checkBoxRadar.UseVisualStyleBackColor = true;
panelYellow.BackColor = Color.Yellow;
panelYellow.Location = new Point(186, 26);
panelYellow.Name = "panelYellow";
panelYellow.Size = new Size(40, 40);
panelYellow.TabIndex = 3;
//
// checkBoxTank
// panelBlack
//
checkBoxTank.AutoSize = true;
checkBoxTank.Location = new Point(6, 162);
checkBoxTank.Name = "checkBoxTank";
checkBoxTank.Size = new Size(190, 24);
checkBoxTank.TabIndex = 5;
checkBoxTank.Text = "Признак наличия бака";
checkBoxTank.UseVisualStyleBackColor = true;
panelBlack.BackColor = Color.Black;
panelBlack.Location = new Point(129, 79);
panelBlack.Name = "panelBlack";
panelBlack.Size = new Size(40, 40);
panelBlack.TabIndex = 6;
//
// panelBlue
//
panelBlue.BackColor = Color.CornflowerBlue;
panelBlue.Location = new Point(129, 26);
panelBlue.Name = "panelBlue";
panelBlue.Size = new Size(40, 40);
panelBlue.TabIndex = 2;
//
// panelGrey
//
panelGrey.BackColor = Color.DarkGray;
panelGrey.Location = new Point(73, 79);
panelGrey.Name = "panelGrey";
panelGrey.Size = new Size(40, 40);
panelGrey.TabIndex = 5;
//
// panelGreen
//
panelGreen.BackColor = Color.YellowGreen;
panelGreen.Location = new Point(73, 26);
panelGreen.Name = "panelGreen";
panelGreen.Size = new Size(40, 40);
panelGreen.TabIndex = 1;
//
// panelWhite
//
panelWhite.BackColor = Color.White;
panelWhite.Location = new Point(16, 79);
panelWhite.Name = "panelWhite";
panelWhite.Size = new Size(40, 40);
panelWhite.TabIndex = 4;
//
// panelRed
//
panelRed.BackColor = Color.IndianRed;
panelRed.Location = new Point(16, 26);
panelRed.Name = "panelRed";
panelRed.Size = new Size(40, 40);
panelRed.TabIndex = 0;
//
// checkBoxPin
//
@ -125,30 +192,171 @@
checkBoxPin.Text = "Признак наличия штыря";
checkBoxPin.UseVisualStyleBackColor = true;
//
// checkBoxTank
//
checkBoxTank.AutoSize = true;
checkBoxTank.Location = new Point(6, 162);
checkBoxTank.Name = "checkBoxTank";
checkBoxTank.Size = new Size(190, 24);
checkBoxTank.TabIndex = 5;
checkBoxTank.Text = "Признак наличия бака";
checkBoxTank.UseVisualStyleBackColor = true;
//
// checkBoxRadar
//
checkBoxRadar.AutoSize = true;
checkBoxRadar.Location = new Point(6, 132);
checkBoxRadar.Name = "checkBoxRadar";
checkBoxRadar.Size = new Size(208, 24);
checkBoxRadar.TabIndex = 4;
checkBoxRadar.Text = "Признак наличия радара";
checkBoxRadar.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(88, 85);
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownWeight.Name = "numericUpDownWeight";
numericUpDownWeight.Size = new Size(102, 27);
numericUpDownWeight.TabIndex = 3;
numericUpDownWeight.Value = new decimal(new int[] { 1000, 0, 0, 0 });
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(88, 42);
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownSpeed.Name = "numericUpDownSpeed";
numericUpDownSpeed.Size = new Size(102, 27);
numericUpDownSpeed.TabIndex = 2;
numericUpDownSpeed.Value = new decimal(new int[] { 1000, 0, 0, 0 });
//
// labelWeight
//
labelWeight.AutoSize = true;
labelWeight.Location = new Point(6, 87);
labelWeight.Name = "labelWeight";
labelWeight.Size = new Size(36, 20);
labelWeight.TabIndex = 1;
labelWeight.Text = "Вес:";
//
// labelSpeed
//
labelSpeed.AutoSize = true;
labelSpeed.Location = new Point(6, 42);
labelSpeed.Name = "labelSpeed";
labelSpeed.Size = new Size(76, 20);
labelSpeed.TabIndex = 0;
labelSpeed.Text = "Скорость:";
//
// panelObject
//
panelObject.AllowDrop = true;
panelObject.Controls.Add(labelAdditionalColor);
panelObject.Controls.Add(labelBodyColor);
panelObject.Controls.Add(pictureBoxObject);
panelObject.Location = new Point(517, 12);
panelObject.Name = "panelObject";
panelObject.Size = new Size(260, 193);
panelObject.TabIndex = 12;
panelObject.DragDrop += PanelObject_DragDrop;
panelObject.DragEnter += PanelObject_DragEnter;
//
// labelAdditionalColor
//
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
labelAdditionalColor.Location = new Point(134, 6);
labelAdditionalColor.Name = "labelAdditionalColor";
labelAdditionalColor.Size = new Size(107, 36);
labelAdditionalColor.TabIndex = 13;
labelAdditionalColor.Text = "Доп. цвет";
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
//
// labelBodyColor
//
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
labelBodyColor.Location = new Point(31, 6);
labelBodyColor.Name = "labelBodyColor";
labelBodyColor.Size = new Size(97, 36);
labelBodyColor.TabIndex = 12;
labelBodyColor.Text = "Цвет";
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
//
// pictureBoxObject
//
pictureBoxObject.Location = new Point(3, 45);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(254, 148);
pictureBoxObject.TabIndex = 7;
pictureBoxObject.TabStop = false;
//
// buttonOk
//
buttonOk.Location = new Point(551, 226);
buttonOk.Name = "buttonOk";
buttonOk.Size = new Size(94, 29);
buttonOk.TabIndex = 13;
buttonOk.Text = "Добавить";
buttonOk.UseVisualStyleBackColor = true;
buttonOk.Click += buttonOk_Click;
//
// button2
//
button2.Location = new Point(651, 226);
button2.Name = "button2";
button2.Size = new Size(94, 29);
button2.TabIndex = 14;
button2.Text = "Отмена";
button2.UseVisualStyleBackColor = true;
//
// FormAirplaneConfig
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 278);
Controls.Add(button2);
Controls.Add(buttonOk);
Controls.Add(panelObject);
Controls.Add(groupBoxParameters);
Name = "FormAirplaneConfig";
Text = "FormAirplaneConfig";
groupBoxParameters.ResumeLayout(false);
groupBoxParameters.PerformLayout();
((System.ComponentModel.ISupportInitialize)numericUpDown1).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDown2).EndInit();
groupBoxColors.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
panelObject.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxParameters;
private NumericUpDown numericUpDown2;
private NumericUpDown numericUpDown1;
private NumericUpDown numericUpDownWeight;
private NumericUpDown numericUpDownSpeed;
private Label labelWeight;
private Label labelSpeed;
private CheckBox checkBoxRadar;
private CheckBox checkBoxPin;
private CheckBox checkBoxTank;
private GroupBox groupBoxColors;
private Panel panelRed;
private Panel panelPurple;
private Panel panelYellow;
private Panel panelBlack;
private Panel panelBlue;
private Panel panelGrey;
private Panel panelGreen;
private Panel panelWhite;
private Label labelModifiedObject;
private Label labelSimpleObject;
private Panel panelObject;
private Label labelAdditionalColor;
private Label labelBodyColor;
private PictureBox pictureBoxObject;
private Button buttonOk;
private Button button2;
}
}

View File

@ -7,15 +7,97 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AirplaneWithRadar.DrawningObjects;
namespace AirplaneWithRadar
{
public partial class FormAirplaneConfig : Form
{
/// <summary>
/// Переменная-выбранный самолет
/// </summary>
DrawningAirplane? _airplane = null;
/// <summary>
/// Событие
/// </summary>
private event AirplaneDelegate? EventAddAirplane;
/// <summary>
/// Конструктор
/// </summary
public FormAirplaneConfig()
{
InitializeComponent();
}
/// <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>
/// Передаем информацию при нажатии на 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 DrawningAirplaneWithRadar((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxRadar.Checked,
checkBoxTank.Checked, checkBoxPin.Checked, pictureBoxObject.Width,
pictureBoxObject.Height);
break;
}
DrawAirplane();
}
/// <summary>
/// Добавление машины
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonOk_Click(object sender, EventArgs e)
{
EventAddCar?.Invoke(_airplane);
Close();
}
}
}