Почти готовая

This commit is contained in:
xom9kxom9k 2024-03-17 14:18:19 +04:00
parent d187881123
commit 485b0683d8
14 changed files with 678 additions and 89 deletions

View File

@ -0,0 +1,118 @@
using AntiAircraftGun.CollectionGenereticObject;
using AntiAircraftGun.Drawnings;
namespace AntiAircraftGun.CollectionGenereticObjects;
/// <summary>
/// Абстракция компании, хранящий коллекцию автомобилей
/// </summary>
public abstract class AbstractCompany
{
/// <summary>
/// Размер места (ширина)
/// </summary>
protected readonly int _placeSizeWidth = 210;
/// <summary>
/// Размер места (высота)
/// </summary>
protected readonly int _placeSizeHeight = 80;
/// <summary>
/// Ширина окна
/// </summary>
protected readonly int _pictureWidth;
/// <summary>
/// Высота окна
/// </summary>
protected readonly int _pictureHeight;
/// <summary>
/// Коллекция поездов
/// </summary>
protected ICollectionGenericObjects<DrawningArmoredCar>? _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<DrawningArmoredCar> collection)
{
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_collection = collection;
_collection.SetMaxCount = GetMaxCount;
}
/// <summary>
/// Перегрузка оператора сложения для класса
/// </summary>
/// <param name="company">Компания</param>
/// <param name="car">Добавляемый объект</param>
/// <returns></returns>
public static int operator +(AbstractCompany company, DrawningArmoredCar car)
{
return company._collection.Insert(car);
}
/// <summary>
/// Перегрузка оператора удаления для класса
/// </summary>
/// <param name="company">Компания</param>
/// <param name="position">Номер удаляемого объекта</param>
/// <returns></returns>
public static DrawningArmoredCar? operator -(AbstractCompany company, int position)
{
return company._collection?.Remove(position);
}
/// <summary>
/// Получение случайного объекта из коллекции
/// </summary>
/// <returns></returns>
public DrawningArmoredCar? 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)
{
DrawningArmoredCar? 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,54 @@
using AntiAircraftGun.CollectionGenereticObject;
using AntiAircraftGun.Drawnings;
namespace AntiAircraftGun.CollectionGenereticObjects;
/// <summary>
/// Реализация абстрактной компании - база бронемашин
/// </summary>
public class CarBase : AbstractCompany
{
/// <summary>
/// Конструктор
/// </summary>
/// <param name="picWidth"></param>
/// <param name="picHeight"></param>
/// <param name="collection"></param>
public CarBase(int picWidth, int picHeight, ICollectionGenericObjects<DrawningArmoredCar> collection) : base(picWidth, picHeight, collection)
{
}
protected override void DrawBackgound(Graphics g)
{
Pen pen = new(Color.Black);
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
{
for (int j = 0; j < _pictureHeight / _placeSizeHeight; j++)
{
g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * j), new((int)(_placeSizeWidth * (i + 0.5f)), _placeSizeHeight * j));
g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * j), new(_placeSizeWidth * i, _placeSizeHeight * (j + 1)));
}
g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * (_pictureHeight / _placeSizeHeight)), new((int)(_placeSizeWidth * (i + 0.5f)), _placeSizeHeight * (_pictureHeight / _placeSizeHeight)));
}
}
protected override void SetObjectsPosition()
{
int n = 0;
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
{
for (int j = 0; j < _pictureHeight / _placeSizeHeight; j++)
{
DrawningArmoredCar? drawingTrans = _collection?.Get(n);
n++;
if (drawingTrans != null)
{
drawingTrans.SetPictureSize(_pictureWidth, _pictureHeight);
drawingTrans.SetPosition(i * _placeSizeWidth + 5, j * _placeSizeHeight + 5);
}
}
}
}
}

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AntiAircraftGun.Drawnings;
namespace AntiAircraftGun.CollectionGenereticObject;
/// <summary>

View File

@ -4,7 +4,7 @@ namespace AntiAircraftGun.Drawnings;
/// <summary>
/// Класс отвечающий за прорисовку и перемещение объекта - сущности
/// </summary>
public class DrawningAntiAircraftGun : DrawningAircraftGun
public class DrawningAntiAircraftGun : DrawningArmoredCar
{
/// <summary>
/// Конструктор

View File

@ -2,12 +2,12 @@
namespace AntiAircraftGun.Drawnings;
public class DrawningAircraftGun
public class DrawningArmoredCar
{
/// <summary>
/// Класс-сущность
/// </summary>
public EntityAircraftGun? EntityAircraftGun { get; protected set; }
public EntityArmoredCar? EntityAircraftGun { get; protected set; }
/// <summary>
/// Ширина
@ -62,7 +62,7 @@ public class DrawningAircraftGun
/// <summary>
/// Пустой конструктор
/// </summary>
private DrawningAircraftGun()
private DrawningArmoredCar()
{
_pictureWidth = null;
_pictureHeight = null;
@ -76,9 +76,9 @@ public class DrawningAircraftGun
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Основной цвет</param>
public DrawningAircraftGun(int speed, double weight, Color bodyColor) : this()
public DrawningArmoredCar(int speed, double weight, Color bodyColor) : this()
{
EntityAircraftGun = new EntityAircraftGun(speed, weight, bodyColor);
EntityAircraftGun = new EntityArmoredCar(speed, weight, bodyColor);
}
/// <summary>
@ -86,7 +86,7 @@ public class DrawningAircraftGun
/// </summary>
/// <param name="drawningGunWidth">Ширина прорисовки зенитной установки</param>
/// <param name="drawningGunHeight">Высота прорисовки зенитной установки</param>
protected DrawningAircraftGun(int drawningGunWidth, int drawningGunHeight) : this()
protected DrawningArmoredCar(int drawningGunWidth, int drawningGunHeight) : this()
{
_drawningGunWidth = drawningGunWidth;
_drawningGunHeight = drawningGunHeight;

View File

@ -2,7 +2,7 @@
/// <summary>
/// Класс-сущность Зенитная установка
/// </summary>
public class EntityAntiAircraftGun : EntityAircraftGun
public class EntityAntiAircraftGun : EntityArmoredCar
{
/// <summary>
/// Дополниетльный цвет

View File

@ -2,7 +2,7 @@
/// <summary>
/// Класс - сущность Бронированная машина
/// </summary>
public class EntityAircraftGun
public class EntityArmoredCar
{
/// <summary>
/// Скорость
@ -27,7 +27,7 @@ public class EntityAircraftGun
/// <param name="speed"></param>
/// <param name="weight"></param>
/// <param name="bodyColor"></param>
public EntityAircraftGun(int speed, double weight, Color bodyColor)
public EntityArmoredCar(int speed, double weight, Color bodyColor)
{
Speed = speed;
Weight = weight;

View File

@ -33,8 +33,6 @@
buttonDown = new Button();
buttonRight = new Button();
buttonUp = new Button();
buttonCreate = new Button();
buttonCreatAircraftGun = new Button();
comboBoxStrategy = new ComboBox();
buttonStrategyStep = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxAntiAircraftGun).BeginInit();
@ -97,28 +95,6 @@
buttonUp.UseVisualStyleBackColor = true;
buttonUp.Click += ButtonMove_Click;
//
// buttonCreate
//
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreate.Location = new Point(12, 406);
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(215, 32);
buttonCreate.TabIndex = 1;
buttonCreate.Text = "Создать зенитную установку";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += ButtonCreate_Click;
//
// buttonCreatAircraftGun
//
buttonCreatAircraftGun.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreatAircraftGun.Location = new Point(233, 406);
buttonCreatAircraftGun.Name = "buttonCreatAircraftGun";
buttonCreatAircraftGun.Size = new Size(215, 32);
buttonCreatAircraftGun.TabIndex = 6;
buttonCreatAircraftGun.Text = "Создать бронированную машину";
buttonCreatAircraftGun.UseVisualStyleBackColor = true;
buttonCreatAircraftGun.Click += buttonCreatAircraftGun_Click;
//
// comboBoxStrategy
//
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
@ -146,12 +122,10 @@
ClientSize = new Size(800, 450);
Controls.Add(buttonStrategyStep);
Controls.Add(comboBoxStrategy);
Controls.Add(buttonCreatAircraftGun);
Controls.Add(buttonUp);
Controls.Add(buttonRight);
Controls.Add(buttonDown);
Controls.Add(buttonLeft);
Controls.Add(buttonCreate);
Controls.Add(pictureBoxAntiAircraftGun);
Name = "FormAntiAircraftGun";
Text = "Зенитная установка";
@ -166,8 +140,6 @@
private Button buttonDown;
private Button buttonRight;
private Button buttonUp;
private Button buttonCreate;
private Button buttonCreatAircraftGun;
private ComboBox comboBoxStrategy;
private Button buttonStrategyStep;
}

View File

@ -8,12 +8,26 @@ public partial class FormAntiAircraftGun : Form
/// <summary>
/// Поле объект для прорисовки объекта
/// </summary>
private DrawningAircraftGun? _drawningAircraftGun;
private DrawningArmoredCar? _drawningAircraftGun;
/// <summary>
/// Стратегия перемещения
/// </summary>
private AbstractStrategy? _strategy;
/// <summary>
/// Получение объекта
/// </summary>
public DrawningArmoredCar SetArmoredCar
{
set
{
_drawningAircraftGun = value;
_drawningAircraftGun.SetPictureSize(pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
comboBoxStrategy.Enabled = true;
_strategy = null;
Draw();
}
}
/// <summary>
/// конструктор формы
/// </summary>
public FormAntiAircraftGun()
@ -35,48 +49,6 @@ public partial class FormAntiAircraftGun : Form
_drawningAircraftGun.DrawTransport(gr);
pictureBoxAntiAircraftGun.Image = bmp;
}
/// <summary>
/// Метод создания объекта
/// </summary>
/// <param name="type"></param>
private void CreateObject(string type)
{
Random random = new();
switch (type)
{
case nameof(DrawningAircraftGun):
_drawningAircraftGun = new DrawningAircraftGun(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(DrawningAntiAircraftGun):
_drawningAircraftGun = new DrawningAntiAircraftGun(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)));
break;
default:
return;
}
_drawningAircraftGun.SetPictureSize(pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
_drawningAircraftGun.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(DrawningAntiAircraftGun));
/// <summary>
/// Обработка кнопик Создать установку
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonCreatAircraftGun_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAircraftGun));
/// <summary>
/// Перемещение объекта по форме
/// </summary>

View File

@ -0,0 +1,167 @@
namespace AntiAircraftGun
{
partial class FormArmoredCarCollection
{
/// <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()
{
groupBoxToools = new GroupBox();
buttonRefresh = new Button();
buttonGoToChek = new Button();
buttonRemoveArmoredCar = new Button();
maskedTextBox = new MaskedTextBox();
buttonAddAntiAircraftGun = new Button();
buttonAddArmoredCar = new Button();
comboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox();
groupBoxToools.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
SuspendLayout();
//
// groupBoxToools
//
groupBoxToools.Controls.Add(buttonRefresh);
groupBoxToools.Controls.Add(buttonGoToChek);
groupBoxToools.Controls.Add(buttonRemoveArmoredCar);
groupBoxToools.Controls.Add(maskedTextBox);
groupBoxToools.Controls.Add(buttonAddAntiAircraftGun);
groupBoxToools.Controls.Add(buttonAddArmoredCar);
groupBoxToools.Controls.Add(comboBoxSelectorCompany);
groupBoxToools.Dock = DockStyle.Right;
groupBoxToools.Location = new Point(1057, 0);
groupBoxToools.Name = "groupBoxToools";
groupBoxToools.Size = new Size(210, 615);
groupBoxToools.TabIndex = 0;
groupBoxToools.TabStop = false;
groupBoxToools.Text = "Инструменты";
//
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.Location = new Point(6, 527);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(198, 39);
buttonRefresh.TabIndex = 6;
buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true;
//
// buttonGoToChek
//
buttonGoToChek.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonGoToChek.Location = new Point(6, 482);
buttonGoToChek.Name = "buttonGoToChek";
buttonGoToChek.Size = new Size(198, 39);
buttonGoToChek.TabIndex = 5;
buttonGoToChek.Text = "Передать на тесты";
buttonGoToChek.UseVisualStyleBackColor = true;
//
// buttonRemoveArmoredCar
//
buttonRemoveArmoredCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRemoveArmoredCar.Location = new Point(6, 302);
buttonRemoveArmoredCar.Name = "buttonRemoveArmoredCar";
buttonRemoveArmoredCar.Size = new Size(198, 60);
buttonRemoveArmoredCar.TabIndex = 4;
buttonRemoveArmoredCar.Text = "Удалить бронемашину";
buttonRemoveArmoredCar.UseVisualStyleBackColor = true;
//
// maskedTextBox
//
maskedTextBox.Location = new Point(6, 249);
maskedTextBox.Mask = "00";
maskedTextBox.Name = "maskedTextBox";
maskedTextBox.Size = new Size(198, 23);
maskedTextBox.TabIndex = 3;
maskedTextBox.ValidatingType = typeof(int);
//
// buttonAddAntiAircraftGun
//
buttonAddAntiAircraftGun.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddAntiAircraftGun.Location = new Point(6, 164);
buttonAddAntiAircraftGun.Name = "buttonAddAntiAircraftGun";
buttonAddAntiAircraftGun.Size = new Size(198, 60);
buttonAddAntiAircraftGun.TabIndex = 2;
buttonAddAntiAircraftGun.Text = "Добавление зениитной установки";
buttonAddAntiAircraftGun.UseVisualStyleBackColor = true;
//
// buttonAddArmoredCar
//
buttonAddArmoredCar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddArmoredCar.Location = new Point(6, 86);
buttonAddArmoredCar.Name = "buttonAddArmoredCar";
buttonAddArmoredCar.Size = new Size(198, 60);
buttonAddArmoredCar.TabIndex = 1;
buttonAddArmoredCar.Text = "Добавление бронемашины";
buttonAddArmoredCar.UseVisualStyleBackColor = true;
//
// 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(198, 23);
comboBoxSelectorCompany.TabIndex = 0;
//
// pictureBox
//
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 0);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(1057, 615);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
// FormArmoredCarCollection
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1267, 615);
Controls.Add(pictureBox);
Controls.Add(groupBoxToools);
Name = "FormArmoredCarCollection";
Text = "Коллекция бронемашин";
groupBoxToools.ResumeLayout(false);
groupBoxToools.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxToools;
private ComboBox comboBoxSelectorCompany;
private Button buttonAddArmoredCar;
private Button buttonAddAntiAircraftGun;
private PictureBox pictureBox;
private Button buttonRemoveArmoredCar;
private MaskedTextBox maskedTextBox;
private Button buttonRefresh;
private Button buttonGoToChek;
}
}

View File

@ -0,0 +1,191 @@
using AntiAircraftGun.CollectionGenereticObject;
using AntiAircraftGun.CollectionGenereticObjects;
using AntiAircraftGun.Drawnings;
namespace AntiAircraftGun;
/// <summary>
/// Форма работы с компанией и ее коллекцией
/// </summary>
public partial class FormArmoredCarCollection : Form
{
/// <summary>
/// Компания
/// </summary>
private AbstractCompany? _company = null;
/// <summary>
/// Конструктор
/// </summary>
public FormArmoredCarCollection()
{
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 CarBase(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawningArmoredCar>());
break;
}
}
/// <summary>
/// Добавление бронерованной машины
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddArmoredCar_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningArmoredCar));
/// <summary>
/// Добавление зенитной установки
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddAntiAircraftGun_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAntiAircraftGun));
/// <summary>
/// Создание объекта класса-перемещения
/// </summary>
/// <param name="type">Тип создаваемого объекта</param>
private void CreateObject(string type)
{
if (_company == null)
{
return;
}
Random random = new();
DrawningArmoredCar drawningArmoredCar;
switch (type)
{
case nameof(DrawningArmoredCar):
drawningArmoredCar = new DrawningArmoredCar(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
break;
case nameof(DrawningAntiAircraftGun):
// вызов диалогового окна для выбора цвета
drawningArmoredCar = new DrawningAntiAircraftGun(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 + drawningArmoredCar != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
}
else
{
_ = MessageBox.Show(drawningArmoredCar.ToString());
}
}
/// <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 ButtonRemoveArmoredCar_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("Не удалось удалить объект");
}
}
/// <summary>
/// Передача объекта в другую форму
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonGoToCheck_Click(object sender, EventArgs e)
{
if (_company == null)
{
return;
}
DrawningArmoredCar? armoredcar = null;
int counter = 100;
while (armoredcar == null)
{
armoredcar = _company.GetRandomObject();
counter--;
if (counter <= 0)
{
break;
}
}
if (armoredcar == null)
{
return;
}
FormAntiAircraftGun form = new()
{
SetArmoredCar = armoredcar
};
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();
}
}

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

@ -7,12 +7,12 @@ public class MoveableAircraftGun: IMoveableObject
/// <summary>
/// Поле-объект класса DrawningAircraftGun или его наследника
/// </summary>
private readonly DrawningAircraftGun? _drawningAircraftGun = null;
private readonly DrawningArmoredCar? _drawningAircraftGun = null;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="trans">Объект класса DrawningTrans</param>
public MoveableAircraftGun(DrawningAircraftGun trans)
public MoveableAircraftGun(DrawningArmoredCar trans)
{
_drawningAircraftGun = trans;
}