This commit is contained in:
Alenka 2023-11-10 10:59:30 +04:00
parent 8c293b6d5c
commit 62a7064012
10 changed files with 258 additions and 104 deletions

View File

@ -1 +0,0 @@


View File

@ -13,7 +13,7 @@ namespace Monorail.Entities
public double Weight { get; private set; } public double Weight { get; private set; }
public Color BodyColor { get; private set; } public Color BodyColor { get; set; }
public double Step => (double)Speed * 100 / Weight; public double Step => (double)Speed * 100 / Weight;
@ -23,5 +23,10 @@ namespace Monorail.Entities
Weight = weight; Weight = weight;
BodyColor = bodyColor; BodyColor = bodyColor;
} }
public void setBodyColor(Color color)
{
BodyColor = color;
}
} }
} }

View File

@ -42,7 +42,12 @@ namespace Monorail.DrawningObjects
_pictureHeight = height; _pictureHeight = height;
EntityPlane = new EntityPlane(speed, weight, bodyColor); EntityPlane = new EntityPlane(speed, weight, bodyColor);
} }
public void ChangeColor(Color col)
{
if (EntityPlane == null)
return;
EntityPlane.BodyColor = col;
}
protected DrawingPlane(int speed, double weight, Color bodyColor, int width, int height, int planeWidth, int planeHeight) protected DrawingPlane(int speed, double weight, Color bodyColor, int width, int height, int planeWidth, int planeHeight)
{ {
if (_planeWidth > width || _planeHeight > height) if (_planeWidth > width || _planeHeight > height)

View File

@ -29,41 +29,30 @@ namespace Monorail.DrawningObjects
base.DrawTransport(g); base.DrawTransport(g);
Pen pen = new Pen(Color.Black, 2); Pen pen = new Pen(Color.Black, 2);
Brush additionalBrush = new SolidBrush(airBomber.AdditionalColor); Brush additionalBrush = new SolidBrush(airBomber.AdditionalColor);
// топливо
if (airBomber.Fuel) if (airBomber.Fuel)
{ {
g.FillEllipse(additionalBrush, _startPosX + 60, _startPosY - 1, 40, 10); Point[] trianglePoints1 =
g.DrawEllipse(pen, _startPosX + 60, _startPosY - 1, 40, 10); {
g.FillEllipse(additionalBrush, _startPosX + 60, _startPosY + 150, 40, 10); new Point(_startPosX + 20, _startPosY + 5),
g.DrawEllipse(pen, _startPosX + 60, _startPosY + 150, 40, 10); new Point(_startPosX + 40, _startPosY + 25),
new Point(_startPosX + 60, _startPosY + 5)
};
Point[] trianglePoints2 =
{
new Point(_startPosX + 20, _startPosY + 55),
new Point(_startPosX + 40, _startPosY + 35),
new Point(_startPosX + 60, _startPosY + 55)
};
g.FillPolygon(additionalBrush, trianglePoints1);
g.FillPolygon(additionalBrush, trianglePoints2);
} }
//бомбы
if (airBomber.Bombs) if (airBomber.Bombs)
{ {
Point[] point = new Point[8] { g.FillEllipse(additionalBrush, _startPosX + 90, _startPosY + 20, 20, 20);
new Point(_startPosX + 70 - 20, _startPosY + 75),
new Point(_startPosX + 90 - 20, _startPosY + 75),
new Point(_startPosX + 100 - 20, _startPosY + 80),
new Point(_startPosX + 110 - 20, _startPosY + 75),
new Point(_startPosX + 110 - 20, _startPosY + 85),
new Point(_startPosX + 100 - 20, _startPosY + 80),
new Point(_startPosX + 90 - 20, _startPosY + 85),
new Point(_startPosX + 70 - 20, _startPosY + 85)
};
g.FillPolygon(additionalBrush, point);
g.DrawPolygon(pen, point);
point = new Point[8] {
new Point(_startPosX + 70 + 30, _startPosY + 75),
new Point(_startPosX + 90 + 30, _startPosY + 75),
new Point(_startPosX + 100 + 30, _startPosY + 80),
new Point(_startPosX + 110 + 30, _startPosY + 75),
new Point(_startPosX + 110 + 30, _startPosY + 85),
new Point(_startPosX + 100 + 30, _startPosY + 80),
new Point(_startPosX + 90 + 30, _startPosY + 85),
new Point(_startPosX + 70 + 30, _startPosY + 85)
};
g.FillPolygon(additionalBrush, point);
g.DrawPolygon(pen, point);
} }
} }
} }

View File

@ -29,15 +29,22 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox1 = new System.Windows.Forms.GroupBox();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.button2 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button();
this.panel3 = new System.Windows.Forms.Panel(); this.panel3 = new System.Windows.Forms.Panel();
this.label6 = new System.Windows.Forms.Label(); this.label_addit_color = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label(); this.label_color = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.labelAdvanced = new System.Windows.Forms.Label(); this.labelAdvanced = new System.Windows.Forms.Label();
this.labelBasic = new System.Windows.Forms.Label(); this.labelBasic = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox();
this.panel9 = new System.Windows.Forms.Panel();
this.panel8 = new System.Windows.Forms.Panel();
this.panel7 = new System.Windows.Forms.Panel();
this.panel6 = new System.Windows.Forms.Panel();
this.panel5 = new System.Windows.Forms.Panel();
this.panel4 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel(); this.panel2 = new System.Windows.Forms.Panel();
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
this.checkBox1 = new System.Windows.Forms.CheckBox(); this.checkBox1 = new System.Windows.Forms.CheckBox();
@ -55,6 +62,7 @@
// //
// groupBox1 // groupBox1
// //
this.groupBox1.Controls.Add(this.checkBox2);
this.groupBox1.Controls.Add(this.button2); this.groupBox1.Controls.Add(this.button2);
this.groupBox1.Controls.Add(this.button1); this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Controls.Add(this.panel3); this.groupBox1.Controls.Add(this.panel3);
@ -71,67 +79,80 @@
this.groupBox1.Size = new System.Drawing.Size(1163, 391); this.groupBox1.Size = new System.Drawing.Size(1163, 391);
this.groupBox1.TabIndex = 0; this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
this.groupBox1.Text = "groupBox1"; this.groupBox1.Text = "Параметры";
//
// checkBox2
//
this.checkBox2.AutoSize = true;
this.checkBox2.Location = new System.Drawing.Point(33, 277);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(232, 29);
this.checkBox2.TabIndex = 12;
this.checkBox2.Text = "Наличие ракетных шахт";
this.checkBox2.UseVisualStyleBackColor = true;
this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
// //
// button2 // button2
// //
this.button2.Location = new System.Drawing.Point(1034, 338); this.button2.Location = new System.Drawing.Point(991, 321);
this.button2.Name = "button2"; this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(74, 33); this.button2.Size = new System.Drawing.Size(127, 38);
this.button2.TabIndex = 11; this.button2.TabIndex = 11;
this.button2.Text = "button2"; this.button2.Text = "Отмена";
this.button2.UseVisualStyleBackColor = true; this.button2.UseVisualStyleBackColor = true;
// //
// button1 // button1
// //
this.button1.Location = new System.Drawing.Point(902, 331); this.button1.Location = new System.Drawing.Point(838, 321);
this.button1.Name = "button1"; this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(84, 38); this.button1.Size = new System.Drawing.Size(136, 38);
this.button1.TabIndex = 10; this.button1.TabIndex = 10;
this.button1.Text = "button1"; this.button1.Text = "Добавить";
this.button1.UseVisualStyleBackColor = true; this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.ButtonAdd_Click); this.button1.Click += new System.EventHandler(this.ButtonAdd_Click);
// //
// panel3 // panel3
// //
this.panel3.AllowDrop = true; this.panel3.AllowDrop = true;
this.panel3.Controls.Add(this.label6); this.panel3.Controls.Add(this.label_addit_color);
this.panel3.Controls.Add(this.label5); this.panel3.Controls.Add(this.label_color);
this.panel3.Controls.Add(this.pictureBox1); this.panel3.Controls.Add(this.pictureBox1);
this.panel3.Location = new System.Drawing.Point(906, 45); this.panel3.Location = new System.Drawing.Point(822, 45);
this.panel3.Name = "panel3"; this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(228, 261); this.panel3.Size = new System.Drawing.Size(312, 261);
this.panel3.TabIndex = 9; this.panel3.TabIndex = 9;
this.panel3.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop); this.panel3.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
this.panel3.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter); this.panel3.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
// //
// label6 // label_addit_color
// //
this.label6.AllowDrop = true; this.label_addit_color.AllowDrop = true;
this.label6.AutoSize = true; this.label_addit_color.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.label6.Location = new System.Drawing.Point(124, 29); this.label_addit_color.Location = new System.Drawing.Point(169, 23);
this.label6.Name = "label6"; this.label_addit_color.Name = "label_addit_color";
this.label6.Size = new System.Drawing.Size(59, 25); this.label_addit_color.Size = new System.Drawing.Size(117, 38);
this.label6.TabIndex = 10; this.label_addit_color.TabIndex = 10;
this.label6.Text = "label6"; this.label_addit_color.Text = "Доп.цвет";
this.label6.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelAddColor_DragDrop); this.label_addit_color.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.label6.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelColor_DragEnter); this.label_addit_color.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelAddColor_DragDrop);
this.label_addit_color.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelAddColor_DragEnter);
// //
// label5 // label_color
// //
this.label5.AllowDrop = true; this.label_color.AllowDrop = true;
this.label5.AutoSize = true; this.label_color.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.label5.Location = new System.Drawing.Point(27, 23); this.label_color.Location = new System.Drawing.Point(30, 23);
this.label5.Name = "label5"; this.label_color.Name = "label_color";
this.label5.Size = new System.Drawing.Size(59, 25); this.label_color.Size = new System.Drawing.Size(110, 38);
this.label5.TabIndex = 9; this.label_color.TabIndex = 9;
this.label5.Text = "label5"; this.label_color.Text = "Цвет";
this.label5.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelColor_DragDrop); this.label_color.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.label5.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelColor_DragEnter); this.label_color.DragDrop += new System.Windows.Forms.DragEventHandler(this.labelColor_DragDrop);
this.label_color.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelColor_DragEnter);
// //
// pictureBox1 // pictureBox1
// //
this.pictureBox1.Location = new System.Drawing.Point(39, 67); this.pictureBox1.Location = new System.Drawing.Point(76, 64);
this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(163, 178); this.pictureBox1.Size = new System.Drawing.Size(163, 178);
this.pictureBox1.TabIndex = 8; this.pictureBox1.TabIndex = 8;
@ -140,45 +161,101 @@
// labelAdvanced // labelAdvanced
// //
this.labelAdvanced.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.labelAdvanced.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelAdvanced.Location = new System.Drawing.Point(671, 305); this.labelAdvanced.Location = new System.Drawing.Point(521, 293);
this.labelAdvanced.Name = "labelAdvanced"; this.labelAdvanced.Name = "labelAdvanced";
this.labelAdvanced.Size = new System.Drawing.Size(59, 25); this.labelAdvanced.Size = new System.Drawing.Size(141, 47);
this.labelAdvanced.TabIndex = 7; this.labelAdvanced.TabIndex = 7;
this.labelAdvanced.Text = "label4"; this.labelAdvanced.Text = "Продвинутый";
this.labelAdvanced.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelAdvanced.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown); this.labelAdvanced.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
// //
// labelBasic // labelBasic
// //
this.labelBasic.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.labelBasic.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelBasic.Location = new System.Drawing.Point(515, 305); this.labelBasic.Location = new System.Drawing.Point(369, 293);
this.labelBasic.Name = "labelBasic"; this.labelBasic.Name = "labelBasic";
this.labelBasic.Size = new System.Drawing.Size(59, 25); this.labelBasic.Size = new System.Drawing.Size(131, 47);
this.labelBasic.TabIndex = 6; this.labelBasic.TabIndex = 6;
this.labelBasic.Text = "label3"; this.labelBasic.Text = "Простой";
this.labelBasic.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelBasic.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown); this.labelBasic.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
// //
// groupBox2 // groupBox2
// //
this.groupBox2.Controls.Add(this.panel9);
this.groupBox2.Controls.Add(this.panel8);
this.groupBox2.Controls.Add(this.panel7);
this.groupBox2.Controls.Add(this.panel6);
this.groupBox2.Controls.Add(this.panel5);
this.groupBox2.Controls.Add(this.panel4);
this.groupBox2.Controls.Add(this.panel2); this.groupBox2.Controls.Add(this.panel2);
this.groupBox2.Controls.Add(this.panel1); this.groupBox2.Controls.Add(this.panel1);
this.groupBox2.Location = new System.Drawing.Point(508, 59); this.groupBox2.Location = new System.Drawing.Point(335, 40);
this.groupBox2.Name = "groupBox2"; this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(333, 231); this.groupBox2.Size = new System.Drawing.Size(357, 231);
this.groupBox2.TabIndex = 5; this.groupBox2.TabIndex = 5;
this.groupBox2.TabStop = false; this.groupBox2.TabStop = false;
this.groupBox2.Text = "groupBox2"; this.groupBox2.Text = "Цвета";
//
// panel9
//
this.panel9.BackColor = System.Drawing.Color.Fuchsia;
this.panel9.Location = new System.Drawing.Point(264, 153);
this.panel9.Name = "panel9";
this.panel9.Size = new System.Drawing.Size(53, 49);
this.panel9.TabIndex = 7;
//
// panel8
//
this.panel8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
this.panel8.Location = new System.Drawing.Point(180, 153);
this.panel8.Name = "panel8";
this.panel8.Size = new System.Drawing.Size(53, 49);
this.panel8.TabIndex = 6;
//
// panel7
//
this.panel7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
this.panel7.Location = new System.Drawing.Point(108, 153);
this.panel7.Name = "panel7";
this.panel7.Size = new System.Drawing.Size(53, 49);
this.panel7.TabIndex = 5;
//
// panel6
//
this.panel6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
this.panel6.Location = new System.Drawing.Point(34, 153);
this.panel6.Name = "panel6";
this.panel6.Size = new System.Drawing.Size(53, 49);
this.panel6.TabIndex = 4;
//
// panel5
//
this.panel5.BackColor = System.Drawing.Color.Purple;
this.panel5.Location = new System.Drawing.Point(264, 44);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(53, 49);
this.panel5.TabIndex = 3;
//
// panel4
//
this.panel4.BackColor = System.Drawing.Color.DarkOrchid;
this.panel4.Location = new System.Drawing.Point(186, 44);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(53, 49);
this.panel4.TabIndex = 2;
// //
// panel2 // panel2
// //
this.panel2.BackColor = System.Drawing.SystemColors.ControlDarkDark; this.panel2.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.panel2.Location = new System.Drawing.Point(124, 45); this.panel2.Location = new System.Drawing.Point(108, 44);
this.panel2.Name = "panel2"; this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(64, 54); this.panel2.Size = new System.Drawing.Size(53, 49);
this.panel2.TabIndex = 1; this.panel2.TabIndex = 1;
// //
// panel1 // panel1
// //
this.panel1.BackColor = System.Drawing.SystemColors.ActiveBorder; this.panel1.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.panel1.Location = new System.Drawing.Point(32, 44); this.panel1.Location = new System.Drawing.Point(32, 44);
this.panel1.Name = "panel1"; this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(55, 49); this.panel1.Size = new System.Drawing.Size(55, 49);
@ -187,44 +264,74 @@
// checkBox1 // checkBox1
// //
this.checkBox1.AutoSize = true; this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(280, 69); this.checkBox1.Location = new System.Drawing.Point(33, 213);
this.checkBox1.Name = "checkBox1"; this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(121, 29); this.checkBox1.Size = new System.Drawing.Size(310, 29);
this.checkBox1.TabIndex = 4; this.checkBox1.TabIndex = 4;
this.checkBox1.Text = "checkBox1"; this.checkBox1.Text = "Наличие площадки под вертолет";
this.checkBox1.UseVisualStyleBackColor = true; this.checkBox1.UseVisualStyleBackColor = true;
// //
// numericUpDown2 // numericUpDown2
// //
this.numericUpDown2.Location = new System.Drawing.Point(171, 143); this.numericUpDown2.Location = new System.Drawing.Point(128, 143);
this.numericUpDown2.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.numericUpDown2.Minimum = new decimal(new int[] {
100,
0,
0,
0});
this.numericUpDown2.Name = "numericUpDown2"; this.numericUpDown2.Name = "numericUpDown2";
this.numericUpDown2.Size = new System.Drawing.Size(54, 31); this.numericUpDown2.Size = new System.Drawing.Size(84, 31);
this.numericUpDown2.TabIndex = 3; this.numericUpDown2.TabIndex = 3;
this.numericUpDown2.Value = new decimal(new int[] {
100,
0,
0,
0});
// //
// numericUpDown1 // numericUpDown1
// //
this.numericUpDown1.Location = new System.Drawing.Point(171, 69); this.numericUpDown1.Location = new System.Drawing.Point(128, 75);
this.numericUpDown1.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.numericUpDown1.Minimum = new decimal(new int[] {
100,
0,
0,
0});
this.numericUpDown1.Name = "numericUpDown1"; this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(53, 31); this.numericUpDown1.Size = new System.Drawing.Size(74, 31);
this.numericUpDown1.TabIndex = 2; this.numericUpDown1.TabIndex = 2;
this.numericUpDown1.Value = new decimal(new int[] {
100,
0,
0,
0});
// //
// label2 // label2
// //
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(33, 145); this.label2.Location = new System.Drawing.Point(33, 145);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(59, 25); this.label2.Size = new System.Drawing.Size(43, 25);
this.label2.TabIndex = 1; this.label2.TabIndex = 1;
this.label2.Text = "label2"; this.label2.Text = "Вес:";
// //
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(33, 75); this.label1.Location = new System.Drawing.Point(33, 75);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(59, 25); this.label1.Size = new System.Drawing.Size(93, 25);
this.label1.TabIndex = 0; this.label1.TabIndex = 0;
this.label1.Text = "label1"; this.label1.Text = "Скорость:";
// //
// Form2 // Form2
// //
@ -233,11 +340,11 @@
this.ClientSize = new System.Drawing.Size(1279, 552); this.ClientSize = new System.Drawing.Size(1279, 552);
this.Controls.Add(this.groupBox1); this.Controls.Add(this.groupBox1);
this.Name = "Form2"; this.Name = "Form2";
this.Text = "Form2"; this.Text = "Создание объекта";
this.Load += new System.EventHandler(this.Form2_Load);
this.groupBox1.ResumeLayout(false); this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout(); this.groupBox1.PerformLayout();
this.panel3.ResumeLayout(false); this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.groupBox2.ResumeLayout(false); this.groupBox2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
@ -252,8 +359,8 @@
private Button button2; private Button button2;
private Button button1; private Button button1;
private Panel panel3; private Panel panel3;
private Label label6; private Label label_addit_color;
private Label label5; private Label label_color;
private PictureBox pictureBox1; private PictureBox pictureBox1;
private Label labelAdvanced; private Label labelAdvanced;
private Label labelBasic; private Label labelBasic;
@ -265,5 +372,12 @@
private NumericUpDown numericUpDown1; private NumericUpDown numericUpDown1;
private Label label2; private Label label2;
private Label label1; private Label label1;
private CheckBox checkBox2;
private Panel panel9;
private Panel panel8;
private Panel panel7;
private Panel panel6;
private Panel panel5;
private Panel panel4;
} }
} }

View File

@ -22,7 +22,8 @@ namespace Cruiser
/// <summary> /// <summary>
/// Событие /// Событие
/// </summary> /// </summary>
private event PlaneDelegate? EventAddPlane; public event Action<DrawingPlane>? EventAddPlane;
public Form2(int pictureWidth, int pictureHeight) public Form2(int pictureWidth, int pictureHeight)
{ {
@ -31,8 +32,18 @@ namespace Cruiser
InitializeComponent(); InitializeComponent();
panel1.MouseDown += PanelColor_MouseDown; panel1.MouseDown += PanelColor_MouseDown;
panel2.MouseDown += PanelColor_MouseDown; panel2.MouseDown += PanelColor_MouseDown;
panel3.MouseDown += PanelColor_MouseDown;
panel4.MouseDown += PanelColor_MouseDown;
panel5.MouseDown += PanelColor_MouseDown;
panel6.MouseDown += PanelColor_MouseDown;
panel7.MouseDown += PanelColor_MouseDown;
panel8.MouseDown += PanelColor_MouseDown;
panel9.MouseDown += PanelColor_MouseDown;
button2.Click += (s, e) => Close(); button2.Click += (s, e) => Close();
} }
private void DrawPlane() private void DrawPlane()
{ {
@ -42,7 +53,8 @@ namespace Cruiser
_plane?.DrawTransport(gr); _plane?.DrawTransport(gr);
pictureBox1.Image = bmp; pictureBox1.Image = bmp;
} }
public void AddEvent(PlaneDelegate ev)
public void AddEvent(Action<DrawingPlane> ev)
{ {
if (EventAddPlane == null) if (EventAddPlane == null)
{ {
@ -90,7 +102,7 @@ namespace Cruiser
case "labelAdvanced": case "labelAdvanced":
_plane = new DrawingAirBomber((int)numericUpDown1.Value, _plane = new DrawingAirBomber((int)numericUpDown1.Value,
(int)numericUpDown2.Value, Color.White, Color.Black, checkBox1.Checked, (int)numericUpDown2.Value, Color.White, Color.Black, checkBox1.Checked,
checkBox1.Checked, _pictureWidth, _pictureHeight); checkBox2.Checked, _pictureWidth, _pictureHeight);
break; break;
} }
DrawPlane(); DrawPlane();
@ -119,18 +131,32 @@ namespace Cruiser
{ {
if (_plane?.EntityPlane == null) if (_plane?.EntityPlane == null)
return; return;
switch (((Label)sender).Name)
{
case "label_color":
_plane?.EntityPlane?.setBodyColor((Color)e.Data.GetData(typeof(Color)));
break;
case "label_addit_color":
if (!(_plane is DrawingAirBomber))
return;
(_plane.EntityPlane as EntityAirBomber)?.setAdditionalColor(color: (Color)e.Data.GetData(typeof(Color)));
break;
}
//на всякий случай
Color bodyColor = (Color)e.Data.GetData(typeof(Color)); Color bodyColor = (Color)e.Data.GetData(typeof(Color));
if (_plane is DrawingAirBomber) if (_plane is DrawingAirBomber)
{ {
_plane = new DrawingAirBomber((int)numericUpDown1.Value, _plane = new DrawingAirBomber((int)numericUpDown1.Value,
(int)numericUpDown2.Value, bodyColor, ((EntityAirBomber)_plane.EntityPlane).AdditionalColor, checkBox1.Checked, (int)numericUpDown2.Value, bodyColor, ((EntityAirBomber)_plane.EntityPlane).AdditionalColor, checkBox1.Checked,
checkBox1.Checked, _pictureWidth, _pictureHeight); checkBox2.Checked, _pictureWidth, _pictureHeight);
} }
else else
{ {
_plane = new DrawingPlane((int)numericUpDown1.Value, _plane = new DrawingPlane((int)numericUpDown1.Value,
(int)numericUpDown2.Value, bodyColor, _pictureWidth, _pictureHeight); (int)numericUpDown2.Value, bodyColor, _pictureWidth, _pictureHeight);
} }
//
DrawPlane(); DrawPlane();
} }
@ -153,7 +179,7 @@ namespace Cruiser
Color additionalColor = (Color)e.Data.GetData(typeof(Color)); Color additionalColor = (Color)e.Data.GetData(typeof(Color));
_plane = new DrawingAirBomber((int)numericUpDown1.Value, _plane = new DrawingAirBomber((int)numericUpDown1.Value,
(int)numericUpDown1.Value, _plane.EntityPlane.BodyColor, additionalColor, checkBox1.Checked, (int)numericUpDown1.Value, _plane.EntityPlane.BodyColor, additionalColor, checkBox1.Checked,
checkBox1.Checked, _pictureWidth, _pictureHeight); checkBox2.Checked, _pictureWidth, _pictureHeight);
DrawPlane(); DrawPlane();
} }
@ -168,8 +194,20 @@ namespace Cruiser
e.Effect = DragDropEffects.None; e.Effect = DragDropEffects.None;
} }
} }
private void ButtonAddCruiser()
{
throw new NotImplementedException();
}
private void Form2_Load(object sender, EventArgs e)
{
} }
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
}
}
} }

View File

@ -30,7 +30,7 @@ namespace Cruiser
} }
private void ButtonAddCruiser_Click(object sender, EventArgs e) public void ButtonAddCruiser_Click(object sender, EventArgs e)
{ {
if (listBoxStorages.SelectedIndex == -1) if (listBoxStorages.SelectedIndex == -1)
{ {
@ -44,7 +44,7 @@ namespace Cruiser
} }
Form2 form = new Form2(pictureBox1.Width, pictureBox1.Height); Form2 form = new Form2(pictureBox1.Width, pictureBox1.Height);
form.Show(); form.Show();
PlaneDelegate? planeDelegate = new((m) => { Action<DrawingPlane>? planeDelegate = new((m) => {
bool q = (obj + m); bool q = (obj + m);
if (q) if (q)
{ {

View File

@ -21,5 +21,9 @@ namespace Monorail.Entities
Bombs = bombs; Bombs = bombs;
Fuel = fuel; Fuel = fuel;
} }
public void setAdditionalColor(Color color)
{
AdditionalColor = color;
}
} }
} }