PIbd-22.Kurbanova A.A. Lab work 03 #3 #5

Closed
ALINA_KURBANOVA wants to merge 2 commits from Laba3 into Laba2
11 changed files with 629 additions and 31 deletions

View File

@ -0,0 +1,133 @@
using WarmlyLocomotive.DrawningObjects;
using WarmlyLocomotive.MovementStrategy;
namespace WarmlyLocomotive.Generics
{
internal class CarsGenericCollection<T, U>
where T : DrawningWarmlyLocomotive
where U : IMoveableObject
{
/// <summary>
/// Ширина окна прорисовки
/// </summary>
private readonly int _pictureWidth;
/// <summary>
/// Высота окна прорисовки
/// </summary>
private readonly int _pictureHeight;
/// <summary>
/// Размер занимаемого объектом места (ширина)
/// </summary>
private readonly int _placeSizeWidth = 270;
/// <summary>
/// Размер занимаемого объектом места (высота)
/// </summary>
private readonly int _placeSizeHeight = 100;
/// <summary>
/// Набор объектов
/// </summary>
private readonly SetGeneric<T> _collection;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="picWidth"></param>
/// <param name="picHeight"></param>
public CarsGenericCollection(int picWidth, int picHeight)
{
int width = picWidth / _placeSizeWidth;
int height = picHeight / _placeSizeHeight;
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_collection = new SetGeneric<T>(width * height);
}
/// <summary>
/// Перегрузка оператора сложения
/// </summary>
/// <param name="collect"></param>
/// <param name="obj"></param>
/// <returns></returns>
public static int operator +(CarsGenericCollection<T, U> collect, T?
obj)
{
if (obj == null)
{
return -1;
}
return collect._collection.Insert(obj);
}
/// <summary>
/// Перегрузка оператора вычитания
/// </summary>
/// <param name="collect"></param>
/// <param name="pos"></param>
/// <returns></returns>
public static bool operator -(CarsGenericCollection<T, U> collect, int
pos)
{
T? obj = collect._collection.Get(pos);
if (obj != null)
{
collect._collection.Remove(pos);
}
return true;
}
/// <summary>
/// Получение объекта IMoveableObject
/// </summary>
/// <param name="pos"></param>
/// <returns></returns>
public U? GetU(int pos)
{
return (U?)_collection.Get(pos)?.GetMoveableObject;
}
/// <summary>
/// Вывод всего набора объектов
/// </summary>
/// <returns></returns>
public Bitmap ShowCars()
{
Bitmap bmp = new(_pictureWidth, _pictureHeight);
Graphics gr = Graphics.FromImage(bmp);
DrawBackground(gr);
DrawObjects(gr);
return bmp;
}
/// <summary>
/// Метод отрисовки фона
/// </summary>
/// <param name="g"></param>
private void DrawBackground(Graphics g)
{
Pen pen = new(Color.Black, 3);
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
{
for (int j = 0; j < _pictureHeight / _placeSizeHeight +
1; ++j)
{
g.DrawLine(pen, i * _placeSizeWidth, j *
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
_placeSizeHeight);
}
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
_placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
}
}
/// <summary>
/// Метод прорисовки объектов
/// </summary>
/// <param name="g"></param>
private void DrawObjects(Graphics g)
{
DrawningWarmlyLocomotive warmlylocomotive;
int numPlacesInRow = _pictureWidth / _placeSizeWidth;
for (int i = 0; i < _collection.Count; i++)
{
warmlylocomotive = _collection.Get(i);
if (warmlylocomotive != null)
{
warmlylocomotive.SetPosition((i % numPlacesInRow) * _placeSizeWidth + _placeSizeWidth / 20, _placeSizeHeight * (i / numPlacesInRow) + _placeSizeHeight / 10);
warmlylocomotive.DrawTransport(g);
}
}
}
}
}

View File

@ -1,15 +1,18 @@
using WarmlyLocomotive.Entities;
namespace WarmlyLocomotive.DrawningObjects
{
/// <summary>
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
/// </summary>
public class DrawningWarmlyLocomotive
using WarmlyLocomotive.MovementStrategy;
namespace WarmlyLocomotive.DrawningObjects
{
/// <summary>
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
/// </summary>
public class DrawningWarmlyLocomotive
{
/// <summary>
/// Класс-сущность
/// </summary>
public EntityWarmlyLocomotive? EntityWarmlyLocomotive { get; protected set; }
public IMoveableObject GetMoveableObject => new DrawningObjectCar(this);
/// <summary>
/// Ширина окна
/// </summary>
@ -151,6 +154,10 @@ namespace WarmlyLocomotive.DrawningObjects
/// Прорисовка объекта
/// </summary>
/// <param name="g"></param>
/// <summary>
/// Прорисовка объекта
/// </summary>
/// <param name="g"></param>
public virtual void DrawTransport(Graphics g)
{
if (EntityWarmlyLocomotive == null)
@ -184,3 +191,4 @@ namespace WarmlyLocomotive.DrawningObjects

View File

@ -5,19 +5,19 @@ namespace WarmlyLocomotive.DrawningObjects
/// <summary>
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
/// </summary>
public class DrawningPro : DrawningWarmlyLocomotive
public class DrawningWarmlyLocomotiveWithTrumpet : DrawningWarmlyLocomotive
{
public DrawningPro(int speed, double weight, Color bodyColor, Color
public DrawningWarmlyLocomotiveWithTrumpet(int speed, double weight, Color bodyColor, Color
additionalColor, bool trumpet, bool luggage, int width, int height) :base(speed, weight, bodyColor, width, height, 200, 75)
{
if (EntityWarmlyLocomotive != null)
{
EntityWarmlyLocomotive = new Pro(speed, weight, bodyColor, additionalColor, trumpet, luggage);
EntityWarmlyLocomotive = new EntityWarmlyLocomotiveWithTrumpet(speed, weight, bodyColor, additionalColor, trumpet, luggage);
}
}
public override void DrawTransport(Graphics g)
{
if (EntityWarmlyLocomotive is not Pro warmlylocomotive)
if (EntityWarmlyLocomotive is not EntityWarmlyLocomotiveWithTrumpet warmlylocomotive)
{
return;
}

View File

@ -1,6 +1,6 @@
namespace WarmlyLocomotive.Entities
{
public class Pro : EntityWarmlyLocomotive
public class EntityWarmlyLocomotiveWithTrumpet : EntityWarmlyLocomotive
{
/// <summary>
/// Дополнительный цвет (для опциональных элементов)
@ -14,7 +14,7 @@
/// Признак (опция) наличия прицепа
/// </summary>
public bool Luggage { get; private set; }
public Pro(int speed, double weight, Color bodyColor, Color
public EntityWarmlyLocomotiveWithTrumpet(int speed, double weight, Color bodyColor, Color
additionalColor, bool trumpet,bool luggage) : base(speed, weight, bodyColor)
{

View File

@ -0,0 +1,135 @@
namespace WarmlyLocomotive
{
partial class FormWarmlyLocomotiveCollection
{
/// <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()
{
labelCollection = new Label();
panelCollectionWarmlyLocomotive = new Panel();
buttonreFreshCollection = new Button();
textBoxCollectionWarmlyLocomotive = new TextBox();
buttonRemove = new Button();
buttonadd = new Button();
pictureBoxCollectionWarmlyLocomotive = new PictureBox();
panelCollectionWarmlyLocomotive.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCollectionWarmlyLocomotive).BeginInit();
SuspendLayout();
//
// labelCollection
//
labelCollection.AutoSize = true;
labelCollection.BorderStyle = BorderStyle.Fixed3D;
labelCollection.Location = new Point(662, 10);
labelCollection.Name = "labelCollection";
labelCollection.Size = new Size(85, 17);
labelCollection.TabIndex = 0;
labelCollection.Text = "Инструменты";
//
// panelCollectionWarmlyLocomotive
//
panelCollectionWarmlyLocomotive.Controls.Add(buttonreFreshCollection);
panelCollectionWarmlyLocomotive.Controls.Add(textBoxCollectionWarmlyLocomotive);
panelCollectionWarmlyLocomotive.Controls.Add(buttonRemove);
panelCollectionWarmlyLocomotive.Controls.Add(buttonadd);
panelCollectionWarmlyLocomotive.Location = new Point(662, 28);
panelCollectionWarmlyLocomotive.Name = "panelCollectionWarmlyLocomotive";
panelCollectionWarmlyLocomotive.Size = new Size(149, 350);
panelCollectionWarmlyLocomotive.TabIndex = 1;
//
// buttonreFreshCollection
//
buttonreFreshCollection.Location = new Point(3, 193);
buttonreFreshCollection.Name = "buttonreFreshCollection";
buttonreFreshCollection.Size = new Size(146, 23);
buttonreFreshCollection.TabIndex = 3;
buttonreFreshCollection.Text = "Обновить коллекцию";
buttonreFreshCollection.UseVisualStyleBackColor = true;
buttonreFreshCollection.Click += buttonreFreshCollection_Click;
//
// textBoxCollectionWarmlyLocomotive
//
textBoxCollectionWarmlyLocomotive.Location = new Point(17, 128);
textBoxCollectionWarmlyLocomotive.Name = "textBoxCollectionWarmlyLocomotive";
textBoxCollectionWarmlyLocomotive.Size = new Size(117, 23);
textBoxCollectionWarmlyLocomotive.TabIndex = 2;
//
// buttonRemove
//
buttonRemove.Location = new Point(3, 71);
buttonRemove.Name = "buttonRemove";
buttonRemove.Size = new Size(131, 23);
buttonRemove.TabIndex = 1;
buttonRemove.Text = "Удалить тепловоз";
buttonRemove.UseVisualStyleBackColor = true;
buttonRemove.Click += buttonRemove_Click;
//
// buttonadd
//
buttonadd.Location = new Point(3, 22);
buttonadd.Name = "buttonadd";
buttonadd.Size = new Size(131, 23);
buttonadd.TabIndex = 0;
buttonadd.Text = "Добавить тепловоз";
buttonadd.UseVisualStyleBackColor = true;
buttonadd.Click += buttonAdd_Click;
//
// pictureBoxCollectionWarmlyLocomotive
//
pictureBoxCollectionWarmlyLocomotive.Location = new Point(12, 28);
pictureBoxCollectionWarmlyLocomotive.Name = "pictureBoxCollectionWarmlyLocomotive";
pictureBoxCollectionWarmlyLocomotive.Size = new Size(647, 350);
pictureBoxCollectionWarmlyLocomotive.TabIndex = 2;
pictureBoxCollectionWarmlyLocomotive.TabStop = false;
//
// FormWarmlyLocomotiveCollection
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(823, 450);
Controls.Add(pictureBoxCollectionWarmlyLocomotive);
Controls.Add(panelCollectionWarmlyLocomotive);
Controls.Add(labelCollection);
Name = "FormWarmlyLocomotiveCollection";
Text = "FormWarmlyLocomotiveCollection";
panelCollectionWarmlyLocomotive.ResumeLayout(false);
panelCollectionWarmlyLocomotive.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCollectionWarmlyLocomotive).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelCollection;
private Panel panelCollectionWarmlyLocomotive;
private PictureBox pictureBoxCollectionWarmlyLocomotive;
private Button buttonadd;
private Button buttonRemove;
private Button buttonreFreshCollection;
private TextBox textBoxCollectionWarmlyLocomotive;
}
}

View File

@ -0,0 +1,65 @@
using WarmlyLocomotive.DrawningObjects;
using WarmlyLocomotive.Generics;
using WarmlyLocomotive.MovementStrategy;
namespace WarmlyLocomotive
{
public partial class FormWarmlyLocomotiveCollection : Form
{
private readonly CarsGenericCollection<DrawningWarmlyLocomotive,
DrawningObjectCar> _warmlylocomotives;
public FormWarmlyLocomotiveCollection()
{
InitializeComponent();
_warmlylocomotives = new CarsGenericCollection<DrawningWarmlyLocomotive, DrawningObjectCar>(pictureBoxCollectionWarmlyLocomotive.Width, pictureBoxCollectionWarmlyLocomotive.Height);
}
private void buttonAdd_Click(object sender, EventArgs e)
{
WarmlyLocomotiveForm form = new();
if (form.ShowDialog() == DialogResult.OK)
{
if (_warmlylocomotives + form.SelectedCar != null)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollectionWarmlyLocomotive.Image = _warmlylocomotives.ShowCars();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
}
private void buttonreFreshCollection_Click(object sender, EventArgs e)
{
pictureBoxCollectionWarmlyLocomotive.Image = _warmlylocomotives.ShowCars();
}
private void buttonRemove_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Удалить объект?", "Удаление",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
int pos;
if (textBoxCollectionWarmlyLocomotive.Text == null || !int.TryParse(textBoxCollectionWarmlyLocomotive.Text, out pos))
{
MessageBox.Show("Введите номер парковочного места");
return;
}
if (_warmlylocomotives - pos != null)
{
MessageBox.Show("Объект удален");
pictureBoxCollectionWarmlyLocomotive.Image = _warmlylocomotives.ShowCars();
}
else
{
MessageBox.Show("Не удалось удалить объект");
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -11,6 +11,7 @@ namespace WarmlyLocomotive
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new FormWarmlyLocomotiveCollection());
Application.Run(new WarmlyLocomotiveForm());
}
}

View File

@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WarmlyLocomotive.Generics
{
internal class SetGeneric<T>
where T : class
{
/// <summary>
/// Массив объектов, которые храним
/// </summary>
private readonly T?[] _places;
/// <summary>
/// Количество объектов в массиве
/// </summary>
public int Count => _places.Length;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="count"></param>
///
public int startPointer = 0;
public SetGeneric(int count)
{
_places = new T?[count];
}
/// <summary>
/// Добавление объекта в набор
/// </summary>
/// <param name="car">Добавляемый автомобиль</param>
/// <returns></returns>
public int Insert(T car)
{
if (_places[Count - 1] != null)
return -1;
return Insert(car, 0);
}
/// <summary>
/// Добавление объекта в набор на конкретную позицию
/// </summary>
/// <param name="car">Добавляемый автомобиль</param>
/// <param name="position">Позиция</param>
/// <returns></returns>
public int Insert(T car, int position)
{
int nullIndex = -1, i;
if (position < 0 || position >= Count)
return -1;
for (i = position; i < Count; i++)
{
if (_places[i] == null)
{
nullIndex = i;
break;
}
}
if (nullIndex < 0)
return -1;
for (i = nullIndex; i > position; i--)
{
_places[i] = _places[i - 1];
}
_places[position] = car;
return position;
}
/// <summary>
/// Удаление объекта из набора с конкретной позиции
/// </summary>
/// <param name="position"></param>
/// <returns></returns>
public bool Remove(int position)
{
if (position < Count && position >= 0)
{
_places[position] = null;
return true;
}
return false;
}
/// <summary>
/// Получение объекта из набора по позиции
/// </summary>
/// <param name="position"></param>
/// <returns></returns>
public T? Get(int position)
{
if (position < Count && position >= 0) { return _places[position]; }
return null;
}
}
}

View File

@ -14,11 +14,13 @@ namespace WarmlyLocomotive
private DrawningWarmlyLocomotive? _drawningWarmlyLocomotive;
private AbstractStrategy? _abstractStrategy;
private AbstractStrategy? _strategy;
public DrawningWarmlyLocomotive? SelectedCar { get; private set; }
public WarmlyLocomotiveForm()
{
InitializeComponent();
_strategy = null;
SelectedCar = null;
}
/// <summary>
/// Ìåòîä ïðîðèñîâêè ìàøèíû
@ -43,10 +45,17 @@ namespace WarmlyLocomotive
private void buttonCreate_Click(object sender, EventArgs e)
{
Random random = new();
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
Color dopColor = 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;
}
_drawningWarmlyLocomotive = new DrawningWarmlyLocomotive(random.Next(100, 300),
random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256),
random.Next(0, 256)),
color,
pictureBoxWarmlyLocomotive.Width, pictureBoxWarmlyLocomotive.Height);
_drawningWarmlyLocomotive.SetPosition(random.Next(10, 100), random.Next(10,
100));
@ -126,18 +135,34 @@ namespace WarmlyLocomotive
private void buttonCreate_Pro_Click(object sender, EventArgs e)
{
Random random = new();
_drawningWarmlyLocomotive = new DrawningPro(random.Next(100, 300),
random.Next(1000, 3000),
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)),
Convert.ToBoolean(random.Next(0, 2)),
Convert.ToBoolean(random.Next(0, 2)),
pictureBoxWarmlyLocomotive.Width, pictureBoxWarmlyLocomotive.Height);
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;
}
Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
ColorDialog dopDialog = new();
if (dopDialog.ShowDialog() == DialogResult.OK)
{
dopColor = dopDialog.Color;
}
_drawningWarmlyLocomotive = new DrawningWarmlyLocomotiveWithTrumpet(random.Next(100, 300),
random.Next(1000, 3000),
color,
dopColor,
Convert.ToBoolean(random.Next(0, 2)),
Convert.ToBoolean(random.Next(0, 2)),
pictureBoxWarmlyLocomotive.Width, pictureBoxWarmlyLocomotive.Height);
_drawningWarmlyLocomotive.SetPosition(random.Next(10, 100), random.Next(10,
100));
Draw();
}
private void buttonSelectCar_Click(object sender, EventArgs e)
{
SelectedCar = _drawningWarmlyLocomotive;
DialogResult = DialogResult.OK;
}
}
}

View File

@ -38,6 +38,7 @@
comboBoxWarmlyLocomotive = new ComboBox();
buttonStep = new Button();
buttonCreate_Pro = new Button();
buttonSelectCar = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxWarmlyLocomotive).BeginInit();
SuspendLayout();
//
@ -46,7 +47,7 @@
pictureBoxWarmlyLocomotive.Dock = DockStyle.Fill;
pictureBoxWarmlyLocomotive.Location = new Point(0, 0);
pictureBoxWarmlyLocomotive.Name = "pictureBoxWarmlyLocomotive";
pictureBoxWarmlyLocomotive.Size = new Size(884, 461);
pictureBoxWarmlyLocomotive.Size = new Size(884, 481);
pictureBoxWarmlyLocomotive.SizeMode = PictureBoxSizeMode.AutoSize;
pictureBoxWarmlyLocomotive.TabIndex = 0;
pictureBoxWarmlyLocomotive.TabStop = false;
@ -54,7 +55,7 @@
// buttonCreate
//
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreate.Location = new Point(210, 404);
buttonCreate.Location = new Point(216, 399);
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(119, 23);
buttonCreate.TabIndex = 1;
@ -67,7 +68,7 @@
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonLeft.BackgroundImage = (Image)resources.GetObject("buttonLeft.BackgroundImage");
buttonLeft.BackgroundImageLayout = ImageLayout.Zoom;
buttonLeft.Location = new Point(751, 400);
buttonLeft.Location = new Point(751, 420);
buttonLeft.Name = "buttonLeft";
buttonLeft.Size = new Size(30, 30);
buttonLeft.TabIndex = 2;
@ -79,7 +80,7 @@
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonUp.BackgroundImage = (Image)resources.GetObject("buttonUp.BackgroundImage");
buttonUp.BackgroundImageLayout = ImageLayout.Zoom;
buttonUp.Location = new Point(777, 372);
buttonUp.Location = new Point(777, 392);
buttonUp.Name = "buttonUp";
buttonUp.Size = new Size(30, 30);
buttonUp.TabIndex = 3;
@ -91,7 +92,7 @@
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonDown.BackgroundImage = (Image)resources.GetObject("buttonDown.BackgroundImage");
buttonDown.BackgroundImageLayout = ImageLayout.Zoom;
buttonDown.Location = new Point(777, 400);
buttonDown.Location = new Point(777, 420);
buttonDown.Name = "buttonDown";
buttonDown.Size = new Size(30, 30);
buttonDown.TabIndex = 4;
@ -103,7 +104,7 @@
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonRight.BackgroundImage = (Image)resources.GetObject("buttonRight.BackgroundImage");
buttonRight.BackgroundImageLayout = ImageLayout.Zoom;
buttonRight.Location = new Point(808, 400);
buttonRight.Location = new Point(808, 420);
buttonRight.Name = "buttonRight";
buttonRight.Size = new Size(30, 30);
buttonRight.TabIndex = 5;
@ -140,9 +141,20 @@
buttonCreate_Pro.UseVisualStyleBackColor = true;
buttonCreate_Pro.Click += buttonCreate_Pro_Click;
//
// buttonSelectCar
//
buttonSelectCar.Location = new Point(705, 99);
buttonSelectCar.Name = "buttonSelectCar";
buttonSelectCar.Size = new Size(133, 23);
buttonSelectCar.TabIndex = 11;
buttonSelectCar.Text = "Выбор тепловоза";
buttonSelectCar.UseVisualStyleBackColor = true;
buttonSelectCar.Click += buttonSelectCar_Click;
//
// WarmlyLocomotiveForm
//
ClientSize = new Size(884, 461);
ClientSize = new Size(884, 481);
Controls.Add(buttonSelectCar);
Controls.Add(buttonCreate_Pro);
Controls.Add(buttonStep);
Controls.Add(comboBoxWarmlyLocomotive);
@ -173,5 +185,6 @@
private ComboBox comboBoxWarmlyLocomotive;
private Button buttonStep;
private Button buttonCreate_Pro;
private Button buttonSelectCar;
}
}