Готовая 3 лабораторная работа. Небольшие изменения в отрисовке объекта
This commit is contained in:
parent
f8b95a402a
commit
d12fbd832b
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AirplaneWithRadar
|
namespace AirplaneWithRadar
|
||||||
{
|
{
|
||||||
internal enum Direction
|
public enum Direction
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
Up = 1,
|
Up = 1,
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AirplaneWithRadar
|
namespace AirplaneWithRadar
|
||||||
{
|
{
|
||||||
internal class DrawningAirplane
|
public class DrawningAirplane
|
||||||
{
|
{
|
||||||
public EntityAirplane Airplane { get; protected set; }
|
public EntityAirplane Airplane { get; protected set; }
|
||||||
protected float _startPosX;
|
protected float _startPosX;
|
||||||
@ -84,9 +84,11 @@ namespace AirplaneWithRadar
|
|||||||
|
|
||||||
// Корпус
|
// Корпус
|
||||||
g.DrawRectangle(pen, _startPosX, _startPosY + 10, 40, 10);
|
g.DrawRectangle(pen, _startPosX, _startPosY + 10, 40, 10);
|
||||||
|
Brush darkBrush = new SolidBrush(Airplane?.BodyColor ?? Color.Black);
|
||||||
|
g.FillRectangle(darkBrush, _startPosX + 1, _startPosY + 11, 39, 9);
|
||||||
|
|
||||||
// Окно
|
// Окно
|
||||||
Brush darkBrush = new SolidBrush(Airplane?.BodyColor ?? Color.Black);
|
darkBrush = new SolidBrush(Color.Black);
|
||||||
g.FillRectangle(darkBrush, _startPosX + 12, _startPosY + 13, 20, 2);
|
g.FillRectangle(darkBrush, _startPosX + 12, _startPosY + 13, 20, 2);
|
||||||
|
|
||||||
// Хвост
|
// Хвост
|
||||||
|
@ -33,7 +33,7 @@ namespace AirplaneWithRadar
|
|||||||
|
|
||||||
if (airplaneWithRadar.Window)
|
if (airplaneWithRadar.Window)
|
||||||
{
|
{
|
||||||
g.DrawEllipse(new Pen(Color.Black), _startPosX + 40, _startPosY + 13, 5, 5);
|
g.FillEllipse(dopBrush, _startPosX + 40, _startPosY + 13, 5, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (airplaneWithRadar.Ladder)
|
if (airplaneWithRadar.Ladder)
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AirplaneWithRadar
|
namespace AirplaneWithRadar
|
||||||
{
|
{
|
||||||
internal class EntityAirplane
|
public class EntityAirplane
|
||||||
{
|
{
|
||||||
public int Speed { get; private set; }
|
public int Speed { get; private set; }
|
||||||
public float Weight { get; private set; }
|
public float Weight { get; private set; }
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
this.buttonRight = new System.Windows.Forms.Button();
|
this.buttonRight = new System.Windows.Forms.Button();
|
||||||
this.buttonUp = new System.Windows.Forms.Button();
|
this.buttonUp = new System.Windows.Forms.Button();
|
||||||
this.buttonCreateModify = new System.Windows.Forms.Button();
|
this.buttonCreateModify = new System.Windows.Forms.Button();
|
||||||
|
this.buttonSelectCar = new System.Windows.Forms.Button();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).BeginInit();
|
||||||
this.statusStrip1.SuspendLayout();
|
this.statusStrip1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -154,11 +155,22 @@
|
|||||||
this.buttonCreateModify.UseVisualStyleBackColor = true;
|
this.buttonCreateModify.UseVisualStyleBackColor = true;
|
||||||
this.buttonCreateModify.Click += new System.EventHandler(this.buttonCreateModify_Click);
|
this.buttonCreateModify.Click += new System.EventHandler(this.buttonCreateModify_Click);
|
||||||
//
|
//
|
||||||
|
// buttonSelectCar
|
||||||
|
//
|
||||||
|
this.buttonSelectCar.Location = new System.Drawing.Point(560, 391);
|
||||||
|
this.buttonSelectCar.Name = "buttonSelectCar";
|
||||||
|
this.buttonSelectCar.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonSelectCar.TabIndex = 8;
|
||||||
|
this.buttonSelectCar.Text = "Выбрать";
|
||||||
|
this.buttonSelectCar.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSelectCar.Click += new System.EventHandler(this.buttonSelectCar_Click);
|
||||||
|
//
|
||||||
// FormAirplane
|
// FormAirplane
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(800, 451);
|
this.ClientSize = new System.Drawing.Size(800, 451);
|
||||||
|
this.Controls.Add(this.buttonSelectCar);
|
||||||
this.Controls.Add(this.buttonCreateModify);
|
this.Controls.Add(this.buttonCreateModify);
|
||||||
this.Controls.Add(this.buttonUp);
|
this.Controls.Add(this.buttonUp);
|
||||||
this.Controls.Add(this.buttonRight);
|
this.Controls.Add(this.buttonRight);
|
||||||
@ -190,5 +202,6 @@
|
|||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
private Button buttonUp;
|
private Button buttonUp;
|
||||||
private Button buttonCreateModify;
|
private Button buttonCreateModify;
|
||||||
|
private Button buttonSelectCar;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,6 +3,10 @@ namespace AirplaneWithRadar
|
|||||||
public partial class FormAirplane : Form
|
public partial class FormAirplane : Form
|
||||||
{
|
{
|
||||||
private DrawningAirplane _airplane;
|
private DrawningAirplane _airplane;
|
||||||
|
/// <summary>
|
||||||
|
/// Âűáđŕííűé îáúĺęň
|
||||||
|
/// </summary>
|
||||||
|
public DrawningAirplane SelectedAirplane { get; private set; }
|
||||||
public FormAirplane()
|
public FormAirplane()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -27,8 +31,14 @@ namespace AirplaneWithRadar
|
|||||||
}
|
}
|
||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random random = new();
|
||||||
_airplane = new DrawningAirplane(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
Color myColor = new Color();
|
||||||
|
ColorDialog MyDialog = new ColorDialog();
|
||||||
|
if (MyDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
myColor = MyDialog.Color;
|
||||||
|
}
|
||||||
|
_airplane = new DrawningAirplane(random.Next(30, 50), random.Next(1000, 2000), myColor);
|
||||||
SetData();
|
SetData();
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
@ -66,12 +76,28 @@ namespace AirplaneWithRadar
|
|||||||
private void buttonCreateModify_Click(object sender, EventArgs e)
|
private void buttonCreateModify_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
_airplane = new DrawningAirplaneWithRadar(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
ColorDialog dialog = new();
|
||||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
color = dialog.Color;
|
||||||
|
}
|
||||||
|
Color dopColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||||
|
ColorDialog dialogDop = new();
|
||||||
|
if (dialogDop.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
dopColor = dialogDop.Color;
|
||||||
|
}
|
||||||
|
_airplane = new DrawningAirplaneWithRadar(rnd.Next(100, 300), rnd.Next(1000, 2000), color, dopColor,
|
||||||
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||||
SetData();
|
SetData();
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void buttonSelectCar_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SelectedAirplane = _airplane;
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
239
AirplaneWithRadar/AirplaneWithRadar/FormMapWithSetAirplane.Designer.cs
generated
Normal file
239
AirplaneWithRadar/AirplaneWithRadar/FormMapWithSetAirplane.Designer.cs
generated
Normal file
@ -0,0 +1,239 @@
|
|||||||
|
namespace AirplaneWithRadar
|
||||||
|
{
|
||||||
|
partial class FormMapWithSetAirplane
|
||||||
|
{
|
||||||
|
/// <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.groupBox = new System.Windows.Forms.GroupBox();
|
||||||
|
this.buttonDown = new System.Windows.Forms.Button();
|
||||||
|
this.buttonRight = new System.Windows.Forms.Button();
|
||||||
|
this.buttonLeft = new System.Windows.Forms.Button();
|
||||||
|
this.buttonUp = new System.Windows.Forms.Button();
|
||||||
|
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
||||||
|
this.buttonShowStorage = new System.Windows.Forms.Button();
|
||||||
|
this.buttonRemoveAirplane = new System.Windows.Forms.Button();
|
||||||
|
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||||
|
this.buttonAddAirplane = new System.Windows.Forms.Button();
|
||||||
|
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||||
|
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||||
|
this.groupBox.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// groupBox
|
||||||
|
//
|
||||||
|
this.groupBox.Controls.Add(this.buttonDown);
|
||||||
|
this.groupBox.Controls.Add(this.buttonRight);
|
||||||
|
this.groupBox.Controls.Add(this.buttonLeft);
|
||||||
|
this.groupBox.Controls.Add(this.buttonUp);
|
||||||
|
this.groupBox.Controls.Add(this.buttonShowOnMap);
|
||||||
|
this.groupBox.Controls.Add(this.buttonShowStorage);
|
||||||
|
this.groupBox.Controls.Add(this.buttonRemoveAirplane);
|
||||||
|
this.groupBox.Controls.Add(this.maskedTextBoxPosition);
|
||||||
|
this.groupBox.Controls.Add(this.buttonAddAirplane);
|
||||||
|
this.groupBox.Controls.Add(this.comboBoxSelectorMap);
|
||||||
|
this.groupBox.Dock = System.Windows.Forms.DockStyle.Right;
|
||||||
|
this.groupBox.Location = new System.Drawing.Point(685, 0);
|
||||||
|
this.groupBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.groupBox.Name = "groupBox";
|
||||||
|
this.groupBox.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.groupBox.Size = new System.Drawing.Size(229, 600);
|
||||||
|
this.groupBox.TabIndex = 0;
|
||||||
|
this.groupBox.TabStop = false;
|
||||||
|
this.groupBox.Text = "Инструменты";
|
||||||
|
//
|
||||||
|
// buttonDown
|
||||||
|
//
|
||||||
|
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonDown.BackgroundImage = global::AirplaneWithRadar.Properties.Resources.arrowDown;
|
||||||
|
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonDown.Location = new System.Drawing.Point(99, 537);
|
||||||
|
this.buttonDown.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonDown.Name = "buttonDown";
|
||||||
|
this.buttonDown.Size = new System.Drawing.Size(34, 40);
|
||||||
|
this.buttonDown.TabIndex = 9;
|
||||||
|
this.buttonDown.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// buttonRight
|
||||||
|
//
|
||||||
|
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonRight.BackgroundImage = global::AirplaneWithRadar.Properties.Resources.arrowRight;
|
||||||
|
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonRight.Location = new System.Drawing.Point(141, 537);
|
||||||
|
this.buttonRight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonRight.Name = "buttonRight";
|
||||||
|
this.buttonRight.Size = new System.Drawing.Size(34, 40);
|
||||||
|
this.buttonRight.TabIndex = 8;
|
||||||
|
this.buttonRight.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// buttonLeft
|
||||||
|
//
|
||||||
|
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonLeft.BackgroundImage = global::AirplaneWithRadar.Properties.Resources.arrowLeft;
|
||||||
|
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonLeft.Location = new System.Drawing.Point(58, 537);
|
||||||
|
this.buttonLeft.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonLeft.Name = "buttonLeft";
|
||||||
|
this.buttonLeft.Size = new System.Drawing.Size(34, 40);
|
||||||
|
this.buttonLeft.TabIndex = 7;
|
||||||
|
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// buttonUp
|
||||||
|
//
|
||||||
|
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonUp.BackgroundImage = global::AirplaneWithRadar.Properties.Resources.arrowUp;
|
||||||
|
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonUp.Location = new System.Drawing.Point(99, 489);
|
||||||
|
this.buttonUp.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonUp.Name = "buttonUp";
|
||||||
|
this.buttonUp.Size = new System.Drawing.Size(34, 40);
|
||||||
|
this.buttonUp.TabIndex = 6;
|
||||||
|
this.buttonUp.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// buttonShowOnMap
|
||||||
|
//
|
||||||
|
this.buttonShowOnMap.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonShowOnMap.Location = new System.Drawing.Point(22, 416);
|
||||||
|
this.buttonShowOnMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonShowOnMap.Name = "buttonShowOnMap";
|
||||||
|
this.buttonShowOnMap.Size = new System.Drawing.Size(193, 40);
|
||||||
|
this.buttonShowOnMap.TabIndex = 5;
|
||||||
|
this.buttonShowOnMap.Text = "Посмотреть карту";
|
||||||
|
this.buttonShowOnMap.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
|
||||||
|
//
|
||||||
|
// buttonShowStorage
|
||||||
|
//
|
||||||
|
this.buttonShowStorage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonShowStorage.Location = new System.Drawing.Point(22, 311);
|
||||||
|
this.buttonShowStorage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonShowStorage.Name = "buttonShowStorage";
|
||||||
|
this.buttonShowStorage.Size = new System.Drawing.Size(193, 40);
|
||||||
|
this.buttonShowStorage.TabIndex = 4;
|
||||||
|
this.buttonShowStorage.Text = "Посмотреть хранилище";
|
||||||
|
this.buttonShowStorage.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
|
||||||
|
//
|
||||||
|
// buttonRemoveAirplane
|
||||||
|
//
|
||||||
|
this.buttonRemoveAirplane.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonRemoveAirplane.Location = new System.Drawing.Point(22, 228);
|
||||||
|
this.buttonRemoveAirplane.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonRemoveAirplane.Name = "buttonRemoveAirplane";
|
||||||
|
this.buttonRemoveAirplane.Size = new System.Drawing.Size(193, 40);
|
||||||
|
this.buttonRemoveAirplane.TabIndex = 3;
|
||||||
|
this.buttonRemoveAirplane.Text = "Удалить самолет";
|
||||||
|
this.buttonRemoveAirplane.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonRemoveAirplane.Click += new System.EventHandler(this.ButtonRemoveAirplane_Click);
|
||||||
|
//
|
||||||
|
// maskedTextBoxPosition
|
||||||
|
//
|
||||||
|
this.maskedTextBoxPosition.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.maskedTextBoxPosition.Location = new System.Drawing.Point(22, 189);
|
||||||
|
this.maskedTextBoxPosition.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.maskedTextBoxPosition.Mask = "00";
|
||||||
|
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||||
|
this.maskedTextBoxPosition.Size = new System.Drawing.Size(193, 27);
|
||||||
|
this.maskedTextBoxPosition.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// buttonAddAirplane
|
||||||
|
//
|
||||||
|
this.buttonAddAirplane.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonAddAirplane.Location = new System.Drawing.Point(22, 120);
|
||||||
|
this.buttonAddAirplane.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonAddAirplane.Name = "buttonAddAirplane";
|
||||||
|
this.buttonAddAirplane.Size = new System.Drawing.Size(193, 40);
|
||||||
|
this.buttonAddAirplane.TabIndex = 1;
|
||||||
|
this.buttonAddAirplane.Text = "Добавить самолет";
|
||||||
|
this.buttonAddAirplane.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAddAirplane.Click += new System.EventHandler(this.ButtonAddAirplane_Click);
|
||||||
|
//
|
||||||
|
// comboBoxSelectorMap
|
||||||
|
//
|
||||||
|
this.comboBoxSelectorMap.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||||
|
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
||||||
|
"Простая карта",
|
||||||
|
"Карта неба с облаками",
|
||||||
|
"Карта туманного неба с грозой"});
|
||||||
|
this.comboBoxSelectorMap.Location = new System.Drawing.Point(22, 44);
|
||||||
|
this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||||
|
this.comboBoxSelectorMap.Size = new System.Drawing.Size(193, 28);
|
||||||
|
this.comboBoxSelectorMap.TabIndex = 0;
|
||||||
|
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// pictureBox
|
||||||
|
//
|
||||||
|
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.pictureBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.pictureBox.Name = "pictureBox";
|
||||||
|
this.pictureBox.Size = new System.Drawing.Size(685, 600);
|
||||||
|
this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||||
|
this.pictureBox.TabIndex = 1;
|
||||||
|
this.pictureBox.TabStop = false;
|
||||||
|
//
|
||||||
|
// FormMapWithSetAirplane
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(914, 600);
|
||||||
|
this.Controls.Add(this.pictureBox);
|
||||||
|
this.Controls.Add(this.groupBox);
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.Name = "FormMapWithSetAirplane";
|
||||||
|
this.Text = "FormMapWithSetAirplane";
|
||||||
|
this.groupBox.ResumeLayout(false);
|
||||||
|
this.groupBox.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private GroupBox groupBox;
|
||||||
|
private Button buttonDown;
|
||||||
|
private Button buttonRight;
|
||||||
|
private Button buttonLeft;
|
||||||
|
private Button buttonUp;
|
||||||
|
private Button buttonShowOnMap;
|
||||||
|
private Button buttonShowStorage;
|
||||||
|
private Button buttonRemoveAirplane;
|
||||||
|
private MaskedTextBox maskedTextBoxPosition;
|
||||||
|
private Button buttonAddAirplane;
|
||||||
|
private ComboBox comboBoxSelectorMap;
|
||||||
|
private PictureBox pictureBox;
|
||||||
|
}
|
||||||
|
}
|
164
AirplaneWithRadar/AirplaneWithRadar/FormMapWithSetAirplane.cs
Normal file
164
AirplaneWithRadar/AirplaneWithRadar/FormMapWithSetAirplane.cs
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
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 static System.Windows.Forms.DataFormats;
|
||||||
|
|
||||||
|
namespace AirplaneWithRadar
|
||||||
|
{
|
||||||
|
public partial class FormMapWithSetAirplane : Form
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Объект от класса карты с набором объектов
|
||||||
|
/// </summary>
|
||||||
|
private MapWithSetAirplaneGeneric<DrawningObjectAirplane, AbstractMap> _mapAirplaneCollectionGeneric;
|
||||||
|
public FormMapWithSetAirplane()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Выбор карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
AbstractMap map = null;
|
||||||
|
switch (comboBoxSelectorMap.Text)
|
||||||
|
{
|
||||||
|
case "Простая карта":
|
||||||
|
map = new SimpleMap();
|
||||||
|
break;
|
||||||
|
case "Карта неба с облаками":
|
||||||
|
map = new SkyMap();
|
||||||
|
break;
|
||||||
|
case "Карта туманного неба с грозой":
|
||||||
|
map = new FoggySkyMap();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (map != null)
|
||||||
|
{
|
||||||
|
_mapAirplaneCollectionGeneric = new MapWithSetAirplaneGeneric<DrawningObjectAirplane, AbstractMap>(
|
||||||
|
pictureBox.Width, pictureBox.Height, map);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_mapAirplaneCollectionGeneric = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Добавление объекта
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonAddAirplane_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_mapAirplaneCollectionGeneric == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FormAirplane form = new();
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
DrawningObjectAirplane airplane = new(form.SelectedAirplane);
|
||||||
|
if (_mapAirplaneCollectionGeneric + airplane != -1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект добавлен");
|
||||||
|
pictureBox.Image = _mapAirplaneCollectionGeneric.ShowSet();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Удаление объекта
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonRemoveAirplane_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||||
|
if (_mapAirplaneCollectionGeneric - pos != null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект удален");
|
||||||
|
pictureBox.Image = _mapAirplaneCollectionGeneric.ShowSet();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось удалить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Вывод набора
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_mapAirplaneCollectionGeneric == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pictureBox.Image = _mapAirplaneCollectionGeneric.ShowSet();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Вывод карты
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_mapAirplaneCollectionGeneric == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pictureBox.Image = _mapAirplaneCollectionGeneric.ShowOnMap();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Перемещение
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_mapAirplaneCollectionGeneric == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//получаем имя кнопки
|
||||||
|
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||||
|
Direction dir = Direction.None;
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case "buttonUp":
|
||||||
|
dir = Direction.Up;
|
||||||
|
break;
|
||||||
|
case "buttonDown":
|
||||||
|
dir = Direction.Down;
|
||||||
|
break;
|
||||||
|
case "buttonLeft":
|
||||||
|
dir = Direction.Left;
|
||||||
|
break;
|
||||||
|
case "buttonRight":
|
||||||
|
dir = Direction.Right;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pictureBox.Image = _mapAirplaneCollectionGeneric.MoveObject(dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
@ -28,9 +28,9 @@
|
|||||||
_map = map;
|
_map = map;
|
||||||
}
|
}
|
||||||
// Перегрузка оператора сложения
|
// Перегрузка оператора сложения
|
||||||
public static int operator +(MapWithSetAirplaneGeneric<T, U> map, T tractor)
|
public static int operator +(MapWithSetAirplaneGeneric<T, U> map, T airplane)
|
||||||
{
|
{
|
||||||
return map._setAirplane.Insert(tractor);
|
return map._setAirplane.Insert(airplane);
|
||||||
}
|
}
|
||||||
// Перегрузка оператора вычитания
|
// Перегрузка оператора вычитания
|
||||||
public static T operator -(MapWithSetAirplaneGeneric<T, U> map, int position)
|
public static T operator -(MapWithSetAirplaneGeneric<T, U> map, int position)
|
||||||
@ -98,7 +98,7 @@
|
|||||||
private void DrawBackground(Graphics g)
|
private void DrawBackground(Graphics g)
|
||||||
{
|
{
|
||||||
Pen pen = new(Color.Black, 3);
|
Pen pen = new(Color.Black, 3);
|
||||||
Brush brush = new SolidBrush(Color.LightSlateGray);
|
Brush brush = new SolidBrush(Color.FromArgb(147, 146, 151));
|
||||||
g.FillRectangle(brush, 0, 0, _pictureWidth, _pictureHeight);
|
g.FillRectangle(brush, 0, 0, _pictureWidth, _pictureHeight);
|
||||||
for (int i = 0; i <= _pictureWidth / _placeSizeWidth; i++)
|
for (int i = 0; i <= _pictureWidth / _placeSizeWidth; i++)
|
||||||
{
|
{
|
||||||
@ -121,8 +121,8 @@
|
|||||||
|
|
||||||
for (int i = _setAirplane.Count; i >= 0; i--)
|
for (int i = _setAirplane.Count; i >= 0; i--)
|
||||||
{
|
{
|
||||||
_setAirplane.Get(i)?.SetObject(_pictureWidth - _placeSizeWidth * curWidth - 10,
|
_setAirplane.Get(i)?.SetObject(_pictureWidth - _placeSizeWidth * curWidth - 80,
|
||||||
curHeight * _placeSizeHeight + 10, _pictureWidth, _pictureHeight);
|
curHeight * _placeSizeHeight + 30, _pictureWidth, _pictureHeight);
|
||||||
_setAirplane.Get(i)?.DrawningObject(g);
|
_setAirplane.Get(i)?.DrawningObject(g);
|
||||||
|
|
||||||
if (curWidth < widthEl)
|
if (curWidth < widthEl)
|
||||||
|
@ -11,7 +11,7 @@ namespace AirplaneWithRadar
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new FormMap());
|
Application.Run(new FormMapWithSetAirplane());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user