Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
ffd4d75e98 | |||
ee27ff9217 | |||
4086d63f23 | |||
6e9dc087ef | |||
b9edbcd1dd | |||
51a21db2aa | |||
e8db2c1ab2 |
25
DoubleDeckerBus.sln
Normal file
25
DoubleDeckerBus.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.7.34024.191
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DoubleDeckerBus\DoubleDeckerBus", "DoubleDeckerBus\DoubleDeckerBus.csproj", "{2AA7FB83-8FC3-451D-B277-158CCA4DAE44}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{2AA7FB83-8FC3-451D-B277-158CCA4DAE44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2AA7FB83-8FC3-451D-B277-158CCA4DAE44}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2AA7FB83-8FC3-451D-B277-158CCA4DAE44}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2AA7FB83-8FC3-451D-B277-158CCA4DAE44}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {7F269221-EAB0-4961-A192-4F793DC88242}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
26
DoubleDeckerBus/DoubleDeckerBus.csproj
Normal file
26
DoubleDeckerBus/DoubleDeckerBus.csproj
Normal file
@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
148
DoubleDeckerBus/Drawing/DrawingBus.cs
Normal file
148
DoubleDeckerBus/Drawing/DrawingBus.cs
Normal file
@ -0,0 +1,148 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using DoubleDeckerbus.Entities;
|
||||
using DoubleDeckerbus.Move_Strategy;
|
||||
|
||||
namespace DoubleDeckerbus.Drawing
|
||||
{
|
||||
public class DrawingBus
|
||||
{
|
||||
public IMoveableObject GetMoveableObject => new DrawingObjectBus(this);
|
||||
public EntityBus? EntityBus { get; protected set; }
|
||||
public int _pictureWidth;
|
||||
public int _pictureHeight;
|
||||
protected int _startPosX;
|
||||
protected int _startPosY;
|
||||
protected readonly int _busWidth = 175;
|
||||
protected readonly int _busHeight = 115;
|
||||
public int GetPosX => _startPosX;
|
||||
public int GetPosY => _startPosY;
|
||||
public int GetWidth => _busWidth;
|
||||
public int GetHeight => _busHeight;
|
||||
public DrawingBus(int speed, double weight, Color bodyColor, int width, int height)
|
||||
{
|
||||
if (width < _busWidth || height < _busHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
EntityBus = new EntityBus(speed, weight, bodyColor);
|
||||
}
|
||||
protected DrawingBus(int speed, double weight, Color bodyColor, int width, int height, int busWidth, int busHeight)
|
||||
{
|
||||
if (width < _busWidth || height < _busHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
_busWidth = busWidth;
|
||||
_busHeight = busHeight;
|
||||
EntityBus = new EntityBus(speed, weight, bodyColor);
|
||||
}
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (x > _pictureWidth || y > _pictureHeight)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
public void MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (!CanMove(direction) || EntityBus == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
case DirectionType.Left:
|
||||
if (_startPosX - EntityBus.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityBus.Step;
|
||||
}
|
||||
break;
|
||||
case DirectionType.Up:
|
||||
if (_startPosY - EntityBus.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityBus.Step;
|
||||
}
|
||||
break;
|
||||
case DirectionType.Right:
|
||||
if (_startPosX + _busWidth + EntityBus.Step < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityBus.Step;
|
||||
}
|
||||
break;
|
||||
case DirectionType.Down:
|
||||
if (_startPosY + _busHeight + EntityBus.Step < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityBus.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
//
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
|
||||
Brush additionalBrush = new
|
||||
SolidBrush(EntityBus.BodyColor);
|
||||
|
||||
g.FillRectangle(additionalBrush, _startPosX + 147, _startPosY + 52, 21, 20);
|
||||
g.FillRectangle(additionalBrush, _startPosX + 147, _startPosY + 71, 30, 27);
|
||||
g.FillRectangle(additionalBrush, _startPosX + 10, _startPosY + 52, 137, 46);
|
||||
|
||||
Brush brBlue = new SolidBrush(Color.LightBlue);
|
||||
|
||||
g.FillRectangle(brBlue, _startPosX + 150, _startPosY + 55, 15, 15);
|
||||
|
||||
g.FillRectangle(brBlue, _startPosX + 42, _startPosY + 55, 15, 15);
|
||||
g.FillRectangle(brBlue, _startPosX + 69, _startPosY + 55, 15, 15);
|
||||
g.FillRectangle(brBlue, _startPosX + 96, _startPosY + 55, 15, 15);
|
||||
g.FillRectangle(brBlue, _startPosX + 123, _startPosY + 55, 15, 15);
|
||||
|
||||
|
||||
g.DrawLine(pen, _startPosX + 30, _startPosY + 52, _startPosX + 30, _startPosY + 98);
|
||||
g.DrawLine(pen, _startPosX + 35, _startPosY + 52, _startPosX + 35, _startPosY + 98);
|
||||
|
||||
Brush gr = new SolidBrush(Color.Gray);
|
||||
|
||||
g.FillEllipse(additionalBrush, _startPosX + 23, _startPosY + 88, 25, 25);
|
||||
g.FillEllipse(additionalBrush, _startPosX + 123, _startPosY + 88, 25, 25);
|
||||
|
||||
g.FillEllipse(gr, _startPosX + 25, _startPosY + 90, 21, 21);
|
||||
g.FillEllipse(gr, _startPosX + 125, _startPosY + 90, 21, 21);
|
||||
}
|
||||
|
||||
public bool CanMove(DirectionType direction)
|
||||
{
|
||||
if (EntityBus == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return direction switch
|
||||
{
|
||||
DirectionType.Left => _startPosX - EntityBus.Step > 0,
|
||||
DirectionType.Up => _startPosY - EntityBus.Step > 0,
|
||||
DirectionType.Right => _startPosX + _busWidth + EntityBus.Step < _pictureWidth,
|
||||
DirectionType.Down => _startPosY + _busHeight + EntityBus.Step < _pictureHeight,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
public void ChangeBordersPicture(int width, int height)
|
||||
{
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
}
|
||||
}
|
||||
}
|
61
DoubleDeckerBus/Drawing/DrawingDoubleDeckerbus.cs
Normal file
61
DoubleDeckerBus/Drawing/DrawingDoubleDeckerbus.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using DoubleDeckerbus.Entities;
|
||||
|
||||
namespace DoubleDeckerbus.Drawing
|
||||
{
|
||||
public class DrawingDoubleDeckerbus : DrawingBus
|
||||
{
|
||||
public DrawingDoubleDeckerbus(int speed, double weight, Color bodyColor, Color additionalColor, bool secondfloor, bool stairs, int width, int height) : base(speed, weight, bodyColor, width, height, 180, 110)
|
||||
{
|
||||
if (EntityBus != null)
|
||||
{
|
||||
EntityBus = new EntityDoubleDeckerbus(speed, weight, bodyColor, additionalColor, secondfloor, stairs);
|
||||
}
|
||||
|
||||
}
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityBus is not EntityDoubleDeckerbus doubleDeckerBus)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
Pen additionalPen = new(doubleDeckerBus.AddColor);
|
||||
Brush additionalBrush = new SolidBrush(doubleDeckerBus.AddColor);
|
||||
base.DrawTransport(g);
|
||||
|
||||
if (doubleDeckerBus.IsSecondFloor)
|
||||
{
|
||||
Brush additionalBrush2 = new SolidBrush(doubleDeckerBus.AddColor);
|
||||
Brush brBlue = new SolidBrush(Color.LightBlue);
|
||||
|
||||
g.FillRectangle(additionalBrush2, _startPosX + 7, _startPosY + 12, 172, 40);
|
||||
|
||||
g.DrawLine(pen, _startPosX + 7, _startPosY + 36, _startPosX + 178, _startPosY + 36);
|
||||
|
||||
g.FillRectangle(brBlue, _startPosX + 15, _startPosY + 15, 15, 15);
|
||||
g.FillRectangle(brBlue, _startPosX + 42, _startPosY + 15, 15, 15);
|
||||
g.FillRectangle(brBlue, _startPosX + 69, _startPosY + 15, 15, 15);
|
||||
g.FillRectangle(brBlue, _startPosX + 96, _startPosY + 15, 15, 15);
|
||||
g.FillRectangle(brBlue, _startPosX + 123, _startPosY + 15, 15, 15);
|
||||
g.FillRectangle(brBlue, _startPosX + 150, _startPosY + 15, 15, 15);
|
||||
}
|
||||
|
||||
if (doubleDeckerBus.IsStairs)
|
||||
{
|
||||
g.DrawLine(pen, _startPosX + 10, _startPosY + 55, _startPosX + 34, _startPosY + 55);
|
||||
g.DrawLine(pen, _startPosX + 10, _startPosY + 58, _startPosX + 34, _startPosY + 58);
|
||||
g.DrawLine(pen, _startPosX + 10, _startPosY + 64, _startPosX + 34, _startPosY + 64);
|
||||
g.DrawLine(pen, _startPosX + 10, _startPosY + 72, _startPosX + 34, _startPosY + 72);
|
||||
g.DrawLine(pen, _startPosX + 10, _startPosY + 80, _startPosX + 34, _startPosY + 80);
|
||||
g.DrawLine(pen, _startPosX + 10, _startPosY + 88, _startPosX + 34, _startPosY + 88);
|
||||
g.DrawLine(pen, _startPosX + 10, _startPosY + 94, _startPosX + 34, _startPosY + 94);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
49
DoubleDeckerBus/Drawing/ExtentionDrawingBus.cs
Normal file
49
DoubleDeckerBus/Drawing/ExtentionDrawingBus.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DoubleDeckerbus.Entities;
|
||||
|
||||
namespace DoubleDeckerbus.Drawing
|
||||
{
|
||||
public static class ExtentionDrawingBus
|
||||
{
|
||||
public static DrawingBus? CreateDrawingBus(this string info, char separatorForObject, int width, int height)
|
||||
{
|
||||
string[] strs = info.Split(separatorForObject);
|
||||
if (strs.Length == 3)
|
||||
{
|
||||
return new DrawingBus(
|
||||
Convert.ToInt32(strs[0]),
|
||||
Convert.ToInt32(strs[1]),
|
||||
Color.FromName(strs[2]), width, height);
|
||||
}
|
||||
if (strs.Length == 6)
|
||||
{
|
||||
return new DrawingDoubleDeckerbus(
|
||||
Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]),
|
||||
Color.FromName(strs[2]), Color.FromName(strs[3]),
|
||||
Convert.ToBoolean(strs[4]), Convert.ToBoolean(strs[5]),
|
||||
width, height);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetDataForSave(this DrawingBus DrawingBus, char separatorForObject)
|
||||
{
|
||||
var truck = DrawingBus.EntityBus;
|
||||
if (truck == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
var str = $"{truck.Speed}{separatorForObject}{truck.Weight}{separatorForObject}{truck.BodyColor.Name}";
|
||||
if (truck is not EntityDoubleDeckerbus DoubleDeckerBus)
|
||||
{
|
||||
return str;
|
||||
}
|
||||
return $"{str}{separatorForObject}{DoubleDeckerBus.AddColor.Name}{separatorForObject}{DoubleDeckerBus.IsSecondFloor}{separatorForObject}{DoubleDeckerBus.IsStairs}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
17
DoubleDeckerBus/Entities/DirectionType.cs
Normal file
17
DoubleDeckerBus/Entities/DirectionType.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DoubleDeckerbus.Entities
|
||||
{
|
||||
public enum DirectionType
|
||||
{
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
Left = 3,
|
||||
Right = 4
|
||||
|
||||
}
|
||||
}
|
27
DoubleDeckerBus/Entities/EntityBus.cs
Normal file
27
DoubleDeckerBus/Entities/EntityBus.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DoubleDeckerbus.Entities
|
||||
{
|
||||
public class EntityBus
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
public double Weight { get; private set; }
|
||||
public Color BodyColor { get; private set; }
|
||||
public double Step => (double)Speed * 100 / Weight;
|
||||
public EntityBus(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
|
||||
public void ChangeBodyColor(Color color)
|
||||
{
|
||||
BodyColor = color;
|
||||
}
|
||||
}
|
||||
}
|
28
DoubleDeckerBus/Entities/EntityDoubleDeckerbus.cs
Normal file
28
DoubleDeckerBus/Entities/EntityDoubleDeckerbus.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using DoubleDeckerbus.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DoubleDeckerbus.Entities
|
||||
{
|
||||
public class EntityDoubleDeckerbus : EntityBus
|
||||
{
|
||||
public Color AddColor { get; private set; }
|
||||
public bool IsSecondFloor { get; private set; }
|
||||
public bool IsStairs { get; private set; }
|
||||
|
||||
public EntityDoubleDeckerbus(int speed, double weight, Color bodyColor, Color additionalColor, bool secondfloor, bool stairs) : base(speed, weight, bodyColor)
|
||||
{
|
||||
AddColor = additionalColor;
|
||||
IsSecondFloor = secondfloor;
|
||||
IsStairs = stairs;
|
||||
}
|
||||
|
||||
public void ChangeAdditionalColor(Color additionalColor)
|
||||
{
|
||||
AddColor = additionalColor;
|
||||
}
|
||||
}
|
||||
}
|
403
DoubleDeckerBus/FormBusConfig.Designer.cs
generated
Normal file
403
DoubleDeckerBus/FormBusConfig.Designer.cs
generated
Normal file
@ -0,0 +1,403 @@
|
||||
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.labelAdvancedObject = new System.Windows.Forms.Label();
|
||||
this.labelSimpleObject = new System.Windows.Forms.Label();
|
||||
this.groupBoxColor = new System.Windows.Forms.GroupBox();
|
||||
this.panelBlue = new System.Windows.Forms.Panel();
|
||||
this.panelBlack = new System.Windows.Forms.Panel();
|
||||
this.panelPink = new System.Windows.Forms.Panel();
|
||||
this.panelGray = new System.Windows.Forms.Panel();
|
||||
this.panelGreen = new System.Windows.Forms.Panel();
|
||||
this.panelYellow = new System.Windows.Forms.Panel();
|
||||
this.panelRoyalBlue = new System.Windows.Forms.Panel();
|
||||
this.panelFirebrick = new System.Windows.Forms.Panel();
|
||||
this.checkBoxLadder = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoxSecondFloor = new System.Windows.Forms.CheckBox();
|
||||
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
|
||||
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
|
||||
this.labelWeight = new System.Windows.Forms.Label();
|
||||
this.labelSpeed = new System.Windows.Forms.Label();
|
||||
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
|
||||
this.panelObject = new System.Windows.Forms.Panel();
|
||||
this.labelAdditionalColor = new System.Windows.Forms.Label();
|
||||
this.labelMainColor = new System.Windows.Forms.Label();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.groupBoxConfig.SuspendLayout();
|
||||
this.groupBoxColor.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
|
||||
this.panelObject.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBoxConfig
|
||||
//
|
||||
this.groupBoxConfig.Controls.Add(this.labelAdvancedObject);
|
||||
this.groupBoxConfig.Controls.Add(this.labelSimpleObject);
|
||||
this.groupBoxConfig.Controls.Add(this.groupBoxColor);
|
||||
this.groupBoxConfig.Controls.Add(this.checkBoxLadder);
|
||||
this.groupBoxConfig.Controls.Add(this.checkBoxSecondFloor);
|
||||
this.groupBoxConfig.Controls.Add(this.numericUpDownSpeed);
|
||||
this.groupBoxConfig.Controls.Add(this.numericUpDownWeight);
|
||||
this.groupBoxConfig.Controls.Add(this.labelWeight);
|
||||
this.groupBoxConfig.Controls.Add(this.labelSpeed);
|
||||
this.groupBoxConfig.Location = new System.Drawing.Point(12, 36);
|
||||
this.groupBoxConfig.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.groupBoxConfig.Name = "groupBoxConfig";
|
||||
this.groupBoxConfig.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.groupBoxConfig.Size = new System.Drawing.Size(499, 188);
|
||||
this.groupBoxConfig.TabIndex = 0;
|
||||
this.groupBoxConfig.TabStop = false;
|
||||
this.groupBoxConfig.Text = "Параметры";
|
||||
//
|
||||
// labelAdvancedObject
|
||||
//
|
||||
this.labelAdvancedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelAdvancedObject.Location = new System.Drawing.Point(385, 141);
|
||||
this.labelAdvancedObject.Name = "labelAdvancedObject";
|
||||
this.labelAdvancedObject.Size = new System.Drawing.Size(105, 23);
|
||||
this.labelAdvancedObject.TabIndex = 8;
|
||||
this.labelAdvancedObject.Text = "Продвинутый";
|
||||
this.labelAdvancedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelAdvancedObject.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(248, 141);
|
||||
this.labelSimpleObject.Name = "labelSimpleObject";
|
||||
this.labelSimpleObject.Size = new System.Drawing.Size(105, 23);
|
||||
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);
|
||||
//
|
||||
// groupBoxColor
|
||||
//
|
||||
this.groupBoxColor.Controls.Add(this.panelBlue);
|
||||
this.groupBoxColor.Controls.Add(this.panelBlack);
|
||||
this.groupBoxColor.Controls.Add(this.panelPink);
|
||||
this.groupBoxColor.Controls.Add(this.panelGray);
|
||||
this.groupBoxColor.Controls.Add(this.panelGreen);
|
||||
this.groupBoxColor.Controls.Add(this.panelYellow);
|
||||
this.groupBoxColor.Controls.Add(this.panelRoyalBlue);
|
||||
this.groupBoxColor.Controls.Add(this.panelFirebrick);
|
||||
this.groupBoxColor.Location = new System.Drawing.Point(248, 24);
|
||||
this.groupBoxColor.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.groupBoxColor.Name = "groupBoxColor";
|
||||
this.groupBoxColor.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.groupBoxColor.Size = new System.Drawing.Size(242, 109);
|
||||
this.groupBoxColor.TabIndex = 6;
|
||||
this.groupBoxColor.TabStop = false;
|
||||
this.groupBoxColor.Text = "Цвета";
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
this.panelBlue.BackColor = System.Drawing.Color.Blue;
|
||||
this.panelBlue.Location = new System.Drawing.Point(4, 64);
|
||||
this.panelBlue.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.panelBlue.Name = "panelBlue";
|
||||
this.panelBlue.Size = new System.Drawing.Size(44, 30);
|
||||
this.panelBlue.TabIndex = 0;
|
||||
//
|
||||
// panelBlack
|
||||
//
|
||||
this.panelBlack.BackColor = System.Drawing.Color.Black;
|
||||
this.panelBlack.Location = new System.Drawing.Point(66, 64);
|
||||
this.panelBlack.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.panelBlack.Name = "panelBlack";
|
||||
this.panelBlack.Size = new System.Drawing.Size(44, 30);
|
||||
this.panelBlack.TabIndex = 0;
|
||||
//
|
||||
// panelPink
|
||||
//
|
||||
this.panelPink.BackColor = System.Drawing.Color.DeepPink;
|
||||
this.panelPink.Location = new System.Drawing.Point(127, 64);
|
||||
this.panelPink.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.panelPink.Name = "panelPink";
|
||||
this.panelPink.Size = new System.Drawing.Size(44, 30);
|
||||
this.panelPink.TabIndex = 0;
|
||||
//
|
||||
// panelGray
|
||||
//
|
||||
this.panelGray.BackColor = System.Drawing.Color.Gray;
|
||||
this.panelGray.Location = new System.Drawing.Point(188, 64);
|
||||
this.panelGray.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.panelGray.Name = "panelGray";
|
||||
this.panelGray.Size = new System.Drawing.Size(44, 30);
|
||||
this.panelGray.TabIndex = 0;
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
this.panelGreen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
|
||||
this.panelGreen.Location = new System.Drawing.Point(188, 19);
|
||||
this.panelGreen.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.panelGreen.Name = "panelGreen";
|
||||
this.panelGreen.Size = new System.Drawing.Size(44, 30);
|
||||
this.panelGreen.TabIndex = 0;
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
|
||||
this.panelYellow.Location = new System.Drawing.Point(127, 19);
|
||||
this.panelYellow.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.panelYellow.Name = "panelYellow";
|
||||
this.panelYellow.Size = new System.Drawing.Size(44, 30);
|
||||
this.panelYellow.TabIndex = 0;
|
||||
//
|
||||
// panelRoyalBlue
|
||||
//
|
||||
this.panelRoyalBlue.BackColor = System.Drawing.Color.RoyalBlue;
|
||||
this.panelRoyalBlue.Location = new System.Drawing.Point(66, 19);
|
||||
this.panelRoyalBlue.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.panelRoyalBlue.Name = "panelRoyalBlue";
|
||||
this.panelRoyalBlue.Size = new System.Drawing.Size(44, 30);
|
||||
this.panelRoyalBlue.TabIndex = 0;
|
||||
//
|
||||
// panelFirebrick
|
||||
//
|
||||
this.panelFirebrick.BackColor = System.Drawing.Color.Firebrick;
|
||||
this.panelFirebrick.Location = new System.Drawing.Point(4, 19);
|
||||
this.panelFirebrick.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.panelFirebrick.Name = "panelFirebrick";
|
||||
this.panelFirebrick.Size = new System.Drawing.Size(44, 30);
|
||||
this.panelFirebrick.TabIndex = 0;
|
||||
//
|
||||
// checkBoxLadder
|
||||
//
|
||||
this.checkBoxLadder.AutoSize = true;
|
||||
this.checkBoxLadder.Location = new System.Drawing.Point(11, 112);
|
||||
this.checkBoxLadder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.checkBoxLadder.Name = "checkBoxLadder";
|
||||
this.checkBoxLadder.Size = new System.Drawing.Size(129, 19);
|
||||
this.checkBoxLadder.TabIndex = 5;
|
||||
this.checkBoxLadder.Text = "Наличие лестница";
|
||||
this.checkBoxLadder.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxSecondFloor
|
||||
//
|
||||
this.checkBoxSecondFloor.AutoSize = true;
|
||||
this.checkBoxSecondFloor.Location = new System.Drawing.Point(11, 89);
|
||||
this.checkBoxSecondFloor.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.checkBoxSecondFloor.Name = "checkBoxSecondFloor";
|
||||
this.checkBoxSecondFloor.Size = new System.Drawing.Size(157, 19);
|
||||
this.checkBoxSecondFloor.TabIndex = 4;
|
||||
this.checkBoxSecondFloor.Text = "Наличие второго этажа";
|
||||
this.checkBoxSecondFloor.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
this.numericUpDownSpeed.Location = new System.Drawing.Point(82, 24);
|
||||
this.numericUpDownSpeed.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.numericUpDownSpeed.Maximum = new decimal(new int[] {
|
||||
1000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownSpeed.Minimum = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||
this.numericUpDownSpeed.Size = new System.Drawing.Size(131, 23);
|
||||
this.numericUpDownSpeed.TabIndex = 3;
|
||||
this.numericUpDownSpeed.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
this.numericUpDownWeight.Location = new System.Drawing.Point(82, 62);
|
||||
this.numericUpDownWeight.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.numericUpDownWeight.Maximum = new decimal(new int[] {
|
||||
1000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownWeight.Minimum = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownWeight.Name = "numericUpDownWeight";
|
||||
this.numericUpDownWeight.Size = new System.Drawing.Size(131, 23);
|
||||
this.numericUpDownWeight.TabIndex = 2;
|
||||
this.numericUpDownWeight.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// labelWeight
|
||||
//
|
||||
this.labelWeight.AutoSize = true;
|
||||
this.labelWeight.Location = new System.Drawing.Point(5, 64);
|
||||
this.labelWeight.Name = "labelWeight";
|
||||
this.labelWeight.Size = new System.Drawing.Size(29, 15);
|
||||
this.labelWeight.TabIndex = 1;
|
||||
this.labelWeight.Text = "Вес:";
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
this.labelSpeed.AutoSize = true;
|
||||
this.labelSpeed.Location = new System.Drawing.Point(5, 24);
|
||||
this.labelSpeed.Name = "labelSpeed";
|
||||
this.labelSpeed.Size = new System.Drawing.Size(62, 15);
|
||||
this.labelSpeed.TabIndex = 0;
|
||||
this.labelSpeed.Text = "Скорость:";
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
this.pictureBoxObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.pictureBoxObject.Location = new System.Drawing.Point(31, 63);
|
||||
this.pictureBoxObject.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.pictureBoxObject.Name = "pictureBoxObject";
|
||||
this.pictureBoxObject.Size = new System.Drawing.Size(286, 154);
|
||||
this.pictureBoxObject.TabIndex = 1;
|
||||
this.pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// panelObject
|
||||
//
|
||||
this.panelObject.AllowDrop = true;
|
||||
this.panelObject.Controls.Add(this.labelAdditionalColor);
|
||||
this.panelObject.Controls.Add(this.labelMainColor);
|
||||
this.panelObject.Controls.Add(this.pictureBoxObject);
|
||||
this.panelObject.Location = new System.Drawing.Point(536, 22);
|
||||
this.panelObject.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.panelObject.Name = "panelObject";
|
||||
this.panelObject.Size = new System.Drawing.Size(351, 226);
|
||||
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);
|
||||
//
|
||||
// labelAdditionalColor
|
||||
//
|
||||
this.labelAdditionalColor.AllowDrop = true;
|
||||
this.labelAdditionalColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelAdditionalColor.Location = new System.Drawing.Point(204, 14);
|
||||
this.labelAdditionalColor.Name = "labelAdditionalColor";
|
||||
this.labelAdditionalColor.Size = new System.Drawing.Size(79, 38);
|
||||
this.labelAdditionalColor.TabIndex = 3;
|
||||
this.labelAdditionalColor.Text = "Доп. цвет";
|
||||
this.labelAdditionalColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelAdditionalColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelAdditionalColor_DragDrop);
|
||||
this.labelAdditionalColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelAdditionalColor_DragEnter);
|
||||
//
|
||||
// labelMainColor
|
||||
//
|
||||
this.labelMainColor.AllowDrop = true;
|
||||
this.labelMainColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelMainColor.Location = new System.Drawing.Point(67, 14);
|
||||
this.labelMainColor.Name = "labelMainColor";
|
||||
this.labelMainColor.Size = new System.Drawing.Size(79, 38);
|
||||
this.labelMainColor.TabIndex = 2;
|
||||
this.labelMainColor.Text = "Цвет";
|
||||
this.labelMainColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelMainColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelMainColor_DragDrop);
|
||||
this.labelMainColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelMainColor_DragEnter);
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(603, 253);
|
||||
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(82, 22);
|
||||
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(740, 254);
|
||||
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(82, 22);
|
||||
this.buttonCancel.TabIndex = 4;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormBusConfig
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(903, 287);
|
||||
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, 2, 3, 2);
|
||||
this.Name = "FormBusConfig";
|
||||
this.Text = "FormBusConfig";
|
||||
this.groupBoxConfig.ResumeLayout(false);
|
||||
this.groupBoxConfig.PerformLayout();
|
||||
this.groupBoxColor.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
|
||||
this.panelObject.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxConfig;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private Label labelWeight;
|
||||
private Label labelSpeed;
|
||||
private CheckBox checkBoxLadder;
|
||||
private CheckBox checkBoxSecondFloor;
|
||||
private GroupBox groupBoxColor;
|
||||
private Panel panelBlue;
|
||||
private Panel panelBlack;
|
||||
private Panel panelPink;
|
||||
private Panel panelGray;
|
||||
private Panel panelGreen;
|
||||
private Panel panelYellow;
|
||||
private Panel panelRoyalBlue;
|
||||
private Panel panelFirebrick;
|
||||
private Label labelAdvancedObject;
|
||||
private Label labelSimpleObject;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Panel panelObject;
|
||||
private Label labelAdditionalColor;
|
||||
private Label labelMainColor;
|
||||
private Button buttonAdd;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
145
DoubleDeckerBus/FormBusConfig.cs
Normal file
145
DoubleDeckerBus/FormBusConfig.cs
Normal file
@ -0,0 +1,145 @@
|
||||
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 DoubleDeckerbus.Drawing;
|
||||
using DoubleDeckerbus.Entities;
|
||||
|
||||
namespace DoubleDeckerbus
|
||||
{
|
||||
public partial class FormBusConfig : Form
|
||||
{
|
||||
|
||||
DrawingBus? _bus = null;
|
||||
private event Action<DrawingBus>? EventAddBus;
|
||||
public FormBusConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelFirebrick.MouseDown += PanelColor_MouseDown;
|
||||
panelRoyalBlue.MouseDown += PanelColor_MouseDown;
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||
panelPink.MouseDown += PanelColor_MouseDown;
|
||||
panelGray.MouseDown += PanelColor_MouseDown;
|
||||
buttonCancel.Click += (s, e) => Close();
|
||||
}
|
||||
private void DrawBus()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_bus?.SetPosition(5, 5);
|
||||
_bus?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
public void AddEvent(Action<DrawingBus> ev)
|
||||
{
|
||||
if (EventAddBus == null)
|
||||
{
|
||||
EventAddBus = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddBus += ev;
|
||||
}
|
||||
}
|
||||
|
||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name,
|
||||
DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||
{
|
||||
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,
|
||||
Color.White,
|
||||
pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
break;
|
||||
|
||||
case "labelAdvancedObject":
|
||||
_bus = new DrawingDoubleDeckerbus(
|
||||
(int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value,
|
||||
Color.White, Color.Black,
|
||||
checkBoxSecondFloor.Checked, checkBoxLadder.Checked,
|
||||
pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
break;
|
||||
}
|
||||
DrawBus();
|
||||
}
|
||||
|
||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
|
||||
DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
private void LabelMainColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)) && _bus != null)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void LabelMainColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
var color = (Color)e.Data.GetData(typeof(Color));
|
||||
_bus.EntityBus.ChangeBodyColor(color);
|
||||
DrawBus();
|
||||
}
|
||||
|
||||
private void LabelAdditionalColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)) && _bus != null && _bus is DrawingDoubleDeckerbus)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
private void LabelAdditionalColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
var color = (Color)e.Data.GetData(typeof(Color));
|
||||
|
||||
EntityDoubleDeckerbus? _doubledeckerbus = _bus.EntityBus as EntityDoubleDeckerbus;
|
||||
_doubledeckerbus.ChangeAdditionalColor(color);
|
||||
DrawBus();
|
||||
}
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddBus?.Invoke(_bus);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
DoubleDeckerBus/FormBusConfig.resx
Normal file
120
DoubleDeckerBus/FormBusConfig.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?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>
|
198
DoubleDeckerBus/FormDoubleDeckerBus.Designer.cs
generated
Normal file
198
DoubleDeckerBus/FormDoubleDeckerBus.Designer.cs
generated
Normal file
@ -0,0 +1,198 @@
|
||||
namespace DoubleDeckerbus
|
||||
{
|
||||
partial class FormDoubleDeckerbus
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
pictureBoxDoubleDeckerbus = new PictureBox();
|
||||
DoubleDeckerbus = new Button();
|
||||
buttonUp = new Button();
|
||||
buttonLeft = new Button();
|
||||
buttonDown = new Button();
|
||||
buttonRight = new Button();
|
||||
comboBoxStrategy = new ComboBox();
|
||||
buttonStep = new Button();
|
||||
buttonCreateBus = new Button();
|
||||
buttonSelect = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxDoubleDeckerbus).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBoxDoubleDeckerbus
|
||||
//
|
||||
pictureBoxDoubleDeckerbus.Dock = DockStyle.Fill;
|
||||
pictureBoxDoubleDeckerbus.Location = new Point(0, 0);
|
||||
pictureBoxDoubleDeckerbus.Margin = new Padding(3, 2, 3, 2);
|
||||
pictureBoxDoubleDeckerbus.Name = "pictureBoxDoubleDeckerbus";
|
||||
pictureBoxDoubleDeckerbus.Size = new Size(772, 340);
|
||||
pictureBoxDoubleDeckerbus.TabIndex = 5;
|
||||
pictureBoxDoubleDeckerbus.TabStop = false;
|
||||
//
|
||||
// DoubleDeckerbus
|
||||
//
|
||||
DoubleDeckerbus.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
DoubleDeckerbus.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
DoubleDeckerbus.Location = new Point(10, 274);
|
||||
DoubleDeckerbus.Margin = new Padding(3, 2, 3, 2);
|
||||
DoubleDeckerbus.Name = "DoubleDeckerbus";
|
||||
DoubleDeckerbus.Size = new Size(105, 55);
|
||||
DoubleDeckerbus.TabIndex = 6;
|
||||
DoubleDeckerbus.Text = "Создать Двухэтажный автобус";
|
||||
DoubleDeckerbus.UseVisualStyleBackColor = true;
|
||||
DoubleDeckerbus.Click += buttonCreateDoubleDeckerbus_Click;
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonUp.Location = new Point(710, 283);
|
||||
buttonUp.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonUp.Name = "buttonUp";
|
||||
buttonUp.Size = new Size(26, 22);
|
||||
buttonUp.TabIndex = 7;
|
||||
buttonUp.UseVisualStyleBackColor = true;
|
||||
buttonUp.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonLeft.Location = new Point(679, 310);
|
||||
buttonLeft.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonLeft.Name = "buttonLeft";
|
||||
buttonLeft.Size = new Size(26, 22);
|
||||
buttonLeft.TabIndex = 8;
|
||||
buttonLeft.UseVisualStyleBackColor = true;
|
||||
buttonLeft.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonDown.Location = new Point(710, 310);
|
||||
buttonDown.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonDown.Name = "buttonDown";
|
||||
buttonDown.Size = new Size(26, 22);
|
||||
buttonDown.TabIndex = 9;
|
||||
buttonDown.UseVisualStyleBackColor = true;
|
||||
buttonDown.Click += buttonMove_Click;
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
buttonRight.Location = new Point(742, 310);
|
||||
buttonRight.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonRight.Name = "buttonRight";
|
||||
buttonRight.Size = new Size(26, 22);
|
||||
buttonRight.TabIndex = 10;
|
||||
buttonRight.UseVisualStyleBackColor = true;
|
||||
buttonRight.Click += buttonMove_Click;
|
||||
//
|
||||
// comboBoxStrategy
|
||||
//
|
||||
comboBoxStrategy.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxStrategy.FormattingEnabled = true;
|
||||
comboBoxStrategy.Items.AddRange(new object[] { "В центр", "В правый нижний угол" });
|
||||
comboBoxStrategy.Location = new Point(629, 9);
|
||||
comboBoxStrategy.Margin = new Padding(3, 2, 3, 2);
|
||||
comboBoxStrategy.Name = "comboBoxStrategy";
|
||||
comboBoxStrategy.Size = new Size(133, 23);
|
||||
comboBoxStrategy.TabIndex = 11;
|
||||
//
|
||||
// buttonStep
|
||||
//
|
||||
buttonStep.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
buttonStep.Location = new Point(654, 34);
|
||||
buttonStep.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonStep.Name = "buttonStep";
|
||||
buttonStep.Size = new Size(82, 22);
|
||||
buttonStep.TabIndex = 12;
|
||||
buttonStep.Text = "Шаг";
|
||||
buttonStep.UseVisualStyleBackColor = true;
|
||||
buttonStep.Click += buttonStep_Click;
|
||||
//
|
||||
// buttonCreateBus
|
||||
//
|
||||
buttonCreateBus.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreateBus.Location = new Point(121, 291);
|
||||
buttonCreateBus.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonCreateBus.Name = "buttonCreateBus";
|
||||
buttonCreateBus.Size = new Size(105, 38);
|
||||
buttonCreateBus.TabIndex = 13;
|
||||
buttonCreateBus.Text = "Создать автобус";
|
||||
buttonCreateBus.UseVisualStyleBackColor = true;
|
||||
buttonCreateBus.Click += buttonCreateBus_Click;
|
||||
//
|
||||
// buttonSelect
|
||||
//
|
||||
buttonSelect.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonSelect.Location = new Point(239, 274);
|
||||
buttonSelect.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonSelect.Name = "buttonSelect";
|
||||
buttonSelect.Size = new Size(105, 55);
|
||||
buttonSelect.TabIndex = 14;
|
||||
buttonSelect.Text = "Выбрать автобус";
|
||||
buttonSelect.UseVisualStyleBackColor = true;
|
||||
buttonSelect.Click += ButtonSelectBus_Click;
|
||||
//
|
||||
// FormDoubleDeckerbus
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(772, 340);
|
||||
Controls.Add(buttonSelect);
|
||||
Controls.Add(buttonCreateBus);
|
||||
Controls.Add(buttonStep);
|
||||
Controls.Add(comboBoxStrategy);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(DoubleDeckerbus);
|
||||
Controls.Add(pictureBoxDoubleDeckerbus);
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormDoubleDeckerbus";
|
||||
Text = "Автобус";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxDoubleDeckerbus).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxDoubleDeckerbus;
|
||||
private Button DoubleDeckerbus;
|
||||
private Button buttonUp;
|
||||
private Button buttonLeft;
|
||||
private Button buttonDown;
|
||||
private Button buttonRight;
|
||||
private ComboBox comboBoxStrategy;
|
||||
private Button buttonStep;
|
||||
private Button buttonCreateBus;
|
||||
private Button buttonSelect;
|
||||
}
|
||||
}
|
136
DoubleDeckerBus/FormDoubleDeckerBus.cs
Normal file
136
DoubleDeckerBus/FormDoubleDeckerBus.cs
Normal file
@ -0,0 +1,136 @@
|
||||
using DoubleDeckerbus.Drawing;
|
||||
using DoubleDeckerbus.Entities;
|
||||
using DoubleDeckerbus.Move_Strategy;
|
||||
|
||||
namespace DoubleDeckerbus
|
||||
{
|
||||
public partial class FormDoubleDeckerbus : Form
|
||||
{
|
||||
private DrawingBus? _drawingBus;
|
||||
private AbstractStrategy? _abstractStrategy;
|
||||
public DrawingBus? SelectedBus { get; private set; }
|
||||
|
||||
public FormDoubleDeckerbus()
|
||||
{
|
||||
InitializeComponent();
|
||||
_abstractStrategy = null;
|
||||
SelectedBus = null;
|
||||
}
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawingBus == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bitmap bmp = new(pictureBoxDoubleDeckerbus.Width, pictureBoxDoubleDeckerbus.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawingBus.DrawTransport(gr);
|
||||
pictureBoxDoubleDeckerbus.Image = bmp;
|
||||
|
||||
}
|
||||
private void buttonCreateDoubleDeckerbus_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
Color color = Color.FromArgb(random.Next(0, 256),
|
||||
random.Next(0, 256), random.Next(0, 256));
|
||||
Color color1 = Color.FromArgb(random.Next(0, 256),
|
||||
random.Next(0, 256), random.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
ColorDialog dialog1 = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK && dialog1.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialog.Color;
|
||||
color1 = dialog1.Color;
|
||||
}
|
||||
_drawingBus = new DrawingDoubleDeckerbus(random.Next(100, 300),
|
||||
random.Next(1000, 3000), color, color1, true, true,
|
||||
pictureBoxDoubleDeckerbus.Width, pictureBoxDoubleDeckerbus.Height);
|
||||
_drawingBus.SetPosition(random.Next(10, 100), random.Next(10,
|
||||
100));
|
||||
Draw();
|
||||
|
||||
}
|
||||
private void buttonCreateBus_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;
|
||||
}
|
||||
|
||||
_drawingBus = new DrawingBus(random.Next(100, 300),
|
||||
random.Next(1000, 3000), color,
|
||||
pictureBoxDoubleDeckerbus.Width, pictureBoxDoubleDeckerbus.Height);
|
||||
_drawingBus.SetPosition(random.Next(10, 100), random.Next(10,100));
|
||||
Draw();
|
||||
|
||||
|
||||
}
|
||||
private void buttonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawingBus == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
_drawingBus.MoveTransport(DirectionType.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
_drawingBus.MoveTransport(DirectionType.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
_drawingBus.MoveTransport(DirectionType.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
_drawingBus.MoveTransport(DirectionType.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
private void buttonStep_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawingBus == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (comboBoxStrategy.Enabled)
|
||||
{
|
||||
_abstractStrategy = comboBoxStrategy.SelectedIndex
|
||||
switch
|
||||
{
|
||||
0 => new MoveToCenter(),
|
||||
1 => new MoveToBorder(),
|
||||
_ => null,
|
||||
};
|
||||
if (_abstractStrategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_abstractStrategy.SetData(new DrawingObjectBus(_drawingBus), pictureBoxDoubleDeckerbus.Width, pictureBoxDoubleDeckerbus.Height);
|
||||
comboBoxStrategy.Enabled = false;
|
||||
}
|
||||
if (_abstractStrategy == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_abstractStrategy.MakeStep();
|
||||
Draw();
|
||||
if (_abstractStrategy.GetStatus() == Status.Finish)
|
||||
{
|
||||
comboBoxStrategy.Enabled = true;
|
||||
_abstractStrategy = null;
|
||||
}
|
||||
}
|
||||
private void ButtonSelectBus_Click(object sender, EventArgs e)
|
||||
{
|
||||
SelectedBus = _drawingBus;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
}
|
2817
DoubleDeckerBus/FormDoubleDeckerBus.resx
Normal file
2817
DoubleDeckerBus/FormDoubleDeckerBus.resx
Normal file
File diff suppressed because it is too large
Load Diff
259
DoubleDeckerBus/FormDoubleDeckerbusCollection.Designer.cs
generated
Normal file
259
DoubleDeckerBus/FormDoubleDeckerbusCollection.Designer.cs
generated
Normal file
@ -0,0 +1,259 @@
|
||||
namespace DoubleDeckerbus
|
||||
{
|
||||
partial class FormDoubleDeckerbusCollection
|
||||
{
|
||||
/// <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.buttonAddBus = new System.Windows.Forms.Button();
|
||||
this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
|
||||
this.labelInstruments = new System.Windows.Forms.Label();
|
||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||
this.buttonDeleteBus = new System.Windows.Forms.Button();
|
||||
this.colorDialog = new System.Windows.Forms.ColorDialog();
|
||||
this.maskedTextBoxNumber = new System.Windows.Forms.MaskedTextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.listBoxStorages = new System.Windows.Forms.ListBox();
|
||||
this.buttonAddStorage = new System.Windows.Forms.Button();
|
||||
this.buttonDeleteStorage = new System.Windows.Forms.Button();
|
||||
this.textBoxStorageName = new System.Windows.Forms.TextBox();
|
||||
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.toolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.loadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
|
||||
this.menuStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonAddBus
|
||||
//
|
||||
this.buttonAddBus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonAddBus.Location = new System.Drawing.Point(859, 331);
|
||||
this.buttonAddBus.Name = "buttonAddBus";
|
||||
this.buttonAddBus.Size = new System.Drawing.Size(118, 28);
|
||||
this.buttonAddBus.TabIndex = 0;
|
||||
this.buttonAddBus.Text = "Добавить автобус";
|
||||
this.buttonAddBus.UseVisualStyleBackColor = true;
|
||||
this.buttonAddBus.Click += new System.EventHandler(this.buttonAddBus_Click);
|
||||
//
|
||||
// pictureBoxCollection
|
||||
//
|
||||
this.pictureBoxCollection.Location = new System.Drawing.Point(0, 20);
|
||||
this.pictureBoxCollection.Name = "pictureBoxCollection";
|
||||
this.pictureBoxCollection.Size = new System.Drawing.Size(830, 475);
|
||||
this.pictureBoxCollection.TabIndex = 1;
|
||||
this.pictureBoxCollection.TabStop = false;
|
||||
//
|
||||
// labelInstruments
|
||||
//
|
||||
this.labelInstruments.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.labelInstruments.AutoSize = true;
|
||||
this.labelInstruments.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.labelInstruments.Location = new System.Drawing.Point(859, 0);
|
||||
this.labelInstruments.Name = "labelInstruments";
|
||||
this.labelInstruments.Size = new System.Drawing.Size(108, 21);
|
||||
this.labelInstruments.TabIndex = 2;
|
||||
this.labelInstruments.Text = "Инструменты";
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
this.buttonUpdate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonUpdate.Location = new System.Drawing.Point(851, 130);
|
||||
this.buttonUpdate.Name = "buttonUpdate";
|
||||
this.buttonUpdate.Size = new System.Drawing.Size(131, 25);
|
||||
this.buttonUpdate.TabIndex = 3;
|
||||
this.buttonUpdate.Text = "Обновить набор";
|
||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
|
||||
//
|
||||
// buttonDeleteBus
|
||||
//
|
||||
this.buttonDeleteBus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonDeleteBus.Location = new System.Drawing.Point(859, 394);
|
||||
this.buttonDeleteBus.Name = "buttonDeleteBus";
|
||||
this.buttonDeleteBus.Size = new System.Drawing.Size(118, 28);
|
||||
this.buttonDeleteBus.TabIndex = 4;
|
||||
this.buttonDeleteBus.Text = "Удалить автобус";
|
||||
this.buttonDeleteBus.UseVisualStyleBackColor = true;
|
||||
this.buttonDeleteBus.Click += new System.EventHandler(this.buttonDeleteBus_Click);
|
||||
//
|
||||
// maskedTextBoxNumber
|
||||
//
|
||||
this.maskedTextBoxNumber.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.maskedTextBoxNumber.Location = new System.Drawing.Point(851, 365);
|
||||
this.maskedTextBoxNumber.Mask = "00";
|
||||
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||
this.maskedTextBoxNumber.Size = new System.Drawing.Size(138, 23);
|
||||
this.maskedTextBoxNumber.TabIndex = 5;
|
||||
this.maskedTextBoxNumber.ValidatingType = typeof(int);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(851, 38);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(52, 15);
|
||||
this.label1.TabIndex = 7;
|
||||
this.label1.Text = "Наборы";
|
||||
//
|
||||
// listBoxStorages
|
||||
//
|
||||
this.listBoxStorages.FormattingEnabled = true;
|
||||
this.listBoxStorages.ItemHeight = 15;
|
||||
this.listBoxStorages.Location = new System.Drawing.Point(850, 160);
|
||||
this.listBoxStorages.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.listBoxStorages.Name = "listBoxStorages";
|
||||
this.listBoxStorages.Size = new System.Drawing.Size(132, 109);
|
||||
this.listBoxStorages.TabIndex = 8;
|
||||
this.listBoxStorages.SelectedIndexChanged += new System.EventHandler(this.listBoxObjects_SelectedIndexChanged);
|
||||
//
|
||||
// buttonAddStorage
|
||||
//
|
||||
this.buttonAddStorage.Location = new System.Drawing.Point(850, 102);
|
||||
this.buttonAddStorage.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonAddStorage.Name = "buttonAddStorage";
|
||||
this.buttonAddStorage.Size = new System.Drawing.Size(131, 25);
|
||||
this.buttonAddStorage.TabIndex = 9;
|
||||
this.buttonAddStorage.Text = "Добавить набор";
|
||||
this.buttonAddStorage.UseVisualStyleBackColor = true;
|
||||
this.buttonAddStorage.Click += new System.EventHandler(this.buttonAddStorage_Click);
|
||||
//
|
||||
// buttonDeleteStorage
|
||||
//
|
||||
this.buttonDeleteStorage.Location = new System.Drawing.Point(850, 273);
|
||||
this.buttonDeleteStorage.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonDeleteStorage.Name = "buttonDeleteStorage";
|
||||
this.buttonDeleteStorage.Size = new System.Drawing.Size(131, 25);
|
||||
this.buttonDeleteStorage.TabIndex = 10;
|
||||
this.buttonDeleteStorage.Text = "Удалить набор";
|
||||
this.buttonDeleteStorage.UseVisualStyleBackColor = true;
|
||||
this.buttonDeleteStorage.Click += new System.EventHandler(this.buttonDeleteStorage_Click);
|
||||
//
|
||||
// textBoxStorageName
|
||||
//
|
||||
this.textBoxStorageName.Location = new System.Drawing.Point(850, 77);
|
||||
this.textBoxStorageName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.textBoxStorageName.Name = "textBoxStorageName";
|
||||
this.textBoxStorageName.Size = new System.Drawing.Size(132, 23);
|
||||
this.textBoxStorageName.TabIndex = 11;
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripMenuItem});
|
||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2);
|
||||
this.menuStrip.Size = new System.Drawing.Size(1003, 24);
|
||||
this.menuStrip.TabIndex = 12;
|
||||
this.menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// toolStripMenuItem
|
||||
//
|
||||
this.toolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.saveToolStripMenuItem,
|
||||
this.loadToolStripMenuItem});
|
||||
this.toolStripMenuItem.Name = "toolStripMenuItem";
|
||||
this.toolStripMenuItem.Size = new System.Drawing.Size(48, 20);
|
||||
this.toolStripMenuItem.Text = "Файл";
|
||||
//
|
||||
// saveToolStripMenuItem
|
||||
//
|
||||
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||
this.saveToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.saveToolStripMenuItem.Text = "Сохранить";
|
||||
this.saveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click);
|
||||
//
|
||||
// loadToolStripMenuItem
|
||||
//
|
||||
this.loadToolStripMenuItem.Name = "loadToolStripMenuItem";
|
||||
this.loadToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.loadToolStripMenuItem.Text = "Загрузить";
|
||||
this.loadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click);
|
||||
//
|
||||
// saveFileDialog
|
||||
//
|
||||
this.saveFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
this.openFileDialog.FileName = "openFileDialog1";
|
||||
this.openFileDialog.Filter = "txt file | *.txt";
|
||||
//
|
||||
// FormDoubleDeckerbusCollection
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1003, 504);
|
||||
this.Controls.Add(this.textBoxStorageName);
|
||||
this.Controls.Add(this.buttonDeleteStorage);
|
||||
this.Controls.Add(this.buttonAddStorage);
|
||||
this.Controls.Add(this.listBoxStorages);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.buttonAddBus);
|
||||
this.Controls.Add(this.maskedTextBoxNumber);
|
||||
this.Controls.Add(this.buttonDeleteBus);
|
||||
this.Controls.Add(this.buttonUpdate);
|
||||
this.Controls.Add(this.labelInstruments);
|
||||
this.Controls.Add(this.pictureBoxCollection);
|
||||
this.Controls.Add(this.menuStrip);
|
||||
this.MainMenuStrip = this.menuStrip;
|
||||
this.Name = "FormDoubleDeckerbusCollection";
|
||||
this.Text = "Набор автобусов";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
|
||||
this.menuStrip.ResumeLayout(false);
|
||||
this.menuStrip.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonAddBus;
|
||||
private PictureBox pictureBoxCollection;
|
||||
private Label labelInstruments;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonDeleteBus;
|
||||
private ColorDialog colorDialog;
|
||||
private MaskedTextBox maskedTextBoxNumber;
|
||||
private Label label1;
|
||||
private ListBox listBoxStorages;
|
||||
private Button buttonAddStorage;
|
||||
private Button buttonDeleteStorage;
|
||||
private TextBox textBoxStorageName;
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem toolStripMenuItem;
|
||||
private ToolStripMenuItem saveToolStripMenuItem;
|
||||
private ToolStripMenuItem loadToolStripMenuItem;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
private OpenFileDialog openFileDialog;
|
||||
}
|
||||
}
|
184
DoubleDeckerBus/FormDoubleDeckerbusCollection.cs
Normal file
184
DoubleDeckerBus/FormDoubleDeckerbusCollection.cs
Normal file
@ -0,0 +1,184 @@
|
||||
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 DoubleDeckerbus.Generic;
|
||||
using DoubleDeckerbus.Drawing;
|
||||
using DoubleDeckerbus.Move_Strategy;
|
||||
|
||||
|
||||
namespace DoubleDeckerbus
|
||||
{
|
||||
public partial class FormDoubleDeckerbusCollection : Form
|
||||
{
|
||||
private readonly BusesGenericStorage _storage;
|
||||
|
||||
public FormDoubleDeckerbusCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
_storage = new BusesGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
}
|
||||
private void ReloadObjects()
|
||||
{
|
||||
int index = listBoxStorages.SelectedIndex;
|
||||
listBoxStorages.Items.Clear();
|
||||
for (int i = 0; i < _storage.Keys.Count; i++)
|
||||
{
|
||||
listBoxStorages.Items.Add(_storage.Keys[i]);
|
||||
}
|
||||
if (listBoxStorages.Items.Count > 0 && (index == -1 || index >= listBoxStorages.Items.Count))
|
||||
{
|
||||
listBoxStorages.SelectedIndex = 0;
|
||||
}
|
||||
else if (listBoxStorages.Items.Count > 0 && index > -1 && index < listBoxStorages.Items.Count)
|
||||
{
|
||||
listBoxStorages.SelectedIndex = index;
|
||||
}
|
||||
|
||||
}
|
||||
private void buttonAddStorage_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxStorageName.Text))
|
||||
{
|
||||
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_storage.AddSet(textBoxStorageName.Text);
|
||||
ReloadObjects();
|
||||
}
|
||||
private void listBoxObjects_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowBus();
|
||||
}
|
||||
private void buttonDeleteStorage_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show($"Удалить объект {listBoxStorages.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_storage.DelSet(listBoxStorages.SelectedItem.ToString() ?? string.Empty);
|
||||
ReloadObjects();
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAddBus_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
var formBusConfig = new FormBusConfig();
|
||||
formBusConfig.AddEvent(AddBus);
|
||||
formBusConfig.Show();
|
||||
}
|
||||
|
||||
private void AddBus(DrawingBus selectedBus)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
MessageBox.Show("Не выбран набор");
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
selectedBus.ChangeBordersPicture(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
if (obj + selectedBus != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowBus();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonDeleteBus_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = 0;
|
||||
try
|
||||
{
|
||||
pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (obj - pos)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBoxCollection.Image = obj.ShowBus();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
private void buttonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
||||
string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBoxCollection.Image = obj.ShowBus();
|
||||
}
|
||||
private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (_storage.SaveData(saveFileDialog.FileName))
|
||||
{
|
||||
MessageBox.Show("Сохранение прошло успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не сохранилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (_storage.LoadData(openFileDialog.FileName))
|
||||
{
|
||||
ReloadObjects();
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
pictureBoxCollection.Image = obj.ShowBus();
|
||||
MessageBox.Show("Загрузка прошла успешно", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не загрузилось", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
75
DoubleDeckerBus/FormDoubleDeckerbusCollection.resx
Normal file
75
DoubleDeckerBus/FormDoubleDeckerbusCollection.resx
Normal file
@ -0,0 +1,75 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="colorDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>152, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>428, 16</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>590, 16</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>36</value>
|
||||
</metadata>
|
||||
</root>
|
97
DoubleDeckerBus/Generic/BusGenericCollection.cs
Normal file
97
DoubleDeckerBus/Generic/BusGenericCollection.cs
Normal file
@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DoubleDeckerbus.Drawing;
|
||||
using DoubleDeckerbus.Move_Strategy;
|
||||
|
||||
namespace DoubleDeckerbus.Generic
|
||||
{
|
||||
internal class BusGenericCollection<T, U>
|
||||
where T : DrawingBus
|
||||
where U : IMoveableObject
|
||||
{
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
private readonly int _placeSizeWidth = 200;
|
||||
private readonly int _placeSizeHeight = 120;
|
||||
private readonly SetGeneric<T> _collection;
|
||||
|
||||
public BusGenericCollection(int picWidth, int picHeight)
|
||||
{
|
||||
int width = picWidth / _placeSizeWidth;
|
||||
int height = picHeight / _placeSizeHeight;
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
|
||||
_collection = new SetGeneric<T>(width * height);
|
||||
}
|
||||
public static int operator +(BusGenericCollection<T, U> collect, T? obj)
|
||||
{
|
||||
if (obj != null)
|
||||
{
|
||||
return collect._collection.Insert(obj);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public static bool operator -(BusGenericCollection<T, U> collect, int pos)
|
||||
{
|
||||
if (collect._collection.GetBus(pos) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return collect?._collection.Remove(pos) ?? false;
|
||||
}
|
||||
|
||||
public IEnumerable<T?> GetBus => _collection.GetBus();
|
||||
public U? GetU(int pos)
|
||||
{
|
||||
return (U?)_collection[pos]?.GetMoveableObject;
|
||||
}
|
||||
|
||||
public Bitmap ShowBus()
|
||||
{
|
||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
DrawBackground(gr);
|
||||
DrawObjects(gr);
|
||||
return bmp;
|
||||
}
|
||||
|
||||
private void DrawBackground(Graphics gr)
|
||||
{
|
||||
Pen pen = new(Color.Black, 3);
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; ++i)
|
||||
{
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
|
||||
{
|
||||
gr.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
|
||||
gr.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawObjects(Graphics g)
|
||||
{
|
||||
int x = _pictureWidth / _placeSizeWidth - 1;
|
||||
int y = 0;
|
||||
|
||||
foreach (var bus in _collection.GetBus())
|
||||
{
|
||||
if (bus != null)
|
||||
{
|
||||
if (x < 0)
|
||||
{
|
||||
x = _pictureWidth / _placeSizeWidth - 1;
|
||||
++y;
|
||||
}
|
||||
bus.SetPosition(_placeSizeWidth * x, _placeSizeHeight * y);
|
||||
bus.DrawTransport(g);
|
||||
--x;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
125
DoubleDeckerBus/Generic/BusesGenericStorage.cs
Normal file
125
DoubleDeckerBus/Generic/BusesGenericStorage.cs
Normal file
@ -0,0 +1,125 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DoubleDeckerbus.Drawing;
|
||||
using DoubleDeckerbus.Move_Strategy;
|
||||
|
||||
namespace DoubleDeckerbus.Generic
|
||||
{
|
||||
internal class BusesGenericStorage
|
||||
{
|
||||
readonly Dictionary<string, BusGenericCollection<DrawingBus, DrawingObjectBus>> _busStorages;
|
||||
public List<string> Keys => _busStorages.Keys.ToList();
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
private static readonly char _separatorForKeyValue = '|';
|
||||
private readonly char _separatorRecords = ';';
|
||||
private static readonly char _separatorForObject = ':';
|
||||
|
||||
public BusesGenericStorage(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_busStorages = new Dictionary<string, BusGenericCollection<DrawingBus, DrawingObjectBus>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
|
||||
public void AddSet(string name)
|
||||
{
|
||||
foreach (string nameStorage in Keys)
|
||||
{
|
||||
if (nameStorage == name)
|
||||
{
|
||||
MessageBox.Show("Набор с заданным именем уже есть", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
_busStorages.Add(name, new BusGenericCollection<DrawingBus, DrawingObjectBus>(_pictureWidth, _pictureHeight));
|
||||
}
|
||||
|
||||
public void DelSet(string name)
|
||||
{
|
||||
if (_busStorages.ContainsKey(name))
|
||||
{
|
||||
_busStorages.Remove(name);
|
||||
}
|
||||
|
||||
}
|
||||
public BusGenericCollection<DrawingBus, DrawingObjectBus>? this[string ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_busStorages.ContainsKey(ind))
|
||||
{
|
||||
return _busStorages[ind];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool SaveData(string filename)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
File.Delete(filename);
|
||||
}
|
||||
|
||||
using (StreamWriter sw = File.CreateText(filename))
|
||||
{
|
||||
sw.WriteLine($"DoubleDeckerBusStorage");
|
||||
foreach (var record in _busStorages)
|
||||
{
|
||||
StringBuilder records = new();
|
||||
foreach (DrawingBus? elem in record.Value.GetBus)
|
||||
{
|
||||
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
|
||||
}
|
||||
sw.WriteLine($"{record.Key}{_separatorForKeyValue}{records}");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool LoadData(string filename)
|
||||
{
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
using (StreamReader sr = File.OpenText(filename))
|
||||
{
|
||||
string? curLine = sr.ReadLine();
|
||||
if (curLine == null || !curLine.Contains("AirbusStorage"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_busStorages.Clear();
|
||||
curLine = sr.ReadLine();
|
||||
while (curLine != null)
|
||||
{
|
||||
string[] record = curLine.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
||||
BusGenericCollection<DrawingBus, DrawingObjectBus> collection = new(_pictureWidth, _pictureHeight);
|
||||
string[] set = record[1].Split(_separatorRecords, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
foreach (string elem in set)
|
||||
{
|
||||
DrawingBus? Bus = elem?.CreateDrawingBus(_separatorForObject, _pictureWidth, _pictureHeight);
|
||||
if (Bus != null)
|
||||
{
|
||||
if (collection + Bus == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
_busStorages.Add(record[0], collection);
|
||||
curLine = sr.ReadLine();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
77
DoubleDeckerBus/Generic/SetGeneric.cs
Normal file
77
DoubleDeckerBus/Generic/SetGeneric.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DoubleDeckerbus.Generic
|
||||
{
|
||||
internal class SetGeneric<T>
|
||||
where T : class
|
||||
{
|
||||
private readonly List<T?> _places;
|
||||
public int Count => _places.Count;
|
||||
private readonly int _maxCount;
|
||||
public SetGeneric(int count)
|
||||
{
|
||||
_maxCount = count;
|
||||
_places = new List<T?>(count);
|
||||
}
|
||||
|
||||
public int Insert(T bus)
|
||||
{
|
||||
_places.Insert(0, bus);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public bool Insert(T bus, int position)
|
||||
{
|
||||
if (position < 0 || position >= Count || Count >= _maxCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_places.Insert(position, bus);
|
||||
return true;
|
||||
}
|
||||
public bool Remove(int position)
|
||||
{
|
||||
if (position < 0 || position >= Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_places.RemoveAt(position);
|
||||
|
||||
return true;
|
||||
}
|
||||
public T? this[int position]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (position < 0 || position >= Count)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _places[position];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (position < 0 || position > Count || Count >= _maxCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_places.Insert(position, value);
|
||||
}
|
||||
}
|
||||
public IEnumerable<T?> GetBus(int? maxBus = null)
|
||||
{
|
||||
for (int i = 0; i < _places.Count; ++i)
|
||||
{
|
||||
yield return _places[i];
|
||||
if (maxBus.HasValue && i == maxBus.Value)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
74
DoubleDeckerBus/Move_Strategy/AbstractStrategy.cs
Normal file
74
DoubleDeckerBus/Move_Strategy/AbstractStrategy.cs
Normal file
@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DoubleDeckerbus.Entities;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
|
||||
namespace DoubleDeckerbus.Move_Strategy
|
||||
{
|
||||
public abstract class AbstractStrategy
|
||||
{
|
||||
private IMoveableObject? _moveableObject;
|
||||
private Status _state = Status.NotInit;
|
||||
protected int FieldWidth { get; private set; }
|
||||
protected int FieldHeight { get; private set; }
|
||||
public Status GetStatus() { return _state; }
|
||||
public void SetData(IMoveableObject moveableObject, int width, int height)
|
||||
{
|
||||
if (moveableObject == null)
|
||||
{
|
||||
_state = Status.NotInit;
|
||||
return;
|
||||
}
|
||||
_state = Status.InProgress;
|
||||
_moveableObject = moveableObject;
|
||||
FieldWidth = width;
|
||||
FieldHeight = height;
|
||||
}
|
||||
public void MakeStep()
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (IsTargetDestinaion())
|
||||
{
|
||||
_state = Status.Finish;
|
||||
return;
|
||||
}
|
||||
MoveToTarget();
|
||||
}
|
||||
protected bool MoveLeft() => MoveTo(DirectionType.Left);
|
||||
protected bool MoveRight() => MoveTo(DirectionType.Right);
|
||||
protected bool MoveUp() => MoveTo(DirectionType.Up);
|
||||
protected bool MoveDown() => MoveTo(DirectionType.Down);
|
||||
protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition;
|
||||
protected int? GetStep()
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _moveableObject?.GetStep;
|
||||
}
|
||||
protected abstract void MoveToTarget();
|
||||
protected abstract bool IsTargetDestinaion();
|
||||
private bool MoveTo(DirectionType directionType)
|
||||
{
|
||||
if (_state != Status.InProgress)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_moveableObject?.CheckCanMove(directionType) ?? false)
|
||||
{
|
||||
_moveableObject.MoveObject(directionType);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
36
DoubleDeckerBus/Move_Strategy/DrawingObjectBus.cs
Normal file
36
DoubleDeckerBus/Move_Strategy/DrawingObjectBus.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using DoubleDeckerbus.Entities;
|
||||
using DoubleDeckerbus.Drawing;
|
||||
|
||||
|
||||
namespace DoubleDeckerbus.Move_Strategy
|
||||
{
|
||||
public class DrawingObjectBus : IMoveableObject
|
||||
{
|
||||
private readonly DrawingBus? _drawingBus = null;
|
||||
public DrawingObjectBus(DrawingBus drawingBus)
|
||||
{
|
||||
_drawingBus = drawingBus;
|
||||
}
|
||||
public ObjectParameters? GetObjectPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_drawingBus == null || _drawingBus.EntityBus == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new ObjectParameters(_drawingBus.GetPosX, _drawingBus.GetPosY, _drawingBus.GetWidth, _drawingBus.GetHeight);
|
||||
}
|
||||
}
|
||||
public int GetStep => (int)(_drawingBus?.EntityBus?.Step ?? 0);
|
||||
public bool CheckCanMove(DirectionType direction) => _drawingBus?.CanMove(direction) ?? false;
|
||||
public void MoveObject(DirectionType direction) => _drawingBus?.MoveTransport(direction);
|
||||
}
|
||||
}
|
19
DoubleDeckerBus/Move_Strategy/IMoveableObject.cs
Normal file
19
DoubleDeckerBus/Move_Strategy/IMoveableObject.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using DoubleDeckerbus.Drawing;
|
||||
using DoubleDeckerbus.Entities;
|
||||
|
||||
namespace DoubleDeckerbus.Move_Strategy
|
||||
{
|
||||
public interface IMoveableObject
|
||||
{
|
||||
ObjectParameters? GetObjectPosition { get; }
|
||||
int GetStep { get; }
|
||||
bool CheckCanMove(DirectionType direction);
|
||||
void MoveObject(DirectionType direction);
|
||||
}
|
||||
}
|
57
DoubleDeckerBus/Move_Strategy/MoveToBorder.cs
Normal file
57
DoubleDeckerBus/Move_Strategy/MoveToBorder.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DoubleDeckerbus.Move_Strategy
|
||||
{
|
||||
internal class MoveToBorder : AbstractStrategy
|
||||
{
|
||||
protected override bool IsTargetDestinaion()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return objParams.RightBorder <= FieldWidth &&
|
||||
objParams.RightBorder + GetStep() >= FieldWidth &&
|
||||
objParams.DownBorder <= FieldHeight &&
|
||||
objParams.DownBorder + GetStep() >= FieldHeight;
|
||||
}
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var diffX = objParams.ObjectMiddleHorizontal - FieldWidth;
|
||||
if (Math.Abs(diffX) > GetStep())
|
||||
{
|
||||
if (diffX > 0)
|
||||
{
|
||||
MoveLeft();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveRight();
|
||||
}
|
||||
|
||||
}
|
||||
var diffY = objParams.ObjectMiddleVertical - FieldHeight;
|
||||
if (Math.Abs(diffY) > GetStep())
|
||||
{
|
||||
if (diffY > 0)
|
||||
{
|
||||
MoveUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
57
DoubleDeckerBus/Move_Strategy/MoveToCenter.cs
Normal file
57
DoubleDeckerBus/Move_Strategy/MoveToCenter.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DoubleDeckerbus.Move_Strategy
|
||||
{
|
||||
public class MoveToCenter : AbstractStrategy
|
||||
{
|
||||
protected override bool IsTargetDestinaion()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return objParams.ObjectMiddleHorizontal <= FieldWidth / 2 &&
|
||||
objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 &&
|
||||
objParams.ObjectMiddleVertical <= FieldHeight / 2 &&
|
||||
objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
|
||||
}
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
var objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
|
||||
if (Math.Abs(diffX) > GetStep())
|
||||
{
|
||||
if (diffX > 0)
|
||||
{
|
||||
MoveLeft();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveRight();
|
||||
}
|
||||
|
||||
}
|
||||
var diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
|
||||
if (Math.Abs(diffY) > GetStep())
|
||||
{
|
||||
if (diffY > 0)
|
||||
{
|
||||
MoveUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
29
DoubleDeckerBus/Move_Strategy/ObjectParameters.cs
Normal file
29
DoubleDeckerBus/Move_Strategy/ObjectParameters.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DoubleDeckerbus.Move_Strategy
|
||||
{
|
||||
public class ObjectParameters
|
||||
{
|
||||
private readonly int _x;
|
||||
private readonly int _y;
|
||||
private readonly int _width;
|
||||
private readonly int _height;
|
||||
public int LeftBorder => _x;
|
||||
public int TopBorder => _y;
|
||||
public int RightBorder => _x + _width;
|
||||
public int DownBorder => _y + _height;
|
||||
public int ObjectMiddleHorizontal => _x + _width / 2;
|
||||
public int ObjectMiddleVertical => _y + _height / 2;
|
||||
public ObjectParameters(int x, int y, int width, int height)
|
||||
{
|
||||
_x = x;
|
||||
_y = y;
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
}
|
||||
}
|
15
DoubleDeckerBus/Move_Strategy/Status.cs
Normal file
15
DoubleDeckerBus/Move_Strategy/Status.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DoubleDeckerbus.Move_Strategy
|
||||
{
|
||||
public enum Status
|
||||
{
|
||||
NotInit,
|
||||
InProgress,
|
||||
Finish
|
||||
}
|
||||
}
|
17
DoubleDeckerBus/Program.cs
Normal file
17
DoubleDeckerBus/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace DoubleDeckerbus
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormDoubleDeckerbusCollection());
|
||||
}
|
||||
}
|
||||
}
|
103
DoubleDeckerBus/Properties/Resources.Designer.cs
generated
Normal file
103
DoubleDeckerBus/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DoubleDeckerbus.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||
/// </summary>
|
||||
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
||||
// с помощью такого средства, как ResGen или Visual Studio.
|
||||
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
||||
// с параметром /str или перестройте свой проект VS.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DoubleDeckerbus.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap стрелка_вверх {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("стрелка вверх", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap стрелка_влево {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("стрелка влево", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap стрелка_вниз {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("стрелка вниз", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap стрелка_вправо {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("стрелка вправо", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
DoubleDeckerBus/Properties/Resources.resx
Normal file
133
DoubleDeckerBus/Properties/Resources.resx
Normal file
@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="стрелка вверх" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\стрелка вверх.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="стрелка влево" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\стрелка влево.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="стрелка вниз" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\стрелка вниз.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="стрелка вправо" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\стрелка вправо.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
DoubleDeckerBus/Resources/ArrowDown.png
Normal file
BIN
DoubleDeckerBus/Resources/ArrowDown.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
BIN
DoubleDeckerBus/Resources/ArrowLeft.png
Normal file
BIN
DoubleDeckerBus/Resources/ArrowLeft.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
BIN
DoubleDeckerBus/Resources/ArrowRight.png
Normal file
BIN
DoubleDeckerBus/Resources/ArrowRight.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
BIN
DoubleDeckerBus/Resources/ArrowUp.png
Normal file
BIN
DoubleDeckerBus/Resources/ArrowUp.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
Loading…
Reference in New Issue
Block a user