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