fix and end work
This commit is contained in:
parent
42a7fe8911
commit
da0640612c
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>
|
@ -68,8 +68,13 @@ namespace ArmoredVehicle
|
||||
MainForm form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.SelectedMachine == null)
|
||||
{
|
||||
MessageBox.Show("Вы не создали объект");
|
||||
return;
|
||||
}
|
||||
DrawningObject machine = new(form.SelectedMachine);
|
||||
if (_mapCarsCollectionGeneric + machine)
|
||||
if (_mapCarsCollectionGeneric + machine != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxImage.Image = _mapCarsCollectionGeneric.ShowSet();
|
||||
@ -81,7 +86,10 @@ namespace ArmoredVehicle
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
|
||||
|
||||
///<summary>
|
||||
/// Удаление объекта
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
@ -97,7 +105,7 @@ namespace ArmoredVehicle
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
if (_mapCarsCollectionGeneric - pos)
|
||||
if (_mapCarsCollectionGeneric - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBoxImage.Image = _mapCarsCollectionGeneric.ShowSet();
|
||||
|
@ -35,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();
|
||||
}
|
||||
@ -90,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)));
|
||||
|
@ -48,15 +48,20 @@
|
||||
_pictureHeight = picHeight;
|
||||
_map = map;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Перегрузка оператора сложения
|
||||
/// </summary>
|
||||
/// <param name="map"></param>
|
||||
/// <param name="car"></param>
|
||||
/// <param name="machine"></param>
|
||||
/// <returns></returns>
|
||||
public static bool operator +(MapWithSetMachineGeneric<T, U> map, T car)
|
||||
public static int operator +(MapWithSetMachineGeneric<T, U> map, T machine)
|
||||
{
|
||||
return map._setMachines.Insert(car);
|
||||
return map._setMachines.Insert(machine);
|
||||
}
|
||||
/// <summary>
|
||||
/// Перегрузка оператора вычитания
|
||||
@ -64,7 +69,7 @@
|
||||
/// <param name="map"></param>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public static bool operator -(MapWithSetMachineGeneric<T, U> map, int position)
|
||||
public static T operator -(MapWithSetMachineGeneric<T, U> map, int position)
|
||||
{
|
||||
return map._setMachines.Remove(position);
|
||||
}
|
||||
@ -143,14 +148,18 @@
|
||||
/// <param name="g"></param>
|
||||
private void DrawBackground(Graphics g)
|
||||
{
|
||||
Pen pen = new(Color.Black, 3);
|
||||
Pen pen = new(Color.LawnGreen, 5);
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||
{
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
|
||||
{//линия рамзетки места
|
||||
g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
|
||||
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));
|
||||
}
|
||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, (_pictureHeight / _placeSizeHeight) * _placeSizeHeight);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@ -159,11 +168,36 @@
|
||||
/// <param name="g"></param>
|
||||
private void DrawMachine(Graphics g)
|
||||
{
|
||||
int width = _pictureWidth / _placeSizeWidth;
|
||||
int height = _pictureHeight / _placeSizeHeight;
|
||||
|
||||
int currentWidth = 0;
|
||||
int currentHeight = 0;
|
||||
|
||||
for (int i = 0; i < _setMachines.Count; i++)
|
||||
{
|
||||
// TODO установка позиции
|
||||
int dop = 0;
|
||||
if(currentWidth > 0 && currentHeight > 0)
|
||||
{
|
||||
dop = 30;
|
||||
}
|
||||
_setMachines.Get(i)?.SetObject(currentWidth * _placeSizeWidth + dop,
|
||||
currentHeight * _placeSizeHeight + dop,
|
||||
_pictureWidth, _pictureHeight);
|
||||
_setMachines.Get(i)?.DrawningObject(g);
|
||||
|
||||
if (currentWidth < width - 1)
|
||||
{
|
||||
currentWidth++;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentWidth = 0;
|
||||
currentHeight++;
|
||||
}
|
||||
if (currentHeight > height) return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@
|
||||
/// Количество объектов в массиве
|
||||
/// </summary>
|
||||
public int Count => _places.Length;
|
||||
private int BusyPlaces = 0;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
@ -28,19 +29,9 @@
|
||||
/// </summary>
|
||||
/// <param name="machine">Добавляемая машина</param>
|
||||
/// <returns></returns>
|
||||
public bool Insert(T machine)
|
||||
public int Insert(T machine)
|
||||
{
|
||||
if(_places.Contains(null))
|
||||
{
|
||||
int pos = Array.IndexOf(_places, null);
|
||||
for(int i = pos; i > 0; i--)
|
||||
{
|
||||
_places[i] = _places[i - 1];
|
||||
}
|
||||
_places[0] = machine;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return Insert(machine, 0);
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор на конкретную позицию
|
||||
@ -48,51 +39,36 @@
|
||||
/// <param name="machine">Добавляемая машина</param>
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <returns></returns>
|
||||
public bool Insert(T machine, int position)
|
||||
public int Insert(T machine, int position)
|
||||
{
|
||||
if(_places[position] == null)
|
||||
{
|
||||
_places[position] = machine;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool empty = false;
|
||||
int pos = 0;
|
||||
for(int i = position; i < _places.Length; i++)
|
||||
{
|
||||
if(_places[i] == null)
|
||||
{
|
||||
empty = true;
|
||||
pos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (empty)
|
||||
if (position < 0 || position >= _places.Length || BusyPlaces == _places.Length) return -1;
|
||||
|
||||
BusyPlaces++;
|
||||
while (_places[position] != null)
|
||||
{
|
||||
for (int i = _places.Length - 1; i > 0; --i)
|
||||
{
|
||||
for (int i = pos; i >= position; i--)
|
||||
if (_places[i] == null && _places[i - 1] != null)
|
||||
{
|
||||
_places[i] = _places[i - 1];
|
||||
_places[i - 1] = null;
|
||||
}
|
||||
_places[position] = machine;
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
}
|
||||
_places[position] = machine;
|
||||
return position;
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора с конкретной позиции
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public bool Remove(int position)
|
||||
public T Remove(int position)
|
||||
{
|
||||
if(_places[position] != null)
|
||||
{
|
||||
_places[position] = null;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
if (position < 0 || position >= _places.Length) return null;
|
||||
T deletemashine = _places[position];
|
||||
_places[position] = null;
|
||||
return deletemashine;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение объекта из набора по позиции
|
||||
@ -101,11 +77,8 @@
|
||||
/// <returns></returns>
|
||||
public T Get(int position)
|
||||
{
|
||||
// TODO проверка позиции
|
||||
if(_places[position] == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (position < 0 || position >= _places.Length) return null;
|
||||
else if (_places[position] == null) return null;
|
||||
return _places[position];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user