lab 5 is done

This commit is contained in:
vladimir_zinovev 2023-12-14 21:48:23 +04:00
parent 904197e493
commit ef62f8b016
11 changed files with 676 additions and 22 deletions

View File

@ -184,7 +184,7 @@
this.Controls.Add(this.ArmoredTransportCollectionFormToolsGroup);
this.Controls.Add(this.pictureBoxCollection);
this.Name = "ArmoredTransportCollectionForm";
this.Text = "ArmoredTransportCollectionForm";
this.Text = "Коллекция бронированного транспорта";
this.ArmoredTransportCollectionFormToolsGroup.ResumeLayout(false);
this.ArmoredTransportCollectionFormToolsGroup.PerformLayout();
this.groupBox1.ResumeLayout(false);

View File

@ -65,10 +65,9 @@ namespace ProjectTank
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ListBoxObjects_SelectedIndexChanged(object sender,EventArgs e)
private void ListBoxObjects_SelectedIndexChanged(object sender, EventArgs e)
{
pictureBoxCollection.Image =
_storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowArmoredTransports();
pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowArmoredTransports();
}
/// <summary>
/// Удаление набора
@ -81,7 +80,8 @@ namespace ProjectTank
{
return;
}
if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes){
if (MessageBox.Show($"Удалить объект: {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
_storage.DelSet(listBoxStorages.SelectedItem.ToString()??string.Empty);
ReloadObjects();
if (listBoxStorages.SelectedIndex == -1)
@ -112,10 +112,12 @@ namespace ProjectTank
{
return;
}
TankForm form = new();
if (form.ShowDialog() == DialogResult.OK)
ArmoredTransportConfigForm form = new(pictureBoxCollection.Width, pictureBoxCollection.Height);
form.Show();
Action<DrawningArmoredTransport>? armoredTransportDelegate = new((m) =>
{
if (obj + form.SelectedArmoredTransport)
bool q = (obj + m);
if (q)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowArmoredTransports();
@ -124,7 +126,8 @@ namespace ProjectTank
{
MessageBox.Show("Не удалось добавить объект");
}
}
});
form.AddEvent(armoredTransportDelegate);
}
/// <summary>
/// Удаление объекта из набора
@ -137,13 +140,12 @@ namespace ProjectTank
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString()??string.Empty];
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.No)
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
@ -163,7 +165,8 @@ namespace ProjectTank
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
private void ButtonRefreshCollection_Click(object sender, EventArgs
e)
{
if (listBoxStorages.SelectedIndex == -1)
{

View File

@ -0,0 +1,399 @@
namespace ProjectTank
{
partial class ArmoredTransportConfigForm
{
/// <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.groupBox1 = new System.Windows.Forms.GroupBox();
this.labelModifiedObject = new System.Windows.Forms.Label();
this.labelSimpleObject = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.panelYellow = new System.Windows.Forms.Panel();
this.panelPurple = new System.Windows.Forms.Panel();
this.panelBlue = new System.Windows.Forms.Panel();
this.panelBlack = new System.Windows.Forms.Panel();
this.panelGreen = new System.Windows.Forms.Panel();
this.panelGray = new System.Windows.Forms.Panel();
this.panelWhite = new System.Windows.Forms.Panel();
this.panelRed = new System.Windows.Forms.Panel();
this.checkBoxMachineGun = new System.Windows.Forms.CheckBox();
this.checkBoxGun = new System.Windows.Forms.CheckBox();
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.pictureBox = new System.Windows.Forms.PictureBox();
this.panel9 = new System.Windows.Forms.Panel();
this.addColorLabel = new System.Windows.Forms.Label();
this.colorLabel = new System.Windows.Forms.Label();
this.buttonOk = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
this.panel9.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.labelModifiedObject);
this.groupBox1.Controls.Add(this.labelSimpleObject);
this.groupBox1.Controls.Add(this.groupBox2);
this.groupBox1.Controls.Add(this.checkBoxMachineGun);
this.groupBox1.Controls.Add(this.checkBoxGun);
this.groupBox1.Controls.Add(this.numericUpDownWeight);
this.groupBox1.Controls.Add(this.numericUpDownSpeed);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Location = new System.Drawing.Point(23, 23);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(888, 523);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Параметры";
//
// labelModifiedObject
//
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelModifiedObject.Location = new System.Drawing.Point(634, 428);
this.labelModifiedObject.Name = "labelModifiedObject";
this.labelModifiedObject.Size = new System.Drawing.Size(230, 70);
this.labelModifiedObject.TabIndex = 8;
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(348, 428);
this.labelSimpleObject.Name = "labelSimpleObject";
this.labelSimpleObject.Size = new System.Drawing.Size(230, 70);
this.labelSimpleObject.TabIndex = 7;
this.labelSimpleObject.Text = "Простой";
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelSimpleObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.colorLabel_DragDrop);
this.labelSimpleObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.colorLabel_DragEnter);
this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.panelYellow);
this.groupBox2.Controls.Add(this.panelPurple);
this.groupBox2.Controls.Add(this.panelBlue);
this.groupBox2.Controls.Add(this.panelBlack);
this.groupBox2.Controls.Add(this.panelGreen);
this.groupBox2.Controls.Add(this.panelGray);
this.groupBox2.Controls.Add(this.panelWhite);
this.groupBox2.Controls.Add(this.panelRed);
this.groupBox2.Location = new System.Drawing.Point(348, 72);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(516, 298);
this.groupBox2.TabIndex = 6;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Цвета";
//
// panelYellow
//
this.panelYellow.AllowDrop = true;
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
this.panelYellow.Location = new System.Drawing.Point(381, 38);
this.panelYellow.Name = "panelYellow";
this.panelYellow.Size = new System.Drawing.Size(100, 100);
this.panelYellow.TabIndex = 4;
this.panelYellow.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelPurple
//
this.panelPurple.AllowDrop = true;
this.panelPurple.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(0)))), ((int)(((byte)(64)))));
this.panelPurple.Location = new System.Drawing.Point(381, 170);
this.panelPurple.Name = "panelPurple";
this.panelPurple.Size = new System.Drawing.Size(100, 100);
this.panelPurple.TabIndex = 4;
this.panelPurple.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelBlue
//
this.panelBlue.AllowDrop = true;
this.panelBlue.BackColor = System.Drawing.Color.Blue;
this.panelBlue.Location = new System.Drawing.Point(259, 38);
this.panelBlue.Name = "panelBlue";
this.panelBlue.Size = new System.Drawing.Size(100, 100);
this.panelBlue.TabIndex = 4;
this.panelBlue.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelBlack
//
this.panelBlack.AllowDrop = true;
this.panelBlack.BackColor = System.Drawing.Color.Black;
this.panelBlack.Location = new System.Drawing.Point(259, 170);
this.panelBlack.Name = "panelBlack";
this.panelBlack.Size = new System.Drawing.Size(100, 100);
this.panelBlack.TabIndex = 4;
this.panelBlack.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelGreen
//
this.panelGreen.AllowDrop = true;
this.panelGreen.BackColor = System.Drawing.Color.Lime;
this.panelGreen.Location = new System.Drawing.Point(138, 38);
this.panelGreen.Name = "panelGreen";
this.panelGreen.Size = new System.Drawing.Size(100, 100);
this.panelGreen.TabIndex = 2;
this.panelGreen.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelGray
//
this.panelGray.AllowDrop = true;
this.panelGray.BackColor = System.Drawing.Color.Silver;
this.panelGray.Location = new System.Drawing.Point(138, 170);
this.panelGray.Name = "panelGray";
this.panelGray.Size = new System.Drawing.Size(100, 100);
this.panelGray.TabIndex = 3;
this.panelGray.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelWhite
//
this.panelWhite.AllowDrop = true;
this.panelWhite.BackColor = System.Drawing.Color.White;
this.panelWhite.Location = new System.Drawing.Point(20, 170);
this.panelWhite.Name = "panelWhite";
this.panelWhite.Size = new System.Drawing.Size(100, 100);
this.panelWhite.TabIndex = 1;
this.panelWhite.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panelRed
//
this.panelRed.AllowDrop = true;
this.panelRed.BackColor = System.Drawing.Color.Red;
this.panelRed.Location = new System.Drawing.Point(20, 38);
this.panelRed.Name = "panelRed";
this.panelRed.Size = new System.Drawing.Size(100, 100);
this.panelRed.TabIndex = 0;
this.panelRed.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// checkBoxMachineGun
//
this.checkBoxMachineGun.AutoSize = true;
this.checkBoxMachineGun.Location = new System.Drawing.Point(20, 247);
this.checkBoxMachineGun.Name = "checkBoxMachineGun";
this.checkBoxMachineGun.Size = new System.Drawing.Size(141, 36);
this.checkBoxMachineGun.TabIndex = 5;
this.checkBoxMachineGun.Text = "Пулемет";
this.checkBoxMachineGun.UseVisualStyleBackColor = true;
//
// checkBoxGun
//
this.checkBoxGun.AutoSize = true;
this.checkBoxGun.Location = new System.Drawing.Point(20, 197);
this.checkBoxGun.Name = "checkBoxGun";
this.checkBoxGun.Size = new System.Drawing.Size(118, 36);
this.checkBoxGun.TabIndex = 4;
this.checkBoxGun.Text = "Пушка";
this.checkBoxGun.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
this.numericUpDownWeight.Location = new System.Drawing.Point(172, 118);
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(143, 39);
this.numericUpDownWeight.TabIndex = 3;
this.numericUpDownWeight.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// numericUpDownSpeed
//
this.numericUpDownSpeed.Location = new System.Drawing.Point(172, 65);
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(143, 39);
this.numericUpDownSpeed.TabIndex = 2;
this.numericUpDownSpeed.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(20, 125);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(57, 32);
this.label2.TabIndex = 1;
this.label2.Text = "Вес:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(17, 72);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(121, 32);
this.label1.TabIndex = 0;
this.label1.Text = "Скорость:";
//
// pictureBox
//
this.pictureBox.Location = new System.Drawing.Point(16, 98);
this.pictureBox.Name = "pictureBox";
this.pictureBox.Size = new System.Drawing.Size(517, 289);
this.pictureBox.TabIndex = 1;
this.pictureBox.TabStop = false;
//
// panel9
//
this.panel9.AllowDrop = true;
this.panel9.Controls.Add(this.addColorLabel);
this.panel9.Controls.Add(this.colorLabel);
this.panel9.Controls.Add(this.pictureBox);
this.panel9.Location = new System.Drawing.Point(929, 42);
this.panel9.Name = "panel9";
this.panel9.Size = new System.Drawing.Size(549, 409);
this.panel9.TabIndex = 2;
this.panel9.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
this.panel9.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
//
// addColorLabel
//
this.addColorLabel.AllowDrop = true;
this.addColorLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.addColorLabel.Location = new System.Drawing.Point(303, 13);
this.addColorLabel.Name = "addColorLabel";
this.addColorLabel.Size = new System.Drawing.Size(230, 70);
this.addColorLabel.TabIndex = 10;
this.addColorLabel.Text = "Доп. цвет";
this.addColorLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.addColorLabel.DragDrop += new System.Windows.Forms.DragEventHandler(this.addColorLabel_DragDrop);
this.addColorLabel.DragEnter += new System.Windows.Forms.DragEventHandler(this.addColorLabel_DragEnter);
//
// colorLabel
//
this.colorLabel.AllowDrop = true;
this.colorLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.colorLabel.Location = new System.Drawing.Point(16, 13);
this.colorLabel.Name = "colorLabel";
this.colorLabel.Size = new System.Drawing.Size(230, 70);
this.colorLabel.TabIndex = 9;
this.colorLabel.Text = "Цвет";
this.colorLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.colorLabel.DragDrop += new System.Windows.Forms.DragEventHandler(this.colorLabel_DragDrop);
this.colorLabel.DragEnter += new System.Windows.Forms.DragEventHandler(this.colorLabel_DragEnter);
//
// buttonOk
//
this.buttonOk.Location = new System.Drawing.Point(945, 474);
this.buttonOk.Name = "buttonOk";
this.buttonOk.Size = new System.Drawing.Size(200, 60);
this.buttonOk.TabIndex = 3;
this.buttonOk.Text = "Добавить";
this.buttonOk.UseVisualStyleBackColor = true;
this.buttonOk.Click += new System.EventHandler(this.ButtonOk_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(1262, 474);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(200, 60);
this.buttonCancel.TabIndex = 4;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
//
// ArmoredTransportConfigForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1497, 577);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOk);
this.Controls.Add(this.panel9);
this.Controls.Add(this.groupBox1);
this.Name = "ArmoredTransportConfigForm";
this.Text = "Создание объекта";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
this.panel9.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private GroupBox groupBox1;
private CheckBox checkBoxMachineGun;
private CheckBox checkBoxGun;
private NumericUpDown numericUpDownWeight;
private NumericUpDown numericUpDownSpeed;
private Label label2;
private Label label1;
private Label labelModifiedObject;
private Label labelSimpleObject;
private GroupBox groupBox2;
private Panel panelYellow;
private Panel panelPurple;
private Panel panelBlue;
private Panel panelBlack;
private Panel panelGreen;
private Panel panelGray;
private Panel panelWhite;
private Panel panelRed;
private PictureBox pictureBox;
private Panel panel9;
private Label addColorLabel;
private Label colorLabel;
private Button buttonOk;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,183 @@
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;
using System;
using System.Collections.Generic;
using ProjectTank.DrawningObjects;
using ProjectTank.Entities;
namespace ProjectTank
{
/// <summary>
/// Форма создания объекта
/// </summary>
public partial class ArmoredTransportConfigForm : Form
{
private readonly int PictureWidth;
private readonly int PictureHeight;
/// <summary>
/// Переменная-выбранная машина
/// </summary>
DrawningArmoredTransport? _armoredTransport = null;
/// <summary>
/// Событие
/// </summary>
Action<DrawningArmoredTransport>? EventAddArmoredTransport;
/// <summary>
/// Конструктор
/// </summary>
public ArmoredTransportConfigForm(int width, int height)
{
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();
PictureWidth = width;
PictureHeight = height;
}
/// <summary>
/// Отрисовать машину
/// </summary>
private void DrawArmoredTransport()
{
Bitmap bmp = new(pictureBox.Width, pictureBox.Height);
Graphics gr = Graphics.FromImage(bmp);
_armoredTransport?.SetPosition(5, 5);
_armoredTransport?.DrawTransport(gr);
pictureBox.Image = bmp;
}
/// <summary>
/// Добавление события
/// </summary>
/// <param name="ev">Привязанный метод</param>
public void AddEvent(Action<DrawningArmoredTransport>? ev)
{
if (EventAddArmoredTransport == null)
{
EventAddArmoredTransport = ev;
}
else
{
EventAddArmoredTransport += 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) ?? 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":
_armoredTransport = new DrawningArmoredTransport((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, PictureWidth, PictureHeight);
break;
case "labelModifiedObject":
_armoredTransport = new DrawningTank((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxGun.Checked, checkBoxMachineGun.Checked, PictureWidth, PictureHeight);
break;
}
DrawArmoredTransport();
}
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
{
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
}
private void allowPanel_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 ButtonOk_Click(object sender, EventArgs e)
{
EventAddArmoredTransport?.Invoke(_armoredTransport);
Close();
}
private void colorLabel_DragDrop(object sender, DragEventArgs e)
{
if (_armoredTransport == null)
return;
_armoredTransport.ChangeColor((Color)e.Data.GetData(typeof(Color)));
DrawArmoredTransport();
}
private void colorLabel_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void addColorLabel_DragDrop(object sender, DragEventArgs e)
{
if ((_armoredTransport == null) || (_armoredTransport is DrawningTank == false))
return;
((DrawningTank)_armoredTransport).ChangeAddColor((Color)e.Data.GetData(typeof(Color)));
DrawArmoredTransport();
}
private void addColorLabel_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
}
}

View 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>

View File

@ -119,6 +119,7 @@ namespace ProjectTank.Generics
}
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth,
_pictureHeight / _placeSizeHeight * _placeSizeHeight);
}
}
/// <summary>

View File

@ -12,8 +12,7 @@ namespace ProjectTank.Generics
/// <summary>
/// Словарь (хранилище)
/// </summary>
readonly Dictionary<string, ArmoredTransportsGenericCollection<DrawningArmoredTransport,
DrawningObjectArmoredTransport>> _armoredTransportStorages;
readonly Dictionary<string, ArmoredTransportsGenericCollection<DrawningArmoredTransport, DrawningObjectArmoredTransport>> _armoredTransportStorages;
/// <summary>
/// Возвращение списка названий наборов
/// </summary>
@ -33,8 +32,7 @@ namespace ProjectTank.Generics
/// <param name="pictureHeight"></param>
public ArmoredTransportsGenericStorage(int pictureWidth, int pictureHeight)
{
_armoredTransportStorages = new Dictionary<string, ArmoredTransportsGenericCollection<DrawningArmoredTransport,
DrawningObjectArmoredTransport>>();
_armoredTransportStorages = new Dictionary<string, ArmoredTransportsGenericCollection<DrawningArmoredTransport, DrawningObjectArmoredTransport>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
@ -44,9 +42,7 @@ namespace ProjectTank.Generics
/// <param name="name">Название набора</param>
public void AddSet(string name)
{
_armoredTransportStorages.Add(name, new ArmoredTransportsGenericCollection<DrawningArmoredTransport,
DrawningObjectArmoredTransport>(_pictureWidth,
_pictureHeight));
_armoredTransportStorages.Add(name, new ArmoredTransportsGenericCollection<DrawningArmoredTransport, DrawningObjectArmoredTransport>(_pictureWidth, _pictureHeight));
}
/// <summary>
/// Удаление набора

View File

@ -119,6 +119,14 @@ namespace ProjectTank.DrawningObjects
_startPosY = y;
}
}
public void ChangeColor(Color color)
{
if (EntityArmoredTransport == null)
{
return;
}
EntityArmoredTransport.BodyColor = color;
}
/// <summary>
/// Прорисовка объекта
/// </summary>

View File

@ -34,6 +34,10 @@ namespace ProjectTank.DrawningObjects
additionalColor, gun, machineGun);
}
}
public void ChangeAddColor(Color color)
{
((EntityTank)EntityArmoredTransport).AdditionalColor = color;
}
public override void DrawTransport(Graphics g)
{
if (EntityArmoredTransport is not EntityTank tank)

View File

@ -22,7 +22,7 @@ namespace ProjectTank.Entities
/// <summary>
/// Основной цвет
/// </summary>
public Color BodyColor { get; private set; }
public Color BodyColor { get; set; }
/// <summary>
/// Шаг перемещения автомобиля
/// </summary>

View File

@ -15,7 +15,7 @@ namespace ProjectTank.Entities
/// <summary>
/// Дополнительный цвет (для опциональных элементов)
/// </summary>
public Color AdditionalColor { get; private set; }
public Color AdditionalColor { get; set; }
/// <summary>
/// Пушка
/// </summary>