Компания

This commit is contained in:
Kirill 2024-04-17 19:18:33 +04:00
parent 5939e2b489
commit 11306c4491
8 changed files with 665 additions and 21 deletions

View File

@ -0,0 +1,114 @@
using ProjectRoadTrain.Drawnings;
namespace ProjectRoadTrain.CollectionGenericObjects;
/// <summary>
/// Абстракция компании, хранящий коллекцию поездов
/// </summary>
public abstract class AbstractCompany
{
/// <summary>
/// Размер места (ширина)
/// </summary>
protected readonly int _placeSizeWidth = 200;
/// <summary>
/// Размер места (высота)
/// </summary>
protected readonly int _placeSizeHeight = 110;
/// <summary>
/// Ширина окна
/// </summary>
protected readonly int _pictureWidth;
/// <summary>
/// Высота окна
/// </summary>
protected readonly int _pictureHeight;
/// <summary>
/// Коллекция поездов
/// </summary>
protected ICollectionGenericObjects<DrawningTrain>? _collection = null;
/// <summary>
/// Вычисление максимального количества элементов, который можно разместить в окне
/// </summary>
private int GetMaxCount => _pictureWidth * _pictureHeight / (_placeSizeWidth * _placeSizeHeight);
/// <summary>
/// Конструктор
/// </summary>
/// <param name="picWidth">Ширина окна</param>
/// <param name="picHeight">Высота окна</param>
/// <param name="collection">Коллекция автомобилей</param>
public AbstractCompany(int picWidth, int picHeight,
ICollectionGenericObjects<DrawningTrain> collection)
{
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_collection = collection;
_collection.SetMaxCount = GetMaxCount;
}
/// <summary>
/// Перегрузка оператора сложения для класса
/// </summary>
/// <param name="company">Компания</param>
/// <param name="сruiser">Добавляемый объект</param>
/// <returns></returns>
public static int operator +(AbstractCompany company, DrawningTrain aircraft)
{
return company._collection.Insert(aircraft);
}
/// <summary>
/// Перегрузка оператора удаления для класса
/// </summary>
/// <param name="company">Компания</param>
/// <param name="position">Номер удаляемого объекта</param>
/// <returns></returns>
public static DrawningTrain operator -(AbstractCompany company, int position)
{
return company._collection?.Remove(position);
}
/// <summary>
/// Получение случайного объекта из коллекции
/// </summary>
/// <returns></returns>
public DrawningTrain? GetRandomObject()
{
Random rnd = new();
return _collection?.Get(rnd.Next(GetMaxCount));
}
/// <summary>
/// Вывод всей коллекции
/// </summary>
/// <returns></returns>
public Bitmap? Show()
{
Bitmap bitmap = new(_pictureWidth, _pictureHeight);
Graphics graphics = Graphics.FromImage(bitmap);
DrawBackgound(graphics);
SetObjectsPosition();
for (int i = 0; i < (_collection?.Count ?? 0); ++i)
{
DrawningTrain? obj = _collection?.Get(i);
obj?.DrawTransport(graphics);
}
return bitmap;
}
/// <summary>
/// Вывод заднего фона
/// </summary>
/// <param name="g"></param>
protected abstract void DrawBackgound(Graphics g);
/// <summary>
/// Расстановка объектов
/// </summary>
protected abstract void SetObjectsPosition();
}

View File

@ -0,0 +1,66 @@
using ProjectRoadTrain.Drawnings;
namespace ProjectRoadTrain.CollectionGenericObjects;
/// <summary>
/// Реализация абстрактной компании - каршеринг
/// </summary>
public class TrainSharingService : AbstractCompany
{
/// <summary>
/// Конструктор
/// </summary>
/// <param name="picWidth"></param>
/// <param name="picHeight"></param>
/// <param name="collection"></param>
public TrainSharingService(int picWidth, int picHeight,
ICollectionGenericObjects<DrawningTrain> collection) : base(picWidth, picHeight, collection)
{
}
protected override void DrawBackgound(Graphics g)
{
int width = _pictureWidth / _placeSizeWidth;
int height = _pictureHeight / _placeSizeHeight;
Pen pen = new(Color.Black, 2);
for (int i = 0; i < width + 1; i++)
{
for (int j = 0; j < height + 1; ++j)
{
g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth - _placeSizeWidth + 8, j * _placeSizeHeight);
g.DrawLine(pen, i * _placeSizeWidth - _placeSizeWidth + 8, j * _placeSizeHeight, i * _placeSizeWidth - _placeSizeWidth + 8, j * _placeSizeHeight - _placeSizeHeight);
}
}
}
protected override void SetObjectsPosition()
{
int width = _pictureWidth / _placeSizeWidth;
int height = _pictureHeight / _placeSizeHeight;
int curWidth = width - 1;
int curHeight = 0;
for (int i = 0; i < (_collection?.Count ?? 0); i++)
{
if (_collection.Get(i) != null)
{
_collection.Get(i).SetPictureSize(_pictureWidth, _pictureHeight);
_collection.Get(i).SetPosition(_placeSizeWidth * curWidth + 10, curHeight * _placeSizeHeight + 10);
}
if (curWidth > 0)
curWidth--;
else
{
curWidth = width - 1;
curHeight++;
}
if (curHeight >= height)
{
return;
}
}
}
}

View File

@ -45,14 +45,14 @@
pictureBoxRoadTrain.Dock = DockStyle.Fill; pictureBoxRoadTrain.Dock = DockStyle.Fill;
pictureBoxRoadTrain.Location = new Point(0, 0); pictureBoxRoadTrain.Location = new Point(0, 0);
pictureBoxRoadTrain.Name = "pictureBoxRoadTrain"; pictureBoxRoadTrain.Name = "pictureBoxRoadTrain";
pictureBoxRoadTrain.Size = new Size(800, 450); pictureBoxRoadTrain.Size = new Size(886, 501);
pictureBoxRoadTrain.TabIndex = 0; pictureBoxRoadTrain.TabIndex = 0;
pictureBoxRoadTrain.TabStop = false; pictureBoxRoadTrain.TabStop = false;
// //
// buttonCreateRoadTrain // buttonCreateRoadTrain
// //
buttonCreateRoadTrain.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; buttonCreateRoadTrain.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreateRoadTrain.Location = new Point(12, 415); buttonCreateRoadTrain.Location = new Point(12, 466);
buttonCreateRoadTrain.Name = "buttonCreateRoadTrain"; buttonCreateRoadTrain.Name = "buttonCreateRoadTrain";
buttonCreateRoadTrain.Size = new Size(175, 23); buttonCreateRoadTrain.Size = new Size(175, 23);
buttonCreateRoadTrain.TabIndex = 1; buttonCreateRoadTrain.TabIndex = 1;
@ -65,7 +65,7 @@
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonDown.BackgroundImage = Properties.Resources.arrowDown; buttonDown.BackgroundImage = Properties.Resources.arrowDown;
buttonDown.BackgroundImageLayout = ImageLayout.Stretch; buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
buttonDown.Location = new Point(666, 409); buttonDown.Location = new Point(752, 460);
buttonDown.Name = "buttonDown"; buttonDown.Name = "buttonDown";
buttonDown.Size = new Size(35, 35); buttonDown.Size = new Size(35, 35);
buttonDown.TabIndex = 2; buttonDown.TabIndex = 2;
@ -77,7 +77,7 @@
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonUp.BackgroundImage = Properties.Resources.arrowUp; buttonUp.BackgroundImage = Properties.Resources.arrowUp;
buttonUp.BackgroundImageLayout = ImageLayout.Stretch; buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
buttonUp.Location = new Point(666, 329); buttonUp.Location = new Point(752, 380);
buttonUp.Name = "buttonUp"; buttonUp.Name = "buttonUp";
buttonUp.Size = new Size(35, 35); buttonUp.Size = new Size(35, 35);
buttonUp.TabIndex = 3; buttonUp.TabIndex = 3;
@ -89,7 +89,7 @@
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonLeft.BackgroundImage = Properties.Resources.arrowLeft; buttonLeft.BackgroundImage = Properties.Resources.arrowLeft;
buttonLeft.BackgroundImageLayout = ImageLayout.Stretch; buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
buttonLeft.Location = new Point(632, 370); buttonLeft.Location = new Point(718, 421);
buttonLeft.Name = "buttonLeft"; buttonLeft.Name = "buttonLeft";
buttonLeft.Size = new Size(35, 35); buttonLeft.Size = new Size(35, 35);
buttonLeft.TabIndex = 4; buttonLeft.TabIndex = 4;
@ -101,7 +101,7 @@
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonRight.BackgroundImage = Properties.Resources.arrowRight; buttonRight.BackgroundImage = Properties.Resources.arrowRight;
buttonRight.BackgroundImageLayout = ImageLayout.Stretch; buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
buttonRight.Location = new Point(699, 370); buttonRight.Location = new Point(785, 421);
buttonRight.Name = "buttonRight"; buttonRight.Name = "buttonRight";
buttonRight.Size = new Size(35, 35); buttonRight.Size = new Size(35, 35);
buttonRight.TabIndex = 5; buttonRight.TabIndex = 5;
@ -111,7 +111,7 @@
// buttonCreateTrain // buttonCreateTrain
// //
buttonCreateTrain.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; buttonCreateTrain.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreateTrain.Location = new Point(205, 415); buttonCreateTrain.Location = new Point(205, 466);
buttonCreateTrain.Name = "buttonCreateTrain"; buttonCreateTrain.Name = "buttonCreateTrain";
buttonCreateTrain.Size = new Size(175, 23); buttonCreateTrain.Size = new Size(175, 23);
buttonCreateTrain.TabIndex = 6; buttonCreateTrain.TabIndex = 6;
@ -125,7 +125,7 @@
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxStrategy.FormattingEnabled = true; comboBoxStrategy.FormattingEnabled = true;
comboBoxStrategy.Items.AddRange(new object[] { "К центру", "К краю" }); comboBoxStrategy.Items.AddRange(new object[] { "К центру", "К краю" });
comboBoxStrategy.Location = new Point(667, 12); comboBoxStrategy.Location = new Point(753, 12);
comboBoxStrategy.Name = "comboBoxStrategy"; comboBoxStrategy.Name = "comboBoxStrategy";
comboBoxStrategy.Size = new Size(121, 23); comboBoxStrategy.Size = new Size(121, 23);
comboBoxStrategy.TabIndex = 7; comboBoxStrategy.TabIndex = 7;
@ -133,7 +133,7 @@
// buttonStrategyStep // buttonStrategyStep
// //
buttonStrategyStep.Anchor = AnchorStyles.Top | AnchorStyles.Right; buttonStrategyStep.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonStrategyStep.Location = new Point(713, 41); buttonStrategyStep.Location = new Point(799, 41);
buttonStrategyStep.Name = "buttonStrategyStep"; buttonStrategyStep.Name = "buttonStrategyStep";
buttonStrategyStep.Size = new Size(75, 23); buttonStrategyStep.Size = new Size(75, 23);
buttonStrategyStep.TabIndex = 8; buttonStrategyStep.TabIndex = 8;
@ -145,7 +145,7 @@
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450); ClientSize = new Size(886, 501);
Controls.Add(buttonStrategyStep); Controls.Add(buttonStrategyStep);
Controls.Add(comboBoxStrategy); Controls.Add(comboBoxStrategy);
Controls.Add(buttonCreateTrain); Controls.Add(buttonCreateTrain);

View File

@ -1,15 +1,14 @@
//using System; using System;
//using System.Collections.Generic; using System.Collections.Generic;
//using System.ComponentModel; using System.ComponentModel;
//using System.Data; using System.Data;
//using System.Drawing; using System.Drawing;
//using System.Linq; using System.Linq;
//using System.Text; using System.Text;
//using System.Threading.Tasks; using System.Threading.Tasks;
//using System.Windows.Forms; using System.Windows.Forms;
using ProjectRoadTrain.Drawnings; using ProjectRoadTrain.Drawnings;
using ProjectRoadTrain.MovementStrategy; using ProjectRoadTrain.MovementStrategy;
//using ProjectRoadTrain.MovementStrategy;
namespace ProjectRoadTrain; namespace ProjectRoadTrain;
/// <summary> /// <summary>
@ -27,6 +26,8 @@ public partial class FormRoadTrain : Form
/// </summary> /// </summary>
private AbstractStrategy? _strategy; private AbstractStrategy? _strategy;
public DrawningTrain SetTrain { get; internal set; }
/// <summary> /// <summary>
/// Конструктор формы /// Конструктор формы

View File

@ -0,0 +1,178 @@
namespace ProjectRoadTrain
{
partial class FormTrainCollection
{
/// <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()
{
groupBoxTools = new GroupBox();
maskedTextBox = new MaskedTextBox();
buttonRefresh = new Button();
buttonGoToCheck = new Button();
buttonRemoveTrain = new Button();
buttonAddRoadTrain = new Button();
buttonAddTrain = new Button();
comboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox();
groupBoxTools.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
SuspendLayout();
//
// groupBoxTools
//
groupBoxTools.Controls.Add(maskedTextBox);
groupBoxTools.Controls.Add(buttonRefresh);
groupBoxTools.Controls.Add(buttonGoToCheck);
groupBoxTools.Controls.Add(buttonRemoveTrain);
groupBoxTools.Controls.Add(buttonAddRoadTrain);
groupBoxTools.Controls.Add(buttonAddTrain);
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(753, 0);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(269, 589);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
//
// maskedTextBox
//
maskedTextBox.Location = new Point(19, 260);
maskedTextBox.Mask = "00";
maskedTextBox.Name = "maskedTextBox";
maskedTextBox.Size = new Size(228, 23);
maskedTextBox.TabIndex = 6;
maskedTextBox.ValidatingType = typeof(int);
//
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.Location = new Point(20, 483);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(229, 59);
buttonRefresh.TabIndex = 5;
buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true;
buttonRefresh.Click += ButtonRefresh_Click;
//
// buttonGoToCheck
//
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonGoToCheck.Location = new Point(18, 389);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(229, 59);
buttonGoToCheck.TabIndex = 4;
buttonGoToCheck.Text = "Передать на тесты";
buttonGoToCheck.UseVisualStyleBackColor = true;
buttonGoToCheck.Click += ButtonGoToCheck_Click;
//
// buttonRemoveTrain
//
buttonRemoveTrain.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRemoveTrain.Location = new Point(20, 289);
buttonRemoveTrain.Name = "buttonRemoveTrain";
buttonRemoveTrain.Size = new Size(229, 59);
buttonRemoveTrain.TabIndex = 3;
buttonRemoveTrain.Text = "Удалить поезд";
buttonRemoveTrain.UseVisualStyleBackColor = true;
buttonRemoveTrain.Click += ButtonRemoveTrain_Click;
//
// buttonAddRoadTrain
//
buttonAddRoadTrain.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddRoadTrain.Location = new Point(19, 152);
buttonAddRoadTrain.Name = "buttonAddRoadTrain";
buttonAddRoadTrain.Size = new Size(229, 59);
buttonAddRoadTrain.TabIndex = 2;
buttonAddRoadTrain.Text = "Добавить автопоезд";
buttonAddRoadTrain.UseVisualStyleBackColor = true;
buttonAddRoadTrain.Click += ButtonAddRoadTrain_Click;
//
// buttonAddTrain
//
buttonAddTrain.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddTrain.Location = new Point(19, 87);
buttonAddTrain.Name = "buttonAddTrain";
buttonAddTrain.Size = new Size(229, 59);
buttonAddTrain.TabIndex = 1;
buttonAddTrain.Text = "Добавить поезда";
buttonAddTrain.UseVisualStyleBackColor = true;
buttonAddTrain.Click += ButtonAddTrain_Click;
//
// comboBoxSelectorCompany
//
comboBoxSelectorCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
comboBoxSelectorCompany.Location = new Point(19, 22);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
comboBoxSelectorCompany.Size = new Size(229, 23);
comboBoxSelectorCompany.TabIndex = 0;
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
//
// pictureBox
//
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 0);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(753, 589);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
// FormTrainCollection
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1022, 589);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
Name = "FormTrainCollection";
Text = "Коллекция поездов";
groupBoxTools.ResumeLayout(false);
groupBoxTools.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxTools;
private ComboBox comboBoxSelectorCompany;
private Button buttonAddTrain;
private Button buttonAddRoadTrain;
private MaskedTextBox maskedTextBox;
private Button buttonRefresh;
private Button buttonGoToCheck;
private Button buttonRemoveTrain;
private PictureBox pictureBox;
}
}

View File

@ -0,0 +1,165 @@
using ProjectRoadTrain.CollectionGenericObjects;
using ProjectRoadTrain.Drawnings;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProjectRoadTrain
{
public partial class FormTrainCollection : Form
{
/// <summary>
/// Компания
/// </summary>
private AbstractCompany? _company = null;
/// <summary>
/// Конструктор
/// </summary>
public FormTrainCollection()
{
InitializeComponent();
}
private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comboBoxSelectorCompany.Text)
{
case "Хранилище":
_company = new TrainSharingService(pictureBox.Width,
pictureBox.Height, new MassiveGenericObjects<DrawningTrain>());
break;
}
}
/// <summary>
/// Создание объекта класса-перемещения
/// </summary>
/// <param name="type">Тип создаваемого объекта</param>
private void CreateObject(string type)
{
if (_company == null)
{
return;
}
Random random = new();
DrawningTrain drawningTrain;
switch (type)
{
case nameof(DrawningTrain):
drawningTrain = new DrawningTrain(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
break;
case nameof(DrawningRoadTrain):
drawningTrain = new DrawningRoadTrain(random.Next(100, 300), random.Next(1000, 3000),
GetColor(random), GetColor(random), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
break;
default:
return;
}
if (_company + drawningTrain != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
/// <summary>
/// Получение цвета
/// </summary>
/// <param name="random">Генератор случайных чисел</param>
/// <returns></returns>
private static Color GetColor(Random random)
{
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;
}
return color;
}
//private void ButtonAddTrain_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningTrain));
//private void ButtonRoadTrain_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningRoadTrain));
private void ButtonAddTrain_Click(object sender, EventArgs e)
{
CreateObject(nameof(DrawningTrain));
}
private void ButtonAddRoadTrain_Click(object sender, EventArgs e)
{
CreateObject(nameof(DrawningRoadTrain));
}
private void ButtonRemoveTrain_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null)
{
return;
}
if (MessageBox.Show("Удалить объект?", "Удаление",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
{
return;
}
int pos = Convert.ToInt32(maskedTextBox.Text);
if (_company - pos != null)
{
MessageBox.Show("Объект удален!");
pictureBox.Image = _company.Show();
}
else
{
MessageBox.Show("Не удалось удалить объект");
}
}
private void ButtonGoToCheck_Click(object sender, EventArgs e)
{
if (_company == null)
{
return;
}
DrawningTrain? train = null;
int counter = 100;
while (train == null)
{
train = _company.GetRandomObject();
counter--;
if (counter <= 0)
{
break;
}
}
if (train == null)
{
return;
}
FormRoadTrain form = new()
{
SetTrain = train
};
form.ShowDialog();
}
private void ButtonRefresh_Click(object sender, EventArgs e)
{
if (_company == null)
{
return;
}
pictureBox.Image = _company.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,7 +11,7 @@ namespace ProjectRoadTrain
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
Application.Run(new FormRoadTrain()); Application.Run(new FormTrainCollection());
} }
} }
} }