ISEbd-12 SinelnikovaA.V. LabWork03 Simple #14

Closed
AnastasiaSinelnikova wants to merge 1 commits from Lab3 into Lab2
10 changed files with 809 additions and 89 deletions
Showing only changes of commit 7a26e24c82 - Show all commits

View File

@ -0,0 +1,115 @@
using ProjectCruiser.Drawnings;
namespace ProjectCruiser.CollectionGenericObjects
{
/// <summary>
/// Абстракция компании, хранящий коллекцию автомобилей
/// </summary>
public abstract class AbstractCompany
{
/// <summary>
/// Размер места (ширина)
/// </summary>
protected readonly int _placeSizeWidth = 180;
/// <summary>
/// Размер места (высота)
/// </summary>
protected readonly int _placeSizeHeight = 70;
/// <summary>
/// Ширина окна
/// </summary>
protected readonly int _pictureWidth;
/// <summary>
/// Высота окна
/// </summary>
protected readonly int _pictureHeight;
/// <summary>
/// Коллекция автомобилей
/// </summary>
protected ICollectionGenericObjects<DrawningCruiser>? _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<DrawningCruiser> 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, DrawningCruiser сruiser)
{
return company._collection.Insert(сruiser);
}
/// <summary>
/// Перегрузка оператора удаления для класса
/// </summary>
/// <param name="company">Компания</param>
/// <param name="position">Номер удаляемого объекта</param>
/// <returns></returns>
public static DrawningCruiser operator -(AbstractCompany company, int position)
{
return company._collection?.Remove(position);
}
/// <summary>
/// Получение случайного объекта из коллекции
/// </summary>
/// <returns></returns>
public DrawningCruiser? 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)
{
DrawningCruiser? 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,65 @@
using ProjectCruiser.Drawnings;
namespace ProjectCruiser.CollectionGenericObjects
{
/// <summary>
/// Реализация абстрактной компании - каршеринг
/// </summary>
public class CruiserDockingService : AbstractCompany
{
/// <summary>
/// Конструктор
/// </summary>
/// <param name="picWidth"></param>
/// <param name="picHeight"></param>
/// <param name="collection"></param>
public CruiserDockingService(int picWidth, int picHeight,
ICollectionGenericObjects<DrawningCruiser> 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, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth - 20, j * _placeSizeHeight);
g.DrawLine(pen, i * _placeSizeWidth + _placeSizeWidth - 20, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth - 20, j * _placeSizeHeight + _placeSizeHeight);
}
}
}
protected override void SetObjectsPosition()
{
int width = _pictureWidth / _placeSizeWidth;
int height = _pictureHeight / _placeSizeHeight;
int curWidth = 0;
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 < width - 1)
curWidth++;
else
{
curWidth = 0;
curHeight ++;
}
if (curHeight >= height)
{
return;
}
}
}
}
}

View File

@ -0,0 +1,45 @@
namespace ProjectCruiser.CollectionGenericObjects
{
/// <summary>
/// Интерфейс описания действий для набора хранимых объектов
/// </summary>
/// <typeparam name="T">Параметр: ограничение - ссылочный тип</typeparam>
public interface ICollectionGenericObjects<T>
where T : class
{
/// <summary>
/// Количество объектов в коллекции
/// </summary>
int Count { get; }
/// <summary>
/// Установка максимального количества элементов
/// </summary>
int SetMaxCount { set; }
/// <summary>
/// Добавление объекта в коллекцию
/// </summary>
/// <param name="obj">Добавляемый объект</param>
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
int Insert(T obj);
/// <summary>
/// Добавление объекта в коллекцию на конкретную позицию
/// </summary>
/// <param name="obj">Добавляемый объект</param>
/// <param name="position">Позиция</param>
/// <returns>true - вставка прошла удачно, false - вставка не удалась</returns>
int Insert(T obj, int position);
/// <summary>
/// Удаление объекта из коллекции с конкретной позиции
/// </summary>
/// <param name="position">Позиция</param>
/// <returns>true - удаление прошло удачно, false - удаление не удалось</returns>
T? Remove(int position);
/// <summary>
/// Получение объекта по позиции
/// </summary>
/// <param name="position">Позиция</param>
/// <returns>Объект</returns>
T? Get(int position);
}
}

View File

@ -0,0 +1,97 @@
using ProjectCruiser.Drawnings;
namespace ProjectCruiser.CollectionGenericObjects
{
/// <summary>
/// Параметризованный набор объектов
/// </summary>
/// <typeparam name="T">Параметр: ограничение - ссылочный тип</typeparam>
public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
where T : class
{
/// <summary>
/// Массив объектов, которые храним
/// </summary>
private T?[] _collection;
public int Count => _collection.Length;
public int SetMaxCount { set { if (value > 0) { _collection = new T?[value]; } } }
/// <summary>
/// Конструктор
/// </summary>
public MassiveGenericObjects()
{
_collection = Array.Empty<T?>();
}
public T? Get(int position)
{
// TODO проверка позиции
if (position >= _collection.Length || position < 0)
{
return null;
}
return _collection[position];
}
public int Insert(T obj)
{
// TODO вставка в свободное место набора
int index = 0;
while (index < _collection.Length)
{
if (_collection[index] == null)
{
_collection[index] = obj;
return index;
}
index++;
}
return -1;
}
public int Insert(T obj, int position)
{
// TODO проверка позиции
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
// ищется свободное место после этой позиции и идет вставка туда
// если нет после, ищем до
// TODO вставка
if (position >= _collection.Length || position < 0)
{ return -1; }
if (_collection[position] == null)
{
_collection[position] = obj;
return position;
}
int index;
for (index = position + 1; index < _collection.Length; ++index)
{
if (_collection[index] == null)
{
_collection[position] = obj;
return position;
}
}
for (index = position - 1; index >= 0; --index)
{
if (_collection[index] == null)
{
_collection[position] = obj;
return position;
}
}
return -1;
}
public T Remove(int position)
{
// TODO проверка позиции
// TODO удаление объекта из массива, присвоив элементу массива значение null
if (position >= _collection.Length || position < 0)
{ return null; }
T drawningCruiser = _collection[position];
_collection[position] = null;
return drawningCruiser;
}
}
}

View File

@ -30,13 +30,11 @@
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormCruiser));
pictureBoxCruiser = new PictureBox();
button1 = new Button();
buttonUp = new Button();
buttonDown = new Button();
buttonRight = new Button();
buttonLeft = new Button();
comboBoxStrategy = new ComboBox();
buttonCretaeCruiser = new Button();
buttonStrategyStep = new Button();
((System.ComponentModel.ISupportInitialize)pictureBoxCruiser).BeginInit();
SuspendLayout();
@ -51,17 +49,6 @@
pictureBoxCruiser.TabIndex = 0;
pictureBoxCruiser.TabStop = false;
//
// button1
//
button1.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
button1.Location = new Point(12, 409);
button1.Name = "button1";
button1.Size = new Size(213, 29);
button1.TabIndex = 1;
button1.Text = "создать военный крейсер";
button1.UseVisualStyleBackColor = true;
button1.Click += ButtonCreateCruiser_Click;
//
// buttonUp
//
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
@ -121,17 +108,6 @@
comboBoxStrategy.Size = new Size(151, 28);
comboBoxStrategy.TabIndex = 6;
//
// buttonCretaeCruiser
//
buttonCretaeCruiser.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCretaeCruiser.Location = new Point(240, 410);
buttonCretaeCruiser.Name = "buttonCretaeCruiser";
buttonCretaeCruiser.Size = new Size(213, 29);
buttonCretaeCruiser.TabIndex = 7;
buttonCretaeCruiser.Text = "создать крейсер";
buttonCretaeCruiser.UseVisualStyleBackColor = true;
buttonCretaeCruiser.Click += buttonCretaeCruiser_Click;
//
// buttonStrategyStep
//
buttonStrategyStep.Location = new Point(694, 46);
@ -148,13 +124,11 @@
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(buttonStrategyStep);
Controls.Add(buttonCretaeCruiser);
Controls.Add(comboBoxStrategy);
Controls.Add(buttonLeft);
Controls.Add(buttonRight);
Controls.Add(buttonDown);
Controls.Add(buttonUp);
Controls.Add(button1);
Controls.Add(pictureBoxCruiser);
Name = "FormCruiser";
Text = "FormCruiser";
@ -167,13 +141,11 @@
#endregion
private PictureBox pictureBoxCruiser;
private Button button1;
private Button buttonUp;
private Button buttonDown;
private Button buttonRight;
private Button buttonLeft;
private ComboBox comboBoxStrategy;
private Button buttonCretaeCruiser;
private Button buttonStrategyStep;
}
}

View File

@ -15,6 +15,25 @@ namespace ProjectCruiser
/// </summary>
private AbstractStrategy? _strategy;
/// <summary>
/// Получение объекта
/// </summary>
public DrawningCruiser SetCruiser
{
set
{
_drawningCruiser = value;
_drawningCruiser.SetPictureSize(pictureBoxCruiser.Width,
pictureBoxCruiser.Height);
comboBoxStrategy.Enabled = true;
_strategy = null;
Draw();
}
}
/// <summary>
/// Конструктор формы
/// </summary>
public FormCruiser()
{
InitializeComponent();
@ -37,57 +56,6 @@ namespace ProjectCruiser
pictureBoxCruiser.Image = bmp;
}
/// <summary>
/// Создание объекта класса-перемещения
/// </summary>
/// <param name="type">Тип создаваемого объекта</param>
private void CreateObject(string type)
{
Random random = new();
switch (type)
{
case nameof(DrawningCruiser):
_drawningCruiser = new DrawningCruiser(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(DrawningMilitaryCruiser):
_drawningCruiser = new DrawningMilitaryCruiser(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)), Convert.ToBoolean(random.Next(0, 2)));
break;
default:
return;
}
_drawningCruiser.SetPictureSize(pictureBoxCruiser.Width,
pictureBoxCruiser.Height);
_drawningCruiser.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 ButtonCreateCruiser_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningMilitaryCruiser));
/// <summary>
/// Обработка нажатия кнопки "Создать крейсер"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonCretaeCruiser_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningCruiser));
/// <summary>
/// Перемещение объекта по форме (нажатие кнопок навигации)
/// </summary>
@ -104,16 +72,13 @@ namespace ProjectCruiser
switch (name)
{
case "buttonUp":
result =
_drawningCruiser.MoveTransport(DirectionType.Up);
result = _drawningCruiser.MoveTransport(DirectionType.Up);
break;
case "buttonDown":
result =
_drawningCruiser.MoveTransport(DirectionType.Down);
result = _drawningCruiser.MoveTransport(DirectionType.Down);
break;
case "buttonLeft":
result =
_drawningCruiser.MoveTransport(DirectionType.Left);
result = _drawningCruiser.MoveTransport(DirectionType.Left);
break;
case "buttonRight":
result =

View File

@ -0,0 +1,173 @@
namespace ProjectCruiser
{
partial class FormCruisersCollection
{
/// <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();
maskedTextBoxPosision = new MaskedTextBox();
buttonRefresh = new Button();
buttonGetToTest = new Button();
ButtonRemoveCruiser = new Button();
ButtonAddMilitaryCruiser = new Button();
ButtonAddCruiser = new Button();
comboBoxSelectorCompany = new ComboBox();
pictureBoxCruiser = new PictureBox();
groupBoxTools.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCruiser).BeginInit();
SuspendLayout();
//
// groupBoxTools
//
groupBoxTools.Controls.Add(maskedTextBoxPosision);
groupBoxTools.Controls.Add(buttonRefresh);
groupBoxTools.Controls.Add(buttonGetToTest);
groupBoxTools.Controls.Add(ButtonRemoveCruiser);
groupBoxTools.Controls.Add(ButtonAddMilitaryCruiser);
groupBoxTools.Controls.Add(ButtonAddCruiser);
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(596, 0);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Size = new Size(222, 574);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "инструменты";
//
// maskedTextBoxPosision
//
maskedTextBoxPosision.Location = new Point(20, 229);
maskedTextBoxPosision.Mask = "00";
maskedTextBoxPosision.Name = "maskedTextBoxPosision";
maskedTextBoxPosision.Size = new Size(186, 27);
maskedTextBoxPosision.TabIndex = 2;
maskedTextBoxPosision.ValidatingType = typeof(int);
//
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonRefresh.Location = new Point(20, 479);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(186, 40);
buttonRefresh.TabIndex = 5;
buttonRefresh.Text = "обновить";
buttonRefresh.UseVisualStyleBackColor = true;
buttonRefresh.Click += ButtonRefresh_Click;
//
// buttonGetToTest
//
buttonGetToTest.Anchor = AnchorStyles.Right;
buttonGetToTest.Location = new Point(20, 366);
buttonGetToTest.Name = "buttonGetToTest";
buttonGetToTest.Size = new Size(186, 40);
buttonGetToTest.TabIndex = 4;
buttonGetToTest.Text = "передать на тесты";
buttonGetToTest.UseVisualStyleBackColor = true;
buttonGetToTest.Click += ButtonGetToTest_Click;
//
// ButtonRemoveCruiser
//
ButtonRemoveCruiser.Anchor = AnchorStyles.Right;
ButtonRemoveCruiser.Location = new Point(20, 271);
ButtonRemoveCruiser.Name = "ButtonRemoveCruiser";
ButtonRemoveCruiser.Size = new Size(186, 40);
ButtonRemoveCruiser.TabIndex = 3;
ButtonRemoveCruiser.Text = "удалить крейсер";
ButtonRemoveCruiser.UseVisualStyleBackColor = true;
ButtonRemoveCruiser.Click += ButtonRemoveCruiser_Click;
//
// ButtonAddMilitaryCruiser
//
ButtonAddMilitaryCruiser.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
ButtonAddMilitaryCruiser.Location = new Point(20, 152);
ButtonAddMilitaryCruiser.Name = "ButtonAddMilitaryCruiser";
ButtonAddMilitaryCruiser.Size = new Size(186, 50);
ButtonAddMilitaryCruiser.TabIndex = 2;
ButtonAddMilitaryCruiser.Text = "добваление военного крейсера";
ButtonAddMilitaryCruiser.UseVisualStyleBackColor = true;
ButtonAddMilitaryCruiser.Click += ButtonAddMilitaryCruiser_Click;
//
// ButtonAddCruiser
//
ButtonAddCruiser.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
ButtonAddCruiser.BackgroundImageLayout = ImageLayout.Center;
ButtonAddCruiser.Location = new Point(20, 106);
ButtonAddCruiser.Name = "ButtonAddCruiser";
ButtonAddCruiser.Size = new Size(186, 40);
ButtonAddCruiser.TabIndex = 1;
ButtonAddCruiser.Text = "добваление крейсера";
ButtonAddCruiser.UseVisualStyleBackColor = true;
ButtonAddCruiser.Click += ButtonAddCruiser_Click;
//
// comboBoxSelectorCompany
//
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "хранилище" });
comboBoxSelectorCompany.Location = new Point(20, 26);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
comboBoxSelectorCompany.Size = new Size(186, 28);
comboBoxSelectorCompany.TabIndex = 0;
comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged_1;
//
// pictureBoxCruiser
//
pictureBoxCruiser.Dock = DockStyle.Fill;
pictureBoxCruiser.Location = new Point(0, 0);
pictureBoxCruiser.Name = "pictureBoxCruiser";
pictureBoxCruiser.Size = new Size(596, 574);
pictureBoxCruiser.TabIndex = 1;
pictureBoxCruiser.TabStop = false;
//
// FormCruisersCollection
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(818, 574);
Controls.Add(pictureBoxCruiser);
Controls.Add(groupBoxTools);
Name = "FormCruisersCollection";
Text = "FormCruisersCollection";
groupBoxTools.ResumeLayout(false);
groupBoxTools.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCruiser).EndInit();
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxTools;
private ComboBox comboBoxSelectorCompany;
private Button ButtonAddMilitaryCruiser;
private Button ButtonAddCruiser;
private Button ButtonRemoveCruiser;
private Button buttonRefresh;
private Button buttonGetToTest;
private PictureBox pictureBoxCruiser;
private MaskedTextBox maskedTextBoxPosision;
}
}

View File

@ -0,0 +1,169 @@
using ProjectCruiser.CollectionGenericObjects;
using ProjectCruiser.Drawnings;
namespace ProjectCruiser
{
public partial class FormCruisersCollection : Form
{
/// <summary>
/// Компания
/// </summary>
private AbstractCompany? _company = null;
/// <summary>
/// Конструктор
/// </summary>
public FormCruisersCollection()
{
InitializeComponent();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void comboBoxSelectorCompany_SelectedIndexChanged_1(object sender, EventArgs e)
{
switch (comboBoxSelectorCompany.Text)
{
case "хранилище":
_company = new CruiserDockingService(pictureBoxCruiser.Width,
pictureBoxCruiser.Height, new MassiveGenericObjects<DrawningCruiser>());
break;
}
}
/// <summary>
/// Создание объекта класса-перемещения
/// </summary>
/// <param name="type">Тип создаваемого объекта</param>
private void CreateObject(string type)
{
if (_company == null)
{
return;
}
Random random = new();
DrawningCruiser drawningCruiser;
switch (type)
{
case nameof(DrawningCruiser):
drawningCruiser = new DrawningCruiser(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
break;
case nameof(DrawningMilitaryCruiser):
drawningCruiser = new DrawningMilitaryCruiser(random.Next(100, 300), random.Next(1000, 3000),
GetColor(random),
GetColor(random),
Convert.ToBoolean(random.Next(0, 2)),
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
break;
default:
return;
}
if (_company + drawningCruiser != -1)
{
MessageBox.Show("объект добавлен");
pictureBoxCruiser.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 ButtonAddCruiser_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningCruiser));
//private void ButtonAddMilitaryCruiser_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningMilitaryCruiser));
private void ButtonAddCruiser_Click(object sender, EventArgs e)
{
CreateObject(nameof(DrawningCruiser));
}
private void ButtonAddMilitaryCruiser_Click(object sender, EventArgs e)
{
CreateObject(nameof(DrawningMilitaryCruiser));
}
private void ButtonRemoveCruiser_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(maskedTextBoxPosision.Text) || _company == null)
{
return;
}
if (MessageBox.Show("удалить объект?", "удаление",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
{
return;
}
int pos = Convert.ToInt32(maskedTextBoxPosision.Text);
if (_company - pos != null)
{
MessageBox.Show("объект удален");
pictureBoxCruiser.Image = _company.Show();
}
else
{
MessageBox.Show("не удалось удалить объект");
}
}
private void ButtonGetToTest_Click(object sender, EventArgs e)
{
if (_company == null)
{
return;
}
DrawningCruiser? cruiser = null;
int counter = 100;
while (cruiser == null)
{
cruiser = _company.GetRandomObject();
counter--;
if (counter <= 0)
{
break;
}
}
if (cruiser == null)
{
return;
}
FormCruiser form = new()
{
SetCruiser = cruiser
};
form.ShowDialog();
}
private void ButtonRefresh_Click(object sender, EventArgs e)
{
if (_company == null)
{
return;
}
pictureBoxCruiser.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

@ -3,15 +3,14 @@ namespace ProjectCruiser
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
// To customize application configuration such as set high DPI settings or default font, see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new FormCruiser());
Application.Run(new FormCruisersCollection());
}
}
}