ПИбд-23 Тихоненков А.Е. Лабораторная №5 #13
@ -16,9 +16,18 @@ namespace AntiAircraftGun.DrawingObjects
|
||||
public AdvancedDrawingAntiAirCraftGun(int speed, double weight, Color bodyColor, Color additionalColor, Color dopColor, bool rocket,bool radar, int width, int height) :
|
||||
base(speed, weight, bodyColor, additionalColor, width, height)
|
||||
{
|
||||
AntiAirСraftGun = new EntityAdvancedAntiAirCraftGun(speed, weight, bodyColor, additionalColor, dopColor, rocket,radar);
|
||||
if (AntiAirСraftGun!=null)
|
||||
{
|
||||
AntiAirСraftGun = new EntityAdvancedAntiAirCraftGun(speed, weight, bodyColor, additionalColor, dopColor, rocket, radar);
|
||||
}
|
||||
}
|
||||
public void ChangeAddColor(Color col)
|
||||
{
|
||||
if (AntiAirСraftGun!=null)
|
||||
{
|
||||
((EntityAdvancedAntiAirCraftGun)AntiAirСraftGun).DopColor = col;
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (AntiAirСraftGun is not EntityAdvancedAntiAirCraftGun advancedGun)
|
||||
|
@ -11,8 +11,8 @@ namespace AntiAircraftGun.DrawingObjects
|
||||
public class BaseDrawingAntiAirCraftGun
|
||||
{
|
||||
public EntityAntiAirCraftGun? AntiAirСraftGun { get; protected set; }
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
private int _pictureWidth;
|
||||
private int _pictureHeight;
|
||||
protected int _startPosX;
|
||||
protected int _startPosY;
|
||||
protected int _zenitWidth = 110;
|
||||
@ -20,6 +20,8 @@ namespace AntiAircraftGun.DrawingObjects
|
||||
|
||||
public BaseDrawingAntiAirCraftGun(int speed, double weight, Color bodyColor, Color additionalColor, int width, int height)
|
||||
{
|
||||
if (width <= _zenitWidth || height <= _zenitHeight)
|
||||
return;
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
AntiAirСraftGun = new EntityAntiAirCraftGun(speed, weight, bodyColor, additionalColor);
|
||||
@ -46,6 +48,18 @@ namespace AntiAircraftGun.DrawingObjects
|
||||
}
|
||||
|
||||
}
|
||||
public void ChangeColor(Color col)
|
||||
{
|
||||
if (AntiAirСraftGun == null)
|
||||
return;
|
||||
AntiAirСraftGun.BodyColor = col;
|
||||
}
|
||||
public void ChangePictureBoxSize(int pictureBoxWidth, int pictureBoxHeight)
|
||||
{
|
||||
_pictureHeight = pictureBoxHeight;
|
||||
_pictureWidth = pictureBoxWidth;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Координата X объекта
|
||||
/// </summary>
|
||||
|
@ -9,7 +9,7 @@ namespace AntiAircraftGun.Enitites
|
||||
public class EntityAdvancedAntiAirCraftGun : EntityAntiAirCraftGun
|
||||
{
|
||||
|
||||
public Color DopColor { get; private set; }
|
||||
public Color DopColor { get; set; }
|
||||
|
||||
public bool Rocket { get; private set; }
|
||||
|
||||
|
@ -11,7 +11,7 @@ namespace AntiAircraftGun.Enitites
|
||||
/// <summary>
|
||||
/// Скорость
|
||||
/// </summary>
|
||||
public int Speed { get; private set; }
|
||||
public int Speed { get; private set; }
|
||||
/// <summary>
|
||||
/// Вес
|
||||
/// </summary>
|
||||
@ -19,11 +19,11 @@ namespace AntiAircraftGun.Enitites
|
||||
/// <summary>
|
||||
/// Основной цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
public Color BodyColor { get; set; }
|
||||
/// <summary>
|
||||
/// Шаг перемещения автомобиля
|
||||
/// </summary>
|
||||
public Color AdditionalColor { get; private set; }
|
||||
public Color AdditionalColor { get; set; }
|
||||
/// <summary>
|
||||
/// Шаг перемещения автомобиля
|
||||
/// </summary>
|
||||
|
@ -90,6 +90,7 @@ namespace AntiAircraftGun
|
||||
ReloadObjects();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAddZenit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
@ -103,21 +104,23 @@ namespace AntiAircraftGun
|
||||
MessageBox.Show("Выбранный набор не найден.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
FormAntiAirCraftGun form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (obj + form.SelectedZenit)
|
||||
FormAntiAirCraftGunConfig form = new();
|
||||
form.Show();
|
||||
Action<BaseDrawingAntiAirCraftGun>? zenitDelegate = new((m) => {
|
||||
bool q = (obj + m);
|
||||
if (q)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
m.ChangePictureBoxSize(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
pictureBoxCollection.Image = obj.ShowZenits();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
});
|
||||
form.AddEvent(zenitDelegate);
|
||||
}
|
||||
|
||||
private void ButtonDeleteZenit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
|
368
AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.Designer.cs
generated
Normal file
368
AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.Designer.cs
generated
Normal file
@ -0,0 +1,368 @@
|
||||
namespace AntiAircraftGun
|
||||
{
|
||||
partial class FormAntiAirCraftGunConfig
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
panel1 = new Panel();
|
||||
groupBoxParameters = new GroupBox();
|
||||
labelAdvanced = new Label();
|
||||
labelBase = new Label();
|
||||
groupBoxColor = new GroupBox();
|
||||
panelPurple = new Panel();
|
||||
panelBlack = new Panel();
|
||||
panelGray = new Panel();
|
||||
panelWhite = new Panel();
|
||||
panelYellow = new Panel();
|
||||
panelBlue = new Panel();
|
||||
panelGreen = new Panel();
|
||||
panelRed = new Panel();
|
||||
checkBoxRocket = new CheckBox();
|
||||
checkBoxRadar = new CheckBox();
|
||||
numericUpDownWeight = new NumericUpDown();
|
||||
numericUpDownSpeed = new NumericUpDown();
|
||||
label2 = new Label();
|
||||
label1 = new Label();
|
||||
pictureBoxObject = new PictureBox();
|
||||
labelColor = new Label();
|
||||
labelAdditionalColor = new Label();
|
||||
buttonAdd = new Button();
|
||||
buttonCancel = new Button();
|
||||
allowPanel = new Panel();
|
||||
panel1.SuspendLayout();
|
||||
groupBoxParameters.SuspendLayout();
|
||||
groupBoxColor.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||
allowPanel.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(groupBoxParameters);
|
||||
panel1.Location = new Point(7, 9);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(574, 306);
|
||||
panel1.TabIndex = 0;
|
||||
//
|
||||
// groupBoxParameters
|
||||
//
|
||||
groupBoxParameters.Controls.Add(labelAdvanced);
|
||||
groupBoxParameters.Controls.Add(labelBase);
|
||||
groupBoxParameters.Controls.Add(groupBoxColor);
|
||||
groupBoxParameters.Controls.Add(checkBoxRocket);
|
||||
groupBoxParameters.Controls.Add(checkBoxRadar);
|
||||
groupBoxParameters.Controls.Add(numericUpDownWeight);
|
||||
groupBoxParameters.Controls.Add(numericUpDownSpeed);
|
||||
groupBoxParameters.Controls.Add(label2);
|
||||
groupBoxParameters.Controls.Add(label1);
|
||||
groupBoxParameters.Location = new Point(5, 3);
|
||||
groupBoxParameters.Name = "groupBoxParameters";
|
||||
groupBoxParameters.Size = new Size(566, 300);
|
||||
groupBoxParameters.TabIndex = 0;
|
||||
groupBoxParameters.TabStop = false;
|
||||
groupBoxParameters.Text = "Параметры";
|
||||
//
|
||||
// labelAdvanced
|
||||
//
|
||||
labelAdvanced.Anchor = AnchorStyles.None;
|
||||
labelAdvanced.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelAdvanced.Location = new Point(427, 217);
|
||||
labelAdvanced.Name = "labelAdvanced";
|
||||
labelAdvanced.Size = new Size(88, 40);
|
||||
labelAdvanced.TabIndex = 8;
|
||||
labelAdvanced.Text = "Продвинутый";
|
||||
labelAdvanced.TextAlign = ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// labelBase
|
||||
//
|
||||
labelBase.Anchor = AnchorStyles.None;
|
||||
labelBase.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelBase.Location = new Point(315, 217);
|
||||
labelBase.Name = "labelBase";
|
||||
labelBase.Size = new Size(88, 40);
|
||||
labelBase.TabIndex = 7;
|
||||
labelBase.Text = "Простой";
|
||||
labelBase.TextAlign = ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// groupBoxColor
|
||||
//
|
||||
groupBoxColor.Controls.Add(panelPurple);
|
||||
groupBoxColor.Controls.Add(panelBlack);
|
||||
groupBoxColor.Controls.Add(panelGray);
|
||||
groupBoxColor.Controls.Add(panelWhite);
|
||||
groupBoxColor.Controls.Add(panelYellow);
|
||||
groupBoxColor.Controls.Add(panelBlue);
|
||||
groupBoxColor.Controls.Add(panelGreen);
|
||||
groupBoxColor.Controls.Add(panelRed);
|
||||
groupBoxColor.Location = new Point(287, 36);
|
||||
groupBoxColor.Name = "groupBoxColor";
|
||||
groupBoxColor.Size = new Size(273, 151);
|
||||
groupBoxColor.TabIndex = 6;
|
||||
groupBoxColor.TabStop = false;
|
||||
groupBoxColor.Text = "Цвета";
|
||||
//
|
||||
// panelPurple
|
||||
//
|
||||
panelPurple.BackColor = Color.Purple;
|
||||
panelPurple.Location = new Point(196, 83);
|
||||
panelPurple.Name = "panelPurple";
|
||||
panelPurple.Size = new Size(50, 50);
|
||||
panelPurple.TabIndex = 2;
|
||||
//
|
||||
// panelBlack
|
||||
//
|
||||
panelBlack.BackColor = Color.Black;
|
||||
panelBlack.Location = new Point(140, 83);
|
||||
panelBlack.Name = "panelBlack";
|
||||
panelBlack.Size = new Size(50, 50);
|
||||
panelBlack.TabIndex = 2;
|
||||
//
|
||||
// panelGray
|
||||
//
|
||||
panelGray.BackColor = Color.Gray;
|
||||
panelGray.Location = new Point(84, 83);
|
||||
panelGray.Name = "panelGray";
|
||||
panelGray.Size = new Size(50, 50);
|
||||
panelGray.TabIndex = 2;
|
||||
//
|
||||
// panelWhite
|
||||
//
|
||||
panelWhite.BackColor = Color.White;
|
||||
panelWhite.Location = new Point(28, 83);
|
||||
panelWhite.Name = "panelWhite";
|
||||
panelWhite.Size = new Size(50, 50);
|
||||
panelWhite.TabIndex = 2;
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
panelYellow.BackColor = Color.Yellow;
|
||||
panelYellow.Location = new Point(196, 27);
|
||||
panelYellow.Name = "panelYellow";
|
||||
panelYellow.Size = new Size(50, 50);
|
||||
panelYellow.TabIndex = 2;
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
panelBlue.BackColor = Color.Blue;
|
||||
panelBlue.Location = new Point(140, 27);
|
||||
panelBlue.Name = "panelBlue";
|
||||
panelBlue.Size = new Size(50, 50);
|
||||
panelBlue.TabIndex = 2;
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
panelGreen.BackColor = Color.Green;
|
||||
panelGreen.Location = new Point(84, 27);
|
||||
panelGreen.Name = "panelGreen";
|
||||
panelGreen.Size = new Size(50, 50);
|
||||
panelGreen.TabIndex = 1;
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
panelRed.BackColor = Color.Red;
|
||||
panelRed.Location = new Point(28, 27);
|
||||
panelRed.Name = "panelRed";
|
||||
panelRed.Size = new Size(50, 50);
|
||||
panelRed.TabIndex = 0;
|
||||
//
|
||||
// checkBoxRocket
|
||||
//
|
||||
checkBoxRocket.AutoSize = true;
|
||||
checkBoxRocket.Location = new Point(41, 229);
|
||||
checkBoxRocket.Name = "checkBoxRocket";
|
||||
checkBoxRocket.Size = new Size(165, 19);
|
||||
checkBoxRocket.TabIndex = 5;
|
||||
checkBoxRocket.Text = "Признак наличия ракеты";
|
||||
checkBoxRocket.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxRadar
|
||||
//
|
||||
checkBoxRadar.AutoSize = true;
|
||||
checkBoxRadar.Location = new Point(41, 189);
|
||||
checkBoxRadar.Name = "checkBoxRadar";
|
||||
checkBoxRadar.Size = new Size(164, 19);
|
||||
checkBoxRadar.TabIndex = 4;
|
||||
checkBoxRadar.Text = "Признак наличия радара";
|
||||
checkBoxRadar.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
numericUpDownWeight.Location = new Point(128, 82);
|
||||
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
numericUpDownWeight.Name = "numericUpDownWeight";
|
||||
numericUpDownWeight.Size = new Size(120, 23);
|
||||
numericUpDownWeight.TabIndex = 3;
|
||||
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
numericUpDownSpeed.Location = new Point(128, 36);
|
||||
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||
numericUpDownSpeed.Size = new Size(120, 23);
|
||||
numericUpDownSpeed.TabIndex = 2;
|
||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(44, 84);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(26, 15);
|
||||
label2.TabIndex = 1;
|
||||
label2.Text = "Вес";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(44, 38);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(59, 15);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Скорость";
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
pictureBoxObject.Location = new Point(41, 85);
|
||||
pictureBoxObject.Name = "pictureBoxObject";
|
||||
pictureBoxObject.Size = new Size(227, 141);
|
||||
pictureBoxObject.TabIndex = 1;
|
||||
pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// labelColor
|
||||
//
|
||||
labelColor.AllowDrop = true;
|
||||
labelColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelColor.Location = new Point(20, 24);
|
||||
labelColor.Name = "labelColor";
|
||||
labelColor.Size = new Size(120, 32);
|
||||
labelColor.TabIndex = 2;
|
||||
labelColor.Text = "Цвет";
|
||||
labelColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelColor.DragDrop += colorLabel_DragDrop;
|
||||
labelColor.DragEnter += colorLabel_DragEnter;
|
||||
//
|
||||
// labelAdditionalColor
|
||||
//
|
||||
labelAdditionalColor.AllowDrop = true;
|
||||
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelAdditionalColor.Location = new Point(169, 24);
|
||||
labelAdditionalColor.Name = "labelAdditionalColor";
|
||||
labelAdditionalColor.Size = new Size(120, 32);
|
||||
labelAdditionalColor.TabIndex = 3;
|
||||
labelAdditionalColor.Text = "Доп.Цвет";
|
||||
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelAdditionalColor.DragDrop += addColorLabel_DragDrop;
|
||||
labelAdditionalColor.DragEnter += colorLabel_DragEnter;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(587, 278);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(164, 37);
|
||||
buttonAdd.TabIndex = 4;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += addButton_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(757, 278);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(152, 37);
|
||||
buttonCancel.TabIndex = 5;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// allowPanel
|
||||
//
|
||||
allowPanel.AllowDrop = true;
|
||||
allowPanel.Controls.Add(labelAdditionalColor);
|
||||
allowPanel.Controls.Add(labelColor);
|
||||
allowPanel.Controls.Add(pictureBoxObject);
|
||||
allowPanel.Location = new Point(589, 9);
|
||||
allowPanel.Name = "allowPanel";
|
||||
allowPanel.Size = new Size(316, 263);
|
||||
allowPanel.TabIndex = 6;
|
||||
allowPanel.DragDrop += allowPanel_DragDrop;
|
||||
allowPanel.DragEnter += allowPanel_DragEnter;
|
||||
//
|
||||
// FormAntiAirCraftGunConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(912, 327);
|
||||
Controls.Add(allowPanel);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(panel1);
|
||||
Name = "FormAntiAirCraftGunConfig";
|
||||
Text = "FormAntiAirCraftGunConfig";
|
||||
panel1.ResumeLayout(false);
|
||||
groupBoxParameters.ResumeLayout(false);
|
||||
groupBoxParameters.PerformLayout();
|
||||
groupBoxColor.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||
allowPanel.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panel1;
|
||||
private GroupBox groupBoxParameters;
|
||||
private Label labelAdvanced;
|
||||
private Label labelBase;
|
||||
private GroupBox groupBoxColor;
|
||||
private Panel panelPurple;
|
||||
private Panel panelBlack;
|
||||
private Panel panelGray;
|
||||
private Panel panelWhite;
|
||||
private Panel panelYellow;
|
||||
private Panel panelBlue;
|
||||
private Panel panelGreen;
|
||||
private Panel panelRed;
|
||||
private CheckBox checkBoxRocket;
|
||||
private CheckBox checkBoxRadar;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private Label label2;
|
||||
private Label label1;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Label labelColor;
|
||||
private Label labelAdditionalColor;
|
||||
private Button buttonAdd;
|
||||
private Button buttonCancel;
|
||||
private Panel allowPanel;
|
||||
}
|
||||
}
|
178
AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.cs
Normal file
178
AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.cs
Normal file
@ -0,0 +1,178 @@
|
||||
using AntiAircraftGun.DrawingObjects;
|
||||
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 AntiAircraftGun
|
||||
{
|
||||
|
||||
|
||||
public partial class FormAntiAirCraftGunConfig : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Выбранная зенитная установка
|
||||
/// </summary>
|
||||
BaseDrawingAntiAirCraftGun? _zenit = null;
|
||||
|
||||
/// <summary>
|
||||
/// Событие для добавления зенитной установки
|
||||
/// </summary>
|
||||
private event Action<BaseDrawingAntiAirCraftGun>? EventAddZenit;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор формы
|
||||
/// </summary>
|
||||
public FormAntiAirCraftGunConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||
panelGray.MouseDown += PanelColor_MouseDown;
|
||||
panelRed.MouseDown += PanelColor_MouseDown;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
panelPurple.MouseDown += PanelColor_MouseDown;
|
||||
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||
labelBase.MouseDown += LabelObject_MouseDown;
|
||||
labelAdvanced.MouseDown += LabelObject_MouseDown;
|
||||
buttonCancel.Click += (s, e) => Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Отрисовка зенитной установки на PictureBox
|
||||
/// </summary>
|
||||
public void DrawAntiAirCraftGun()
|
||||
{
|
||||
Bitmap bmp = new Bitmap(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_zenit?.SetPosition(15, 15);
|
||||
_zenit?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление обработчика события для добавления зенитной установки
|
||||
/// </summary>
|
||||
public void AddEvent(Action<BaseDrawingAntiAirCraftGun> ev)
|
||||
{
|
||||
if (EventAddZenit == null)
|
||||
{
|
||||
EventAddZenit = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddZenit += ev;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обработчик события MouseDown для LabelObject
|
||||
/// </summary>
|
||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обработчик события DragEnter для allowPanel
|
||||
/// </summary>
|
||||
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>
|
||||
/// Обработчик события DragDrop для allowPanel
|
||||
/// </summary>
|
||||
private void allowPanel_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "labelBase":
|
||||
_zenit = new BaseDrawingAntiAirCraftGun((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, Color.Gray, pictureBoxObject.Width,
|
||||
pictureBoxObject.Height);
|
||||
break;
|
||||
case "labelAdvanced":
|
||||
_zenit = new AdvancedDrawingAntiAirCraftGun((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, Color.Gray, Color.Silver,
|
||||
checkBoxRadar.Checked, checkBoxRocket.Checked, pictureBoxObject.Width,
|
||||
pictureBoxObject.Height);
|
||||
break;
|
||||
}
|
||||
labelColor.BackColor = Color.Empty;
|
||||
labelAdditionalColor.BackColor = Color.Empty;
|
||||
DrawAntiAirCraftGun();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обработчик события Click для addButton
|
||||
/// </summary>
|
||||
private void addButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddZenit?.Invoke(_zenit);
|
||||
Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обработчик события MouseDown для панелей цвета
|
||||
/// </summary>
|
||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обработчик события DragDrop для colorLabel
|
||||
/// </summary>
|
||||
private void colorLabel_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_zenit == null)
|
||||
return;
|
||||
labelColor.BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||
_zenit.ChangeColor(labelColor.BackColor);
|
||||
DrawAntiAirCraftGun();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обработчик события DragEnter для colorLabel
|
||||
/// </summary>
|
||||
private void colorLabel_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Обработчик события DragDrop для addColorLabel
|
||||
/// </summary>
|
||||
private void addColorLabel_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if ((_zenit == null) || (_zenit is AdvancedDrawingAntiAirCraftGun == false))
|
||||
return;
|
||||
labelAdditionalColor.BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||
((AdvancedDrawingAntiAirCraftGun)_zenit).ChangeAddColor(labelAdditionalColor.BackColor);
|
||||
DrawAntiAirCraftGun();
|
||||
}
|
||||
}
|
||||
}
|
120
AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.resx
Normal file
120
AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGunConfig.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?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>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user