Compare commits
10 Commits
FirstLabWo
...
ThirdLabWo
| Author | SHA1 | Date | |
|---|---|---|---|
| aeb3e0cfb0 | |||
| 533515c075 | |||
| 9848138396 | |||
| e2129a1e01 | |||
| 878637552a | |||
| 396b2d8f1e | |||
| da0640612c | |||
| 42a7fe8911 | |||
| f6a15851ae | |||
| 6cb049d4d6 |
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace ArmoredVehicle
|
||||
{
|
||||
internal class ArmoredVehicleEntity
|
||||
public class ArmoredVehicleEntity
|
||||
{
|
||||
public ArmoredVehicleEntity(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace ArmoredVehicle
|
||||
/// <summary>
|
||||
/// Направление перемещения
|
||||
/// </summary>
|
||||
internal enum Direction
|
||||
public enum Direction
|
||||
{
|
||||
None = 0,
|
||||
Up = 1,
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace ArmoredVehicle
|
||||
{
|
||||
internal class DrawingArmoredVehicle
|
||||
public class DrawingArmoredVehicle
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
|
||||
212
ArmoredVehicle/FormMap.Designer.cs
generated
212
ArmoredVehicle/FormMap.Designer.cs
generated
@@ -1,212 +0,0 @@
|
||||
namespace ArmoredVehicle
|
||||
{
|
||||
partial class FormMap
|
||||
{
|
||||
/// <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.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.CreateButton = new System.Windows.Forms.Button();
|
||||
this.DrawingPictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripStatusLabelColor = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.statusStrip = new System.Windows.Forms.StatusStrip();
|
||||
this.TankButton = new System.Windows.Forms.Button();
|
||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.DrawingPictureBox)).BeginInit();
|
||||
this.statusStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ButtonDown
|
||||
//
|
||||
this.ButtonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonDown.BackgroundImage = global::ArmoredVehicle.Properties.Resources.arrowDown;
|
||||
this.ButtonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.ButtonDown.Location = new System.Drawing.Point(711, 373);
|
||||
this.ButtonDown.Name = "ButtonDown";
|
||||
this.ButtonDown.Size = new System.Drawing.Size(30, 30);
|
||||
this.ButtonDown.TabIndex = 13;
|
||||
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::ArmoredVehicle.Properties.Resources.arrowRight;
|
||||
this.ButtonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.ButtonRight.Location = new System.Drawing.Point(754, 326);
|
||||
this.ButtonRight.Name = "ButtonRight";
|
||||
this.ButtonRight.Size = new System.Drawing.Size(30, 30);
|
||||
this.ButtonRight.TabIndex = 12;
|
||||
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::ArmoredVehicle.Properties.Resources.arrowLeft;
|
||||
this.ButtonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.ButtonLeft.Location = new System.Drawing.Point(671, 328);
|
||||
this.ButtonLeft.Name = "ButtonLeft";
|
||||
this.ButtonLeft.Size = new System.Drawing.Size(30, 30);
|
||||
this.ButtonLeft.TabIndex = 11;
|
||||
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::ArmoredVehicle.Properties.Resources.arrowUp;
|
||||
this.ButtonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.ButtonUp.Location = new System.Drawing.Point(711, 278);
|
||||
this.ButtonUp.Name = "ButtonUp";
|
||||
this.ButtonUp.Size = new System.Drawing.Size(30, 30);
|
||||
this.ButtonUp.TabIndex = 10;
|
||||
this.ButtonUp.UseVisualStyleBackColor = true;
|
||||
this.ButtonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// CreateButton
|
||||
//
|
||||
this.CreateButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.CreateButton.Location = new System.Drawing.Point(12, 362);
|
||||
this.CreateButton.Name = "CreateButton";
|
||||
this.CreateButton.Size = new System.Drawing.Size(112, 34);
|
||||
this.CreateButton.TabIndex = 9;
|
||||
this.CreateButton.Text = "Создать";
|
||||
this.CreateButton.UseVisualStyleBackColor = true;
|
||||
this.CreateButton.Click += new System.EventHandler(this.ButtonCreate_Click);
|
||||
//
|
||||
// DrawingPictureBox
|
||||
//
|
||||
this.DrawingPictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.DrawingPictureBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.DrawingPictureBox.Name = "DrawingPictureBox";
|
||||
this.DrawingPictureBox.Size = new System.Drawing.Size(800, 418);
|
||||
this.DrawingPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.DrawingPictureBox.TabIndex = 7;
|
||||
this.DrawingPictureBox.TabStop = false;
|
||||
//
|
||||
// toolStripStatusLabelSpeed
|
||||
//
|
||||
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
|
||||
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(89, 25);
|
||||
this.toolStripStatusLabelSpeed.Text = "Скорость";
|
||||
//
|
||||
// toolStripStatusLabelWeight
|
||||
//
|
||||
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
|
||||
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(39, 25);
|
||||
this.toolStripStatusLabelWeight.Text = "Вес";
|
||||
//
|
||||
// toolStripStatusLabelColor
|
||||
//
|
||||
this.toolStripStatusLabelColor.Name = "toolStripStatusLabelColor";
|
||||
this.toolStripStatusLabelColor.Size = new System.Drawing.Size(51, 25);
|
||||
this.toolStripStatusLabelColor.Text = "Цвет";
|
||||
//
|
||||
// statusStrip
|
||||
//
|
||||
this.statusStrip.ImageScalingSize = new System.Drawing.Size(24, 24);
|
||||
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripStatusLabelSpeed,
|
||||
this.toolStripStatusLabelWeight,
|
||||
this.toolStripStatusLabelColor});
|
||||
this.statusStrip.Location = new System.Drawing.Point(0, 418);
|
||||
this.statusStrip.Name = "statusStrip";
|
||||
this.statusStrip.Size = new System.Drawing.Size(800, 32);
|
||||
this.statusStrip.TabIndex = 8;
|
||||
this.statusStrip.Text = "statusStrip1";
|
||||
//
|
||||
// TankButton
|
||||
//
|
||||
this.TankButton.Location = new System.Drawing.Point(139, 365);
|
||||
this.TankButton.Name = "TankButton";
|
||||
this.TankButton.Size = new System.Drawing.Size(143, 34);
|
||||
this.TankButton.TabIndex = 14;
|
||||
this.TankButton.Text = "Модификация";
|
||||
this.TankButton.UseVisualStyleBackColor = true;
|
||||
this.TankButton.Click += new System.EventHandler(this.TankButton_Click);
|
||||
//
|
||||
// comboBoxSelectorMap
|
||||
//
|
||||
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(13, 321);
|
||||
this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(171, 33);
|
||||
this.comboBoxSelectorMap.TabIndex = 15;
|
||||
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.comboBoxSelectorMap_SelectedIndexChanged_1);
|
||||
//
|
||||
// FormMap
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.comboBoxSelectorMap);
|
||||
this.Controls.Add(this.TankButton);
|
||||
this.Controls.Add(this.ButtonDown);
|
||||
this.Controls.Add(this.ButtonRight);
|
||||
this.Controls.Add(this.ButtonLeft);
|
||||
this.Controls.Add(this.ButtonUp);
|
||||
this.Controls.Add(this.CreateButton);
|
||||
this.Controls.Add(this.DrawingPictureBox);
|
||||
this.Controls.Add(this.statusStrip);
|
||||
this.MinimumSize = new System.Drawing.Size(210, 50);
|
||||
this.Name = "FormMap";
|
||||
this.Text = "Карта";
|
||||
((System.ComponentModel.ISupportInitialize)(this.DrawingPictureBox)).EndInit();
|
||||
this.statusStrip.ResumeLayout(false);
|
||||
this.statusStrip.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button ButtonDown;
|
||||
private Button ButtonRight;
|
||||
private Button ButtonLeft;
|
||||
private Button ButtonUp;
|
||||
private Button CreateButton;
|
||||
private PictureBox DrawingPictureBox;
|
||||
private ToolStripStatusLabel toolStripStatusLabelSpeed;
|
||||
private ToolStripStatusLabel toolStripStatusLabelWeight;
|
||||
private ToolStripStatusLabel toolStripStatusLabelColor;
|
||||
private StatusStrip statusStrip;
|
||||
private Button TankButton;
|
||||
private ComboBox comboBoxSelectorMap;
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
namespace ArmoredVehicle
|
||||
{
|
||||
public partial class FormMap : Form
|
||||
{
|
||||
private AbstractMap _abstractMap;
|
||||
|
||||
public FormMap()
|
||||
{
|
||||
InitializeComponent();
|
||||
_abstractMap = new SimpleMap();
|
||||
}
|
||||
/// <summary>
|
||||
/// Заполнение информации по объекту
|
||||
/// </summary>
|
||||
/// <param name="car"></param>
|
||||
private void SetData(DrawingArmoredVehicle armoredVehicle)
|
||||
{
|
||||
toolStripStatusLabelSpeed.Text = $"Скорость: {armoredVehicle.ArmoredVehicle.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Вес: {armoredVehicle.ArmoredVehicle.Weight}";
|
||||
toolStripStatusLabelColor.Text = $"Цвет: {armoredVehicle.ArmoredVehicle.BodyColor.Name}";
|
||||
DrawingPictureBox.Image = _abstractMap.CreateMap(DrawingPictureBox.Width, DrawingPictureBox.Height,
|
||||
new DrawningObject(armoredVehicle));
|
||||
}
|
||||
/// <summary>
|
||||
/// Обработка нажатия кнопки "Создать"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
var machine = new DrawingArmoredVehicle(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
SetData(machine);
|
||||
}
|
||||
/// <summary>
|
||||
/// Изменение размеров формы
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
//получаем имя кнопки
|
||||
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;
|
||||
}
|
||||
|
||||
DrawingPictureBox.Image = _abstractMap?.MoveObject(dir);
|
||||
}
|
||||
/// <summary>
|
||||
/// Смена карты
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
|
||||
private void comboBoxSelectorMap_SelectedIndexChanged_1(object sender, EventArgs e)
|
||||
{
|
||||
switch (comboBoxSelectorMap.Text)
|
||||
{
|
||||
case "Простая карта":
|
||||
_abstractMap = new SimpleMap();
|
||||
break;
|
||||
case "Горизонтальная карта":
|
||||
_abstractMap = new HorizontalMap();
|
||||
break;
|
||||
case "Вертикальная карта":
|
||||
_abstractMap = new VerticalMap();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void TankButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
Random rnd = new();
|
||||
var tank = new DrawingTank(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
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)),
|
||||
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||
SetData(tank);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
<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>
|
||||
<metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
284
ArmoredVehicle/FormMapWithSetMachine.Designer.cs
generated
Normal file
284
ArmoredVehicle/FormMapWithSetMachine.Designer.cs
generated
Normal file
@@ -0,0 +1,284 @@
|
||||
namespace ArmoredVehicle
|
||||
{
|
||||
partial class FormMapWithSetMachine
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMapWithSetMachine));
|
||||
this.groupBoxInstruments = new System.Windows.Forms.GroupBox();
|
||||
this.groupBoxMap = new System.Windows.Forms.GroupBox();
|
||||
this.buttonDeleteMap = new System.Windows.Forms.Button();
|
||||
this.listBoxMaps = new System.Windows.Forms.ListBox();
|
||||
this.buttonAddMap = new System.Windows.Forms.Button();
|
||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||
this.textBoxNewMapName = new System.Windows.Forms.TextBox();
|
||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
||||
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.buttonMap = new System.Windows.Forms.Button();
|
||||
this.buttonStore = new System.Windows.Forms.Button();
|
||||
this.buttonDelete = new System.Windows.Forms.Button();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.pictureBoxImage = new System.Windows.Forms.PictureBox();
|
||||
this.groupBoxInstruments.SuspendLayout();
|
||||
this.groupBoxMap.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxImage)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBoxInstruments
|
||||
//
|
||||
this.groupBoxInstruments.Controls.Add(this.groupBoxMap);
|
||||
this.groupBoxInstruments.Controls.Add(this.maskedTextBoxPosition);
|
||||
this.groupBoxInstruments.Controls.Add(this.ButtonDown);
|
||||
this.groupBoxInstruments.Controls.Add(this.ButtonRight);
|
||||
this.groupBoxInstruments.Controls.Add(this.ButtonLeft);
|
||||
this.groupBoxInstruments.Controls.Add(this.ButtonUp);
|
||||
this.groupBoxInstruments.Controls.Add(this.buttonMap);
|
||||
this.groupBoxInstruments.Controls.Add(this.buttonStore);
|
||||
this.groupBoxInstruments.Controls.Add(this.buttonDelete);
|
||||
this.groupBoxInstruments.Controls.Add(this.buttonAdd);
|
||||
this.groupBoxInstruments.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.groupBoxInstruments.Location = new System.Drawing.Point(964, 0);
|
||||
this.groupBoxInstruments.Name = "groupBoxInstruments";
|
||||
this.groupBoxInstruments.Size = new System.Drawing.Size(300, 910);
|
||||
this.groupBoxInstruments.TabIndex = 0;
|
||||
this.groupBoxInstruments.TabStop = false;
|
||||
this.groupBoxInstruments.Text = "Инструменты";
|
||||
//
|
||||
// groupBoxMap
|
||||
//
|
||||
this.groupBoxMap.Controls.Add(this.buttonDeleteMap);
|
||||
this.groupBoxMap.Controls.Add(this.listBoxMaps);
|
||||
this.groupBoxMap.Controls.Add(this.buttonAddMap);
|
||||
this.groupBoxMap.Controls.Add(this.comboBoxSelectorMap);
|
||||
this.groupBoxMap.Controls.Add(this.textBoxNewMapName);
|
||||
this.groupBoxMap.Location = new System.Drawing.Point(13, 30);
|
||||
this.groupBoxMap.Name = "groupBoxMap";
|
||||
this.groupBoxMap.Size = new System.Drawing.Size(267, 408);
|
||||
this.groupBoxMap.TabIndex = 19;
|
||||
this.groupBoxMap.TabStop = false;
|
||||
this.groupBoxMap.Text = "Карты";
|
||||
//
|
||||
// buttonDeleteMap
|
||||
//
|
||||
this.buttonDeleteMap.Location = new System.Drawing.Point(5, 330);
|
||||
this.buttonDeleteMap.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.buttonDeleteMap.Name = "buttonDeleteMap";
|
||||
this.buttonDeleteMap.Size = new System.Drawing.Size(250, 58);
|
||||
this.buttonDeleteMap.TabIndex = 6;
|
||||
this.buttonDeleteMap.Text = "Удалить карту";
|
||||
this.buttonDeleteMap.UseVisualStyleBackColor = true;
|
||||
this.buttonDeleteMap.Click += new System.EventHandler(this.ButtonDeleteMap_Click);
|
||||
//
|
||||
// listBoxMaps
|
||||
//
|
||||
this.listBoxMaps.FormattingEnabled = true;
|
||||
this.listBoxMaps.ItemHeight = 25;
|
||||
this.listBoxMaps.Location = new System.Drawing.Point(5, 189);
|
||||
this.listBoxMaps.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.listBoxMaps.Name = "listBoxMaps";
|
||||
this.listBoxMaps.Size = new System.Drawing.Size(248, 129);
|
||||
this.listBoxMaps.TabIndex = 5;
|
||||
this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.ListBoxMaps_SelectedIndexChanged);
|
||||
//
|
||||
// buttonAddMap
|
||||
//
|
||||
this.buttonAddMap.Location = new System.Drawing.Point(5, 121);
|
||||
this.buttonAddMap.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.buttonAddMap.Name = "buttonAddMap";
|
||||
this.buttonAddMap.Size = new System.Drawing.Size(250, 58);
|
||||
this.buttonAddMap.TabIndex = 4;
|
||||
this.buttonAddMap.Text = "Добавить карту";
|
||||
this.buttonAddMap.UseVisualStyleBackColor = true;
|
||||
this.buttonAddMap.Click += new System.EventHandler(this.ButtonAddMap_Click);
|
||||
//
|
||||
// comboBoxSelectorMap
|
||||
//
|
||||
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(5, 73);
|
||||
this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(248, 33);
|
||||
this.comboBoxSelectorMap.TabIndex = 3;
|
||||
//
|
||||
// textBoxNewMapName
|
||||
//
|
||||
this.textBoxNewMapName.Location = new System.Drawing.Point(5, 32);
|
||||
this.textBoxNewMapName.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.textBoxNewMapName.Name = "textBoxNewMapName";
|
||||
this.textBoxNewMapName.Size = new System.Drawing.Size(248, 31);
|
||||
this.textBoxNewMapName.TabIndex = 1;
|
||||
//
|
||||
// maskedTextBoxPosition
|
||||
//
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(10, 506);
|
||||
this.maskedTextBoxPosition.Mask = "00";
|
||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(270, 31);
|
||||
this.maskedTextBoxPosition.TabIndex = 18;
|
||||
//
|
||||
// ButtonDown
|
||||
//
|
||||
this.ButtonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ButtonDown.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("ButtonDown.BackgroundImage")));
|
||||
this.ButtonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.ButtonDown.Location = new System.Drawing.Point(129, 823);
|
||||
this.ButtonDown.Name = "ButtonDown";
|
||||
this.ButtonDown.Size = new System.Drawing.Size(40, 36);
|
||||
this.ButtonDown.TabIndex = 17;
|
||||
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 = ((System.Drawing.Image)(resources.GetObject("ButtonRight.BackgroundImage")));
|
||||
this.ButtonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.ButtonRight.Location = new System.Drawing.Point(172, 776);
|
||||
this.ButtonRight.Name = "ButtonRight";
|
||||
this.ButtonRight.Size = new System.Drawing.Size(40, 36);
|
||||
this.ButtonRight.TabIndex = 16;
|
||||
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 = ((System.Drawing.Image)(resources.GetObject("ButtonLeft.BackgroundImage")));
|
||||
this.ButtonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.ButtonLeft.Location = new System.Drawing.Point(89, 778);
|
||||
this.ButtonLeft.Name = "ButtonLeft";
|
||||
this.ButtonLeft.Size = new System.Drawing.Size(40, 36);
|
||||
this.ButtonLeft.TabIndex = 15;
|
||||
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 = ((System.Drawing.Image)(resources.GetObject("ButtonUp.BackgroundImage")));
|
||||
this.ButtonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.ButtonUp.Location = new System.Drawing.Point(129, 728);
|
||||
this.ButtonUp.Name = "ButtonUp";
|
||||
this.ButtonUp.Size = new System.Drawing.Size(40, 36);
|
||||
this.ButtonUp.TabIndex = 14;
|
||||
this.ButtonUp.UseVisualStyleBackColor = true;
|
||||
this.ButtonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonMap
|
||||
//
|
||||
this.buttonMap.Location = new System.Drawing.Point(18, 680);
|
||||
this.buttonMap.Name = "buttonMap";
|
||||
this.buttonMap.Size = new System.Drawing.Size(262, 34);
|
||||
this.buttonMap.TabIndex = 5;
|
||||
this.buttonMap.Text = "Посмотреть карту";
|
||||
this.buttonMap.UseVisualStyleBackColor = true;
|
||||
this.buttonMap.Click += new System.EventHandler(this.ButtonMap_Click);
|
||||
//
|
||||
// buttonStore
|
||||
//
|
||||
this.buttonStore.Location = new System.Drawing.Point(16, 614);
|
||||
this.buttonStore.Name = "buttonStore";
|
||||
this.buttonStore.Size = new System.Drawing.Size(264, 34);
|
||||
this.buttonStore.TabIndex = 4;
|
||||
this.buttonStore.Text = "Посмотреть хранилище";
|
||||
this.buttonStore.UseVisualStyleBackColor = true;
|
||||
this.buttonStore.Click += new System.EventHandler(this.ButtonStore_Click);
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
this.buttonDelete.Location = new System.Drawing.Point(12, 561);
|
||||
this.buttonDelete.Name = "buttonDelete";
|
||||
this.buttonDelete.Size = new System.Drawing.Size(268, 34);
|
||||
this.buttonDelete.TabIndex = 3;
|
||||
this.buttonDelete.Text = "Удалить машину";
|
||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
||||
this.buttonDelete.Click += new System.EventHandler(this.ButtonDelete_Click);
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(5, 444);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(275, 34);
|
||||
this.buttonAdd.TabIndex = 1;
|
||||
this.buttonAdd.Text = "Добавить машину";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// pictureBoxImage
|
||||
//
|
||||
this.pictureBoxImage.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxImage.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxImage.Name = "pictureBoxImage";
|
||||
this.pictureBoxImage.Size = new System.Drawing.Size(964, 910);
|
||||
this.pictureBoxImage.TabIndex = 1;
|
||||
this.pictureBoxImage.TabStop = false;
|
||||
//
|
||||
// FormMapWithSetMachine
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1264, 910);
|
||||
this.Controls.Add(this.pictureBoxImage);
|
||||
this.Controls.Add(this.groupBoxInstruments);
|
||||
this.Name = "FormMapWithSetMachine";
|
||||
this.Text = "Карта с набором объектов";
|
||||
this.groupBoxInstruments.ResumeLayout(false);
|
||||
this.groupBoxInstruments.PerformLayout();
|
||||
this.groupBoxMap.ResumeLayout(false);
|
||||
this.groupBoxMap.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxImage)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxInstruments;
|
||||
private Button buttonMap;
|
||||
private Button buttonStore;
|
||||
private Button buttonDelete;
|
||||
private Button buttonAdd;
|
||||
private PictureBox pictureBoxImage;
|
||||
private MaskedTextBox maskedTextBoxPosition;
|
||||
private Button ButtonDown;
|
||||
private Button ButtonRight;
|
||||
private Button ButtonLeft;
|
||||
private Button ButtonUp;
|
||||
private GroupBox groupBoxMap;
|
||||
private Button buttonDeleteMap;
|
||||
private ListBox listBoxMaps;
|
||||
private Button buttonAddMap;
|
||||
private ComboBox comboBoxSelectorMap;
|
||||
private TextBox textBoxNewMapName;
|
||||
}
|
||||
}
|
||||
235
ArmoredVehicle/FormMapWithSetMachine.cs
Normal file
235
ArmoredVehicle/FormMapWithSetMachine.cs
Normal file
@@ -0,0 +1,235 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ArmoredVehicle
|
||||
{
|
||||
public partial class FormMapWithSetMachine : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Словарь для выпадающего списка
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, AbstractMap> _mapsDict = new()
|
||||
{
|
||||
{ "Простая карта", new SimpleMap() },
|
||||
{ "Вертикальная карта", new VerticalMap() },
|
||||
{ "Горизонтальная карта", new HorizontalMap() }
|
||||
};
|
||||
/// <summary>
|
||||
/// Объект от коллекции карт
|
||||
/// </summary>
|
||||
private readonly MapsCollection _mapsCollection;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormMapWithSetMachine()
|
||||
{
|
||||
InitializeComponent();
|
||||
_mapsCollection = new MapsCollection(pictureBoxImage.Width, pictureBoxImage.Height);
|
||||
comboBoxSelectorMap.Items.Clear();
|
||||
foreach (var elem in _mapsDict)
|
||||
{
|
||||
comboBoxSelectorMap.Items.Add(elem.Key);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Заполнение listBoxMaps
|
||||
/// </summary>
|
||||
private void ReloadMaps()
|
||||
{
|
||||
int index = listBoxMaps.SelectedIndex;
|
||||
|
||||
listBoxMaps.Items.Clear();
|
||||
for (int i = 0; i < _mapsCollection.Keys.Count; i++)
|
||||
{
|
||||
listBoxMaps.Items.Add(_mapsCollection.Keys[i]);
|
||||
}
|
||||
|
||||
if (listBoxMaps.Items.Count > 0 && (index == -1 || index >= listBoxMaps.Items.Count))
|
||||
{
|
||||
listBoxMaps.SelectedIndex = 0;
|
||||
}
|
||||
else if (listBoxMaps.Items.Count > 0 && index > -1 && index < listBoxMaps.Items.Count)
|
||||
{
|
||||
listBoxMaps.SelectedIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление карты
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddMap_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxSelectorMap.SelectedIndex == -1 || string.IsNullOrEmpty(textBoxNewMapName.Text))
|
||||
{
|
||||
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (!_mapsDict.ContainsKey(comboBoxSelectorMap.Text))
|
||||
{
|
||||
MessageBox.Show("Нет такой карты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_mapsCollection.AddMap(textBoxNewMapName.Text, _mapsDict[comboBoxSelectorMap.Text]);
|
||||
ReloadMaps();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Выбор карты
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ListBoxMaps_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxImage.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удаление карты
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonDeleteMap_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (MessageBox.Show($"Удалить карту {listBoxMaps.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_mapsCollection.DelMap(listBoxMaps.SelectedItem?.ToString() ?? string.Empty);
|
||||
ReloadMaps();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление объекта
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MainForm form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.SelectedMachine == null)
|
||||
{
|
||||
MessageBox.Show("Вы не создали объект");
|
||||
return;
|
||||
}
|
||||
DrawningObject machine = new(form.SelectedMachine);
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + machine != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxImage.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Удаление объекта
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonDelete_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 (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBoxImage.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Вывод набора
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonStore_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBoxImage.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Вывод карты
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonMap_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBoxImage.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перемещение
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] == 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;
|
||||
}
|
||||
pictureBoxImage.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
3382
ArmoredVehicle/FormMapWithSetMachine.resx
Normal file
3382
ArmoredVehicle/FormMapWithSetMachine.resx
Normal file
File diff suppressed because it is too large
Load Diff
26
ArmoredVehicle/MainForm.Designer.cs
generated
26
ArmoredVehicle/MainForm.Designer.cs
generated
@@ -40,7 +40,7 @@
|
||||
this.toolStripStatusLabelColor = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.statusStrip = new System.Windows.Forms.StatusStrip();
|
||||
this.TankButton = new System.Windows.Forms.Button();
|
||||
this.Mapbutton = new System.Windows.Forms.Button();
|
||||
this.ChooseButton = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.DrawingPictureBox)).BeginInit();
|
||||
this.statusStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@@ -109,7 +109,7 @@
|
||||
this.DrawingPictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.DrawingPictureBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.DrawingPictureBox.Name = "DrawingPictureBox";
|
||||
this.DrawingPictureBox.Size = new System.Drawing.Size(800, 418);
|
||||
this.DrawingPictureBox.Size = new System.Drawing.Size(800, 450);
|
||||
this.DrawingPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.DrawingPictureBox.TabIndex = 7;
|
||||
this.DrawingPictureBox.TabStop = false;
|
||||
@@ -156,30 +156,30 @@
|
||||
this.TankButton.UseVisualStyleBackColor = true;
|
||||
this.TankButton.Click += new System.EventHandler(this.TankButton_Click);
|
||||
//
|
||||
// Mapbutton
|
||||
// ChooseButton
|
||||
//
|
||||
this.Mapbutton.Location = new System.Drawing.Point(304, 362);
|
||||
this.Mapbutton.Name = "Mapbutton";
|
||||
this.Mapbutton.Size = new System.Drawing.Size(179, 34);
|
||||
this.Mapbutton.TabIndex = 15;
|
||||
this.Mapbutton.Text = "Перейти на карту";
|
||||
this.Mapbutton.UseVisualStyleBackColor = true;
|
||||
this.Mapbutton.Click += new System.EventHandler(this.Mapbutton_Click);
|
||||
this.ChooseButton.Location = new System.Drawing.Point(484, 362);
|
||||
this.ChooseButton.Name = "ChooseButton";
|
||||
this.ChooseButton.Size = new System.Drawing.Size(143, 34);
|
||||
this.ChooseButton.TabIndex = 15;
|
||||
this.ChooseButton.Text = "Выбрать";
|
||||
this.ChooseButton.UseVisualStyleBackColor = true;
|
||||
this.ChooseButton.Click += new System.EventHandler(this.ChooseButton_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.Mapbutton);
|
||||
this.Controls.Add(this.ChooseButton);
|
||||
this.Controls.Add(this.TankButton);
|
||||
this.Controls.Add(this.ButtonDown);
|
||||
this.Controls.Add(this.ButtonRight);
|
||||
this.Controls.Add(this.ButtonLeft);
|
||||
this.Controls.Add(this.ButtonUp);
|
||||
this.Controls.Add(this.CreateButton);
|
||||
this.Controls.Add(this.DrawingPictureBox);
|
||||
this.Controls.Add(this.statusStrip);
|
||||
this.Controls.Add(this.DrawingPictureBox);
|
||||
this.MinimumSize = new System.Drawing.Size(210, 50);
|
||||
this.Name = "MainForm";
|
||||
this.Text = "Военная машина";
|
||||
@@ -204,6 +204,6 @@
|
||||
private ToolStripStatusLabel toolStripStatusLabelColor;
|
||||
private StatusStrip statusStrip;
|
||||
private Button TankButton;
|
||||
private Button Mapbutton;
|
||||
private Button ChooseButton;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@ namespace ArmoredVehicle
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public DrawingArmoredVehicle SelectedMachine { get; private set; }
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
@@ -33,8 +35,15 @@ namespace ArmoredVehicle
|
||||
private void CreateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialog.Color;
|
||||
}
|
||||
|
||||
_ArmoredVehicle = new DrawingArmoredVehicle(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
color);
|
||||
SetData();
|
||||
Draw();
|
||||
}
|
||||
@@ -42,7 +51,7 @@ namespace ArmoredVehicle
|
||||
private void SetData()
|
||||
{
|
||||
Random rnd = new();
|
||||
_ArmoredVehicle.SetPosition( -10, rnd.Next(0, 100), DrawingPictureBox.Width, DrawingPictureBox.Height);
|
||||
_ArmoredVehicle.SetPosition(/*rnd.Next(0, 100)*/ -10, rnd.Next(0, 100), DrawingPictureBox.Width, DrawingPictureBox.Height);
|
||||
toolStripStatusLabelSpeed.Text = $"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {_ArmoredVehicle.ArmoredVehicle.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"<22><><EFBFBD>: {_ArmoredVehicle.ArmoredVehicle.Weight}";
|
||||
toolStripStatusLabelColor.Text = $"<22><><EFBFBD><EFBFBD>: {_ArmoredVehicle.ArmoredVehicle.BodyColor.Name}";
|
||||
@@ -88,10 +97,22 @@ namespace ArmoredVehicle
|
||||
private void TankButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
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;
|
||||
}
|
||||
_ArmoredVehicle = new DrawingTank(rnd.Next(100, 300),
|
||||
rnd.Next(1000, 2000),
|
||||
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)),
|
||||
color,
|
||||
dopColor,
|
||||
Convert.ToBoolean(rnd.Next(0, 2)),
|
||||
Convert.ToBoolean(rnd.Next(0, 2)),
|
||||
Convert.ToBoolean(rnd.Next(0, 2)));
|
||||
@@ -99,10 +120,15 @@ namespace ArmoredVehicle
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void Mapbutton_Click(object sender, EventArgs e)
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ChooseButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormMap map = new FormMap();
|
||||
map.Show();
|
||||
SelectedMachine = _ArmoredVehicle;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
195
ArmoredVehicle/MapWithSetMachineGeneric.cs
Normal file
195
ArmoredVehicle/MapWithSetMachineGeneric.cs
Normal file
@@ -0,0 +1,195 @@
|
||||
namespace ArmoredVehicle
|
||||
{
|
||||
/// <summary>
|
||||
/// Карта с набром объектов под нее
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="U"></typeparam>
|
||||
internal class MapWithSetMachineGeneric<T, U>
|
||||
where T : class, IDrawningObject
|
||||
where U : AbstractMap
|
||||
{
|
||||
/// <summary>
|
||||
/// Ширина окна отрисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureWidth;
|
||||
/// <summary>
|
||||
/// Высота окна отрисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureHeight;
|
||||
/// <summary>
|
||||
/// Размер занимаемого объектом места (ширина)
|
||||
/// </summary>
|
||||
private readonly int _placeSizeWidth = 210;
|
||||
/// <summary>
|
||||
/// Размер занимаемого объектом места (высота)
|
||||
/// </summary>
|
||||
private readonly int _placeSizeHeight = 90;
|
||||
/// <summary>
|
||||
/// Набор объектов
|
||||
/// </summary>
|
||||
private readonly SetMachineGeneric<T> _setMachines;
|
||||
/// <summary>
|
||||
/// Карта
|
||||
/// </summary>
|
||||
private readonly U _map;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="picWidth"></param>
|
||||
/// <param name="picHeight"></param>
|
||||
/// <param name="map"></param>
|
||||
public MapWithSetMachineGeneric(int picWidth, int picHeight, U map)
|
||||
{
|
||||
int width = picWidth / _placeSizeWidth;
|
||||
int height = picHeight / _placeSizeHeight;
|
||||
_setMachines = new SetMachineGeneric<T>(width * height);
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
_map = map;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перегрузка оператора сложения
|
||||
/// </summary>
|
||||
/// <param name="map"></param>
|
||||
/// <param name="machine"></param>
|
||||
/// <returns></returns>
|
||||
public static int operator +(MapWithSetMachineGeneric<T, U> map, T machine)
|
||||
{
|
||||
return map._setMachines.Insert(machine);
|
||||
}
|
||||
/// <summary>
|
||||
/// Перегрузка оператора вычитания
|
||||
/// </summary>
|
||||
/// <param name="map"></param>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public static T operator -(MapWithSetMachineGeneric<T, U> map, int position)
|
||||
{
|
||||
return map._setMachines.Remove(position);
|
||||
}
|
||||
/// <summary>
|
||||
/// Вывод всего набора объектов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Bitmap ShowSet()
|
||||
{
|
||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
DrawBackground(gr);
|
||||
DrawMachine(gr);
|
||||
return bmp;
|
||||
}
|
||||
/// <summary>
|
||||
/// Просмотр объекта на карте
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Bitmap ShowOnMap()
|
||||
{
|
||||
Shaking();
|
||||
foreach (var machine in _setMachines.GetMachine())
|
||||
{
|
||||
return _map.CreateMap(_pictureWidth, _pictureHeight, machine);
|
||||
}
|
||||
return new(_pictureWidth, _pictureHeight);
|
||||
}
|
||||
/// <summary>
|
||||
/// Перемещение объекта по крате
|
||||
/// </summary>
|
||||
/// <param name="direction"></param>
|
||||
/// <returns></returns>
|
||||
public Bitmap MoveObject(Direction direction)
|
||||
{
|
||||
if (_map != null)
|
||||
{
|
||||
return _map.MoveObject(direction);
|
||||
}
|
||||
return new(_pictureWidth, _pictureHeight);
|
||||
}
|
||||
/// <summary>
|
||||
/// "Взбалтываем" набор, чтобы все элементы оказались в начале
|
||||
/// </summary>
|
||||
private void Shaking()
|
||||
{
|
||||
int j = _setMachines.Count - 1;
|
||||
for (int i = 0; i < _setMachines.Count; i++)
|
||||
{
|
||||
if (_setMachines[i] == null)
|
||||
{
|
||||
for (; j > i; j--)
|
||||
{
|
||||
var car = _setMachines[j];
|
||||
if (car != null)
|
||||
{
|
||||
_setMachines.Insert(car, i);
|
||||
_setMachines.Remove(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j <= i)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод отрисовки фона
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
private void DrawBackground(Graphics g)
|
||||
{
|
||||
Pen pen = new(Color.LawnGreen, 5);
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||
{
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
|
||||
{//линия рамзетки места
|
||||
int dop = 0;
|
||||
if(i>0 && j>0)
|
||||
{
|
||||
dop = 30;
|
||||
}
|
||||
g.DrawRectangle(pen, new Rectangle(i * _placeSizeWidth + dop, j * _placeSizeHeight + dop, i * _placeSizeWidth + _placeSizeWidth, j * _placeSizeHeight + _placeSizeHeight));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод прорисовки объектов
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
private void DrawMachine(Graphics g)
|
||||
{
|
||||
int width = _pictureWidth / _placeSizeWidth;
|
||||
int height = _pictureHeight / _placeSizeHeight;
|
||||
|
||||
int currentWidth = 0;
|
||||
int currentHeight = 0;
|
||||
|
||||
foreach (var machine in _setMachines.GetMachine())
|
||||
{
|
||||
int dop = 0;
|
||||
if (currentWidth > 0 && currentHeight > 0)
|
||||
{
|
||||
dop = 30;
|
||||
}
|
||||
|
||||
machine.SetObject(currentWidth * _placeSizeWidth + dop,
|
||||
currentHeight * _placeSizeHeight + dop,
|
||||
_pictureWidth, _pictureHeight);
|
||||
machine?.DrawningObject(g);
|
||||
if (currentWidth < width - 1)
|
||||
{
|
||||
currentWidth++;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentWidth = 0;
|
||||
currentHeight++;
|
||||
}
|
||||
if (currentHeight > height) return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
97
ArmoredVehicle/MapsCollection.cs
Normal file
97
ArmoredVehicle/MapsCollection.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ArmoredVehicle
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс для хранения коллекции карт
|
||||
/// </summary>
|
||||
internal class MapsCollection
|
||||
{
|
||||
/// <summary>
|
||||
/// Словарь (хранилище) с картами
|
||||
/// </summary>
|
||||
readonly Dictionary<string, MapWithSetMachineGeneric<DrawningObject,
|
||||
AbstractMap>> _mapStorages;
|
||||
/// <summary>
|
||||
/// Возвращение списка названий карт
|
||||
/// </summary>
|
||||
public List<string> Keys => _mapStorages.Keys.ToList();
|
||||
/// <summary>
|
||||
/// Ширина окна отрисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureWidth;
|
||||
/// <summary>
|
||||
/// Высота окна отрисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureHeight;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="pictureWidth"></param>
|
||||
/// <param name="pictureHeight"></param>
|
||||
public MapsCollection(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_mapStorages = new Dictionary<string,
|
||||
MapWithSetMachineGeneric<DrawningObject, AbstractMap>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление карты
|
||||
/// </summary>
|
||||
/// <param name="name">Название карты</param>
|
||||
/// <param name="map">Карта</param>
|
||||
public void AddMap(string name, AbstractMap map)
|
||||
{
|
||||
if (Keys.Contains(name))
|
||||
{
|
||||
MessageBox.Show("Такая карта уже есть");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
var NewElem = new MapWithSetMachineGeneric<DrawningObject, AbstractMap>(
|
||||
_pictureWidth, _pictureHeight, map);
|
||||
_mapStorages.Add(name, NewElem);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление карты
|
||||
/// </summary>
|
||||
/// <param name="name">Название карты</param>
|
||||
public void DelMap(string name)
|
||||
{
|
||||
if (Keys.Contains(name))
|
||||
{
|
||||
_mapStorages.Remove(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Такой карты нет");
|
||||
return;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Доступ к парковке
|
||||
/// </summary>
|
||||
/// <param name="ind"></param>
|
||||
/// <returns></returns>
|
||||
public MapWithSetMachineGeneric<DrawningObject, AbstractMap> this[string ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
if(Keys.Contains(ind))
|
||||
{
|
||||
return _mapStorages[ind];
|
||||
}
|
||||
MessageBox.Show("Такой карты нет");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ namespace ArmoredVehicle
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormMap());
|
||||
Application.Run(new FormMapWithSetMachine());
|
||||
}
|
||||
}
|
||||
}
|
||||
123
ArmoredVehicle/SetMachineGeneric.cs
Normal file
123
ArmoredVehicle/SetMachineGeneric.cs
Normal file
@@ -0,0 +1,123 @@
|
||||
namespace ArmoredVehicle
|
||||
{
|
||||
/// <summary>
|
||||
/// Параметризованный набор объектов
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
internal class SetMachineGeneric<T>
|
||||
where T : class
|
||||
{
|
||||
/// <summary>
|
||||
/// Список объектов, которые храним
|
||||
/// </summary>
|
||||
private readonly List<T> _places;
|
||||
private readonly int _maxCount;
|
||||
/// <summary>
|
||||
/// Количество объектов в списке
|
||||
/// </summary>
|
||||
public int Count => _places.Count;
|
||||
private int BusyPlaces = 0;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="count"></param>
|
||||
public SetMachineGeneric(int count)
|
||||
{
|
||||
_maxCount = count;
|
||||
_places = new List<T>();
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор
|
||||
/// </summary>
|
||||
/// <param name="machine">Добавляемая машина</param>
|
||||
/// <returns></returns>
|
||||
public int Insert(T machine)
|
||||
{
|
||||
if (Count + 1 <= _maxCount) return Insert(machine, 0);
|
||||
else return -1;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор на конкретную позицию
|
||||
/// </summary>
|
||||
/// <param name="machine">Добавляемая машина</param>
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <returns></returns>
|
||||
public int Insert(T machine, int position)
|
||||
{
|
||||
if (position >= _maxCount && position < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
_places.Insert(position, machine);
|
||||
|
||||
return position;
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора с конкретной позиции
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public T Remove(int position)
|
||||
{
|
||||
if (position < _maxCount && position >= 0)
|
||||
{
|
||||
if (_places.ElementAt(position) != null)
|
||||
{
|
||||
T result = _places.ElementAt(position);
|
||||
|
||||
_places.RemoveAt(position);
|
||||
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение объекта из набора по позиции
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public T this[int position]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (position < _maxCount && position >= 0)
|
||||
{
|
||||
return _places.ElementAt(position);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (position < _maxCount && position >= 0)
|
||||
{
|
||||
Insert(this[position], position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Проход по набору до первого пустого
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<T> GetMachine()
|
||||
{
|
||||
foreach (var machine in _places)
|
||||
{
|
||||
if (machine != null)
|
||||
{
|
||||
yield return machine;
|
||||
}
|
||||
else
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user