Правки 5 лаб
This commit is contained in:
parent
431f46b2bb
commit
b2a66c7bc6
@ -27,6 +27,7 @@ namespace Tank.Entites
|
||||
/// Шаг перемещения автомобиля
|
||||
/// </summary>
|
||||
public double Step => (double)Speed * 300 / Weight;
|
||||
public void setBodyColor(Color color) { BodyColor = color; }
|
||||
/// <summary>
|
||||
/// Конструктор с параметрами
|
||||
/// </summary>
|
||||
|
@ -10,6 +10,7 @@ namespace Tank.Entites
|
||||
public class EntityTank : EntityArmoredCar
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
public void setAdditionalColor(Color color) { AdditionalColor = color; }
|
||||
public Color AdditionalColor { get; private set; }
|
||||
// Признак (опция) наличия обвеса
|
||||
public bool BodyKit { get; private set; }
|
||||
|
@ -38,7 +38,28 @@ namespace Tank
|
||||
listBoxStorages.SelectedIndex = index;
|
||||
}
|
||||
}
|
||||
public void AddArmoredCar(DrawingArmoredCar tank)
|
||||
{
|
||||
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ((obj + tank) != false)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowTanks();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
private void ButtonAddArmoredCar_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
@ -50,19 +71,9 @@ namespace Tank
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormTank form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (obj + form.SelectedTank)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowTanks();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
FormTankConfig form = new FormTankConfig();
|
||||
form.AddEvent(AddArmoredCar);
|
||||
form.Show();
|
||||
}
|
||||
|
||||
private void ButtonRemoveArmoredCar_Click(object sender, EventArgs e)
|
||||
|
@ -29,7 +29,7 @@ namespace Tank
|
||||
Bitmap bmp = new(pictureBoxTank.Width,
|
||||
pictureBoxTank.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_Tank.DrawTransport(gr);
|
||||
_Tank?.DrawTransport(gr);
|
||||
pictureBoxTank.Image = bmp;
|
||||
}
|
||||
|
||||
@ -118,7 +118,6 @@ namespace Tank
|
||||
100));
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void buttonStep_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_Tank == null)
|
||||
|
387
Tank/Tank/FormTankConfig.Designer.cs
generated
Normal file
387
Tank/Tank/FormTankConfig.Designer.cs
generated
Normal file
@ -0,0 +1,387 @@
|
||||
namespace Tank
|
||||
{
|
||||
partial class FormTankConfig
|
||||
{
|
||||
/// <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.button_Cancel = new System.Windows.Forms.Button();
|
||||
this.button_Add = new System.Windows.Forms.Button();
|
||||
this.panelColor = new System.Windows.Forms.Panel();
|
||||
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
|
||||
this.labelAdditionalColor = new System.Windows.Forms.Label();
|
||||
this.labelColor = new System.Windows.Forms.Label();
|
||||
this.labelComplexObject = 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.panelSilver = new System.Windows.Forms.Panel();
|
||||
this.panelGray = new System.Windows.Forms.Panel();
|
||||
this.panelBlack = 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.checkBoxLine = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoxBodyKit = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoxTrunk = new System.Windows.Forms.CheckBox();
|
||||
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
|
||||
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
|
||||
this.labelWeigth = new System.Windows.Forms.Label();
|
||||
this.labelSpeed = new System.Windows.Forms.Label();
|
||||
this.groupBoxParameters.SuspendLayout();
|
||||
this.panelColor.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
|
||||
this.groupBoxColors.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBoxParameters
|
||||
//
|
||||
this.groupBoxParameters.Controls.Add(this.button_Cancel);
|
||||
this.groupBoxParameters.Controls.Add(this.button_Add);
|
||||
this.groupBoxParameters.Controls.Add(this.panelColor);
|
||||
this.groupBoxParameters.Controls.Add(this.labelComplexObject);
|
||||
this.groupBoxParameters.Controls.Add(this.labelSimpleObject);
|
||||
this.groupBoxParameters.Controls.Add(this.groupBoxColors);
|
||||
this.groupBoxParameters.Controls.Add(this.checkBoxLine);
|
||||
this.groupBoxParameters.Controls.Add(this.checkBoxBodyKit);
|
||||
this.groupBoxParameters.Controls.Add(this.checkBoxTrunk);
|
||||
this.groupBoxParameters.Controls.Add(this.numericUpDownWeight);
|
||||
this.groupBoxParameters.Controls.Add(this.numericUpDownSpeed);
|
||||
this.groupBoxParameters.Controls.Add(this.labelWeigth);
|
||||
this.groupBoxParameters.Controls.Add(this.labelSpeed);
|
||||
this.groupBoxParameters.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupBoxParameters.Name = "groupBoxParameters";
|
||||
this.groupBoxParameters.Size = new System.Drawing.Size(752, 303);
|
||||
this.groupBoxParameters.TabIndex = 0;
|
||||
this.groupBoxParameters.TabStop = false;
|
||||
this.groupBoxParameters.Text = "Параметры";
|
||||
//
|
||||
// button_Cancel
|
||||
//
|
||||
this.button_Cancel.Location = new System.Drawing.Point(591, 198);
|
||||
this.button_Cancel.Name = "button_Cancel";
|
||||
this.button_Cancel.Size = new System.Drawing.Size(105, 32);
|
||||
this.button_Cancel.TabIndex = 15;
|
||||
this.button_Cancel.Text = "Отмена";
|
||||
this.button_Cancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button_Add
|
||||
//
|
||||
this.button_Add.Location = new System.Drawing.Point(477, 197);
|
||||
this.button_Add.Name = "button_Add";
|
||||
this.button_Add.Size = new System.Drawing.Size(105, 32);
|
||||
this.button_Add.TabIndex = 14;
|
||||
this.button_Add.Text = "Добавить";
|
||||
this.button_Add.UseVisualStyleBackColor = true;
|
||||
this.button_Add.Click += new System.EventHandler(this.button_Add_Click);
|
||||
//
|
||||
// panelColor
|
||||
//
|
||||
this.panelColor.AllowDrop = true;
|
||||
this.panelColor.Controls.Add(this.pictureBoxObject);
|
||||
this.panelColor.Controls.Add(this.labelAdditionalColor);
|
||||
this.panelColor.Controls.Add(this.labelColor);
|
||||
this.panelColor.Location = new System.Drawing.Point(477, 30);
|
||||
this.panelColor.Name = "panelColor";
|
||||
this.panelColor.Size = new System.Drawing.Size(219, 153);
|
||||
this.panelColor.TabIndex = 11;
|
||||
this.panelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
|
||||
this.panelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
this.pictureBoxObject.Location = new System.Drawing.Point(13, 55);
|
||||
this.pictureBoxObject.Name = "pictureBoxObject";
|
||||
this.pictureBoxObject.Size = new System.Drawing.Size(196, 84);
|
||||
this.pictureBoxObject.TabIndex = 10;
|
||||
this.pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// labelAdditionalColor
|
||||
//
|
||||
this.labelAdditionalColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelAdditionalColor.Location = new System.Drawing.Point(114, 10);
|
||||
this.labelAdditionalColor.Name = "labelAdditionalColor";
|
||||
this.labelAdditionalColor.Size = new System.Drawing.Size(95, 32);
|
||||
this.labelAdditionalColor.TabIndex = 13;
|
||||
this.labelAdditionalColor.Text = "Доп.цвет";
|
||||
this.labelAdditionalColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// labelColor
|
||||
//
|
||||
this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelColor.Location = new System.Drawing.Point(13, 10);
|
||||
this.labelColor.Name = "labelColor";
|
||||
this.labelColor.Size = new System.Drawing.Size(95, 32);
|
||||
this.labelColor.TabIndex = 12;
|
||||
this.labelColor.Text = "Цвет";
|
||||
this.labelColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// labelComplexObject
|
||||
//
|
||||
this.labelComplexObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelComplexObject.Location = new System.Drawing.Point(346, 195);
|
||||
this.labelComplexObject.Name = "labelComplexObject";
|
||||
this.labelComplexObject.Size = new System.Drawing.Size(109, 34);
|
||||
this.labelComplexObject.TabIndex = 9;
|
||||
this.labelComplexObject.Text = "Продвинутый";
|
||||
this.labelComplexObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelSimpleObject.Location = new System.Drawing.Point(222, 195);
|
||||
this.labelSimpleObject.Name = "labelSimpleObject";
|
||||
this.labelSimpleObject.Size = new System.Drawing.Size(109, 34);
|
||||
this.labelSimpleObject.TabIndex = 8;
|
||||
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.panelSilver);
|
||||
this.groupBoxColors.Controls.Add(this.panelGray);
|
||||
this.groupBoxColors.Controls.Add(this.panelBlack);
|
||||
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(222, 22);
|
||||
this.groupBoxColors.Name = "groupBoxColors";
|
||||
this.groupBoxColors.Size = new System.Drawing.Size(233, 136);
|
||||
this.groupBoxColors.TabIndex = 7;
|
||||
this.groupBoxColors.TabStop = false;
|
||||
this.groupBoxColors.Text = "Цвета";
|
||||
//
|
||||
// panelWhite
|
||||
//
|
||||
this.panelWhite.BackColor = System.Drawing.Color.White;
|
||||
this.panelWhite.Location = new System.Drawing.Point(178, 63);
|
||||
this.panelWhite.Name = "panelWhite";
|
||||
this.panelWhite.Size = new System.Drawing.Size(48, 35);
|
||||
this.panelWhite.TabIndex = 1;
|
||||
//
|
||||
// panelSilver
|
||||
//
|
||||
this.panelSilver.BackColor = System.Drawing.Color.Silver;
|
||||
this.panelSilver.Location = new System.Drawing.Point(124, 63);
|
||||
this.panelSilver.Name = "panelSilver";
|
||||
this.panelSilver.Size = new System.Drawing.Size(48, 35);
|
||||
this.panelSilver.TabIndex = 1;
|
||||
//
|
||||
// panelGray
|
||||
//
|
||||
this.panelGray.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.panelGray.Location = new System.Drawing.Point(70, 63);
|
||||
this.panelGray.Name = "panelGray";
|
||||
this.panelGray.Size = new System.Drawing.Size(48, 35);
|
||||
this.panelGray.TabIndex = 1;
|
||||
//
|
||||
// panelBlack
|
||||
//
|
||||
this.panelBlack.BackColor = System.Drawing.Color.Black;
|
||||
this.panelBlack.Location = new System.Drawing.Point(16, 63);
|
||||
this.panelBlack.Name = "panelBlack";
|
||||
this.panelBlack.Size = new System.Drawing.Size(48, 35);
|
||||
this.panelBlack.TabIndex = 1;
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
|
||||
this.panelYellow.Location = new System.Drawing.Point(178, 22);
|
||||
this.panelYellow.Name = "panelYellow";
|
||||
this.panelYellow.Size = new System.Drawing.Size(48, 35);
|
||||
this.panelYellow.TabIndex = 1;
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
this.panelBlue.BackColor = System.Drawing.Color.Blue;
|
||||
this.panelBlue.Location = new System.Drawing.Point(124, 22);
|
||||
this.panelBlue.Name = "panelBlue";
|
||||
this.panelBlue.Size = new System.Drawing.Size(48, 35);
|
||||
this.panelBlue.TabIndex = 1;
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
this.panelGreen.BackColor = System.Drawing.Color.Green;
|
||||
this.panelGreen.Location = new System.Drawing.Point(70, 22);
|
||||
this.panelGreen.Name = "panelGreen";
|
||||
this.panelGreen.Size = new System.Drawing.Size(48, 35);
|
||||
this.panelGreen.TabIndex = 1;
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
this.panelRed.BackColor = System.Drawing.Color.Red;
|
||||
this.panelRed.Location = new System.Drawing.Point(16, 22);
|
||||
this.panelRed.Name = "panelRed";
|
||||
this.panelRed.Size = new System.Drawing.Size(48, 35);
|
||||
this.panelRed.TabIndex = 0;
|
||||
//
|
||||
// checkBoxLine
|
||||
//
|
||||
this.checkBoxLine.AutoSize = true;
|
||||
this.checkBoxLine.Location = new System.Drawing.Point(37, 164);
|
||||
this.checkBoxLine.Name = "checkBoxLine";
|
||||
this.checkBoxLine.Size = new System.Drawing.Size(121, 19);
|
||||
this.checkBoxLine.TabIndex = 6;
|
||||
this.checkBoxLine.Text = "Наличие полосы";
|
||||
this.checkBoxLine.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxBodyKit
|
||||
//
|
||||
this.checkBoxBodyKit.AutoSize = true;
|
||||
this.checkBoxBodyKit.Location = new System.Drawing.Point(37, 139);
|
||||
this.checkBoxBodyKit.Name = "checkBoxBodyKit";
|
||||
this.checkBoxBodyKit.Size = new System.Drawing.Size(116, 19);
|
||||
this.checkBoxBodyKit.TabIndex = 5;
|
||||
this.checkBoxBodyKit.Text = "Наличие обвеса";
|
||||
this.checkBoxBodyKit.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxTrunk
|
||||
//
|
||||
this.checkBoxTrunk.AutoSize = true;
|
||||
this.checkBoxTrunk.Location = new System.Drawing.Point(37, 114);
|
||||
this.checkBoxTrunk.Name = "checkBoxTrunk";
|
||||
this.checkBoxTrunk.Size = new System.Drawing.Size(137, 19);
|
||||
this.checkBoxTrunk.TabIndex = 4;
|
||||
this.checkBoxTrunk.Text = "Наличие багажника";
|
||||
this.checkBoxTrunk.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
this.numericUpDownWeight.Location = new System.Drawing.Point(115, 72);
|
||||
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(77, 23);
|
||||
this.numericUpDownWeight.TabIndex = 3;
|
||||
this.numericUpDownWeight.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
this.numericUpDownSpeed.Location = new System.Drawing.Point(115, 40);
|
||||
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(77, 23);
|
||||
this.numericUpDownSpeed.TabIndex = 2;
|
||||
this.numericUpDownSpeed.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// labelWeigth
|
||||
//
|
||||
this.labelWeigth.AutoSize = true;
|
||||
this.labelWeigth.Location = new System.Drawing.Point(37, 74);
|
||||
this.labelWeigth.Name = "labelWeigth";
|
||||
this.labelWeigth.Size = new System.Drawing.Size(26, 15);
|
||||
this.labelWeigth.TabIndex = 1;
|
||||
this.labelWeigth.Text = "Вес";
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
this.labelSpeed.AutoSize = true;
|
||||
this.labelSpeed.Location = new System.Drawing.Point(37, 40);
|
||||
this.labelSpeed.Name = "labelSpeed";
|
||||
this.labelSpeed.Size = new System.Drawing.Size(59, 15);
|
||||
this.labelSpeed.TabIndex = 0;
|
||||
this.labelSpeed.Text = "Скорость";
|
||||
//
|
||||
// FormTankConfig
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.groupBoxParameters);
|
||||
this.Name = "FormTankConfig";
|
||||
this.Text = "FormTankConfig";
|
||||
this.groupBoxParameters.ResumeLayout(false);
|
||||
this.groupBoxParameters.PerformLayout();
|
||||
this.panelColor.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
|
||||
this.groupBoxColors.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxParameters;
|
||||
private CheckBox checkBoxLine;
|
||||
private CheckBox checkBoxBodyKit;
|
||||
private CheckBox checkBoxTrunk;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private Label labelWeigth;
|
||||
private Label labelSpeed;
|
||||
private GroupBox groupBoxColors;
|
||||
private Panel panelWhite;
|
||||
private Panel panelSilver;
|
||||
private Panel panelGray;
|
||||
private Panel panelBlack;
|
||||
private Panel panelYellow;
|
||||
private Panel panelBlue;
|
||||
private Panel panelGreen;
|
||||
private Panel panelRed;
|
||||
private Label labelComplexObject;
|
||||
private Label labelSimpleObject;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Button button_Cancel;
|
||||
private Button button_Add;
|
||||
private Label labelAdditionalColor;
|
||||
private Label labelColor;
|
||||
private Panel panelColor;
|
||||
}
|
||||
}
|
137
Tank/Tank/FormTankConfig.cs
Normal file
137
Tank/Tank/FormTankConfig.cs
Normal file
@ -0,0 +1,137 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Tank.DrawingObjects;
|
||||
using Tank.Entites;
|
||||
|
||||
namespace Tank
|
||||
{
|
||||
public partial class FormTankConfig : Form
|
||||
{
|
||||
|
||||
DrawingArmoredCar? _Tank = null;
|
||||
|
||||
private event Action<DrawingArmoredCar> EventAddTank;
|
||||
|
||||
|
||||
public FormTankConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelRed.MouseDown += panelColor_MouseDown;
|
||||
panelGreen.MouseDown += panelColor_MouseDown;
|
||||
panelBlue.MouseDown += panelColor_MouseDown;
|
||||
panelYellow.MouseDown += panelColor_MouseDown;
|
||||
panelBlack.MouseDown += panelColor_MouseDown;
|
||||
panelGray.MouseDown += panelColor_MouseDown;
|
||||
panelSilver.MouseDown += panelColor_MouseDown;
|
||||
panelWhite.MouseDown += panelColor_MouseDown;
|
||||
|
||||
button_Cancel.Click += (s, e) => Close();
|
||||
}
|
||||
private void DrawTank()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_Tank?.SetPosition(5, 5);
|
||||
_Tank?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
internal void AddEvent(Action<DrawingArmoredCar> eventAdd)
|
||||
{
|
||||
if (EventAddTank == null)
|
||||
{
|
||||
EventAddTank = eventAdd;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddTank += eventAdd;
|
||||
}
|
||||
}
|
||||
private void panelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
private void labelColor_dragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
private void labelColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_Tank == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
((Label)sender).BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||
switch (((Label)sender).Name)
|
||||
{
|
||||
case "labelColor":
|
||||
_Tank.Tank.setBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||
break;
|
||||
case "labelAdditionalColor":
|
||||
if (!(_Tank is DrawingTank))
|
||||
return;
|
||||
(_Tank.Tank as EntityTank).setAdditionalColor((Color)e.Data.GetData(typeof(Color)));
|
||||
break;
|
||||
}
|
||||
DrawTank();
|
||||
}
|
||||
|
||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name,
|
||||
DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "labelSimpleObject":
|
||||
_Tank = new DrawingArmoredCar((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
|
||||
pictureBoxObject.Height);
|
||||
break;
|
||||
case "labelComplexObject":
|
||||
_Tank = new DrawingTank((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxTrunk.Checked,
|
||||
checkBoxBodyKit.Checked, checkBoxLine.Checked, pictureBoxObject.Width,
|
||||
pictureBoxObject.Height);
|
||||
break;
|
||||
}
|
||||
DrawTank();
|
||||
}
|
||||
|
||||
private void button_Add_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddTank?.Invoke(_Tank);
|
||||
Close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
60
Tank/Tank/FormTankConfig.resx
Normal file
60
Tank/Tank/FormTankConfig.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…
x
Reference in New Issue
Block a user