Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
3d7c6e7d0d | |||
a3bd74377d |
@ -35,6 +35,7 @@ namespace DoubleDeckerBus
|
|||||||
}
|
}
|
||||||
public Bitmap MoveObject(Direction direction)
|
public Bitmap MoveObject(Direction direction)
|
||||||
{
|
{
|
||||||
|
|
||||||
_drawingObject.MoveObject(direction);
|
_drawingObject.MoveObject(direction);
|
||||||
|
|
||||||
bool collision = CheckCollision();
|
bool collision = CheckCollision();
|
||||||
@ -68,7 +69,6 @@ namespace DoubleDeckerBus
|
|||||||
int y = _random.Next(0, 10);
|
int y = _random.Next(0, 10);
|
||||||
_drawingObject.SetObject(x, y, _width, _height);
|
_drawingObject.SetObject(x, y, _width, _height);
|
||||||
|
|
||||||
|
|
||||||
return !CheckCollision();
|
return !CheckCollision();
|
||||||
}
|
}
|
||||||
private Bitmap DrawMapWithObject()
|
private Bitmap DrawMapWithObject()
|
||||||
@ -109,14 +109,13 @@ namespace DoubleDeckerBus
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (int y = startY; y <= endY + 1; y++)
|
for (int y = startY; y < endY; y++)
|
||||||
{
|
{
|
||||||
for (int x = startX; x <= endX + 1; x++)
|
for (int x = startX; x < endX; x++)
|
||||||
{
|
{
|
||||||
if (_map[x, y] == _barrier)
|
if (_map[x, y] == _barrier)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
namespace DoubleDeckerBus
|
|
||||||
{
|
|
||||||
public delegate void BusDelegate(DrawingBus bus);
|
|
||||||
}
|
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace DoubleDeckerBus
|
namespace DoubleDeckerBus
|
||||||
{
|
{
|
||||||
public enum Direction
|
internal enum Direction
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
Up = 1,
|
Up = 1,
|
||||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace DoubleDeckerBus
|
namespace DoubleDeckerBus
|
||||||
{
|
{
|
||||||
public class DrawingBus
|
internal class DrawingBus
|
||||||
{
|
{
|
||||||
public EntityBus Bus { get; protected set; }
|
public EntityBus Bus { get; protected set; }
|
||||||
|
|
||||||
@ -19,6 +19,7 @@ namespace DoubleDeckerBus
|
|||||||
private readonly int _busHeight = 30;
|
private readonly int _busHeight = 30;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public DrawingBus(int speed, float weight, Color bodyColor) {
|
public DrawingBus(int speed, float weight, Color bodyColor) {
|
||||||
Bus = new EntityBus(speed, weight, bodyColor);
|
Bus = new EntityBus(speed, weight, bodyColor);
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,6 @@ namespace DoubleDeckerBus
|
|||||||
{
|
{
|
||||||
internal class DrawingDDB : DrawingBus
|
internal class DrawingDDB : DrawingBus
|
||||||
{
|
{
|
||||||
public void SetDopColor(Color color)
|
|
||||||
{
|
|
||||||
((EntityDDB)Bus).ExtraColor = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DrawingDDB(int speed, float weight, Color bodyColor, Color extraColor, bool ledder, bool secondStage) : base(speed, weight, bodyColor, 100, 100) {
|
public DrawingDDB(int speed, float weight, Color bodyColor, Color extraColor, bool ledder, bool secondStage) : base(speed, weight, bodyColor, 100, 100) {
|
||||||
Bus = new EntityDDB(speed, weight, bodyColor, extraColor, ledder, secondStage);
|
Bus = new EntityDDB(speed, weight, bodyColor, extraColor, ledder, secondStage);
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,11 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace DoubleDeckerBus
|
namespace DoubleDeckerBus
|
||||||
{
|
{
|
||||||
public class EntityBus
|
internal class EntityBus
|
||||||
{
|
{
|
||||||
public int Speed { get; private set; }
|
public int Speed { get; private set; }
|
||||||
public float Weight { get; private set; }
|
public float Weight { get; private set; }
|
||||||
public Color BodyColor { get; set; }
|
public Color BodyColor { get; private set; }
|
||||||
public float Step => Speed * 100 / Weight;
|
public float Step => Speed * 100 / Weight;
|
||||||
public EntityBus(int speed, float weight, Color bodyColor)
|
public EntityBus(int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@ namespace DoubleDeckerBus
|
|||||||
{
|
{
|
||||||
internal class EntityDDB : EntityBus
|
internal class EntityDDB : EntityBus
|
||||||
{
|
{
|
||||||
public Color ExtraColor { get; set; }
|
public Color ExtraColor { get; private set; }
|
||||||
|
|
||||||
public bool Ledder { get; private set; }
|
public bool Ledder { get; private set; }
|
||||||
|
|
||||||
|
13
DoubleDeckerBus/DoubleDeckerBus/FormBus.Designer.cs
generated
13
DoubleDeckerBus/DoubleDeckerBus/FormBus.Designer.cs
generated
@ -39,7 +39,6 @@
|
|||||||
this.buttonRight = new System.Windows.Forms.Button();
|
this.buttonRight = new System.Windows.Forms.Button();
|
||||||
this.pictureBoxBus = new System.Windows.Forms.PictureBox();
|
this.pictureBoxBus = new System.Windows.Forms.PictureBox();
|
||||||
this.buttonСreateExtra = new System.Windows.Forms.Button();
|
this.buttonСreateExtra = new System.Windows.Forms.Button();
|
||||||
this.ButtonSelectBus = new System.Windows.Forms.Button();
|
|
||||||
this.statusStrip1.SuspendLayout();
|
this.statusStrip1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxBus)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxBus)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -166,22 +165,11 @@
|
|||||||
this.buttonСreateExtra.UseVisualStyleBackColor = true;
|
this.buttonСreateExtra.UseVisualStyleBackColor = true;
|
||||||
this.buttonСreateExtra.Click += new System.EventHandler(this.ButtonСreateExtra_Click);
|
this.buttonСreateExtra.Click += new System.EventHandler(this.ButtonСreateExtra_Click);
|
||||||
//
|
//
|
||||||
// ButtonSelectBus
|
|
||||||
//
|
|
||||||
this.ButtonSelectBus.Location = new System.Drawing.Point(525, 290);
|
|
||||||
this.ButtonSelectBus.Name = "ButtonSelectBus";
|
|
||||||
this.ButtonSelectBus.Size = new System.Drawing.Size(75, 23);
|
|
||||||
this.ButtonSelectBus.TabIndex = 9;
|
|
||||||
this.ButtonSelectBus.Text = "Выбрать";
|
|
||||||
this.ButtonSelectBus.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonSelectBus.Click += new System.EventHandler(this.ButtonSelectBus_Click);
|
|
||||||
//
|
|
||||||
// FormBus
|
// FormBus
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(700, 338);
|
this.ClientSize = new System.Drawing.Size(700, 338);
|
||||||
this.Controls.Add(this.ButtonSelectBus);
|
|
||||||
this.Controls.Add(this.buttonСreateExtra);
|
this.Controls.Add(this.buttonСreateExtra);
|
||||||
this.Controls.Add(this.buttonRight);
|
this.Controls.Add(this.buttonRight);
|
||||||
this.Controls.Add(this.buttonDown);
|
this.Controls.Add(this.buttonDown);
|
||||||
@ -214,6 +202,5 @@
|
|||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
private PictureBox pictureBoxBus;
|
private PictureBox pictureBoxBus;
|
||||||
private Button buttonСreateExtra;
|
private Button buttonСreateExtra;
|
||||||
private Button ButtonSelectBus;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,9 +3,6 @@ namespace DoubleDeckerBus
|
|||||||
public partial class FormBus : Form
|
public partial class FormBus : Form
|
||||||
{
|
{
|
||||||
private DrawingBus _bus;
|
private DrawingBus _bus;
|
||||||
|
|
||||||
public DrawingBus SelectedBus { get; private set; }
|
|
||||||
|
|
||||||
public FormBus()
|
public FormBus()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -22,13 +19,7 @@ namespace DoubleDeckerBus
|
|||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
_bus = new DrawingBus(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||||
ColorDialog dialog = new();
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
color = dialog.Color;
|
|
||||||
}
|
|
||||||
_bus = new DrawingBus(rnd.Next(100, 300), rnd.Next(1000, 2000), color);
|
|
||||||
SetData();
|
SetData();
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
@ -69,28 +60,12 @@ namespace DoubleDeckerBus
|
|||||||
private void ButtonÑreateExtra_Click(object sender, EventArgs e)
|
private void ButtonÑreateExtra_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
_bus = new DrawingDDB(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||||
ColorDialog dialog = new();
|
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||||
{
|
|
||||||
color = dialog.Color;
|
|
||||||
}
|
|
||||||
Color dopColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
|
||||||
ColorDialog dialogDop = new();
|
|
||||||
if (dialogDop.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
dopColor = dialogDop.Color;
|
|
||||||
}
|
|
||||||
_bus = new DrawingDDB(rnd.Next(100, 300), rnd.Next(1000, 2000), color, dopColor,
|
|
||||||
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||||
SetData();
|
SetData();
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonSelectBus_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
SelectedBus = _bus;
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,383 +0,0 @@
|
|||||||
namespace DoubleDeckerBus
|
|
||||||
{
|
|
||||||
partial class FormBusConfig
|
|
||||||
{
|
|
||||||
/// <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.groupBoxConfig = new System.Windows.Forms.GroupBox();
|
|
||||||
this.labelModifiedObject = new System.Windows.Forms.Label();
|
|
||||||
this.labelSimpleObject = new System.Windows.Forms.Label();
|
|
||||||
this.groupBoxColors = new System.Windows.Forms.GroupBox();
|
|
||||||
this.panelWhite = new System.Windows.Forms.Panel();
|
|
||||||
this.panelGray = new System.Windows.Forms.Panel();
|
|
||||||
this.panelBlack = new System.Windows.Forms.Panel();
|
|
||||||
this.panelPurple = new System.Windows.Forms.Panel();
|
|
||||||
this.panelGreen = new System.Windows.Forms.Panel();
|
|
||||||
this.panelBlue = new System.Windows.Forms.Panel();
|
|
||||||
this.panelYellow = new System.Windows.Forms.Panel();
|
|
||||||
this.panelRed = new System.Windows.Forms.Panel();
|
|
||||||
this.checkBoxStage = new System.Windows.Forms.CheckBox();
|
|
||||||
this.checkBoxLadder = new System.Windows.Forms.CheckBox();
|
|
||||||
this.labelWeight = new System.Windows.Forms.Label();
|
|
||||||
this.labelSpeed = new System.Windows.Forms.Label();
|
|
||||||
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
|
|
||||||
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
|
|
||||||
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
|
|
||||||
this.panelObject = new System.Windows.Forms.Panel();
|
|
||||||
this.labelExtraColor = new System.Windows.Forms.Label();
|
|
||||||
this.labelColor = new System.Windows.Forms.Label();
|
|
||||||
this.buttonAdd = new System.Windows.Forms.Button();
|
|
||||||
this.buttonCancel = new System.Windows.Forms.Button();
|
|
||||||
this.groupBoxConfig.SuspendLayout();
|
|
||||||
this.groupBoxColors.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
|
|
||||||
this.panelObject.SuspendLayout();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// groupBoxConfig
|
|
||||||
//
|
|
||||||
this.groupBoxConfig.Controls.Add(this.labelModifiedObject);
|
|
||||||
this.groupBoxConfig.Controls.Add(this.labelSimpleObject);
|
|
||||||
this.groupBoxConfig.Controls.Add(this.groupBoxColors);
|
|
||||||
this.groupBoxConfig.Controls.Add(this.checkBoxStage);
|
|
||||||
this.groupBoxConfig.Controls.Add(this.checkBoxLadder);
|
|
||||||
this.groupBoxConfig.Controls.Add(this.labelWeight);
|
|
||||||
this.groupBoxConfig.Controls.Add(this.labelSpeed);
|
|
||||||
this.groupBoxConfig.Controls.Add(this.numericUpDownWeight);
|
|
||||||
this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed);
|
|
||||||
this.groupBoxConfig.Location = new System.Drawing.Point(14, 16);
|
|
||||||
this.groupBoxConfig.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.groupBoxConfig.Name = "groupBoxConfig";
|
|
||||||
this.groupBoxConfig.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.groupBoxConfig.Size = new System.Drawing.Size(529, 277);
|
|
||||||
this.groupBoxConfig.TabIndex = 0;
|
|
||||||
this.groupBoxConfig.TabStop = false;
|
|
||||||
this.groupBoxConfig.Text = "Параметры";
|
|
||||||
//
|
|
||||||
// labelModifiedObject
|
|
||||||
//
|
|
||||||
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
|
||||||
this.labelModifiedObject.Location = new System.Drawing.Point(370, 193);
|
|
||||||
this.labelModifiedObject.Name = "labelModifiedObject";
|
|
||||||
this.labelModifiedObject.Size = new System.Drawing.Size(114, 54);
|
|
||||||
this.labelModifiedObject.TabIndex = 8;
|
|
||||||
this.labelModifiedObject.Text = "Продвинутый";
|
|
||||||
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
|
||||||
this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
|
|
||||||
//
|
|
||||||
// labelSimpleObject
|
|
||||||
//
|
|
||||||
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
|
||||||
this.labelSimpleObject.Location = new System.Drawing.Point(223, 193);
|
|
||||||
this.labelSimpleObject.Name = "labelSimpleObject";
|
|
||||||
this.labelSimpleObject.Size = new System.Drawing.Size(114, 54);
|
|
||||||
this.labelSimpleObject.TabIndex = 7;
|
|
||||||
this.labelSimpleObject.Text = "Простой";
|
|
||||||
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
|
||||||
this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
|
|
||||||
//
|
|
||||||
// groupBoxColors
|
|
||||||
//
|
|
||||||
this.groupBoxColors.Controls.Add(this.panelWhite);
|
|
||||||
this.groupBoxColors.Controls.Add(this.panelGray);
|
|
||||||
this.groupBoxColors.Controls.Add(this.panelBlack);
|
|
||||||
this.groupBoxColors.Controls.Add(this.panelPurple);
|
|
||||||
this.groupBoxColors.Controls.Add(this.panelGreen);
|
|
||||||
this.groupBoxColors.Controls.Add(this.panelBlue);
|
|
||||||
this.groupBoxColors.Controls.Add(this.panelYellow);
|
|
||||||
this.groupBoxColors.Controls.Add(this.panelRed);
|
|
||||||
this.groupBoxColors.Location = new System.Drawing.Point(223, 23);
|
|
||||||
this.groupBoxColors.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.groupBoxColors.Name = "groupBoxColors";
|
|
||||||
this.groupBoxColors.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.groupBoxColors.Size = new System.Drawing.Size(262, 155);
|
|
||||||
this.groupBoxColors.TabIndex = 6;
|
|
||||||
this.groupBoxColors.TabStop = false;
|
|
||||||
this.groupBoxColors.Text = "Цвета";
|
|
||||||
//
|
|
||||||
// panelWhite
|
|
||||||
//
|
|
||||||
this.panelWhite.BackColor = System.Drawing.Color.White;
|
|
||||||
this.panelWhite.Location = new System.Drawing.Point(37, 84);
|
|
||||||
this.panelWhite.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.panelWhite.Name = "panelWhite";
|
|
||||||
this.panelWhite.Size = new System.Drawing.Size(48, 53);
|
|
||||||
this.panelWhite.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// panelGray
|
|
||||||
//
|
|
||||||
this.panelGray.BackColor = System.Drawing.Color.Gray;
|
|
||||||
this.panelGray.Location = new System.Drawing.Point(91, 84);
|
|
||||||
this.panelGray.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.panelGray.Name = "panelGray";
|
|
||||||
this.panelGray.Size = new System.Drawing.Size(48, 53);
|
|
||||||
this.panelGray.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// panelBlack
|
|
||||||
//
|
|
||||||
this.panelBlack.BackColor = System.Drawing.Color.Black;
|
|
||||||
this.panelBlack.Location = new System.Drawing.Point(146, 84);
|
|
||||||
this.panelBlack.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.panelBlack.Name = "panelBlack";
|
|
||||||
this.panelBlack.Size = new System.Drawing.Size(48, 53);
|
|
||||||
this.panelBlack.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// panelPurple
|
|
||||||
//
|
|
||||||
this.panelPurple.BackColor = System.Drawing.Color.Purple;
|
|
||||||
this.panelPurple.Location = new System.Drawing.Point(201, 84);
|
|
||||||
this.panelPurple.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.panelPurple.Name = "panelPurple";
|
|
||||||
this.panelPurple.Size = new System.Drawing.Size(48, 53);
|
|
||||||
this.panelPurple.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// panelGreen
|
|
||||||
//
|
|
||||||
this.panelGreen.BackColor = System.Drawing.Color.Green;
|
|
||||||
this.panelGreen.Location = new System.Drawing.Point(91, 23);
|
|
||||||
this.panelGreen.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.panelGreen.Name = "panelGreen";
|
|
||||||
this.panelGreen.Size = new System.Drawing.Size(48, 53);
|
|
||||||
this.panelGreen.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// panelBlue
|
|
||||||
//
|
|
||||||
this.panelBlue.BackColor = System.Drawing.Color.Blue;
|
|
||||||
this.panelBlue.Location = new System.Drawing.Point(146, 23);
|
|
||||||
this.panelBlue.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.panelBlue.Name = "panelBlue";
|
|
||||||
this.panelBlue.Size = new System.Drawing.Size(48, 53);
|
|
||||||
this.panelBlue.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// panelYellow
|
|
||||||
//
|
|
||||||
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
|
|
||||||
this.panelYellow.Location = new System.Drawing.Point(201, 23);
|
|
||||||
this.panelYellow.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.panelYellow.Name = "panelYellow";
|
|
||||||
this.panelYellow.Size = new System.Drawing.Size(48, 53);
|
|
||||||
this.panelYellow.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// panelRed
|
|
||||||
//
|
|
||||||
this.panelRed.BackColor = System.Drawing.Color.Red;
|
|
||||||
this.panelRed.Location = new System.Drawing.Point(37, 23);
|
|
||||||
this.panelRed.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.panelRed.Name = "panelRed";
|
|
||||||
this.panelRed.Size = new System.Drawing.Size(48, 53);
|
|
||||||
this.panelRed.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// checkBoxStage
|
|
||||||
//
|
|
||||||
this.checkBoxStage.AutoSize = true;
|
|
||||||
this.checkBoxStage.Location = new System.Drawing.Point(7, 180);
|
|
||||||
this.checkBoxStage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.checkBoxStage.Name = "checkBoxStage";
|
|
||||||
this.checkBoxStage.Size = new System.Drawing.Size(118, 24);
|
|
||||||
this.checkBoxStage.TabIndex = 5;
|
|
||||||
this.checkBoxStage.Text = "Второй этаж";
|
|
||||||
this.checkBoxStage.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// checkBoxLadder
|
|
||||||
//
|
|
||||||
this.checkBoxLadder.AutoSize = true;
|
|
||||||
this.checkBoxLadder.Location = new System.Drawing.Point(7, 131);
|
|
||||||
this.checkBoxLadder.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.checkBoxLadder.Name = "checkBoxLadder";
|
|
||||||
this.checkBoxLadder.Size = new System.Drawing.Size(97, 24);
|
|
||||||
this.checkBoxLadder.TabIndex = 4;
|
|
||||||
this.checkBoxLadder.Text = "Лестница";
|
|
||||||
this.checkBoxLadder.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// labelWeight
|
|
||||||
//
|
|
||||||
this.labelWeight.AutoSize = true;
|
|
||||||
this.labelWeight.Location = new System.Drawing.Point(7, 79);
|
|
||||||
this.labelWeight.Name = "labelWeight";
|
|
||||||
this.labelWeight.Size = new System.Drawing.Size(33, 20);
|
|
||||||
this.labelWeight.TabIndex = 3;
|
|
||||||
this.labelWeight.Text = "Вес";
|
|
||||||
//
|
|
||||||
// labelSpeed
|
|
||||||
//
|
|
||||||
this.labelSpeed.AutoSize = true;
|
|
||||||
this.labelSpeed.Location = new System.Drawing.Point(7, 25);
|
|
||||||
this.labelSpeed.Name = "labelSpeed";
|
|
||||||
this.labelSpeed.Size = new System.Drawing.Size(73, 20);
|
|
||||||
this.labelSpeed.TabIndex = 2;
|
|
||||||
this.labelSpeed.Text = "Скорость";
|
|
||||||
//
|
|
||||||
// numericUpDownWeight
|
|
||||||
//
|
|
||||||
this.numericUpDownWeight.Location = new System.Drawing.Point(81, 68);
|
|
||||||
this.numericUpDownWeight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.numericUpDownWeight.Name = "numericUpDownWeight";
|
|
||||||
this.numericUpDownWeight.Size = new System.Drawing.Size(94, 27);
|
|
||||||
this.numericUpDownWeight.TabIndex = 1;
|
|
||||||
this.numericUpDownWeight.Value = new decimal(new int[] {
|
|
||||||
100,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0});
|
|
||||||
//
|
|
||||||
// numericUpDownSpeed
|
|
||||||
//
|
|
||||||
this.numericUpDownSpeed.Location = new System.Drawing.Point(81, 23);
|
|
||||||
this.numericUpDownSpeed.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.numericUpDownSpeed.Name = "numericUpDownSpeed";
|
|
||||||
this.numericUpDownSpeed.Size = new System.Drawing.Size(94, 27);
|
|
||||||
this.numericUpDownSpeed.TabIndex = 0;
|
|
||||||
this.numericUpDownSpeed.Value = new decimal(new int[] {
|
|
||||||
100,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0});
|
|
||||||
//
|
|
||||||
// pictureBoxObject
|
|
||||||
//
|
|
||||||
this.pictureBoxObject.Location = new System.Drawing.Point(22, 65);
|
|
||||||
this.pictureBoxObject.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.pictureBoxObject.Name = "pictureBoxObject";
|
|
||||||
this.pictureBoxObject.Size = new System.Drawing.Size(313, 140);
|
|
||||||
this.pictureBoxObject.TabIndex = 1;
|
|
||||||
this.pictureBoxObject.TabStop = false;
|
|
||||||
//
|
|
||||||
// panelObject
|
|
||||||
//
|
|
||||||
this.panelObject.AllowDrop = true;
|
|
||||||
this.panelObject.Controls.Add(this.labelExtraColor);
|
|
||||||
this.panelObject.Controls.Add(this.labelColor);
|
|
||||||
this.panelObject.Controls.Add(this.pictureBoxObject);
|
|
||||||
this.panelObject.Location = new System.Drawing.Point(550, 16);
|
|
||||||
this.panelObject.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.panelObject.Name = "panelObject";
|
|
||||||
this.panelObject.Size = new System.Drawing.Size(351, 217);
|
|
||||||
this.panelObject.TabIndex = 2;
|
|
||||||
this.panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
|
|
||||||
this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
|
|
||||||
//
|
|
||||||
// labelExtraColor
|
|
||||||
//
|
|
||||||
this.labelExtraColor.AllowDrop = true;
|
|
||||||
this.labelExtraColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
|
||||||
this.labelExtraColor.Location = new System.Drawing.Point(170, 20);
|
|
||||||
this.labelExtraColor.Name = "labelExtraColor";
|
|
||||||
this.labelExtraColor.Size = new System.Drawing.Size(164, 30);
|
|
||||||
this.labelExtraColor.TabIndex = 9;
|
|
||||||
this.labelExtraColor.Text = "Доп цвет";
|
|
||||||
this.labelExtraColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
|
||||||
this.labelExtraColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelExtraColor_DragDrop);
|
|
||||||
this.labelExtraColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelExtraColor_DragEnter);
|
|
||||||
//
|
|
||||||
// labelColor
|
|
||||||
//
|
|
||||||
this.labelColor.AllowDrop = true;
|
|
||||||
this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
|
||||||
this.labelColor.Location = new System.Drawing.Point(22, 20);
|
|
||||||
this.labelColor.Name = "labelColor";
|
|
||||||
this.labelColor.Size = new System.Drawing.Size(141, 30);
|
|
||||||
this.labelColor.TabIndex = 8;
|
|
||||||
this.labelColor.Text = "Цвет";
|
|
||||||
this.labelColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
|
||||||
this.labelColor.UseCompatibleTextRendering = true;
|
|
||||||
this.labelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop);
|
|
||||||
this.labelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
this.buttonAdd.Location = new System.Drawing.Point(561, 241);
|
|
||||||
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.buttonAdd.Name = "buttonAdd";
|
|
||||||
this.buttonAdd.Size = new System.Drawing.Size(152, 52);
|
|
||||||
this.buttonAdd.TabIndex = 3;
|
|
||||||
this.buttonAdd.Text = "Добавить";
|
|
||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(733, 241);
|
|
||||||
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.buttonCancel.Name = "buttonCancel";
|
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(152, 52);
|
|
||||||
this.buttonCancel.TabIndex = 4;
|
|
||||||
this.buttonCancel.Text = "Отмена";
|
|
||||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// FormBusConfig
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(914, 328);
|
|
||||||
this.Controls.Add(this.buttonCancel);
|
|
||||||
this.Controls.Add(this.buttonAdd);
|
|
||||||
this.Controls.Add(this.panelObject);
|
|
||||||
this.Controls.Add(this.groupBoxConfig);
|
|
||||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.Name = "FormBusConfig";
|
|
||||||
this.Text = "Создние объекта";
|
|
||||||
this.groupBoxConfig.ResumeLayout(false);
|
|
||||||
this.groupBoxConfig.PerformLayout();
|
|
||||||
this.groupBoxColors.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
|
|
||||||
this.panelObject.ResumeLayout(false);
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private GroupBox groupBoxConfig;
|
|
||||||
private CheckBox checkBoxStage;
|
|
||||||
private CheckBox checkBoxLadder;
|
|
||||||
private Label labelWeight;
|
|
||||||
private Label labelSpeed;
|
|
||||||
private NumericUpDown numericUpDownWeight;
|
|
||||||
private NumericUpDown numericUpDownSpeed;
|
|
||||||
private GroupBox groupBoxColors;
|
|
||||||
private Panel panelWhite;
|
|
||||||
private Panel panelGray;
|
|
||||||
private Panel panelBlack;
|
|
||||||
private Panel panelPurple;
|
|
||||||
private Panel panelGreen;
|
|
||||||
private Panel panelBlue;
|
|
||||||
private Panel panelYellow;
|
|
||||||
private Panel panelRed;
|
|
||||||
private Label labelSimpleObject;
|
|
||||||
private Label labelModifiedObject;
|
|
||||||
private PictureBox pictureBoxObject;
|
|
||||||
private Panel panelObject;
|
|
||||||
private Label labelExtraColor;
|
|
||||||
private Label labelColor;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private Button buttonCancel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,151 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace DoubleDeckerBus
|
|
||||||
{
|
|
||||||
public partial class FormBusConfig : Form
|
|
||||||
{
|
|
||||||
DrawingBus _bus = null;
|
|
||||||
private event BusDelegate EventAddBus;
|
|
||||||
|
|
||||||
public FormBusConfig()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
panelBlack.MouseDown += PanelColor_MouseDown;
|
|
||||||
panelPurple.MouseDown += PanelColor_MouseDown;
|
|
||||||
panelGray.MouseDown += PanelColor_MouseDown;
|
|
||||||
panelGreen.MouseDown += PanelColor_MouseDown;
|
|
||||||
panelRed.MouseDown += PanelColor_MouseDown;
|
|
||||||
panelWhite.MouseDown += PanelColor_MouseDown;
|
|
||||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
|
||||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
|
||||||
buttonCancel.Click += (object sender, EventArgs a) => Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
(sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DrawBus()
|
|
||||||
{
|
|
||||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
_bus?.SetPosition(5, 5, pictureBoxObject.Width, pictureBoxObject.Height);
|
|
||||||
_bus?.DrawTransport(gr);
|
|
||||||
pictureBoxObject.Image = bmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddEvent(BusDelegate ev)
|
|
||||||
{
|
|
||||||
if (EventAddBus == null)
|
|
||||||
{
|
|
||||||
EventAddBus = new BusDelegate(ev);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EventAddBus += ev;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Data.GetDataPresent(DataFormats.Text))
|
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.Copy;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
switch (e.Data.GetData(DataFormats.Text).ToString())
|
|
||||||
{
|
|
||||||
case "labelSimpleObject":
|
|
||||||
_bus = new DrawingBus((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelColor.BackColor);
|
|
||||||
break;
|
|
||||||
case "labelModifiedObject":
|
|
||||||
_bus = new DrawingDDB((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelColor.BackColor, labelExtraColor.BackColor,
|
|
||||||
checkBoxLadder.Checked, checkBoxStage.Checked);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
DrawBus();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
(sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LabelColor_DragEnter(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Data.GetDataPresent(typeof(Color)))
|
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.Copy;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LabelColor_DragDrop(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
var color = e.Data.GetData(typeof(Color));
|
|
||||||
if (color != null) {
|
|
||||||
(sender as Label).BackColor = (Color)color;
|
|
||||||
}
|
|
||||||
if (_bus != null)
|
|
||||||
{
|
|
||||||
_bus.Bus.BodyColor = (Color)color;
|
|
||||||
DrawBus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LabelExtraColor_DragEnter(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Data.GetDataPresent(typeof(Color)))
|
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.Copy;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LabelExtraColor_DragDrop(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
var color = e.Data.GetData(typeof(Color));
|
|
||||||
if (color != null)
|
|
||||||
{
|
|
||||||
(sender as Label).BackColor = (Color)color;
|
|
||||||
}
|
|
||||||
if (_bus != null)
|
|
||||||
{
|
|
||||||
if (_bus is DrawingDDB bus)
|
|
||||||
{
|
|
||||||
bus.SetDopColor((Color)color);
|
|
||||||
DrawBus();
|
|
||||||
}
|
|
||||||
DrawBus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
EventAddBus?.Invoke(_bus);
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
<root>
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
214
DoubleDeckerBus/DoubleDeckerBus/FormMap.Designer.cs
generated
Normal file
214
DoubleDeckerBus/DoubleDeckerBus/FormMap.Designer.cs
generated
Normal file
@ -0,0 +1,214 @@
|
|||||||
|
namespace DoubleDeckerBus
|
||||||
|
{
|
||||||
|
partial class FormMap
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.buttonCreate = new System.Windows.Forms.Button();
|
||||||
|
this.buttonUp = new System.Windows.Forms.Button();
|
||||||
|
this.buttonLeft = new System.Windows.Forms.Button();
|
||||||
|
this.buttonDown = new System.Windows.Forms.Button();
|
||||||
|
this.buttonRight = new System.Windows.Forms.Button();
|
||||||
|
this.pictureBoxBus = new System.Windows.Forms.PictureBox();
|
||||||
|
this.buttonСreateExtra = new System.Windows.Forms.Button();
|
||||||
|
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
|
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
|
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
|
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
||||||
|
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxBus)).BeginInit();
|
||||||
|
this.statusStrip1.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonCreate
|
||||||
|
//
|
||||||
|
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.buttonCreate.Location = new System.Drawing.Point(0, 389);
|
||||||
|
this.buttonCreate.Name = "buttonCreate";
|
||||||
|
this.buttonCreate.Size = new System.Drawing.Size(99, 28);
|
||||||
|
this.buttonCreate.TabIndex = 2;
|
||||||
|
this.buttonCreate.Text = "Создать";
|
||||||
|
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
|
||||||
|
//
|
||||||
|
// buttonUp
|
||||||
|
//
|
||||||
|
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonUp.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.UpArrow;
|
||||||
|
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonUp.Location = new System.Drawing.Point(718, 337);
|
||||||
|
this.buttonUp.Name = "buttonUp";
|
||||||
|
this.buttonUp.Size = new System.Drawing.Size(30, 29);
|
||||||
|
this.buttonUp.TabIndex = 3;
|
||||||
|
this.buttonUp.Text = " ";
|
||||||
|
this.buttonUp.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// buttonLeft
|
||||||
|
//
|
||||||
|
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonLeft.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.LeftArrow;
|
||||||
|
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonLeft.Location = new System.Drawing.Point(693, 363);
|
||||||
|
this.buttonLeft.Name = "buttonLeft";
|
||||||
|
this.buttonLeft.Size = new System.Drawing.Size(30, 29);
|
||||||
|
this.buttonLeft.TabIndex = 4;
|
||||||
|
this.buttonLeft.Text = " ";
|
||||||
|
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// buttonDown
|
||||||
|
//
|
||||||
|
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonDown.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.DownArrow;
|
||||||
|
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonDown.Location = new System.Drawing.Point(719, 388);
|
||||||
|
this.buttonDown.Name = "buttonDown";
|
||||||
|
this.buttonDown.Size = new System.Drawing.Size(30, 29);
|
||||||
|
this.buttonDown.TabIndex = 5;
|
||||||
|
this.buttonDown.Text = " ";
|
||||||
|
this.buttonDown.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// buttonRight
|
||||||
|
//
|
||||||
|
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonRight.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.RightArrow;
|
||||||
|
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonRight.Location = new System.Drawing.Point(745, 363);
|
||||||
|
this.buttonRight.Name = "buttonRight";
|
||||||
|
this.buttonRight.Size = new System.Drawing.Size(30, 29);
|
||||||
|
this.buttonRight.TabIndex = 6;
|
||||||
|
this.buttonRight.Text = " ";
|
||||||
|
this.buttonRight.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// pictureBoxBus
|
||||||
|
//
|
||||||
|
this.pictureBoxBus.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.pictureBoxBus.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.pictureBoxBus.Name = "pictureBoxBus";
|
||||||
|
this.pictureBoxBus.Size = new System.Drawing.Size(800, 425);
|
||||||
|
this.pictureBoxBus.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||||
|
this.pictureBoxBus.TabIndex = 7;
|
||||||
|
this.pictureBoxBus.TabStop = false;
|
||||||
|
//
|
||||||
|
// buttonСreateExtra
|
||||||
|
//
|
||||||
|
this.buttonСreateExtra.Location = new System.Drawing.Point(118, 388);
|
||||||
|
this.buttonСreateExtra.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonСreateExtra.Name = "buttonСreateExtra";
|
||||||
|
this.buttonСreateExtra.Size = new System.Drawing.Size(113, 28);
|
||||||
|
this.buttonСreateExtra.TabIndex = 8;
|
||||||
|
this.buttonСreateExtra.Text = "Модификация";
|
||||||
|
this.buttonСreateExtra.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonСreateExtra.Click += new System.EventHandler(this.ButtonСreateExtra_Click);
|
||||||
|
//
|
||||||
|
// toolStripStatusLabelSpeed
|
||||||
|
//
|
||||||
|
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
|
||||||
|
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(80, 20);
|
||||||
|
this.toolStripStatusLabelSpeed.Text = "Скорость: ";
|
||||||
|
//
|
||||||
|
// toolStripStatusLabelWeight
|
||||||
|
//
|
||||||
|
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
|
||||||
|
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(40, 20);
|
||||||
|
this.toolStripStatusLabelWeight.Text = "Вес: ";
|
||||||
|
//
|
||||||
|
// toolStripStatusLabelBodyColor
|
||||||
|
//
|
||||||
|
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
|
||||||
|
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(49, 20);
|
||||||
|
this.toolStripStatusLabelBodyColor.Text = "Цвет: ";
|
||||||
|
//
|
||||||
|
// statusStrip1
|
||||||
|
//
|
||||||
|
this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||||
|
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.toolStripStatusLabelSpeed,
|
||||||
|
this.toolStripStatusLabelWeight,
|
||||||
|
this.toolStripStatusLabelBodyColor});
|
||||||
|
this.statusStrip1.Location = new System.Drawing.Point(0, 425);
|
||||||
|
this.statusStrip1.Name = "statusStrip1";
|
||||||
|
this.statusStrip1.Size = new System.Drawing.Size(800, 26);
|
||||||
|
this.statusStrip1.TabIndex = 1;
|
||||||
|
this.statusStrip1.Text = "statusStrip1";
|
||||||
|
//
|
||||||
|
// comboBoxSelectorMap
|
||||||
|
//
|
||||||
|
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||||
|
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
||||||
|
"Простая карта",
|
||||||
|
"Водная карта"});
|
||||||
|
this.comboBoxSelectorMap.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||||
|
this.comboBoxSelectorMap.Size = new System.Drawing.Size(138, 28);
|
||||||
|
this.comboBoxSelectorMap.TabIndex = 9;
|
||||||
|
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// FormMap
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 451);
|
||||||
|
this.Controls.Add(this.comboBoxSelectorMap);
|
||||||
|
this.Controls.Add(this.buttonСreateExtra);
|
||||||
|
this.Controls.Add(this.buttonRight);
|
||||||
|
this.Controls.Add(this.buttonDown);
|
||||||
|
this.Controls.Add(this.buttonLeft);
|
||||||
|
this.Controls.Add(this.buttonUp);
|
||||||
|
this.Controls.Add(this.buttonCreate);
|
||||||
|
this.Controls.Add(this.pictureBoxBus);
|
||||||
|
this.Controls.Add(this.statusStrip1);
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.Name = "FormMap";
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxBus)).EndInit();
|
||||||
|
this.statusStrip1.ResumeLayout(false);
|
||||||
|
this.statusStrip1.PerformLayout();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
private Button buttonCreate;
|
||||||
|
private Button buttonUp;
|
||||||
|
private Button buttonLeft;
|
||||||
|
private Button buttonDown;
|
||||||
|
private Button buttonRight;
|
||||||
|
private PictureBox pictureBoxBus;
|
||||||
|
private Button buttonСreateExtra;
|
||||||
|
private ToolStripStatusLabel toolStripStatusLabelSpeed;
|
||||||
|
private ToolStripStatusLabel toolStripStatusLabelWeight;
|
||||||
|
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
|
||||||
|
private StatusStrip statusStrip1;
|
||||||
|
private ComboBox comboBoxSelectorMap;
|
||||||
|
}
|
||||||
|
}
|
87
DoubleDeckerBus/DoubleDeckerBus/FormMap.cs
Normal file
87
DoubleDeckerBus/DoubleDeckerBus/FormMap.cs
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace DoubleDeckerBus
|
||||||
|
{
|
||||||
|
public partial class FormMap : Form
|
||||||
|
{
|
||||||
|
private AbstractMap _abstractMap;
|
||||||
|
public FormMap()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_abstractMap = new SimpleMap();
|
||||||
|
comboBoxSelectorMap.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Random rnd = new();
|
||||||
|
var bus = new DrawingBus(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||||
|
SetData(bus);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||||
|
Direction dir = Direction.None;
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case "buttonUp":
|
||||||
|
dir = Direction.Up;
|
||||||
|
break;
|
||||||
|
case "buttonDown":
|
||||||
|
dir = Direction.Down;
|
||||||
|
break;
|
||||||
|
case "buttonLeft":
|
||||||
|
dir = Direction.Left;
|
||||||
|
break;
|
||||||
|
case "buttonRight":
|
||||||
|
dir = Direction.Right;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pictureBoxBus.Image = _abstractMap?.MoveObject(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetData(DrawingBus bus)
|
||||||
|
{
|
||||||
|
toolStripStatusLabelSpeed.Text = $"Скорость: {bus.Bus.Speed}";
|
||||||
|
toolStripStatusLabelWeight.Text = $"Вес: {bus.Bus.Weight}";
|
||||||
|
toolStripStatusLabelBodyColor.Text = $"Цвет: {bus.Bus.BodyColor.Name}";
|
||||||
|
pictureBoxBus.Image = _abstractMap.CreateMap(pictureBoxBus.Width, pictureBoxBus.Height,
|
||||||
|
new DrawingObjectBus(bus));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonСreateExtra_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Random rnd = new();
|
||||||
|
var bus = new DrawingDDB(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||||
|
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||||
|
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||||
|
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||||
|
SetData(bus);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
switch (comboBoxSelectorMap.Text)
|
||||||
|
{
|
||||||
|
case "Простая карта":
|
||||||
|
_abstractMap = new SimpleMap();
|
||||||
|
break;
|
||||||
|
case "Водная карта":
|
||||||
|
_abstractMap = new WaterMap();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -57,4 +57,7 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
@ -1,283 +0,0 @@
|
|||||||
namespace DoubleDeckerBus
|
|
||||||
{
|
|
||||||
partial class FormMapWithSetBuses
|
|
||||||
{
|
|
||||||
/// <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.groupBoxSettings = new System.Windows.Forms.GroupBox();
|
|
||||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
|
||||||
this.listBoxMaps = new System.Windows.Forms.ListBox();
|
|
||||||
this.ButtonDeleteMap = new System.Windows.Forms.Button();
|
|
||||||
this.ButtonAddMap = new System.Windows.Forms.Button();
|
|
||||||
this.textBoxNewMapName = new System.Windows.Forms.TextBox();
|
|
||||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
|
||||||
this.buttonRight = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDown = new System.Windows.Forms.Button();
|
|
||||||
this.buttonLeft = new System.Windows.Forms.Button();
|
|
||||||
this.buttonUp = new System.Windows.Forms.Button();
|
|
||||||
this.button1 = new System.Windows.Forms.Button();
|
|
||||||
this.buttonShowStorage = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDeleteBus = new System.Windows.Forms.Button();
|
|
||||||
this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
|
|
||||||
this.buttonAddBus = new System.Windows.Forms.Button();
|
|
||||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
|
||||||
this.groupBoxSettings.SuspendLayout();
|
|
||||||
this.groupBox1.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// groupBoxSettings
|
|
||||||
//
|
|
||||||
this.groupBoxSettings.Controls.Add(this.groupBox1);
|
|
||||||
this.groupBoxSettings.Controls.Add(this.buttonRight);
|
|
||||||
this.groupBoxSettings.Controls.Add(this.buttonDown);
|
|
||||||
this.groupBoxSettings.Controls.Add(this.buttonLeft);
|
|
||||||
this.groupBoxSettings.Controls.Add(this.buttonUp);
|
|
||||||
this.groupBoxSettings.Controls.Add(this.button1);
|
|
||||||
this.groupBoxSettings.Controls.Add(this.buttonShowStorage);
|
|
||||||
this.groupBoxSettings.Controls.Add(this.buttonDeleteBus);
|
|
||||||
this.groupBoxSettings.Controls.Add(this.maskedTextBoxPosition);
|
|
||||||
this.groupBoxSettings.Controls.Add(this.buttonAddBus);
|
|
||||||
this.groupBoxSettings.Dock = System.Windows.Forms.DockStyle.Right;
|
|
||||||
this.groupBoxSettings.Location = new System.Drawing.Point(645, 0);
|
|
||||||
this.groupBoxSettings.Name = "groupBoxSettings";
|
|
||||||
this.groupBoxSettings.Size = new System.Drawing.Size(200, 643);
|
|
||||||
this.groupBoxSettings.TabIndex = 0;
|
|
||||||
this.groupBoxSettings.TabStop = false;
|
|
||||||
this.groupBoxSettings.Text = "Инструменты";
|
|
||||||
//
|
|
||||||
// groupBox1
|
|
||||||
//
|
|
||||||
this.groupBox1.Controls.Add(this.listBoxMaps);
|
|
||||||
this.groupBox1.Controls.Add(this.ButtonDeleteMap);
|
|
||||||
this.groupBox1.Controls.Add(this.ButtonAddMap);
|
|
||||||
this.groupBox1.Controls.Add(this.textBoxNewMapName);
|
|
||||||
this.groupBox1.Controls.Add(this.comboBoxSelectorMap);
|
|
||||||
this.groupBox1.Location = new System.Drawing.Point(0, 22);
|
|
||||||
this.groupBox1.Name = "groupBox1";
|
|
||||||
this.groupBox1.Size = new System.Drawing.Size(200, 339);
|
|
||||||
this.groupBox1.TabIndex = 11;
|
|
||||||
this.groupBox1.TabStop = false;
|
|
||||||
this.groupBox1.Text = "Карты";
|
|
||||||
//
|
|
||||||
// listBoxMaps
|
|
||||||
//
|
|
||||||
this.listBoxMaps.FormattingEnabled = true;
|
|
||||||
this.listBoxMaps.ItemHeight = 15;
|
|
||||||
this.listBoxMaps.Location = new System.Drawing.Point(6, 150);
|
|
||||||
this.listBoxMaps.Name = "listBoxMaps";
|
|
||||||
this.listBoxMaps.Size = new System.Drawing.Size(188, 124);
|
|
||||||
this.listBoxMaps.TabIndex = 4;
|
|
||||||
this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.listBoxMaps_SelectedIndexChanged);
|
|
||||||
//
|
|
||||||
// ButtonDeleteMap
|
|
||||||
//
|
|
||||||
this.ButtonDeleteMap.Location = new System.Drawing.Point(6, 280);
|
|
||||||
this.ButtonDeleteMap.Name = "ButtonDeleteMap";
|
|
||||||
this.ButtonDeleteMap.Size = new System.Drawing.Size(194, 53);
|
|
||||||
this.ButtonDeleteMap.TabIndex = 3;
|
|
||||||
this.ButtonDeleteMap.Text = "Удалить карту";
|
|
||||||
this.ButtonDeleteMap.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonDeleteMap.Click += new System.EventHandler(this.ButtonDeleteMap_Click);
|
|
||||||
//
|
|
||||||
// ButtonAddMap
|
|
||||||
//
|
|
||||||
this.ButtonAddMap.Location = new System.Drawing.Point(6, 84);
|
|
||||||
this.ButtonAddMap.Name = "ButtonAddMap";
|
|
||||||
this.ButtonAddMap.Size = new System.Drawing.Size(194, 53);
|
|
||||||
this.ButtonAddMap.TabIndex = 2;
|
|
||||||
this.ButtonAddMap.Text = "Добавить карту";
|
|
||||||
this.ButtonAddMap.UseVisualStyleBackColor = true;
|
|
||||||
this.ButtonAddMap.Click += new System.EventHandler(this.ButtonAddMap_Click);
|
|
||||||
//
|
|
||||||
// textBoxNewMapName
|
|
||||||
//
|
|
||||||
this.textBoxNewMapName.Location = new System.Drawing.Point(6, 22);
|
|
||||||
this.textBoxNewMapName.Name = "textBoxNewMapName";
|
|
||||||
this.textBoxNewMapName.Size = new System.Drawing.Size(188, 23);
|
|
||||||
this.textBoxNewMapName.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// comboBoxSelectorMap
|
|
||||||
//
|
|
||||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
|
||||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(6, 55);
|
|
||||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
|
||||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(188, 23);
|
|
||||||
this.comboBoxSelectorMap.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// buttonRight
|
|
||||||
//
|
|
||||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonRight.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.RightArrow;
|
|
||||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonRight.Location = new System.Drawing.Point(109, 591);
|
|
||||||
this.buttonRight.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonRight.Name = "buttonRight";
|
|
||||||
this.buttonRight.Size = new System.Drawing.Size(26, 22);
|
|
||||||
this.buttonRight.TabIndex = 10;
|
|
||||||
this.buttonRight.Text = " ";
|
|
||||||
this.buttonRight.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonDown
|
|
||||||
//
|
|
||||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonDown.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.DownArrow;
|
|
||||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonDown.Location = new System.Drawing.Point(86, 610);
|
|
||||||
this.buttonDown.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonDown.Name = "buttonDown";
|
|
||||||
this.buttonDown.Size = new System.Drawing.Size(26, 22);
|
|
||||||
this.buttonDown.TabIndex = 9;
|
|
||||||
this.buttonDown.Text = " ";
|
|
||||||
this.buttonDown.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonLeft
|
|
||||||
//
|
|
||||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonLeft.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.LeftArrow;
|
|
||||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonLeft.Location = new System.Drawing.Point(63, 591);
|
|
||||||
this.buttonLeft.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonLeft.Name = "buttonLeft";
|
|
||||||
this.buttonLeft.Size = new System.Drawing.Size(26, 22);
|
|
||||||
this.buttonLeft.TabIndex = 8;
|
|
||||||
this.buttonLeft.Text = " ";
|
|
||||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonUp
|
|
||||||
//
|
|
||||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonUp.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.UpArrow;
|
|
||||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonUp.Location = new System.Drawing.Point(85, 572);
|
|
||||||
this.buttonUp.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonUp.Name = "buttonUp";
|
|
||||||
this.buttonUp.Size = new System.Drawing.Size(26, 22);
|
|
||||||
this.buttonUp.TabIndex = 7;
|
|
||||||
this.buttonUp.Text = " ";
|
|
||||||
this.buttonUp.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// button1
|
|
||||||
//
|
|
||||||
this.button1.Location = new System.Drawing.Point(6, 521);
|
|
||||||
this.button1.Name = "button1";
|
|
||||||
this.button1.Size = new System.Drawing.Size(182, 35);
|
|
||||||
this.button1.TabIndex = 5;
|
|
||||||
this.button1.Text = "Посмотреть карту";
|
|
||||||
this.button1.UseVisualStyleBackColor = true;
|
|
||||||
this.button1.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
|
|
||||||
//
|
|
||||||
// buttonShowStorage
|
|
||||||
//
|
|
||||||
this.buttonShowStorage.Location = new System.Drawing.Point(6, 480);
|
|
||||||
this.buttonShowStorage.Name = "buttonShowStorage";
|
|
||||||
this.buttonShowStorage.Size = new System.Drawing.Size(182, 35);
|
|
||||||
this.buttonShowStorage.TabIndex = 4;
|
|
||||||
this.buttonShowStorage.Text = "Посмотреть хранилище";
|
|
||||||
this.buttonShowStorage.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
|
|
||||||
//
|
|
||||||
// buttonDeleteBus
|
|
||||||
//
|
|
||||||
this.buttonDeleteBus.Location = new System.Drawing.Point(6, 438);
|
|
||||||
this.buttonDeleteBus.Name = "buttonDeleteBus";
|
|
||||||
this.buttonDeleteBus.Size = new System.Drawing.Size(188, 36);
|
|
||||||
this.buttonDeleteBus.TabIndex = 3;
|
|
||||||
this.buttonDeleteBus.Text = "Удалить автобус";
|
|
||||||
this.buttonDeleteBus.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDeleteBus.Click += new System.EventHandler(this.ButtonRemoveBus_Click);
|
|
||||||
//
|
|
||||||
// maskedTextBoxPosition
|
|
||||||
//
|
|
||||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(6, 409);
|
|
||||||
this.maskedTextBoxPosition.Mask = "00";
|
|
||||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
|
||||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(188, 23);
|
|
||||||
this.maskedTextBoxPosition.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// buttonAddBus
|
|
||||||
//
|
|
||||||
this.buttonAddBus.Location = new System.Drawing.Point(6, 367);
|
|
||||||
this.buttonAddBus.Name = "buttonAddBus";
|
|
||||||
this.buttonAddBus.Size = new System.Drawing.Size(188, 36);
|
|
||||||
this.buttonAddBus.TabIndex = 1;
|
|
||||||
this.buttonAddBus.Text = "Добавить автобус";
|
|
||||||
this.buttonAddBus.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonAddBus.Click += new System.EventHandler(this.ButtonAddBus_Click);
|
|
||||||
//
|
|
||||||
// pictureBox
|
|
||||||
//
|
|
||||||
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
||||||
this.pictureBox.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.pictureBox.Name = "pictureBox";
|
|
||||||
this.pictureBox.Size = new System.Drawing.Size(645, 643);
|
|
||||||
this.pictureBox.TabIndex = 1;
|
|
||||||
this.pictureBox.TabStop = false;
|
|
||||||
//
|
|
||||||
// FormMapWithSetBuses
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(845, 643);
|
|
||||||
this.Controls.Add(this.pictureBox);
|
|
||||||
this.Controls.Add(this.groupBoxSettings);
|
|
||||||
this.Name = "FormMapWithSetBuses";
|
|
||||||
this.Text = "Карты с набором объектов";
|
|
||||||
this.groupBoxSettings.ResumeLayout(false);
|
|
||||||
this.groupBoxSettings.PerformLayout();
|
|
||||||
this.groupBox1.ResumeLayout(false);
|
|
||||||
this.groupBox1.PerformLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private GroupBox groupBoxSettings;
|
|
||||||
private PictureBox pictureBox;
|
|
||||||
private Button buttonAddBus;
|
|
||||||
private Button buttonDeleteBus;
|
|
||||||
private MaskedTextBox maskedTextBoxPosition;
|
|
||||||
private Button buttonShowStorage;
|
|
||||||
private Button button1;
|
|
||||||
private Button buttonRight;
|
|
||||||
private Button buttonDown;
|
|
||||||
private Button buttonLeft;
|
|
||||||
private Button buttonUp;
|
|
||||||
private GroupBox groupBox1;
|
|
||||||
private TextBox textBoxNewMapName;
|
|
||||||
private ComboBox comboBoxSelectorMap;
|
|
||||||
private Button ButtonDeleteMap;
|
|
||||||
private Button ButtonAddMap;
|
|
||||||
private ListBox listBoxMaps;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,184 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using static System.Windows.Forms.DataFormats;
|
|
||||||
|
|
||||||
namespace DoubleDeckerBus
|
|
||||||
{
|
|
||||||
public partial class FormMapWithSetBuses : Form
|
|
||||||
{
|
|
||||||
|
|
||||||
private readonly Dictionary<string, AbstractMap> _mapsDict = new Dictionary<string, AbstractMap>() {
|
|
||||||
{ "Простая карта", new SimpleMap() },
|
|
||||||
{ "Водная карта", new WaterMap() }
|
|
||||||
};
|
|
||||||
|
|
||||||
private readonly MapsCollection _mapsCollection;
|
|
||||||
|
|
||||||
public FormMapWithSetBuses()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_mapsCollection = new MapsCollection(pictureBox.Width, pictureBox.Height);
|
|
||||||
comboBoxSelectorMap.Items.Clear();
|
|
||||||
foreach (var item in _mapsDict) {
|
|
||||||
comboBoxSelectorMap.Items.Add(item.Key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ReloadMaps()
|
|
||||||
{
|
|
||||||
int index = listBoxMaps.SelectedIndex;
|
|
||||||
|
|
||||||
listBoxMaps.Items.Clear();
|
|
||||||
for (int i = 0; i < _mapsCollection.Keys.Count; i++)
|
|
||||||
{
|
|
||||||
listBoxMaps.Items.Add(_mapsCollection.Keys[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (listBoxMaps.Items.Count > 0 && (index == -1 || index >= listBoxMaps.Items.Count))
|
|
||||||
{
|
|
||||||
listBoxMaps.SelectedIndex = 0;
|
|
||||||
}
|
|
||||||
else if (listBoxMaps.Items.Count > 0 && index > -1 && index < listBoxMaps.Items.Count)
|
|
||||||
{
|
|
||||||
listBoxMaps.SelectedIndex = index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAddBus_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var formBusConfig = new FormBusConfig();
|
|
||||||
// TODO Call method AddEvent from fromBusConfig
|
|
||||||
formBusConfig.AddEvent(AddBus);
|
|
||||||
formBusConfig.Show();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AddBus(DrawingBus bus)
|
|
||||||
{
|
|
||||||
if (listBoxMaps.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
DrawingObjectBus boat = new(bus);
|
|
||||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + boat >= 0)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект добавлен");
|
|
||||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonRemoveBus_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
|
||||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект удален");
|
|
||||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось удалить объект");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxMaps.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxMaps.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxMaps.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
|
||||||
Direction dir = Direction.None;
|
|
||||||
switch (name)
|
|
||||||
{
|
|
||||||
case "buttonUp":
|
|
||||||
dir = Direction.Up;
|
|
||||||
break;
|
|
||||||
case "buttonDown":
|
|
||||||
dir = Direction.Down;
|
|
||||||
break;
|
|
||||||
case "buttonLeft":
|
|
||||||
dir = Direction.Left;
|
|
||||||
break;
|
|
||||||
case "buttonRight":
|
|
||||||
dir = Direction.Right;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].MoveObject(dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAddMap_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (comboBoxSelectorMap.SelectedIndex == -1 || string.IsNullOrEmpty(textBoxNewMapName.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!_mapsDict.ContainsKey(comboBoxSelectorMap.Text))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Нет такой карты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_mapsCollection.AddMap(textBoxNewMapName.Text, _mapsDict[comboBoxSelectorMap.Text]);
|
|
||||||
ReloadMaps();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void listBoxMaps_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonDeleteMap_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (listBoxMaps.SelectedIndex == -1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MessageBox.Show($"Удалить карту {listBoxMaps.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
||||||
{
|
|
||||||
_mapsCollection.DelMap(listBoxMaps.SelectedItem?.ToString() ?? string.Empty);
|
|
||||||
ReloadMaps();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,144 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DoubleDeckerBus
|
|
||||||
{
|
|
||||||
internal class MapWithSetBusesGeneric<T, U>
|
|
||||||
where T : class, IDrawingObject
|
|
||||||
where U : AbstractMap
|
|
||||||
{
|
|
||||||
|
|
||||||
private readonly int _pictureWidth;
|
|
||||||
private readonly int _pictureHeight;
|
|
||||||
private readonly int _placeSizeWidth = 210;
|
|
||||||
private readonly int _placeSizeHeight = 90;
|
|
||||||
private readonly SetBusesGeneric<T> _setBuses;
|
|
||||||
private readonly U _map;
|
|
||||||
|
|
||||||
public MapWithSetBusesGeneric(int picWidth, int picHeight, U map)
|
|
||||||
{
|
|
||||||
int width = picWidth / _placeSizeWidth;
|
|
||||||
int height = picHeight / _placeSizeHeight;
|
|
||||||
_setBuses = new SetBusesGeneric<T>(width * height);
|
|
||||||
_pictureWidth = picWidth;
|
|
||||||
_pictureHeight = picHeight;
|
|
||||||
_map = map;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int operator +(MapWithSetBusesGeneric<T, U> map, T bus)
|
|
||||||
{
|
|
||||||
return map._setBuses.Insert(bus);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static T operator -(MapWithSetBusesGeneric<T, U> map, int position)
|
|
||||||
{
|
|
||||||
return map._setBuses.Remove(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Bitmap ShowSet()
|
|
||||||
{
|
|
||||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
DrawBackground(gr);
|
|
||||||
DrawBuses(gr);
|
|
||||||
return bmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Bitmap ShowOnMap()
|
|
||||||
{
|
|
||||||
Shaking();
|
|
||||||
foreach (var bus in _setBuses.GetBuses())
|
|
||||||
{
|
|
||||||
return _map.CreateMap(_pictureWidth, _pictureHeight, bus);
|
|
||||||
}
|
|
||||||
return new(_pictureWidth, _pictureHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Bitmap MoveObject(Direction direction)
|
|
||||||
{
|
|
||||||
if (_map != null)
|
|
||||||
{
|
|
||||||
return _map.MoveObject(direction);
|
|
||||||
}
|
|
||||||
return new(_pictureWidth, _pictureHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Shaking()
|
|
||||||
{
|
|
||||||
int j = _setBuses.Count - 1;
|
|
||||||
for (int i = 0; i < _setBuses.Count; i++)
|
|
||||||
{
|
|
||||||
if (_setBuses[i] == null)
|
|
||||||
{
|
|
||||||
for (; j > i; j--)
|
|
||||||
{
|
|
||||||
var bus = _setBuses[j];
|
|
||||||
if (bus != null)
|
|
||||||
{
|
|
||||||
_setBuses.Insert(bus, i);
|
|
||||||
_setBuses.Remove(j);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (j <= i)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DrawBackground(Graphics g)
|
|
||||||
{
|
|
||||||
Pen pen = new(Color.Black, 3);
|
|
||||||
Brush pointColor = new SolidBrush(Color.Orange);
|
|
||||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
|
|
||||||
{
|
|
||||||
g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
|
|
||||||
g.DrawLine(pen, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight,
|
|
||||||
i * _placeSizeWidth + _placeSizeWidth / 2, (int)((j * _placeSizeHeight) - (40)));
|
|
||||||
|
|
||||||
g.FillPolygon(pointColor, new Point[] {
|
|
||||||
new Point(i * _placeSizeWidth + _placeSizeWidth / 2, (int)((j * _placeSizeHeight) - (40))),
|
|
||||||
new Point(i * _placeSizeWidth + _placeSizeWidth / 2 - 10, (int)((j * _placeSizeHeight) - (50))),
|
|
||||||
new Point(i * _placeSizeWidth + _placeSizeWidth / 2, (int)((j * _placeSizeHeight) - (60))),
|
|
||||||
new Point(i * _placeSizeWidth + _placeSizeWidth / 2 + 10, (int)((j * _placeSizeHeight) - (50)))
|
|
||||||
});
|
|
||||||
}
|
|
||||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, (_pictureHeight / _placeSizeHeight) * _placeSizeHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DrawBuses(Graphics g)
|
|
||||||
{
|
|
||||||
int width = _pictureWidth / _placeSizeWidth;
|
|
||||||
int height = _pictureHeight / _placeSizeHeight;
|
|
||||||
|
|
||||||
int currentWidth = width - 1;
|
|
||||||
int currentHeight = 0;
|
|
||||||
|
|
||||||
foreach (var bus in _setBuses.GetBuses())
|
|
||||||
{
|
|
||||||
|
|
||||||
bus?.SetObject(currentWidth * _placeSizeWidth,
|
|
||||||
currentHeight * _placeSizeHeight,
|
|
||||||
_pictureWidth, _pictureHeight);
|
|
||||||
bus?.DrawingObject(g);
|
|
||||||
|
|
||||||
if (currentWidth > 0)
|
|
||||||
currentWidth--;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
currentWidth = width - 1;
|
|
||||||
currentHeight++;
|
|
||||||
}
|
|
||||||
if (currentHeight > height) return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
using DoubleDeckerBus;
|
|
||||||
|
|
||||||
namespace DoubleDeckerBus
|
|
||||||
{
|
|
||||||
internal class MapsCollection
|
|
||||||
{
|
|
||||||
|
|
||||||
readonly Dictionary<string, MapWithSetBusesGeneric<DrawingObjectBus, AbstractMap>> _mapStorages;
|
|
||||||
|
|
||||||
public List<string> Keys => _mapStorages.Keys.ToList();
|
|
||||||
|
|
||||||
private readonly int _pictureWidth;
|
|
||||||
|
|
||||||
private readonly int _pictureHeight;
|
|
||||||
|
|
||||||
public MapsCollection(int pictureWidth, int pictureHeight)
|
|
||||||
{
|
|
||||||
_mapStorages = new Dictionary<string, MapWithSetBusesGeneric<DrawingObjectBus, AbstractMap>>();
|
|
||||||
_pictureWidth = pictureWidth;
|
|
||||||
_pictureHeight = pictureHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddMap(string name, AbstractMap map)
|
|
||||||
{
|
|
||||||
if (Keys.Contains(name)) return;
|
|
||||||
_mapStorages.Add(name, new MapWithSetBusesGeneric<DrawingObjectBus, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DelMap(string name)
|
|
||||||
{
|
|
||||||
_mapStorages.Remove(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MapWithSetBusesGeneric<DrawingObjectBus, AbstractMap> this[string ind]
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
_mapStorages.TryGetValue(ind, out var result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,7 +11,7 @@ namespace DoubleDeckerBus
|
|||||||
// 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 FormMapWithSetBuses());
|
Application.Run(new FormMap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,72 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DoubleDeckerBus
|
|
||||||
{
|
|
||||||
internal class SetBusesGeneric<T>
|
|
||||||
where T : class
|
|
||||||
{
|
|
||||||
private readonly List<T> _places;
|
|
||||||
|
|
||||||
public int Count => _places.Count;
|
|
||||||
private int BusyPlaces = 0;
|
|
||||||
|
|
||||||
private readonly int _maxCount;
|
|
||||||
|
|
||||||
public SetBusesGeneric(int count)
|
|
||||||
{
|
|
||||||
_maxCount = count;
|
|
||||||
_places = new List<T>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Insert(T bus)
|
|
||||||
{
|
|
||||||
return Insert(bus, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Insert(T bus, int position)
|
|
||||||
{
|
|
||||||
if (position < 0 || position >= _maxCount || BusyPlaces == _maxCount) return -1;
|
|
||||||
|
|
||||||
BusyPlaces++;
|
|
||||||
_places.Insert(position, bus);
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T Remove(int position)
|
|
||||||
{
|
|
||||||
if (position < 0 || position >= _maxCount) return null;
|
|
||||||
T savedBus = _places[position];
|
|
||||||
_places.RemoveAt(position);
|
|
||||||
return savedBus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T this[int position] {
|
|
||||||
get {
|
|
||||||
if (position < 0 || position >= _maxCount) return null;
|
|
||||||
return _places[position];
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
Insert(value, position);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<T> GetBuses() {
|
|
||||||
foreach (var bus in _places)
|
|
||||||
{
|
|
||||||
if (bus != null)
|
|
||||||
{
|
|
||||||
yield return bus;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
yield break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user