Осталось дописать задачи
This commit is contained in:
parent
e7492d7da7
commit
663adfd533
@ -29,12 +29,10 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
pictureBox1 = new PictureBox();
|
||||
buttonCreateZU = new Button();
|
||||
buttonLeft = new Button();
|
||||
buttonRight = new Button();
|
||||
buttonUp = new Button();
|
||||
buttonDown = new Button();
|
||||
buttonCreatePlatforma = new Button();
|
||||
comboBoxStrategy = new ComboBox();
|
||||
buttonStrategyStep = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
|
||||
@ -50,17 +48,6 @@
|
||||
pictureBox1.TabIndex = 0;
|
||||
pictureBox1.TabStop = false;
|
||||
//
|
||||
// buttonCreateZU
|
||||
//
|
||||
buttonCreateZU.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreateZU.Location = new Point(12, 289);
|
||||
buttonCreateZU.Name = "buttonCreateZU";
|
||||
buttonCreateZU.Size = new Size(69, 23);
|
||||
buttonCreateZU.TabIndex = 1;
|
||||
buttonCreateZU.Text = "Новая ЗУ";
|
||||
buttonCreateZU.UseVisualStyleBackColor = true;
|
||||
buttonCreateZU.Click += buttonCreate_Click_1;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
@ -109,17 +96,6 @@
|
||||
buttonDown.UseVisualStyleBackColor = true;
|
||||
buttonDown.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonCreatePlatforma
|
||||
//
|
||||
buttonCreatePlatforma.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreatePlatforma.Location = new Point(87, 289);
|
||||
buttonCreatePlatforma.Name = "buttonCreatePlatforma";
|
||||
buttonCreatePlatforma.Size = new Size(115, 23);
|
||||
buttonCreatePlatforma.TabIndex = 6;
|
||||
buttonCreatePlatforma.Text = "Новая платформа";
|
||||
buttonCreatePlatforma.UseVisualStyleBackColor = true;
|
||||
buttonCreatePlatforma.Click += buttonCreatePlatforma_Click;
|
||||
//
|
||||
// comboBoxStrategy
|
||||
//
|
||||
comboBoxStrategy.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
@ -149,12 +125,10 @@
|
||||
ClientSize = new Size(874, 324);
|
||||
Controls.Add(buttonStrategyStep);
|
||||
Controls.Add(comboBoxStrategy);
|
||||
Controls.Add(buttonCreatePlatforma);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(buttonCreateZU);
|
||||
Controls.Add(pictureBox1);
|
||||
Name = "FormTankZU";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
@ -167,12 +141,10 @@
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBox1;
|
||||
private Button buttonCreateZU;
|
||||
private Button buttonLeft;
|
||||
private Button buttonRight;
|
||||
private Button buttonUp;
|
||||
private Button buttonDown;
|
||||
private Button buttonCreatePlatforma;
|
||||
private ComboBox comboBoxStrategy;
|
||||
private Button buttonStrategyStep;
|
||||
}
|
||||
|
@ -27,6 +27,21 @@ namespace WinFormsLabRad1
|
||||
/// </summary>
|
||||
private AbstractStrategy? _strategy;
|
||||
|
||||
/// <summary>
|
||||
/// Получение объекта
|
||||
/// </summary>
|
||||
public DrawningPlatforma SetPlatforma
|
||||
{
|
||||
set
|
||||
{
|
||||
_drawningPlatforma = value;
|
||||
_drawningPlatforma.SetPictureSize(pictureBox1.Width, pictureBox1.Height);
|
||||
comboBoxStrategy.Enabled = true;
|
||||
_strategy = null;
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор формы
|
||||
/// </summary>
|
||||
@ -55,7 +70,7 @@ namespace WinFormsLabRad1
|
||||
/// Создание объекта класса-перемещения
|
||||
/// </summary>
|
||||
/// <param name="type">Тип создаваемого объекта</param>
|
||||
private void CreateObject(string type)
|
||||
/* private void CreateObject(string type)
|
||||
{
|
||||
Random random = new();
|
||||
switch (type)
|
||||
@ -95,7 +110,7 @@ namespace WinFormsLabRad1
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
|
||||
private void buttonCreate_Click_1(object sender, EventArgs e) => CreateObject(nameof(DrawningTankZU));
|
||||
private void buttonCreate_Click_1(object sender, EventArgs e) => CreateObject(nameof(DrawningTankZU)); */
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -67,6 +67,7 @@
|
||||
buttonRefresh.TabIndex = 6;
|
||||
buttonRefresh.Text = "Обновить";
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
buttonRefresh.Click += buttonRefresh_Click;
|
||||
//
|
||||
// buttonGoToCheck
|
||||
//
|
||||
@ -77,6 +78,7 @@
|
||||
buttonGoToCheck.TabIndex = 5;
|
||||
buttonGoToCheck.Text = "Передать на тесты";
|
||||
buttonGoToCheck.UseVisualStyleBackColor = true;
|
||||
buttonGoToCheck.Click += buttonGoToCheck_Click;
|
||||
//
|
||||
// buttonRemoveMachine
|
||||
//
|
||||
@ -87,6 +89,7 @@
|
||||
buttonRemoveMachine.TabIndex = 4;
|
||||
buttonRemoveMachine.Text = "Удалить машину";
|
||||
buttonRemoveMachine.UseVisualStyleBackColor = true;
|
||||
buttonRemoveMachine.Click += buttonRemoveMachine_Click;
|
||||
//
|
||||
// maskedTextBox1
|
||||
//
|
||||
@ -107,6 +110,7 @@
|
||||
buttonAddTankZU.TabIndex = 2;
|
||||
buttonAddTankZU.Text = "Добавить ЗУ";
|
||||
buttonAddTankZU.UseVisualStyleBackColor = true;
|
||||
buttonAddTankZU.Click += buttonAddTankZU_Click;
|
||||
//
|
||||
// buttonAddMachine
|
||||
//
|
||||
@ -117,6 +121,7 @@
|
||||
buttonAddMachine.TabIndex = 1;
|
||||
buttonAddMachine.Text = "Добавить машину";
|
||||
buttonAddMachine.UseVisualStyleBackColor = true;
|
||||
buttonAddMachine.Click += buttonAddMachine_Click;
|
||||
//
|
||||
// comboBoxSelectorCompany
|
||||
//
|
||||
|
@ -21,7 +21,7 @@ namespace WinFormsLabRad1
|
||||
/// Компания
|
||||
/// </summary>
|
||||
private AbstractCompany? _company = null;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
@ -44,5 +44,149 @@ namespace WinFormsLabRad1
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление обычного объекта
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonAddMachine_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningPlatforma));
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Добавление дочернего объекта
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonAddTankZU_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningTankZU));
|
||||
|
||||
/// <summary>
|
||||
/// Создание объекта класса-перемещения
|
||||
/// </summary>
|
||||
/// <param name="type">Тип создаваемого объекта</param>
|
||||
private void CreateObject(string type)
|
||||
{
|
||||
if (_company == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Random random = new();
|
||||
DrawningPlatforma drawningPlatforma;
|
||||
switch (type)
|
||||
{
|
||||
case nameof(DrawningPlatforma):
|
||||
drawningPlatforma = new DrawningPlatforma(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
|
||||
break;
|
||||
case nameof(DrawningTankZU):
|
||||
// TODO вызов диалогового окна для выбора цвета
|
||||
drawningPlatforma = new DrawningTankZU(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;
|
||||
}
|
||||
if (_company + drawningPlatforma)
|
||||
{
|
||||
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 buttonRemoveMachine_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(maskedTextBox1.Text) || _company == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBox1.Text);
|
||||
if (_company - pos)
|
||||
{
|
||||
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;
|
||||
}
|
||||
DrawningPlatforma? platforma = null;
|
||||
int counter = 100;
|
||||
while (platforma == null)
|
||||
{
|
||||
platforma = _company.GetRandomObject();
|
||||
counter--;
|
||||
if (counter <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (platforma == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormTankZU form = new()
|
||||
{
|
||||
SetPlatforma = platforma
|
||||
};
|
||||
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 WinFormsLabRad1
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormTankZU());
|
||||
Application.Run(new FormTanksCollection());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user