lab5
This commit is contained in:
parent
9c7884da80
commit
5920c92eca
@ -40,5 +40,6 @@ namespace ProjectAircraftCarrier.Entities
|
||||
Runway = runway;
|
||||
Cabin = cabin;
|
||||
}
|
||||
public void ChangeAddColor(Color color) { AdditionalColor = color; }
|
||||
}
|
||||
}
|
@ -39,5 +39,6 @@ namespace ProjectAircraftCarrier.Entities
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
public void ChangeColor(Color color) { BodyColor = color; }
|
||||
}
|
||||
}
|
||||
|
@ -109,10 +109,10 @@ namespace ProjectAircraftCarrier
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormAircraftCarrier form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (obj + form.SelectedWarship)
|
||||
FormWarshipConfig form = new();
|
||||
form.Show();
|
||||
Action<DrawingWarship>? warshipDelegate = new((warship) => {
|
||||
if (obj + warship)
|
||||
{
|
||||
MessageBox.Show("Object added");
|
||||
pictureBoxCollection.Image = obj.ShowWarships();
|
||||
@ -121,7 +121,8 @@ namespace ProjectAircraftCarrier
|
||||
{
|
||||
MessageBox.Show("Failed to add an object");
|
||||
}
|
||||
}
|
||||
});
|
||||
form.AddEvent(warshipDelegate);
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора
|
||||
|
370
AircraftCarrier/AircraftCarrier/FormWarshipConfig.Designer.cs
generated
Normal file
370
AircraftCarrier/AircraftCarrier/FormWarshipConfig.Designer.cs
generated
Normal file
@ -0,0 +1,370 @@
|
||||
namespace ProjectAircraftCarrier
|
||||
{
|
||||
partial class FormWarshipConfig
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
groupBoxCreationParameters = new GroupBox();
|
||||
labelModifiedObject = new Label();
|
||||
labelSimpleObject = new Label();
|
||||
groupBoxCreationColors = new GroupBox();
|
||||
panelBlack = new Panel();
|
||||
panelWhite = new Panel();
|
||||
panelPurple = new Panel();
|
||||
panelBlue = new Panel();
|
||||
panelGreen = new Panel();
|
||||
panelRed = new Panel();
|
||||
panelGray = new Panel();
|
||||
panelYellow = new Panel();
|
||||
checkBoxCabin = new CheckBox();
|
||||
checkBoxRunway = new CheckBox();
|
||||
numericUpDownWeight = new NumericUpDown();
|
||||
labelSpeed = new Label();
|
||||
numericUpDownSpeed = new NumericUpDown();
|
||||
labelWeight = new Label();
|
||||
pictureBoxObject = new PictureBox();
|
||||
panelObject = new Panel();
|
||||
labelAddColor = new Label();
|
||||
labelColor = new Label();
|
||||
buttonAddWarship = new Button();
|
||||
buttonCancel = new Button();
|
||||
groupBoxCreationParameters.SuspendLayout();
|
||||
groupBoxCreationColors.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||
panelObject.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBoxCreationParameters
|
||||
//
|
||||
groupBoxCreationParameters.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
groupBoxCreationParameters.Controls.Add(labelModifiedObject);
|
||||
groupBoxCreationParameters.Controls.Add(labelSimpleObject);
|
||||
groupBoxCreationParameters.Controls.Add(groupBoxCreationColors);
|
||||
groupBoxCreationParameters.Controls.Add(checkBoxCabin);
|
||||
groupBoxCreationParameters.Controls.Add(checkBoxRunway);
|
||||
groupBoxCreationParameters.Controls.Add(numericUpDownWeight);
|
||||
groupBoxCreationParameters.Controls.Add(labelSpeed);
|
||||
groupBoxCreationParameters.Controls.Add(numericUpDownSpeed);
|
||||
groupBoxCreationParameters.Controls.Add(labelWeight);
|
||||
groupBoxCreationParameters.Location = new Point(12, 12);
|
||||
groupBoxCreationParameters.Name = "groupBoxCreationParameters";
|
||||
groupBoxCreationParameters.Size = new Size(684, 306);
|
||||
groupBoxCreationParameters.TabIndex = 0;
|
||||
groupBoxCreationParameters.TabStop = false;
|
||||
groupBoxCreationParameters.Text = "Parameters";
|
||||
//
|
||||
// labelModifiedObject
|
||||
//
|
||||
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelModifiedObject.Location = new Point(518, 229);
|
||||
labelModifiedObject.Name = "labelModifiedObject";
|
||||
labelModifiedObject.Size = new Size(140, 50);
|
||||
labelModifiedObject.TabIndex = 8;
|
||||
labelModifiedObject.Text = "Modified";
|
||||
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelSimpleObject.Location = new Point(358, 229);
|
||||
labelSimpleObject.Name = "labelSimpleObject";
|
||||
labelSimpleObject.Size = new Size(140, 50);
|
||||
labelSimpleObject.TabIndex = 7;
|
||||
labelSimpleObject.Text = "Simple";
|
||||
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// groupBoxCreationColors
|
||||
//
|
||||
groupBoxCreationColors.Controls.Add(panelBlack);
|
||||
groupBoxCreationColors.Controls.Add(panelWhite);
|
||||
groupBoxCreationColors.Controls.Add(panelPurple);
|
||||
groupBoxCreationColors.Controls.Add(panelBlue);
|
||||
groupBoxCreationColors.Controls.Add(panelGreen);
|
||||
groupBoxCreationColors.Controls.Add(panelRed);
|
||||
groupBoxCreationColors.Controls.Add(panelGray);
|
||||
groupBoxCreationColors.Controls.Add(panelYellow);
|
||||
groupBoxCreationColors.Location = new Point(346, 24);
|
||||
groupBoxCreationColors.Name = "groupBoxCreationColors";
|
||||
groupBoxCreationColors.Size = new Size(327, 190);
|
||||
groupBoxCreationColors.TabIndex = 1;
|
||||
groupBoxCreationColors.TabStop = false;
|
||||
groupBoxCreationColors.Text = "Colors";
|
||||
//
|
||||
// panelBlack
|
||||
//
|
||||
panelBlack.BackColor = Color.Black;
|
||||
panelBlack.Location = new Point(172, 110);
|
||||
panelBlack.Name = "panelBlack";
|
||||
panelBlack.Size = new Size(60, 60);
|
||||
panelBlack.TabIndex = 7;
|
||||
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelWhite
|
||||
//
|
||||
panelWhite.BackColor = Color.White;
|
||||
panelWhite.Location = new Point(12, 110);
|
||||
panelWhite.Name = "panelWhite";
|
||||
panelWhite.Size = new Size(60, 60);
|
||||
panelWhite.TabIndex = 6;
|
||||
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelPurple
|
||||
//
|
||||
panelPurple.BackColor = Color.Purple;
|
||||
panelPurple.Location = new Point(252, 110);
|
||||
panelPurple.Name = "panelPurple";
|
||||
panelPurple.Size = new Size(60, 60);
|
||||
panelPurple.TabIndex = 5;
|
||||
panelPurple.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
panelBlue.BackColor = Color.Blue;
|
||||
panelBlue.Location = new Point(172, 30);
|
||||
panelBlue.Name = "panelBlue";
|
||||
panelBlue.Size = new Size(60, 60);
|
||||
panelBlue.TabIndex = 4;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
panelGreen.BackColor = Color.Green;
|
||||
panelGreen.Location = new Point(92, 30);
|
||||
panelGreen.Name = "panelGreen";
|
||||
panelGreen.Size = new Size(60, 60);
|
||||
panelGreen.TabIndex = 3;
|
||||
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
panelRed.BackColor = Color.Red;
|
||||
panelRed.Location = new Point(12, 30);
|
||||
panelRed.Name = "panelRed";
|
||||
panelRed.Size = new Size(60, 60);
|
||||
panelRed.TabIndex = 2;
|
||||
panelRed.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelGray
|
||||
//
|
||||
panelGray.BackColor = Color.Gray;
|
||||
panelGray.Location = new Point(92, 110);
|
||||
panelGray.Name = "panelGray";
|
||||
panelGray.Size = new Size(60, 60);
|
||||
panelGray.TabIndex = 1;
|
||||
panelGray.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
panelYellow.BackColor = Color.Yellow;
|
||||
panelYellow.Location = new Point(252, 30);
|
||||
panelYellow.Name = "panelYellow";
|
||||
panelYellow.Size = new Size(60, 60);
|
||||
panelYellow.TabIndex = 0;
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// checkBoxCabin
|
||||
//
|
||||
checkBoxCabin.AutoSize = true;
|
||||
checkBoxCabin.Location = new Point(25, 198);
|
||||
checkBoxCabin.Name = "checkBoxCabin";
|
||||
checkBoxCabin.Size = new Size(272, 29);
|
||||
checkBoxCabin.TabIndex = 6;
|
||||
checkBoxCabin.Text = "Indication of cabin availability";
|
||||
checkBoxCabin.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxRunway
|
||||
//
|
||||
checkBoxRunway.AutoSize = true;
|
||||
checkBoxRunway.Location = new Point(25, 145);
|
||||
checkBoxRunway.Name = "checkBoxRunway";
|
||||
checkBoxRunway.Size = new Size(287, 29);
|
||||
checkBoxRunway.TabIndex = 5;
|
||||
checkBoxRunway.Text = "Indication of runway availability";
|
||||
checkBoxRunway.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
numericUpDownWeight.Location = new Point(116, 85);
|
||||
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(180, 31);
|
||||
numericUpDownWeight.TabIndex = 4;
|
||||
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
labelSpeed.AutoSize = true;
|
||||
labelSpeed.Location = new Point(16, 43);
|
||||
labelSpeed.Name = "labelSpeed";
|
||||
labelSpeed.Size = new Size(66, 25);
|
||||
labelSpeed.TabIndex = 1;
|
||||
labelSpeed.Text = "Speed:";
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
numericUpDownSpeed.Location = new Point(116, 41);
|
||||
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(180, 31);
|
||||
numericUpDownSpeed.TabIndex = 3;
|
||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// labelWeight
|
||||
//
|
||||
labelWeight.AutoSize = true;
|
||||
labelWeight.Location = new Point(17, 87);
|
||||
labelWeight.Name = "labelWeight";
|
||||
labelWeight.Size = new Size(72, 25);
|
||||
labelWeight.TabIndex = 2;
|
||||
labelWeight.Text = "Weight:";
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
pictureBoxObject.Location = new Point(16, 70);
|
||||
pictureBoxObject.Name = "pictureBoxObject";
|
||||
pictureBoxObject.Size = new Size(331, 157);
|
||||
pictureBoxObject.TabIndex = 1;
|
||||
pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// panelObject
|
||||
//
|
||||
panelObject.AllowDrop = true;
|
||||
panelObject.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
panelObject.Controls.Add(labelAddColor);
|
||||
panelObject.Controls.Add(labelColor);
|
||||
panelObject.Controls.Add(pictureBoxObject);
|
||||
panelObject.Location = new Point(708, 12);
|
||||
panelObject.Name = "panelObject";
|
||||
panelObject.Size = new Size(366, 242);
|
||||
panelObject.TabIndex = 2;
|
||||
panelObject.DragDrop += PanelObject_DragDrop;
|
||||
panelObject.DragEnter += PanelObject_DragEnter;
|
||||
//
|
||||
// labelAddColor
|
||||
//
|
||||
labelAddColor.AllowDrop = true;
|
||||
labelAddColor.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
labelAddColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelAddColor.Location = new Point(195, 13);
|
||||
labelAddColor.Name = "labelAddColor";
|
||||
labelAddColor.Size = new Size(152, 50);
|
||||
labelAddColor.TabIndex = 3;
|
||||
labelAddColor.Text = "Add. color";
|
||||
labelAddColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelAddColor.DragDrop += LabelAddColor_DragDrop;
|
||||
labelAddColor.DragEnter += LabelColor_DragEnter;
|
||||
//
|
||||
// labelColor
|
||||
//
|
||||
labelColor.AllowDrop = true;
|
||||
labelColor.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
labelColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelColor.Location = new Point(16, 13);
|
||||
labelColor.Name = "labelColor";
|
||||
labelColor.Size = new Size(156, 50);
|
||||
labelColor.TabIndex = 2;
|
||||
labelColor.Text = "Color";
|
||||
labelColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelColor.DragDrop += LabelColor_DragDrop;
|
||||
labelColor.DragEnter += LabelColor_DragEnter;
|
||||
//
|
||||
// buttonAddWarship
|
||||
//
|
||||
buttonAddWarship.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonAddWarship.Location = new Point(724, 260);
|
||||
buttonAddWarship.Name = "buttonAddWarship";
|
||||
buttonAddWarship.Size = new Size(156, 50);
|
||||
buttonAddWarship.TabIndex = 4;
|
||||
buttonAddWarship.Text = "Add";
|
||||
buttonAddWarship.UseVisualStyleBackColor = true;
|
||||
buttonAddWarship.Click += ButtonAdd_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonCancel.Location = new Point(903, 260);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(152, 50);
|
||||
buttonCancel.TabIndex = 5;
|
||||
buttonCancel.Text = "Cancel";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormWarshipConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1084, 322);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(panelObject);
|
||||
Controls.Add(buttonAddWarship);
|
||||
Controls.Add(groupBoxCreationParameters);
|
||||
Name = "FormWarshipConfig";
|
||||
Text = "Object creation";
|
||||
groupBoxCreationParameters.ResumeLayout(false);
|
||||
groupBoxCreationParameters.PerformLayout();
|
||||
groupBoxCreationColors.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||
panelObject.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxCreationParameters;
|
||||
private Label labelSpeed;
|
||||
private Label labelWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private GroupBox groupBoxCreationColors;
|
||||
private CheckBox checkBoxCabin;
|
||||
private CheckBox checkBoxRunway;
|
||||
private Panel panelBlack;
|
||||
private Panel panelWhite;
|
||||
private Panel panelPurple;
|
||||
private Panel panelBlue;
|
||||
private Panel panelGreen;
|
||||
private Panel panelRed;
|
||||
private Panel panelGray;
|
||||
private Panel panelYellow;
|
||||
private Label labelModifiedObject;
|
||||
private Label labelSimpleObject;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Panel panelObject;
|
||||
private Button buttonAddWarship;
|
||||
private Label labelAddColor;
|
||||
private Label labelColor;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
153
AircraftCarrier/AircraftCarrier/FormWarshipConfig.cs
Normal file
153
AircraftCarrier/AircraftCarrier/FormWarshipConfig.cs
Normal file
@ -0,0 +1,153 @@
|
||||
using ProjectAircraftCarrier.DrawingObjects;
|
||||
using ProjectAircraftCarrier.Entities;
|
||||
|
||||
namespace ProjectAircraftCarrier
|
||||
{
|
||||
public partial class FormWarshipConfig : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Переменная-выбранный военный корабль
|
||||
/// </summary>
|
||||
DrawingWarship? _warship = null;
|
||||
private event Action<DrawingWarship>? EventAddWarship;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormWarshipConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||
panelPurple.MouseDown += PanelColor_MouseDown;
|
||||
panelGray.MouseDown += PanelColor_MouseDown;
|
||||
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||
panelRed.MouseDown += PanelColor_MouseDown;
|
||||
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
buttonCancel.Click += (s, e) => Close();
|
||||
}
|
||||
/// <summary>
|
||||
/// Отрисовать военний корабль
|
||||
/// </summary>
|
||||
private void DrawWarship()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_warship?.SetPosition(5, 5);
|
||||
_warship?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление события
|
||||
/// </summary>
|
||||
/// <param name="ev">Привязанный метод</param>
|
||||
public void AddEvent(Action<DrawingWarship>? ev)
|
||||
{
|
||||
if (EventAddWarship == null)
|
||||
{
|
||||
EventAddWarship = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddWarship += 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":
|
||||
_warship = new DrawingWarship(
|
||||
(int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White,
|
||||
pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
break;
|
||||
case "labelModifiedObject":
|
||||
_warship = new DrawingAircraftCarrier(
|
||||
(int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White,
|
||||
Color.Black, checkBoxCabin.Checked,
|
||||
checkBoxRunway.Checked,
|
||||
pictureBoxObject.Width,pictureBoxObject.Height);
|
||||
break;
|
||||
}
|
||||
DrawWarship();
|
||||
}
|
||||
private void PanelColor_MouseDown(object? sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
|
||||
DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление военного корабля
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_warship == null)
|
||||
return;
|
||||
EventAddWarship?.Invoke(_warship);
|
||||
Close();
|
||||
}
|
||||
private void LabelColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_warship?.EntityWarship == null)
|
||||
return;
|
||||
Color bodyColor = (Color)e.Data.GetData(typeof(Color));
|
||||
_warship.EntityWarship.ChangeColor(bodyColor);
|
||||
DrawWarship();
|
||||
}
|
||||
private void LabelAddColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if ((_warship?.EntityWarship == null) || (_warship is
|
||||
DrawingAircraftCarrier == false))
|
||||
return;
|
||||
Color additionalColor = (Color)e.Data.GetData(typeof(Color));
|
||||
((EntityAircraftCarrier)_warship.EntityWarship).ChangeAddColor(additionalColor);
|
||||
DrawWarship();
|
||||
}
|
||||
private void LabelColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
AircraftCarrier/AircraftCarrier/FormWarshipConfig.resx
Normal file
120
AircraftCarrier/AircraftCarrier/FormWarshipConfig.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