изменения
This commit is contained in:
parent
485b0683d8
commit
29a246d8f3
@ -5,7 +5,7 @@ using AntiAircraftGun.Drawnings;
|
|||||||
namespace AntiAircraftGun.CollectionGenereticObjects;
|
namespace AntiAircraftGun.CollectionGenereticObjects;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Абстракция компании, хранящий коллекцию автомобилей
|
/// Абстракция компании, хранящий коллекцию бронемашин
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class AbstractCompany
|
public abstract class AbstractCompany
|
||||||
{
|
{
|
||||||
@ -30,7 +30,7 @@ public abstract class AbstractCompany
|
|||||||
protected readonly int _pictureHeight;
|
protected readonly int _pictureHeight;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Коллекция поездов
|
/// Коллекция броенамашин
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected ICollectionGenericObjects<DrawningArmoredCar>? _collection = null;
|
protected ICollectionGenericObjects<DrawningArmoredCar>? _collection = null;
|
||||||
|
|
||||||
@ -57,11 +57,11 @@ public abstract class AbstractCompany
|
|||||||
/// Перегрузка оператора сложения для класса
|
/// Перегрузка оператора сложения для класса
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="company">Компания</param>
|
/// <param name="company">Компания</param>
|
||||||
/// <param name="car">Добавляемый объект</param>
|
/// <param name="airplan">Добавляемый объект</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static int operator +(AbstractCompany company, DrawningArmoredCar car)
|
public static int operator +(AbstractCompany company, DrawningArmoredCar airplan)
|
||||||
{
|
{
|
||||||
return company._collection.Insert(car);
|
return company._collection.Insert(airplan);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -70,9 +70,9 @@ public abstract class AbstractCompany
|
|||||||
/// <param name="company">Компания</param>
|
/// <param name="company">Компания</param>
|
||||||
/// <param name="position">Номер удаляемого объекта</param>
|
/// <param name="position">Номер удаляемого объекта</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static DrawningArmoredCar? operator -(AbstractCompany company, int position)
|
public static DrawningArmoredCar operator -(AbstractCompany company, int position)
|
||||||
{
|
{
|
||||||
return company._collection?.Remove(position);
|
return company._collection.Remove(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -18,36 +18,47 @@ public class CarBase : AbstractCompany
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Отрисовка базы
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g">Графика</param>
|
||||||
protected override void DrawBackgound(Graphics g)
|
protected override void DrawBackgound(Graphics g)
|
||||||
{
|
{
|
||||||
Pen pen = new(Color.Black);
|
Pen pen = new Pen(Color.Black, 4f);
|
||||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
for (int i = 0; i < _pictureHeight / _placeSizeHeight / 2; i++)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight; j++)
|
g.DrawLine(pen, 0, i * _placeSizeHeight * 2, _pictureWidth / _placeSizeWidth * _placeSizeWidth, i * _placeSizeHeight * 2);
|
||||||
|
for (int j = 0; j < _pictureWidth / _placeSizeWidth + 1; ++j)
|
||||||
{
|
{
|
||||||
g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * j), new((int)(_placeSizeWidth * (i + 0.5f)), _placeSizeHeight * j));
|
g.DrawLine(pen, j * _placeSizeWidth, i * _placeSizeHeight * 2, j * _placeSizeWidth, i * _placeSizeHeight * 2 + _placeSizeHeight);
|
||||||
g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * j), new(_placeSizeWidth * i, _placeSizeHeight * (j + 1)));
|
|
||||||
}
|
}
|
||||||
g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * (_pictureHeight / _placeSizeHeight)), new((int)(_placeSizeWidth * (i + 0.5f)), _placeSizeHeight * (_pictureHeight / _placeSizeHeight)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Установка объекта в базу
|
||||||
|
/// </summary>
|
||||||
protected override void SetObjectsPosition()
|
protected override void SetObjectsPosition()
|
||||||
{
|
{
|
||||||
int n = 0;
|
int nowWidth = 0;
|
||||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
int nowHeight = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < (_collection?.Count ?? 0); i++)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight; j++)
|
if (nowHeight > _pictureHeight / _placeSizeHeight)
|
||||||
{
|
{
|
||||||
DrawningArmoredCar? drawingTrans = _collection?.Get(n);
|
return;
|
||||||
n++;
|
}
|
||||||
if (drawingTrans != null)
|
if (_collection?.Get(i) != null)
|
||||||
{
|
{
|
||||||
drawingTrans.SetPictureSize(_pictureWidth, _pictureHeight);
|
_collection?.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight);
|
||||||
drawingTrans.SetPosition(i * _placeSizeWidth + 5, j * _placeSizeHeight + 5);
|
_collection?.Get(i)?.SetPosition(_placeSizeWidth * nowWidth + 30, nowHeight * _placeSizeHeight * 2 + 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nowWidth < _pictureWidth / _placeSizeWidth - 1) nowWidth++;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nowWidth = 0;
|
||||||
|
nowHeight++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@
|
|||||||
buttonRefresh.TabIndex = 6;
|
buttonRefresh.TabIndex = 6;
|
||||||
buttonRefresh.Text = "Обновить";
|
buttonRefresh.Text = "Обновить";
|
||||||
buttonRefresh.UseVisualStyleBackColor = true;
|
buttonRefresh.UseVisualStyleBackColor = true;
|
||||||
|
buttonRefresh.Click += buttonRefresh_Click;
|
||||||
//
|
//
|
||||||
// buttonGoToChek
|
// buttonGoToChek
|
||||||
//
|
//
|
||||||
@ -77,6 +78,7 @@
|
|||||||
buttonGoToChek.TabIndex = 5;
|
buttonGoToChek.TabIndex = 5;
|
||||||
buttonGoToChek.Text = "Передать на тесты";
|
buttonGoToChek.Text = "Передать на тесты";
|
||||||
buttonGoToChek.UseVisualStyleBackColor = true;
|
buttonGoToChek.UseVisualStyleBackColor = true;
|
||||||
|
buttonGoToChek.Click += buttonGoToChek_Click;
|
||||||
//
|
//
|
||||||
// buttonRemoveArmoredCar
|
// buttonRemoveArmoredCar
|
||||||
//
|
//
|
||||||
@ -87,6 +89,7 @@
|
|||||||
buttonRemoveArmoredCar.TabIndex = 4;
|
buttonRemoveArmoredCar.TabIndex = 4;
|
||||||
buttonRemoveArmoredCar.Text = "Удалить бронемашину";
|
buttonRemoveArmoredCar.Text = "Удалить бронемашину";
|
||||||
buttonRemoveArmoredCar.UseVisualStyleBackColor = true;
|
buttonRemoveArmoredCar.UseVisualStyleBackColor = true;
|
||||||
|
buttonRemoveArmoredCar.Click += buttonRemoveArmoredCar_Click;
|
||||||
//
|
//
|
||||||
// maskedTextBox
|
// maskedTextBox
|
||||||
//
|
//
|
||||||
@ -106,6 +109,7 @@
|
|||||||
buttonAddAntiAircraftGun.TabIndex = 2;
|
buttonAddAntiAircraftGun.TabIndex = 2;
|
||||||
buttonAddAntiAircraftGun.Text = "Добавление зениитной установки";
|
buttonAddAntiAircraftGun.Text = "Добавление зениитной установки";
|
||||||
buttonAddAntiAircraftGun.UseVisualStyleBackColor = true;
|
buttonAddAntiAircraftGun.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddAntiAircraftGun.Click += buttonAddAntiAircraftGun_Click;
|
||||||
//
|
//
|
||||||
// buttonAddArmoredCar
|
// buttonAddArmoredCar
|
||||||
//
|
//
|
||||||
@ -116,6 +120,7 @@
|
|||||||
buttonAddArmoredCar.TabIndex = 1;
|
buttonAddArmoredCar.TabIndex = 1;
|
||||||
buttonAddArmoredCar.Text = "Добавление бронемашины";
|
buttonAddArmoredCar.Text = "Добавление бронемашины";
|
||||||
buttonAddArmoredCar.UseVisualStyleBackColor = true;
|
buttonAddArmoredCar.UseVisualStyleBackColor = true;
|
||||||
|
buttonAddArmoredCar.Click += buttonAddArmoredCar_Click;
|
||||||
//
|
//
|
||||||
// comboBoxSelectorCompany
|
// comboBoxSelectorCompany
|
||||||
//
|
//
|
||||||
@ -127,6 +132,7 @@
|
|||||||
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
|
||||||
comboBoxSelectorCompany.Size = new Size(198, 23);
|
comboBoxSelectorCompany.Size = new Size(198, 23);
|
||||||
comboBoxSelectorCompany.TabIndex = 0;
|
comboBoxSelectorCompany.TabIndex = 0;
|
||||||
|
comboBoxSelectorCompany.SelectedIndexChanged += comboBoxSelectorCompany_SelectedIndexChanged;
|
||||||
//
|
//
|
||||||
// pictureBox
|
// pictureBox
|
||||||
//
|
//
|
||||||
|
@ -27,7 +27,7 @@ public partial class FormArmoredCarCollection : Form
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ComboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
|
private void comboBoxSelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
switch (comboBoxSelectorCompany.Text)
|
switch (comboBoxSelectorCompany.Text)
|
||||||
{
|
{
|
||||||
@ -42,15 +42,14 @@ public partial class FormArmoredCarCollection : Form
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonAddArmoredCar_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningArmoredCar));
|
private void buttonAddArmoredCar_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningArmoredCar));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление зенитной установки
|
/// Добавление зенитной установки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonAddAntiAircraftGun_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAntiAircraftGun));
|
private void buttonAddAntiAircraftGun_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAntiAircraftGun));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Создание объекта класса-перемещения
|
/// Создание объекта класса-перемещения
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -113,18 +112,16 @@ public partial class FormArmoredCarCollection : Form
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonRemoveArmoredCar_Click(object sender, EventArgs e)
|
private void buttonRemoveArmoredCar_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null)
|
if (string.IsNullOrEmpty(maskedTextBox.Text) || _company == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pos = Convert.ToInt32(maskedTextBox.Text);
|
int pos = Convert.ToInt32(maskedTextBox.Text);
|
||||||
if (_company - pos != null)
|
if (_company - pos != null)
|
||||||
{
|
{
|
||||||
@ -137,12 +134,27 @@ public partial class FormArmoredCarCollection : Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <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();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Передача объекта в другую форму
|
/// Передача объекта в другую форму
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonGoToCheck_Click(object sender, EventArgs e)
|
private void buttonGoToChek_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_company == null)
|
if (_company == null)
|
||||||
{
|
{
|
||||||
@ -174,18 +186,5 @@ public partial class FormArmoredCarCollection : Form
|
|||||||
form.ShowDialog();
|
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace AntiAircraftGun
|
|||||||
// 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 FormAntiAircraftGun());
|
Application.Run(new FormArmoredCarCollection());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user