компании
This commit is contained in:
parent
343844e578
commit
b95fc3e7cd
62
ProjectCar/ProjectCar/CollectionGenericObjects/Autopark.cs
Normal file
62
ProjectCar/ProjectCar/CollectionGenericObjects/Autopark.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using ProjectGasMachine.Drawnings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGasMachine.CollectionGenericObjects;
|
||||
|
||||
public class Autopark : AbstractCompany
|
||||
{
|
||||
public Autopark(int picWidth, int picHeight, ICollectionGenericObjects<DrawningMachine> collection) : base(picWidth, picHeight, collection)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void DrawBackground(Graphics g)
|
||||
{
|
||||
Pen pen = new(Color.Black, 2);
|
||||
Pen Pen2 = new(Color.Black, 3);
|
||||
|
||||
for (int i = 0; i < _pictureHeight / _placeSizeHeight; i++)
|
||||
{
|
||||
int y = _placeSizeHeight;
|
||||
y *= i;
|
||||
|
||||
for (int j = 0; j <= _pictureWidth / _placeSizeWidth; j++)
|
||||
{
|
||||
int x = _placeSizeWidth;
|
||||
x *= j;
|
||||
|
||||
g.DrawLine(Pen2, x, y, x + _placeSizeWidth / 2, y);
|
||||
g.DrawLine(Pen2, x, y + _placeSizeHeight - 10, x + _placeSizeWidth / 2, y + _placeSizeHeight - 10);
|
||||
g.DrawLine(pen, x, y, x, y + _placeSizeHeight - 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override void SetObjectsPosition()
|
||||
{
|
||||
int n = 0;
|
||||
int m = 0;
|
||||
|
||||
for (int i = 0; i < (_collection?.Count ?? 0); i++)
|
||||
{
|
||||
if (_collection?.Get(i) != null)
|
||||
{
|
||||
int x = 5 + _placeSizeWidth * n;
|
||||
int y = (-3 + _placeSizeHeight * (_pictureHeight / _placeSizeHeight - 1)) - _placeSizeHeight * m;
|
||||
|
||||
_collection?.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight);
|
||||
_collection?.Get(i)?.SetPosition(x, y);
|
||||
}
|
||||
|
||||
if (n < _pictureWidth / _placeSizeWidth)
|
||||
n++;
|
||||
else
|
||||
{
|
||||
n = 0;
|
||||
m++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
using ProjectGasMachine.Drawnings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGasMachine.CollectionGenericObjects;
|
||||
|
||||
public class MachineSharingService : AbstractCompany
|
||||
{
|
||||
public MachineSharingService(int picWidth, int picHeight, ICollectionGenericObjects<DrawningMachine> collection) : base(picWidth, picHeight, collection)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void DrawBackground(Graphics g)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override void SetObjectsPosition()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
28
ProjectCar/ProjectCar/FormGasMachine.Designer.cs
generated
28
ProjectCar/ProjectCar/FormGasMachine.Designer.cs
generated
@ -28,29 +28,16 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
buttonCreate = new Button();
|
||||
buttonLeft = new Button();
|
||||
buttonRight = new Button();
|
||||
buttonUp = new Button();
|
||||
buttonDown = new Button();
|
||||
pictureBoxGasMachine = new PictureBox();
|
||||
buttonCreateMachine = new Button();
|
||||
comboBoxStrategy = new ComboBox();
|
||||
buttonStrategyStep = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxGasMachine).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreate.Location = new Point(12, 493);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(216, 23);
|
||||
buttonCreate.TabIndex = 1;
|
||||
buttonCreate.Text = "Создать газовоз";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
@ -108,17 +95,6 @@
|
||||
pictureBoxGasMachine.TabIndex = 0;
|
||||
pictureBoxGasMachine.TabStop = false;
|
||||
//
|
||||
// buttonCreateMachine
|
||||
//
|
||||
buttonCreateMachine.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreateMachine.Location = new Point(245, 493);
|
||||
buttonCreateMachine.Name = "buttonCreateMachine";
|
||||
buttonCreateMachine.Size = new Size(216, 23);
|
||||
buttonCreateMachine.TabIndex = 6;
|
||||
buttonCreateMachine.Text = "Создать орнамент на колесах";
|
||||
buttonCreateMachine.UseVisualStyleBackColor = true;
|
||||
buttonCreateMachine.Click += ButtonCreateMachine_Click;
|
||||
//
|
||||
// comboBoxStrategy
|
||||
//
|
||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
@ -146,12 +122,10 @@
|
||||
ClientSize = new Size(988, 528);
|
||||
Controls.Add(buttonStrategyStep);
|
||||
Controls.Add(comboBoxStrategy);
|
||||
Controls.Add(buttonCreateMachine);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(pictureBoxGasMachine);
|
||||
Name = "FormGasMachine";
|
||||
Text = "Газовоз";
|
||||
@ -160,13 +134,11 @@
|
||||
}
|
||||
|
||||
#endregion
|
||||
private Button buttonCreate;
|
||||
private Button buttonLeft;
|
||||
private Button buttonRight;
|
||||
private Button buttonUp;
|
||||
private Button buttonDown;
|
||||
private PictureBox pictureBoxGasMachine;
|
||||
private Button buttonCreateMachine;
|
||||
private ComboBox comboBoxStrategy;
|
||||
private Button buttonStrategyStep;
|
||||
}
|
||||
|
@ -15,6 +15,18 @@ public partial class FormGasMachine : Form
|
||||
/// </summary>
|
||||
private AbstractStrategy? _strategy;
|
||||
|
||||
public DrawningMachine SetMachine
|
||||
{
|
||||
set
|
||||
{
|
||||
_drawningMachine = value;
|
||||
_drawningMachine.SetPictureSize(pictureBoxGasMachine.Height, pictureBoxGasMachine.Width);
|
||||
comboBoxStrategy.Enabled = true;
|
||||
_strategy = null;
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// конструктор формы
|
||||
/// </summary>
|
||||
@ -41,57 +53,6 @@ public partial class FormGasMachine : Form
|
||||
_drawningMachine.DrawTransport(gr);
|
||||
pictureBoxGasMachine.Image = bmp;
|
||||
}
|
||||
/// <summary>
|
||||
/// создание объекта класса-перемещение
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
private void CreateObject(string type)
|
||||
{
|
||||
Random random = new();
|
||||
switch (type)
|
||||
{
|
||||
case nameof(DrawningMachine):
|
||||
_drawningMachine = new DrawningMachine(random.Next(100, 300), random.Next(1000, 3000),
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
|
||||
break;
|
||||
case nameof(DrawningGasMachine):
|
||||
_drawningMachine = new DrawningGasMachine(random.Next(100, 300), random.Next(1000, 3000),
|
||||
Color.FromArgb(random.Next(0, 256), 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), random.Next(0, 256)),
|
||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
_drawningMachine.SetPictureSize(pictureBoxGasMachine.Width, pictureBoxGasMachine.Height);
|
||||
_drawningMachine.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
_strategy = null;
|
||||
comboBoxStrategy.Enabled = true;
|
||||
Draw();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// обработка нажатия кнопки "создать газовоз"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonCreate_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningGasMachine));
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// обработка нажатия кнопки "создать орнамент на колесах"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
|
||||
private void ButtonCreateMachine_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningMachine));
|
||||
|
||||
|
||||
|
||||
|
173
ProjectCar/ProjectCar/FormGasMachineCollection.Designer.cs
generated
Normal file
173
ProjectCar/ProjectCar/FormGasMachineCollection.Designer.cs
generated
Normal file
@ -0,0 +1,173 @@
|
||||
namespace ProjectGasMachine
|
||||
{
|
||||
partial class FormGasMachineCollection
|
||||
{
|
||||
/// <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();
|
||||
buttonRefresh = new Button();
|
||||
buttonGoToCheck = new Button();
|
||||
buttonRemoveMachine = new Button();
|
||||
maskedTextBoxPosition = new MaskedTextBox();
|
||||
buttonAddMachine = new Button();
|
||||
buttonAddGasMachine = new Button();
|
||||
comboBoxSelectorCompany = new ComboBox();
|
||||
pictureBox = new PictureBox();
|
||||
groupBoxTools.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBoxTools
|
||||
//
|
||||
groupBoxTools.Controls.Add(buttonRefresh);
|
||||
groupBoxTools.Controls.Add(buttonGoToCheck);
|
||||
groupBoxTools.Controls.Add(buttonRemoveMachine);
|
||||
groupBoxTools.Controls.Add(maskedTextBoxPosition);
|
||||
groupBoxTools.Controls.Add(buttonAddMachine);
|
||||
groupBoxTools.Controls.Add(buttonAddGasMachine);
|
||||
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
||||
groupBoxTools.Dock = DockStyle.Right;
|
||||
groupBoxTools.Location = new Point(727, 0);
|
||||
groupBoxTools.Name = "groupBoxTools";
|
||||
groupBoxTools.Size = new Size(196, 543);
|
||||
groupBoxTools.TabIndex = 0;
|
||||
groupBoxTools.TabStop = false;
|
||||
groupBoxTools.Text = "Инструменты";
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonRefresh.Location = new Point(6, 487);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(184, 50);
|
||||
buttonRefresh.TabIndex = 7;
|
||||
buttonRefresh.Text = "Обновить";
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
buttonRefresh.Click += ButtonRefresh_Click;
|
||||
//
|
||||
// buttonGoToCheck
|
||||
//
|
||||
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonGoToCheck.Location = new Point(6, 365);
|
||||
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||
buttonGoToCheck.Size = new Size(184, 50);
|
||||
buttonGoToCheck.TabIndex = 6;
|
||||
buttonGoToCheck.Text = "Передать на тесты";
|
||||
buttonGoToCheck.UseVisualStyleBackColor = true;
|
||||
buttonGoToCheck.Click += ButtonGoToCheck_Click;
|
||||
//
|
||||
// buttonRemoveMachine
|
||||
//
|
||||
buttonRemoveMachine.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonRemoveMachine.Location = new Point(6, 265);
|
||||
buttonRemoveMachine.Name = "buttonRemoveMachine";
|
||||
buttonRemoveMachine.Size = new Size(184, 50);
|
||||
buttonRemoveMachine.TabIndex = 5;
|
||||
buttonRemoveMachine.Text = "Удалить газовоз";
|
||||
buttonRemoveMachine.UseVisualStyleBackColor = true;
|
||||
buttonRemoveMachine.Click += ButtonRemoveMachine_Click;
|
||||
//
|
||||
// maskedTextBoxPosition
|
||||
//
|
||||
maskedTextBoxPosition.Location = new Point(6, 236);
|
||||
maskedTextBoxPosition.Mask = "00";
|
||||
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||
maskedTextBoxPosition.Size = new Size(184, 23);
|
||||
maskedTextBoxPosition.TabIndex = 4;
|
||||
maskedTextBoxPosition.ValidatingType = typeof(int);
|
||||
//
|
||||
// buttonAddMachine
|
||||
//
|
||||
buttonAddMachine.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonAddMachine.Location = new Point(6, 140);
|
||||
buttonAddMachine.Name = "buttonAddMachine";
|
||||
buttonAddMachine.Size = new Size(184, 50);
|
||||
buttonAddMachine.TabIndex = 2;
|
||||
buttonAddMachine.Text = "Добавление грузовика";
|
||||
buttonAddMachine.UseVisualStyleBackColor = true;
|
||||
buttonAddMachine.Click += ButtonAddMachine_Click;
|
||||
//
|
||||
// buttonAddGasMachine
|
||||
//
|
||||
buttonAddGasMachine.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
buttonAddGasMachine.Location = new Point(6, 84);
|
||||
buttonAddGasMachine.Name = "buttonAddGasMachine";
|
||||
buttonAddGasMachine.Size = new Size(184, 50);
|
||||
buttonAddGasMachine.TabIndex = 1;
|
||||
buttonAddGasMachine.Text = "Добавление газовоза";
|
||||
buttonAddGasMachine.UseVisualStyleBackColor = true;
|
||||
buttonAddGasMachine.Click += ButtonAddGasMachine_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(6, 22);
|
||||
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
||||
comboBoxSelectorCompany.Size = new Size(184, 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(727, 543);
|
||||
pictureBox.TabIndex = 3;
|
||||
pictureBox.TabStop = false;
|
||||
//
|
||||
// FormGasMachineCollection
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(923, 543);
|
||||
Controls.Add(pictureBox);
|
||||
Controls.Add(groupBoxTools);
|
||||
Name = "FormGasMachineCollection";
|
||||
Text = "Коллекция газовозов";
|
||||
groupBoxTools.ResumeLayout(false);
|
||||
groupBoxTools.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxTools;
|
||||
private ComboBox comboBoxSelectorCompany;
|
||||
private Button buttonAddMachine;
|
||||
private Button buttonAddGasMachine;
|
||||
private Button buttonRemoveMachine;
|
||||
private MaskedTextBox maskedTextBoxPosition;
|
||||
private PictureBox pictureBox;
|
||||
private Button buttonRefresh;
|
||||
private Button buttonGoToCheck;
|
||||
}
|
||||
}
|
186
ProjectCar/ProjectCar/FormGasMachineCollection.cs
Normal file
186
ProjectCar/ProjectCar/FormGasMachineCollection.cs
Normal file
@ -0,0 +1,186 @@
|
||||
using ProjectGasMachine.CollectionGenericObjects;
|
||||
using ProjectGasMachine.Drawnings;
|
||||
|
||||
namespace ProjectGasMachine
|
||||
{
|
||||
/// <summary>
|
||||
/// Форма работы с компанией и ее коллекцией
|
||||
/// </summary>
|
||||
public partial class FormGasMachineCollection : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Компания
|
||||
/// </summary>
|
||||
private AbstractCompany? _company = null;
|
||||
|
||||
/// <summary>
|
||||
/// конструктор
|
||||
/// </summary>
|
||||
public FormGasMachineCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Выбор компании
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
switch (comboBoxSelectorCompany.Text)
|
||||
{
|
||||
case "Хранилище":
|
||||
_company = new Autopark(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawningMachine>());
|
||||
break;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Создание объекта класса-перемещения
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
private void CreateObject(string type)
|
||||
{
|
||||
if (_company == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Random random = new();
|
||||
DrawningMachine drawningMachine;
|
||||
switch (type)
|
||||
{
|
||||
case nameof(DrawningMachine):
|
||||
drawningMachine = new DrawningMachine(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
|
||||
break;
|
||||
case nameof(DrawningGasMachine):
|
||||
drawningMachine = new DrawningGasMachine(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 + drawningMachine != -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// добавление газовоза
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddGasMachine_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningGasMachine));
|
||||
|
||||
/// <summary>
|
||||
/// добавление грузовика
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddMachine_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningMachine));
|
||||
|
||||
/// <summary>
|
||||
/// удаление объекта
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRemoveMachine_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text) || _company == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (MessageBox.Show("Удалить объект", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
if (_company - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBox.Image = _company.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Передача объекта в другую форму
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonGoToCheck_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_company == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DrawningMachine? machine = null;
|
||||
int counter = 100;
|
||||
|
||||
while (machine == null)
|
||||
{
|
||||
machine = _company.GetRandomObject();
|
||||
counter--;
|
||||
if (counter <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (machine == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FormGasMachine form = new()
|
||||
{
|
||||
SetMachine = machine
|
||||
};
|
||||
form.ShowDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перерисовка коллекции
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRefresh_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_company == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
pictureBox.Image = _company.Show();
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectCar/ProjectCar/FormGasMachineCollection.resx
Normal file
120
ProjectCar/ProjectCar/FormGasMachineCollection.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -11,7 +11,7 @@ namespace ProjectGasMachine
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormGasMachine());
|
||||
Application.Run(new FormGasMachineCollection());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user