PIbd22_Kamcharova_K.A._lab3
This commit is contained in:
parent
51a21db2aa
commit
b9edbcd1dd
@ -71,5 +71,4 @@ namespace DoubleDeckerbus.MovementStrategy
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
105
DoubleDeckerBus/BusGenericCollection.cs
Normal file
105
DoubleDeckerBus/BusGenericCollection.cs
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DoubleDeckerbus.DrawingObjects;
|
||||||
|
using DoubleDeckerbus.MovementStrategy;
|
||||||
|
|
||||||
|
namespace DoubleDeckerbus
|
||||||
|
{
|
||||||
|
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.Get(pos) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return collect?._collection.Remove(pos) ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ReturnLength()
|
||||||
|
{
|
||||||
|
return _collection.Count;
|
||||||
|
}
|
||||||
|
public U? GetU(int pos)
|
||||||
|
{
|
||||||
|
return (U?)_collection.Get(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 = 0;
|
||||||
|
int y = 0;
|
||||||
|
int index = -1;
|
||||||
|
for (int i = 0; i <= _collection.Count; ++i)
|
||||||
|
{
|
||||||
|
DrawingBus _bus = _collection.Get(i);
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
if (_bus != null)
|
||||||
|
{
|
||||||
|
index = _collection.Count - i;
|
||||||
|
while ((index - _pictureWidth / _placeSizeWidth) >= 0)
|
||||||
|
{
|
||||||
|
y++;
|
||||||
|
index -= _pictureWidth / _placeSizeWidth;
|
||||||
|
}
|
||||||
|
if (index > 0)
|
||||||
|
{
|
||||||
|
x += index;
|
||||||
|
}
|
||||||
|
x = _pictureWidth / _placeSizeWidth - 1 - x;
|
||||||
|
_bus.SetPosition(_placeSizeWidth * x, _placeSizeHeight * y);
|
||||||
|
|
||||||
|
_bus.DrawTransport(g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||||||
namespace DoubleDeckerbus
|
namespace DoubleDeckerbus
|
||||||
{
|
{
|
||||||
public enum DirectionType
|
public enum DirectionType
|
||||||
{
|
{
|
||||||
Up = 1,
|
Up = 1,
|
||||||
Down = 2,
|
Down = 2,
|
||||||
Left = 3,
|
Left = 3,
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio Version 17
|
|
||||||
VisualStudioVersion = 17.7.34024.191
|
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "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
|
|
@ -5,18 +5,20 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using DoubleDeckerbus.Entities;
|
using DoubleDeckerbus.Entities;
|
||||||
|
using DoubleDeckerbus.MovementStrategy;
|
||||||
|
|
||||||
namespace DoubleDeckerbus.DrawingObjects
|
namespace DoubleDeckerbus.DrawingObjects
|
||||||
{
|
{
|
||||||
public class DrawingBus
|
public class DrawingBus
|
||||||
{
|
{
|
||||||
|
public IMoveableObject GetMoveableObject => new DrawingObjectBus(this);
|
||||||
public EntityBus? EntityBus { get; protected set; }
|
public EntityBus? EntityBus { get; protected set; }
|
||||||
public int _pictureWidth;
|
public int _pictureWidth;
|
||||||
public int _pictureHeight;
|
public int _pictureHeight;
|
||||||
protected int _startPosX;
|
protected int _startPosX;
|
||||||
protected int _startPosY;
|
protected int _startPosY;
|
||||||
protected readonly int _busWidth = 175;
|
protected readonly int _busWidth = 175;
|
||||||
protected readonly int _busHeight = 115;
|
protected readonly int _busHeight = 115;
|
||||||
public int GetPosX => _startPosX;
|
public int GetPosX => _startPosX;
|
||||||
public int GetPosY => _startPosY;
|
public int GetPosY => _startPosY;
|
||||||
public int GetWidth => _busWidth;
|
public int GetWidth => _busWidth;
|
||||||
@ -53,7 +55,7 @@ namespace DoubleDeckerbus.DrawingObjects
|
|||||||
_startPosY = y;
|
_startPosY = y;
|
||||||
}
|
}
|
||||||
public void MoveTransport(DirectionType direction)
|
public void MoveTransport(DirectionType direction)
|
||||||
{
|
{
|
||||||
if (!CanMove(direction) || EntityBus == null)
|
if (!CanMove(direction) || EntityBus == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -89,19 +91,19 @@ namespace DoubleDeckerbus.DrawingObjects
|
|||||||
public virtual void DrawTransport(Graphics g)
|
public virtual void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
|
|
||||||
Brush additionalBrush = new
|
Brush additionalBrush = new
|
||||||
SolidBrush(EntityBus.BodyColor);
|
SolidBrush(EntityBus.BodyColor);
|
||||||
g.FillRectangle(additionalBrush, _startPosX + 147, _startPosY + 52, 21, 20); //маленький
|
|
||||||
g.FillRectangle(additionalBrush, _startPosX + 147, _startPosY + 71, 30, 27); //2
|
|
||||||
g.FillRectangle(additionalBrush, _startPosX + 10, _startPosY + 52, 137, 46); //большой прямоугольник 2
|
|
||||||
|
|
||||||
|
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);
|
Brush brBlue = new SolidBrush(Color.LightBlue);
|
||||||
g.FillRectangle(brBlue, _startPosX + 150, _startPosY + 55, 15, 15);
|
g.FillRectangle(brBlue, _startPosX + 150, _startPosY + 55, 15, 15);
|
||||||
g.FillRectangle(brBlue, _startPosX + 42, _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 + 69, _startPosY + 55, 15, 15);
|
||||||
g.FillRectangle(brBlue, _startPosX + 96, _startPosY + 55, 15, 15);
|
g.FillRectangle(brBlue, _startPosX + 96, _startPosY + 55, 15, 15);
|
||||||
g.FillRectangle(brBlue, _startPosX + 123, _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 + 30, _startPosY + 52, _startPosX + 30, _startPosY + 98);
|
||||||
g.DrawLine(pen, _startPosX + 35, _startPosY + 52, _startPosX + 35, _startPosY + 98);
|
g.DrawLine(pen, _startPosX + 35, _startPosY + 52, _startPosX + 35, _startPosY + 98);
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ namespace DoubleDeckerbus
|
|||||||
{
|
{
|
||||||
EntityBus = new EntityDoubleDeckerBus(speed, weight, bodyColor, additionalColor, secondfloor, stairs);
|
EntityBus = new EntityDoubleDeckerBus(speed, weight, bodyColor, additionalColor, secondfloor, stairs);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public override void DrawTransport(Graphics g)
|
public override void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
@ -25,19 +26,15 @@ namespace DoubleDeckerbus
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
Pen additionalPen = new(doubleDeckerBus.AdditionalColor);
|
Pen additionalPen = new(doubleDeckerBus.Body);
|
||||||
Brush additionalBrush = new SolidBrush(doubleDeckerBus.AdditionalColor);
|
Brush additionalBrush = new SolidBrush(doubleDeckerBus.Body);
|
||||||
base.DrawTransport(g);
|
base.DrawTransport(g);
|
||||||
|
|
||||||
if (doubleDeckerBus.Secondfloor)
|
if (doubleDeckerBus.Secondfloor)
|
||||||
{
|
{
|
||||||
Brush additionalBrush2 = new SolidBrush(doubleDeckerBus.AdditionalColor);
|
Brush additionalBrush2 = new SolidBrush(doubleDeckerBus.Body);
|
||||||
Brush brBlue = new SolidBrush(Color.LightBlue);
|
Brush brBlue = new SolidBrush(Color.LightBlue);
|
||||||
|
|
||||||
g.FillRectangle(additionalBrush2, _startPosX + 7, _startPosY + 12, 172, 40);
|
g.FillRectangle(additionalBrush2, _startPosX + 7, _startPosY + 12, 172, 40);
|
||||||
|
|
||||||
g.DrawLine(pen, _startPosX + 7, _startPosY + 36, _startPosX + 178, _startPosY + 36);
|
g.DrawLine(pen, _startPosX + 7, _startPosY + 36, _startPosX + 178, _startPosY + 36);
|
||||||
|
|
||||||
g.FillRectangle(brBlue, _startPosX + 15, _startPosY + 15, 15, 15);
|
g.FillRectangle(brBlue, _startPosX + 15, _startPosY + 15, 15, 15);
|
||||||
g.FillRectangle(brBlue, _startPosX + 42, _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 + 69, _startPosY + 15, 15, 15);
|
||||||
@ -45,7 +42,6 @@ namespace DoubleDeckerbus
|
|||||||
g.FillRectangle(brBlue, _startPosX + 123, _startPosY + 15, 15, 15);
|
g.FillRectangle(brBlue, _startPosX + 123, _startPosY + 15, 15, 15);
|
||||||
g.FillRectangle(brBlue, _startPosX + 150, _startPosY + 15, 15, 15);
|
g.FillRectangle(brBlue, _startPosX + 150, _startPosY + 15, 15, 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doubleDeckerBus.Stairs)
|
if (doubleDeckerBus.Stairs)
|
||||||
{
|
{
|
||||||
g.DrawLine(pen, _startPosX + 10, _startPosY + 55, _startPosX + 34, _startPosY + 55);
|
g.DrawLine(pen, _startPosX + 10, _startPosY + 55, _startPosX + 34, _startPosY + 55);
|
||||||
|
@ -9,12 +9,12 @@ namespace DoubleDeckerbus.Entities
|
|||||||
{
|
{
|
||||||
public class EntityDoubleDeckerBus : EntityBus
|
public class EntityDoubleDeckerBus : EntityBus
|
||||||
{
|
{
|
||||||
public Color AdditionalColor { get; private set; }
|
public Color Body { get; private set; }
|
||||||
public bool Secondfloor { get; private set; }
|
public bool Secondfloor { get; private set; }
|
||||||
public bool Stairs { get; private set; }
|
public bool Stairs { get; private set; }
|
||||||
public EntityDoubleDeckerBus(int speed, double weight, Color bodyColor, Color additionalColor, bool secondfloor, bool stairs) : base(speed, weight, bodyColor)
|
public EntityDoubleDeckerBus(int speed, double weight, Color bodyColor, Color additionalColor, bool secondfloor, bool stairs) : base(speed, weight, bodyColor)
|
||||||
{
|
{
|
||||||
AdditionalColor = additionalColor;
|
Body = additionalColor;
|
||||||
Secondfloor = secondfloor;
|
Secondfloor = secondfloor;
|
||||||
Stairs = stairs;
|
Stairs = stairs;
|
||||||
}
|
}
|
||||||
|
128
DoubleDeckerBus/FormBusCollection.Designer.cs
generated
Normal file
128
DoubleDeckerBus/FormBusCollection.Designer.cs
generated
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
namespace DoubleDeckerbus
|
||||||
|
{
|
||||||
|
partial class FormBusCollection
|
||||||
|
{
|
||||||
|
/// <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.pictureBoxCollection = new System.Windows.Forms.PictureBox();
|
||||||
|
this.labelInstruments = new System.Windows.Forms.Label();
|
||||||
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
|
this.maskedTextBoxNumber = new System.Windows.Forms.TextBox();
|
||||||
|
this.buttonDelete = new System.Windows.Forms.Button();
|
||||||
|
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// pictureBoxCollection
|
||||||
|
//
|
||||||
|
this.pictureBoxCollection.Location = new System.Drawing.Point(1, -2);
|
||||||
|
this.pictureBoxCollection.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
|
this.pictureBoxCollection.Name = "pictureBoxCollection";
|
||||||
|
this.pictureBoxCollection.Size = new System.Drawing.Size(803, 924);
|
||||||
|
this.pictureBoxCollection.TabIndex = 0;
|
||||||
|
this.pictureBoxCollection.TabStop = false;
|
||||||
|
//
|
||||||
|
// labelInstruments
|
||||||
|
//
|
||||||
|
this.labelInstruments.AutoSize = true;
|
||||||
|
this.labelInstruments.Location = new System.Drawing.Point(852, 22);
|
||||||
|
this.labelInstruments.Name = "labelInstruments";
|
||||||
|
this.labelInstruments.Size = new System.Drawing.Size(83, 15);
|
||||||
|
this.labelInstruments.TabIndex = 1;
|
||||||
|
this.labelInstruments.Text = "Инструменты";
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(823, 63);
|
||||||
|
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(161, 44);
|
||||||
|
this.buttonAdd.TabIndex = 2;
|
||||||
|
this.buttonAdd.Text = "Добавить автобус";
|
||||||
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.ButtonAddBus_Click);
|
||||||
|
//
|
||||||
|
// maskedTextBoxNumber
|
||||||
|
//
|
||||||
|
this.maskedTextBoxNumber.Location = new System.Drawing.Point(874, 140);
|
||||||
|
this.maskedTextBoxNumber.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
|
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||||
|
this.maskedTextBoxNumber.Size = new System.Drawing.Size(110, 23);
|
||||||
|
this.maskedTextBoxNumber.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// buttonDelete
|
||||||
|
//
|
||||||
|
this.buttonDelete.Location = new System.Drawing.Point(840, 167);
|
||||||
|
this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
|
this.buttonDelete.Name = "buttonDelete";
|
||||||
|
this.buttonDelete.Size = new System.Drawing.Size(165, 45);
|
||||||
|
this.buttonDelete.TabIndex = 4;
|
||||||
|
this.buttonDelete.Text = "Удалить автобус";
|
||||||
|
this.buttonDelete.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDelete.Click += new System.EventHandler(this.ButtonRemoveBus_Click);
|
||||||
|
//
|
||||||
|
// buttonUpdate
|
||||||
|
//
|
||||||
|
this.buttonUpdate.Location = new System.Drawing.Point(840, 260);
|
||||||
|
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
|
this.buttonUpdate.Name = "buttonUpdate";
|
||||||
|
this.buttonUpdate.Size = new System.Drawing.Size(165, 45);
|
||||||
|
this.buttonUpdate.TabIndex = 5;
|
||||||
|
this.buttonUpdate.Text = "Обновить";
|
||||||
|
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUpdate.Click += new System.EventHandler(this.ButtonRefreshCollection_Click);
|
||||||
|
//
|
||||||
|
// FormBusCollection
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(1152, 975);
|
||||||
|
this.Controls.Add(this.buttonUpdate);
|
||||||
|
this.Controls.Add(this.buttonDelete);
|
||||||
|
this.Controls.Add(this.maskedTextBoxNumber);
|
||||||
|
this.Controls.Add(this.buttonAdd);
|
||||||
|
this.Controls.Add(this.labelInstruments);
|
||||||
|
this.Controls.Add(this.pictureBoxCollection);
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
|
this.Name = "FormBusCollection";
|
||||||
|
this.Text = "Автобус";
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private PictureBox pictureBoxCollection;
|
||||||
|
private Label labelInstruments;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private TextBox maskedTextBoxNumber;
|
||||||
|
private Button buttonDelete;
|
||||||
|
private Button buttonUpdate;
|
||||||
|
}
|
||||||
|
}
|
74
DoubleDeckerBus/FormBusCollection.cs
Normal file
74
DoubleDeckerBus/FormBusCollection.cs
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
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.DrawingObjects;
|
||||||
|
using DoubleDeckerbus;
|
||||||
|
using DoubleDeckerbus.MovementStrategy;
|
||||||
|
|
||||||
|
namespace DoubleDeckerbus
|
||||||
|
{
|
||||||
|
public partial class FormBusCollection : Form
|
||||||
|
{
|
||||||
|
private readonly BusGenericCollection<DrawingBus, DrawingObjectBus> _bus;
|
||||||
|
public FormBusCollection()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_bus = new BusGenericCollection<DrawingBus, DrawingObjectBus>(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||||
|
|
||||||
|
}
|
||||||
|
private void ButtonAddBus_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
FormDoubleDeckerbus form = new();
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (_bus + form.SelectedBus != -1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект добавлен");
|
||||||
|
pictureBoxCollection.Image = _bus.ShowBus();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonRemoveBus_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||||||
|
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int pos = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pos = Convert.ToInt32(maskedTextBoxNumber.Text) ;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
MessageBox.Show("Ошибка ввода данных");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_bus - (_bus.ReturnLength() - pos))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект удален");
|
||||||
|
pictureBoxCollection.Image = _bus.ShowBus();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось удалить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonRefreshCollection_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
pictureBoxCollection.Image = _bus.ShowBus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
DoubleDeckerBus/FormBusCollection.resx
Normal file
60
DoubleDeckerBus/FormBusCollection.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
230
DoubleDeckerBus/FormDoubleDeckerBus.Designer.cs
generated
230
DoubleDeckerBus/FormDoubleDeckerBus.Designer.cs
generated
@ -1,6 +1,6 @@
|
|||||||
namespace DoubleDeckerbus
|
namespace DoubleDeckerbus
|
||||||
{
|
{
|
||||||
partial class FormDoubleDeckerBus
|
partial class FormDoubleDeckerbus
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
||||||
@ -28,141 +28,158 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.pictureBoxDoubleDeckerbus = new System.Windows.Forms.PictureBox();
|
pictureBoxDoubleDeckerbus = new PictureBox();
|
||||||
this.DoubleDeckerbus = new System.Windows.Forms.Button();
|
DoubleDeckerbus = new Button();
|
||||||
this.buttonUp = new System.Windows.Forms.Button();
|
buttonUp = new Button();
|
||||||
this.buttonLeft = new System.Windows.Forms.Button();
|
buttonLeft = new Button();
|
||||||
this.buttonDown = new System.Windows.Forms.Button();
|
buttonDown = new Button();
|
||||||
this.buttonRight = new System.Windows.Forms.Button();
|
buttonRight = new Button();
|
||||||
this.comboBoxStrategy = new System.Windows.Forms.ComboBox();
|
comboBoxStrategy = new ComboBox();
|
||||||
this.buttonStep = new System.Windows.Forms.Button();
|
buttonStep = new Button();
|
||||||
this.buttonCreateBus = new System.Windows.Forms.Button();
|
buttonCreateBus = new Button();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxDoubleDeckerbus)).BeginInit();
|
buttonSelect = new Button();
|
||||||
this.SuspendLayout();
|
((System.ComponentModel.ISupportInitialize)pictureBoxDoubleDeckerbus).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// pictureBoxDoubleDeckerbus
|
// pictureBoxDoubleDeckerbus
|
||||||
//
|
//
|
||||||
this.pictureBoxDoubleDeckerbus.Dock = System.Windows.Forms.DockStyle.Fill;
|
pictureBoxDoubleDeckerbus.Dock = DockStyle.Fill;
|
||||||
this.pictureBoxDoubleDeckerbus.Location = new System.Drawing.Point(0, 0);
|
pictureBoxDoubleDeckerbus.Location = new Point(0, 0);
|
||||||
this.pictureBoxDoubleDeckerbus.Name = "pictureBoxDoubleDeckerbus";
|
pictureBoxDoubleDeckerbus.Margin = new Padding(3, 2, 3, 2);
|
||||||
this.pictureBoxDoubleDeckerbus.Size = new System.Drawing.Size(882, 453);
|
pictureBoxDoubleDeckerbus.Name = "pictureBoxDoubleDeckerbus";
|
||||||
this.pictureBoxDoubleDeckerbus.TabIndex = 5;
|
pictureBoxDoubleDeckerbus.Size = new Size(772, 340);
|
||||||
this.pictureBoxDoubleDeckerbus.TabStop = false;
|
pictureBoxDoubleDeckerbus.TabIndex = 5;
|
||||||
|
pictureBoxDoubleDeckerbus.TabStop = false;
|
||||||
//
|
//
|
||||||
// DoubleDeckerbus
|
// DoubleDeckerbus
|
||||||
//
|
//
|
||||||
this.DoubleDeckerbus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
DoubleDeckerbus.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
this.DoubleDeckerbus.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
DoubleDeckerbus.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
this.DoubleDeckerbus.Location = new System.Drawing.Point(11, 365);
|
DoubleDeckerbus.Location = new Point(10, 274);
|
||||||
this.DoubleDeckerbus.Name = "DoubleDeckerbus";
|
DoubleDeckerbus.Margin = new Padding(3, 2, 3, 2);
|
||||||
this.DoubleDeckerbus.Size = new System.Drawing.Size(120, 73);
|
DoubleDeckerbus.Name = "DoubleDeckerbus";
|
||||||
this.DoubleDeckerbus.TabIndex = 6;
|
DoubleDeckerbus.Size = new Size(105, 55);
|
||||||
this.DoubleDeckerbus.Text = "Создать Двухэтажный автобус";
|
DoubleDeckerbus.TabIndex = 6;
|
||||||
this.DoubleDeckerbus.UseVisualStyleBackColor = true;
|
DoubleDeckerbus.Text = "Создать Двухэтажный автобус";
|
||||||
this.DoubleDeckerbus.Click += new System.EventHandler(this.buttonCreateDoubleDeckerbus_Click);
|
DoubleDeckerbus.UseVisualStyleBackColor = true;
|
||||||
|
DoubleDeckerbus.Click += buttonCreateDoubleDeckerbus_Click;
|
||||||
//
|
//
|
||||||
// buttonUp
|
// buttonUp
|
||||||
//
|
//
|
||||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
this.buttonUp.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.ArrowUp;
|
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
buttonUp.Location = new Point(710, 283);
|
||||||
this.buttonUp.Location = new System.Drawing.Point(811, 377);
|
buttonUp.Margin = new Padding(3, 2, 3, 2);
|
||||||
this.buttonUp.Name = "buttonUp";
|
buttonUp.Name = "buttonUp";
|
||||||
this.buttonUp.Size = new System.Drawing.Size(30, 29);
|
buttonUp.Size = new Size(26, 22);
|
||||||
this.buttonUp.TabIndex = 7;
|
buttonUp.TabIndex = 7;
|
||||||
this.buttonUp.UseVisualStyleBackColor = true;
|
buttonUp.UseVisualStyleBackColor = true;
|
||||||
this.buttonUp.Click += new System.EventHandler(this.buttonMove_Click);
|
buttonUp.Click += buttonMove_Click;
|
||||||
//
|
//
|
||||||
// buttonLeft
|
// buttonLeft
|
||||||
//
|
//
|
||||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
this.buttonLeft.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.ArrowLeft;
|
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
buttonLeft.Location = new Point(679, 310);
|
||||||
this.buttonLeft.Location = new System.Drawing.Point(776, 413);
|
buttonLeft.Margin = new Padding(3, 2, 3, 2);
|
||||||
this.buttonLeft.Name = "buttonLeft";
|
buttonLeft.Name = "buttonLeft";
|
||||||
this.buttonLeft.Size = new System.Drawing.Size(30, 29);
|
buttonLeft.Size = new Size(26, 22);
|
||||||
this.buttonLeft.TabIndex = 8;
|
buttonLeft.TabIndex = 8;
|
||||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
buttonLeft.UseVisualStyleBackColor = true;
|
||||||
this.buttonLeft.Click += new System.EventHandler(this.buttonMove_Click);
|
buttonLeft.Click += buttonMove_Click;
|
||||||
//
|
//
|
||||||
// buttonDown
|
// buttonDown
|
||||||
//
|
//
|
||||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
this.buttonDown.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.ArrowDown;
|
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
buttonDown.Location = new Point(710, 310);
|
||||||
this.buttonDown.Location = new System.Drawing.Point(811, 413);
|
buttonDown.Margin = new Padding(3, 2, 3, 2);
|
||||||
this.buttonDown.Name = "buttonDown";
|
buttonDown.Name = "buttonDown";
|
||||||
this.buttonDown.Size = new System.Drawing.Size(30, 29);
|
buttonDown.Size = new Size(26, 22);
|
||||||
this.buttonDown.TabIndex = 9;
|
buttonDown.TabIndex = 9;
|
||||||
this.buttonDown.UseVisualStyleBackColor = true;
|
buttonDown.UseVisualStyleBackColor = true;
|
||||||
this.buttonDown.Click += new System.EventHandler(this.buttonMove_Click);
|
buttonDown.Click += buttonMove_Click;
|
||||||
//
|
//
|
||||||
// buttonRight
|
// buttonRight
|
||||||
//
|
//
|
||||||
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
this.buttonRight.BackgroundImage = global::DoubleDeckerBus.Properties.Resources.ArrowRight;
|
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
buttonRight.Location = new Point(742, 310);
|
||||||
this.buttonRight.Location = new System.Drawing.Point(848, 413);
|
buttonRight.Margin = new Padding(3, 2, 3, 2);
|
||||||
this.buttonRight.Name = "buttonRight";
|
buttonRight.Name = "buttonRight";
|
||||||
this.buttonRight.Size = new System.Drawing.Size(30, 29);
|
buttonRight.Size = new Size(26, 22);
|
||||||
this.buttonRight.TabIndex = 10;
|
buttonRight.TabIndex = 10;
|
||||||
this.buttonRight.UseVisualStyleBackColor = true;
|
buttonRight.UseVisualStyleBackColor = true;
|
||||||
this.buttonRight.Click += new System.EventHandler(this.buttonMove_Click);
|
buttonRight.Click += buttonMove_Click;
|
||||||
//
|
//
|
||||||
// comboBoxStrategy
|
// comboBoxStrategy
|
||||||
//
|
//
|
||||||
this.comboBoxStrategy.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
comboBoxStrategy.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
this.comboBoxStrategy.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
this.comboBoxStrategy.FormattingEnabled = true;
|
comboBoxStrategy.FormattingEnabled = true;
|
||||||
this.comboBoxStrategy.Items.AddRange(new object[] {
|
comboBoxStrategy.Items.AddRange(new object[] { "В центр", "В правый нижний угол" });
|
||||||
"В центр",
|
comboBoxStrategy.Location = new Point(629, 9);
|
||||||
"В правый нижний угол"});
|
comboBoxStrategy.Margin = new Padding(3, 2, 3, 2);
|
||||||
this.comboBoxStrategy.Location = new System.Drawing.Point(719, 12);
|
comboBoxStrategy.Name = "comboBoxStrategy";
|
||||||
this.comboBoxStrategy.Name = "comboBoxStrategy";
|
comboBoxStrategy.Size = new Size(133, 23);
|
||||||
this.comboBoxStrategy.Size = new System.Drawing.Size(151, 28);
|
comboBoxStrategy.TabIndex = 11;
|
||||||
this.comboBoxStrategy.TabIndex = 11;
|
|
||||||
//
|
//
|
||||||
// buttonStep
|
// buttonStep
|
||||||
//
|
//
|
||||||
this.buttonStep.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
buttonStep.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
this.buttonStep.Location = new System.Drawing.Point(747, 45);
|
buttonStep.Location = new Point(654, 34);
|
||||||
this.buttonStep.Name = "buttonStep";
|
buttonStep.Margin = new Padding(3, 2, 3, 2);
|
||||||
this.buttonStep.Size = new System.Drawing.Size(94, 29);
|
buttonStep.Name = "buttonStep";
|
||||||
this.buttonStep.TabIndex = 12;
|
buttonStep.Size = new Size(82, 22);
|
||||||
this.buttonStep.Text = "Шаг";
|
buttonStep.TabIndex = 12;
|
||||||
this.buttonStep.UseVisualStyleBackColor = true;
|
buttonStep.Text = "Шаг";
|
||||||
this.buttonStep.Click += new System.EventHandler(this.buttonStep_Click);
|
buttonStep.UseVisualStyleBackColor = true;
|
||||||
|
buttonStep.Click += buttonStep_Click;
|
||||||
//
|
//
|
||||||
// buttonCreateBus
|
// buttonCreateBus
|
||||||
//
|
//
|
||||||
this.buttonCreateBus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
buttonCreateBus.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
this.buttonCreateBus.Location = new System.Drawing.Point(138, 388);
|
buttonCreateBus.Location = new Point(121, 291);
|
||||||
this.buttonCreateBus.Name = "buttonCreateBus";
|
buttonCreateBus.Margin = new Padding(3, 2, 3, 2);
|
||||||
this.buttonCreateBus.Size = new System.Drawing.Size(120, 51);
|
buttonCreateBus.Name = "buttonCreateBus";
|
||||||
this.buttonCreateBus.TabIndex = 13;
|
buttonCreateBus.Size = new Size(105, 38);
|
||||||
this.buttonCreateBus.Text = "Создать автобус";
|
buttonCreateBus.TabIndex = 13;
|
||||||
this.buttonCreateBus.UseVisualStyleBackColor = true;
|
buttonCreateBus.Text = "Создать автобус";
|
||||||
this.buttonCreateBus.Click += new System.EventHandler(this.buttonCreateBus_Click);
|
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
|
// FormDoubleDeckerbus
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(882, 453);
|
ClientSize = new Size(772, 340);
|
||||||
this.Controls.Add(this.buttonCreateBus);
|
Controls.Add(buttonSelect);
|
||||||
this.Controls.Add(this.buttonStep);
|
Controls.Add(buttonCreateBus);
|
||||||
this.Controls.Add(this.comboBoxStrategy);
|
Controls.Add(buttonStep);
|
||||||
this.Controls.Add(this.buttonRight);
|
Controls.Add(comboBoxStrategy);
|
||||||
this.Controls.Add(this.buttonDown);
|
Controls.Add(buttonRight);
|
||||||
this.Controls.Add(this.buttonLeft);
|
Controls.Add(buttonDown);
|
||||||
this.Controls.Add(this.buttonUp);
|
Controls.Add(buttonLeft);
|
||||||
this.Controls.Add(this.DoubleDeckerbus);
|
Controls.Add(buttonUp);
|
||||||
this.Controls.Add(this.pictureBoxDoubleDeckerbus);
|
Controls.Add(DoubleDeckerbus);
|
||||||
this.Name = "FormDoubleDeckerbus";
|
Controls.Add(pictureBoxDoubleDeckerbus);
|
||||||
this.Text = "DoubleDeckerbus";
|
Margin = new Padding(3, 2, 3, 2);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxDoubleDeckerbus)).EndInit();
|
Name = "FormDoubleDeckerbus";
|
||||||
this.ResumeLayout(false);
|
Text = "Автобус";
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxDoubleDeckerbus).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -176,5 +193,6 @@
|
|||||||
private ComboBox comboBoxStrategy;
|
private ComboBox comboBoxStrategy;
|
||||||
private Button buttonStep;
|
private Button buttonStep;
|
||||||
private Button buttonCreateBus;
|
private Button buttonCreateBus;
|
||||||
|
private Button buttonSelect;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,13 +3,16 @@ using DoubleDeckerbus.MovementStrategy;
|
|||||||
|
|
||||||
namespace DoubleDeckerbus
|
namespace DoubleDeckerbus
|
||||||
{
|
{
|
||||||
public partial class FormDoubleDeckerBus : Form
|
public partial class FormDoubleDeckerbus : Form
|
||||||
{
|
{
|
||||||
private DrawingBus? _drawingBus;
|
private DrawingBus? _drawingBus;
|
||||||
private AbstractStrategy? _abstractStrategy;
|
private AbstractStrategy? _abstractStrategy;
|
||||||
public FormDoubleDeckerBus()
|
public DrawingBus? SelectedBus { get; private set; }
|
||||||
|
public FormDoubleDeckerbus()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_abstractStrategy = null;
|
||||||
|
SelectedBus = null;
|
||||||
}
|
}
|
||||||
private void Draw()
|
private void Draw()
|
||||||
{
|
{
|
||||||
@ -25,25 +28,36 @@ namespace DoubleDeckerbus
|
|||||||
private void buttonCreateDoubleDeckerbus_Click(object sender, EventArgs e)
|
private void buttonCreateDoubleDeckerbus_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random random = new();
|
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),
|
_drawingBus = new DrawingDoubleDeckerbus(random.Next(100, 300),
|
||||||
random.Next(1000, 3000),
|
random.Next(1000, 3000), color, color1, true, true,
|
||||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256),
|
|
||||||
random.Next(0, 256)),
|
|
||||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256),
|
|
||||||
random.Next(0, 256)),
|
|
||||||
true,
|
|
||||||
Convert.ToBoolean(random.Next(0, 2)),
|
|
||||||
pictureBoxDoubleDeckerbus.Width, pictureBoxDoubleDeckerbus.Height);
|
pictureBoxDoubleDeckerbus.Width, pictureBoxDoubleDeckerbus.Height);
|
||||||
_drawingBus.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
_drawingBus.SetPosition(random.Next(10, 100), random.Next(10,
|
||||||
|
100));
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
private void buttonCreateBus_Click(object sender, EventArgs e)
|
private void buttonCreateBus_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random random = new();
|
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),
|
_drawingBus = new DrawingBus(random.Next(100, 300),
|
||||||
random.Next(1000, 3000),
|
random.Next(1000, 3000), color,
|
||||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256),
|
|
||||||
random.Next(0, 256)),
|
|
||||||
pictureBoxDoubleDeckerbus.Width, pictureBoxDoubleDeckerbus.Height);
|
pictureBoxDoubleDeckerbus.Width, pictureBoxDoubleDeckerbus.Height);
|
||||||
_drawingBus.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
_drawingBus.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||||
Draw();
|
Draw();
|
||||||
@ -106,5 +120,10 @@ namespace DoubleDeckerbus
|
|||||||
_abstractStrategy = null;
|
_abstractStrategy = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void ButtonSelectBus_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SelectedBus = _drawingBus;
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -38,6 +38,7 @@ namespace DoubleDeckerbus.MovementStrategy
|
|||||||
{
|
{
|
||||||
MoveRight();
|
MoveRight();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
var diffY = objParams.ObjectMiddleVertical - FieldHeight;
|
var diffY = objParams.ObjectMiddleVertical - FieldHeight;
|
||||||
if (Math.Abs(diffY) > GetStep())
|
if (Math.Abs(diffY) > GetStep())
|
||||||
|
@ -38,6 +38,7 @@ namespace DoubleDeckerbus.MovementStrategy
|
|||||||
{
|
{
|
||||||
MoveRight();
|
MoveRight();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
var diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
|
var diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
|
||||||
if (Math.Abs(diffY) > GetStep())
|
if (Math.Abs(diffY) > GetStep())
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace DoubleDeckerbus
|
namespace DoubleDeckerbus
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
@ -10,8 +8,10 @@ namespace DoubleDeckerbus
|
|||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new FormDoubleDeckerBus());
|
Application.Run(new FormBusCollection());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
85
DoubleDeckerBus/SetGeneric.cs
Normal file
85
DoubleDeckerBus/SetGeneric.cs
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DoubleDeckerbus
|
||||||
|
{
|
||||||
|
internal class SetGeneric<T>
|
||||||
|
where T : class
|
||||||
|
|
||||||
|
{
|
||||||
|
private readonly T?[] _places;
|
||||||
|
public int Count => _places.Length - 1;
|
||||||
|
public SetGeneric(int count)
|
||||||
|
{
|
||||||
|
_places = new T?[count];
|
||||||
|
}
|
||||||
|
public int Insert(T bus)
|
||||||
|
{
|
||||||
|
int pos = Count - 1;
|
||||||
|
if (_places[Count] != null)
|
||||||
|
{
|
||||||
|
for (int i = pos; i > 0; --i)
|
||||||
|
{
|
||||||
|
if (_places[i] == null)
|
||||||
|
{
|
||||||
|
pos = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = pos + 1; i <= Count; ++i)
|
||||||
|
{
|
||||||
|
_places[i - 1] = _places[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_places[Count] = bus;
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
public bool Insert(T bus, int position)
|
||||||
|
{
|
||||||
|
if (position < 0 || position > Count)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (_places[Count] != null)
|
||||||
|
{
|
||||||
|
int pos = Count;
|
||||||
|
for (int i = Count; i > 0; --i)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (_places[i] == null)
|
||||||
|
{
|
||||||
|
pos = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = Count; i >= pos; --i)
|
||||||
|
{
|
||||||
|
_places[i - 1] = _places[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_places[Count] = bus;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Remove(int position)
|
||||||
|
{
|
||||||
|
if (position < 0 || position > Count)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_places[position] = null;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public T? Get(int position)
|
||||||
|
{
|
||||||
|
if (position < 0 || position > Count)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return _places[position];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user