Компания
This commit is contained in:
parent
fc55667cd4
commit
f6bac334bf
116
LabOOP_1/LabOOP_1/CollectionGenereticObjects/AbstractCompany.cs
Normal file
116
LabOOP_1/LabOOP_1/CollectionGenereticObjects/AbstractCompany.cs
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
using Project_Catamaran.Drawnings;
|
||||||
|
|
||||||
|
namespace ProjectCatamaran.CollectionGenericObjects;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Абстракция компании, хранящий коллекцию лодок
|
||||||
|
/// </summary>
|
||||||
|
public abstract class AbstractCompany
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Размер места (ширина)
|
||||||
|
/// </summary>
|
||||||
|
protected readonly int _placeSizeWidth = 120;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Размер места (высота)
|
||||||
|
/// </summary>
|
||||||
|
protected readonly int _placeSizeHeight = 105;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ширина окна
|
||||||
|
/// </summary>
|
||||||
|
protected readonly int _pictureWidth;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Высота окна
|
||||||
|
/// </summary>
|
||||||
|
protected readonly int _pictureHeight;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Коллекция лодок
|
||||||
|
/// </summary>
|
||||||
|
protected ICollectionGenericObjects<DrawningSimpleCatamaran>? _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<DrawningSimpleCatamaran> collection)
|
||||||
|
{
|
||||||
|
_pictureWidth = picWidth;
|
||||||
|
_pictureHeight = picHeight;
|
||||||
|
_collection = collection;
|
||||||
|
_collection.SetMaxCount = GetMaxCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Перегрузка оператора сложения для класса
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="company">Компания</param>
|
||||||
|
/// <param name="catamaran">Добавляемый объект</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static int operator +(AbstractCompany company, DrawningSimpleCatamaran catamaran)
|
||||||
|
{
|
||||||
|
return company._collection?.Insert(catamaran) ?? -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Перегрузка оператора удаления для класса
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="company">Компания</param>
|
||||||
|
/// <param name="position">Номер удаляемого объекта</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DrawningSimpleCatamaran operator -(AbstractCompany company, int position)
|
||||||
|
{
|
||||||
|
return company._collection?.Remove(position) ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение случайного объекта из коллекции
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public DrawningSimpleCatamaran? 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);
|
||||||
|
DrawBackground(graphics);
|
||||||
|
|
||||||
|
SetObjectsPosition();
|
||||||
|
for (int i = 0; i < (_collection?.Count ?? 0); ++i)
|
||||||
|
{
|
||||||
|
DrawningSimpleCatamaran? obj = _collection?.Get(i);
|
||||||
|
obj?.DrawTransport(graphics);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Вывод заднего фона
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g"></param>
|
||||||
|
protected abstract void DrawBackground(Graphics g);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Расстановка объектов
|
||||||
|
/// </summary>
|
||||||
|
protected abstract void SetObjectsPosition();
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
using Project_Catamaran.Drawnings;
|
||||||
|
using ProjectCatamaran.CollectionGenericObjects;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Project_Catamaran.CollectionGenereticObjects
|
||||||
|
{
|
||||||
|
public class CatamaranSharingService : AbstractCompany
|
||||||
|
{
|
||||||
|
private List<Tuple<int, int>> locCoord = new List<Tuple<int, int>>();
|
||||||
|
private int numRows, numCols;
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="picWidth"></param>
|
||||||
|
/// <param name="picHeight"></param>
|
||||||
|
/// <param name="collection"></param>
|
||||||
|
public CatamaranSharingService(int picWidth, int picHeight, ICollectionGenericObjects<DrawningSimpleCatamaran> collection) : base(picWidth, picHeight, collection)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void DrawBackground(Graphics g)
|
||||||
|
{
|
||||||
|
Color backgroundColor = Color.White;
|
||||||
|
using (Brush brush = new SolidBrush(backgroundColor))
|
||||||
|
{
|
||||||
|
g.FillRectangle(brush, new Rectangle(0, 0, _pictureWidth, _pictureHeight));
|
||||||
|
}
|
||||||
|
Pen pen = new Pen(Color.Brown, 3);
|
||||||
|
int offsetX = 10, offsetY = -5;
|
||||||
|
int x = 1 + offsetX, y = _pictureHeight - _placeSizeHeight + offsetY;
|
||||||
|
numRows = 0;
|
||||||
|
while (y >= 0)
|
||||||
|
{
|
||||||
|
int numCols = 0;
|
||||||
|
while (x + _placeSizeWidth <= _pictureWidth)
|
||||||
|
{
|
||||||
|
numCols++;
|
||||||
|
g.DrawLine(pen, x, y, x + _placeSizeWidth / 2, y);
|
||||||
|
g.DrawLine(pen, x, y, x, y + _placeSizeHeight + 4);
|
||||||
|
locCoord.Add(new Tuple<int, int>(x, y));
|
||||||
|
x += _placeSizeWidth + 2;
|
||||||
|
}
|
||||||
|
numRows++;
|
||||||
|
x = 1 + offsetX;
|
||||||
|
y -= _placeSizeHeight + 2 + offsetY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void SetObjectsPosition()
|
||||||
|
{
|
||||||
|
if (locCoord == null || _collection == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int row = numRows - 1, col = numCols;
|
||||||
|
for (int i = 0; i < _collection?.Count; i++, col--)
|
||||||
|
{
|
||||||
|
_collection?.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight);
|
||||||
|
_collection?.Get(i)?.SetPosition(locCoord[row * numCols - col].Item1 + 5, locCoord[row * numCols - col].Item2 + 9);
|
||||||
|
if (col == 1)
|
||||||
|
{
|
||||||
|
col = numCols + 1;
|
||||||
|
row--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -22,14 +22,15 @@ public class DrawningCatamaran : DrawningSimpleCatamaran
|
|||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
public DrawningCatamaran(int speed, double weight, Color bodyColor, Color additionalColor, bool floats, bool sail, bool deck ) : base(speed, weight, bodyColor)
|
||||||
|
|
||||||
|
|
||||||
public DrawningCatamaran(int speed, double weight, Color bodyColor, Color additionalColor, bool floats, bool sail, bool deck) : base(100, 90, bodyColor)
|
|
||||||
{
|
{
|
||||||
EntitySimpleCatamaran = new EntityCatamaran(speed, weight, bodyColor, additionalColor, floats, sail, deck);
|
EntitySimpleCatamaran = new EntityCatamaran(speed, weight, bodyColor, additionalColor, floats, sail, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public override void DrawTransport(Graphics g)
|
public override void DrawTransport(Graphics g)
|
||||||
|
@ -37,12 +37,12 @@ public class DrawningSimpleCatamaran
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина прорисовки катамарана
|
/// Ширина прорисовки катамарана
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _drawningCatamaranWidth = 100;
|
private readonly int _drawningCatamaranWidth = 90;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Высота прорисовки катамарана
|
/// Высота прорисовки катамарана
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _drawningCatamaranHeight = 85;
|
private readonly int _drawningCatamaranHeight = 95;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
28
LabOOP_1/LabOOP_1/FormCatamaran.Designer.cs
generated
28
LabOOP_1/LabOOP_1/FormCatamaran.Designer.cs
generated
@ -28,29 +28,16 @@ partial class FormCatamaran
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
buttonCreateSimpleCatamaran = new Button();
|
|
||||||
buttonLeft = new Button();
|
buttonLeft = new Button();
|
||||||
buttonDown = new Button();
|
buttonDown = new Button();
|
||||||
buttonUp = new Button();
|
buttonUp = new Button();
|
||||||
buttonRight = new Button();
|
buttonRight = new Button();
|
||||||
pictureBoxCatamaran = new PictureBox();
|
pictureBoxCatamaran = new PictureBox();
|
||||||
buttonCreateCatamaran = new Button();
|
|
||||||
comboBoxStrategy = new ComboBox();
|
comboBoxStrategy = new ComboBox();
|
||||||
buttonStrategyStep = new Button();
|
buttonStrategyStep = new Button();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCatamaran).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxCatamaran).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// buttonCreateSimpleCatamaran
|
|
||||||
//
|
|
||||||
buttonCreateSimpleCatamaran.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
buttonCreateSimpleCatamaran.Location = new Point(12, 404);
|
|
||||||
buttonCreateSimpleCatamaran.Name = "buttonCreateSimpleCatamaran";
|
|
||||||
buttonCreateSimpleCatamaran.Size = new Size(260, 34);
|
|
||||||
buttonCreateSimpleCatamaran.TabIndex = 1;
|
|
||||||
buttonCreateSimpleCatamaran.Text = "Создать простой катамаран";
|
|
||||||
buttonCreateSimpleCatamaran.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreateSimpleCatamaran.Click += buttonCreateSimpleCatamaran_Click;
|
|
||||||
//
|
|
||||||
// buttonLeft
|
// buttonLeft
|
||||||
//
|
//
|
||||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
@ -108,17 +95,6 @@ partial class FormCatamaran
|
|||||||
pictureBoxCatamaran.TabIndex = 6;
|
pictureBoxCatamaran.TabIndex = 6;
|
||||||
pictureBoxCatamaran.TabStop = false;
|
pictureBoxCatamaran.TabStop = false;
|
||||||
//
|
//
|
||||||
// buttonCreateCatamaran
|
|
||||||
//
|
|
||||||
buttonCreateCatamaran.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
buttonCreateCatamaran.Location = new Point(291, 404);
|
|
||||||
buttonCreateCatamaran.Name = "buttonCreateCatamaran";
|
|
||||||
buttonCreateCatamaran.Size = new Size(202, 34);
|
|
||||||
buttonCreateCatamaran.TabIndex = 7;
|
|
||||||
buttonCreateCatamaran.Text = "Создать катамаран";
|
|
||||||
buttonCreateCatamaran.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreateCatamaran.Click += buttonCreateCatamaran_Click;
|
|
||||||
//
|
|
||||||
// comboBoxStrategy
|
// comboBoxStrategy
|
||||||
//
|
//
|
||||||
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
@ -146,12 +122,10 @@ partial class FormCatamaran
|
|||||||
ClientSize = new Size(800, 450);
|
ClientSize = new Size(800, 450);
|
||||||
Controls.Add(buttonStrategyStep);
|
Controls.Add(buttonStrategyStep);
|
||||||
Controls.Add(comboBoxStrategy);
|
Controls.Add(comboBoxStrategy);
|
||||||
Controls.Add(buttonCreateCatamaran);
|
|
||||||
Controls.Add(buttonRight);
|
Controls.Add(buttonRight);
|
||||||
Controls.Add(buttonUp);
|
Controls.Add(buttonUp);
|
||||||
Controls.Add(buttonDown);
|
Controls.Add(buttonDown);
|
||||||
Controls.Add(buttonLeft);
|
Controls.Add(buttonLeft);
|
||||||
Controls.Add(buttonCreateSimpleCatamaran);
|
|
||||||
Controls.Add(pictureBoxCatamaran);
|
Controls.Add(pictureBoxCatamaran);
|
||||||
Name = "FormCatamaran";
|
Name = "FormCatamaran";
|
||||||
Text = "Катамаран";
|
Text = "Катамаран";
|
||||||
@ -160,13 +134,11 @@ partial class FormCatamaran
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
private Button buttonCreateSimpleCatamaran;
|
|
||||||
private Button buttonLeft;
|
private Button buttonLeft;
|
||||||
private Button buttonDown;
|
private Button buttonDown;
|
||||||
private Button buttonUp;
|
private Button buttonUp;
|
||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
private PictureBox pictureBoxCatamaran;
|
private PictureBox pictureBoxCatamaran;
|
||||||
private Button buttonCreateCatamaran;
|
|
||||||
private ComboBox comboBoxStrategy;
|
private ComboBox comboBoxStrategy;
|
||||||
private Button buttonStrategyStep;
|
private Button buttonStrategyStep;
|
||||||
}
|
}
|
@ -23,6 +23,18 @@ public partial class FormCatamaran : Form
|
|||||||
|
|
||||||
private AbstractStrategy? _strategy;
|
private AbstractStrategy? _strategy;
|
||||||
|
|
||||||
|
public DrawningSimpleCatamaran SetSimpleCatamaran
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_drawningSimpleCatamaran = value;
|
||||||
|
_drawningSimpleCatamaran.SetPictureSize(pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
|
||||||
|
comboBoxStrategy.Enabled = true;
|
||||||
|
_strategy = null;
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public FormCatamaran()
|
public FormCatamaran()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -42,51 +54,8 @@ public partial class FormCatamaran : Form
|
|||||||
pictureBoxCatamaran.Image = bmp;
|
pictureBoxCatamaran.Image = bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Обработка нажатия кнопки "Создать"
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void CreateObject(string type)
|
|
||||||
{
|
|
||||||
Random random = new();
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case nameof(DrawningSimpleCatamaran):
|
|
||||||
_drawningSimpleCatamaran = new DrawningSimpleCatamaran(random.Next(30, 70), random.Next(100, 500),
|
|
||||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
|
|
||||||
break;
|
|
||||||
case nameof(DrawningCatamaran):
|
|
||||||
_drawningSimpleCatamaran = new DrawningCatamaran(random.Next(30, 70), random.Next(100, 500),
|
|
||||||
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;
|
|
||||||
|
|
||||||
}
|
|
||||||
_drawningSimpleCatamaran.SetPictureSize(pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
|
|
||||||
_drawningSimpleCatamaran.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 buttonCreateSimpleCatamaran_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningSimpleCatamaran));
|
|
||||||
/// <summary>
|
|
||||||
/// Обработка кнопки "Создать катамаран"
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
|
|
||||||
private void buttonCreateCatamaran_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningCatamaran));
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
173
LabOOP_1/LabOOP_1/FormCatamaranColection.Designer.cs
generated
Normal file
173
LabOOP_1/LabOOP_1/FormCatamaranColection.Designer.cs
generated
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
namespace Project_Catamaran
|
||||||
|
{
|
||||||
|
partial class FormCatamaranColection
|
||||||
|
{
|
||||||
|
/// <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();
|
||||||
|
buttonRemoveCatamaran = new Button();
|
||||||
|
maskedTextBoxPosition = new MaskedTextBox();
|
||||||
|
buttonAddCatamaran = new Button();
|
||||||
|
buttonAddSimpleCatamaran = 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(buttonRemoveCatamaran);
|
||||||
|
groupBoxTools.Controls.Add(maskedTextBoxPosition);
|
||||||
|
groupBoxTools.Controls.Add(buttonAddCatamaran);
|
||||||
|
groupBoxTools.Controls.Add(buttonAddSimpleCatamaran);
|
||||||
|
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
|
||||||
|
groupBoxTools.Dock = DockStyle.Right;
|
||||||
|
groupBoxTools.Location = new Point(643, 0);
|
||||||
|
groupBoxTools.Name = "groupBoxTools";
|
||||||
|
groupBoxTools.Size = new Size(228, 477);
|
||||||
|
groupBoxTools.TabIndex = 0;
|
||||||
|
groupBoxTools.TabStop = false;
|
||||||
|
groupBoxTools.Text = "Инструменты";
|
||||||
|
//
|
||||||
|
// buttonRefresh
|
||||||
|
//
|
||||||
|
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonRefresh.Location = new Point(18, 298);
|
||||||
|
buttonRefresh.Name = "buttonRefresh";
|
||||||
|
buttonRefresh.Size = new Size(198, 39);
|
||||||
|
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(18, 256);
|
||||||
|
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||||
|
buttonGoToCheck.Size = new Size(198, 36);
|
||||||
|
buttonGoToCheck.TabIndex = 5;
|
||||||
|
buttonGoToCheck.Text = "Передать на тесты";
|
||||||
|
buttonGoToCheck.UseVisualStyleBackColor = true;
|
||||||
|
buttonGoToCheck.Click += buttonGoToCheck_Click;
|
||||||
|
//
|
||||||
|
// buttonRemoveCatamaran
|
||||||
|
//
|
||||||
|
buttonRemoveCatamaran.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonRemoveCatamaran.Location = new Point(18, 220);
|
||||||
|
buttonRemoveCatamaran.Name = "buttonRemoveCatamaran";
|
||||||
|
buttonRemoveCatamaran.Size = new Size(198, 30);
|
||||||
|
buttonRemoveCatamaran.TabIndex = 4;
|
||||||
|
buttonRemoveCatamaran.Text = "Удалить катамаран";
|
||||||
|
buttonRemoveCatamaran.UseVisualStyleBackColor = true;
|
||||||
|
buttonRemoveCatamaran.Click += buttonRemoveCatamaran_Click_1;
|
||||||
|
//
|
||||||
|
// maskedTextBoxPosition
|
||||||
|
//
|
||||||
|
maskedTextBoxPosition.Location = new Point(18, 174);
|
||||||
|
maskedTextBoxPosition.Mask = "00";
|
||||||
|
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||||
|
maskedTextBoxPosition.Size = new Size(198, 31);
|
||||||
|
maskedTextBoxPosition.TabIndex = 3;
|
||||||
|
maskedTextBoxPosition.ValidatingType = typeof(int);
|
||||||
|
//
|
||||||
|
// buttonAddCatamaran
|
||||||
|
//
|
||||||
|
buttonAddCatamaran.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonAddCatamaran.Location = new Point(18, 109);
|
||||||
|
buttonAddCatamaran.Name = "buttonAddCatamaran";
|
||||||
|
buttonAddCatamaran.Size = new Size(198, 59);
|
||||||
|
buttonAddCatamaran.TabIndex = 2;
|
||||||
|
buttonAddCatamaran.Text = "Создать улучшенный катамаран";
|
||||||
|
buttonAddCatamaran.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddCatamaran.Click += buttonAddCatamaran_Click_1;
|
||||||
|
//
|
||||||
|
// buttonAddSimpleCatamaran
|
||||||
|
//
|
||||||
|
buttonAddSimpleCatamaran.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonAddSimpleCatamaran.Location = new Point(18, 69);
|
||||||
|
buttonAddSimpleCatamaran.Name = "buttonAddSimpleCatamaran";
|
||||||
|
buttonAddSimpleCatamaran.Size = new Size(198, 34);
|
||||||
|
buttonAddSimpleCatamaran.TabIndex = 1;
|
||||||
|
buttonAddSimpleCatamaran.Text = "Создать Катамаран";
|
||||||
|
buttonAddSimpleCatamaran.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddSimpleCatamaran.Click += buttonAddSimpleCatamaran_Click_1;
|
||||||
|
//
|
||||||
|
// 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(18, 30);
|
||||||
|
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
||||||
|
comboBoxSelectorCompany.Size = new Size(198, 33);
|
||||||
|
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(643, 477);
|
||||||
|
pictureBox.TabIndex = 1;
|
||||||
|
pictureBox.TabStop = false;
|
||||||
|
//
|
||||||
|
// FormCatamaranColection
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(871, 477);
|
||||||
|
Controls.Add(pictureBox);
|
||||||
|
Controls.Add(groupBoxTools);
|
||||||
|
Name = "FormCatamaranColection";
|
||||||
|
Text = "Коллекция катамаранов";
|
||||||
|
groupBoxTools.ResumeLayout(false);
|
||||||
|
groupBoxTools.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private GroupBox groupBoxTools;
|
||||||
|
private ComboBox comboBoxSelectorCompany;
|
||||||
|
private Button buttonAddCatamaran;
|
||||||
|
private Button buttonAddSimpleCatamaran;
|
||||||
|
private PictureBox pictureBox;
|
||||||
|
private Button buttonRemoveCatamaran;
|
||||||
|
private MaskedTextBox maskedTextBoxPosition;
|
||||||
|
private Button buttonRefresh;
|
||||||
|
private Button buttonGoToCheck;
|
||||||
|
}
|
||||||
|
}
|
176
LabOOP_1/LabOOP_1/FormCatamaranColection.cs
Normal file
176
LabOOP_1/LabOOP_1/FormCatamaranColection.cs
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
using Project_Catamaran.CollectionGenereticObjects;
|
||||||
|
using Project_Catamaran.Drawnings;
|
||||||
|
using ProjectCatamaran.CollectionGenericObjects;
|
||||||
|
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 Project_Catamaran
|
||||||
|
{
|
||||||
|
public partial class FormCatamaranColection : Form
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Компания
|
||||||
|
/// </summary>
|
||||||
|
private AbstractCompany? _company;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
public FormCatamaranColection()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Выбор компании
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
|
||||||
|
|
||||||
|
private void CreateObject(string type)
|
||||||
|
{
|
||||||
|
if (_company == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DrawningSimpleCatamaran drawningSimpleCatamaran;
|
||||||
|
Random random = new();
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case nameof(DrawningSimpleCatamaran):
|
||||||
|
drawningSimpleCatamaran = new DrawningSimpleCatamaran(random.Next(30, 70), random.Next(100, 500),
|
||||||
|
GetColor(random));
|
||||||
|
break;
|
||||||
|
case nameof(DrawningCatamaran):
|
||||||
|
drawningSimpleCatamaran = new DrawningCatamaran(random.Next(30, 70), random.Next(100, 500),
|
||||||
|
GetColor(random), GetColor(random),
|
||||||
|
Convert.ToBoolean(random.Next(2, 2)), Convert.ToBoolean(random.Next(2, 2)), Convert.ToBoolean(random.Next(2, 2)));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (_company + drawningSimpleCatamaran != -1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект добавлен");
|
||||||
|
pictureBox.Image = _company.Show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение цвета
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="random">Генератор случайных чисел</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
|
||||||
|
private static Color GetColor(Random random)
|
||||||
|
{
|
||||||
|
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||||
|
ColorDialog dialog = new();
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
color = dialog.Color;
|
||||||
|
}
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonRefresh_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_company == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pictureBox.Image = _company.Show();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Передача объекта в другую форму
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
|
||||||
|
private void buttonGoToCheck_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_company == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawningSimpleCatamaran? catamaran = null;
|
||||||
|
int counter = 100;
|
||||||
|
while (catamaran == null)
|
||||||
|
{
|
||||||
|
catamaran = _company.GetRandomObject();
|
||||||
|
counter--;
|
||||||
|
if (counter <= 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (catamaran == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
FormCatamaran form = new FormCatamaran();
|
||||||
|
form.SetSimpleCatamaran = catamaran;
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAddSimpleCatamaran_Click_1(object sender, EventArgs e) => CreateObject(nameof(DrawningSimpleCatamaran));
|
||||||
|
|
||||||
|
private void buttonAddCatamaran_Click_1(object sender, EventArgs e) => CreateObject(nameof(DrawningCatamaran));
|
||||||
|
|
||||||
|
private void buttonRemoveCatamaran_Click_1(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("Не удалось удалить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void comboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
switch (comboBoxSelectorCompany.Text)
|
||||||
|
{
|
||||||
|
case "Хранилище":
|
||||||
|
_company = new CatamaranSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawningSimpleCatamaran>());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
LabOOP_1/LabOOP_1/FormCatamaranColection.resx
Normal file
120
LabOOP_1/LabOOP_1/FormCatamaranColection.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,6 +11,6 @@ internal static class Program
|
|||||||
// 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 FormCatamaran());
|
Application.Run(new FormCatamaranColection());
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user