Компания

This commit is contained in:
Adelina888 2024-04-02 08:53:49 +04:00
parent 93e3386cd8
commit 14d621ebb7
9 changed files with 662 additions and 77 deletions

View File

@ -0,0 +1,102 @@
using ProjectStormtrooper.Drawnings;
namespace ProjectStormtrooper.CollectionGenericObjects;
/// <summary>
/// Абстракция компании, хранящий коллекцию бомбардировщиков
/// </summary>
public abstract class AbstractCompany
{
/// <summary>
/// Размер места (ширина)
/// </summary>
protected readonly int _placeSizeWidth = 210;
/// <summary>
/// Размер места (высота)
/// </summary>
protected readonly int _placeSizeHeight = 155;
/// <summary>
/// Ширина окна
/// </summary>
protected readonly int _pictureWidth;
/// <summary>
/// Высота окна
/// </summary>
protected readonly int _pictureHeight;
/// <summary>
/// Коллекция штурмовика
/// </summary>
protected ICollectionGenericObjects<DrawningStormtrooperBase>? _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<DrawningStormtrooperBase> collection)
{
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_collection = collection;
_collection.SetMaxCount = GetMaxCount;
}
/// <summary>
/// Перегрузка оператора сложения для класса
/// </summary>
/// <param name="company">Компания</param>
/// <param name="stormtrooper">Добавляемый объект</param>
/// <returns></returns>
public static int operator +(AbstractCompany company, DrawningStormtrooperBase stormtrooper)
{
return company._collection.Insert(stormtrooper);
}
/// <summary>
/// Перегрузка оператора удаления для класса
/// </summary>
/// <param name="company">Компания</param>
/// <param name="position">Номер удаляемого объекта</param>
/// <returns></returns>
public static DrawningStormtrooperBase operator -(AbstractCompany company, int position)
{
return company._collection.Remove(position);
}
/// <summary>
/// Получение случайного объекта из коллекции
/// </summary>
/// <returns></returns>
public DrawningStormtrooperBase? 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)
{
DrawningStormtrooperBase? obj = _collection?.Get(i);
obj?.DrawTransport(graphics);
}
return bitmap;
}
/// <summary>
/// Вывод заднего фона
/// </summary>
/// <param name="g"></param>
protected abstract void DrawBackgound(Graphics graphics);
/// <summary>
/// Расстановка объектов
/// </summary>
protected abstract void SetObjectsPosition();
}

View File

@ -5,7 +5,10 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ProjectStormtrooper.CollectionGenericObjects; namespace ProjectStormtrooper.CollectionGenericObjects;
/// <summary>
/// Интерфейс описания действий для набора хранимых объектов
/// </summary>
/// <typeparam name="T">Параметр: ограничение - ссылочный тип</typeparam>
public interface ICollectionGenericObjects<T> public interface ICollectionGenericObjects<T>
where T : class where T : class
{ {

View File

@ -0,0 +1,58 @@
using ProjectStormtrooper.Drawnings;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectStormtrooper.CollectionGenericObjects;
public class StormtrooperSharingService : AbstractCompany
{
public StormtrooperSharingService(int picWidth, int picHeight, ICollectionGenericObjects<DrawningStormtrooperBase> 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; i++)
{
for (int j = 0; j < height + 1; ++j)
{
g.DrawLine(pen, i * _placeSizeWidth + 15, j * _placeSizeHeight, i * _placeSizeWidth + 15 + _placeSizeWidth - 55, j * _placeSizeHeight);
g.DrawLine(pen, i * _placeSizeWidth + 15, j * _placeSizeHeight, i * _placeSizeWidth + 15, 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 + 15, curHeight * _placeSizeHeight + 3);
}
if (curWidth > 0)
curWidth--;
else
{
curWidth = width - 1;
curHeight++;
}
if (curHeight > height)
{
return;
}
}
}
}

View File

@ -29,12 +29,10 @@
private void InitializeComponent() private void InitializeComponent()
{ {
pictureBoxStormtrooper = new PictureBox(); pictureBoxStormtrooper = new PictureBox();
buttonCreateStormtrooper = new Button();
buttonLeft = new Button(); buttonLeft = new Button();
buttonUp = new Button(); buttonUp = new Button();
buttonDown = new Button(); buttonDown = new Button();
buttonRight = new Button(); buttonRight = new Button();
buttonCreateStormtrooperBase = new Button();
comboBoxStrategy = new ComboBox(); comboBoxStrategy = new ComboBox();
buttonStrategyStep = new Button(); buttonStrategyStep = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxStormtrooper).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureBoxStormtrooper).BeginInit();
@ -49,17 +47,6 @@
pictureBoxStormtrooper.TabIndex = 0; pictureBoxStormtrooper.TabIndex = 0;
pictureBoxStormtrooper.TabStop = false; pictureBoxStormtrooper.TabStop = false;
// //
// buttonCreateStormtrooper
//
buttonCreateStormtrooper.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreateStormtrooper.Location = new Point(12, 562);
buttonCreateStormtrooper.Name = "buttonCreateStormtrooper";
buttonCreateStormtrooper.Size = new Size(162, 23);
buttonCreateStormtrooper.TabIndex = 1;
buttonCreateStormtrooper.Text = "Создать штурмовик";
buttonCreateStormtrooper.UseVisualStyleBackColor = true;
buttonCreateStormtrooper.Click += ButtonCreateStormtrooper_Click;
//
// buttonLeft // buttonLeft
// //
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
@ -108,17 +95,6 @@
buttonRight.UseVisualStyleBackColor = true; buttonRight.UseVisualStyleBackColor = true;
buttonRight.Click += ButtonMove_Click; buttonRight.Click += ButtonMove_Click;
// //
// buttonCreateStormtrooperBase
//
buttonCreateStormtrooperBase.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreateStormtrooperBase.Location = new Point(198, 562);
buttonCreateStormtrooperBase.Name = "buttonCreateStormtrooperBase";
buttonCreateStormtrooperBase.Size = new Size(180, 23);
buttonCreateStormtrooperBase.TabIndex = 6;
buttonCreateStormtrooperBase.Text = "Создать штурмовик базовый";
buttonCreateStormtrooperBase.UseVisualStyleBackColor = true;
buttonCreateStormtrooperBase.Click += ButtonCreateStormtrooperBase_Click;
//
// comboBoxStrategy // comboBoxStrategy
// //
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
@ -146,12 +122,10 @@
ClientSize = new Size(925, 597); ClientSize = new Size(925, 597);
Controls.Add(buttonStrategyStep); Controls.Add(buttonStrategyStep);
Controls.Add(comboBoxStrategy); Controls.Add(comboBoxStrategy);
Controls.Add(buttonCreateStormtrooperBase);
Controls.Add(buttonRight); Controls.Add(buttonRight);
Controls.Add(buttonDown); Controls.Add(buttonDown);
Controls.Add(buttonUp); Controls.Add(buttonUp);
Controls.Add(buttonLeft); Controls.Add(buttonLeft);
Controls.Add(buttonCreateStormtrooper);
Controls.Add(pictureBoxStormtrooper); Controls.Add(pictureBoxStormtrooper);
Name = "FormStormtrooper"; Name = "FormStormtrooper";
Text = "Штурмовик"; Text = "Штурмовик";
@ -162,12 +136,10 @@
#endregion #endregion
private PictureBox pictureBoxStormtrooper; private PictureBox pictureBoxStormtrooper;
private Button buttonCreateStormtrooper;
private Button buttonLeft; private Button buttonLeft;
private Button buttonUp; private Button buttonUp;
private Button buttonDown; private Button buttonDown;
private Button buttonRight; private Button buttonRight;
private Button buttonCreateStormtrooperBase;
private ComboBox comboBoxStrategy; private ComboBox comboBoxStrategy;
private Button buttonStrategyStep; private Button buttonStrategyStep;
} }

View File

@ -17,6 +17,17 @@ public partial class FormStormtrooper : Form
/// <summary> /// <summary>
/// Конструктор формы /// Конструктор формы
/// </summary> /// </summary>
public DrawningStormtrooperBase SetStormtrooper
{
set
{
_drawningStormtrooperBase = value;
_drawningStormtrooperBase.SetPictureSize(pictureBoxStormtrooper.Width, pictureBoxStormtrooper.Height);
comboBoxStrategy.Enabled = true;
_strategy = null;
Draw();
}
}
public FormStormtrooper() public FormStormtrooper()
{ {
InitializeComponent(); InitializeComponent();
@ -39,49 +50,6 @@ public partial class FormStormtrooper : Form
_drawningStormtrooperBase.DrawTransport(gr); _drawningStormtrooperBase.DrawTransport(gr);
pictureBoxStormtrooper.Image = bmp; pictureBoxStormtrooper.Image = bmp;
} }
/// <summary>
/// Создание объекта класса-перемещения
/// </summary>
/// <param name="type"></param>
private void CreateObject(string type)
{
Random random = new();
switch (type)
{
case nameof(DrawingStormtrooper):
_drawningStormtrooperBase = new DrawingStormtrooper(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;
case nameof(DrawningStormtrooperBase):
_drawningStormtrooperBase = new DrawningStormtrooperBase(random.Next(100, 300), random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
break;
default:
return;
}
_drawningStormtrooperBase.SetPictureSize(pictureBoxStormtrooper.Width, pictureBoxStormtrooper.Height);
_drawningStormtrooperBase.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 ButtonCreateStormtrooper_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingStormtrooper));
/// <summary>
/// Обработка нажатия кнопки "Создать базовый штурмовик"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonCreateStormtrooperBase_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningStormtrooperBase));
/// <summary> /// <summary>
/// Перемещение объкта по форме(нажатие кнопок навигации) /// Перемещение объкта по форме(нажатие кнопок навигации)

View File

@ -0,0 +1,173 @@
namespace ProjectStormtrooper
{
partial class FormStormtrooperCollection
{
/// <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();
buttonRemoveStormtrooper = new Button();
maskedTextBox = new MaskedTextBox();
buttonAddStormtrooper = new Button();
buttonAddStormtrooperBase = 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(buttonRemoveStormtrooper);
groupBoxTools.Controls.Add(maskedTextBox);
groupBoxTools.Controls.Add(buttonAddStormtrooper);
groupBoxTools.Controls.Add(buttonAddStormtrooperBase);
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(919, 0);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(165, 861);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
//
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRefresh.Location = new Point(6, 381);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(153, 32);
buttonRefresh.TabIndex = 6;
buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true;
buttonRefresh.Click += ButtonRefresh_Click;
//
// buttonGoToCheck
//
buttonGoToCheck.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonGoToCheck.Location = new Point(6, 309);
buttonGoToCheck.Name = "buttonGoToCheck";
buttonGoToCheck.Size = new Size(153, 36);
buttonGoToCheck.TabIndex = 5;
buttonGoToCheck.Text = "Передать на тесты";
buttonGoToCheck.UseVisualStyleBackColor = true;
buttonGoToCheck.Click += ButtonGoToCheck_Click;
//
// buttonRemoveStormtrooper
//
buttonRemoveStormtrooper.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonRemoveStormtrooper.Location = new Point(6, 248);
buttonRemoveStormtrooper.Name = "buttonRemoveStormtrooper";
buttonRemoveStormtrooper.Size = new Size(153, 33);
buttonRemoveStormtrooper.TabIndex = 4;
buttonRemoveStormtrooper.Text = "Удалить Штурмовик";
buttonRemoveStormtrooper.UseVisualStyleBackColor = true;
buttonRemoveStormtrooper.Click += ButtonRemoveStormtrooper_Click;
//
// maskedTextBox
//
maskedTextBox.Location = new Point(6, 208);
maskedTextBox.Mask = "00";
maskedTextBox.Name = "maskedTextBox";
maskedTextBox.Size = new Size(153, 23);
maskedTextBox.TabIndex = 3;
maskedTextBox.ValidatingType = typeof(int);
//
// buttonAddStormtrooper
//
buttonAddStormtrooper.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddStormtrooper.Location = new Point(6, 139);
buttonAddStormtrooper.Name = "buttonAddStormtrooper";
buttonAddStormtrooper.Size = new Size(153, 45);
buttonAddStormtrooper.TabIndex = 2;
buttonAddStormtrooper.Text = "Добавление Штурмовика";
buttonAddStormtrooper.UseVisualStyleBackColor = true;
buttonAddStormtrooper.Click += ButtonAddStormtrooper_Click;
//
// buttonAddStormtrooperBase
//
buttonAddStormtrooperBase.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddStormtrooperBase.Location = new Point(6, 78);
buttonAddStormtrooperBase.Name = "buttonAddStormtrooperBase";
buttonAddStormtrooperBase.Size = new Size(153, 39);
buttonAddStormtrooperBase.TabIndex = 1;
buttonAddStormtrooperBase.Text = "Добавление базового Штурмовика";
buttonAddStormtrooperBase.UseVisualStyleBackColor = true;
buttonAddStormtrooperBase.Click += ButtonAddStormtrooperBase_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(159, 23);
comboBoxSelectorCompany.TabIndex = 0;
comboBoxSelectorCompany.SelectedIndexChanged += СomboBoxSelectorCompany_SelectedIndexChanged;
//
// pictureBox
//
pictureBox.Dock = DockStyle.Fill;
pictureBox.Location = new Point(0, 0);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(919, 861);
pictureBox.TabIndex = 3;
pictureBox.TabStop = false;
//
// FormStormtrooperCollection
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1084, 861);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
Name = "FormStormtrooperCollection";
Text = "Коллекция штурмовиков";
groupBoxTools.ResumeLayout(false);
groupBoxTools.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxTools;
private Button buttonAddStormtrooperBase;
private ComboBox comboBoxSelectorCompany;
private Button buttonAddStormtrooper;
private PictureBox pictureBox;
private Button buttonRemoveStormtrooper;
private MaskedTextBox maskedTextBox;
private Button buttonGoToCheck;
private Button buttonRefresh;
}
}

View File

@ -0,0 +1,189 @@
using ProjectStormtrooper.CollectionGenericObjects;
using ProjectStormtrooper.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 ProjectStormtrooper;
/// <summary>
/// Форма работы с компанией и ее коллекцией
/// </summary>
public partial class FormStormtrooperCollection : Form
{
/// <summary>
/// Компания
/// </summary>
private AbstractCompany? _company;
/// <summary>
/// Конструктор
/// </summary>
public FormStormtrooperCollection()
{
InitializeComponent();
}
/// <summary>
/// Выбор компании
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void СomboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comboBoxSelectorCompany.Text)
{
case "Хранилище":
_company = new StormtrooperSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawningStormtrooperBase>());
break;
}
}
/// <summary>
/// Создание объекта класса-перемещения
/// </summary>
/// <param name="type"></param>
private void CreateObject(string type)
{
if (_company == null)
{
return;
}
Random random = new();
DrawningStormtrooperBase drawningStormtrooperBase;
switch (type)
{
case nameof(DrawingStormtrooper):
drawningStormtrooperBase = new DrawingStormtrooper(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;
case nameof(DrawningStormtrooperBase):
drawningStormtrooperBase = new DrawningStormtrooperBase(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
break;
default:
return;
}
if (_company + drawningStormtrooperBase != -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 ButtonAddStormtrooperBase_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningStormtrooperBase));
/// <summary>
/// Добавление штурмовика
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddStormtrooper_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingStormtrooper));
/// <summary>
/// Удаление объекта
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonRemoveStormtrooper_Click(object sender, EventArgs e)
{
if (_company == null)
{
return;
}
if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null)
{
return;
}
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
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;
}
DrawningStormtrooperBase? stormtrooper = null;
int counter = 100;
while (stormtrooper == null)
{
stormtrooper = _company.GetRandomObject();
counter--;
if (counter < -0)
{
break;
}
}
if (stormtrooper == null)
{
return;
}
FormStormtrooper form = new()
{
SetStormtrooper = stormtrooper
};
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

@ -11,7 +11,7 @@ namespace ProjectStormtrooper
// 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 FormStormtrooper()); Application.Run(new FormStormtrooperCollection());
} }
} }
} }