SemesterFirstLabFifthBomberBase
This commit is contained in:
parent
4beddff8a2
commit
592059a118
@ -22,11 +22,11 @@ namespace ProjectBomber.DrawningObjects
|
||||
/// <summary>
|
||||
/// Ширина окна
|
||||
/// </summary>
|
||||
private int _pictureWidth;
|
||||
public int _pictureWidth;
|
||||
/// <summary>
|
||||
/// Высота окна
|
||||
/// </summary>
|
||||
private int _pictureHeight;
|
||||
public int _pictureHeight;
|
||||
/// <summary>
|
||||
/// Левая координата прорисовки бомбардировщика
|
||||
/// </summary>
|
||||
@ -280,5 +280,9 @@ namespace ProjectBomber.DrawningObjects
|
||||
// Рисуем контур линии
|
||||
g.DrawPath(pen, path1);
|
||||
}
|
||||
public void setColor(Color color)
|
||||
{
|
||||
EntityBomber.setColor(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,8 +60,13 @@ namespace ProjectBomber.DrawningObjects
|
||||
g.FillRectangle(additionalBrush, _startPosX + 10, _startPosY + 34, 50, 2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setAddColor(Color color)
|
||||
{
|
||||
if (EntityBomber is EntityBomberAdvanced bomber)
|
||||
{
|
||||
bomber.setAddColor(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,5 +40,9 @@ namespace ProjectBomber.Entities
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
public void setColor(Color color)
|
||||
{
|
||||
BodyColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,5 +47,9 @@ namespace ProjectBomber.Entities
|
||||
FuelTanks = fuelTanks;
|
||||
Line = line;
|
||||
}
|
||||
public void setAddColor(Color color)
|
||||
{
|
||||
AdditionalColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,12 +90,33 @@ _storage[ListBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowPlanes()
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show($"Удалить объект {ListBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_storage.DelSet(ListBoxStorages.SelectedItem.ToString()?? string.Empty);
|
||||
ReloadObjects();
|
||||
}
|
||||
}
|
||||
private void AddPlane(DrawningBomber plane)
|
||||
{
|
||||
if (ListBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[ListBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ((obj + plane) != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowPlanes();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор
|
||||
/// </summary>
|
||||
@ -107,25 +128,14 @@ MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[ListBoxStorages.SelectedItem.ToString() ??
|
||||
string.Empty];
|
||||
var obj = _storage[ListBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormBomber form = new FormBomber();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (obj + form.SelectedBomber)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowPlanes();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
var formPlaneConfig = new FormPlaneConfig();
|
||||
formPlaneConfig.Show();
|
||||
formPlaneConfig.AddEvent(AddPlane);
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора
|
||||
|
382
ProjectBomber/ProjectBomber/FormPlaneConfig.Designer.cs
generated
Normal file
382
ProjectBomber/ProjectBomber/FormPlaneConfig.Designer.cs
generated
Normal file
@ -0,0 +1,382 @@
|
||||
namespace ProjectBomber
|
||||
{
|
||||
partial class FormPlaneConfig
|
||||
{
|
||||
/// <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.groupBoxColors = new System.Windows.Forms.GroupBox();
|
||||
this.panelPurple = new System.Windows.Forms.Panel();
|
||||
this.panelBlack = new System.Windows.Forms.Panel();
|
||||
this.panelGray = new System.Windows.Forms.Panel();
|
||||
this.panelWhite = new System.Windows.Forms.Panel();
|
||||
this.panelYellow = new System.Windows.Forms.Panel();
|
||||
this.panelBlue = new System.Windows.Forms.Panel();
|
||||
this.panelGreen = new System.Windows.Forms.Panel();
|
||||
this.panelRed = new System.Windows.Forms.Panel();
|
||||
this.checkBoxLine = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoxFuelTanks = new System.Windows.Forms.CheckBox();
|
||||
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
|
||||
this.checkBoxBombs = new System.Windows.Forms.CheckBox();
|
||||
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.panelObject = new System.Windows.Forms.Panel();
|
||||
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
|
||||
this.labelAddColor = new System.Windows.Forms.Label();
|
||||
this.labelColor = new System.Windows.Forms.Label();
|
||||
this.ButtonOk = new System.Windows.Forms.Button();
|
||||
this.buttonCanel = new System.Windows.Forms.Button();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBoxColors.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
|
||||
this.panelObject.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.labelModifiedObject);
|
||||
this.groupBox1.Controls.Add(this.labelSimpleObject);
|
||||
this.groupBox1.Controls.Add(this.groupBoxColors);
|
||||
this.groupBox1.Controls.Add(this.checkBoxLine);
|
||||
this.groupBox1.Controls.Add(this.checkBoxFuelTanks);
|
||||
this.groupBox1.Controls.Add(this.numericUpDownWeight);
|
||||
this.groupBox1.Controls.Add(this.checkBoxBombs);
|
||||
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(12, 12);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(530, 225);
|
||||
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(400, 183);
|
||||
this.labelModifiedObject.Name = "labelModifiedObject";
|
||||
this.labelModifiedObject.Size = new System.Drawing.Size(93, 31);
|
||||
this.labelModifiedObject.TabIndex = 9;
|
||||
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(273, 183);
|
||||
this.labelSimpleObject.Name = "labelSimpleObject";
|
||||
this.labelSimpleObject.Size = new System.Drawing.Size(99, 31);
|
||||
this.labelSimpleObject.TabIndex = 8;
|
||||
this.labelSimpleObject.Text = "Простой";
|
||||
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
|
||||
//
|
||||
// groupBoxColors
|
||||
//
|
||||
this.groupBoxColors.Controls.Add(this.panelPurple);
|
||||
this.groupBoxColors.Controls.Add(this.panelBlack);
|
||||
this.groupBoxColors.Controls.Add(this.panelGray);
|
||||
this.groupBoxColors.Controls.Add(this.panelWhite);
|
||||
this.groupBoxColors.Controls.Add(this.panelYellow);
|
||||
this.groupBoxColors.Controls.Add(this.panelBlue);
|
||||
this.groupBoxColors.Controls.Add(this.panelGreen);
|
||||
this.groupBoxColors.Controls.Add(this.panelRed);
|
||||
this.groupBoxColors.Location = new System.Drawing.Point(273, 32);
|
||||
this.groupBoxColors.Name = "groupBoxColors";
|
||||
this.groupBoxColors.Size = new System.Drawing.Size(245, 120);
|
||||
this.groupBoxColors.TabIndex = 7;
|
||||
this.groupBoxColors.TabStop = false;
|
||||
this.groupBoxColors.Text = "Цвета";
|
||||
//
|
||||
// panelPurple
|
||||
//
|
||||
this.panelPurple.BackColor = System.Drawing.Color.Purple;
|
||||
this.panelPurple.Location = new System.Drawing.Point(192, 73);
|
||||
this.panelPurple.Name = "panelPurple";
|
||||
this.panelPurple.Size = new System.Drawing.Size(45, 40);
|
||||
this.panelPurple.TabIndex = 7;
|
||||
this.panelPurple.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// panelBlack
|
||||
//
|
||||
this.panelBlack.BackColor = System.Drawing.Color.Black;
|
||||
this.panelBlack.Location = new System.Drawing.Point(130, 73);
|
||||
this.panelBlack.Name = "panelBlack";
|
||||
this.panelBlack.Size = new System.Drawing.Size(45, 40);
|
||||
this.panelBlack.TabIndex = 6;
|
||||
this.panelBlack.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// panelGray
|
||||
//
|
||||
this.panelGray.BackColor = System.Drawing.Color.Gray;
|
||||
this.panelGray.Location = new System.Drawing.Point(68, 73);
|
||||
this.panelGray.Name = "panelGray";
|
||||
this.panelGray.Size = new System.Drawing.Size(45, 40);
|
||||
this.panelGray.TabIndex = 5;
|
||||
this.panelGray.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// panelWhite
|
||||
//
|
||||
this.panelWhite.BackColor = System.Drawing.Color.White;
|
||||
this.panelWhite.Location = new System.Drawing.Point(6, 73);
|
||||
this.panelWhite.Name = "panelWhite";
|
||||
this.panelWhite.Size = new System.Drawing.Size(45, 40);
|
||||
this.panelWhite.TabIndex = 4;
|
||||
this.panelWhite.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
|
||||
this.panelYellow.Location = new System.Drawing.Point(192, 19);
|
||||
this.panelYellow.Name = "panelYellow";
|
||||
this.panelYellow.Size = new System.Drawing.Size(45, 40);
|
||||
this.panelYellow.TabIndex = 3;
|
||||
this.panelYellow.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
this.panelBlue.BackColor = System.Drawing.Color.Blue;
|
||||
this.panelBlue.Location = new System.Drawing.Point(130, 19);
|
||||
this.panelBlue.Name = "panelBlue";
|
||||
this.panelBlue.Size = new System.Drawing.Size(45, 40);
|
||||
this.panelBlue.TabIndex = 2;
|
||||
this.panelBlue.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
this.panelGreen.BackColor = System.Drawing.Color.Green;
|
||||
this.panelGreen.Location = new System.Drawing.Point(68, 19);
|
||||
this.panelGreen.Name = "panelGreen";
|
||||
this.panelGreen.Size = new System.Drawing.Size(45, 40);
|
||||
this.panelGreen.TabIndex = 1;
|
||||
this.panelGreen.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
this.panelRed.BackColor = System.Drawing.Color.Red;
|
||||
this.panelRed.Location = new System.Drawing.Point(6, 19);
|
||||
this.panelRed.Name = "panelRed";
|
||||
this.panelRed.Size = new System.Drawing.Size(45, 40);
|
||||
this.panelRed.TabIndex = 0;
|
||||
this.panelRed.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||
//
|
||||
// checkBoxLine
|
||||
//
|
||||
this.checkBoxLine.AutoSize = true;
|
||||
this.checkBoxLine.Location = new System.Drawing.Point(30, 183);
|
||||
this.checkBoxLine.Name = "checkBoxLine";
|
||||
this.checkBoxLine.Size = new System.Drawing.Size(155, 17);
|
||||
this.checkBoxLine.TabIndex = 6;
|
||||
this.checkBoxLine.Text = "Признак наличия полосы";
|
||||
this.checkBoxLine.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxFuelTanks
|
||||
//
|
||||
this.checkBoxFuelTanks.AutoSize = true;
|
||||
this.checkBoxFuelTanks.Location = new System.Drawing.Point(30, 149);
|
||||
this.checkBoxFuelTanks.Name = "checkBoxFuelTanks";
|
||||
this.checkBoxFuelTanks.Size = new System.Drawing.Size(204, 17);
|
||||
this.checkBoxFuelTanks.TabIndex = 5;
|
||||
this.checkBoxFuelTanks.Text = "Признак наличия топливных баков";
|
||||
this.checkBoxFuelTanks.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
this.numericUpDownWeight.Location = new System.Drawing.Point(91, 71);
|
||||
this.numericUpDownWeight.Name = "numericUpDownWeight";
|
||||
this.numericUpDownWeight.Size = new System.Drawing.Size(75, 20);
|
||||
this.numericUpDownWeight.TabIndex = 4;
|
||||
//
|
||||
// checkBoxBombs
|
||||
//
|
||||
this.checkBoxBombs.AutoSize = true;
|
||||
this.checkBoxBombs.Location = new System.Drawing.Point(30, 116);
|
||||
this.checkBoxBombs.Name = "checkBoxBombs";
|
||||
this.checkBoxBombs.Size = new System.Drawing.Size(143, 17);
|
||||
this.checkBoxBombs.TabIndex = 3;
|
||||
this.checkBoxBombs.Text = "Признак наличия бомб";
|
||||
this.checkBoxBombs.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
this.numericUpDownSpeed.Increment = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownSpeed.Location = new System.Drawing.Point(91, 32);
|
||||
this.numericUpDownSpeed.Maximum = new decimal(new int[] {
|
||||
1000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||
this.numericUpDownSpeed.Size = new System.Drawing.Size(75, 20);
|
||||
this.numericUpDownSpeed.TabIndex = 2;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(27, 73);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(29, 13);
|
||||
this.label2.TabIndex = 1;
|
||||
this.label2.Text = "Вес:";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(27, 32);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(58, 13);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "Скорость:";
|
||||
//
|
||||
// panelObject
|
||||
//
|
||||
this.panelObject.AllowDrop = true;
|
||||
this.panelObject.Controls.Add(this.pictureBoxObject);
|
||||
this.panelObject.Controls.Add(this.labelAddColor);
|
||||
this.panelObject.Controls.Add(this.labelColor);
|
||||
this.panelObject.Location = new System.Drawing.Point(558, 12);
|
||||
this.panelObject.Name = "panelObject";
|
||||
this.panelObject.Size = new System.Drawing.Size(230, 187);
|
||||
this.panelObject.TabIndex = 1;
|
||||
this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
|
||||
this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
this.pictureBoxObject.Location = new System.Drawing.Point(19, 48);
|
||||
this.pictureBoxObject.Name = "pictureBoxObject";
|
||||
this.pictureBoxObject.Size = new System.Drawing.Size(190, 125);
|
||||
this.pictureBoxObject.TabIndex = 2;
|
||||
this.pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// labelAddColor
|
||||
//
|
||||
this.labelAddColor.AllowDrop = true;
|
||||
this.labelAddColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelAddColor.Location = new System.Drawing.Point(122, 18);
|
||||
this.labelAddColor.Name = "labelAddColor";
|
||||
this.labelAddColor.Size = new System.Drawing.Size(88, 27);
|
||||
this.labelAddColor.TabIndex = 1;
|
||||
this.labelAddColor.Text = "Доп. цвет";
|
||||
this.labelAddColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelAddColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelAddColor_DragDrop);
|
||||
this.labelAddColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelColor_DragEnter);
|
||||
//
|
||||
// labelColor
|
||||
//
|
||||
this.labelColor.AllowDrop = true;
|
||||
this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelColor.Location = new System.Drawing.Point(17, 18);
|
||||
this.labelColor.Name = "labelColor";
|
||||
this.labelColor.Size = new System.Drawing.Size(86, 27);
|
||||
this.labelColor.TabIndex = 0;
|
||||
this.labelColor.Text = "Цвет";
|
||||
this.labelColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop);
|
||||
this.labelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.labelColor_DragEnter);
|
||||
//
|
||||
// ButtonOk
|
||||
//
|
||||
this.ButtonOk.Location = new System.Drawing.Point(577, 210);
|
||||
this.ButtonOk.Name = "ButtonOk";
|
||||
this.ButtonOk.Size = new System.Drawing.Size(84, 27);
|
||||
this.ButtonOk.TabIndex = 2;
|
||||
this.ButtonOk.Text = "Добавить";
|
||||
this.ButtonOk.UseVisualStyleBackColor = true;
|
||||
this.ButtonOk.Click += new System.EventHandler(this.ButtonOk_Click);
|
||||
//
|
||||
// buttonCanel
|
||||
//
|
||||
this.buttonCanel.Location = new System.Drawing.Point(683, 210);
|
||||
this.buttonCanel.Name = "buttonCanel";
|
||||
this.buttonCanel.Size = new System.Drawing.Size(84, 27);
|
||||
this.buttonCanel.TabIndex = 3;
|
||||
this.buttonCanel.Text = "Отмена";
|
||||
this.buttonCanel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormPlaneConfig
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 243);
|
||||
this.Controls.Add(this.buttonCanel);
|
||||
this.Controls.Add(this.ButtonOk);
|
||||
this.Controls.Add(this.panelObject);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Name = "FormPlaneConfig";
|
||||
this.Text = "FormPlaneConfig";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.groupBoxColors.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
|
||||
this.panelObject.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.NumericUpDown numericUpDownWeight;
|
||||
private System.Windows.Forms.CheckBox checkBoxBombs;
|
||||
private System.Windows.Forms.NumericUpDown numericUpDownSpeed;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.CheckBox checkBoxFuelTanks;
|
||||
private System.Windows.Forms.Label labelModifiedObject;
|
||||
private System.Windows.Forms.Label labelSimpleObject;
|
||||
private System.Windows.Forms.GroupBox groupBoxColors;
|
||||
private System.Windows.Forms.Panel panelPurple;
|
||||
private System.Windows.Forms.Panel panelBlack;
|
||||
private System.Windows.Forms.Panel panelGray;
|
||||
private System.Windows.Forms.Panel panelWhite;
|
||||
private System.Windows.Forms.Panel panelYellow;
|
||||
private System.Windows.Forms.Panel panelBlue;
|
||||
private System.Windows.Forms.Panel panelGreen;
|
||||
private System.Windows.Forms.Panel panelRed;
|
||||
private System.Windows.Forms.CheckBox checkBoxLine;
|
||||
private System.Windows.Forms.Panel panelObject;
|
||||
private System.Windows.Forms.PictureBox pictureBoxObject;
|
||||
private System.Windows.Forms.Label labelAddColor;
|
||||
private System.Windows.Forms.Label labelColor;
|
||||
private System.Windows.Forms.Button ButtonOk;
|
||||
private System.Windows.Forms.Button buttonCanel;
|
||||
}
|
||||
}
|
176
ProjectBomber/ProjectBomber/FormPlaneConfig.cs
Normal file
176
ProjectBomber/ProjectBomber/FormPlaneConfig.cs
Normal file
@ -0,0 +1,176 @@
|
||||
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 ProjectBomber.DrawningObjects;
|
||||
using ProjectBomber.Entities;
|
||||
|
||||
namespace ProjectBomber
|
||||
{
|
||||
public partial class FormPlaneConfig : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Переменная-выбранный самолет
|
||||
/// </summary>
|
||||
DrawningBomber _plane = null;
|
||||
/// <summary>
|
||||
/// Событие
|
||||
/// </summary>
|
||||
private event Action<DrawningBomber> EventAddPlane;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormPlaneConfig()
|
||||
{
|
||||
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;
|
||||
buttonCanel.Click += (s, e) => Close();
|
||||
}
|
||||
/// <summary>
|
||||
/// Отрисовать самолет
|
||||
/// </summary>
|
||||
private void DrawPlane()
|
||||
{
|
||||
Bitmap bmp = new Bitmap(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_plane?.SetPosition(5, 5);
|
||||
_plane?.DrawTransport(gr);
|
||||
if (_plane is DrawningBomber)
|
||||
(_plane as DrawningBomber).DrawTransport(gr);
|
||||
else
|
||||
_plane?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
/// <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":
|
||||
_plane = new DrawningBomber((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
|
||||
pictureBoxObject.Height);
|
||||
break;
|
||||
case "labelModifiedObject":
|
||||
_plane = new DrawningBomberAdvanced((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxBombs.Checked,
|
||||
checkBoxFuelTanks.Checked, checkBoxLine.Checked, pictureBoxObject.Width,
|
||||
pictureBoxObject.Height);
|
||||
break;
|
||||
}
|
||||
DrawPlane();
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление события
|
||||
/// </summary>
|
||||
/// <param name="ev">Привязанный метод</param>
|
||||
public void AddEvent(Action<DrawningBomber> ev)
|
||||
{
|
||||
if (EventAddPlane == null)
|
||||
{
|
||||
EventAddPlane = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddPlane += ev;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление машины
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddPlane?.Invoke(_plane);
|
||||
Close();
|
||||
}
|
||||
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 labelColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Действия при приеме перетаскиваемой информации об обычном цвете
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
|
||||
if (_plane is DrawningBomber plane)
|
||||
{
|
||||
labelColor.BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||
plane.setColor((Color)e.Data.GetData(typeof(Color)));
|
||||
}
|
||||
DrawPlane();
|
||||
}
|
||||
private void LabelAddColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_plane is DrawningBomberAdvanced bomber)
|
||||
{
|
||||
labelAddColor.BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||
bomber.setAddColor((Color)e.Data.GetData(typeof(Color)));
|
||||
}
|
||||
DrawPlane();
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectBomber/ProjectBomber/FormPlaneConfig.resx
Normal file
120
ProjectBomber/ProjectBomber/FormPlaneConfig.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>
|
@ -21,11 +21,11 @@ namespace ProjectBomber.Generics
|
||||
/// <summary>
|
||||
/// Ширина окна прорисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int pictureWidth;
|
||||
/// <summary>
|
||||
/// Высота окна прорисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureHeight;
|
||||
private readonly int pictureHeight;
|
||||
/// <summary>
|
||||
/// Размер занимаемого объектом места (ширина)
|
||||
/// </summary>
|
||||
@ -47,8 +47,8 @@ namespace ProjectBomber.Generics
|
||||
{
|
||||
int width = picWidth / _placeSizeWidth;
|
||||
int height = picHeight / _placeSizeHeight;
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
pictureWidth = picWidth;
|
||||
pictureHeight = picHeight;
|
||||
_collection = new SetGeneric<T>(width * height);
|
||||
}
|
||||
/// <summary>
|
||||
@ -57,15 +57,14 @@ namespace ProjectBomber.Generics
|
||||
/// <param name="collect"></param>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static bool operator +(PlanesGenericCollection<T, U> collect, T
|
||||
public static int operator +(PlanesGenericCollection<T, U> collect, T
|
||||
obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
collect?._collection.Insert(obj);
|
||||
return true;
|
||||
return collect?._collection.Insert(obj) ?? -1;
|
||||
}
|
||||
/// <summary>
|
||||
/// Перегрузка оператора вычитания
|
||||
@ -97,7 +96,7 @@ namespace ProjectBomber.Generics
|
||||
/// <returns></returns>
|
||||
public Bitmap ShowPlanes()
|
||||
{
|
||||
Bitmap bmp = new Bitmap(_pictureWidth, _pictureHeight);
|
||||
Bitmap bmp = new Bitmap(pictureWidth, pictureHeight);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
DrawBackground(gr);
|
||||
DrawObjects(gr);
|
||||
@ -110,8 +109,8 @@ namespace ProjectBomber.Generics
|
||||
private void DrawBackground(Graphics g)
|
||||
{
|
||||
Pen pen = new Pen(Color.Black, 3);
|
||||
int numColumns = _pictureWidth / _placeSizeWidth;
|
||||
int numRows = _pictureHeight / _placeSizeHeight;
|
||||
int numColumns = pictureWidth / _placeSizeWidth;
|
||||
int numRows = pictureHeight / _placeSizeHeight;
|
||||
|
||||
for (int i = 0; i <= numColumns; i++)
|
||||
{
|
||||
@ -132,11 +131,13 @@ namespace ProjectBomber.Generics
|
||||
/// <param name="g"></param>
|
||||
private void DrawObjects(Graphics g)
|
||||
{
|
||||
int numColumns = _pictureWidth / _placeSizeWidth;
|
||||
int numColumns = pictureWidth / _placeSizeWidth;
|
||||
int column = numColumns - 1;
|
||||
int row = 0;
|
||||
foreach (var plane in _collection.GetPlanes())
|
||||
{
|
||||
plane._pictureHeight = pictureHeight;
|
||||
plane._pictureWidth = pictureWidth;
|
||||
// Установка позиции бомбардировщика
|
||||
int xPosition = column * _placeSizeWidth;
|
||||
int yPosition = row * _placeSizeHeight;
|
||||
|
@ -80,6 +80,12 @@
|
||||
<Compile Include="FormPlaneCollection.Designer.cs">
|
||||
<DependentUpon>FormPlaneCollection.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="FormPlaneConfig.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FormPlaneConfig.Designer.cs">
|
||||
<DependentUpon>FormPlaneConfig.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="IMoveableObject.cs" />
|
||||
<Compile Include="MoveToBottomRight.cs" />
|
||||
<Compile Include="MoveToCenter.cs" />
|
||||
@ -96,6 +102,9 @@
|
||||
<EmbeddedResource Include="FormPlaneCollection.resx">
|
||||
<DependentUpon>FormPlaneCollection.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="FormPlaneConfig.resx">
|
||||
<DependentUpon>FormPlaneConfig.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
|
@ -39,12 +39,12 @@ namespace ProjectBomber.Generics
|
||||
/// </summary>
|
||||
/// <param name="plane">Добавляемый самолет</param>
|
||||
/// <returns></returns>
|
||||
public bool Insert(T plane)
|
||||
public int Insert(T plane)
|
||||
{
|
||||
if (_places.Count == 0)
|
||||
{
|
||||
_places.Add(plane);
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -57,10 +57,10 @@ namespace ProjectBomber.Generics
|
||||
_places[i] = _places[_places.Count - 1];
|
||||
_places[_places.Count - 1] = temp;
|
||||
}
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор на конкретную позицию
|
||||
|
Loading…
x
Reference in New Issue
Block a user