parent
76aaebda1d
commit
295bdabdb7
188
LainerForm.Designer.cs
generated
188
LainerForm.Designer.cs
generated
@ -1,188 +0,0 @@
|
|||||||
namespace ProjectLainer
|
|
||||||
{
|
|
||||||
partial class LainerForm : Form
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
pictureBoxLainer = new PictureBox();
|
|
||||||
ButtonCreate = new Button();
|
|
||||||
buttonRight = new Button();
|
|
||||||
buttonLeft = new Button();
|
|
||||||
buttonDown = new Button();
|
|
||||||
buttonUp = new Button();
|
|
||||||
ButtonCreateSuperLainer = new Button();
|
|
||||||
comboBoxStrategy = new ComboBox();
|
|
||||||
ButtonStep = new Button();
|
|
||||||
ButtonSelectLainer = new Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxLainer).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// pictureBoxLainer
|
|
||||||
//
|
|
||||||
pictureBoxLainer.Dock = DockStyle.Fill;
|
|
||||||
pictureBoxLainer.Location = new Point(0, 0);
|
|
||||||
pictureBoxLainer.Name = "pictureBoxLainer";
|
|
||||||
pictureBoxLainer.Size = new Size(729, 397);
|
|
||||||
pictureBoxLainer.SizeMode = PictureBoxSizeMode.AutoSize;
|
|
||||||
pictureBoxLainer.TabIndex = 0;
|
|
||||||
pictureBoxLainer.TabStop = false;
|
|
||||||
//
|
|
||||||
// ButtonCreate
|
|
||||||
//
|
|
||||||
ButtonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
ButtonCreate.Location = new Point(12, 356);
|
|
||||||
ButtonCreate.Name = "ButtonCreate";
|
|
||||||
ButtonCreate.Size = new Size(94, 29);
|
|
||||||
ButtonCreate.TabIndex = 1;
|
|
||||||
ButtonCreate.Text = "создать";
|
|
||||||
ButtonCreate.UseVisualStyleBackColor = true;
|
|
||||||
ButtonCreate.Click += ButtonCreate_Click;
|
|
||||||
//
|
|
||||||
// buttonRight
|
|
||||||
//
|
|
||||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonRight.BackgroundImage = Lainer1.Properties.Resources._3042406;
|
|
||||||
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonRight.Location = new Point(659, 315);
|
|
||||||
buttonRight.Name = "buttonRight";
|
|
||||||
buttonRight.Size = new Size(30, 30);
|
|
||||||
buttonRight.TabIndex = 2;
|
|
||||||
buttonRight.UseVisualStyleBackColor = true;
|
|
||||||
buttonRight.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonLeft
|
|
||||||
//
|
|
||||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonLeft.BackgroundImage = Lainer1.Properties.Resources._2;
|
|
||||||
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonLeft.Location = new Point(587, 315);
|
|
||||||
buttonLeft.Name = "buttonLeft";
|
|
||||||
buttonLeft.Size = new Size(30, 30);
|
|
||||||
buttonLeft.TabIndex = 3;
|
|
||||||
buttonLeft.UseVisualStyleBackColor = true;
|
|
||||||
buttonLeft.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonDown
|
|
||||||
//
|
|
||||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonDown.BackgroundImage = Lainer1.Properties.Resources._1;
|
|
||||||
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonDown.Location = new Point(623, 344);
|
|
||||||
buttonDown.Name = "buttonDown";
|
|
||||||
buttonDown.Size = new Size(30, 30);
|
|
||||||
buttonDown.TabIndex = 4;
|
|
||||||
buttonDown.UseVisualStyleBackColor = true;
|
|
||||||
buttonDown.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// buttonUp
|
|
||||||
//
|
|
||||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonUp.BackgroundImage = Lainer1.Properties.Resources._3;
|
|
||||||
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
|
||||||
buttonUp.Location = new Point(623, 287);
|
|
||||||
buttonUp.Name = "buttonUp";
|
|
||||||
buttonUp.Size = new Size(30, 30);
|
|
||||||
buttonUp.TabIndex = 5;
|
|
||||||
buttonUp.UseVisualStyleBackColor = true;
|
|
||||||
buttonUp.Click += ButtonMove_Click;
|
|
||||||
//
|
|
||||||
// ButtonCreateSuperLainer
|
|
||||||
//
|
|
||||||
ButtonCreateSuperLainer.Location = new Point(137, 356);
|
|
||||||
ButtonCreateSuperLainer.Name = "ButtonCreateSuperLainer";
|
|
||||||
ButtonCreateSuperLainer.Size = new Size(192, 29);
|
|
||||||
ButtonCreateSuperLainer.TabIndex = 6;
|
|
||||||
ButtonCreateSuperLainer.Text = "создать супер лайнер";
|
|
||||||
ButtonCreateSuperLainer.UseVisualStyleBackColor = true;
|
|
||||||
ButtonCreateSuperLainer.Click += ButtonCreateSuperLainer_Click;
|
|
||||||
//
|
|
||||||
// comboBoxStrategy
|
|
||||||
//
|
|
||||||
comboBoxStrategy.FormattingEnabled = true;
|
|
||||||
comboBoxStrategy.Items.AddRange(new object[] { "центр", "край" });
|
|
||||||
comboBoxStrategy.Location = new Point(566, 12);
|
|
||||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
|
||||||
comboBoxStrategy.Size = new Size(151, 28);
|
|
||||||
comboBoxStrategy.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// ButtonStep
|
|
||||||
//
|
|
||||||
ButtonStep.Location = new Point(623, 66);
|
|
||||||
ButtonStep.Name = "ButtonStep";
|
|
||||||
ButtonStep.Size = new Size(94, 29);
|
|
||||||
ButtonStep.TabIndex = 8;
|
|
||||||
ButtonStep.Text = "шаг";
|
|
||||||
ButtonStep.UseVisualStyleBackColor = true;
|
|
||||||
ButtonStep.Click += ButtonStep_Click;
|
|
||||||
//
|
|
||||||
// ButtonSelectLainer
|
|
||||||
//
|
|
||||||
ButtonSelectLainer.Location = new Point(369, 356);
|
|
||||||
ButtonSelectLainer.Name = "ButtonSelectLainer";
|
|
||||||
ButtonSelectLainer.Size = new Size(94, 29);
|
|
||||||
ButtonSelectLainer.TabIndex = 9;
|
|
||||||
ButtonSelectLainer.Text = "выбрать";
|
|
||||||
ButtonSelectLainer.UseVisualStyleBackColor = true;
|
|
||||||
ButtonSelectLainer.Click += ButtonSelectLainer_Click;
|
|
||||||
//
|
|
||||||
// LainerForm
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(729, 397);
|
|
||||||
Controls.Add(ButtonSelectLainer);
|
|
||||||
Controls.Add(ButtonStep);
|
|
||||||
Controls.Add(comboBoxStrategy);
|
|
||||||
Controls.Add(ButtonCreateSuperLainer);
|
|
||||||
Controls.Add(buttonUp);
|
|
||||||
Controls.Add(buttonDown);
|
|
||||||
Controls.Add(buttonLeft);
|
|
||||||
Controls.Add(buttonRight);
|
|
||||||
Controls.Add(ButtonCreate);
|
|
||||||
Controls.Add(pictureBoxLainer);
|
|
||||||
Name = "LainerForm";
|
|
||||||
Text = "LainerField";
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxLainer).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private PictureBox pictureBoxLainer;
|
|
||||||
private Button ButtonCreate;
|
|
||||||
private Button buttonRight;
|
|
||||||
private Button buttonLeft;
|
|
||||||
private Button buttonDown;
|
|
||||||
private Button buttonUp;
|
|
||||||
private Button ButtonCreateSuperLainer;
|
|
||||||
private ComboBox comboBoxStrategy;
|
|
||||||
private Button ButtonStep;
|
|
||||||
private Button ButtonSelectLainer;
|
|
||||||
}
|
|
||||||
}
|
|
131
LainerForm.cs
131
LainerForm.cs
@ -1,131 +0,0 @@
|
|||||||
using ProjectLainer.DrawningObjects;
|
|
||||||
using ProjectLainer.MovementStrategy;
|
|
||||||
namespace ProjectLainer
|
|
||||||
{
|
|
||||||
public partial class LainerForm : Form
|
|
||||||
{
|
|
||||||
private DrawingLainer? _drawningLainer;
|
|
||||||
private AbstractStrategy? _abstractStrategy;
|
|
||||||
private AbstractStrategy? _strategy;
|
|
||||||
public DrawingLainer? SelectedLainer { get; private set; }
|
|
||||||
public LainerForm()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_strategy = null;
|
|
||||||
SelectedLainer = null;
|
|
||||||
}
|
|
||||||
private void Draw()
|
|
||||||
{
|
|
||||||
if (_drawningLainer == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Bitmap bmp = new(pictureBoxLainer.Width,
|
|
||||||
pictureBoxLainer.Height);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
_drawningLainer.DrawTransport(gr);
|
|
||||||
pictureBoxLainer.Image = bmp;
|
|
||||||
}
|
|
||||||
private void ButtonCreateSuperLainer_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random random = new();
|
|
||||||
Color mainColor = Color.FromArgb(random.Next(0, 256),
|
|
||||||
random.Next(0, 256), random.Next(0, 256));
|
|
||||||
Color additColor = Color.FromArgb(random.Next(0, 256),
|
|
||||||
random.Next(0, 256), random.Next(0, 256));
|
|
||||||
ColorDialog dialog = new();
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
mainColor = dialog.Color;
|
|
||||||
}
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
additColor = dialog.Color;
|
|
||||||
}
|
|
||||||
_drawningLainer = new DrawningSuperLainer(random.Next(100, 300),
|
|
||||||
random.Next(1000, 3000), mainColor, additColor, Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)),
|
|
||||||
pictureBoxLainer.Width, pictureBoxLainer.Height);
|
|
||||||
_drawningLainer.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random random = new();
|
|
||||||
Color color = Color.FromArgb(random.Next(0, 256),
|
|
||||||
random.Next(0, 256), random.Next(0, 256));
|
|
||||||
ColorDialog dialog = new();
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
color = dialog.Color;
|
|
||||||
}
|
|
||||||
_drawningLainer = new DrawingLainer(random.Next(100, 300),
|
|
||||||
random.Next(1000, 3000), color,
|
|
||||||
pictureBoxLainer.Width, pictureBoxLainer.Height);
|
|
||||||
_drawningLainer.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_drawningLainer == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
|
||||||
switch (name)
|
|
||||||
{
|
|
||||||
case "buttonUp":
|
|
||||||
_drawningLainer.MoveTransport(DirectionType.Up);
|
|
||||||
break;
|
|
||||||
case "buttonDown":
|
|
||||||
_drawningLainer.MoveTransport(DirectionType.Down);
|
|
||||||
break;
|
|
||||||
case "buttonLeft":
|
|
||||||
_drawningLainer.MoveTransport(DirectionType.Left);
|
|
||||||
break;
|
|
||||||
case "buttonRight":
|
|
||||||
_drawningLainer.MoveTransport(DirectionType.Right);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
private void ButtonStep_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_drawningLainer == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (comboBoxStrategy.Enabled)
|
|
||||||
{
|
|
||||||
_strategy = comboBoxStrategy.SelectedIndex switch
|
|
||||||
{
|
|
||||||
0 => new MoveToCenter(),
|
|
||||||
1 => new MoveToBorder(),
|
|
||||||
_ => null,
|
|
||||||
};
|
|
||||||
if (_strategy == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_strategy.SetData(_drawningLainer.GetMoveableObject,
|
|
||||||
pictureBoxLainer.Width, pictureBoxLainer.Height);
|
|
||||||
}
|
|
||||||
if (_strategy == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
comboBoxStrategy.Enabled = false;
|
|
||||||
_strategy.MakeStep();
|
|
||||||
Draw();
|
|
||||||
if (_strategy.GetStatus() == Status.Finish)
|
|
||||||
{
|
|
||||||
comboBoxStrategy.Enabled = true;
|
|
||||||
_strategy = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonSelectLainer_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
SelectedLainer = _drawningLainer;
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
120
LainerForm.resx
120
LainerForm.resx
@ -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>
|
|
Loading…
Reference in New Issue
Block a user