PIbd22_Kamcharova_K.A._lab6
This commit is contained in:
parent
ee27ff9217
commit
ffd4d75e98
@ -90,26 +90,39 @@ namespace DoubleDeckerbus.Drawing
|
|||||||
}
|
}
|
||||||
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 + 52, 21, 20);
|
||||||
g.FillRectangle(additionalBrush, _startPosX + 147, _startPosY + 71, 30, 27);
|
g.FillRectangle(additionalBrush, _startPosX + 147, _startPosY + 71, 30, 27);
|
||||||
g.FillRectangle(additionalBrush, _startPosX + 10, _startPosY + 52, 137, 46);
|
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);
|
||||||
|
|
||||||
Brush gr = new SolidBrush(Color.Gray);
|
Brush gr = new SolidBrush(Color.Gray);
|
||||||
|
|
||||||
g.FillEllipse(additionalBrush, _startPosX + 23, _startPosY + 88, 25, 25);
|
g.FillEllipse(additionalBrush, _startPosX + 23, _startPosY + 88, 25, 25);
|
||||||
g.FillEllipse(additionalBrush, _startPosX + 123, _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 + 25, _startPosY + 90, 21, 21);
|
||||||
g.FillEllipse(gr, _startPosX + 125, _startPosY + 90, 21, 21);
|
g.FillEllipse(gr, _startPosX + 125, _startPosY + 90, 21, 21);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanMove(DirectionType direction)
|
public bool CanMove(DirectionType direction)
|
||||||
{
|
{
|
||||||
if (EntityBus == null)
|
if (EntityBus == null)
|
||||||
@ -125,6 +138,7 @@ namespace DoubleDeckerbus.Drawing
|
|||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeBordersPicture(int width, int height)
|
public void ChangeBordersPicture(int width, int height)
|
||||||
{
|
{
|
||||||
_pictureWidth = width;
|
_pictureWidth = width;
|
||||||
|
@ -16,6 +16,7 @@ namespace DoubleDeckerbus.Drawing
|
|||||||
{
|
{
|
||||||
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)
|
||||||
{
|
{
|
||||||
@ -24,16 +25,19 @@ namespace DoubleDeckerbus.Drawing
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
Pen additionalPen = new(doubleDeckerBus.Body);
|
Pen additionalPen = new(doubleDeckerBus.AddColor);
|
||||||
Brush additionalBrush = new SolidBrush(doubleDeckerBus.Body);
|
Brush additionalBrush = new SolidBrush(doubleDeckerBus.AddColor);
|
||||||
base.DrawTransport(g);
|
base.DrawTransport(g);
|
||||||
|
|
||||||
if (doubleDeckerBus.Secondfloor)
|
if (doubleDeckerBus.IsSecondFloor)
|
||||||
{
|
{
|
||||||
Brush additionalBrush2 = new SolidBrush(doubleDeckerBus.Body);
|
Brush additionalBrush2 = new SolidBrush(doubleDeckerBus.AddColor);
|
||||||
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);
|
||||||
@ -42,7 +46,7 @@ namespace DoubleDeckerbus.Drawing
|
|||||||
g.FillRectangle(brBlue, _startPosX + 150, _startPosY + 15, 15, 15);
|
g.FillRectangle(brBlue, _startPosX + 150, _startPosY + 15, 15, 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doubleDeckerBus.Stairs)
|
if (doubleDeckerBus.IsStairs)
|
||||||
{
|
{
|
||||||
g.DrawLine(pen, _startPosX + 10, _startPosY + 55, _startPosX + 34, _startPosY + 55);
|
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 + 58, _startPosX + 34, _startPosY + 58);
|
||||||
|
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}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -12,5 +12,6 @@ namespace DoubleDeckerbus.Entities
|
|||||||
Down = 2,
|
Down = 2,
|
||||||
Left = 3,
|
Left = 3,
|
||||||
Right = 4
|
Right = 4
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,6 +18,7 @@ namespace DoubleDeckerbus.Entities
|
|||||||
Weight = weight;
|
Weight = weight;
|
||||||
BodyColor = bodyColor;
|
BodyColor = bodyColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeBodyColor(Color color)
|
public void ChangeBodyColor(Color color)
|
||||||
{
|
{
|
||||||
BodyColor = color;
|
BodyColor = color;
|
||||||
|
@ -10,14 +10,16 @@ namespace DoubleDeckerbus.Entities
|
|||||||
public class EntityDoubleDeckerbus : EntityBus
|
public class EntityDoubleDeckerbus : EntityBus
|
||||||
{
|
{
|
||||||
public Color AddColor { get; private set; }
|
public Color AddColor { get; private set; }
|
||||||
public bool Secondfloor { get; private set; }
|
public bool IsSecondFloor { get; private set; }
|
||||||
public bool Stairs { 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)
|
public EntityDoubleDeckerbus(int speed, double weight, Color bodyColor, Color additionalColor, bool secondfloor, bool stairs) : base(speed, weight, bodyColor)
|
||||||
{
|
{
|
||||||
AddColor = additionalColor;
|
AddColor = additionalColor;
|
||||||
Secondfloor = secondfloor;
|
IsSecondFloor = secondfloor;
|
||||||
Stairs = stairs;
|
IsStairs = stairs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeAdditionalColor(Color additionalColor)
|
public void ChangeAdditionalColor(Color additionalColor)
|
||||||
{
|
{
|
||||||
AddColor = additionalColor;
|
AddColor = additionalColor;
|
||||||
|
@ -14,6 +14,7 @@ namespace DoubleDeckerbus
|
|||||||
{
|
{
|
||||||
public partial class FormBusConfig : Form
|
public partial class FormBusConfig : Form
|
||||||
{
|
{
|
||||||
|
|
||||||
DrawingBus? _bus = null;
|
DrawingBus? _bus = null;
|
||||||
private event Action<DrawingBus>? EventAddBus;
|
private event Action<DrawingBus>? EventAddBus;
|
||||||
public FormBusConfig()
|
public FormBusConfig()
|
||||||
@ -48,11 +49,13 @@ namespace DoubleDeckerbus
|
|||||||
EventAddBus += ev;
|
EventAddBus += ev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name,
|
(sender as Label)?.DoDragDrop((sender as Label)?.Name,
|
||||||
DragDropEffects.Move | DragDropEffects.Copy);
|
DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||||
@ -87,11 +90,13 @@ namespace DoubleDeckerbus
|
|||||||
}
|
}
|
||||||
DrawBus();
|
DrawBus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
|
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
|
||||||
DragDropEffects.Move | DragDropEffects.Copy);
|
DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LabelMainColor_DragEnter(object sender, DragEventArgs e)
|
private void LabelMainColor_DragEnter(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Data.GetDataPresent(typeof(Color)) && _bus != null)
|
if (e.Data.GetDataPresent(typeof(Color)) && _bus != null)
|
||||||
@ -103,12 +108,14 @@ namespace DoubleDeckerbus
|
|||||||
e.Effect = DragDropEffects.None;
|
e.Effect = DragDropEffects.None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LabelMainColor_DragDrop(object sender, DragEventArgs e)
|
private void LabelMainColor_DragDrop(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
var color = (Color)e.Data.GetData(typeof(Color));
|
var color = (Color)e.Data.GetData(typeof(Color));
|
||||||
_bus.EntityBus.ChangeBodyColor(color);
|
_bus.EntityBus.ChangeBodyColor(color);
|
||||||
DrawBus();
|
DrawBus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LabelAdditionalColor_DragEnter(object sender, DragEventArgs e)
|
private void LabelAdditionalColor_DragEnter(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Data.GetDataPresent(typeof(Color)) && _bus != null && _bus is DrawingDoubleDeckerbus)
|
if (e.Data.GetDataPresent(typeof(Color)) && _bus != null && _bus is DrawingDoubleDeckerbus)
|
||||||
@ -128,6 +135,7 @@ namespace DoubleDeckerbus
|
|||||||
_doubledeckerbus.ChangeAdditionalColor(color);
|
_doubledeckerbus.ChangeAdditionalColor(color);
|
||||||
DrawBus();
|
DrawBus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
EventAddBus?.Invoke(_bus);
|
EventAddBus?.Invoke(_bus);
|
||||||
|
@ -1,4 +1,64 @@
|
|||||||
<root>
|
<?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: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:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
@ -28,155 +28,211 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
buttonAddBus = new Button();
|
this.buttonAddBus = new System.Windows.Forms.Button();
|
||||||
pictureBoxCollection = new PictureBox();
|
this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
|
||||||
labelInstruments = new Label();
|
this.labelInstruments = new System.Windows.Forms.Label();
|
||||||
buttonUpdate = new Button();
|
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||||
buttonDeleteBus = new Button();
|
this.buttonDeleteBus = new System.Windows.Forms.Button();
|
||||||
colorDialog = new ColorDialog();
|
this.colorDialog = new System.Windows.Forms.ColorDialog();
|
||||||
maskedTextBoxNumber = new MaskedTextBox();
|
this.maskedTextBoxNumber = new System.Windows.Forms.MaskedTextBox();
|
||||||
label1 = new Label();
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
listBoxStorages = new ListBox();
|
this.listBoxStorages = new System.Windows.Forms.ListBox();
|
||||||
buttonAddStorage = new Button();
|
this.buttonAddStorage = new System.Windows.Forms.Button();
|
||||||
buttonDeleteStorage = new Button();
|
this.buttonDeleteStorage = new System.Windows.Forms.Button();
|
||||||
textBoxStorageName = new TextBox();
|
this.textBoxStorageName = new System.Windows.Forms.TextBox();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||||
SuspendLayout();
|
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
|
// buttonAddBus
|
||||||
//
|
//
|
||||||
buttonAddBus.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
this.buttonAddBus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
buttonAddBus.Location = new Point(859, 331);
|
this.buttonAddBus.Location = new System.Drawing.Point(859, 331);
|
||||||
buttonAddBus.Name = "buttonAddBus";
|
this.buttonAddBus.Name = "buttonAddBus";
|
||||||
buttonAddBus.Size = new Size(118, 28);
|
this.buttonAddBus.Size = new System.Drawing.Size(118, 28);
|
||||||
buttonAddBus.TabIndex = 0;
|
this.buttonAddBus.TabIndex = 0;
|
||||||
buttonAddBus.Text = "Добавить автобус";
|
this.buttonAddBus.Text = "Добавить автобус";
|
||||||
buttonAddBus.UseVisualStyleBackColor = true;
|
this.buttonAddBus.UseVisualStyleBackColor = true;
|
||||||
buttonAddBus.Click += buttonAddBus_Click;
|
this.buttonAddBus.Click += new System.EventHandler(this.buttonAddBus_Click);
|
||||||
//
|
//
|
||||||
// pictureBoxCollection
|
// pictureBoxCollection
|
||||||
//
|
//
|
||||||
pictureBoxCollection.Location = new Point(3, 0);
|
this.pictureBoxCollection.Location = new System.Drawing.Point(0, 20);
|
||||||
pictureBoxCollection.Name = "pictureBoxCollection";
|
this.pictureBoxCollection.Name = "pictureBoxCollection";
|
||||||
pictureBoxCollection.Size = new Size(830, 475);
|
this.pictureBoxCollection.Size = new System.Drawing.Size(830, 475);
|
||||||
pictureBoxCollection.TabIndex = 1;
|
this.pictureBoxCollection.TabIndex = 1;
|
||||||
pictureBoxCollection.TabStop = false;
|
this.pictureBoxCollection.TabStop = false;
|
||||||
//
|
//
|
||||||
// labelInstruments
|
// labelInstruments
|
||||||
//
|
//
|
||||||
labelInstruments.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
this.labelInstruments.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
labelInstruments.AutoSize = true;
|
this.labelInstruments.AutoSize = true;
|
||||||
labelInstruments.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
this.labelInstruments.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
labelInstruments.Location = new Point(859, 0);
|
this.labelInstruments.Location = new System.Drawing.Point(859, 0);
|
||||||
labelInstruments.Name = "labelInstruments";
|
this.labelInstruments.Name = "labelInstruments";
|
||||||
labelInstruments.Size = new Size(108, 21);
|
this.labelInstruments.Size = new System.Drawing.Size(108, 21);
|
||||||
labelInstruments.TabIndex = 2;
|
this.labelInstruments.TabIndex = 2;
|
||||||
labelInstruments.Text = "Инструменты";
|
this.labelInstruments.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
// buttonUpdate
|
// buttonUpdate
|
||||||
//
|
//
|
||||||
buttonUpdate.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
this.buttonUpdate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
buttonUpdate.Location = new Point(851, 130);
|
this.buttonUpdate.Location = new System.Drawing.Point(851, 130);
|
||||||
buttonUpdate.Name = "buttonUpdate";
|
this.buttonUpdate.Name = "buttonUpdate";
|
||||||
buttonUpdate.Size = new Size(131, 25);
|
this.buttonUpdate.Size = new System.Drawing.Size(131, 25);
|
||||||
buttonUpdate.TabIndex = 3;
|
this.buttonUpdate.TabIndex = 3;
|
||||||
buttonUpdate.Text = "Обновить набор";
|
this.buttonUpdate.Text = "Обновить набор";
|
||||||
buttonUpdate.UseVisualStyleBackColor = true;
|
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
buttonUpdate.Click += buttonUpdate_Click;
|
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
|
||||||
//
|
//
|
||||||
// buttonDeleteBus
|
// buttonDeleteBus
|
||||||
//
|
//
|
||||||
buttonDeleteBus.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
this.buttonDeleteBus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
buttonDeleteBus.Location = new Point(859, 394);
|
this.buttonDeleteBus.Location = new System.Drawing.Point(859, 394);
|
||||||
buttonDeleteBus.Name = "buttonDeleteBus";
|
this.buttonDeleteBus.Name = "buttonDeleteBus";
|
||||||
buttonDeleteBus.Size = new Size(118, 28);
|
this.buttonDeleteBus.Size = new System.Drawing.Size(118, 28);
|
||||||
buttonDeleteBus.TabIndex = 4;
|
this.buttonDeleteBus.TabIndex = 4;
|
||||||
buttonDeleteBus.Text = "Удалить автобус";
|
this.buttonDeleteBus.Text = "Удалить автобус";
|
||||||
buttonDeleteBus.UseVisualStyleBackColor = true;
|
this.buttonDeleteBus.UseVisualStyleBackColor = true;
|
||||||
buttonDeleteBus.Click += buttonDeleteBus_Click;
|
this.buttonDeleteBus.Click += new System.EventHandler(this.buttonDeleteBus_Click);
|
||||||
//
|
//
|
||||||
// maskedTextBoxNumber
|
// maskedTextBoxNumber
|
||||||
//
|
//
|
||||||
maskedTextBoxNumber.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
this.maskedTextBoxNumber.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
maskedTextBoxNumber.Location = new Point(851, 365);
|
this.maskedTextBoxNumber.Location = new System.Drawing.Point(851, 365);
|
||||||
maskedTextBoxNumber.Mask = "00";
|
this.maskedTextBoxNumber.Mask = "00";
|
||||||
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||||
maskedTextBoxNumber.Size = new Size(138, 23);
|
this.maskedTextBoxNumber.Size = new System.Drawing.Size(138, 23);
|
||||||
maskedTextBoxNumber.TabIndex = 5;
|
this.maskedTextBoxNumber.TabIndex = 5;
|
||||||
maskedTextBoxNumber.ValidatingType = typeof(int);
|
this.maskedTextBoxNumber.ValidatingType = typeof(int);
|
||||||
//
|
//
|
||||||
// label1
|
// label1
|
||||||
//
|
//
|
||||||
label1.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
label1.AutoSize = true;
|
this.label1.AutoSize = true;
|
||||||
label1.Location = new Point(851, 38);
|
this.label1.Location = new System.Drawing.Point(851, 38);
|
||||||
label1.Name = "label1";
|
this.label1.Name = "label1";
|
||||||
label1.Size = new Size(52, 15);
|
this.label1.Size = new System.Drawing.Size(52, 15);
|
||||||
label1.TabIndex = 7;
|
this.label1.TabIndex = 7;
|
||||||
label1.Text = "Наборы";
|
this.label1.Text = "Наборы";
|
||||||
//
|
//
|
||||||
// listBoxStorages
|
// listBoxStorages
|
||||||
//
|
//
|
||||||
listBoxStorages.FormattingEnabled = true;
|
this.listBoxStorages.FormattingEnabled = true;
|
||||||
listBoxStorages.ItemHeight = 15;
|
this.listBoxStorages.ItemHeight = 15;
|
||||||
listBoxStorages.Location = new Point(850, 160);
|
this.listBoxStorages.Location = new System.Drawing.Point(850, 160);
|
||||||
listBoxStorages.Margin = new Padding(3, 2, 3, 2);
|
this.listBoxStorages.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
listBoxStorages.Name = "listBoxStorages";
|
this.listBoxStorages.Name = "listBoxStorages";
|
||||||
listBoxStorages.Size = new Size(132, 109);
|
this.listBoxStorages.Size = new System.Drawing.Size(132, 109);
|
||||||
listBoxStorages.TabIndex = 8;
|
this.listBoxStorages.TabIndex = 8;
|
||||||
listBoxStorages.SelectedIndexChanged += listBoxObjects_SelectedIndexChanged;
|
this.listBoxStorages.SelectedIndexChanged += new System.EventHandler(this.listBoxObjects_SelectedIndexChanged);
|
||||||
//
|
//
|
||||||
// buttonAddStorage
|
// buttonAddStorage
|
||||||
//
|
//
|
||||||
buttonAddStorage.Location = new Point(850, 102);
|
this.buttonAddStorage.Location = new System.Drawing.Point(850, 102);
|
||||||
buttonAddStorage.Margin = new Padding(3, 2, 3, 2);
|
this.buttonAddStorage.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
buttonAddStorage.Name = "buttonAddStorage";
|
this.buttonAddStorage.Name = "buttonAddStorage";
|
||||||
buttonAddStorage.Size = new Size(131, 25);
|
this.buttonAddStorage.Size = new System.Drawing.Size(131, 25);
|
||||||
buttonAddStorage.TabIndex = 9;
|
this.buttonAddStorage.TabIndex = 9;
|
||||||
buttonAddStorage.Text = "Добавить набор";
|
this.buttonAddStorage.Text = "Добавить набор";
|
||||||
buttonAddStorage.UseVisualStyleBackColor = true;
|
this.buttonAddStorage.UseVisualStyleBackColor = true;
|
||||||
buttonAddStorage.Click += buttonAddStorage_Click;
|
this.buttonAddStorage.Click += new System.EventHandler(this.buttonAddStorage_Click);
|
||||||
//
|
//
|
||||||
// buttonDeleteStorage
|
// buttonDeleteStorage
|
||||||
//
|
//
|
||||||
buttonDeleteStorage.Location = new Point(850, 273);
|
this.buttonDeleteStorage.Location = new System.Drawing.Point(850, 273);
|
||||||
buttonDeleteStorage.Margin = new Padding(3, 2, 3, 2);
|
this.buttonDeleteStorage.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
buttonDeleteStorage.Name = "buttonDeleteStorage";
|
this.buttonDeleteStorage.Name = "buttonDeleteStorage";
|
||||||
buttonDeleteStorage.Size = new Size(131, 25);
|
this.buttonDeleteStorage.Size = new System.Drawing.Size(131, 25);
|
||||||
buttonDeleteStorage.TabIndex = 10;
|
this.buttonDeleteStorage.TabIndex = 10;
|
||||||
buttonDeleteStorage.Text = "Удалить набор";
|
this.buttonDeleteStorage.Text = "Удалить набор";
|
||||||
buttonDeleteStorage.UseVisualStyleBackColor = true;
|
this.buttonDeleteStorage.UseVisualStyleBackColor = true;
|
||||||
buttonDeleteStorage.Click += buttonDeleteStorage_Click;
|
this.buttonDeleteStorage.Click += new System.EventHandler(this.buttonDeleteStorage_Click);
|
||||||
//
|
//
|
||||||
// textBoxStorageName
|
// textBoxStorageName
|
||||||
//
|
//
|
||||||
textBoxStorageName.Location = new Point(850, 77);
|
this.textBoxStorageName.Location = new System.Drawing.Point(850, 77);
|
||||||
textBoxStorageName.Margin = new Padding(3, 2, 3, 2);
|
this.textBoxStorageName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
textBoxStorageName.Name = "textBoxStorageName";
|
this.textBoxStorageName.Name = "textBoxStorageName";
|
||||||
textBoxStorageName.Size = new Size(132, 23);
|
this.textBoxStorageName.Size = new System.Drawing.Size(132, 23);
|
||||||
textBoxStorageName.TabIndex = 11;
|
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
|
// FormDoubleDeckerbusCollection
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
ClientSize = new Size(1003, 480);
|
this.ClientSize = new System.Drawing.Size(1003, 504);
|
||||||
Controls.Add(textBoxStorageName);
|
this.Controls.Add(this.textBoxStorageName);
|
||||||
Controls.Add(buttonDeleteStorage);
|
this.Controls.Add(this.buttonDeleteStorage);
|
||||||
Controls.Add(buttonAddStorage);
|
this.Controls.Add(this.buttonAddStorage);
|
||||||
Controls.Add(listBoxStorages);
|
this.Controls.Add(this.listBoxStorages);
|
||||||
Controls.Add(label1);
|
this.Controls.Add(this.label1);
|
||||||
Controls.Add(buttonAddBus);
|
this.Controls.Add(this.buttonAddBus);
|
||||||
Controls.Add(maskedTextBoxNumber);
|
this.Controls.Add(this.maskedTextBoxNumber);
|
||||||
Controls.Add(buttonDeleteBus);
|
this.Controls.Add(this.buttonDeleteBus);
|
||||||
Controls.Add(buttonUpdate);
|
this.Controls.Add(this.buttonUpdate);
|
||||||
Controls.Add(labelInstruments);
|
this.Controls.Add(this.labelInstruments);
|
||||||
Controls.Add(pictureBoxCollection);
|
this.Controls.Add(this.pictureBoxCollection);
|
||||||
Name = "FormDoubleDeckerbusCollection";
|
this.Controls.Add(this.menuStrip);
|
||||||
Text = "Набор автобусов";
|
this.MainMenuStrip = this.menuStrip;
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
this.Name = "FormDoubleDeckerbusCollection";
|
||||||
ResumeLayout(false);
|
this.Text = "Набор автобусов";
|
||||||
PerformLayout();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
|
||||||
|
this.menuStrip.ResumeLayout(false);
|
||||||
|
this.menuStrip.PerformLayout();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -193,5 +249,11 @@
|
|||||||
private Button buttonAddStorage;
|
private Button buttonAddStorage;
|
||||||
private Button buttonDeleteStorage;
|
private Button buttonDeleteStorage;
|
||||||
private TextBox textBoxStorageName;
|
private TextBox textBoxStorageName;
|
||||||
|
private MenuStrip menuStrip;
|
||||||
|
private ToolStripMenuItem toolStripMenuItem;
|
||||||
|
private ToolStripMenuItem saveToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem loadToolStripMenuItem;
|
||||||
|
private SaveFileDialog saveFileDialog;
|
||||||
|
private OpenFileDialog openFileDialog;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,11 +11,13 @@ using DoubleDeckerbus.Generic;
|
|||||||
using DoubleDeckerbus.Drawing;
|
using DoubleDeckerbus.Drawing;
|
||||||
using DoubleDeckerbus.Move_Strategy;
|
using DoubleDeckerbus.Move_Strategy;
|
||||||
|
|
||||||
|
|
||||||
namespace DoubleDeckerbus
|
namespace DoubleDeckerbus
|
||||||
{
|
{
|
||||||
public partial class FormDoubleDeckerbusCollection : Form
|
public partial class FormDoubleDeckerbusCollection : Form
|
||||||
{
|
{
|
||||||
private readonly BusesGenericStorage _storage;
|
private readonly BusesGenericStorage _storage;
|
||||||
|
|
||||||
public FormDoubleDeckerbusCollection()
|
public FormDoubleDeckerbusCollection()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -37,6 +39,7 @@ namespace DoubleDeckerbus
|
|||||||
{
|
{
|
||||||
listBoxStorages.SelectedIndex = index;
|
listBoxStorages.SelectedIndex = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private void buttonAddStorage_Click(object sender, EventArgs e)
|
private void buttonAddStorage_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@ -64,12 +67,15 @@ namespace DoubleDeckerbus
|
|||||||
ReloadObjects();
|
ReloadObjects();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonAddBus_Click(object sender, EventArgs e)
|
private void buttonAddBus_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
var formBusConfig = new FormBusConfig();
|
var formBusConfig = new FormBusConfig();
|
||||||
formBusConfig.AddEvent(AddBus);
|
formBusConfig.AddEvent(AddBus);
|
||||||
formBusConfig.Show();
|
formBusConfig.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddBus(DrawingBus selectedBus)
|
private void AddBus(DrawingBus selectedBus)
|
||||||
{
|
{
|
||||||
if (listBoxStorages.SelectedIndex == -1)
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
@ -84,15 +90,16 @@ namespace DoubleDeckerbus
|
|||||||
}
|
}
|
||||||
selectedBus.ChangeBordersPicture(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
selectedBus.ChangeBordersPicture(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||||
if (obj + selectedBus != -1)
|
if (obj + selectedBus != -1)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
pictureBoxCollection.Image = obj.ShowBus();
|
pictureBoxCollection.Image = obj.ShowBus();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonDeleteBus_Click(object sender, EventArgs e)
|
private void buttonDeleteBus_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (listBoxStorages.SelectedIndex == -1)
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
@ -142,5 +149,36 @@ namespace DoubleDeckerbus
|
|||||||
}
|
}
|
||||||
pictureBoxCollection.Image = obj.ShowBus();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,64 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<root>
|
||||||
<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: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:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
@ -120,6 +60,15 @@
|
|||||||
<metadata name="colorDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="colorDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</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">
|
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>36</value>
|
<value>36</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
@ -43,10 +43,13 @@ namespace DoubleDeckerbus.Generic
|
|||||||
}
|
}
|
||||||
return collect?._collection.Remove(pos) ?? false;
|
return collect?._collection.Remove(pos) ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<T?> GetBus => _collection.GetBus();
|
||||||
public U? GetU(int pos)
|
public U? GetU(int pos)
|
||||||
{
|
{
|
||||||
return (U?)_collection[pos]?.GetMoveableObject;
|
return (U?)_collection[pos]?.GetMoveableObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bitmap ShowBus()
|
public Bitmap ShowBus()
|
||||||
{
|
{
|
||||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||||
@ -55,6 +58,7 @@ namespace DoubleDeckerbus.Generic
|
|||||||
DrawObjects(gr);
|
DrawObjects(gr);
|
||||||
return bmp;
|
return bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawBackground(Graphics gr)
|
private void DrawBackground(Graphics gr)
|
||||||
{
|
{
|
||||||
Pen pen = new(Color.Black, 3);
|
Pen pen = new(Color.Black, 3);
|
||||||
@ -67,9 +71,9 @@ namespace DoubleDeckerbus.Generic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawObjects(Graphics g)
|
private void DrawObjects(Graphics g)
|
||||||
{
|
{
|
||||||
|
|
||||||
int x = _pictureWidth / _placeSizeWidth - 1;
|
int x = _pictureWidth / _placeSizeWidth - 1;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
|
|
||||||
|
@ -14,12 +14,17 @@ namespace DoubleDeckerbus.Generic
|
|||||||
public List<string> Keys => _busStorages.Keys.ToList();
|
public List<string> Keys => _busStorages.Keys.ToList();
|
||||||
private readonly int _pictureWidth;
|
private readonly int _pictureWidth;
|
||||||
private readonly int _pictureHeight;
|
private readonly int _pictureHeight;
|
||||||
|
private static readonly char _separatorForKeyValue = '|';
|
||||||
|
private readonly char _separatorRecords = ';';
|
||||||
|
private static readonly char _separatorForObject = ':';
|
||||||
|
|
||||||
public BusesGenericStorage(int pictureWidth, int pictureHeight)
|
public BusesGenericStorage(int pictureWidth, int pictureHeight)
|
||||||
{
|
{
|
||||||
_busStorages = new Dictionary<string, BusGenericCollection<DrawingBus, DrawingObjectBus>>();
|
_busStorages = new Dictionary<string, BusGenericCollection<DrawingBus, DrawingObjectBus>>();
|
||||||
_pictureWidth = pictureWidth;
|
_pictureWidth = pictureWidth;
|
||||||
_pictureHeight = pictureHeight;
|
_pictureHeight = pictureHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddSet(string name)
|
public void AddSet(string name)
|
||||||
{
|
{
|
||||||
foreach (string nameStorage in Keys)
|
foreach (string nameStorage in Keys)
|
||||||
@ -32,12 +37,14 @@ namespace DoubleDeckerbus.Generic
|
|||||||
}
|
}
|
||||||
_busStorages.Add(name, new BusGenericCollection<DrawingBus, DrawingObjectBus>(_pictureWidth, _pictureHeight));
|
_busStorages.Add(name, new BusGenericCollection<DrawingBus, DrawingObjectBus>(_pictureWidth, _pictureHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DelSet(string name)
|
public void DelSet(string name)
|
||||||
{
|
{
|
||||||
if (_busStorages.ContainsKey(name))
|
if (_busStorages.ContainsKey(name))
|
||||||
{
|
{
|
||||||
_busStorages.Remove(name);
|
_busStorages.Remove(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public BusGenericCollection<DrawingBus, DrawingObjectBus>? this[string ind]
|
public BusGenericCollection<DrawingBus, DrawingObjectBus>? this[string ind]
|
||||||
{
|
{
|
||||||
@ -50,5 +57,69 @@ namespace DoubleDeckerbus.Generic
|
|||||||
return null;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,13 @@ namespace DoubleDeckerbus.Generic
|
|||||||
_maxCount = count;
|
_maxCount = count;
|
||||||
_places = new List<T?>(count);
|
_places = new List<T?>(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Insert(T bus)
|
public int Insert(T bus)
|
||||||
{
|
{
|
||||||
_places.Insert(0, bus);
|
_places.Insert(0, bus);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Insert(T bus, int position)
|
public bool Insert(T bus, int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= Count || Count >= _maxCount)
|
if (position < 0 || position >= Count || Count >= _maxCount)
|
||||||
|
@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
|||||||
using DoubleDeckerbus.Entities;
|
using DoubleDeckerbus.Entities;
|
||||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||||
|
|
||||||
|
|
||||||
namespace DoubleDeckerbus.Move_Strategy
|
namespace DoubleDeckerbus.Move_Strategy
|
||||||
{
|
{
|
||||||
public abstract class AbstractStrategy
|
public abstract class AbstractStrategy
|
||||||
@ -70,3 +71,4 @@ namespace DoubleDeckerbus.Move_Strategy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ using System.Threading.Tasks;
|
|||||||
using DoubleDeckerbus.Entities;
|
using DoubleDeckerbus.Entities;
|
||||||
using DoubleDeckerbus.Drawing;
|
using DoubleDeckerbus.Drawing;
|
||||||
|
|
||||||
|
|
||||||
namespace DoubleDeckerbus.Move_Strategy
|
namespace DoubleDeckerbus.Move_Strategy
|
||||||
{
|
{
|
||||||
public class DrawingObjectBus : IMoveableObject
|
public class DrawingObjectBus : IMoveableObject
|
||||||
|
8
DoubleDeckerBus/Properties/Resources.Designer.cs
generated
8
DoubleDeckerBus/Properties/Resources.Designer.cs
generated
@ -65,7 +65,7 @@ namespace DoubleDeckerbus.Properties {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal static System.Drawing.Bitmap стрелка_вверх {
|
internal static System.Drawing.Bitmap стрелка_вверх {
|
||||||
get {
|
get {
|
||||||
object obj = ResourceManager.GetObject("ArrowUp", resourceCulture);
|
object obj = ResourceManager.GetObject("стрелка вверх", resourceCulture);
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ namespace DoubleDeckerbus.Properties {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal static System.Drawing.Bitmap стрелка_влево {
|
internal static System.Drawing.Bitmap стрелка_влево {
|
||||||
get {
|
get {
|
||||||
object obj = ResourceManager.GetObject("ArrowLeft", resourceCulture);
|
object obj = ResourceManager.GetObject("стрелка влево", resourceCulture);
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ namespace DoubleDeckerbus.Properties {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal static System.Drawing.Bitmap стрелка_вниз {
|
internal static System.Drawing.Bitmap стрелка_вниз {
|
||||||
get {
|
get {
|
||||||
object obj = ResourceManager.GetObject("ArrowDown", resourceCulture);
|
object obj = ResourceManager.GetObject("стрелка вниз", resourceCulture);
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ namespace DoubleDeckerbus.Properties {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal static System.Drawing.Bitmap стрелка_вправо {
|
internal static System.Drawing.Bitmap стрелка_вправо {
|
||||||
get {
|
get {
|
||||||
object obj = ResourceManager.GetObject("ArrowRight", resourceCulture);
|
object obj = ResourceManager.GetObject("стрелка вправо", resourceCulture);
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,16 +118,16 @@
|
|||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
<data name="ArrowUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="стрелка вверх" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\ArrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\стрелка вверх.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ArrowLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="стрелка влево" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\ArrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\стрелка влево.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ArrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="стрелка вниз" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\ArrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\стрелка вниз.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ArrowRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="стрелка вправо" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\ArrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\стрелка вправо.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
Loading…
Reference in New Issue
Block a user