All done
This commit is contained in:
parent
8893e998d1
commit
b2e5c3e9b5
@ -17,7 +17,6 @@ namespace ProjectTank.DrawningObjects
|
||||
|
||||
EntityTankBase = new EntityTank(speed, weight, bodyColor, additionalColor, isTankTower, isAntiAirforceGun);
|
||||
}
|
||||
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityTankBase is not EntityTank tank) return;
|
||||
@ -59,5 +58,9 @@ namespace ProjectTank.DrawningObjects
|
||||
g.DrawPolygon(pen, rightRectanglePoints);
|
||||
}
|
||||
}
|
||||
public void ChangeAdditionalColor(Color color)
|
||||
{
|
||||
((EntityTank)EntityTankBase).AdditionalColor = color;
|
||||
}
|
||||
}
|
||||
}
|
@ -58,6 +58,11 @@ namespace ProjectTank.DrawningObjects
|
||||
startPosY = 1;
|
||||
}
|
||||
}
|
||||
public void ChangePictureBoxSize(int pictureBoxWidth, int pictureBoxHeight)
|
||||
{
|
||||
pictureHeight = pictureBoxHeight;
|
||||
pictureWidth = pictureBoxWidth;
|
||||
}
|
||||
public void MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (!CanMove(direction) || EntityTankBase == null) return;
|
||||
@ -115,5 +120,11 @@ namespace ProjectTank.DrawningObjects
|
||||
|
||||
g.FillRectangle(brush, startPosX + 5, startPosY + 55 + 1, tankWidth - 10, 9);
|
||||
}
|
||||
|
||||
public void ChangeColor(Color col)
|
||||
{
|
||||
if (EntityTankBase == null) return;
|
||||
EntityTankBase.BodyColor = col;
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ namespace ProjectTank.Entities
|
||||
{
|
||||
public class EntityTank : EntityTankBase
|
||||
{
|
||||
public Color AdditionalColor { get; private set; }
|
||||
public Color AdditionalColor { get; set; }
|
||||
public bool TankTower { get; private set; }
|
||||
public bool AntiAirforceGun { get; private set; }
|
||||
public EntityTank(int speed, double weight, Color bodyColor, Color
|
||||
|
@ -10,7 +10,7 @@ namespace ProjectTank.Entities
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
public double Weight { get; private set; }
|
||||
public Color BodyColor { get; private set; }
|
||||
public Color BodyColor { get; set; }
|
||||
public double Step => (double)Speed * 100 / Weight;
|
||||
public EntityTankBase(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
|
110
ProjectTank/FormTankCollection.Designer.cs
generated
110
ProjectTank/FormTankCollection.Designer.cs
generated
@ -30,15 +30,15 @@
|
||||
{
|
||||
pictureBoxCollection = new PictureBox();
|
||||
label1 = new Label();
|
||||
button3 = new Button();
|
||||
button2 = new Button();
|
||||
button4 = new Button();
|
||||
refreshObjectsButton = new Button();
|
||||
deleteTankButton = new Button();
|
||||
addTankButton = new Button();
|
||||
maskedTextBoxNumber = new TextBox();
|
||||
label2 = new Label();
|
||||
textBoxStorageName = new TextBox();
|
||||
button1 = new Button();
|
||||
addObjectButton = new Button();
|
||||
listBoxStorages = new ListBox();
|
||||
button5 = new Button();
|
||||
deleteObjectButton = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -59,35 +59,35 @@
|
||||
label1.TabIndex = 1;
|
||||
label1.Text = "Инструменты";
|
||||
//
|
||||
// button3
|
||||
// refreshObjectsButton
|
||||
//
|
||||
button3.Location = new Point(775, 448);
|
||||
button3.Name = "button3";
|
||||
button3.Size = new Size(139, 29);
|
||||
button3.TabIndex = 4;
|
||||
button3.Text = "Обн. коллекцию";
|
||||
button3.UseVisualStyleBackColor = true;
|
||||
button3.Click += ButtonRefreshCollection_Click;
|
||||
refreshObjectsButton.Location = new Point(775, 448);
|
||||
refreshObjectsButton.Name = "refreshObjectsButton";
|
||||
refreshObjectsButton.Size = new Size(139, 29);
|
||||
refreshObjectsButton.TabIndex = 4;
|
||||
refreshObjectsButton.Text = "Обн. коллекцию";
|
||||
refreshObjectsButton.UseVisualStyleBackColor = true;
|
||||
refreshObjectsButton.Click += ButtonRefreshCollection_Click;
|
||||
//
|
||||
// button2
|
||||
// deleteTankButton
|
||||
//
|
||||
button2.Location = new Point(775, 393);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(139, 29);
|
||||
button2.TabIndex = 5;
|
||||
button2.Text = "Удалить танк";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += ButtonRemoveTank_Click;
|
||||
deleteTankButton.Location = new Point(775, 393);
|
||||
deleteTankButton.Name = "deleteTankButton";
|
||||
deleteTankButton.Size = new Size(139, 29);
|
||||
deleteTankButton.TabIndex = 5;
|
||||
deleteTankButton.Text = "Удалить танк";
|
||||
deleteTankButton.UseVisualStyleBackColor = true;
|
||||
deleteTankButton.Click += ButtonRemoveTank_Click;
|
||||
//
|
||||
// button4
|
||||
// addTankButton
|
||||
//
|
||||
button4.Location = new Point(775, 306);
|
||||
button4.Name = "button4";
|
||||
button4.Size = new Size(139, 29);
|
||||
button4.TabIndex = 6;
|
||||
button4.Text = "Добавить танк";
|
||||
button4.UseVisualStyleBackColor = true;
|
||||
button4.Click += ButtonAddTank_Click;
|
||||
addTankButton.Location = new Point(775, 306);
|
||||
addTankButton.Name = "addTankButton";
|
||||
addTankButton.Size = new Size(139, 29);
|
||||
addTankButton.TabIndex = 6;
|
||||
addTankButton.Text = "Добавить танк";
|
||||
addTankButton.UseVisualStyleBackColor = true;
|
||||
addTankButton.Click += ButtonAddTank_Click;
|
||||
//
|
||||
// maskedTextBoxNumber
|
||||
//
|
||||
@ -112,15 +112,15 @@
|
||||
textBoxStorageName.Size = new Size(139, 27);
|
||||
textBoxStorageName.TabIndex = 9;
|
||||
//
|
||||
// button1
|
||||
// addObjectButton
|
||||
//
|
||||
button1.Location = new Point(775, 107);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(139, 29);
|
||||
button1.TabIndex = 10;
|
||||
button1.Text = "Добавить набор";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += ButtonAddObject_Click;
|
||||
addObjectButton.Location = new Point(775, 107);
|
||||
addObjectButton.Name = "addObjectButton";
|
||||
addObjectButton.Size = new Size(139, 29);
|
||||
addObjectButton.TabIndex = 10;
|
||||
addObjectButton.Text = "Добавить набор";
|
||||
addObjectButton.UseVisualStyleBackColor = true;
|
||||
addObjectButton.Click += ButtonAddObject_Click;
|
||||
//
|
||||
// listBoxStorages
|
||||
//
|
||||
@ -132,30 +132,30 @@
|
||||
listBoxStorages.TabIndex = 11;
|
||||
listBoxStorages.SelectedIndexChanged += ListBoxObjects_SelectedIndexChanged;
|
||||
//
|
||||
// button5
|
||||
// deleteObjectButton
|
||||
//
|
||||
button5.Location = new Point(775, 232);
|
||||
button5.Name = "button5";
|
||||
button5.Size = new Size(139, 29);
|
||||
button5.TabIndex = 12;
|
||||
button5.Text = "Удалить набор";
|
||||
button5.UseVisualStyleBackColor = true;
|
||||
button5.Click += ButtonDelObject_Click;
|
||||
deleteObjectButton.Location = new Point(775, 232);
|
||||
deleteObjectButton.Name = "deleteObjectButton";
|
||||
deleteObjectButton.Size = new Size(139, 29);
|
||||
deleteObjectButton.TabIndex = 12;
|
||||
deleteObjectButton.Text = "Удалить набор";
|
||||
deleteObjectButton.UseVisualStyleBackColor = true;
|
||||
deleteObjectButton.Click += ButtonDelObject_Click;
|
||||
//
|
||||
// FormTankCollection
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(926, 486);
|
||||
Controls.Add(button5);
|
||||
Controls.Add(deleteObjectButton);
|
||||
Controls.Add(listBoxStorages);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(addObjectButton);
|
||||
Controls.Add(textBoxStorageName);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(maskedTextBoxNumber);
|
||||
Controls.Add(button4);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(button3);
|
||||
Controls.Add(addTankButton);
|
||||
Controls.Add(deleteTankButton);
|
||||
Controls.Add(refreshObjectsButton);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(pictureBoxCollection);
|
||||
Name = "FormTankCollection";
|
||||
@ -169,14 +169,14 @@
|
||||
|
||||
private PictureBox pictureBoxCollection;
|
||||
private Label label1;
|
||||
private Button button3;
|
||||
private Button button2;
|
||||
private Button button4;
|
||||
private Button refreshObjectsButton;
|
||||
private Button deleteTankButton;
|
||||
private Button addTankButton;
|
||||
private TextBox maskedTextBoxNumber;
|
||||
private Label label2;
|
||||
private TextBox textBoxStorageName;
|
||||
private Button button1;
|
||||
private Button addObjectButton;
|
||||
private ListBox listBoxStorages;
|
||||
private Button button5;
|
||||
private Button deleteObjectButton;
|
||||
}
|
||||
}
|
@ -21,12 +21,10 @@ namespace ProjectTank
|
||||
{
|
||||
int index = listBoxStorages.SelectedIndex;
|
||||
listBoxStorages.Items.Clear();
|
||||
|
||||
for (int i = 0; i < _storage.Keys.Count; i++)
|
||||
{
|
||||
listBoxStorages.Items.Add(_storage.Keys[i]);
|
||||
}
|
||||
|
||||
if (listBoxStorages.Items.Count > 0 && (index == -1 || index
|
||||
>= listBoxStorages.Items.Count))
|
||||
{
|
||||
@ -41,10 +39,10 @@ namespace ProjectTank
|
||||
|
||||
private void ButtonAddObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
string objName = textBoxStorageName.Text;
|
||||
if (string.IsNullOrEmpty(objName))
|
||||
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
||||
{
|
||||
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show("Не все данные заполнены", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_storage.AddSet(textBoxStorageName.Text);
|
||||
@ -81,20 +79,26 @@ namespace ProjectTank
|
||||
private void ButtonAddTank_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1) return;
|
||||
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null) return;
|
||||
|
||||
FormTank form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
FormTankConfig form = new();
|
||||
form.Show();
|
||||
Action<DrawningTankBase>? tankDelegate = new((t) =>
|
||||
{
|
||||
if (obj + form.SelectedTank)
|
||||
if (obj + t)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowTanks();
|
||||
t.ChangePictureBoxSize(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
}
|
||||
else MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
});
|
||||
|
||||
form.AddEvent(tankDelegate);
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора
|
||||
@ -103,8 +107,10 @@ namespace ProjectTank
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRemoveTank_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1) return;
|
||||
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null) return;
|
||||
|
||||
|
365
ProjectTank/FormTankConfig.Designer.cs
generated
Normal file
365
ProjectTank/FormTankConfig.Designer.cs
generated
Normal file
@ -0,0 +1,365 @@
|
||||
namespace ProjectTank
|
||||
{
|
||||
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()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
contextMenuStrip1 = new ContextMenuStrip(components);
|
||||
mainGroupBox = new GroupBox();
|
||||
labelModifiedObject = new Label();
|
||||
labelSimpleObject = new Label();
|
||||
colorsGroupBox = new GroupBox();
|
||||
bluePanel = new Panel();
|
||||
blackPanel = new Panel();
|
||||
orangePanel = new Panel();
|
||||
greenPanel = new Panel();
|
||||
redPanel = new Panel();
|
||||
purplePanel = new Panel();
|
||||
cyanPanel = new Panel();
|
||||
yellowPanel = new Panel();
|
||||
checkBoxAntiAirforceGun = new CheckBox();
|
||||
checkBoxTankTower = new CheckBox();
|
||||
numericUpDownWeight = new NumericUpDown();
|
||||
numericUpDownSpeed = new NumericUpDown();
|
||||
weightLabel = new Label();
|
||||
speedLabel = new Label();
|
||||
mainColorLabel = new Label();
|
||||
additionalColorLabel = new Label();
|
||||
addButton = new Button();
|
||||
cancelButton = new Button();
|
||||
pictureBoxPanel = new Panel();
|
||||
pictureBoxObject = new PictureBox();
|
||||
mainGroupBox.SuspendLayout();
|
||||
colorsGroupBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||
pictureBoxPanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// contextMenuStrip1
|
||||
//
|
||||
contextMenuStrip1.ImageScalingSize = new Size(20, 20);
|
||||
contextMenuStrip1.Name = "contextMenuStrip1";
|
||||
contextMenuStrip1.Size = new Size(61, 4);
|
||||
//
|
||||
// mainGroupBox
|
||||
//
|
||||
mainGroupBox.Controls.Add(labelModifiedObject);
|
||||
mainGroupBox.Controls.Add(labelSimpleObject);
|
||||
mainGroupBox.Controls.Add(colorsGroupBox);
|
||||
mainGroupBox.Controls.Add(checkBoxAntiAirforceGun);
|
||||
mainGroupBox.Controls.Add(checkBoxTankTower);
|
||||
mainGroupBox.Controls.Add(numericUpDownWeight);
|
||||
mainGroupBox.Controls.Add(numericUpDownSpeed);
|
||||
mainGroupBox.Controls.Add(weightLabel);
|
||||
mainGroupBox.Controls.Add(speedLabel);
|
||||
mainGroupBox.Location = new Point(12, 12);
|
||||
mainGroupBox.Name = "mainGroupBox";
|
||||
mainGroupBox.Size = new Size(610, 239);
|
||||
mainGroupBox.TabIndex = 1;
|
||||
mainGroupBox.TabStop = false;
|
||||
mainGroupBox.Text = "Параметры";
|
||||
//
|
||||
// labelModifiedObject
|
||||
//
|
||||
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelModifiedObject.Location = new Point(465, 179);
|
||||
labelModifiedObject.Name = "labelModifiedObject";
|
||||
labelModifiedObject.Size = new Size(127, 47);
|
||||
labelModifiedObject.TabIndex = 8;
|
||||
labelModifiedObject.Text = "Продвинутый";
|
||||
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelSimpleObject.Location = new Point(322, 179);
|
||||
labelSimpleObject.Name = "labelSimpleObject";
|
||||
labelSimpleObject.Size = new Size(127, 47);
|
||||
labelSimpleObject.TabIndex = 5;
|
||||
labelSimpleObject.Text = "Простой";
|
||||
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// colorsGroupBox
|
||||
//
|
||||
colorsGroupBox.Controls.Add(bluePanel);
|
||||
colorsGroupBox.Controls.Add(blackPanel);
|
||||
colorsGroupBox.Controls.Add(orangePanel);
|
||||
colorsGroupBox.Controls.Add(greenPanel);
|
||||
colorsGroupBox.Controls.Add(redPanel);
|
||||
colorsGroupBox.Controls.Add(purplePanel);
|
||||
colorsGroupBox.Controls.Add(cyanPanel);
|
||||
colorsGroupBox.Controls.Add(yellowPanel);
|
||||
colorsGroupBox.Location = new Point(322, 26);
|
||||
colorsGroupBox.Name = "colorsGroupBox";
|
||||
colorsGroupBox.Size = new Size(270, 145);
|
||||
colorsGroupBox.TabIndex = 2;
|
||||
colorsGroupBox.TabStop = false;
|
||||
colorsGroupBox.Text = "Цвета";
|
||||
//
|
||||
// bluePanel
|
||||
//
|
||||
bluePanel.BackColor = Color.Blue;
|
||||
bluePanel.Location = new Point(211, 84);
|
||||
bluePanel.Name = "bluePanel";
|
||||
bluePanel.Size = new Size(49, 48);
|
||||
bluePanel.TabIndex = 4;
|
||||
//
|
||||
// blackPanel
|
||||
//
|
||||
blackPanel.BackColor = Color.Black;
|
||||
blackPanel.Location = new Point(143, 84);
|
||||
blackPanel.Name = "blackPanel";
|
||||
blackPanel.Size = new Size(49, 48);
|
||||
blackPanel.TabIndex = 3;
|
||||
//
|
||||
// orangePanel
|
||||
//
|
||||
orangePanel.BackColor = Color.FromArgb(255, 128, 0);
|
||||
orangePanel.Location = new Point(78, 84);
|
||||
orangePanel.Name = "orangePanel";
|
||||
orangePanel.Size = new Size(49, 48);
|
||||
orangePanel.TabIndex = 2;
|
||||
//
|
||||
// greenPanel
|
||||
//
|
||||
greenPanel.BackColor = Color.Lime;
|
||||
greenPanel.Location = new Point(12, 84);
|
||||
greenPanel.Name = "greenPanel";
|
||||
greenPanel.Size = new Size(49, 48);
|
||||
greenPanel.TabIndex = 1;
|
||||
//
|
||||
// redPanel
|
||||
//
|
||||
redPanel.BackColor = Color.Red;
|
||||
redPanel.Location = new Point(211, 26);
|
||||
redPanel.Name = "redPanel";
|
||||
redPanel.Size = new Size(49, 48);
|
||||
redPanel.TabIndex = 3;
|
||||
//
|
||||
// purplePanel
|
||||
//
|
||||
purplePanel.BackColor = Color.Fuchsia;
|
||||
purplePanel.Location = new Point(143, 26);
|
||||
purplePanel.Name = "purplePanel";
|
||||
purplePanel.Size = new Size(49, 48);
|
||||
purplePanel.TabIndex = 2;
|
||||
//
|
||||
// cyanPanel
|
||||
//
|
||||
cyanPanel.BackColor = Color.Cyan;
|
||||
cyanPanel.Location = new Point(78, 26);
|
||||
cyanPanel.Name = "cyanPanel";
|
||||
cyanPanel.Size = new Size(49, 48);
|
||||
cyanPanel.TabIndex = 1;
|
||||
//
|
||||
// yellowPanel
|
||||
//
|
||||
yellowPanel.BackColor = Color.FromArgb(255, 255, 128);
|
||||
yellowPanel.Location = new Point(12, 26);
|
||||
yellowPanel.Name = "yellowPanel";
|
||||
yellowPanel.Size = new Size(49, 48);
|
||||
yellowPanel.TabIndex = 0;
|
||||
//
|
||||
// checkBoxAntiAirforceGun
|
||||
//
|
||||
checkBoxAntiAirforceGun.AutoSize = true;
|
||||
checkBoxAntiAirforceGun.Location = new Point(17, 175);
|
||||
checkBoxAntiAirforceGun.Name = "checkBoxAntiAirforceGun";
|
||||
checkBoxAntiAirforceGun.Size = new Size(287, 24);
|
||||
checkBoxAntiAirforceGun.TabIndex = 7;
|
||||
checkBoxAntiAirforceGun.Text = "Признак наличия зенитного оружия";
|
||||
checkBoxAntiAirforceGun.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxTankTower
|
||||
//
|
||||
checkBoxTankTower.AutoSize = true;
|
||||
checkBoxTankTower.Location = new Point(17, 134);
|
||||
checkBoxTankTower.Name = "checkBoxTankTower";
|
||||
checkBoxTankTower.Size = new Size(253, 24);
|
||||
checkBoxTankTower.TabIndex = 6;
|
||||
checkBoxTankTower.Text = "Признак наличия дула и башни";
|
||||
checkBoxTankTower.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
numericUpDownWeight.Location = new Point(99, 80);
|
||||
numericUpDownWeight.Maximum = new decimal(new int[] { 3000, 0, 0, 0 });
|
||||
numericUpDownWeight.Minimum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||
numericUpDownWeight.Name = "numericUpDownWeight";
|
||||
numericUpDownWeight.Size = new Size(150, 27);
|
||||
numericUpDownWeight.TabIndex = 5;
|
||||
numericUpDownWeight.Value = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
numericUpDownSpeed.Location = new Point(99, 40);
|
||||
numericUpDownSpeed.Maximum = new decimal(new int[] { 300, 0, 0, 0 });
|
||||
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||
numericUpDownSpeed.Size = new Size(150, 27);
|
||||
numericUpDownSpeed.TabIndex = 4;
|
||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// weightLabel
|
||||
//
|
||||
weightLabel.AutoSize = true;
|
||||
weightLabel.Location = new Point(17, 82);
|
||||
weightLabel.Name = "weightLabel";
|
||||
weightLabel.Size = new Size(36, 20);
|
||||
weightLabel.TabIndex = 3;
|
||||
weightLabel.Text = "Вес:";
|
||||
//
|
||||
// speedLabel
|
||||
//
|
||||
speedLabel.AutoSize = true;
|
||||
speedLabel.Location = new Point(17, 42);
|
||||
speedLabel.Name = "speedLabel";
|
||||
speedLabel.Size = new Size(76, 20);
|
||||
speedLabel.TabIndex = 2;
|
||||
speedLabel.Text = "Скорость:";
|
||||
//
|
||||
// mainColorLabel
|
||||
//
|
||||
mainColorLabel.AllowDrop = true;
|
||||
mainColorLabel.BorderStyle = BorderStyle.FixedSingle;
|
||||
mainColorLabel.Location = new Point(13, 9);
|
||||
mainColorLabel.Name = "mainColorLabel";
|
||||
mainColorLabel.Size = new Size(92, 38);
|
||||
mainColorLabel.TabIndex = 9;
|
||||
mainColorLabel.Text = "Цвет";
|
||||
mainColorLabel.TextAlign = ContentAlignment.MiddleCenter;
|
||||
mainColorLabel.DragDrop += ColorLabel_DragDrop;
|
||||
mainColorLabel.DragEnter += ColorLabel_DragEnter;
|
||||
//
|
||||
// additionalColorLabel
|
||||
//
|
||||
additionalColorLabel.AllowDrop = true;
|
||||
additionalColorLabel.BorderStyle = BorderStyle.FixedSingle;
|
||||
additionalColorLabel.Location = new Point(126, 9);
|
||||
additionalColorLabel.Name = "additionalColorLabel";
|
||||
additionalColorLabel.Size = new Size(92, 38);
|
||||
additionalColorLabel.TabIndex = 10;
|
||||
additionalColorLabel.Text = "Доп. Цвет";
|
||||
additionalColorLabel.TextAlign = ContentAlignment.MiddleCenter;
|
||||
additionalColorLabel.DragDrop += ColorLabel_DragDrop;
|
||||
additionalColorLabel.DragEnter += ColorLabel_DragEnter;
|
||||
//
|
||||
// addButton
|
||||
//
|
||||
addButton.Location = new Point(632, 222);
|
||||
addButton.Name = "addButton";
|
||||
addButton.Size = new Size(94, 29);
|
||||
addButton.TabIndex = 11;
|
||||
addButton.Text = "Добавить";
|
||||
addButton.UseVisualStyleBackColor = true;
|
||||
addButton.Click += ButtonOk_Click;
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
cancelButton.Location = new Point(769, 222);
|
||||
cancelButton.Name = "cancelButton";
|
||||
cancelButton.Size = new Size(94, 29);
|
||||
cancelButton.TabIndex = 12;
|
||||
cancelButton.Text = "Отмена";
|
||||
cancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// pictureBoxPanel
|
||||
//
|
||||
pictureBoxPanel.AllowDrop = true;
|
||||
pictureBoxPanel.Controls.Add(pictureBoxObject);
|
||||
pictureBoxPanel.Controls.Add(mainColorLabel);
|
||||
pictureBoxPanel.Controls.Add(additionalColorLabel);
|
||||
pictureBoxPanel.Location = new Point(628, 22);
|
||||
pictureBoxPanel.Name = "pictureBoxPanel";
|
||||
pictureBoxPanel.Size = new Size(235, 189);
|
||||
pictureBoxPanel.TabIndex = 9;
|
||||
pictureBoxPanel.DragDrop += PanelObject_DragDrop;
|
||||
pictureBoxPanel.DragEnter += PanelObject_DragEnter;
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
pictureBoxObject.Location = new Point(13, 60);
|
||||
pictureBoxObject.Name = "pictureBoxObject";
|
||||
pictureBoxObject.Size = new Size(205, 117);
|
||||
pictureBoxObject.TabIndex = 13;
|
||||
pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// FormTankConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(875, 267);
|
||||
Controls.Add(pictureBoxPanel);
|
||||
Controls.Add(cancelButton);
|
||||
Controls.Add(addButton);
|
||||
Controls.Add(mainGroupBox);
|
||||
Name = "FormTankConfig";
|
||||
Text = "Настройка конфигурации танка";
|
||||
mainGroupBox.ResumeLayout(false);
|
||||
mainGroupBox.PerformLayout();
|
||||
colorsGroupBox.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||
pictureBoxPanel.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ContextMenuStrip contextMenuStrip1;
|
||||
private GroupBox mainGroupBox;
|
||||
private CheckBox checkBoxAntiAirforceGun;
|
||||
private CheckBox checkBoxTankTower;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private Label weightLabel;
|
||||
private Label speedLabel;
|
||||
private GroupBox colorsGroupBox;
|
||||
private Panel redPanel;
|
||||
private Panel purplePanel;
|
||||
private Panel cyanPanel;
|
||||
private Panel yellowPanel;
|
||||
private Panel greenPanel;
|
||||
private Panel bluePanel;
|
||||
private Panel blackPanel;
|
||||
private Panel orangePanel;
|
||||
private Label labelSimpleObject;
|
||||
private Label labelModifiedObject;
|
||||
private Label mainColorLabel;
|
||||
private Label additionalColorLabel;
|
||||
private Button addButton;
|
||||
private Button cancelButton;
|
||||
private Panel pictureBoxPanel;
|
||||
private PictureBox pictureBoxObject;
|
||||
}
|
||||
}
|
154
ProjectTank/FormTankConfig.cs
Normal file
154
ProjectTank/FormTankConfig.cs
Normal file
@ -0,0 +1,154 @@
|
||||
using ProjectTank.DrawningObjects;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ProjectTank
|
||||
{
|
||||
/// <summary>
|
||||
/// Форма создания объекта
|
||||
/// </summary>
|
||||
public partial class FormTankConfig : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Переменная-выбранный танк
|
||||
/// </summary>
|
||||
DrawningTankBase? _tank = null;
|
||||
/// <summary>
|
||||
/// Событие
|
||||
/// </summary>
|
||||
private event Action<DrawningTankBase>? EventAddTank;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormTankConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
yellowPanel.MouseDown += PanelColor_MouseDown;
|
||||
cyanPanel.MouseDown += PanelColor_MouseDown;
|
||||
purplePanel.MouseDown += PanelColor_MouseDown;
|
||||
redPanel.MouseDown += PanelColor_MouseDown;
|
||||
greenPanel.MouseDown += PanelColor_MouseDown;
|
||||
orangePanel.MouseDown += PanelColor_MouseDown;
|
||||
blackPanel.MouseDown += PanelColor_MouseDown;
|
||||
bluePanel.MouseDown += PanelColor_MouseDown;
|
||||
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
||||
cancelButton.Click += (s, e) => Close();
|
||||
}
|
||||
/// <summary>
|
||||
/// Отрисовать танк
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление события
|
||||
/// </summary>
|
||||
/// <param name="ev">Привязанный метод</param>
|
||||
public void AddEvent(Action<DrawningTankBase> ev)
|
||||
{
|
||||
if (EventAddTank == null) EventAddTank = ev;
|
||||
else EventAddTank += ev;
|
||||
}
|
||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
/// <summary>
|
||||
/// Передаем информацию при нажатии на Label
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
/// <summary>
|
||||
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Действия при приеме перетаскиваемой информации
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "labelSimpleObject":
|
||||
_tank = new DrawningTankBase((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
|
||||
pictureBoxObject.Height);
|
||||
break;
|
||||
case "labelModifiedObject":
|
||||
_tank = new DrawningTank((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxTankTower.Checked,
|
||||
checkBoxAntiAirforceGun.Checked, pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
break;
|
||||
}
|
||||
|
||||
mainColorLabel.BackColor = Color.Empty;
|
||||
additionalColorLabel.BackColor = Color.Empty;
|
||||
DrawTank();
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление танка
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddTank?.Invoke(_tank);
|
||||
Close();
|
||||
}
|
||||
private void ColorLabel_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
string senderName = ((Label)sender).Name;
|
||||
if (_tank == null || e.Data.GetDataPresent(typeof(Color)) == false)
|
||||
return;
|
||||
|
||||
Color droppedColor = (Color)e.Data.GetData(typeof(Color));
|
||||
|
||||
if (senderName == "mainColorLabel")
|
||||
{
|
||||
mainColorLabel.BackColor = droppedColor;
|
||||
((DrawningTankBase)_tank).ChangeColor(mainColorLabel.BackColor);
|
||||
}
|
||||
else if (senderName == "additionalColorLabel" && _tank is DrawningTank)
|
||||
{
|
||||
additionalColorLabel.BackColor = droppedColor;
|
||||
((DrawningTank)_tank).ChangeAdditionalColor(additionalColorLabel.BackColor);
|
||||
}
|
||||
|
||||
DrawTank();
|
||||
}
|
||||
private void ColorLabel_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
123
ProjectTank/FormTankConfig.resx
Normal file
123
ProjectTank/FormTankConfig.resx
Normal file
@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<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>
|
||||
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user