Compare commits
No commits in common. "LabWork_6" and "main" have entirely different histories.
147
ProjectMonorail/FormMonorail.Designer.cs
generated
147
ProjectMonorail/FormMonorail.Designer.cs
generated
@ -1,147 +0,0 @@
|
|||||||
namespace ProjectMonorail
|
|
||||||
{
|
|
||||||
partial class FormMonorail
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
buttonMove_Right = new Button();
|
|
||||||
buttonMove_Down = new Button();
|
|
||||||
buttonMove_Left = new Button();
|
|
||||||
buttonMove_Up = new Button();
|
|
||||||
pictureBoxMonorail = new PictureBox();
|
|
||||||
comboBoxStrategy = new ComboBox();
|
|
||||||
buttonStrategyStep = new Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxMonorail).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonMove_Right
|
|
||||||
//
|
|
||||||
buttonMove_Right.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonMove_Right.BackgroundImage = Properties.Resources.ArrowRight;
|
|
||||||
buttonMove_Right.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonMove_Right.Location = new Point(766, 427);
|
|
||||||
buttonMove_Right.Name = "buttonMove_Right";
|
|
||||||
buttonMove_Right.Size = new Size(35, 35);
|
|
||||||
buttonMove_Right.TabIndex = 0;
|
|
||||||
buttonMove_Right.UseVisualStyleBackColor = true;
|
|
||||||
buttonMove_Right.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonMove_Down
|
|
||||||
//
|
|
||||||
buttonMove_Down.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonMove_Down.BackgroundImage = Properties.Resources.ArrowDown;
|
|
||||||
buttonMove_Down.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonMove_Down.Location = new Point(725, 427);
|
|
||||||
buttonMove_Down.Name = "buttonMove_Down";
|
|
||||||
buttonMove_Down.Size = new Size(35, 35);
|
|
||||||
buttonMove_Down.TabIndex = 1;
|
|
||||||
buttonMove_Down.UseVisualStyleBackColor = true;
|
|
||||||
buttonMove_Down.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonMove_Left
|
|
||||||
//
|
|
||||||
buttonMove_Left.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonMove_Left.BackgroundImage = Properties.Resources.ArrowLeft;
|
|
||||||
buttonMove_Left.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonMove_Left.Location = new Point(684, 427);
|
|
||||||
buttonMove_Left.Name = "buttonMove_Left";
|
|
||||||
buttonMove_Left.Size = new Size(35, 35);
|
|
||||||
buttonMove_Left.TabIndex = 2;
|
|
||||||
buttonMove_Left.UseVisualStyleBackColor = true;
|
|
||||||
buttonMove_Left.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonMove_Up
|
|
||||||
//
|
|
||||||
buttonMove_Up.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonMove_Up.BackgroundImage = Properties.Resources.ArrowUp;
|
|
||||||
buttonMove_Up.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonMove_Up.Location = new Point(725, 386);
|
|
||||||
buttonMove_Up.Name = "buttonMove_Up";
|
|
||||||
buttonMove_Up.Size = new Size(35, 35);
|
|
||||||
buttonMove_Up.TabIndex = 3;
|
|
||||||
buttonMove_Up.UseVisualStyleBackColor = true;
|
|
||||||
buttonMove_Up.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// pictureBoxMonorail
|
|
||||||
//
|
|
||||||
pictureBoxMonorail.Dock = DockStyle.Fill;
|
|
||||||
pictureBoxMonorail.ImageLocation = "";
|
|
||||||
pictureBoxMonorail.Location = new Point(0, 0);
|
|
||||||
pictureBoxMonorail.Name = "pictureBoxMonorail";
|
|
||||||
pictureBoxMonorail.Size = new Size(813, 474);
|
|
||||||
pictureBoxMonorail.TabIndex = 4;
|
|
||||||
pictureBoxMonorail.TabStop = false;
|
|
||||||
//
|
|
||||||
// comboBoxStrategy
|
|
||||||
//
|
|
||||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxStrategy.FormattingEnabled = true;
|
|
||||||
comboBoxStrategy.Items.AddRange(new object[] { "К центру", "К краю" });
|
|
||||||
comboBoxStrategy.Location = new Point(680, 12);
|
|
||||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
|
||||||
comboBoxStrategy.Size = new Size(121, 23);
|
|
||||||
comboBoxStrategy.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// buttonStrategyStep
|
|
||||||
//
|
|
||||||
buttonStrategyStep.Location = new Point(704, 41);
|
|
||||||
buttonStrategyStep.Name = "buttonStrategyStep";
|
|
||||||
buttonStrategyStep.Size = new Size(75, 23);
|
|
||||||
buttonStrategyStep.TabIndex = 8;
|
|
||||||
buttonStrategyStep.Text = "Шаг";
|
|
||||||
buttonStrategyStep.UseVisualStyleBackColor = true;
|
|
||||||
buttonStrategyStep.Click += buttonStrategyStep_Click;
|
|
||||||
//
|
|
||||||
// FormMonorail
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(813, 474);
|
|
||||||
Controls.Add(buttonStrategyStep);
|
|
||||||
Controls.Add(comboBoxStrategy);
|
|
||||||
Controls.Add(buttonMove_Up);
|
|
||||||
Controls.Add(buttonMove_Left);
|
|
||||||
Controls.Add(buttonMove_Down);
|
|
||||||
Controls.Add(buttonMove_Right);
|
|
||||||
Controls.Add(pictureBoxMonorail);
|
|
||||||
Name = "FormMonorail";
|
|
||||||
Text = "Монорельс";
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxMonorail).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonMove_Right;
|
|
||||||
private Button buttonMove_Down;
|
|
||||||
private Button buttonMove_Left;
|
|
||||||
private Button buttonMove_Up;
|
|
||||||
private PictureBox pictureBoxMonorail;
|
|
||||||
private ComboBox comboBoxStrategy;
|
|
||||||
private Button buttonStrategyStep;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,125 +0,0 @@
|
|||||||
using ProjectMonorail.Scripts.Monorail.Drawnings;
|
|
||||||
using ProjectMonorail.Scripts.Monorail.MovementStrategy;
|
|
||||||
|
|
||||||
namespace ProjectMonorail
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Форма работы с объектом "Монорельс"
|
|
||||||
/// </summary>
|
|
||||||
public partial class FormMonorail : Form
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Поле-объект для прорисовки объекта
|
|
||||||
/// </summary>
|
|
||||||
private DrawingMonorail? _drawningMonorail;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Стратегия перемещения
|
|
||||||
/// </summary>
|
|
||||||
private AbstractStrategy? _strategy;
|
|
||||||
|
|
||||||
public DrawingMonorail SetMonorail
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_drawningMonorail = value;
|
|
||||||
_drawningMonorail.SetPictureSize(pictureBoxMonorail.Width, pictureBoxMonorail.Height);
|
|
||||||
Random random = new Random();
|
|
||||||
_drawningMonorail.SetPosition(random.Next(0, 100), random.Next(0, 100));
|
|
||||||
comboBoxStrategy.Enabled = true;
|
|
||||||
_strategy = null;
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор формы
|
|
||||||
/// </summary>
|
|
||||||
public FormMonorail()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_strategy = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Метод для прорисовки автомобиля
|
|
||||||
/// </summary>
|
|
||||||
private void Draw()
|
|
||||||
{
|
|
||||||
if (_drawningMonorail == null) return;
|
|
||||||
|
|
||||||
Bitmap bmp = new(pictureBoxMonorail.Width, pictureBoxMonorail.Height);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
_drawningMonorail.DrawTransport(gr);
|
|
||||||
pictureBoxMonorail.Image = bmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Обработка кнопок перемешения
|
|
||||||
/// </summary>
|
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_drawningMonorail == null) return;
|
|
||||||
|
|
||||||
string name = ((Button)sender).Name ?? string.Empty;
|
|
||||||
bool result = false;
|
|
||||||
switch (name)
|
|
||||||
{
|
|
||||||
case "buttonMove_Up":
|
|
||||||
result = _drawningMonorail.MoveTransport(DirectionType.Up);
|
|
||||||
break;
|
|
||||||
case "buttonMove_Down":
|
|
||||||
result = _drawningMonorail.MoveTransport(DirectionType.Down);
|
|
||||||
break;
|
|
||||||
case "buttonMove_Right":
|
|
||||||
result = _drawningMonorail.MoveTransport(DirectionType.Right);
|
|
||||||
break;
|
|
||||||
case "buttonMove_Left":
|
|
||||||
result = _drawningMonorail.MoveTransport(DirectionType.Left);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result) Draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void buttonStrategyStep_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_drawningMonorail == null) return;
|
|
||||||
|
|
||||||
if (comboBoxStrategy.Enabled)
|
|
||||||
{
|
|
||||||
_strategy = comboBoxStrategy.SelectedIndex switch
|
|
||||||
{
|
|
||||||
0 => new MoveToCenter(),
|
|
||||||
1 => new MoveToRightDownBorder(),
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
if (_strategy == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_strategy.SetData(new MoveableMonorail(_drawningMonorail), pictureBoxMonorail.Width, pictureBoxMonorail.Height);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_strategy == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
comboBoxStrategy.Enabled = false;
|
|
||||||
_strategy.MakeStep();
|
|
||||||
Draw();
|
|
||||||
|
|
||||||
if (_strategy.GetStatus() == StrategyStatus.Finish)
|
|
||||||
{
|
|
||||||
comboBoxStrategy.Enabled = true;
|
|
||||||
_strategy = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
355
ProjectMonorail/FormMonorailCollection.Designer.cs
generated
355
ProjectMonorail/FormMonorailCollection.Designer.cs
generated
@ -1,355 +0,0 @@
|
|||||||
namespace ProjectMonorail
|
|
||||||
{
|
|
||||||
partial class FormMonorailCollection
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
groupBoxTools = new GroupBox();
|
|
||||||
panelCompanyTools = new Panel();
|
|
||||||
buttonAddMonorail = new Button();
|
|
||||||
maskedTextBox = new MaskedTextBox();
|
|
||||||
buttonRefresh = new Button();
|
|
||||||
buttonRemoveMonorail = new Button();
|
|
||||||
buttonGoToCheck = new Button();
|
|
||||||
buttonCreateCompany = new Button();
|
|
||||||
panelStorage = new Panel();
|
|
||||||
buttonCollectionDelete = new Button();
|
|
||||||
listBoxCollection = new ListBox();
|
|
||||||
buttonCollectionAdd = new Button();
|
|
||||||
radioButtonList = new RadioButton();
|
|
||||||
radioButtonMassive = new RadioButton();
|
|
||||||
textBoxCollectionName = new TextBox();
|
|
||||||
labelCollectionName = new Label();
|
|
||||||
comboBoxSelectorCompany = new ComboBox();
|
|
||||||
pictureBox = new PictureBox();
|
|
||||||
menuStrip = new MenuStrip();
|
|
||||||
файлToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
saveToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
loadToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
saveFileDialog = new SaveFileDialog();
|
|
||||||
openFileDialog = new OpenFileDialog();
|
|
||||||
groupBoxTools.SuspendLayout();
|
|
||||||
panelCompanyTools.SuspendLayout();
|
|
||||||
panelStorage.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
|
||||||
menuStrip.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// groupBoxTools
|
|
||||||
//
|
|
||||||
groupBoxTools.Controls.Add(panelCompanyTools);
|
|
||||||
groupBoxTools.Controls.Add(buttonCreateCompany);
|
|
||||||
groupBoxTools.Controls.Add(panelStorage);
|
|
||||||
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
|
||||||
groupBoxTools.Dock = DockStyle.Right;
|
|
||||||
groupBoxTools.Location = new Point(970, 24);
|
|
||||||
groupBoxTools.Name = "groupBoxTools";
|
|
||||||
groupBoxTools.Size = new Size(241, 638);
|
|
||||||
groupBoxTools.TabIndex = 0;
|
|
||||||
groupBoxTools.TabStop = false;
|
|
||||||
groupBoxTools.Text = "Инструменты";
|
|
||||||
//
|
|
||||||
// panelCompanyTools
|
|
||||||
//
|
|
||||||
panelCompanyTools.Controls.Add(buttonAddMonorail);
|
|
||||||
panelCompanyTools.Controls.Add(maskedTextBox);
|
|
||||||
panelCompanyTools.Controls.Add(buttonRefresh);
|
|
||||||
panelCompanyTools.Controls.Add(buttonRemoveMonorail);
|
|
||||||
panelCompanyTools.Controls.Add(buttonGoToCheck);
|
|
||||||
panelCompanyTools.Dock = DockStyle.Bottom;
|
|
||||||
panelCompanyTools.Enabled = false;
|
|
||||||
panelCompanyTools.Location = new Point(3, 313);
|
|
||||||
panelCompanyTools.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
panelCompanyTools.Name = "panelCompanyTools";
|
|
||||||
panelCompanyTools.Size = new Size(235, 322);
|
|
||||||
panelCompanyTools.TabIndex = 8;
|
|
||||||
//
|
|
||||||
// buttonAddMonorail
|
|
||||||
//
|
|
||||||
buttonAddMonorail.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
buttonAddMonorail.Location = new Point(8, 32);
|
|
||||||
buttonAddMonorail.Name = "buttonAddMonorail";
|
|
||||||
buttonAddMonorail.Size = new Size(221, 48);
|
|
||||||
buttonAddMonorail.TabIndex = 1;
|
|
||||||
buttonAddMonorail.Text = "Добавление монорельса";
|
|
||||||
buttonAddMonorail.UseVisualStyleBackColor = true;
|
|
||||||
buttonAddMonorail.Click += ButtonAddMonorail_Click;
|
|
||||||
//
|
|
||||||
// maskedTextBox
|
|
||||||
//
|
|
||||||
maskedTextBox.Location = new Point(5, 130);
|
|
||||||
maskedTextBox.Mask = "00";
|
|
||||||
maskedTextBox.Name = "maskedTextBox";
|
|
||||||
maskedTextBox.Size = new Size(223, 23);
|
|
||||||
maskedTextBox.TabIndex = 3;
|
|
||||||
maskedTextBox.ValidatingType = typeof(int);
|
|
||||||
//
|
|
||||||
// buttonRefresh
|
|
||||||
//
|
|
||||||
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
buttonRefresh.Location = new Point(8, 267);
|
|
||||||
buttonRefresh.Name = "buttonRefresh";
|
|
||||||
buttonRefresh.Size = new Size(219, 48);
|
|
||||||
buttonRefresh.TabIndex = 6;
|
|
||||||
buttonRefresh.Text = "Обновить";
|
|
||||||
buttonRefresh.UseVisualStyleBackColor = true;
|
|
||||||
buttonRefresh.Click += ButtonRefresh_Click;
|
|
||||||
//
|
|
||||||
// buttonRemoveMonorail
|
|
||||||
//
|
|
||||||
buttonRemoveMonorail.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
buttonRemoveMonorail.Location = new Point(8, 159);
|
|
||||||
buttonRemoveMonorail.Name = "buttonRemoveMonorail";
|
|
||||||
buttonRemoveMonorail.Size = new Size(221, 48);
|
|
||||||
buttonRemoveMonorail.TabIndex = 4;
|
|
||||||
buttonRemoveMonorail.Text = "Удалить монорельс";
|
|
||||||
buttonRemoveMonorail.UseVisualStyleBackColor = true;
|
|
||||||
buttonRemoveMonorail.Click += buttonRemoveMonorail_Click;
|
|
||||||
//
|
|
||||||
// buttonGoToCheck
|
|
||||||
//
|
|
||||||
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
buttonGoToCheck.Location = new Point(8, 213);
|
|
||||||
buttonGoToCheck.Name = "buttonGoToCheck";
|
|
||||||
buttonGoToCheck.Size = new Size(220, 48);
|
|
||||||
buttonGoToCheck.TabIndex = 5;
|
|
||||||
buttonGoToCheck.Text = "Передать на тесты";
|
|
||||||
buttonGoToCheck.UseVisualStyleBackColor = true;
|
|
||||||
buttonGoToCheck.Click += ButtonGoToCheck_Click;
|
|
||||||
//
|
|
||||||
// buttonCreateCompany
|
|
||||||
//
|
|
||||||
buttonCreateCompany.Location = new Point(6, 291);
|
|
||||||
buttonCreateCompany.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
buttonCreateCompany.Name = "buttonCreateCompany";
|
|
||||||
buttonCreateCompany.Size = new Size(222, 22);
|
|
||||||
buttonCreateCompany.TabIndex = 7;
|
|
||||||
buttonCreateCompany.Text = "Создать компанию";
|
|
||||||
buttonCreateCompany.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreateCompany.Click += ButtonCreateCompany_Click;
|
|
||||||
//
|
|
||||||
// panelStorage
|
|
||||||
//
|
|
||||||
panelStorage.Controls.Add(buttonCollectionDelete);
|
|
||||||
panelStorage.Controls.Add(listBoxCollection);
|
|
||||||
panelStorage.Controls.Add(buttonCollectionAdd);
|
|
||||||
panelStorage.Controls.Add(radioButtonList);
|
|
||||||
panelStorage.Controls.Add(radioButtonMassive);
|
|
||||||
panelStorage.Controls.Add(textBoxCollectionName);
|
|
||||||
panelStorage.Controls.Add(labelCollectionName);
|
|
||||||
panelStorage.Dock = DockStyle.Top;
|
|
||||||
panelStorage.Location = new Point(3, 19);
|
|
||||||
panelStorage.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
panelStorage.Name = "panelStorage";
|
|
||||||
panelStorage.Size = new Size(235, 242);
|
|
||||||
panelStorage.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// buttonCollectionDelete
|
|
||||||
//
|
|
||||||
buttonCollectionDelete.Location = new Point(5, 206);
|
|
||||||
buttonCollectionDelete.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
buttonCollectionDelete.Name = "buttonCollectionDelete";
|
|
||||||
buttonCollectionDelete.Size = new Size(222, 22);
|
|
||||||
buttonCollectionDelete.TabIndex = 6;
|
|
||||||
buttonCollectionDelete.Text = "Удалить коллекцию";
|
|
||||||
buttonCollectionDelete.UseVisualStyleBackColor = true;
|
|
||||||
buttonCollectionDelete.Click += ButtonCollectionDelete_Click;
|
|
||||||
//
|
|
||||||
// listBoxCollection
|
|
||||||
//
|
|
||||||
listBoxCollection.FormattingEnabled = true;
|
|
||||||
listBoxCollection.ItemHeight = 15;
|
|
||||||
listBoxCollection.Location = new Point(5, 123);
|
|
||||||
listBoxCollection.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
listBoxCollection.Name = "listBoxCollection";
|
|
||||||
listBoxCollection.Size = new Size(223, 79);
|
|
||||||
listBoxCollection.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// buttonCollectionAdd
|
|
||||||
//
|
|
||||||
buttonCollectionAdd.Location = new Point(5, 97);
|
|
||||||
buttonCollectionAdd.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
buttonCollectionAdd.Name = "buttonCollectionAdd";
|
|
||||||
buttonCollectionAdd.Size = new Size(222, 22);
|
|
||||||
buttonCollectionAdd.TabIndex = 4;
|
|
||||||
buttonCollectionAdd.Text = "Добавить коллекцию";
|
|
||||||
buttonCollectionAdd.UseVisualStyleBackColor = true;
|
|
||||||
buttonCollectionAdd.Click += ButtonCollectionAdd_Click;
|
|
||||||
//
|
|
||||||
// radioButtonList
|
|
||||||
//
|
|
||||||
radioButtonList.AutoSize = true;
|
|
||||||
radioButtonList.Location = new Point(113, 67);
|
|
||||||
radioButtonList.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
radioButtonList.Name = "radioButtonList";
|
|
||||||
radioButtonList.Size = new Size(66, 19);
|
|
||||||
radioButtonList.TabIndex = 3;
|
|
||||||
radioButtonList.TabStop = true;
|
|
||||||
radioButtonList.Text = "Список";
|
|
||||||
radioButtonList.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// radioButtonMassive
|
|
||||||
//
|
|
||||||
radioButtonMassive.AutoSize = true;
|
|
||||||
radioButtonMassive.Location = new Point(20, 67);
|
|
||||||
radioButtonMassive.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
radioButtonMassive.Name = "radioButtonMassive";
|
|
||||||
radioButtonMassive.Size = new Size(67, 19);
|
|
||||||
radioButtonMassive.TabIndex = 2;
|
|
||||||
radioButtonMassive.TabStop = true;
|
|
||||||
radioButtonMassive.Text = "Массив";
|
|
||||||
radioButtonMassive.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// textBoxCollectionName
|
|
||||||
//
|
|
||||||
textBoxCollectionName.Location = new Point(5, 28);
|
|
||||||
textBoxCollectionName.Margin = new Padding(3, 2, 3, 2);
|
|
||||||
textBoxCollectionName.Name = "textBoxCollectionName";
|
|
||||||
textBoxCollectionName.Size = new Size(223, 23);
|
|
||||||
textBoxCollectionName.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// labelCollectionName
|
|
||||||
//
|
|
||||||
labelCollectionName.AutoSize = true;
|
|
||||||
labelCollectionName.Location = new Point(47, 10);
|
|
||||||
labelCollectionName.Name = "labelCollectionName";
|
|
||||||
labelCollectionName.Size = new Size(125, 15);
|
|
||||||
labelCollectionName.TabIndex = 0;
|
|
||||||
labelCollectionName.Text = "Название коллекции:";
|
|
||||||
//
|
|
||||||
// comboBoxSelectorCompany
|
|
||||||
//
|
|
||||||
comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxSelectorCompany.FormattingEnabled = true;
|
|
||||||
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
|
|
||||||
comboBoxSelectorCompany.Location = new Point(3, 265);
|
|
||||||
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
|
||||||
comboBoxSelectorCompany.Size = new Size(229, 23);
|
|
||||||
comboBoxSelectorCompany.TabIndex = 0;
|
|
||||||
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
|
|
||||||
//
|
|
||||||
// pictureBox
|
|
||||||
//
|
|
||||||
pictureBox.Dock = DockStyle.Fill;
|
|
||||||
pictureBox.Location = new Point(0, 24);
|
|
||||||
pictureBox.Name = "pictureBox";
|
|
||||||
pictureBox.Size = new Size(970, 638);
|
|
||||||
pictureBox.TabIndex = 1;
|
|
||||||
pictureBox.TabStop = false;
|
|
||||||
//
|
|
||||||
// menuStrip
|
|
||||||
//
|
|
||||||
menuStrip.Items.AddRange(new ToolStripItem[] { файлToolStripMenuItem });
|
|
||||||
menuStrip.Location = new Point(0, 0);
|
|
||||||
menuStrip.Name = "menuStrip";
|
|
||||||
menuStrip.Size = new Size(1211, 24);
|
|
||||||
menuStrip.TabIndex = 2;
|
|
||||||
menuStrip.Text = "menuStrip1";
|
|
||||||
//
|
|
||||||
// файлToolStripMenuItem
|
|
||||||
//
|
|
||||||
файлToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { saveToolStripMenuItem, loadToolStripMenuItem });
|
|
||||||
файлToolStripMenuItem.Name = "файлToolStripMenuItem";
|
|
||||||
файлToolStripMenuItem.Size = new Size(48, 20);
|
|
||||||
файлToolStripMenuItem.Text = "Файл";
|
|
||||||
//
|
|
||||||
// saveToolStripMenuItem
|
|
||||||
//
|
|
||||||
saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
|
||||||
saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
|
|
||||||
saveToolStripMenuItem.Size = new Size(184, 22);
|
|
||||||
saveToolStripMenuItem.Text = "Сохранение ";
|
|
||||||
saveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// loadToolStripMenuItem
|
|
||||||
//
|
|
||||||
loadToolStripMenuItem.Name = "loadToolStripMenuItem";
|
|
||||||
loadToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.L;
|
|
||||||
loadToolStripMenuItem.Size = new Size(184, 22);
|
|
||||||
loadToolStripMenuItem.Text = "Загрузка";
|
|
||||||
loadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// saveFileDialog
|
|
||||||
//
|
|
||||||
saveFileDialog.Filter = "txt file | *.txt";
|
|
||||||
//
|
|
||||||
// openFileDialog
|
|
||||||
//
|
|
||||||
openFileDialog.Filter = "txt file | *.txt";
|
|
||||||
//
|
|
||||||
// FormMonorailCollection
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(1211, 662);
|
|
||||||
Controls.Add(pictureBox);
|
|
||||||
Controls.Add(groupBoxTools);
|
|
||||||
Controls.Add(menuStrip);
|
|
||||||
MainMenuStrip = menuStrip;
|
|
||||||
Name = "FormMonorailCollection";
|
|
||||||
Text = "Коллекция монорельсов";
|
|
||||||
groupBoxTools.ResumeLayout(false);
|
|
||||||
panelCompanyTools.ResumeLayout(false);
|
|
||||||
panelCompanyTools.PerformLayout();
|
|
||||||
panelStorage.ResumeLayout(false);
|
|
||||||
panelStorage.PerformLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
|
||||||
menuStrip.ResumeLayout(false);
|
|
||||||
menuStrip.PerformLayout();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private GroupBox groupBoxTools;
|
|
||||||
private ComboBox comboBoxSelectorCompany;
|
|
||||||
private Button buttonRemoveMonorail;
|
|
||||||
private MaskedTextBox maskedTextBox;
|
|
||||||
private Button buttonAddMonorail;
|
|
||||||
private PictureBox pictureBox;
|
|
||||||
private Button buttonGoToCheck;
|
|
||||||
private Button buttonRefresh;
|
|
||||||
private Panel panelStorage;
|
|
||||||
private Label labelCollectionName;
|
|
||||||
private TextBox textBoxCollectionName;
|
|
||||||
private Button buttonCollectionAdd;
|
|
||||||
private RadioButton radioButtonList;
|
|
||||||
private RadioButton radioButtonMassive;
|
|
||||||
private Button buttonCollectionDelete;
|
|
||||||
private ListBox listBoxCollection;
|
|
||||||
private Button buttonCreateCompany;
|
|
||||||
private Panel panelCompanyTools;
|
|
||||||
private MenuStrip menuStrip;
|
|
||||||
private ToolStripMenuItem файлToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem saveToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem loadToolStripMenuItem;
|
|
||||||
private SaveFileDialog saveFileDialog;
|
|
||||||
private OpenFileDialog openFileDialog;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,247 +0,0 @@
|
|||||||
using ProjectMonorail.Scripts.Monorail.CollectionGenericObjects;
|
|
||||||
using ProjectMonorail.Scripts.Monorail.Drawnings;
|
|
||||||
|
|
||||||
namespace ProjectMonorail
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
public partial class FormMonorailCollection : Form
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Хранилище коллекций
|
|
||||||
/// </summary>
|
|
||||||
private readonly StorageCollection<DrawingMonorail> _storageCollection;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Компания
|
|
||||||
/// </summary>
|
|
||||||
private AbstractCompany? _company = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
public FormMonorailCollection()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_storageCollection = new StorageCollection<DrawingMonorail>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
switch (comboBoxSelectorCompany.Text)
|
|
||||||
{
|
|
||||||
case "Хранилище":
|
|
||||||
_company = new DepotSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawingMonorail>());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAddMonorail_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
FormMonorailConfig form = new FormMonorailConfig();
|
|
||||||
form.Show();
|
|
||||||
form.AddEventListener_Monorail(SetMonorail);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetMonorail(DrawingMonorail monorail)
|
|
||||||
{
|
|
||||||
if (monorail == null || _company == null) return;
|
|
||||||
|
|
||||||
if (_company + monorail != -1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект добавлен");
|
|
||||||
pictureBox.Image = _company.Show();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonRemoveMonorail_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null) return;
|
|
||||||
|
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return;
|
|
||||||
|
|
||||||
int position = Convert.ToInt32(maskedTextBox.Text);
|
|
||||||
|
|
||||||
if (_company - position != null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект удален");
|
|
||||||
pictureBox.Image = _company.Show();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось удалить объект");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonGoToCheck_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_company == null) return;
|
|
||||||
|
|
||||||
DrawingMonorail? monorail = null;
|
|
||||||
int coutner = 100;
|
|
||||||
|
|
||||||
while (monorail == null && coutner-- > 0)
|
|
||||||
{
|
|
||||||
monorail = _company.GetRandomObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (monorail == null) return;
|
|
||||||
|
|
||||||
FormMonorail form = new FormMonorail()
|
|
||||||
{
|
|
||||||
SetMonorail = monorail
|
|
||||||
};
|
|
||||||
form.ShowDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonRefresh_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_company == null) return;
|
|
||||||
pictureBox.Image = _company.Show();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Обновление списка в listBoxCollection
|
|
||||||
/// </summary>
|
|
||||||
private void RerfreshListBoxItems()
|
|
||||||
{
|
|
||||||
listBoxCollection.Items.Clear();
|
|
||||||
for (int i = 0; i < _storageCollection.Keys?.Count; ++i)
|
|
||||||
{
|
|
||||||
string? colName = _storageCollection.Keys?[i];
|
|
||||||
if (!string.IsNullOrEmpty(colName))
|
|
||||||
{
|
|
||||||
listBoxCollection.Items.Add(colName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление коллекции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonCollectionAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonList.Checked && !radioButtonMassive.Checked))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CollectionType collectionType = CollectionType.None;
|
|
||||||
if (radioButtonMassive.Checked)
|
|
||||||
{
|
|
||||||
collectionType = CollectionType.Massive;
|
|
||||||
}
|
|
||||||
else if (radioButtonList.Checked)
|
|
||||||
{
|
|
||||||
collectionType = CollectionType.List;
|
|
||||||
}
|
|
||||||
_storageCollection.AddCollection(textBoxCollectionName.Text,
|
|
||||||
collectionType);
|
|
||||||
RerfreshListBoxItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление коллекции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonCollectionDelete_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
// TODO прописать логику удаления элемента из коллекции
|
|
||||||
// нужно убедиться, что есть выбранная коллекция
|
|
||||||
// спросить у пользователя через MessageBox, что он подтверждает, что хочет удалить запись
|
|
||||||
// удалить и обновить ListBox
|
|
||||||
if (listBoxCollection.SelectedItem == null || listBoxCollection.SelectedIndex < 0)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Коллекция для удаления не выбрана");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (MessageBox.Show("Удалить коллекцию?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return;
|
|
||||||
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
|
|
||||||
RerfreshListBoxItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Создание компании
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonCreateCompany_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Коллекция не выбрана");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ICollectionGenericObjects<DrawingMonorail>? collection =
|
|
||||||
_storageCollection[listBoxCollection.SelectedItem.ToString() ?? string.Empty];
|
|
||||||
if (collection == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Коллекция не проинициализирована");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (comboBoxSelectorCompany.Text)
|
|
||||||
{
|
|
||||||
case "Хранилище":
|
|
||||||
_company = new DepotSharingService(pictureBox.Width,
|
|
||||||
pictureBox.Height, collection);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
panelCompanyTools.Enabled = true;
|
|
||||||
RerfreshListBoxItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Обработка нажатия "Сохранения"
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
if (_storageCollection.SaveData(saveFileDialog.FileName))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не сохранилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Обработка нажатия "Загрузки"
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
if (_storageCollection.LoadData(openFileDialog.FileName))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
RerfreshListBoxItems();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не загрузилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,129 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 17</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>126, 17</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>261, 17</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
|
404
ProjectMonorail/FormMonorailConfig.Designer.cs
generated
404
ProjectMonorail/FormMonorailConfig.Designer.cs
generated
@ -1,404 +0,0 @@
|
|||||||
namespace ProjectMonorail
|
|
||||||
{
|
|
||||||
partial class FormMonorailConfig
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
groupBoxConfig = new GroupBox();
|
|
||||||
groupBoxColors = new GroupBox();
|
|
||||||
panelColor_Purple = new Panel();
|
|
||||||
panelColor_Black = new Panel();
|
|
||||||
panelColor_Yellow = new Panel();
|
|
||||||
panelColor_Grey = new Panel();
|
|
||||||
panelColor_Blue = new Panel();
|
|
||||||
panelColor_White = new Panel();
|
|
||||||
panelColor_Green = new Panel();
|
|
||||||
panelColor_Red = new Panel();
|
|
||||||
checkBoxCabin = new CheckBox();
|
|
||||||
checkBoxMonorailTrack = new CheckBox();
|
|
||||||
numericUpDownWeight = new NumericUpDown();
|
|
||||||
labelWeight = new Label();
|
|
||||||
numericUpDownSpeed = new NumericUpDown();
|
|
||||||
labelSpeed = new Label();
|
|
||||||
labelModifiedObject = new Label();
|
|
||||||
labelSimpleObject = new Label();
|
|
||||||
pictureBoxObject = new PictureBox();
|
|
||||||
buttonAdd = new Button();
|
|
||||||
buttonCancel = new Button();
|
|
||||||
panelObject = new Panel();
|
|
||||||
labelBodyColor = new Label();
|
|
||||||
labelAdditionalColor = new Label();
|
|
||||||
panelBaseColor = new Panel();
|
|
||||||
panelAdditionalColor = new Panel();
|
|
||||||
groupBoxConfig.SuspendLayout();
|
|
||||||
groupBoxColors.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
|
||||||
panelObject.SuspendLayout();
|
|
||||||
panelBaseColor.SuspendLayout();
|
|
||||||
panelAdditionalColor.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// groupBoxConfig
|
|
||||||
//
|
|
||||||
groupBoxConfig.Controls.Add(groupBoxColors);
|
|
||||||
groupBoxConfig.Controls.Add(checkBoxCabin);
|
|
||||||
groupBoxConfig.Controls.Add(checkBoxMonorailTrack);
|
|
||||||
groupBoxConfig.Controls.Add(numericUpDownWeight);
|
|
||||||
groupBoxConfig.Controls.Add(labelWeight);
|
|
||||||
groupBoxConfig.Controls.Add(numericUpDownSpeed);
|
|
||||||
groupBoxConfig.Controls.Add(labelSpeed);
|
|
||||||
groupBoxConfig.Controls.Add(labelModifiedObject);
|
|
||||||
groupBoxConfig.Controls.Add(labelSimpleObject);
|
|
||||||
groupBoxConfig.Dock = DockStyle.Left;
|
|
||||||
groupBoxConfig.Location = new Point(0, 0);
|
|
||||||
groupBoxConfig.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
groupBoxConfig.Name = "groupBoxConfig";
|
|
||||||
groupBoxConfig.Padding = new Padding(3, 4, 3, 4);
|
|
||||||
groupBoxConfig.Size = new Size(582, 236);
|
|
||||||
groupBoxConfig.TabIndex = 0;
|
|
||||||
groupBoxConfig.TabStop = false;
|
|
||||||
groupBoxConfig.Text = "Параметры";
|
|
||||||
//
|
|
||||||
// groupBoxColors
|
|
||||||
//
|
|
||||||
groupBoxColors.Controls.Add(panelColor_Purple);
|
|
||||||
groupBoxColors.Controls.Add(panelColor_Black);
|
|
||||||
groupBoxColors.Controls.Add(panelColor_Yellow);
|
|
||||||
groupBoxColors.Controls.Add(panelColor_Grey);
|
|
||||||
groupBoxColors.Controls.Add(panelColor_Blue);
|
|
||||||
groupBoxColors.Controls.Add(panelColor_White);
|
|
||||||
groupBoxColors.Controls.Add(panelColor_Green);
|
|
||||||
groupBoxColors.Controls.Add(panelColor_Red);
|
|
||||||
groupBoxColors.Location = new Point(315, 29);
|
|
||||||
groupBoxColors.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
groupBoxColors.Name = "groupBoxColors";
|
|
||||||
groupBoxColors.Padding = new Padding(3, 4, 3, 4);
|
|
||||||
groupBoxColors.Size = new Size(235, 140);
|
|
||||||
groupBoxColors.TabIndex = 8;
|
|
||||||
groupBoxColors.TabStop = false;
|
|
||||||
groupBoxColors.Text = "Цвета";
|
|
||||||
//
|
|
||||||
// panelColor_Purple
|
|
||||||
//
|
|
||||||
panelColor_Purple.BackColor = Color.Purple;
|
|
||||||
panelColor_Purple.Location = new Point(198, 83);
|
|
||||||
panelColor_Purple.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
panelColor_Purple.Name = "panelColor_Purple";
|
|
||||||
panelColor_Purple.Size = new Size(31, 39);
|
|
||||||
panelColor_Purple.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// panelColor_Black
|
|
||||||
//
|
|
||||||
panelColor_Black.BackColor = Color.Black;
|
|
||||||
panelColor_Black.Location = new Point(138, 83);
|
|
||||||
panelColor_Black.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
panelColor_Black.Name = "panelColor_Black";
|
|
||||||
panelColor_Black.Size = new Size(31, 39);
|
|
||||||
panelColor_Black.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// panelColor_Yellow
|
|
||||||
//
|
|
||||||
panelColor_Yellow.BackColor = Color.Yellow;
|
|
||||||
panelColor_Yellow.Location = new Point(198, 29);
|
|
||||||
panelColor_Yellow.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
panelColor_Yellow.Name = "panelColor_Yellow";
|
|
||||||
panelColor_Yellow.Size = new Size(31, 39);
|
|
||||||
panelColor_Yellow.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// panelColor_Grey
|
|
||||||
//
|
|
||||||
panelColor_Grey.BackColor = Color.Gray;
|
|
||||||
panelColor_Grey.Location = new Point(71, 83);
|
|
||||||
panelColor_Grey.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
panelColor_Grey.Name = "panelColor_Grey";
|
|
||||||
panelColor_Grey.Size = new Size(31, 39);
|
|
||||||
panelColor_Grey.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// panelColor_Blue
|
|
||||||
//
|
|
||||||
panelColor_Blue.BackColor = Color.Blue;
|
|
||||||
panelColor_Blue.Location = new Point(138, 29);
|
|
||||||
panelColor_Blue.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
panelColor_Blue.Name = "panelColor_Blue";
|
|
||||||
panelColor_Blue.Size = new Size(31, 39);
|
|
||||||
panelColor_Blue.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// panelColor_White
|
|
||||||
//
|
|
||||||
panelColor_White.BackColor = Color.White;
|
|
||||||
panelColor_White.Location = new Point(7, 83);
|
|
||||||
panelColor_White.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
panelColor_White.Name = "panelColor_White";
|
|
||||||
panelColor_White.Size = new Size(31, 39);
|
|
||||||
panelColor_White.TabIndex = 4;
|
|
||||||
//
|
|
||||||
// panelColor_Green
|
|
||||||
//
|
|
||||||
panelColor_Green.BackColor = Color.Green;
|
|
||||||
panelColor_Green.Location = new Point(71, 29);
|
|
||||||
panelColor_Green.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
panelColor_Green.Name = "panelColor_Green";
|
|
||||||
panelColor_Green.Size = new Size(31, 39);
|
|
||||||
panelColor_Green.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// panelColor_Red
|
|
||||||
//
|
|
||||||
panelColor_Red.BackColor = Color.Red;
|
|
||||||
panelColor_Red.Location = new Point(7, 29);
|
|
||||||
panelColor_Red.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
panelColor_Red.Name = "panelColor_Red";
|
|
||||||
panelColor_Red.Size = new Size(31, 39);
|
|
||||||
panelColor_Red.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// checkBoxCabin
|
|
||||||
//
|
|
||||||
checkBoxCabin.AutoSize = true;
|
|
||||||
checkBoxCabin.Location = new Point(14, 192);
|
|
||||||
checkBoxCabin.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
checkBoxCabin.Name = "checkBoxCabin";
|
|
||||||
checkBoxCabin.Size = new Size(211, 24);
|
|
||||||
checkBoxCabin.TabIndex = 7;
|
|
||||||
checkBoxCabin.Text = "Признак наличия кабины";
|
|
||||||
checkBoxCabin.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// checkBoxMonorailTrack
|
|
||||||
//
|
|
||||||
checkBoxMonorailTrack.AutoSize = true;
|
|
||||||
checkBoxMonorailTrack.Location = new Point(14, 159);
|
|
||||||
checkBoxMonorailTrack.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
checkBoxMonorailTrack.Name = "checkBoxMonorailTrack";
|
|
||||||
checkBoxMonorailTrack.Size = new Size(312, 24);
|
|
||||||
checkBoxMonorailTrack.TabIndex = 6;
|
|
||||||
checkBoxMonorailTrack.Text = "Признак наличия монорельсового пути";
|
|
||||||
checkBoxMonorailTrack.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// numericUpDownWeight
|
|
||||||
//
|
|
||||||
numericUpDownWeight.Location = new Point(91, 104);
|
|
||||||
numericUpDownWeight.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
|
||||||
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
|
||||||
numericUpDownWeight.Name = "numericUpDownWeight";
|
|
||||||
numericUpDownWeight.Size = new Size(137, 27);
|
|
||||||
numericUpDownWeight.TabIndex = 5;
|
|
||||||
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
|
||||||
//
|
|
||||||
// labelWeight
|
|
||||||
//
|
|
||||||
labelWeight.AutoSize = true;
|
|
||||||
labelWeight.Location = new Point(14, 107);
|
|
||||||
labelWeight.Name = "labelWeight";
|
|
||||||
labelWeight.Size = new Size(36, 20);
|
|
||||||
labelWeight.TabIndex = 4;
|
|
||||||
labelWeight.Text = "Вес:";
|
|
||||||
//
|
|
||||||
// numericUpDownSpeed
|
|
||||||
//
|
|
||||||
numericUpDownSpeed.Location = new Point(91, 43);
|
|
||||||
numericUpDownSpeed.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
numericUpDownSpeed.Name = "numericUpDownSpeed";
|
|
||||||
numericUpDownSpeed.Size = new Size(137, 27);
|
|
||||||
numericUpDownSpeed.TabIndex = 3;
|
|
||||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
|
||||||
//
|
|
||||||
// labelSpeed
|
|
||||||
//
|
|
||||||
labelSpeed.AutoSize = true;
|
|
||||||
labelSpeed.Location = new Point(14, 45);
|
|
||||||
labelSpeed.Name = "labelSpeed";
|
|
||||||
labelSpeed.Size = new Size(76, 20);
|
|
||||||
labelSpeed.TabIndex = 2;
|
|
||||||
labelSpeed.Text = "Скорость:";
|
|
||||||
//
|
|
||||||
// labelModifiedObject
|
|
||||||
//
|
|
||||||
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
|
||||||
labelModifiedObject.Location = new Point(437, 187);
|
|
||||||
labelModifiedObject.Name = "labelModifiedObject";
|
|
||||||
labelModifiedObject.Size = new Size(114, 30);
|
|
||||||
labelModifiedObject.TabIndex = 1;
|
|
||||||
labelModifiedObject.Text = "Продвинутый";
|
|
||||||
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
|
||||||
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
|
||||||
//
|
|
||||||
// labelSimpleObject
|
|
||||||
//
|
|
||||||
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
|
||||||
labelSimpleObject.Location = new Point(315, 188);
|
|
||||||
labelSimpleObject.Name = "labelSimpleObject";
|
|
||||||
labelSimpleObject.Size = new Size(114, 30);
|
|
||||||
labelSimpleObject.TabIndex = 0;
|
|
||||||
labelSimpleObject.Text = "Простой";
|
|
||||||
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
|
||||||
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
|
||||||
//
|
|
||||||
// pictureBoxObject
|
|
||||||
//
|
|
||||||
pictureBoxObject.Location = new Point(19, 16);
|
|
||||||
pictureBoxObject.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
pictureBoxObject.Name = "pictureBoxObject";
|
|
||||||
pictureBoxObject.Size = new Size(226, 95);
|
|
||||||
pictureBoxObject.TabIndex = 1;
|
|
||||||
pictureBoxObject.TabStop = false;
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
buttonAdd.Location = new Point(600, 192);
|
|
||||||
buttonAdd.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
buttonAdd.Name = "buttonAdd";
|
|
||||||
buttonAdd.Size = new Size(86, 31);
|
|
||||||
buttonAdd.TabIndex = 2;
|
|
||||||
buttonAdd.Text = "Добавить";
|
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
buttonAdd.MouseClick += ButtonAdd_MouseClick;
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
buttonCancel.Location = new Point(777, 192);
|
|
||||||
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
buttonCancel.Name = "buttonCancel";
|
|
||||||
buttonCancel.Size = new Size(86, 31);
|
|
||||||
buttonCancel.TabIndex = 3;
|
|
||||||
buttonCancel.Text = "Отмена";
|
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// panelObject
|
|
||||||
//
|
|
||||||
panelObject.AllowDrop = true;
|
|
||||||
panelObject.Controls.Add(pictureBoxObject);
|
|
||||||
panelObject.Location = new Point(600, 59);
|
|
||||||
panelObject.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
panelObject.Name = "panelObject";
|
|
||||||
panelObject.Size = new Size(263, 124);
|
|
||||||
panelObject.TabIndex = 4;
|
|
||||||
panelObject.DragDrop += PanelObject_DragDrop;
|
|
||||||
panelObject.DragEnter += PanelObject_DragEnter;
|
|
||||||
//
|
|
||||||
// labelBodyColor
|
|
||||||
//
|
|
||||||
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
|
|
||||||
labelBodyColor.Location = new Point(10, 11);
|
|
||||||
labelBodyColor.Name = "labelBodyColor";
|
|
||||||
labelBodyColor.Size = new Size(114, 30);
|
|
||||||
labelBodyColor.TabIndex = 9;
|
|
||||||
labelBodyColor.Text = "Основной цвет";
|
|
||||||
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
|
|
||||||
//
|
|
||||||
// labelAdditionalColor
|
|
||||||
//
|
|
||||||
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
|
|
||||||
labelAdditionalColor.Location = new Point(13, 13);
|
|
||||||
labelAdditionalColor.Name = "labelAdditionalColor";
|
|
||||||
labelAdditionalColor.Size = new Size(114, 30);
|
|
||||||
labelAdditionalColor.TabIndex = 10;
|
|
||||||
labelAdditionalColor.Text = "Доп. цвет";
|
|
||||||
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
|
|
||||||
labelAdditionalColor.DragDrop += PanelObject_DragDrop;
|
|
||||||
labelAdditionalColor.DragEnter += PanelObject_DragEnter;
|
|
||||||
//
|
|
||||||
// panelBaseColor
|
|
||||||
//
|
|
||||||
panelBaseColor.AllowDrop = true;
|
|
||||||
panelBaseColor.Controls.Add(labelBodyColor);
|
|
||||||
panelBaseColor.Location = new Point(600, 1);
|
|
||||||
panelBaseColor.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
panelBaseColor.Name = "panelBaseColor";
|
|
||||||
panelBaseColor.Size = new Size(142, 49);
|
|
||||||
panelBaseColor.TabIndex = 11;
|
|
||||||
panelBaseColor.DragDrop += PanelColorBody_DragDrop;
|
|
||||||
panelBaseColor.DragEnter += PanelColor_DragEnter;
|
|
||||||
//
|
|
||||||
// panelAdditionalColor
|
|
||||||
//
|
|
||||||
panelAdditionalColor.AllowDrop = true;
|
|
||||||
panelAdditionalColor.Controls.Add(labelAdditionalColor);
|
|
||||||
panelAdditionalColor.Location = new Point(744, -1);
|
|
||||||
panelAdditionalColor.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
panelAdditionalColor.Name = "panelAdditionalColor";
|
|
||||||
panelAdditionalColor.Size = new Size(134, 52);
|
|
||||||
panelAdditionalColor.TabIndex = 12;
|
|
||||||
panelAdditionalColor.DragDrop += PanelColorAdditional_DragDrop;
|
|
||||||
panelAdditionalColor.DragEnter += PanelColor_DragEnter;
|
|
||||||
//
|
|
||||||
// FormMonorailConfig
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(885, 236);
|
|
||||||
Controls.Add(panelAdditionalColor);
|
|
||||||
Controls.Add(panelBaseColor);
|
|
||||||
Controls.Add(panelObject);
|
|
||||||
Controls.Add(buttonCancel);
|
|
||||||
Controls.Add(buttonAdd);
|
|
||||||
Controls.Add(groupBoxConfig);
|
|
||||||
Margin = new Padding(3, 4, 3, 4);
|
|
||||||
Name = "FormMonorailConfig";
|
|
||||||
Text = "Создание объекта";
|
|
||||||
groupBoxConfig.ResumeLayout(false);
|
|
||||||
groupBoxConfig.PerformLayout();
|
|
||||||
groupBoxColors.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
|
||||||
panelObject.ResumeLayout(false);
|
|
||||||
panelBaseColor.ResumeLayout(false);
|
|
||||||
panelAdditionalColor.ResumeLayout(false);
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private GroupBox groupBoxConfig;
|
|
||||||
private Label labelSimpleObject;
|
|
||||||
private NumericUpDown numericUpDownWeight;
|
|
||||||
private Label labelWeight;
|
|
||||||
private NumericUpDown numericUpDownSpeed;
|
|
||||||
private Label labelSpeed;
|
|
||||||
private Label labelModifiedObject;
|
|
||||||
private CheckBox checkBoxMonorailTrack;
|
|
||||||
private CheckBox checkBoxCabin;
|
|
||||||
private GroupBox groupBoxColors;
|
|
||||||
private Panel panelColor_Purple;
|
|
||||||
private Panel panelColor_Black;
|
|
||||||
private Panel panelColor_Yellow;
|
|
||||||
private Panel panelColor_Grey;
|
|
||||||
private Panel panelColor_Blue;
|
|
||||||
private Panel panelColor_White;
|
|
||||||
private Panel panelColor_Green;
|
|
||||||
private Panel panelColor_Red;
|
|
||||||
private PictureBox pictureBoxObject;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private Button buttonCancel;
|
|
||||||
private Panel panelObject;
|
|
||||||
private Label labelBodyColor;
|
|
||||||
private Label labelAdditionalColor;
|
|
||||||
private Panel panelBaseColor;
|
|
||||||
private Panel panelAdditionalColor;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,136 +0,0 @@
|
|||||||
using ProjectMonorail.Scripts.Monorail.Drawnings;
|
|
||||||
using ProjectMonorail.Scripts.Monorail.Entities;
|
|
||||||
|
|
||||||
namespace ProjectMonorail
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Форма конфигурации объекта
|
|
||||||
/// </summary>
|
|
||||||
public partial class FormMonorailConfig : Form
|
|
||||||
{
|
|
||||||
#region Events & Delegates
|
|
||||||
private event Action<DrawingMonorail> OnSendEvent_Monorail;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Объект прорисовки монорельса
|
|
||||||
/// </summary>
|
|
||||||
private DrawingMonorail? _monorail;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
public FormMonorailConfig()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
|
|
||||||
panelColor_Red.MouseDown += PanelColor_MouseDown;
|
|
||||||
panelColor_Green.MouseDown += PanelColor_MouseDown;
|
|
||||||
panelColor_Blue.MouseDown += PanelColor_MouseDown;
|
|
||||||
panelColor_Yellow.MouseDown += PanelColor_MouseDown;
|
|
||||||
panelColor_Purple.MouseDown += PanelColor_MouseDown;
|
|
||||||
panelColor_White.MouseDown += PanelColor_MouseDown;
|
|
||||||
panelColor_Black.MouseDown += PanelColor_MouseDown;
|
|
||||||
panelColor_Grey.MouseDown += PanelColor_MouseDown;
|
|
||||||
|
|
||||||
// TODO buttonCancel.Click with lambda
|
|
||||||
buttonCancel.Click += (object? obj, EventArgs e) => Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddEventListener_Monorail(Action<DrawingMonorail> method)
|
|
||||||
{
|
|
||||||
OnSendEvent_Monorail += method;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Прорисовка объекта
|
|
||||||
/// </summary>
|
|
||||||
private void DrawObject()
|
|
||||||
{
|
|
||||||
Bitmap bmp = new Bitmap(pictureBoxObject.Width, pictureBoxObject.Height);
|
|
||||||
Graphics g = Graphics.FromImage(bmp);
|
|
||||||
_monorail?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
|
|
||||||
_monorail?.SetPosition(10, 10);
|
|
||||||
_monorail?.DrawTransport(g);
|
|
||||||
pictureBoxObject.Image = bmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Передаем информацию при нажатии на Label
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Проверка полученной информации(ее типа на соответствие требуемому)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
e.Effect = e.Data?.GetDataPresent(DataFormats.Text) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Действия при приеме перетаскиваемой информации
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
switch (e.Data?.GetData(DataFormats.Text)?.ToString())
|
|
||||||
{
|
|
||||||
case "labelSimpleObject":
|
|
||||||
_monorail = new DrawingMonorail((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
|
|
||||||
panelAdditionalColor.AllowDrop = false;
|
|
||||||
break;
|
|
||||||
case "labelModifiedObject":
|
|
||||||
_monorail = new DrawingModernMonorail((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White,
|
|
||||||
Color.Black, checkBoxMonorailTrack.Checked, checkBoxCabin.Checked);
|
|
||||||
panelAdditionalColor.AllowDrop = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
DrawObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Передаем информацию при нажатии на Panel
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void PanelColor_MouseDown(object? sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor ?? Color.Black, DragDropEffects.Move | DragDropEffects.Copy);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PanelColor_DragEnter(object? sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
e.Effect = e.Data?.GetDataPresent(typeof(Color)) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PanelColorBody_DragDrop(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
_monorail?.EntityMonorail?.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
|
|
||||||
|
|
||||||
DrawObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PanelColorAdditional_DragDrop(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
if (_monorail is not DrawingModernMonorail) return;
|
|
||||||
((_monorail as DrawingModernMonorail)?.EntityMonorail as EntityModernMonorail)?.SetAdditionalColor((Color)e.Data.GetData(typeof(Color)));
|
|
||||||
|
|
||||||
DrawObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAdd_MouseClick(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
if (_monorail != null) OnSendEvent_Monorail?.Invoke(_monorail);
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>WinExe</OutputType>
|
|
||||||
<TargetFramework>net8.0-windows</TargetFramework>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="Properties\Resources.Designer.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Update="Properties\Resources.resx">
|
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
|
||||||
</EmbeddedResource>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
103
ProjectMonorail/Properties/Resources.Designer.cs
generated
103
ProjectMonorail/Properties/Resources.Designer.cs
generated
@ -1,103 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// Этот код создан программой.
|
|
||||||
// Исполняемая версия:4.0.30319.42000
|
|
||||||
//
|
|
||||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
|
||||||
// повторной генерации кода.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace ProjectMonorail.Properties {
|
|
||||||
using System;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
|
||||||
/// </summary>
|
|
||||||
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
|
||||||
// с помощью такого средства, как ResGen или Visual Studio.
|
|
||||||
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
|
||||||
// с параметром /str или перестройте свой проект VS.
|
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
|
||||||
internal class Resources {
|
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
|
||||||
|
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
|
||||||
|
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
|
||||||
internal Resources() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
|
||||||
get {
|
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectMonorail.Properties.Resources", typeof(Resources).Assembly);
|
|
||||||
resourceMan = temp;
|
|
||||||
}
|
|
||||||
return resourceMan;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
|
||||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Globalization.CultureInfo Culture {
|
|
||||||
get {
|
|
||||||
return resourceCulture;
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
resourceCulture = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap ArrowDown {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("ArrowDown", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap ArrowLeft {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("ArrowLeft", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap ArrowRight {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("ArrowRight", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap ArrowUp {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("ArrowUp", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,133 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
|
||||||
<data name="ArrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\Arrows\ArrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="ArrowLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\Arrows\ArrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="ArrowRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\Arrows\ArrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="ArrowUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\Arrows\ArrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
|
Binary file not shown.
Before Width: | Height: | Size: 23 KiB |
Binary file not shown.
Before Width: | Height: | Size: 22 KiB |
Binary file not shown.
Before Width: | Height: | Size: 22 KiB |
Binary file not shown.
Before Width: | Height: | Size: 23 KiB |
Binary file not shown.
Before Width: | Height: | Size: 77 KiB |
@ -1,115 +0,0 @@
|
|||||||
using ProjectMonorail.Scripts.Monorail.Drawnings;
|
|
||||||
|
|
||||||
namespace ProjectMonorail.Scripts.Monorail.CollectionGenericObjects
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Абстракция компании, хранящий коллекцию монорельсов
|
|
||||||
/// </summary>
|
|
||||||
public abstract class AbstractCompany
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Размер места (ширина)
|
|
||||||
/// </summary>
|
|
||||||
protected readonly int _placeSizeWidth = 240;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Размер места (высота)
|
|
||||||
/// </summary>
|
|
||||||
protected readonly int _placeSizeHeight = 80;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина окна
|
|
||||||
/// </summary>
|
|
||||||
protected readonly int _pictureWidth;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Высота окна
|
|
||||||
/// </summary>
|
|
||||||
protected readonly int _pictureHeight;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Коллекция монорельсов
|
|
||||||
/// </summary>
|
|
||||||
protected ICollectionGenericObjects<DrawingMonorail>? _collection = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Вычисление максимального количества элементов, который можно разместить в окне
|
|
||||||
/// </summary>
|
|
||||||
private int GetMaxCount => _pictureWidth * _pictureHeight / (_placeSizeWidth * _placeSizeHeight);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pictureWidth">Ширина окна</param>
|
|
||||||
/// <param name="pictureHeight">Высота окна</param>
|
|
||||||
/// <param name="collection">Коллекция монорельсов</param>
|
|
||||||
public AbstractCompany(int pictureWidth, int pictureHeight, ICollectionGenericObjects<DrawingMonorail> collection)
|
|
||||||
{
|
|
||||||
_pictureWidth = pictureWidth;
|
|
||||||
_pictureHeight = pictureHeight;
|
|
||||||
_collection = collection;
|
|
||||||
_collection.MaxCount = GetMaxCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перегрузка оператора сложения для класса
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="company">Компания</param>
|
|
||||||
/// <param name="monorail">Добавляемый объект</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static int operator +(AbstractCompany company, DrawingMonorail monorail)
|
|
||||||
{
|
|
||||||
return company._collection?.Insert(monorail) ?? -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перегрузка оператора удаления для класса
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="company">Компания</param>
|
|
||||||
/// <param name="position">Номер удаляемого объекта</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static DrawingMonorail operator -(AbstractCompany company, int position)
|
|
||||||
{
|
|
||||||
return company._collection?.Remove(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение случайного объекта из коллекции
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public DrawingMonorail? GetRandomObject()
|
|
||||||
{
|
|
||||||
Random rnd = new();
|
|
||||||
return _collection?.Get(rnd.Next(GetMaxCount));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Вывод всей коллекции
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public Bitmap? Show()
|
|
||||||
{
|
|
||||||
Bitmap bitmap = new(_pictureWidth, _pictureHeight);
|
|
||||||
Graphics graphics = Graphics.FromImage(bitmap);
|
|
||||||
DrawBackgound(graphics);
|
|
||||||
SetObjectsPosition();
|
|
||||||
for (int i = 0; i < (_collection?.Count ?? 0); ++i)
|
|
||||||
{
|
|
||||||
DrawingMonorail? obj = _collection?.Get(i);
|
|
||||||
obj?.DrawTransport(graphics);
|
|
||||||
}
|
|
||||||
return bitmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Вывод заднего фона
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="g"></param>
|
|
||||||
protected abstract void DrawBackgound(Graphics g);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Расстановка объектов
|
|
||||||
/// </summary>
|
|
||||||
protected abstract void SetObjectsPosition();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
namespace ProjectMonorail.Scripts.Monorail.CollectionGenericObjects
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Тип коллекции
|
|
||||||
/// </summary>
|
|
||||||
public enum CollectionType
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Неопределено
|
|
||||||
/// </summary>
|
|
||||||
None = 0,
|
|
||||||
/// <summary>
|
|
||||||
/// Массив
|
|
||||||
/// </summary>
|
|
||||||
Massive = 1,
|
|
||||||
/// <summary>
|
|
||||||
/// Список
|
|
||||||
/// </summary
|
|
||||||
List = 2
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
using ProjectMonorail.Scripts.Monorail.Drawnings;
|
|
||||||
|
|
||||||
namespace ProjectMonorail.Scripts.Monorail.CollectionGenericObjects
|
|
||||||
{
|
|
||||||
public class DepotSharingService : AbstractCompany
|
|
||||||
{
|
|
||||||
public DepotSharingService(int pictureWidth, int pictureHeight, ICollectionGenericObjects<DrawingMonorail> collection) : base(pictureWidth, pictureHeight, collection) {}
|
|
||||||
|
|
||||||
private int offsetX = 30;
|
|
||||||
|
|
||||||
protected override void DrawBackgound(Graphics g)
|
|
||||||
{
|
|
||||||
Pen pen = new Pen(Color.Black, 4);
|
|
||||||
|
|
||||||
int maxCountX = _pictureWidth / _placeSizeWidth;
|
|
||||||
int maxCountY = _pictureHeight / _placeSizeHeight;
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < maxCountX; i++)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < maxCountY; j++)
|
|
||||||
{
|
|
||||||
g.DrawLine(pen, i * offsetX + i * _placeSizeWidth, j * _placeSizeHeight, _placeSizeWidth + i * offsetX + i * _placeSizeWidth, j * _placeSizeHeight);
|
|
||||||
g.DrawLine(pen, i * offsetX + i * _placeSizeWidth, j * _placeSizeHeight, i * offsetX + i * _placeSizeWidth, _placeSizeHeight + j * _placeSizeHeight);
|
|
||||||
g.DrawLine(pen, i * offsetX + i * _placeSizeWidth, _placeSizeHeight + j * _placeSizeHeight, _placeSizeWidth + i * offsetX + i * _placeSizeWidth, _placeSizeHeight + j * _placeSizeHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void SetObjectsPosition()
|
|
||||||
{
|
|
||||||
int maxCountX = _pictureWidth / _placeSizeWidth;
|
|
||||||
int maxCountY = _pictureHeight / _placeSizeHeight;
|
|
||||||
|
|
||||||
int boarderOffsetX = 20;
|
|
||||||
int boarderOffsetY = 20;
|
|
||||||
|
|
||||||
int currentIndex = 0;
|
|
||||||
|
|
||||||
for (int j = maxCountY - 1; j >= 0; j--)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < maxCountX; i++, currentIndex++)
|
|
||||||
{
|
|
||||||
if (_collection.Get(currentIndex) == null) continue;
|
|
||||||
|
|
||||||
_collection.Get(currentIndex).SetPictureSize(_pictureWidth, _pictureHeight);
|
|
||||||
_collection.Get(currentIndex).SetPosition(boarderOffsetX + i * _placeSizeWidth + i * offsetX, boarderOffsetY + j * _placeSizeHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
using ProjectMonorail.Scripts.Monorail.Drawnings;
|
|
||||||
|
|
||||||
namespace ProjectMonorail.Scripts.Monorail.CollectionGenericObjects
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Интерфейс описания действий для набора хранимых объектов
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">Параметр: ограничение - ссылочный тип</typeparam>
|
|
||||||
public interface ICollectionGenericObjects<T>
|
|
||||||
where T : class
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Количество объектов в коллекции
|
|
||||||
/// </summary>
|
|
||||||
int Count { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Установка максимального количества элементов
|
|
||||||
/// </summary>
|
|
||||||
int MaxCount { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление объекта в коллекцию
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="obj">Добавляемый объект</param>
|
|
||||||
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
|
|
||||||
int Insert(T obj);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление объекта в коллекцию на конкретную позицию
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="obj">Добавляемый объект</param>
|
|
||||||
/// <param name="position">Позиция</param>
|
|
||||||
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
|
|
||||||
int Insert(T obj, int position);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление объекта из коллекции с конкретной позиции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="position">Позиция</param>
|
|
||||||
/// <returns>true - удаление прошло удачно, false - удаление не удалось</returns>
|
|
||||||
T? Remove(int position);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение объекта по позиции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="position">Позиция</param>
|
|
||||||
/// <returns>Объект</returns>
|
|
||||||
T? Get(int position);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение типа коллекции
|
|
||||||
/// </summary>
|
|
||||||
CollectionType GetCollectionType { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение объектов коллекции по одному
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Поэлементный вывод элементов коллекции</returns>
|
|
||||||
IEnumerable<T?> GetItems();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
|
|
||||||
namespace ProjectMonorail.Scripts.Monorail.CollectionGenericObjects
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Параметризованный набор объектов
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">Параметр: ограничение - ссылочный тип</typeparam>
|
|
||||||
public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
|
||||||
where T : class
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Список объектов, которые храним
|
|
||||||
/// </summary>
|
|
||||||
private readonly List<T?> _collection;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Максимально допустимое число объектов в списке
|
|
||||||
/// </summary>
|
|
||||||
private int _maxCount;
|
|
||||||
|
|
||||||
public int Count => _collection.Count;
|
|
||||||
|
|
||||||
public int MaxCount {
|
|
||||||
get { return Count; }
|
|
||||||
set { if (value > 0) { _maxCount = value; } }
|
|
||||||
}
|
|
||||||
|
|
||||||
public CollectionType GetCollectionType => CollectionType.List;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
public ListGenericObjects()
|
|
||||||
{
|
|
||||||
_collection = new();
|
|
||||||
}
|
|
||||||
|
|
||||||
public T? Get(int position)
|
|
||||||
{
|
|
||||||
// TODO проверка позиции
|
|
||||||
if (position < 0 || position >= _collection.Count) return null;
|
|
||||||
return _collection[position];
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Insert(T obj)
|
|
||||||
{
|
|
||||||
// TODO проверка, что не превышено максимальное количество элементов
|
|
||||||
// TODO вставка в конец набора
|
|
||||||
|
|
||||||
if (_collection.Count + 1 > _maxCount) return -1;
|
|
||||||
|
|
||||||
_collection.Add(obj);
|
|
||||||
return _collection.Count + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Insert(T obj, int position)
|
|
||||||
{
|
|
||||||
// TODO проверка, что не превышено максимальное количество элементов
|
|
||||||
// TODO проверка позиции
|
|
||||||
// TODO вставка по позиции
|
|
||||||
if (position < 0 || position > _collection.Count || _collection[position] != null) return -1;
|
|
||||||
|
|
||||||
_collection.Insert(position, obj);
|
|
||||||
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T Remove(int position)
|
|
||||||
{
|
|
||||||
// TODO проверка позиции
|
|
||||||
// TODO удаление объекта из списка
|
|
||||||
|
|
||||||
if (position < 0 || position > _collection.Count) return null;
|
|
||||||
|
|
||||||
T temp = _collection[position];
|
|
||||||
|
|
||||||
_collection[position] = null;
|
|
||||||
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<T?> GetItems()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _collection.Count; ++i)
|
|
||||||
{
|
|
||||||
yield return _collection[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,125 +0,0 @@
|
|||||||
using ProjectMonorail.Scripts.Monorail.Drawnings;
|
|
||||||
using System.Diagnostics;
|
|
||||||
|
|
||||||
namespace ProjectMonorail.Scripts.Monorail.CollectionGenericObjects
|
|
||||||
{
|
|
||||||
public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
|
|
||||||
where T : class
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Массив объектов, которые храним
|
|
||||||
/// </summary>
|
|
||||||
private T?[] _collection;
|
|
||||||
|
|
||||||
public int Count => _collection.Length;
|
|
||||||
|
|
||||||
public int MaxCount
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _collection.Length;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value > 0)
|
|
||||||
{
|
|
||||||
if (_collection.Length > 0)
|
|
||||||
{
|
|
||||||
Array.Resize(ref _collection, value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_collection = new T?[value];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CollectionType GetCollectionType => CollectionType.Massive;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
public MassiveGenericObjects()
|
|
||||||
{
|
|
||||||
_collection = Array.Empty<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public T? Get(int position)
|
|
||||||
{
|
|
||||||
// TODO проверка позиции
|
|
||||||
if (!(position >= 0 && position < Count) || _collection[position] == null) return null;
|
|
||||||
return _collection[position];
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Insert(T obj)
|
|
||||||
{
|
|
||||||
// TODO вставка в свободное место набора
|
|
||||||
for (int i = 0; i < Count; i++)
|
|
||||||
{
|
|
||||||
if (InsertingElementCollection(i, obj)) return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Insert(T obj, int position)
|
|
||||||
{
|
|
||||||
// TODO проверка позиции
|
|
||||||
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
|
|
||||||
// ищется свободное место после этой позиции и идет вставка туда
|
|
||||||
// если нет после, ищем до
|
|
||||||
// TODO вставка
|
|
||||||
if (!(position >= 0 && position < Count)) return -1;
|
|
||||||
if (InsertingElementCollection(position, obj)) return position;
|
|
||||||
|
|
||||||
for (int i = position + 1; i < Count; i++)
|
|
||||||
{
|
|
||||||
if (InsertingElementCollection(i, obj)) return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = position - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
if (InsertingElementCollection(i, obj)) return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T Remove(int position)
|
|
||||||
{
|
|
||||||
// TODO проверка позиции
|
|
||||||
// TODO удаление объекта из массива, присвоив элементу массива значение null
|
|
||||||
|
|
||||||
if (!(position >= 0 && position < Count) || _collection[position] == null) return null;
|
|
||||||
|
|
||||||
T obj = _collection[position];
|
|
||||||
_collection[position] = null;
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Если элемент массива пустой, то происходит вставка нового элемента
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="index">Индекс элемента</param>
|
|
||||||
/// <param name="obj">Элемент</param>
|
|
||||||
/// <returns>false - элемент массива не равен null, true - равен null</returns>
|
|
||||||
private bool InsertingElementCollection(int index, T obj)
|
|
||||||
{
|
|
||||||
if (_collection[index] != null) return false;
|
|
||||||
|
|
||||||
_collection[index] = obj;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<T?> GetItems()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _collection.Length; ++i)
|
|
||||||
{
|
|
||||||
yield return _collection[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,222 +0,0 @@
|
|||||||
using ProjectMonorail.Scripts.Monorail.Drawnings;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace ProjectMonorail.Scripts.Monorail.CollectionGenericObjects
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Класс-хранилище коллекций
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
public class StorageCollection<T>
|
|
||||||
where T : DrawingMonorail
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Словарь (хранилище) с коллекциями
|
|
||||||
/// </summary>
|
|
||||||
readonly Dictionary<string, ICollectionGenericObjects<T>> _storages;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Возвращение списка названий коллекций
|
|
||||||
/// </summary>
|
|
||||||
public List<string> Keys => _storages.Keys.ToList();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ключевое слово, с которого должен начинаться файл
|
|
||||||
/// </summary>
|
|
||||||
private readonly string _collectionKey = "CollectionsStorage";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Разделитель для записи ключа и значения элемента словаря
|
|
||||||
/// </summary>
|
|
||||||
private readonly string _separatorForKeyValue = "|";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Разделитель для записей коллекции данных в файл
|
|
||||||
/// </summary>
|
|
||||||
private readonly string _separatorItems = ";";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
public StorageCollection()
|
|
||||||
{
|
|
||||||
_storages = new Dictionary<string, ICollectionGenericObjects<T>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Добавление коллекции в хранилище
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">Название коллекции</param>
|
|
||||||
/// <param name="collectionType">тип коллекции</param>
|
|
||||||
public void AddCollection(string name, CollectionType collectionType)
|
|
||||||
{
|
|
||||||
// TODO проверка, что name не пустой и нет в словаре записи с таким ключом
|
|
||||||
// TODO Прописать логику для добавления
|
|
||||||
if (!_storages.ContainsKey(name))
|
|
||||||
{
|
|
||||||
ICollectionGenericObjects<T> collection;
|
|
||||||
|
|
||||||
switch (collectionType)
|
|
||||||
{
|
|
||||||
case CollectionType.List:
|
|
||||||
collection = new ListGenericObjects<T>();
|
|
||||||
break;
|
|
||||||
case CollectionType.Massive:
|
|
||||||
collection = new MassiveGenericObjects<T>();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_storages.Add(name, collection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Удаление коллекции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">Название коллекции</param>
|
|
||||||
public void DelCollection(string name)
|
|
||||||
{
|
|
||||||
// TODO Прописать логику для удаления коллекции
|
|
||||||
|
|
||||||
_storages.Remove(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Доступ к коллекции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">Название коллекции</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public ICollectionGenericObjects<T>? this[string name]
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
// TODO Продумать логику получения
|
|
||||||
|
|
||||||
if (_storages.TryGetValue(name, out var value)) return value;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Сохранение информации по автомобилям в хранилище в файл
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="filename">Путь и имя файла</param>
|
|
||||||
/// <returns>true - сохранение прошло успешно, false - ошибка при сохранении данных</returns>
|
|
||||||
public bool SaveData(string filename)
|
|
||||||
{
|
|
||||||
if (_storages.Count == 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (File.Exists(filename))
|
|
||||||
{
|
|
||||||
File.Delete(filename);
|
|
||||||
}
|
|
||||||
using (StreamWriter writer = new StreamWriter(filename))
|
|
||||||
{
|
|
||||||
writer.Write(_collectionKey);
|
|
||||||
foreach (KeyValuePair<string, ICollectionGenericObjects<T>> value in _storages)
|
|
||||||
{
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
stringBuilder.Append(Environment.NewLine);
|
|
||||||
|
|
||||||
if (value.Value.Count == 0)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
stringBuilder.Append(value.Key);
|
|
||||||
stringBuilder.Append(_separatorForKeyValue);
|
|
||||||
stringBuilder.Append(value.Value.GetCollectionType);
|
|
||||||
stringBuilder.Append(_separatorForKeyValue);
|
|
||||||
stringBuilder.Append(value.Value.MaxCount);
|
|
||||||
stringBuilder.Append(_separatorForKeyValue);
|
|
||||||
|
|
||||||
foreach (T? item in value.Value.GetItems())
|
|
||||||
{
|
|
||||||
string data = item?.GetDataForSave() ?? string.Empty;
|
|
||||||
if (string.IsNullOrEmpty(data))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
stringBuilder.Append(data);
|
|
||||||
stringBuilder.Append(_separatorItems);
|
|
||||||
}
|
|
||||||
writer.Write(stringBuilder);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Загрузка информации по автомобилям в хранилище из файла
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="filename">Путь и имя файла</param>
|
|
||||||
/// <returns>true - загрузка прошла успешно, false - ошибка при загрузке данных</returns>
|
|
||||||
public bool LoadData(string filename)
|
|
||||||
{
|
|
||||||
if (!File.Exists(filename))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
using (StreamReader streamRader = File.OpenText(filename))
|
|
||||||
{
|
|
||||||
string inputString = streamRader.ReadLine();
|
|
||||||
|
|
||||||
if (inputString == null || inputString.Length == 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!inputString.StartsWith(_collectionKey))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
_storages.Clear();
|
|
||||||
string strs = "";
|
|
||||||
while ((strs = streamRader.ReadLine()) != null)
|
|
||||||
{
|
|
||||||
string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
if (record.Length != 4)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
CollectionType collectionType = (CollectionType)Enum.Parse(typeof(CollectionType), record[1]);
|
|
||||||
ICollectionGenericObjects<T>? collection = StorageCollection<T>.CreateCollection(collectionType);
|
|
||||||
if (collection == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
collection.MaxCount = Convert.ToInt32(record[2]);
|
|
||||||
string[] set = record[3].Split(_separatorItems, StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
foreach (string elem in set)
|
|
||||||
{
|
|
||||||
if (elem?.CreateDrawingMonorail() is T ship)
|
|
||||||
{
|
|
||||||
if (collection.Insert(ship) == -1)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_storages.Add(record[0], collection);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ICollectionGenericObjects<T>? CreateCollection(CollectionType collectionType)
|
|
||||||
{
|
|
||||||
return collectionType switch
|
|
||||||
{
|
|
||||||
CollectionType.Massive => new MassiveGenericObjects<T>(),
|
|
||||||
CollectionType.List => new ListGenericObjects<T>(),
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
using ProjectMonorail.Scripts.Monorail.Drawnings;
|
|
||||||
|
|
||||||
namespace ProjectMonorail.Scripts.Monorail.Delegates
|
|
||||||
{
|
|
||||||
public delegate void DelegateMonorail(DrawingMonorail monorail);
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
namespace ProjectMonorail.Scripts.Monorail.Drawnings
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Направление перемещения
|
|
||||||
/// </summary>
|
|
||||||
public enum DirectionType
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Неизвестное направление
|
|
||||||
/// </summary>
|
|
||||||
Unknow = -1,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Вверх
|
|
||||||
/// </summary>
|
|
||||||
Up = 1,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Вниз
|
|
||||||
/// </summary>
|
|
||||||
Down = 2,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Влево
|
|
||||||
/// </summary>
|
|
||||||
Left = 3,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Вправо
|
|
||||||
/// </summary>
|
|
||||||
Right = 4
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,147 +0,0 @@
|
|||||||
using System.Diagnostics;
|
|
||||||
using System.Drawing.Drawing2D;
|
|
||||||
using ProjectMonorail.Scripts.Monorail.Entities;
|
|
||||||
|
|
||||||
namespace ProjectMonorail.Scripts.Monorail.Drawnings
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
|
||||||
/// </summary>
|
|
||||||
public class DrawingModernMonorail : DrawingMonorail
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="entityModernMonorail"></param>
|
|
||||||
public DrawingModernMonorail(EntityModernMonorail entityModernMonorail) : base((entityModernMonorail.Cabin ? 170 : 90), 40)
|
|
||||||
{
|
|
||||||
EntityMonorail = new EntityModernMonorail(entityModernMonorail.Speed, entityModernMonorail.Weight, entityModernMonorail.BodyColor, entityModernMonorail.AdditionalColor, entityModernMonorail.MonorailTrack, entityModernMonorail.Cabin);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
|
||||||
/// <param name="monorailTrack">Признак наличия монорельсового пути</param>
|
|
||||||
/// <param name="cabin">Признак наличия кабиныы</param>
|
|
||||||
public DrawingModernMonorail(int speed, double weight, Color bodyColor, Color additionalColor, bool monorailTrack, bool cabin) : base((cabin ? 170 : 90), 40)
|
|
||||||
{
|
|
||||||
EntityMonorail = new EntityModernMonorail(speed, weight, bodyColor, additionalColor, monorailTrack, cabin);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Прорисовка объекта
|
|
||||||
/// </summary>
|
|
||||||
public override void DrawTransport(Graphics g)
|
|
||||||
{
|
|
||||||
if (EntityMonorail == null || EntityMonorail is not EntityModernMonorail entityModernMonorail || !_startPositionX.HasValue || !_startPositionY.HasValue) return;
|
|
||||||
|
|
||||||
Pen pen_Body = new Pen(EntityMonorail.BodyColor, 1.5f);
|
|
||||||
Pen pen_Additional = new Pen(entityModernMonorail.AdditionalColor, 1.5f);
|
|
||||||
|
|
||||||
Brush brush_Body = new SolidBrush(EntityMonorail.BodyColor);
|
|
||||||
Brush brush_Additional = new SolidBrush(entityModernMonorail.AdditionalColor);
|
|
||||||
|
|
||||||
|
|
||||||
base.DrawTransport(g);
|
|
||||||
|
|
||||||
//Перекраска окон первого монорельса
|
|
||||||
g.DrawRectangle(pen_Additional, _startPositionX.Value + 14, _startPositionY.Value + 2, 5, 6);
|
|
||||||
g.DrawRectangle(pen_Additional, _startPositionX.Value + 21, _startPositionY.Value + 2, 5, 6);
|
|
||||||
g.DrawRectangle(pen_Additional, _startPositionX.Value + 70, _startPositionY.Value + 2, 5, 6);
|
|
||||||
|
|
||||||
if (entityModernMonorail.MonorailTrack)
|
|
||||||
{
|
|
||||||
if (entityModernMonorail.Cabin)
|
|
||||||
{
|
|
||||||
g.FillRectangle(brush_Additional, _startPositionX.Value, _startPositionY.Value + 35, 170, 5);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g.FillRectangle(brush_Additional, _startPositionX.Value, _startPositionY.Value + 35, 86, 5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Колеса
|
|
||||||
Brush brush_White = new SolidBrush(Color.White);
|
|
||||||
g.FillEllipse(brush_White, _startPositionX.Value + 10, _startPositionY.Value + 30, 10, 10);
|
|
||||||
g.DrawEllipse(pen_Body, _startPositionX.Value + 10, _startPositionY.Value + 30, 10, 10);
|
|
||||||
|
|
||||||
g.FillEllipse(brush_White, _startPositionX.Value + 25, _startPositionY.Value + 30, 10, 10);
|
|
||||||
g.DrawEllipse(pen_Body, _startPositionX.Value + 25, _startPositionY.Value + 30, 10, 10);
|
|
||||||
|
|
||||||
g.FillEllipse(brush_White, _startPositionX.Value + 65, _startPositionY.Value + 30, 10, 10);
|
|
||||||
g.DrawEllipse(pen_Body, _startPositionX.Value + 65, _startPositionY.Value + 30, 10, 10);
|
|
||||||
|
|
||||||
g.FillEllipse(brush_White, _startPositionX.Value + 50, _startPositionY.Value + 30, 10, 10);
|
|
||||||
g.DrawEllipse(pen_Body, _startPositionX.Value + 50, _startPositionY.Value + 30, 10, 10);
|
|
||||||
|
|
||||||
|
|
||||||
if (entityModernMonorail.Cabin)
|
|
||||||
{
|
|
||||||
int offset = 170;
|
|
||||||
//Кузов монорельса
|
|
||||||
GraphicsPath pointsMonorailBody_RightBody = new GraphicsPath();
|
|
||||||
pointsMonorailBody_RightBody.AddLine(_startPositionX.Value - 8 + offset, _startPositionY.Value + 10, _startPositionX.Value - 13 + offset, _startPositionY.Value);
|
|
||||||
pointsMonorailBody_RightBody.AddLine(_startPositionX.Value - 13 + offset, _startPositionY.Value, _startPositionX.Value - 80 + offset, _startPositionY.Value);
|
|
||||||
pointsMonorailBody_RightBody.AddLine(_startPositionX.Value - 80 + offset, _startPositionY.Value, _startPositionX.Value - 80 + offset, _startPositionY.Value + 25);
|
|
||||||
pointsMonorailBody_RightBody.AddLine(_startPositionX.Value - 80 + offset, _startPositionY.Value + 25, _startPositionX.Value - 8 + offset, _startPositionY.Value + 25);
|
|
||||||
pointsMonorailBody_RightBody.AddLine(_startPositionX.Value - 8 + offset, _startPositionY.Value + 25, _startPositionX.Value - 8 + offset, _startPositionY.Value + 10);
|
|
||||||
g.DrawLine(pen_Body, _startPositionX.Value - 8 + offset, _startPositionY.Value + 10, _startPositionX.Value - 30 + offset, _startPositionY.Value + 10);
|
|
||||||
g.DrawLine(pen_Body, _startPositionX.Value - 39 + offset, _startPositionY.Value + 10, _startPositionX.Value - 80 + offset, _startPositionY.Value + 10);
|
|
||||||
g.DrawPath(pen_Body, pointsMonorailBody_RightBody);
|
|
||||||
|
|
||||||
//Дверь
|
|
||||||
g.DrawRectangle(pen_Body, _startPositionX.Value - 39 + offset, _startPositionY.Value + 5, 9, 15);
|
|
||||||
|
|
||||||
//Окна
|
|
||||||
g.DrawRectangle(pen_Additional, _startPositionX.Value - 20 + offset, _startPositionY.Value + 2, 5, 6);
|
|
||||||
g.DrawRectangle(pen_Additional, _startPositionX.Value - 27 + offset, _startPositionY.Value + 2, 5, 6);
|
|
||||||
g.DrawRectangle(pen_Additional, _startPositionX.Value - 76 + offset, _startPositionY.Value + 2, 5, 6);
|
|
||||||
|
|
||||||
//Связка монорельса
|
|
||||||
g.FillRectangle(brush_Body, _startPositionX.Value - 87 + offset, _startPositionY.Value + 2, 7, 22);
|
|
||||||
|
|
||||||
//Нижняя часть монорельса
|
|
||||||
PointF[] pointsLowerPartMonorail_2_LeftSide = new PointF[8];
|
|
||||||
pointsLowerPartMonorail_2_LeftSide[0] = new PointF(_startPositionX.Value + offset, _startPositionY.Value + 30);
|
|
||||||
pointsLowerPartMonorail_2_LeftSide[1] = new PointF(_startPositionX.Value - 8 + offset, _startPositionY.Value + 25);
|
|
||||||
pointsLowerPartMonorail_2_LeftSide[2] = new PointF(_startPositionX.Value - 72 + offset, _startPositionY.Value + 25);
|
|
||||||
pointsLowerPartMonorail_2_LeftSide[3] = new PointF(_startPositionX.Value - 36 + offset, _startPositionY.Value + 25);
|
|
||||||
pointsLowerPartMonorail_2_LeftSide[4] = new PointF(_startPositionX.Value - 36 + offset, _startPositionY.Value + 32);
|
|
||||||
pointsLowerPartMonorail_2_LeftSide[5] = new PointF(_startPositionX.Value - 15 + offset, _startPositionY.Value + 32);
|
|
||||||
pointsLowerPartMonorail_2_LeftSide[6] = new PointF(_startPositionX.Value - 15 + offset, _startPositionY.Value + 35);
|
|
||||||
pointsLowerPartMonorail_2_LeftSide[7] = new PointF(_startPositionX.Value + offset, _startPositionY.Value + 32);
|
|
||||||
g.FillPolygon(brush_Body, pointsLowerPartMonorail_2_LeftSide);
|
|
||||||
|
|
||||||
PointF[] pointsLowerPartMonorail_2_RightSide = new PointF[7];
|
|
||||||
pointsLowerPartMonorail_2_RightSide[0] = new PointF(_startPositionX.Value - 86 + offset, _startPositionY.Value + 30);
|
|
||||||
pointsLowerPartMonorail_2_RightSide[1] = new PointF(_startPositionX.Value - 80 + offset, _startPositionY.Value + 25);
|
|
||||||
pointsLowerPartMonorail_2_RightSide[2] = new PointF(_startPositionX.Value - 50 + offset, _startPositionY.Value + 25);
|
|
||||||
pointsLowerPartMonorail_2_RightSide[3] = new PointF(_startPositionX.Value - 50 + offset, _startPositionY.Value + 32);
|
|
||||||
pointsLowerPartMonorail_2_RightSide[4] = new PointF(_startPositionX.Value - 69 + offset, _startPositionY.Value + 32);
|
|
||||||
pointsLowerPartMonorail_2_RightSide[5] = new PointF(_startPositionX.Value - 79 + offset, _startPositionY.Value + 35);
|
|
||||||
pointsLowerPartMonorail_2_RightSide[6] = new PointF(_startPositionX.Value - 86 + offset, _startPositionY.Value + 32);
|
|
||||||
g.FillPolygon(brush_Body, pointsLowerPartMonorail_2_RightSide);
|
|
||||||
g.FillRectangle(brush_Body, _startPositionX.Value - 80 + offset, _startPositionY.Value + 25, 70, 3);
|
|
||||||
|
|
||||||
|
|
||||||
//Колеса
|
|
||||||
g.FillEllipse(brush_White, _startPositionX.Value - 20 + offset, _startPositionY.Value + 30, 10, 10);
|
|
||||||
g.DrawEllipse(pen_Body, _startPositionX.Value - 20 + offset, _startPositionY.Value + 30, 10, 10);
|
|
||||||
|
|
||||||
g.FillEllipse(brush_White, _startPositionX.Value - 35 + offset, _startPositionY.Value + 30, 10, 10);
|
|
||||||
g.DrawEllipse(pen_Body, _startPositionX.Value - 35 + offset, _startPositionY.Value + 30, 10, 10);
|
|
||||||
|
|
||||||
g.FillEllipse(brush_White, _startPositionX.Value - 75 + offset, _startPositionY.Value + 30, 10, 10);
|
|
||||||
g.DrawEllipse(pen_Body, _startPositionX.Value - 75 + offset, _startPositionY.Value + 30, 10, 10);
|
|
||||||
|
|
||||||
g.FillEllipse(brush_White, _startPositionX.Value - 60 + offset, _startPositionY.Value + 30, 10, 10);
|
|
||||||
g.DrawEllipse(pen_Body, _startPositionX.Value - 60 + offset, _startPositionY.Value + 30, 10, 10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,286 +0,0 @@
|
|||||||
using ProjectMonorail.Scripts.Monorail.Entities;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Drawing.Drawing2D;
|
|
||||||
|
|
||||||
namespace ProjectMonorail.Scripts.Monorail.Drawnings
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Класс, отвечающий за прорисовку и перемещение базового объекта-сущности
|
|
||||||
/// </summary>
|
|
||||||
public class DrawingMonorail
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Класс-сущность
|
|
||||||
/// </summary>
|
|
||||||
public EntityMonorail? EntityMonorail { get; protected set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина окна
|
|
||||||
/// </summary>
|
|
||||||
private int? _pictureWidth;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Высота окна
|
|
||||||
/// </summary>
|
|
||||||
private int? _pictureHeight;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Левая координата прорисовки монорельса
|
|
||||||
/// </summary>
|
|
||||||
protected int? _startPositionX;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Верхняя кооридната прорисовки монорельса
|
|
||||||
/// </summary>
|
|
||||||
protected int? _startPositionY;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина прорисовки монорельса
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _drawningMonorailWidth = 90;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Высота прорисовки монорельса
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _drawningMonorailHeight = 40;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Координаты X объекта
|
|
||||||
/// </summary>
|
|
||||||
public int? GetPositionX => _startPositionX;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Координаты Y объекта
|
|
||||||
/// </summary>
|
|
||||||
public int? GetPositionY => _startPositionY;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина объекта
|
|
||||||
/// </summary>
|
|
||||||
public int GetWidth => _drawningMonorailWidth;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Высота объекта
|
|
||||||
/// </summary>
|
|
||||||
public int GetHeight => _drawningMonorailHeight;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Пустой конструкотор
|
|
||||||
/// </summary>
|
|
||||||
private DrawingMonorail()
|
|
||||||
{
|
|
||||||
_pictureWidth = null;
|
|
||||||
_pictureHeight = null;
|
|
||||||
_startPositionX = null;
|
|
||||||
_startPositionY = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
public DrawingMonorail(int speed, double weight, Color bodyColor) : this()
|
|
||||||
{
|
|
||||||
EntityMonorail = new EntityMonorail(speed, weight, bodyColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="entityMonorail"></param>
|
|
||||||
public DrawingMonorail(EntityMonorail entityMonorail) : this()
|
|
||||||
{
|
|
||||||
Debug.WriteLine(entityMonorail.BodyColor.ToString() + " " + entityMonorail.Speed + " " + entityMonorail.Weight);
|
|
||||||
EntityMonorail = new EntityMonorail(entityMonorail.Speed, entityMonorail.Weight, entityMonorail.BodyColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор для наследников
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="drawningMonorailWidth">Ширина прорисовки монорельса</param>
|
|
||||||
/// <param name="drawningMonorailHeight">Высота прорисовки монорельса</param>
|
|
||||||
protected DrawingMonorail(int drawningMonorailWidth, int drawningMonorailHeight) : this()
|
|
||||||
{
|
|
||||||
_drawningMonorailWidth = drawningMonorailWidth;
|
|
||||||
_drawningMonorailHeight = drawningMonorailHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Установка границ поля
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="width">Ширина поля</param>
|
|
||||||
/// <param name="height">Высота поля</param>
|
|
||||||
/// <returns> true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах</returns>
|
|
||||||
public bool SetPictureSize(int width, int height)
|
|
||||||
{
|
|
||||||
// TODO проверка, что объект "влезает" в размеры поля
|
|
||||||
// если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена
|
|
||||||
if (_drawningMonorailWidth > width || _drawningMonorailHeight > height) return false;
|
|
||||||
|
|
||||||
if (_startPositionX.HasValue && _startPositionY.HasValue)
|
|
||||||
{
|
|
||||||
if (_startPositionX.Value + _drawningMonorailWidth > width)
|
|
||||||
{
|
|
||||||
_startPositionX = width - _drawningMonorailWidth;
|
|
||||||
}
|
|
||||||
if (_startPositionY.Value + _drawningMonorailHeight > height)
|
|
||||||
{
|
|
||||||
_startPositionY = height - _drawningMonorailHeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_pictureWidth = width;
|
|
||||||
_pictureHeight = height;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Установка позиции
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="x">Координата X</param>
|
|
||||||
/// <param name="y">Координата Y</param>
|
|
||||||
public void SetPosition(int x, int y)
|
|
||||||
{
|
|
||||||
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue) return;
|
|
||||||
|
|
||||||
// TODO если при установке объекта в эти координаты, он будет "выходить" за границы формы
|
|
||||||
// то надо изменить координаты, чтобы он оставался в этих границах
|
|
||||||
|
|
||||||
if (x + _drawningMonorailWidth > _pictureWidth.Value || x < 0)
|
|
||||||
{
|
|
||||||
Random random = new();
|
|
||||||
_startPositionX = random.Next(0, _pictureWidth.Value - _drawningMonorailWidth);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_startPositionX = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (y + _drawningMonorailHeight > _pictureHeight.Value || y < 0)
|
|
||||||
{
|
|
||||||
Random random = new();
|
|
||||||
_startPositionY = random.Next(0, _pictureHeight.Value - _drawningMonorailHeight);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_startPositionY = y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Изменение направления перемещения
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction">Направление</param>
|
|
||||||
/// <returns>true - перемещене выполнено, false - перемещение невозможно</returns>
|
|
||||||
public bool MoveTransport(DirectionType direction)
|
|
||||||
{
|
|
||||||
if (EntityMonorail == null || !_startPositionX.HasValue || !_startPositionY.HasValue) return false;
|
|
||||||
|
|
||||||
switch (direction)
|
|
||||||
{
|
|
||||||
case DirectionType.Left:
|
|
||||||
if (_startPositionX.Value - EntityMonorail.Step > 0)
|
|
||||||
{
|
|
||||||
_startPositionX -= (int)EntityMonorail.Step;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case DirectionType.Up:
|
|
||||||
if (_startPositionY.Value - EntityMonorail.Step > 0)
|
|
||||||
{
|
|
||||||
_startPositionY -= (int)EntityMonorail.Step;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case DirectionType.Right:
|
|
||||||
if (_startPositionX.Value + EntityMonorail.Step + _drawningMonorailWidth < _pictureWidth)
|
|
||||||
{
|
|
||||||
_startPositionX += (int)EntityMonorail.Step;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case DirectionType.Down:
|
|
||||||
if (_startPositionY.Value + EntityMonorail.Step + _drawningMonorailHeight < _pictureHeight)
|
|
||||||
{
|
|
||||||
_startPositionY += (int)EntityMonorail.Step;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Прорисовка объекта
|
|
||||||
/// </summary>
|
|
||||||
public virtual void DrawTransport(Graphics g)
|
|
||||||
{
|
|
||||||
if (EntityMonorail == null || !_startPositionX.HasValue || !_startPositionY.HasValue) return;
|
|
||||||
|
|
||||||
Pen pen_Body = new Pen(EntityMonorail.BodyColor, 1.5f);
|
|
||||||
|
|
||||||
Brush brush_Body = new SolidBrush(EntityMonorail.BodyColor);
|
|
||||||
|
|
||||||
Debug.WriteLine("+");
|
|
||||||
Debug.WriteLine(EntityMonorail.BodyColor.Name);
|
|
||||||
|
|
||||||
//Кузов монорельса
|
|
||||||
GraphicsPath pointsMonorailBody_LeftBody = new GraphicsPath();
|
|
||||||
pointsMonorailBody_LeftBody.AddLine(_startPositionX.Value + 8, _startPositionY.Value + 10, _startPositionX.Value + 13, _startPositionY.Value);
|
|
||||||
pointsMonorailBody_LeftBody.AddLine(_startPositionX.Value + 13, _startPositionY.Value, _startPositionX.Value + 80, _startPositionY.Value);
|
|
||||||
pointsMonorailBody_LeftBody.AddLine(_startPositionX.Value + 80, _startPositionY.Value, _startPositionX.Value + 80, _startPositionY.Value + 25);
|
|
||||||
pointsMonorailBody_LeftBody.AddLine(_startPositionX.Value + 80, _startPositionY.Value + 25, _startPositionX.Value + 8, _startPositionY.Value + 25);
|
|
||||||
pointsMonorailBody_LeftBody.AddLine(_startPositionX.Value + 8, _startPositionY.Value + 25, _startPositionX.Value + 8, _startPositionY.Value + 10);
|
|
||||||
g.DrawLine(pen_Body, _startPositionX.Value + 8, _startPositionY.Value + 10, _startPositionX.Value + 30, _startPositionY.Value + 10);
|
|
||||||
g.DrawLine(pen_Body, _startPositionX.Value + 39, _startPositionY.Value + 10, _startPositionX.Value + 80, _startPositionY.Value + 10);
|
|
||||||
g.DrawPath(pen_Body, pointsMonorailBody_LeftBody);
|
|
||||||
|
|
||||||
//Дверь
|
|
||||||
g.DrawRectangle(pen_Body, _startPositionX.Value + 30, _startPositionY.Value + 5, 9, 15);
|
|
||||||
|
|
||||||
//Окна
|
|
||||||
g.DrawRectangle(pen_Body, _startPositionX.Value + 14, _startPositionY.Value + 2, 5, 6);
|
|
||||||
g.DrawRectangle(pen_Body, _startPositionX.Value + 21, _startPositionY.Value + 2, 5, 6);
|
|
||||||
g.DrawRectangle(pen_Body, _startPositionX.Value + 70, _startPositionY.Value + 2, 5, 6);
|
|
||||||
|
|
||||||
//Связка монорельса
|
|
||||||
g.FillRectangle(brush_Body, _startPositionX.Value + 80, _startPositionY.Value + 2, 7, 22);
|
|
||||||
|
|
||||||
//Нижняя часть монорельса
|
|
||||||
PointF[] pointsLowerPartMonorail_LeftSide = new PointF[8];
|
|
||||||
pointsLowerPartMonorail_LeftSide[0] = new PointF(_startPositionX.Value, _startPositionY.Value + 30);
|
|
||||||
pointsLowerPartMonorail_LeftSide[1] = new PointF(_startPositionX.Value + 8, _startPositionY.Value + 25);
|
|
||||||
pointsLowerPartMonorail_LeftSide[2] = new PointF(_startPositionX.Value + 72, _startPositionY.Value + 25);
|
|
||||||
pointsLowerPartMonorail_LeftSide[3] = new PointF(_startPositionX.Value + 36, _startPositionY.Value + 25);
|
|
||||||
pointsLowerPartMonorail_LeftSide[4] = new PointF(_startPositionX.Value + 36, _startPositionY.Value + 32);
|
|
||||||
pointsLowerPartMonorail_LeftSide[5] = new PointF(_startPositionX.Value + 15, _startPositionY.Value + 32);
|
|
||||||
pointsLowerPartMonorail_LeftSide[6] = new PointF(_startPositionX.Value + 15, _startPositionY.Value + 35);
|
|
||||||
pointsLowerPartMonorail_LeftSide[7] = new PointF(_startPositionX.Value, _startPositionY.Value + 32);
|
|
||||||
g.FillPolygon(brush_Body, pointsLowerPartMonorail_LeftSide);
|
|
||||||
|
|
||||||
PointF[] pointsLowerPartMonorail_RightSide = new PointF[7];
|
|
||||||
pointsLowerPartMonorail_RightSide[0] = new PointF(_startPositionX.Value + 86, _startPositionY.Value + 30);
|
|
||||||
pointsLowerPartMonorail_RightSide[1] = new PointF(_startPositionX.Value + 80, _startPositionY.Value + 25);
|
|
||||||
pointsLowerPartMonorail_RightSide[2] = new PointF(_startPositionX.Value + 50, _startPositionY.Value + 25);
|
|
||||||
pointsLowerPartMonorail_RightSide[3] = new PointF(_startPositionX.Value + 50, _startPositionY.Value + 32);
|
|
||||||
pointsLowerPartMonorail_RightSide[4] = new PointF(_startPositionX.Value + 69, _startPositionY.Value + 32);
|
|
||||||
pointsLowerPartMonorail_RightSide[5] = new PointF(_startPositionX.Value + 79, _startPositionY.Value + 35);
|
|
||||||
pointsLowerPartMonorail_RightSide[6] = new PointF(_startPositionX.Value + 86, _startPositionY.Value + 32);
|
|
||||||
g.FillPolygon(brush_Body, pointsLowerPartMonorail_RightSide);
|
|
||||||
g.FillRectangle(brush_Body, _startPositionX.Value + 8, _startPositionY.Value + 25, 70, 3);
|
|
||||||
|
|
||||||
//Колеса
|
|
||||||
Brush brush_White = new SolidBrush(Color.White);
|
|
||||||
g.FillEllipse(brush_White, _startPositionX.Value + 10, _startPositionY.Value + 30, 10, 10);
|
|
||||||
g.DrawEllipse(pen_Body, _startPositionX.Value + 10, _startPositionY.Value + 30, 10, 10);
|
|
||||||
|
|
||||||
g.FillEllipse(brush_White, _startPositionX.Value + 25, _startPositionY.Value + 30, 10, 10);
|
|
||||||
g.DrawEllipse(pen_Body, _startPositionX.Value + 25, _startPositionY.Value + 30, 10, 10);
|
|
||||||
|
|
||||||
g.FillEllipse(brush_White, _startPositionX.Value + 65, _startPositionY.Value + 30, 10, 10);
|
|
||||||
g.DrawEllipse(pen_Body, _startPositionX.Value + 65, _startPositionY.Value + 30, 10, 10);
|
|
||||||
|
|
||||||
g.FillEllipse(brush_White, _startPositionX.Value + 50, _startPositionY.Value + 30, 10, 10);
|
|
||||||
g.DrawEllipse(pen_Body, _startPositionX.Value + 50, _startPositionY.Value + 30, 10, 10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
using ProjectMonorail.Scripts.Monorail.Entities;
|
|
||||||
|
|
||||||
namespace ProjectMonorail.Scripts.Monorail.Drawnings
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Расширение для класса EntityMonorail
|
|
||||||
/// </summary>
|
|
||||||
public static class ExtentionDrawningMonorail
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Разделитель для записи информации по объекту в файл
|
|
||||||
/// </summary>
|
|
||||||
private static readonly string _separatorForObject = ":";
|
|
||||||
|
|
||||||
public static DrawingMonorail? CreateDrawingMonorail(this string info)
|
|
||||||
{
|
|
||||||
string[] args = info.Split(_separatorForObject);
|
|
||||||
EntityMonorail? monorail = EntityModernMonorail.CreateEntityModernMonorail(args);
|
|
||||||
|
|
||||||
if (monorail != null) return new DrawingModernMonorail((EntityModernMonorail)monorail);
|
|
||||||
|
|
||||||
monorail = EntityMonorail.CreateEntityMonorail(args);
|
|
||||||
|
|
||||||
if (monorail != null) return new DrawingMonorail(monorail);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение данных для сохранения в файл
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="drawingMonorail"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static string GetDataForSave(this DrawingMonorail drawingMonorail)
|
|
||||||
{
|
|
||||||
string[]? array = drawingMonorail?.EntityMonorail?.GetStringRepresention();
|
|
||||||
|
|
||||||
if (array == null)
|
|
||||||
return string.Empty;
|
|
||||||
|
|
||||||
return string.Join(_separatorForObject, array);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
namespace ProjectMonorail.Scripts.Monorail.Entities
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Класс-сущности "Современный монорельс"
|
|
||||||
/// </summary>
|
|
||||||
public class EntityModernMonorail : EntityMonorail
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Дополнительный цвет (для опциональных элементов)
|
|
||||||
/// </summary>
|
|
||||||
public Color AdditionalColor { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Признак (опция) наличия монорельсового пути
|
|
||||||
/// </summary>
|
|
||||||
public bool MonorailTrack { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Признак (опция) наличия кабины
|
|
||||||
/// </summary>
|
|
||||||
public bool Cabin { get; private set; }
|
|
||||||
|
|
||||||
public void SetAdditionalColor(Color value)
|
|
||||||
{
|
|
||||||
AdditionalColor = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Инициальзация полей объекта-класса спортивного автомобиля
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес автомобиля</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
|
||||||
/// <param name="monorailTrack">Признак наличия монорельсового пути</param>
|
|
||||||
/// <param name="cabin">Признак наличия кабины</param>
|
|
||||||
public EntityModernMonorail(int speed, double weight, Color bodyColor, Color additionalColor, bool monorailTrack, bool cabin) : base(speed, weight, bodyColor)
|
|
||||||
{
|
|
||||||
AdditionalColor = additionalColor;
|
|
||||||
MonorailTrack = monorailTrack;
|
|
||||||
Cabin = cabin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение строк с значениями свойств объекта класса-сущности
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public override string[] GetStringRepresention()
|
|
||||||
{
|
|
||||||
return new string[] { nameof(EntityModernMonorail), Speed.ToString(), Weight.ToString(), BodyColor.Name.ToString(), AdditionalColor.Name.ToString(), MonorailTrack.ToString(), Cabin.ToString()};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Создание объекта из массива строк
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="args"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static EntityModernMonorail? CreateEntityModernMonorail(string[] args)
|
|
||||||
{
|
|
||||||
if (args.Length == 0 || args[0] != nameof(EntityModernMonorail)) return null;
|
|
||||||
|
|
||||||
return new EntityModernMonorail(Convert.ToInt32(args[1]), Convert.ToDouble(args[2]), Color.FromName(args[3]), Color.FromName(args[4]), Convert.ToBoolean(args[5]), Convert.ToBoolean(args[6]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
namespace ProjectMonorail.Scripts.Monorail.Entities
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Класс-сущности "Монорельс"
|
|
||||||
/// </summary>
|
|
||||||
public class EntityMonorail
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Скорость
|
|
||||||
/// </summary>
|
|
||||||
public int Speed { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Вес
|
|
||||||
/// </summary>
|
|
||||||
public double Weight { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Основной цвет
|
|
||||||
/// </summary>
|
|
||||||
public Color BodyColor { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг перемещения автомобиля
|
|
||||||
/// </summary>
|
|
||||||
public double Step => Speed * 100 / Weight;
|
|
||||||
|
|
||||||
public void SetBodyColor(Color value)
|
|
||||||
{
|
|
||||||
BodyColor = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор сущности
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="speed">Скорость</param>
|
|
||||||
/// <param name="weight">Вес автомобиля</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
|
||||||
public EntityMonorail(int speed, double weight, Color bodyColor)
|
|
||||||
{
|
|
||||||
Speed = speed;
|
|
||||||
Weight = weight;
|
|
||||||
BodyColor = bodyColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение строк с значениями свойств объекта класса-сущности
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public virtual string[] GetStringRepresention()
|
|
||||||
{
|
|
||||||
return new string[] { nameof(EntityMonorail), Speed.ToString(), Weight.ToString(), BodyColor.Name.ToString() };
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Создание объекта из массива строк
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="args"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static EntityMonorail? CreateEntityMonorail(string[] args)
|
|
||||||
{
|
|
||||||
if (args.Length == 0 || args[0] != nameof(EntityMonorail)) return null;
|
|
||||||
|
|
||||||
return new EntityMonorail(Convert.ToInt32(args[1]), Convert.ToDouble(args[2]), Color.FromName(args[3]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,133 +0,0 @@
|
|||||||
namespace ProjectMonorail.Scripts.Monorail.MovementStrategy
|
|
||||||
{
|
|
||||||
public abstract class AbstractStrategy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещаемый объект
|
|
||||||
/// </summary>
|
|
||||||
private IMoveableObject? _moveableObject;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Статус перемещения
|
|
||||||
/// </summary>
|
|
||||||
private StrategyStatus _state = StrategyStatus.NotInit;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина поля
|
|
||||||
/// </summary>
|
|
||||||
protected int FieldWidth { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Высота поля
|
|
||||||
/// </summary>
|
|
||||||
protected int FieldHeight { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Статус перемещения
|
|
||||||
/// </summary>
|
|
||||||
public StrategyStatus GetStatus() { return _state; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Установка данных
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="moveableObject">Перемещаемый объект</param>
|
|
||||||
/// <param name="width">Ширина поля</param>
|
|
||||||
/// <param name="height">Высота поля</param>
|
|
||||||
public void SetData(IMoveableObject moveableObject, int width, int height)
|
|
||||||
{
|
|
||||||
if (moveableObject == null)
|
|
||||||
{
|
|
||||||
_state = StrategyStatus.NotInit;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_state = StrategyStatus.InProgress;
|
|
||||||
_moveableObject = moveableObject;
|
|
||||||
FieldWidth = width;
|
|
||||||
FieldHeight = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг перемещения
|
|
||||||
/// </summary>
|
|
||||||
public void MakeStep()
|
|
||||||
{
|
|
||||||
if (_state != StrategyStatus.InProgress)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (IsTargetDestinaion())
|
|
||||||
{
|
|
||||||
_state = StrategyStatus.Finish;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
MoveToTarget();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение влево
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
|
||||||
protected bool MoveLeft() => MoveTo(MovementDirection.Left);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение вправо
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
|
||||||
protected bool MoveRight() => MoveTo(MovementDirection.Right);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение вверх
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
|
||||||
protected bool MoveUp() => MoveTo(MovementDirection.Up);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение вниз
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Результат перемещения (true - удалось переместиться, false - неудача)</returns>
|
|
||||||
protected bool MoveDown() => MoveTo(MovementDirection.Down);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Параметры объекта
|
|
||||||
/// </summary>
|
|
||||||
protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг объекта
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
protected int? GetStep()
|
|
||||||
{
|
|
||||||
if (_state != StrategyStatus.InProgress)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return _moveableObject?.GetStep;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перемещение к цели
|
|
||||||
/// </summary>
|
|
||||||
protected abstract void MoveToTarget();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Достигнута ли цель
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
protected abstract bool IsTargetDestinaion();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Попытка перемещения в требуемом направлении
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="movementDirection">Направление</param>
|
|
||||||
/// <returns>Результат попытки (true - удалось переместиться, false - неудача)</returns>
|
|
||||||
private bool MoveTo(MovementDirection movementDirection)
|
|
||||||
{
|
|
||||||
if (_state != StrategyStatus.InProgress)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return _moveableObject?.TryMoveObject(movementDirection) ?? false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
namespace ProjectMonorail.Scripts.Monorail.MovementStrategy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Интерфейс для работы с перемещаемым объектом
|
|
||||||
/// </summary>I
|
|
||||||
public interface IMoveableObject
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Получение координаты объекта
|
|
||||||
/// </summary>
|
|
||||||
ObjectParameters? GetObjectPosition { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Шаг объекта
|
|
||||||
/// </summary>
|
|
||||||
int GetStep { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Попытка переместить объект в указанном направлении
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction">Направление</param>
|
|
||||||
/// <returns>true - объект перемещен, false - перемещение невозможно</returns>
|
|
||||||
bool TryMoveObject(MovementDirection direction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
namespace ProjectMonorail.Scripts.Monorail.MovementStrategy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Стратегия перемещения объекта в центр экрана
|
|
||||||
/// </summary>
|
|
||||||
public class MoveToCenter : AbstractStrategy
|
|
||||||
{
|
|
||||||
protected override bool IsTargetDestinaion()
|
|
||||||
{
|
|
||||||
ObjectParameters? objParams = GetObjectParameters;
|
|
||||||
if (objParams == null) return false;
|
|
||||||
|
|
||||||
return objParams.ObjectMiddleHorizontal - GetStep() <= FieldWidth / 2
|
|
||||||
&& objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2
|
|
||||||
&& objParams.ObjectMiddleVertical - GetStep() <= FieldHeight / 2
|
|
||||||
&& objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected override void MoveToTarget()
|
|
||||||
{
|
|
||||||
ObjectParameters? objParams = GetObjectParameters;
|
|
||||||
if (objParams == null) return;
|
|
||||||
|
|
||||||
int diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
|
|
||||||
if (Math.Abs(diffX) > GetStep())
|
|
||||||
{
|
|
||||||
if (diffX > 0)
|
|
||||||
{
|
|
||||||
MoveLeft();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MoveRight();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
|
|
||||||
if (Math.Abs(diffY) > GetStep())
|
|
||||||
{
|
|
||||||
if (diffY > 0)
|
|
||||||
{
|
|
||||||
MoveUp();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MoveDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
namespace ProjectMonorail.Scripts.Monorail.MovementStrategy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Стратегия перемещения объекта в левый нижний угл экрана
|
|
||||||
/// </summary>
|
|
||||||
public class MoveToRightDownBorder : AbstractStrategy
|
|
||||||
{
|
|
||||||
protected override bool IsTargetDestinaion()
|
|
||||||
{
|
|
||||||
ObjectParameters? objParams = GetObjectParameters;
|
|
||||||
if (objParams == null) return false;
|
|
||||||
|
|
||||||
return objParams.RightBorder + GetStep() >= FieldWidth
|
|
||||||
&& objParams.DownBorder + GetStep() >= FieldHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void MoveToTarget()
|
|
||||||
{
|
|
||||||
ObjectParameters? objParams = GetObjectParameters;
|
|
||||||
if (objParams == null) return;
|
|
||||||
|
|
||||||
int diffX = objParams.LeftBorder - FieldWidth;
|
|
||||||
if (Math.Abs(diffX) > GetStep())
|
|
||||||
{
|
|
||||||
MoveRight();
|
|
||||||
}
|
|
||||||
|
|
||||||
int diffY = objParams.DownBorder - FieldHeight;
|
|
||||||
if (Math.Abs(diffY) > GetStep())
|
|
||||||
{
|
|
||||||
MoveDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
using ProjectMonorail.Scripts.Monorail.Drawnings;
|
|
||||||
|
|
||||||
namespace ProjectMonorail.Scripts.Monorail.MovementStrategy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Класс-реализация IMoveableObject с использованием DrawingMonorail
|
|
||||||
/// </summary>
|
|
||||||
public class MoveableMonorail : IMoveableObject
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Поле-объект класса DrawingMonorail или его наследника
|
|
||||||
/// </summary>
|
|
||||||
private readonly DrawingMonorail _drawingMonorail;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="drawingMonorail">Объект класса DrawingMonorail</param>
|
|
||||||
public MoveableMonorail(DrawingMonorail drawingMonorail)
|
|
||||||
{
|
|
||||||
_drawingMonorail = drawingMonorail;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ObjectParameters? GetObjectPosition
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_drawingMonorail == null || _drawingMonorail.EntityMonorail == null || !_drawingMonorail.GetPositionX.HasValue || !_drawingMonorail.GetPositionY.HasValue) return null;
|
|
||||||
return new ObjectParameters(_drawingMonorail.GetPositionX.Value, _drawingMonorail.GetPositionY.Value, _drawingMonorail.GetWidth, _drawingMonorail.GetHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetStep => (int)(_drawingMonorail?.EntityMonorail?.Step ?? 0);
|
|
||||||
|
|
||||||
public bool TryMoveObject(MovementDirection direction)
|
|
||||||
{
|
|
||||||
if (_drawingMonorail == null || _drawingMonorail.EntityMonorail == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return _drawingMonorail.MoveTransport(GetDirectionType(direction));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конвертация из MovementDirection в DirectionType
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="direction">MovementDirection</param>
|
|
||||||
/// <returns>DirectionType</returns>
|
|
||||||
private static DirectionType GetDirectionType(MovementDirection direction)
|
|
||||||
{
|
|
||||||
return direction switch
|
|
||||||
{
|
|
||||||
MovementDirection.Left => DirectionType.Left,
|
|
||||||
MovementDirection.Right => DirectionType.Right,
|
|
||||||
MovementDirection.Up => DirectionType.Up,
|
|
||||||
MovementDirection.Down => DirectionType.Down,
|
|
||||||
_ => DirectionType.Unknow,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
namespace ProjectMonorail.Scripts.Monorail.MovementStrategy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Направление перемещения
|
|
||||||
/// </summary>
|
|
||||||
public enum MovementDirection
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Вверх
|
|
||||||
/// </summary>
|
|
||||||
Up = 1,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Вниз
|
|
||||||
/// </summary>
|
|
||||||
Down = 2,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Влево
|
|
||||||
/// </summary>
|
|
||||||
Left = 3,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Вправо
|
|
||||||
/// </summary>
|
|
||||||
Right = 4
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
namespace ProjectMonorail.Scripts.Monorail.MovementStrategy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Параметры-координаты объекта
|
|
||||||
/// </summary>
|
|
||||||
public class ObjectParameters
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Координата X
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _x;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Координата Y
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _y;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ширина объекта
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _width;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Высота объекта
|
|
||||||
/// </summary>
|
|
||||||
private readonly int _height;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Левая граница
|
|
||||||
/// </summary>
|
|
||||||
public int LeftBorder => _x;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Верхняя граница
|
|
||||||
/// </summary>
|
|
||||||
public int TopBorder => _y;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Правая граница
|
|
||||||
/// </summary>
|
|
||||||
public int RightBorder => _x + _width;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Нижняя граница
|
|
||||||
/// </summary>
|
|
||||||
public int DownBorder => _y + _height;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Середина объекта
|
|
||||||
/// </summary>
|
|
||||||
public int ObjectMiddleHorizontal => _x + _width / 2;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Середина объекта
|
|
||||||
/// </summary>
|
|
||||||
public int ObjectMiddleVertical => _y + _height / 2;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Конструктор
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="x">Координата X</param>
|
|
||||||
/// <param name="y">Координата Y</param>
|
|
||||||
/// <param name="width">Ширина объекта</param>
|
|
||||||
/// <param name="height">Высота объекта</param>
|
|
||||||
public ObjectParameters(int x, int y, int width, int height)
|
|
||||||
{
|
|
||||||
_x = x;
|
|
||||||
_y = y;
|
|
||||||
_width = width;
|
|
||||||
_height = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
namespace ProjectMonorail.Scripts.Monorail.MovementStrategy
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Статус выполнения операции перемещения
|
|
||||||
/// </summary>
|
|
||||||
public enum StrategyStatus
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Все готово к началу
|
|
||||||
/// </summary>
|
|
||||||
NotInit,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Выполняется
|
|
||||||
/// </summary>
|
|
||||||
InProgress,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Завершено
|
|
||||||
/// </summary>
|
|
||||||
Finish
|
|
||||||
}
|
|
||||||
}
|
|
39
ProjectSportCar/Form1.Designer.cs
generated
Normal file
39
ProjectSportCar/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
namespace ProjectSportCar
|
||||||
|
{
|
||||||
|
partial class Form1
|
||||||
|
{
|
||||||
|
/// <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.components = new System.ComponentModel.Container();
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Text = "Form1";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
10
ProjectSportCar/Form1.cs
Normal file
10
ProjectSportCar/Form1.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace ProjectSportCar
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
namespace ProjectMonorail
|
namespace ProjectSportCar
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
@ -11,7 +11,7 @@ namespace ProjectMonorail
|
|||||||
// 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 FormMonorailCollection());
|
Application.Run(new Form1());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
11
ProjectSportCar/ProjectSportCar.csproj
Normal file
11
ProjectSportCar/ProjectSportCar.csproj
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -1,8 +1,9 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.0.32002.185
|
VisualStudioVersion = 17.0.32002.185
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectMonorail", "ProjectMonorail.csproj", "{C1C061F8-FA8C-4805-AE55-2DABEB1E86B7}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectSportCar", "ProjectSportCar.csproj", "{C1C061F8-FA8C-4805-AE55-2DABEB1E86B7}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
Loading…
x
Reference in New Issue
Block a user