Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 07f181560c | |||
| c6dd512670 | |||
| fbef71ec0b | |||
| be78034cce | |||
| 5ed0f353cd | |||
| 4b35bb8677 | |||
| df129f6eab | |||
| 5859a15b9d | |||
| dba4e885f9 | |||
| 4876d76488 | |||
| 26ab064025 | |||
| 5d57863fde | |||
| 9e6feca9ab | |||
| 6c1ba48d5c | |||
| bb3ec87411 | |||
| 3664eed949 | |||
| 20616550bc | |||
| 24e3b1ac19 | |||
| a4072a3348 | |||
| 1868d30d50 | |||
| 55fd52996a | |||
| a0bdea876b | |||
| b85628c4e6 | |||
| bbd11c3210 | |||
| c5828dace3 | |||
| 1f5d796785 |
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ArmoredCar
|
namespace ArmoredCar
|
||||||
{
|
{
|
||||||
enum Direction
|
public enum Direction
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
Up = 1,
|
Up = 1,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ArmoredCar
|
namespace ArmoredCar
|
||||||
{
|
{
|
||||||
internal class DrawningArmoredCar
|
public class DrawningArmoredCar
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Класс-сущность
|
/// Класс-сущность
|
||||||
@@ -177,5 +177,9 @@ namespace ArmoredCar
|
|||||||
{
|
{
|
||||||
return (_startPosX, _startPosX + _carWidth, _startPosY, _startPosY + _carHeight);
|
return (_startPosX, _startPosX + _carWidth, _startPosY, _startPosY + _carHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void setColor(Color color) {
|
||||||
|
ArmoredCar = new EntityArmoredCar(ArmoredCar.Speed, ArmoredCar.Weight, color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,15 @@ namespace ArmoredCar
|
|||||||
base.DrawTransport(g);
|
base.DrawTransport(g);
|
||||||
_startPosY -= 10;
|
_startPosY -= 10;
|
||||||
}
|
}
|
||||||
|
public override void setColor(Color color)
|
||||||
|
{
|
||||||
|
ArmoredCar = new EntityTank(ArmoredCar.Speed, ArmoredCar.Weight, color,
|
||||||
|
(ArmoredCar as EntityTank).DopColor, (ArmoredCar as EntityTank).TowerWeapon, (ArmoredCar as EntityTank).AMachineGun);
|
||||||
|
}
|
||||||
|
public void setDopColor(Color color)
|
||||||
|
{
|
||||||
|
ArmoredCar = new EntityTank(ArmoredCar.Speed, ArmoredCar.Weight, ArmoredCar.BodyColor,
|
||||||
|
color, (ArmoredCar as EntityTank).TowerWeapon, (ArmoredCar as EntityTank).AMachineGun);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using System.Text;
|
|||||||
|
|
||||||
namespace ArmoredCar
|
namespace ArmoredCar
|
||||||
{
|
{
|
||||||
internal class EntityArmoredCar
|
public class EntityArmoredCar
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Скорость
|
/// Скорость
|
||||||
|
|||||||
383
ArmoredCar/ArmoredCar/FormArmoredCarConfig.Designer.cs
generated
Normal file
383
ArmoredCar/ArmoredCar/FormArmoredCarConfig.Designer.cs
generated
Normal file
@@ -0,0 +1,383 @@
|
|||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace ArmoredCar
|
||||||
|
{
|
||||||
|
partial class FormArmoredCarConfig
|
||||||
|
{
|
||||||
|
/// <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.groupBoxConfig = new System.Windows.Forms.GroupBox();
|
||||||
|
this.labelModifiedObject = new System.Windows.Forms.Label();
|
||||||
|
this.labelSimpleObject = new System.Windows.Forms.Label();
|
||||||
|
this.groupBoxColors = new System.Windows.Forms.GroupBox();
|
||||||
|
this.panelPurple = new System.Windows.Forms.Panel();
|
||||||
|
this.panelYellow = new System.Windows.Forms.Panel();
|
||||||
|
this.panelBlack = new System.Windows.Forms.Panel();
|
||||||
|
this.panelBlue = new System.Windows.Forms.Panel();
|
||||||
|
this.panelGray = 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.checkBoxAMachineGun = new System.Windows.Forms.CheckBox();
|
||||||
|
this.checkBoxTowerWeapon = new System.Windows.Forms.CheckBox();
|
||||||
|
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.labelWeight = new System.Windows.Forms.Label();
|
||||||
|
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.labelSpeed = new System.Windows.Forms.Label();
|
||||||
|
this.panelObject = new System.Windows.Forms.Panel();
|
||||||
|
this.labelDopColor = new System.Windows.Forms.Label();
|
||||||
|
this.labelBaseColor = new System.Windows.Forms.Label();
|
||||||
|
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.buttonOk = new System.Windows.Forms.Button();
|
||||||
|
this.groupBoxConfig.SuspendLayout();
|
||||||
|
this.groupBoxColors.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
|
||||||
|
this.panelObject.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// groupBoxConfig
|
||||||
|
//
|
||||||
|
this.groupBoxConfig.Controls.Add(this.labelModifiedObject);
|
||||||
|
this.groupBoxConfig.Controls.Add(this.labelSimpleObject);
|
||||||
|
this.groupBoxConfig.Controls.Add(this.groupBoxColors);
|
||||||
|
this.groupBoxConfig.Controls.Add(this.checkBoxAMachineGun);
|
||||||
|
this.groupBoxConfig.Controls.Add(this.checkBoxTowerWeapon);
|
||||||
|
this.groupBoxConfig.Controls.Add(this.numericUpDownWeight);
|
||||||
|
this.groupBoxConfig.Controls.Add(this.labelWeight);
|
||||||
|
this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed);
|
||||||
|
this.groupBoxConfig.Controls.Add(this.labelSpeed);
|
||||||
|
this.groupBoxConfig.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.groupBoxConfig.Name = "groupBoxConfig";
|
||||||
|
this.groupBoxConfig.Size = new System.Drawing.Size(520, 220);
|
||||||
|
this.groupBoxConfig.TabIndex = 0;
|
||||||
|
this.groupBoxConfig.TabStop = false;
|
||||||
|
this.groupBoxConfig.Text = "Параметры";
|
||||||
|
//
|
||||||
|
// labelModifiedObject
|
||||||
|
//
|
||||||
|
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.labelModifiedObject.Location = new System.Drawing.Point(394, 162);
|
||||||
|
this.labelModifiedObject.Name = "labelModifiedObject";
|
||||||
|
this.labelModifiedObject.Size = new System.Drawing.Size(97, 38);
|
||||||
|
this.labelModifiedObject.TabIndex = 16;
|
||||||
|
this.labelModifiedObject.Text = "Продвинутый";
|
||||||
|
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
|
this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
|
||||||
|
//
|
||||||
|
// labelSimpleObject
|
||||||
|
//
|
||||||
|
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.labelSimpleObject.Location = new System.Drawing.Point(282, 162);
|
||||||
|
this.labelSimpleObject.Name = "labelSimpleObject";
|
||||||
|
this.labelSimpleObject.Size = new System.Drawing.Size(97, 38);
|
||||||
|
this.labelSimpleObject.TabIndex = 15;
|
||||||
|
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.panelPurple);
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelYellow);
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelBlack);
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelBlue);
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelGray);
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelGreen);
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelWhite);
|
||||||
|
this.groupBoxColors.Controls.Add(this.panelRed);
|
||||||
|
this.groupBoxColors.Location = new System.Drawing.Point(267, 22);
|
||||||
|
this.groupBoxColors.Name = "groupBoxColors";
|
||||||
|
this.groupBoxColors.Size = new System.Drawing.Size(241, 127);
|
||||||
|
this.groupBoxColors.TabIndex = 14;
|
||||||
|
this.groupBoxColors.TabStop = false;
|
||||||
|
this.groupBoxColors.Text = "Цвета";
|
||||||
|
//
|
||||||
|
// panelPurple
|
||||||
|
//
|
||||||
|
this.panelPurple.BackColor = System.Drawing.Color.Purple;
|
||||||
|
this.panelPurple.Location = new System.Drawing.Point(184, 73);
|
||||||
|
this.panelPurple.Name = "panelPurple";
|
||||||
|
this.panelPurple.Size = new System.Drawing.Size(40, 40);
|
||||||
|
this.panelPurple.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// panelYellow
|
||||||
|
//
|
||||||
|
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
|
||||||
|
this.panelYellow.Location = new System.Drawing.Point(184, 22);
|
||||||
|
this.panelYellow.Name = "panelYellow";
|
||||||
|
this.panelYellow.Size = new System.Drawing.Size(40, 40);
|
||||||
|
this.panelYellow.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelBlack
|
||||||
|
//
|
||||||
|
this.panelBlack.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.panelBlack.Location = new System.Drawing.Point(127, 73);
|
||||||
|
this.panelBlack.Name = "panelBlack";
|
||||||
|
this.panelBlack.Size = new System.Drawing.Size(40, 40);
|
||||||
|
this.panelBlack.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// panelBlue
|
||||||
|
//
|
||||||
|
this.panelBlue.BackColor = System.Drawing.Color.Blue;
|
||||||
|
this.panelBlue.Location = new System.Drawing.Point(127, 22);
|
||||||
|
this.panelBlue.Name = "panelBlue";
|
||||||
|
this.panelBlue.Size = new System.Drawing.Size(40, 40);
|
||||||
|
this.panelBlue.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelGray
|
||||||
|
//
|
||||||
|
this.panelGray.BackColor = System.Drawing.Color.Gray;
|
||||||
|
this.panelGray.Location = new System.Drawing.Point(72, 73);
|
||||||
|
this.panelGray.Name = "panelGray";
|
||||||
|
this.panelGray.Size = new System.Drawing.Size(40, 40);
|
||||||
|
this.panelGray.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// panelGreen
|
||||||
|
//
|
||||||
|
this.panelGreen.BackColor = System.Drawing.Color.Green;
|
||||||
|
this.panelGreen.Location = new System.Drawing.Point(72, 22);
|
||||||
|
this.panelGreen.Name = "panelGreen";
|
||||||
|
this.panelGreen.Size = new System.Drawing.Size(40, 40);
|
||||||
|
this.panelGreen.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panelWhite
|
||||||
|
//
|
||||||
|
this.panelWhite.BackColor = System.Drawing.Color.White;
|
||||||
|
this.panelWhite.Location = new System.Drawing.Point(15, 73);
|
||||||
|
this.panelWhite.Name = "panelWhite";
|
||||||
|
this.panelWhite.Size = new System.Drawing.Size(40, 40);
|
||||||
|
this.panelWhite.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// panelRed
|
||||||
|
//
|
||||||
|
this.panelRed.BackColor = System.Drawing.Color.Red;
|
||||||
|
this.panelRed.Location = new System.Drawing.Point(15, 22);
|
||||||
|
this.panelRed.Name = "panelRed";
|
||||||
|
this.panelRed.Size = new System.Drawing.Size(40, 40);
|
||||||
|
this.panelRed.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// checkBoxAMachineGun
|
||||||
|
//
|
||||||
|
this.checkBoxAMachineGun.AutoSize = true;
|
||||||
|
this.checkBoxAMachineGun.Location = new System.Drawing.Point(22, 149);
|
||||||
|
this.checkBoxAMachineGun.Name = "checkBoxAMachineGun";
|
||||||
|
this.checkBoxAMachineGun.Size = new System.Drawing.Size(237, 19);
|
||||||
|
this.checkBoxAMachineGun.TabIndex = 12;
|
||||||
|
this.checkBoxAMachineGun.Text = "Признак наличия зенитного пулемета";
|
||||||
|
this.checkBoxAMachineGun.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxTowerWeapon
|
||||||
|
//
|
||||||
|
this.checkBoxTowerWeapon.AutoSize = true;
|
||||||
|
this.checkBoxTowerWeapon.Location = new System.Drawing.Point(22, 115);
|
||||||
|
this.checkBoxTowerWeapon.Name = "checkBoxTowerWeapon";
|
||||||
|
this.checkBoxTowerWeapon.Size = new System.Drawing.Size(221, 19);
|
||||||
|
this.checkBoxTowerWeapon.TabIndex = 11;
|
||||||
|
this.checkBoxTowerWeapon.Text = "Признак наличия орудия на башне";
|
||||||
|
this.checkBoxTowerWeapon.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// numericUpDownWeight
|
||||||
|
//
|
||||||
|
this.numericUpDownWeight.Location = new System.Drawing.Point(90, 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(79, 23);
|
||||||
|
this.numericUpDownWeight.TabIndex = 10;
|
||||||
|
this.numericUpDownWeight.Value = new decimal(new int[] {
|
||||||
|
100,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
//
|
||||||
|
// labelWeight
|
||||||
|
//
|
||||||
|
this.labelWeight.AutoSize = true;
|
||||||
|
this.labelWeight.Location = new System.Drawing.Point(22, 74);
|
||||||
|
this.labelWeight.Name = "labelWeight";
|
||||||
|
this.labelWeight.Size = new System.Drawing.Size(29, 15);
|
||||||
|
this.labelWeight.TabIndex = 9;
|
||||||
|
this.labelWeight.Text = "Вес:";
|
||||||
|
//
|
||||||
|
// numericUpDownSpeed
|
||||||
|
//
|
||||||
|
this.numericUpDownSpeed.Location = new System.Drawing.Point(90, 30);
|
||||||
|
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(79, 23);
|
||||||
|
this.numericUpDownSpeed.TabIndex = 8;
|
||||||
|
this.numericUpDownSpeed.Value = new decimal(new int[] {
|
||||||
|
100,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
//
|
||||||
|
// labelSpeed
|
||||||
|
//
|
||||||
|
this.labelSpeed.AutoSize = true;
|
||||||
|
this.labelSpeed.Location = new System.Drawing.Point(22, 32);
|
||||||
|
this.labelSpeed.Name = "labelSpeed";
|
||||||
|
this.labelSpeed.Size = new System.Drawing.Size(62, 15);
|
||||||
|
this.labelSpeed.TabIndex = 7;
|
||||||
|
this.labelSpeed.Text = "Скорость:";
|
||||||
|
//
|
||||||
|
// panelObject
|
||||||
|
//
|
||||||
|
this.panelObject.AllowDrop = true;
|
||||||
|
this.panelObject.Controls.Add(this.labelDopColor);
|
||||||
|
this.panelObject.Controls.Add(this.labelBaseColor);
|
||||||
|
this.panelObject.Controls.Add(this.pictureBoxObject);
|
||||||
|
this.panelObject.Location = new System.Drawing.Point(538, 12);
|
||||||
|
this.panelObject.Name = "panelObject";
|
||||||
|
this.panelObject.Size = new System.Drawing.Size(262, 184);
|
||||||
|
this.panelObject.TabIndex = 2;
|
||||||
|
this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
|
||||||
|
this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
|
||||||
|
//
|
||||||
|
// labelDopColor
|
||||||
|
//
|
||||||
|
this.labelDopColor.AllowDrop = true;
|
||||||
|
this.labelDopColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.labelDopColor.Location = new System.Drawing.Point(141, 9);
|
||||||
|
this.labelDopColor.Name = "labelDopColor";
|
||||||
|
this.labelDopColor.Size = new System.Drawing.Size(104, 32);
|
||||||
|
this.labelDopColor.TabIndex = 2;
|
||||||
|
this.labelDopColor.Text = "Доп. цвет";
|
||||||
|
this.labelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
|
this.labelDopColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragDrop);
|
||||||
|
this.labelDopColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
|
||||||
|
//
|
||||||
|
// labelBaseColor
|
||||||
|
//
|
||||||
|
this.labelBaseColor.AllowDrop = true;
|
||||||
|
this.labelBaseColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.labelBaseColor.Location = new System.Drawing.Point(20, 9);
|
||||||
|
this.labelBaseColor.Name = "labelBaseColor";
|
||||||
|
this.labelBaseColor.Size = new System.Drawing.Size(104, 32);
|
||||||
|
this.labelBaseColor.TabIndex = 1;
|
||||||
|
this.labelBaseColor.Text = "Цвет";
|
||||||
|
this.labelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
|
this.labelBaseColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragDrop);
|
||||||
|
this.labelBaseColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
|
||||||
|
//
|
||||||
|
// pictureBoxObject
|
||||||
|
//
|
||||||
|
this.pictureBoxObject.Location = new System.Drawing.Point(20, 44);
|
||||||
|
this.pictureBoxObject.Name = "pictureBoxObject";
|
||||||
|
this.pictureBoxObject.Size = new System.Drawing.Size(225, 125);
|
||||||
|
this.pictureBoxObject.TabIndex = 0;
|
||||||
|
this.pictureBoxObject.TabStop = false;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(679, 202);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(104, 30);
|
||||||
|
this.buttonCancel.TabIndex = 5;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// buttonOk
|
||||||
|
//
|
||||||
|
this.buttonOk.Location = new System.Drawing.Point(558, 202);
|
||||||
|
this.buttonOk.Name = "buttonOk";
|
||||||
|
this.buttonOk.Size = new System.Drawing.Size(104, 30);
|
||||||
|
this.buttonOk.TabIndex = 4;
|
||||||
|
this.buttonOk.Text = "Добавить";
|
||||||
|
this.buttonOk.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonOk.Click += new System.EventHandler(this.ButtonOk_Click);
|
||||||
|
//
|
||||||
|
// FormArmoredCarConfig
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(810, 242);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonOk);
|
||||||
|
this.Controls.Add(this.panelObject);
|
||||||
|
this.Controls.Add(this.groupBoxConfig);
|
||||||
|
this.Name = "FormArmoredCarConfig";
|
||||||
|
this.Text = "Создание объекта";
|
||||||
|
this.groupBoxConfig.ResumeLayout(false);
|
||||||
|
this.groupBoxConfig.PerformLayout();
|
||||||
|
this.groupBoxColors.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
|
||||||
|
this.panelObject.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private GroupBox groupBoxConfig;
|
||||||
|
private CheckBox checkBoxAMachineGun;
|
||||||
|
private CheckBox checkBoxTowerWeapon;
|
||||||
|
private NumericUpDown numericUpDownWeight;
|
||||||
|
private Label labelWeight;
|
||||||
|
private NumericUpDown numericUpDownSpeed;
|
||||||
|
private Label labelSpeed;
|
||||||
|
private Label labelModifiedObject;
|
||||||
|
private Label labelSimpleObject;
|
||||||
|
private GroupBox groupBoxColors;
|
||||||
|
private Panel panelPurple;
|
||||||
|
private Panel panelYellow;
|
||||||
|
private Panel panelBlack;
|
||||||
|
private Panel panelBlue;
|
||||||
|
private Panel panelGray;
|
||||||
|
private Panel panelGreen;
|
||||||
|
private Panel panelWhite;
|
||||||
|
private Panel panelRed;
|
||||||
|
private Panel panelObject;
|
||||||
|
private Label labelDopColor;
|
||||||
|
private Label labelBaseColor;
|
||||||
|
private PictureBox pictureBoxObject;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonOk;
|
||||||
|
}
|
||||||
|
}
|
||||||
174
ArmoredCar/ArmoredCar/FormArmoredCarConfig.cs
Normal file
174
ArmoredCar/ArmoredCar/FormArmoredCarConfig.cs
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace ArmoredCar
|
||||||
|
{
|
||||||
|
public partial class FormArmoredCarConfig : Form
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Переменная-выбранная бронемашина
|
||||||
|
/// </summary>
|
||||||
|
DrawningArmoredCar _armoredCar = null;
|
||||||
|
/// <summary>
|
||||||
|
/// Событие
|
||||||
|
/// </summary>
|
||||||
|
private event Action<DrawningArmoredCar> EventAddCar;
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
public FormArmoredCarConfig()
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
buttonCancel.Click += (s, e) => Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Отрисовать бронемашину
|
||||||
|
/// </summary>
|
||||||
|
private void DrawArmoredCar()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_armoredCar?.SetPosition(5, 5, pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
_armoredCar?.DrawTransport(gr);
|
||||||
|
pictureBoxObject.Image = bmp;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление события
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ev"></param>
|
||||||
|
public void AddEvent(Action<DrawningArmoredCar> ev)
|
||||||
|
{
|
||||||
|
if (EventAddCar == null)
|
||||||
|
{
|
||||||
|
EventAddCar = new Action<DrawningArmoredCar>(ev);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EventAddCar += 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))
|
||||||
|
{
|
||||||
|
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":
|
||||||
|
_armoredCar = new DrawningArmoredCar((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White);
|
||||||
|
break;
|
||||||
|
case "labelModifiedObject":
|
||||||
|
_armoredCar = new DrawningTank((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black,
|
||||||
|
checkBoxTowerWeapon.Checked, checkBoxAMachineGun.Checked);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
DrawArmoredCar();
|
||||||
|
}
|
||||||
|
/// <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_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 LabelBaseColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_armoredCar != null) {
|
||||||
|
_armoredCar.setColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
DrawArmoredCar();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Принимаем дополнительный цвет
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
if (_armoredCar is not DrawningTank tank)
|
||||||
|
return;
|
||||||
|
|
||||||
|
tank.setDopColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
DrawArmoredCar();
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление бронемашины
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonOk_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
EventAddCar?.Invoke(_armoredCar);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -57,7 +57,4 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 17</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
</root>
|
||||||
28
ArmoredCar/ArmoredCar/FormCar.Designer.cs
generated
28
ArmoredCar/ArmoredCar/FormCar.Designer.cs
generated
@@ -39,6 +39,8 @@ namespace ArmoredCar
|
|||||||
this.buttonLeft = new System.Windows.Forms.Button();
|
this.buttonLeft = new System.Windows.Forms.Button();
|
||||||
this.buttonDown = new System.Windows.Forms.Button();
|
this.buttonDown = new System.Windows.Forms.Button();
|
||||||
this.buttonRight = new System.Windows.Forms.Button();
|
this.buttonRight = new System.Windows.Forms.Button();
|
||||||
|
this.buttonSelectArmoredCar = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCreateModif = new System.Windows.Forms.Button();
|
||||||
this.statusStrip1.SuspendLayout();
|
this.statusStrip1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@@ -144,11 +146,35 @@ namespace ArmoredCar
|
|||||||
this.buttonRight.UseVisualStyleBackColor = true;
|
this.buttonRight.UseVisualStyleBackColor = true;
|
||||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
//
|
//
|
||||||
|
// buttonSelectArmoredCar
|
||||||
|
//
|
||||||
|
this.buttonSelectArmoredCar.Location = new System.Drawing.Point(545, 382);
|
||||||
|
this.buttonSelectArmoredCar.Name = "buttonSelectArmoredCar";
|
||||||
|
this.buttonSelectArmoredCar.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonSelectArmoredCar.TabIndex = 12;
|
||||||
|
this.buttonSelectArmoredCar.Text = "Выбрать";
|
||||||
|
this.buttonSelectArmoredCar.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSelectArmoredCar.Click += new System.EventHandler(this.buttonSelectArmoredCar_Click);
|
||||||
|
//
|
||||||
|
// buttonCreateModif
|
||||||
|
//
|
||||||
|
this.buttonCreateModif.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.buttonCreateModif.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||||
|
this.buttonCreateModif.Location = new System.Drawing.Point(148, 382);
|
||||||
|
this.buttonCreateModif.Name = "buttonCreateModif";
|
||||||
|
this.buttonCreateModif.Size = new System.Drawing.Size(109, 23);
|
||||||
|
this.buttonCreateModif.TabIndex = 13;
|
||||||
|
this.buttonCreateModif.Text = "Модификация";
|
||||||
|
this.buttonCreateModif.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCreateModif.Click += new System.EventHandler(this.buttonCreateModif_Click);
|
||||||
|
//
|
||||||
// FormCar
|
// FormCar
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Controls.Add(this.buttonCreateModif);
|
||||||
|
this.Controls.Add(this.buttonSelectArmoredCar);
|
||||||
this.Controls.Add(this.buttonRight);
|
this.Controls.Add(this.buttonRight);
|
||||||
this.Controls.Add(this.buttonDown);
|
this.Controls.Add(this.buttonDown);
|
||||||
this.Controls.Add(this.buttonLeft);
|
this.Controls.Add(this.buttonLeft);
|
||||||
@@ -178,6 +204,8 @@ namespace ArmoredCar
|
|||||||
private System.Windows.Forms.Button buttonLeft;
|
private System.Windows.Forms.Button buttonLeft;
|
||||||
private System.Windows.Forms.Button buttonDown;
|
private System.Windows.Forms.Button buttonDown;
|
||||||
private System.Windows.Forms.Button buttonRight;
|
private System.Windows.Forms.Button buttonRight;
|
||||||
|
private System.Windows.Forms.Button buttonSelectArmoredCar;
|
||||||
|
private System.Windows.Forms.Button buttonCreateModif;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ namespace ArmoredCar
|
|||||||
{
|
{
|
||||||
private DrawningArmoredCar _car;
|
private DrawningArmoredCar _car;
|
||||||
|
|
||||||
|
public DrawningArmoredCar SelectedCar { get; private set; }
|
||||||
|
|
||||||
public FormCar()
|
public FormCar()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -28,6 +30,16 @@ namespace ArmoredCar
|
|||||||
_car?.DrawTransport(gr);
|
_car?.DrawTransport(gr);
|
||||||
pictureBoxCar.Image = bmp;
|
pictureBoxCar.Image = bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetData()
|
||||||
|
{
|
||||||
|
Random rnd = new();
|
||||||
|
_car.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxCar.Width, pictureBoxCar.Height);
|
||||||
|
toolStripStatusLabelSpeed.Text = $"Скорость: {_car.ArmoredCar.Speed}";
|
||||||
|
toolStripStatusLabelWeight.Text = $"Вес: {_car.ArmoredCar.Weight}";
|
||||||
|
toolStripStatusLabelBodyColor.Text = $"Цвет: {_car.ArmoredCar.BodyColor.Name}";
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Обработка нажатия кнопки "Создать"
|
/// Обработка нажатия кнопки "Создать"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -36,13 +48,14 @@ namespace ArmoredCar
|
|||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
_car = new DrawningArmoredCar(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
ColorDialog dialog = new();
|
||||||
_car.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxCar.Width, pictureBoxCar.Height);
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
toolStripStatusLabelSpeed.Text = $"Скорость: {_car.ArmoredCar.Speed}";
|
color = dialog.Color;
|
||||||
toolStripStatusLabelWeight.Text = $"Вес: {_car.ArmoredCar.Weight}";
|
}
|
||||||
toolStripStatusLabelBodyColor.Text = $"Цвет: { _car.ArmoredCar.BodyColor.Name}";
|
_car = new DrawningArmoredCar(rnd.Next(100, 300), rnd.Next(1000, 2000), color);
|
||||||
|
SetData();
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -81,5 +94,37 @@ namespace ArmoredCar
|
|||||||
_car?.ChangeBorders(pictureBoxCar.Width, pictureBoxCar.Height);
|
_car?.ChangeBorders(pictureBoxCar.Width, pictureBoxCar.Height);
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void buttonSelectArmoredCar_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_car != null) {
|
||||||
|
SelectedCar = _car;
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCreateModif_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Random rnd = new();
|
||||||
|
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||||
|
ColorDialog dialog = new();
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
color = dialog.Color;
|
||||||
|
}
|
||||||
|
Color dopColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||||
|
ColorDialog dialogDop = new();
|
||||||
|
if (dialogDop.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
dopColor = dialogDop.Color;
|
||||||
|
}
|
||||||
|
_car = new DrawningTank(rnd.Next(100, 300), rnd.Next(1000, 2000), color, dopColor,
|
||||||
|
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||||
|
SetData();
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
212
ArmoredCar/ArmoredCar/FormMap.Designer.cs
generated
212
ArmoredCar/ArmoredCar/FormMap.Designer.cs
generated
@@ -1,212 +0,0 @@
|
|||||||
|
|
||||||
namespace ArmoredCar
|
|
||||||
{
|
|
||||||
partial class FormMap
|
|
||||||
{
|
|
||||||
/// <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.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
|
||||||
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
|
|
||||||
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
|
|
||||||
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
|
|
||||||
this.pictureBoxCar = new System.Windows.Forms.PictureBox();
|
|
||||||
this.button1 = new System.Windows.Forms.Button();
|
|
||||||
this.buttonUp = new System.Windows.Forms.Button();
|
|
||||||
this.buttonLeft = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDown = new System.Windows.Forms.Button();
|
|
||||||
this.buttonRight = new System.Windows.Forms.Button();
|
|
||||||
this.button2 = new System.Windows.Forms.Button();
|
|
||||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
|
||||||
this.statusStrip1.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// statusStrip1
|
|
||||||
//
|
|
||||||
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
|
||||||
this.toolStripStatusLabelSpeed,
|
|
||||||
this.toolStripStatusLabelWeight,
|
|
||||||
this.toolStripStatusLabelBodyColor});
|
|
||||||
this.statusStrip1.Location = new System.Drawing.Point(0, 428);
|
|
||||||
this.statusStrip1.Name = "statusStrip1";
|
|
||||||
this.statusStrip1.Size = new System.Drawing.Size(800, 22);
|
|
||||||
this.statusStrip1.TabIndex = 0;
|
|
||||||
this.statusStrip1.Text = "statusStrip1";
|
|
||||||
//
|
|
||||||
// toolStripStatusLabelSpeed
|
|
||||||
//
|
|
||||||
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
|
|
||||||
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(62, 17);
|
|
||||||
this.toolStripStatusLabelSpeed.Text = "Скорость:";
|
|
||||||
//
|
|
||||||
// toolStripStatusLabelWeight
|
|
||||||
//
|
|
||||||
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
|
|
||||||
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(32, 17);
|
|
||||||
this.toolStripStatusLabelWeight.Text = "Вес: ";
|
|
||||||
//
|
|
||||||
// toolStripStatusLabelBodyColor
|
|
||||||
//
|
|
||||||
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
|
|
||||||
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(36, 17);
|
|
||||||
this.toolStripStatusLabelBodyColor.Text = "Цвет:";
|
|
||||||
//
|
|
||||||
// pictureBoxCar
|
|
||||||
//
|
|
||||||
this.pictureBoxCar.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
||||||
this.pictureBoxCar.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.pictureBoxCar.Name = "pictureBoxCar";
|
|
||||||
this.pictureBoxCar.Size = new System.Drawing.Size(800, 428);
|
|
||||||
this.pictureBoxCar.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
|
||||||
this.pictureBoxCar.TabIndex = 6;
|
|
||||||
this.pictureBoxCar.TabStop = false;
|
|
||||||
//
|
|
||||||
// button1
|
|
||||||
//
|
|
||||||
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.button1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
|
||||||
this.button1.Location = new System.Drawing.Point(42, 382);
|
|
||||||
this.button1.Name = "button1";
|
|
||||||
this.button1.Size = new System.Drawing.Size(75, 23);
|
|
||||||
this.button1.TabIndex = 7;
|
|
||||||
this.button1.Text = "Создать";
|
|
||||||
this.button1.UseVisualStyleBackColor = true;
|
|
||||||
this.button1.Click += new System.EventHandler(this.ButtonCreate_Click);
|
|
||||||
//
|
|
||||||
// buttonUp
|
|
||||||
//
|
|
||||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonUp.BackgroundImage = global::ArmoredCar.Properties.Resources.Up;
|
|
||||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
|
||||||
this.buttonUp.Location = new System.Drawing.Point(692, 324);
|
|
||||||
this.buttonUp.Name = "buttonUp";
|
|
||||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
|
||||||
this.buttonUp.TabIndex = 8;
|
|
||||||
this.buttonUp.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonLeft
|
|
||||||
//
|
|
||||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonLeft.BackgroundImage = global::ArmoredCar.Properties.Resources.Left;
|
|
||||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
|
||||||
this.buttonLeft.Location = new System.Drawing.Point(656, 360);
|
|
||||||
this.buttonLeft.Name = "buttonLeft";
|
|
||||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
|
||||||
this.buttonLeft.TabIndex = 9;
|
|
||||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonDown
|
|
||||||
//
|
|
||||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonDown.BackgroundImage = global::ArmoredCar.Properties.Resources.Down;
|
|
||||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
|
||||||
this.buttonDown.Location = new System.Drawing.Point(692, 360);
|
|
||||||
this.buttonDown.Name = "buttonDown";
|
|
||||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
|
||||||
this.buttonDown.TabIndex = 10;
|
|
||||||
this.buttonDown.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonRight
|
|
||||||
//
|
|
||||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonRight.BackgroundImage = global::ArmoredCar.Properties.Resources.Right;
|
|
||||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
|
||||||
this.buttonRight.Location = new System.Drawing.Point(728, 360);
|
|
||||||
this.buttonRight.Name = "buttonRight";
|
|
||||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
|
||||||
this.buttonRight.TabIndex = 11;
|
|
||||||
this.buttonRight.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// button2
|
|
||||||
//
|
|
||||||
this.button2.Location = new System.Drawing.Point(154, 382);
|
|
||||||
this.button2.Name = "button2";
|
|
||||||
this.button2.Size = new System.Drawing.Size(95, 23);
|
|
||||||
this.button2.TabIndex = 12;
|
|
||||||
this.button2.Text = "Модификация";
|
|
||||||
this.button2.UseVisualStyleBackColor = true;
|
|
||||||
this.button2.Click += new System.EventHandler(this.ButtonCreateModif_Click);
|
|
||||||
//
|
|
||||||
// comboBoxSelectorMap
|
|
||||||
//
|
|
||||||
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
|
||||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
|
||||||
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
|
||||||
"Простая карта",
|
|
||||||
"Карта 1",
|
|
||||||
"Карта 2"});
|
|
||||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(42, 26);
|
|
||||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
|
||||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(107, 23);
|
|
||||||
this.comboBoxSelectorMap.TabIndex = 13;
|
|
||||||
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
|
||||||
//
|
|
||||||
// FormMap
|
|
||||||
//
|
|
||||||
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.comboBoxSelectorMap);
|
|
||||||
this.Controls.Add(this.button2);
|
|
||||||
this.Controls.Add(this.buttonRight);
|
|
||||||
this.Controls.Add(this.buttonDown);
|
|
||||||
this.Controls.Add(this.buttonLeft);
|
|
||||||
this.Controls.Add(this.buttonUp);
|
|
||||||
this.Controls.Add(this.button1);
|
|
||||||
this.Controls.Add(this.pictureBoxCar);
|
|
||||||
this.Controls.Add(this.statusStrip1);
|
|
||||||
this.Name = "FormMap";
|
|
||||||
this.Text = "Карта";
|
|
||||||
this.statusStrip1.ResumeLayout(false);
|
|
||||||
this.statusStrip1.PerformLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private System.Windows.Forms.StatusStrip statusStrip1;
|
|
||||||
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelSpeed;
|
|
||||||
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelWeight;
|
|
||||||
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelBodyColor;
|
|
||||||
private System.Windows.Forms.PictureBox pictureBoxCar;
|
|
||||||
private System.Windows.Forms.Button button1;
|
|
||||||
private System.Windows.Forms.Button buttonUp;
|
|
||||||
private System.Windows.Forms.Button buttonLeft;
|
|
||||||
private System.Windows.Forms.Button buttonDown;
|
|
||||||
private System.Windows.Forms.Button buttonRight;
|
|
||||||
private System.Windows.Forms.Button button2;
|
|
||||||
private System.Windows.Forms.ComboBox comboBoxSelectorMap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace ArmoredCar
|
|
||||||
{
|
|
||||||
public partial class FormMap : Form
|
|
||||||
{
|
|
||||||
|
|
||||||
private AbstractMap _abstractMap;
|
|
||||||
public FormMap()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_abstractMap = new SimpleMap();
|
|
||||||
}
|
|
||||||
private void SetData(DrawningArmoredCar car)
|
|
||||||
{
|
|
||||||
toolStripStatusLabelSpeed.Text = $"Скорость: {car.ArmoredCar.Speed}";
|
|
||||||
toolStripStatusLabelWeight.Text = $"Вес: {car.ArmoredCar.Weight}";
|
|
||||||
toolStripStatusLabelBodyColor.Text = $"Цвет:{ car.ArmoredCar.BodyColor.Name}";
|
|
||||||
pictureBoxCar.Image = _abstractMap.CreateMap(pictureBoxCar.Width,
|
|
||||||
pictureBoxCar.Height, new DrawningObjectArmCar(car));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Обработка нажатия кнопки "Создать"
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random rnd = new();
|
|
||||||
var car = new DrawningArmoredCar(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
|
||||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
|
||||||
SetData(car);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Изменение размеров формы
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
//получаем имя кнопки
|
|
||||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
|
||||||
Direction dir = Direction.None;
|
|
||||||
switch (name)
|
|
||||||
{
|
|
||||||
case "buttonUp":
|
|
||||||
dir = Direction.Up;
|
|
||||||
break;
|
|
||||||
case "buttonDown":
|
|
||||||
dir = Direction.Down;
|
|
||||||
break;
|
|
||||||
case "buttonLeft":
|
|
||||||
dir = Direction.Left;
|
|
||||||
break;
|
|
||||||
case "buttonRight":
|
|
||||||
dir = Direction.Right;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pictureBoxCar.Image = _abstractMap?.MoveObject(dir);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Обработка нажатия кнопки "Модификация"
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonCreateModif_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random rnd = new();
|
|
||||||
var tank = new DrawningTank(rnd.Next(100, 300), rnd.Next(1000,
|
|
||||||
2000),
|
|
||||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0,
|
|
||||||
256)),
|
|
||||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0,
|
|
||||||
256)),
|
|
||||||
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
|
||||||
SetData(tank);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Смена карты
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender,
|
|
||||||
EventArgs e)
|
|
||||||
{
|
|
||||||
switch (comboBoxSelectorMap.Text)
|
|
||||||
{
|
|
||||||
case "Простая карта":
|
|
||||||
_abstractMap = new SimpleMap();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "Карта 1":
|
|
||||||
_abstractMap = new MyMapWooden();
|
|
||||||
break;
|
|
||||||
case "Карта 2":
|
|
||||||
_abstractMap = new MyMapLabirinth();
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
281
ArmoredCar/ArmoredCar/FormMapWithSetArmoredCars.Designer.cs
generated
Normal file
281
ArmoredCar/ArmoredCar/FormMapWithSetArmoredCars.Designer.cs
generated
Normal file
@@ -0,0 +1,281 @@
|
|||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace ArmoredCar
|
||||||
|
{
|
||||||
|
partial class FormMapWithSetArmoredCars
|
||||||
|
{
|
||||||
|
/// <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.groupBoxTools = new System.Windows.Forms.GroupBox();
|
||||||
|
this.groupBoxMaps = new System.Windows.Forms.GroupBox();
|
||||||
|
this.buttonAddMap = new System.Windows.Forms.Button();
|
||||||
|
this.buttonDeleteMap = new System.Windows.Forms.Button();
|
||||||
|
this.listBoxMaps = new System.Windows.Forms.ListBox();
|
||||||
|
this.textBoxNewMapName = new System.Windows.Forms.TextBox();
|
||||||
|
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||||
|
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||||
|
this.buttonRemoveCar = new System.Windows.Forms.Button();
|
||||||
|
this.buttonShowStorage = new System.Windows.Forms.Button();
|
||||||
|
this.buttonDown = new System.Windows.Forms.Button();
|
||||||
|
this.buttonRight = new System.Windows.Forms.Button();
|
||||||
|
this.buttonLeft = new System.Windows.Forms.Button();
|
||||||
|
this.buttonUp = new System.Windows.Forms.Button();
|
||||||
|
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
||||||
|
this.buttonAddCar = new System.Windows.Forms.Button();
|
||||||
|
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||||
|
this.groupBoxTools.SuspendLayout();
|
||||||
|
this.groupBoxMaps.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// groupBoxTools
|
||||||
|
//
|
||||||
|
this.groupBoxTools.Controls.Add(this.groupBoxMaps);
|
||||||
|
this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition);
|
||||||
|
this.groupBoxTools.Controls.Add(this.buttonRemoveCar);
|
||||||
|
this.groupBoxTools.Controls.Add(this.buttonShowStorage);
|
||||||
|
this.groupBoxTools.Controls.Add(this.buttonDown);
|
||||||
|
this.groupBoxTools.Controls.Add(this.buttonRight);
|
||||||
|
this.groupBoxTools.Controls.Add(this.buttonLeft);
|
||||||
|
this.groupBoxTools.Controls.Add(this.buttonUp);
|
||||||
|
this.groupBoxTools.Controls.Add(this.buttonShowOnMap);
|
||||||
|
this.groupBoxTools.Controls.Add(this.buttonAddCar);
|
||||||
|
this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
|
||||||
|
this.groupBoxTools.Location = new System.Drawing.Point(811, 0);
|
||||||
|
this.groupBoxTools.Name = "groupBoxTools";
|
||||||
|
this.groupBoxTools.Size = new System.Drawing.Size(204, 632);
|
||||||
|
this.groupBoxTools.TabIndex = 0;
|
||||||
|
this.groupBoxTools.TabStop = false;
|
||||||
|
this.groupBoxTools.Text = "Инструменты";
|
||||||
|
//
|
||||||
|
// groupBoxMaps
|
||||||
|
//
|
||||||
|
this.groupBoxMaps.Controls.Add(this.buttonAddMap);
|
||||||
|
this.groupBoxMaps.Controls.Add(this.buttonDeleteMap);
|
||||||
|
this.groupBoxMaps.Controls.Add(this.listBoxMaps);
|
||||||
|
this.groupBoxMaps.Controls.Add(this.textBoxNewMapName);
|
||||||
|
this.groupBoxMaps.Controls.Add(this.comboBoxSelectorMap);
|
||||||
|
this.groupBoxMaps.Location = new System.Drawing.Point(6, 22);
|
||||||
|
this.groupBoxMaps.Name = "groupBoxMaps";
|
||||||
|
this.groupBoxMaps.Size = new System.Drawing.Size(192, 248);
|
||||||
|
this.groupBoxMaps.TabIndex = 0;
|
||||||
|
this.groupBoxMaps.TabStop = false;
|
||||||
|
this.groupBoxMaps.Text = "Карты";
|
||||||
|
//
|
||||||
|
// buttonAddMap
|
||||||
|
//
|
||||||
|
this.buttonAddMap.Location = new System.Drawing.Point(11, 80);
|
||||||
|
this.buttonAddMap.Name = "buttonAddMap";
|
||||||
|
this.buttonAddMap.Size = new System.Drawing.Size(175, 35);
|
||||||
|
this.buttonAddMap.TabIndex = 2;
|
||||||
|
this.buttonAddMap.Text = "Добавить карту";
|
||||||
|
this.buttonAddMap.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAddMap.Click += new System.EventHandler(this.ButtonAddMap_Click);
|
||||||
|
//
|
||||||
|
// buttonDeleteMap
|
||||||
|
//
|
||||||
|
this.buttonDeleteMap.Location = new System.Drawing.Point(11, 206);
|
||||||
|
this.buttonDeleteMap.Name = "buttonDeleteMap";
|
||||||
|
this.buttonDeleteMap.Size = new System.Drawing.Size(175, 35);
|
||||||
|
this.buttonDeleteMap.TabIndex = 4;
|
||||||
|
this.buttonDeleteMap.Text = "Удалить карту";
|
||||||
|
this.buttonDeleteMap.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDeleteMap.Click += new System.EventHandler(this.ButtonDeleteMap_Click);
|
||||||
|
//
|
||||||
|
// listBoxMaps
|
||||||
|
//
|
||||||
|
this.listBoxMaps.FormattingEnabled = true;
|
||||||
|
this.listBoxMaps.ItemHeight = 15;
|
||||||
|
this.listBoxMaps.Location = new System.Drawing.Point(11, 121);
|
||||||
|
this.listBoxMaps.Name = "listBoxMaps";
|
||||||
|
this.listBoxMaps.Size = new System.Drawing.Size(175, 79);
|
||||||
|
this.listBoxMaps.TabIndex = 3;
|
||||||
|
this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.ListBoxMaps_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// textBoxNewMapName
|
||||||
|
//
|
||||||
|
this.textBoxNewMapName.Location = new System.Drawing.Point(11, 22);
|
||||||
|
this.textBoxNewMapName.Name = "textBoxNewMapName";
|
||||||
|
this.textBoxNewMapName.Size = new System.Drawing.Size(175, 23);
|
||||||
|
this.textBoxNewMapName.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// comboBoxSelectorMap
|
||||||
|
//
|
||||||
|
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||||
|
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
||||||
|
"Простая карта"});
|
||||||
|
this.comboBoxSelectorMap.Location = new System.Drawing.Point(11, 51);
|
||||||
|
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||||
|
this.comboBoxSelectorMap.Size = new System.Drawing.Size(175, 23);
|
||||||
|
this.comboBoxSelectorMap.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// maskedTextBoxPosition
|
||||||
|
//
|
||||||
|
this.maskedTextBoxPosition.Location = new System.Drawing.Point(17, 355);
|
||||||
|
this.maskedTextBoxPosition.Mask = "00";
|
||||||
|
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||||
|
this.maskedTextBoxPosition.Size = new System.Drawing.Size(175, 23);
|
||||||
|
this.maskedTextBoxPosition.TabIndex = 2;
|
||||||
|
this.maskedTextBoxPosition.ValidatingType = typeof(int);
|
||||||
|
//
|
||||||
|
// buttonRemoveCar
|
||||||
|
//
|
||||||
|
this.buttonRemoveCar.Location = new System.Drawing.Point(17, 384);
|
||||||
|
this.buttonRemoveCar.Name = "buttonRemoveCar";
|
||||||
|
this.buttonRemoveCar.Size = new System.Drawing.Size(175, 35);
|
||||||
|
this.buttonRemoveCar.TabIndex = 3;
|
||||||
|
this.buttonRemoveCar.Text = "Удалить бронемашину";
|
||||||
|
this.buttonRemoveCar.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonRemoveCar.Click += new System.EventHandler(this.ButtonRemoveArmoredCar_Click);
|
||||||
|
//
|
||||||
|
// buttonShowStorage
|
||||||
|
//
|
||||||
|
this.buttonShowStorage.Location = new System.Drawing.Point(17, 437);
|
||||||
|
this.buttonShowStorage.Name = "buttonShowStorage";
|
||||||
|
this.buttonShowStorage.Size = new System.Drawing.Size(175, 35);
|
||||||
|
this.buttonShowStorage.TabIndex = 4;
|
||||||
|
this.buttonShowStorage.Text = "Посмотреть хранилище";
|
||||||
|
this.buttonShowStorage.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
|
||||||
|
//
|
||||||
|
// buttonDown
|
||||||
|
//
|
||||||
|
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonDown.BackgroundImage = global::ArmoredCar.Properties.Resources.Down;
|
||||||
|
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonDown.Location = new System.Drawing.Point(91, 582);
|
||||||
|
this.buttonDown.Name = "buttonDown";
|
||||||
|
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.buttonDown.TabIndex = 10;
|
||||||
|
this.buttonDown.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// buttonRight
|
||||||
|
//
|
||||||
|
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonRight.BackgroundImage = global::ArmoredCar.Properties.Resources.Right;
|
||||||
|
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonRight.Location = new System.Drawing.Point(127, 582);
|
||||||
|
this.buttonRight.Name = "buttonRight";
|
||||||
|
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.buttonRight.TabIndex = 9;
|
||||||
|
this.buttonRight.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// buttonLeft
|
||||||
|
//
|
||||||
|
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonLeft.BackgroundImage = global::ArmoredCar.Properties.Resources.Left;
|
||||||
|
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonLeft.Location = new System.Drawing.Point(55, 582);
|
||||||
|
this.buttonLeft.Name = "buttonLeft";
|
||||||
|
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.buttonLeft.TabIndex = 8;
|
||||||
|
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// buttonUp
|
||||||
|
//
|
||||||
|
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonUp.BackgroundImage = global::ArmoredCar.Properties.Resources.Up;
|
||||||
|
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonUp.Location = new System.Drawing.Point(91, 546);
|
||||||
|
this.buttonUp.Name = "buttonUp";
|
||||||
|
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.buttonUp.TabIndex = 7;
|
||||||
|
this.buttonUp.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// buttonShowOnMap
|
||||||
|
//
|
||||||
|
this.buttonShowOnMap.Location = new System.Drawing.Point(17, 487);
|
||||||
|
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
||||||
|
this.buttonShowOnMap.Size = new System.Drawing.Size(175, 35);
|
||||||
|
this.buttonShowOnMap.TabIndex = 5;
|
||||||
|
this.buttonShowOnMap.Text = "Посмотреть карту";
|
||||||
|
this.buttonShowOnMap.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
|
||||||
|
//
|
||||||
|
// buttonAddCar
|
||||||
|
//
|
||||||
|
this.buttonAddCar.Location = new System.Drawing.Point(17, 314);
|
||||||
|
this.buttonAddCar.Name = "buttonAddCar";
|
||||||
|
this.buttonAddCar.Size = new System.Drawing.Size(175, 35);
|
||||||
|
this.buttonAddCar.TabIndex = 1;
|
||||||
|
this.buttonAddCar.Text = "Добавить бронемашину";
|
||||||
|
this.buttonAddCar.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAddCar.Click += new System.EventHandler(this.ButtonAddarmoredCar_Click);
|
||||||
|
//
|
||||||
|
// pictureBox
|
||||||
|
//
|
||||||
|
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.pictureBox.Name = "pictureBox";
|
||||||
|
this.pictureBox.Size = new System.Drawing.Size(811, 632);
|
||||||
|
this.pictureBox.TabIndex = 1;
|
||||||
|
this.pictureBox.TabStop = false;
|
||||||
|
//
|
||||||
|
// FormMapWithSetArmoredCars
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(1015, 632);
|
||||||
|
this.Controls.Add(this.pictureBox);
|
||||||
|
this.Controls.Add(this.groupBoxTools);
|
||||||
|
this.Name = "FormMapWithSetArmoredCars";
|
||||||
|
this.Text = "Карта с набором объектов";
|
||||||
|
this.groupBoxTools.ResumeLayout(false);
|
||||||
|
this.groupBoxTools.PerformLayout();
|
||||||
|
this.groupBoxMaps.ResumeLayout(false);
|
||||||
|
this.groupBoxMaps.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private GroupBox groupBoxTools;
|
||||||
|
private PictureBox pictureBox;
|
||||||
|
private ComboBox comboBoxSelectorMap;
|
||||||
|
private Button buttonShowOnMap;
|
||||||
|
private Button buttonAddCar;
|
||||||
|
private Button buttonDown;
|
||||||
|
private Button buttonRight;
|
||||||
|
private Button buttonLeft;
|
||||||
|
private Button buttonUp;
|
||||||
|
private Button buttonShowStorage;
|
||||||
|
private Button buttonRemoveCar;
|
||||||
|
private MaskedTextBox maskedTextBoxPosition;
|
||||||
|
private GroupBox groupBoxMaps;
|
||||||
|
private Button buttonDeleteMap;
|
||||||
|
private ListBox listBoxMaps;
|
||||||
|
private TextBox textBoxNewMapName;
|
||||||
|
private Button buttonAddMap;
|
||||||
|
}
|
||||||
|
}
|
||||||
224
ArmoredCar/ArmoredCar/FormMapWithSetArmoredCars.cs
Normal file
224
ArmoredCar/ArmoredCar/FormMapWithSetArmoredCars.cs
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace ArmoredCar
|
||||||
|
{
|
||||||
|
public partial class FormMapWithSetArmoredCars : Form
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Словарь для выпадающего списка
|
||||||
|
/// </summary>
|
||||||
|
private readonly Dictionary<string, AbstractMap> _mapsDict = new()
|
||||||
|
{
|
||||||
|
{ "Простая карта", new SimpleMap() },
|
||||||
|
{ "Карта 1", new MyMapLabirinth() },
|
||||||
|
{ "Карта 2", new MyMapWooden() }
|
||||||
|
};
|
||||||
|
/// <summary>
|
||||||
|
/// Объект от коллекции карт
|
||||||
|
/// </summary>
|
||||||
|
private readonly MapsCollection _mapsCollection;
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
public FormMapWithSetArmoredCars()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height);
|
||||||
|
comboBoxSelectorMap.Items.Clear();
|
||||||
|
foreach (var elem in _mapsDict)
|
||||||
|
{
|
||||||
|
comboBoxSelectorMap.Items.Add(elem.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Заполнение listBoxMaps
|
||||||
|
/// </summary>
|
||||||
|
private void ReloadMaps()
|
||||||
|
{
|
||||||
|
int index = listBoxMaps.SelectedIndex;
|
||||||
|
|
||||||
|
listBoxMaps.Items.Clear();
|
||||||
|
for (int i = 0; i < _mapsCollection.Keys.Count; i++)
|
||||||
|
{
|
||||||
|
listBoxMaps.Items.Add(_mapsCollection.Keys[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listBoxMaps.Items.Count > 0 && (index == -1 || index >= listBoxMaps.Items.Count))
|
||||||
|
{
|
||||||
|
listBoxMaps.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
else if (listBoxMaps.Items.Count > 0 && index > -1 && index < listBoxMaps.Items.Count)
|
||||||
|
{
|
||||||
|
listBoxMaps.SelectedIndex = index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonAddMap_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (comboBoxSelectorMap.SelectedIndex == -1 || string.IsNullOrEmpty(textBoxNewMapName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!_mapsDict.ContainsKey(comboBoxSelectorMap.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Нет такой карты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_mapsCollection.AddMap(textBoxNewMapName.Text, _mapsDict[comboBoxSelectorMap.Text]);
|
||||||
|
ReloadMaps();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Выбор карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ListBoxMaps_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonDeleteMap_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MessageBox.Show($"Удалить карту {listBoxMaps.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
_mapsCollection.DelMap(listBoxMaps.SelectedItem?.ToString() ?? string.Empty);
|
||||||
|
ReloadMaps();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление объекта
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonAddarmoredCar_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var form = new FormArmoredCarConfig();
|
||||||
|
form.AddEvent(AddArmoredCar);
|
||||||
|
form.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddArmoredCar(DrawningArmoredCar drawningArmoredCar)
|
||||||
|
{
|
||||||
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawningObjectArmCar armoredCar = new(drawningArmoredCar);
|
||||||
|
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + armoredCar > -1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект добавлен");
|
||||||
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление объекта
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonRemoveArmoredCar_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||||
|
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект удален");
|
||||||
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось удалить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Вывод набора
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Вывод карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Перемещение
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//получаем имя кнопки
|
||||||
|
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||||
|
Direction dir = Direction.None;
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case "buttonUp":
|
||||||
|
dir = Direction.Up;
|
||||||
|
break;
|
||||||
|
case "buttonDown":
|
||||||
|
dir = Direction.Down;
|
||||||
|
break;
|
||||||
|
case "buttonLeft":
|
||||||
|
dir = Direction.Left;
|
||||||
|
break;
|
||||||
|
case "buttonRight":
|
||||||
|
dir = Direction.Right;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
60
ArmoredCar/ArmoredCar/FormMapWithSetArmoredCars.resx
Normal file
60
ArmoredCar/ArmoredCar/FormMapWithSetArmoredCars.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>
|
||||||
185
ArmoredCar/ArmoredCar/MapWithSetArmoredCarsGeneric.cs
Normal file
185
ArmoredCar/ArmoredCar/MapWithSetArmoredCarsGeneric.cs
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ArmoredCar
|
||||||
|
{
|
||||||
|
internal class MapWithSetArmoredCarsGeneric<T, U>
|
||||||
|
where T : class, IDrawningObject
|
||||||
|
where U : AbstractMap
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Ширина окна отрисовки
|
||||||
|
/// </summary>
|
||||||
|
private readonly int _pictureWidth;
|
||||||
|
/// <summary>
|
||||||
|
/// Высота окна отрисовки
|
||||||
|
/// </summary>
|
||||||
|
private readonly int _pictureHeight;
|
||||||
|
/// <summary>
|
||||||
|
/// Размер занимаемого объектом места (ширина)
|
||||||
|
/// </summary>
|
||||||
|
private readonly int _placeSizeWidth = 210;
|
||||||
|
/// <summary>
|
||||||
|
/// Размер занимаемого объектом места (высота)
|
||||||
|
/// </summary>
|
||||||
|
private readonly int _placeSizeHeight = 90;
|
||||||
|
/// <summary>
|
||||||
|
/// Набор объектов
|
||||||
|
/// </summary>
|
||||||
|
private readonly SetArmoredCarsGeneric<T> _setCars;
|
||||||
|
/// <summary>
|
||||||
|
/// Карта
|
||||||
|
/// </summary>
|
||||||
|
private readonly U _map;
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="picWidth"></param>
|
||||||
|
/// <param name="picHeight"></param>
|
||||||
|
/// <param name="map"></param>
|
||||||
|
public MapWithSetArmoredCarsGeneric(int picWidth, int picHeight, U map)
|
||||||
|
{
|
||||||
|
int width = picWidth / _placeSizeWidth;
|
||||||
|
int height = picHeight / _placeSizeHeight;
|
||||||
|
_setCars = new SetArmoredCarsGeneric<T>(width * height);
|
||||||
|
_pictureWidth = picWidth;
|
||||||
|
_pictureHeight = picHeight;
|
||||||
|
_map = map;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Перегрузка оператора сложения
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="map"></param>
|
||||||
|
/// <param name="car"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static int operator +(MapWithSetArmoredCarsGeneric<T, U> map, T car)
|
||||||
|
{
|
||||||
|
return map._setCars.Insert(car);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Перегрузка оператора вычитания
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="map"></param>
|
||||||
|
/// <param name="position"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static T operator -(MapWithSetArmoredCarsGeneric<T, U> map, int
|
||||||
|
position)
|
||||||
|
{
|
||||||
|
return map._setCars.Remove(position);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Вывод всего набора объектов
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Bitmap ShowSet()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
DrawBackground(gr);
|
||||||
|
DrawArmoredCars(gr);
|
||||||
|
return bmp;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Просмотр объекта на карте
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Bitmap ShowOnMap()
|
||||||
|
{
|
||||||
|
Shaking();
|
||||||
|
foreach (var armoredCar in _setCars.GetCars())
|
||||||
|
{
|
||||||
|
return _map.CreateMap(_pictureWidth, _pictureHeight, armoredCar);
|
||||||
|
}
|
||||||
|
return new(_pictureWidth, _pictureHeight);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Перемещение объекта по крате
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="direction"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Bitmap MoveObject(Direction direction)
|
||||||
|
{
|
||||||
|
if (_map != null)
|
||||||
|
{
|
||||||
|
return _map.MoveObject(direction);
|
||||||
|
}
|
||||||
|
return new(_pictureWidth, _pictureHeight);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// "Взбалтываем" набор, чтобы все элементы оказались в начале
|
||||||
|
/// </summary>
|
||||||
|
private void Shaking()
|
||||||
|
{
|
||||||
|
int j = _setCars.Count - 1;
|
||||||
|
for (int i = 0; i < _setCars.Count; i++)
|
||||||
|
{
|
||||||
|
if (_setCars[i] == null)
|
||||||
|
{
|
||||||
|
for (; j > i; j--)
|
||||||
|
{
|
||||||
|
var armoredCar = _setCars[i];
|
||||||
|
if (armoredCar != null)
|
||||||
|
{
|
||||||
|
_setCars.Insert(armoredCar, i);
|
||||||
|
_setCars.Remove(j);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (j <= i)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Метод отрисовки фона
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g"></param>
|
||||||
|
private void DrawBackground(Graphics g)
|
||||||
|
{
|
||||||
|
Pen pen = new(Color.Black, 3);
|
||||||
|
Brush brushRoad = new SolidBrush(Color.Gray);
|
||||||
|
Brush brushBox = new SolidBrush(Color.SandyBrown);
|
||||||
|
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
|
||||||
|
{
|
||||||
|
g.FillRectangle(brushRoad, i * _placeSizeWidth, j * _placeSizeHeight, _placeSizeWidth, _placeSizeHeight);
|
||||||
|
g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
|
||||||
|
|
||||||
|
int boxSize = _placeSizeWidth / 7;
|
||||||
|
g.FillRectangle(brushBox, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight + _placeSizeHeight / 5, boxSize, boxSize);
|
||||||
|
g.DrawRectangle(pen, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight + _placeSizeHeight / 5, boxSize, boxSize);
|
||||||
|
g.FillRectangle(brushBox, i * _placeSizeWidth + _placeSizeWidth / 2 - boxSize / 2, j * _placeSizeHeight + _placeSizeHeight / 5 + boxSize, boxSize, boxSize);
|
||||||
|
g.DrawRectangle(pen, i * _placeSizeWidth + _placeSizeWidth / 2 - boxSize / 2, j * _placeSizeHeight + _placeSizeHeight / 5 + boxSize, boxSize, boxSize);
|
||||||
|
g.FillRectangle(brushBox, i * _placeSizeWidth + _placeSizeWidth / 2 + boxSize / 2, j * _placeSizeHeight + _placeSizeHeight / 5 + boxSize, boxSize, boxSize);
|
||||||
|
g.DrawRectangle(pen, i * _placeSizeWidth + _placeSizeWidth / 2 + boxSize / 2, j * _placeSizeHeight + _placeSizeHeight / 5 + boxSize, boxSize, boxSize);
|
||||||
|
}
|
||||||
|
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth,
|
||||||
|
(_pictureHeight / _placeSizeHeight) * _placeSizeHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Метод прорисовки объектов
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g"></param>
|
||||||
|
private void DrawArmoredCars(Graphics g)
|
||||||
|
{
|
||||||
|
int width = _pictureWidth / _placeSizeWidth;
|
||||||
|
int k = 0;
|
||||||
|
foreach (var armoredCar in _setCars.GetCars())
|
||||||
|
{
|
||||||
|
armoredCar.SetObject(k % width * _placeSizeWidth + 5, k / width * _placeSizeHeight + 10, _pictureWidth, _pictureHeight);
|
||||||
|
armoredCar.DrawningObject(g);
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
72
ArmoredCar/ArmoredCar/MapsCollection.cs
Normal file
72
ArmoredCar/ArmoredCar/MapsCollection.cs
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ArmoredCar
|
||||||
|
{
|
||||||
|
internal class MapsCollection
|
||||||
|
{
|
||||||
|
/// Словарь (хранилище) с картами
|
||||||
|
/// </summary>
|
||||||
|
readonly Dictionary<string, MapWithSetArmoredCarsGeneric<DrawningObjectArmCar, AbstractMap>> _mapStorages;
|
||||||
|
/// <summary>
|
||||||
|
/// Возвращение списка названий карт
|
||||||
|
/// </summary>
|
||||||
|
public List<string> Keys => _mapStorages.Keys.ToList();
|
||||||
|
/// <summary>
|
||||||
|
/// Ширина окна отрисовки
|
||||||
|
/// </summary>
|
||||||
|
private readonly int _pictureWidth;
|
||||||
|
/// <summary>
|
||||||
|
/// Высота окна отрисовки
|
||||||
|
/// </summary>
|
||||||
|
private readonly int _pictureHeight;
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pictureWidth"></param>
|
||||||
|
/// <param name="pictureHeight"></param>
|
||||||
|
public MapsCollection(int pictureWidth, int pictureHeight)
|
||||||
|
{
|
||||||
|
_mapStorages = new Dictionary<string, MapWithSetArmoredCarsGeneric<DrawningObjectArmCar, AbstractMap>>();
|
||||||
|
_pictureWidth = pictureWidth;
|
||||||
|
_pictureHeight = pictureHeight;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название карты</param>
|
||||||
|
/// <param name="map">Карта</param>
|
||||||
|
public void AddMap(string name, AbstractMap map)
|
||||||
|
{
|
||||||
|
if (!Keys.Contains(name))
|
||||||
|
_mapStorages.Add(name, new MapWithSetArmoredCarsGeneric<DrawningObjectArmCar, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Название карты</param>
|
||||||
|
public void DelMap(string name)
|
||||||
|
{
|
||||||
|
if (Keys.Contains(name))
|
||||||
|
_mapStorages.Remove(name);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Доступ к парковке
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ind"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public MapWithSetArmoredCarsGeneric<DrawningObjectArmCar, AbstractMap> this[string
|
||||||
|
ind]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (Keys.Contains(ind))
|
||||||
|
return _mapStorages[ind];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ namespace ArmoredCar
|
|||||||
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
Application.Run(new FormMap());
|
Application.Run(new FormMapWithSetArmoredCars());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
110
ArmoredCar/ArmoredCar/SetArmoredCarsGeneric.cs
Normal file
110
ArmoredCar/ArmoredCar/SetArmoredCarsGeneric.cs
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ArmoredCar
|
||||||
|
{
|
||||||
|
internal class SetArmoredCarsGeneric<T>
|
||||||
|
where T : class
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Список объектов, которые храним
|
||||||
|
/// </summary>
|
||||||
|
private readonly List<T> _places;
|
||||||
|
/// <summary>
|
||||||
|
/// Количество объектов в массиве
|
||||||
|
/// </summary>
|
||||||
|
public int Count => _places.Count;
|
||||||
|
private readonly int _maxCount;
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="count"></param>
|
||||||
|
public SetArmoredCarsGeneric(int count)
|
||||||
|
{
|
||||||
|
_maxCount = count;
|
||||||
|
_places = new List<T>();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление объекта в набор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="armoredCar">Добавляемый автомобиль</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int Insert(T armoredCar)
|
||||||
|
{
|
||||||
|
if (Count < _maxCount)
|
||||||
|
return Insert(armoredCar, 0);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление объекта в набор на конкретную позицию
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="armoredCar">Добавляемый автомобиль</param>
|
||||||
|
/// <param name="position">Позиция</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int Insert(T armoredCar, int position)
|
||||||
|
{
|
||||||
|
if (position < 0 || position >= _maxCount)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
_places.Insert(position, armoredCar);
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление объекта из набора с конкретной позиции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="position"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public T Remove(int position)
|
||||||
|
{
|
||||||
|
if (position < 0 || position >= Count)
|
||||||
|
return null;
|
||||||
|
T armoredCar = _places[position];
|
||||||
|
_places.RemoveAt(position);
|
||||||
|
return armoredCar;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Получение объекта из набора по позиции
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="position"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public T this[int position]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (position < 0 || position >= Count)
|
||||||
|
return null;
|
||||||
|
return _places[position];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
|
||||||
|
if (position < 0 || position >= _maxCount)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_places.Add(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Проход по набору до первого пустого
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public IEnumerable<T> GetCars()
|
||||||
|
{
|
||||||
|
foreach (var car in _places)
|
||||||
|
{
|
||||||
|
if (car != null)
|
||||||
|
{
|
||||||
|
yield return car;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user