Лабораторная работа 5

This commit is contained in:
gettterot 2024-04-17 10:15:59 +04:00
parent d1e6850818
commit 2ab72ce5de
9 changed files with 784 additions and 149 deletions

View File

@ -10,12 +10,12 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
/// <summary>
/// Список объектов, которые храним
/// </summary>
private readonly List<T?> _collection;
private readonly Dictionary<int, T> _collection;
/// <summary>
/// Максимально допустимое число объектов в списке
/// </summary>
private int _maxCount;
public int Count => _collection.Count;
public int Count => _collection.Keys.Count;
public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } }
/// <summary>
/// Конструктор
@ -31,22 +31,21 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
}
public int Insert(T obj)
{
if (Count + 1 > _maxCount) return -1;
_collection.Add(obj);
if (Count > _maxCount) return -1;
_collection[Count-1] = obj;
return Count;
}
public int Insert(T obj, int position)
{
if (Count + 1 > _maxCount) return -1;
if (position < 0 || position > Count) return -1;
_collection.Insert(position, obj);
if (Count > _maxCount) return -1;
_collection[position] = obj;
return 1;
}
public T? Remove(int position)
{
if (position < 0 || position > Count) return null;
if (_collection.ContainsKey(position)) return null;
T? temp = _collection[position];
_collection.RemoveAt(position);
_collection.Remove(position);
return temp;
}
}

View File

@ -0,0 +1,13 @@
using ProjectLiner.Drawnings;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectLiner;
/// <summary>
/// Делегат передачи объекта класса-прорисовки
/// </summary>
/// <param name="liner"></param>
public delegate void CommonLinerDelegate(DrawningCommonLiner liner);

View File

@ -46,5 +46,14 @@ namespace ProjectLiner.Entities
BodyColor = bodyColor;
}
/// <summary>
/// Метод передачи основного цвета
/// </summary>
/// <param name="bodyColor"></param>
public void SetBodyColor(Color bodyColor)
{
BodyColor = bodyColor;
}
}
}

View File

@ -42,4 +42,13 @@ public class EntityLiner: EntityCommonLiner
Boats = boats;
Pipe = pipe;
}
/// <summary>
/// Метод передачи дополнительного цвета
/// </summary>
/// <param name="additionalColor"></param>
public void SetAdditionalColor(Color additionalColor)
{
AdditionalColor = additionalColor;
}
}

View File

@ -41,12 +41,11 @@
comboBoxSelectorCompany = new ComboBox();
pictureBox = new PictureBox();
panelCompanyTools = new Panel();
button1 = new Button();
button2 = new Button();
buttonAddLiner = new Button();
maskedTextBox1 = new MaskedTextBox();
button5 = new Button();
button3 = new Button();
button4 = new Button();
button5 = new Button();
groupBoxTools.SuspendLayout();
panelStorage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
@ -59,11 +58,9 @@
groupBoxTools.Controls.Add(panelStorage);
groupBoxTools.Controls.Add(comboBoxSelectorCompany);
groupBoxTools.Dock = DockStyle.Right;
groupBoxTools.Location = new Point(681, 0);
groupBoxTools.Margin = new Padding(2);
groupBoxTools.Location = new Point(1052, 0);
groupBoxTools.Name = "groupBoxTools";
groupBoxTools.Padding = new Padding(2);
groupBoxTools.Size = new Size(176, 648);
groupBoxTools.Size = new Size(272, 1063);
groupBoxTools.TabIndex = 0;
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
@ -71,9 +68,10 @@
// buttonCreateCompany
//
buttonCreateCompany.Font = new Font("Segoe UI", 9.75F, FontStyle.Regular, GraphicsUnit.Point);
buttonCreateCompany.Location = new Point(5, 317);
buttonCreateCompany.Location = new Point(8, 520);
buttonCreateCompany.Margin = new Padding(5);
buttonCreateCompany.Name = "buttonCreateCompany";
buttonCreateCompany.Size = new Size(166, 23);
buttonCreateCompany.Size = new Size(257, 38);
buttonCreateCompany.TabIndex = 8;
buttonCreateCompany.Text = "Создать компанию";
buttonCreateCompany.UseVisualStyleBackColor = true;
@ -89,18 +87,18 @@
panelStorage.Controls.Add(textBoxCollectionName);
panelStorage.Controls.Add(labelCollectionName);
panelStorage.Dock = DockStyle.Top;
panelStorage.Location = new Point(2, 28);
panelStorage.Margin = new Padding(2);
panelStorage.Location = new Point(3, 43);
panelStorage.Name = "panelStorage";
panelStorage.Size = new Size(172, 247);
panelStorage.Size = new Size(266, 405);
panelStorage.TabIndex = 7;
//
// buttonCollectionDel
//
buttonCollectionDel.Font = new Font("Segoe UI", 9.75F, FontStyle.Regular, GraphicsUnit.Point);
buttonCollectionDel.Location = new Point(3, 212);
buttonCollectionDel.Location = new Point(5, 348);
buttonCollectionDel.Margin = new Padding(5);
buttonCollectionDel.Name = "buttonCollectionDel";
buttonCollectionDel.Size = new Size(166, 23);
buttonCollectionDel.Size = new Size(257, 38);
buttonCollectionDel.TabIndex = 6;
buttonCollectionDel.Text = "Удалить Коллекцию";
buttonCollectionDel.UseVisualStyleBackColor = true;
@ -110,19 +108,19 @@
//
listBoxCollection.Font = new Font("Segoe UI", 9.75F, FontStyle.Regular, GraphicsUnit.Point);
listBoxCollection.FormattingEnabled = true;
listBoxCollection.ItemHeight = 17;
listBoxCollection.Location = new Point(3, 110);
listBoxCollection.ItemHeight = 30;
listBoxCollection.Location = new Point(5, 180);
listBoxCollection.Margin = new Padding(5);
listBoxCollection.Name = "listBoxCollection";
listBoxCollection.Size = new Size(166, 89);
listBoxCollection.Size = new Size(254, 124);
listBoxCollection.TabIndex = 5;
//
// buttonCollectionAdd
//
buttonCollectionAdd.Font = new Font("Segoe UI", 7.948052F, FontStyle.Regular, GraphicsUnit.Point);
buttonCollectionAdd.Location = new Point(2, 82);
buttonCollectionAdd.Margin = new Padding(2);
buttonCollectionAdd.Location = new Point(3, 134);
buttonCollectionAdd.Name = "buttonCollectionAdd";
buttonCollectionAdd.Size = new Size(170, 23);
buttonCollectionAdd.Size = new Size(263, 38);
buttonCollectionAdd.TabIndex = 4;
buttonCollectionAdd.Text = "Добавить коллекцию";
buttonCollectionAdd.UseVisualStyleBackColor = true;
@ -132,10 +130,9 @@
//
radioButtonList.AutoSize = true;
radioButtonList.Font = new Font("Segoe UI", 9.818182F, FontStyle.Regular, GraphicsUnit.Point);
radioButtonList.Location = new Point(89, 58);
radioButtonList.Margin = new Padding(2);
radioButtonList.Location = new Point(138, 95);
radioButtonList.Name = "radioButtonList";
radioButtonList.Size = new Size(73, 23);
radioButtonList.Size = new Size(107, 34);
radioButtonList.TabIndex = 3;
radioButtonList.TabStop = true;
radioButtonList.Text = "Список";
@ -145,10 +142,9 @@
//
radioButtonMassive.AutoSize = true;
radioButtonMassive.Font = new Font("Segoe UI", 9.818182F, FontStyle.Regular, GraphicsUnit.Point);
radioButtonMassive.Location = new Point(2, 58);
radioButtonMassive.Margin = new Padding(2);
radioButtonMassive.Location = new Point(3, 95);
radioButtonMassive.Name = "radioButtonMassive";
radioButtonMassive.Size = new Size(71, 23);
radioButtonMassive.Size = new Size(107, 34);
radioButtonMassive.TabIndex = 2;
radioButtonMassive.TabStop = true;
radioButtonMassive.Text = "массив";
@ -156,20 +152,18 @@
//
// textBoxCollectionName
//
textBoxCollectionName.Location = new Point(0, 26);
textBoxCollectionName.Margin = new Padding(2);
textBoxCollectionName.Location = new Point(0, 43);
textBoxCollectionName.Name = "textBoxCollectionName";
textBoxCollectionName.Size = new Size(172, 33);
textBoxCollectionName.Size = new Size(264, 47);
textBoxCollectionName.TabIndex = 1;
//
// labelCollectionName
//
labelCollectionName.AutoSize = true;
labelCollectionName.Font = new Font("Segoe UI", 9.818182F, FontStyle.Regular, GraphicsUnit.Point);
labelCollectionName.Location = new Point(14, 5);
labelCollectionName.Margin = new Padding(2, 0, 2, 0);
labelCollectionName.Location = new Point(22, 8);
labelCollectionName.Name = "labelCollectionName";
labelCollectionName.Size = new Size(140, 19);
labelCollectionName.Size = new Size(213, 30);
labelCollectionName.TabIndex = 0;
labelCollectionName.Text = "Название коллекции";
//
@ -179,10 +173,9 @@
comboBoxSelectorCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectorCompany.FormattingEnabled = true;
comboBoxSelectorCompany.Items.AddRange(new object[] { "Хранилище" });
comboBoxSelectorCompany.Location = new Point(13, 279);
comboBoxSelectorCompany.Margin = new Padding(2);
comboBoxSelectorCompany.Location = new Point(20, 458);
comboBoxSelectorCompany.Name = "comboBoxSelectorCompany";
comboBoxSelectorCompany.Size = new Size(158, 33);
comboBoxSelectorCompany.Size = new Size(242, 49);
comboBoxSelectorCompany.TabIndex = 0;
comboBoxSelectorCompany.SelectedIndexChanged += ComboBoxSelectorCompany_SelectedIndexChanged;
//
@ -191,67 +184,61 @@
pictureBox.Dock = DockStyle.Bottom;
pictureBox.Enabled = false;
pictureBox.Location = new Point(0, 0);
pictureBox.Margin = new Padding(2);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(681, 648);
pictureBox.Size = new Size(1052, 1063);
pictureBox.TabIndex = 1;
pictureBox.TabStop = false;
//
// panelCompanyTools
//
panelCompanyTools.BackColor = SystemColors.Window;
panelCompanyTools.Controls.Add(button1);
panelCompanyTools.Controls.Add(button2);
panelCompanyTools.Controls.Add(buttonAddLiner);
panelCompanyTools.Controls.Add(maskedTextBox1);
panelCompanyTools.Controls.Add(button5);
panelCompanyTools.Controls.Add(button3);
panelCompanyTools.Controls.Add(button4);
panelCompanyTools.Location = new Point(681, 346);
panelCompanyTools.Location = new Point(1052, 567);
panelCompanyTools.Margin = new Padding(5);
panelCompanyTools.Name = "panelCompanyTools";
panelCompanyTools.Size = new Size(176, 302);
panelCompanyTools.Size = new Size(272, 495);
panelCompanyTools.TabIndex = 9;
//
// button1
// buttonAddLiner
//
button1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
button1.Location = new Point(4, 2);
button1.Margin = new Padding(2);
button1.Name = "button1";
button1.Size = new Size(140, 46);
button1.TabIndex = 1;
button1.Text = "Добавление Лайнера";
button1.UseVisualStyleBackColor = true;
button1.Click += ButtonAddLiner_Click;
//
// button2
//
button2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
button2.Location = new Point(2, 52);
button2.Margin = new Padding(2);
button2.Name = "button2";
button2.Size = new Size(140, 46);
button2.TabIndex = 2;
button2.Text = "Добавление Обычного Лайнера";
button2.UseVisualStyleBackColor = true;
button2.Click += ButtonAddCommonLiner_Click;
buttonAddLiner.Location = new Point(6, 54);
buttonAddLiner.Name = "buttonAddLiner";
buttonAddLiner.Size = new Size(214, 75);
buttonAddLiner.TabIndex = 7;
buttonAddLiner.Text = "Добавить";
buttonAddLiner.UseVisualStyleBackColor = true;
buttonAddLiner.Click += ButtonAddCommonLiner_Click;
//
// maskedTextBox1
//
maskedTextBox1.Location = new Point(2, 102);
maskedTextBox1.Margin = new Padding(2);
maskedTextBox1.Location = new Point(3, 167);
maskedTextBox1.Mask = "00";
maskedTextBox1.Name = "maskedTextBox1";
maskedTextBox1.Size = new Size(142, 33);
maskedTextBox1.Size = new Size(217, 47);
maskedTextBox1.TabIndex = 3;
maskedTextBox1.ValidatingType = typeof(int);
//
// button5
//
button5.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
button5.Location = new Point(3, 384);
button5.Name = "button5";
button5.Size = new Size(216, 75);
button5.TabIndex = 6;
button5.Text = "Обновить";
button5.UseVisualStyleBackColor = true;
button5.Click += ButtonRefresh_Click;
//
// button3
//
button3.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
button3.Location = new Point(2, 134);
button3.Margin = new Padding(2);
button3.Location = new Point(3, 220);
button3.Name = "button3";
button3.Size = new Size(140, 46);
button3.Size = new Size(216, 75);
button3.TabIndex = 4;
button3.Text = "Удаление Лайнера";
button3.UseVisualStyleBackColor = true;
@ -260,36 +247,22 @@
// button4
//
button4.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
button4.Location = new Point(2, 184);
button4.Margin = new Padding(2);
button4.Location = new Point(3, 302);
button4.Name = "button4";
button4.Size = new Size(140, 46);
button4.Size = new Size(216, 75);
button4.TabIndex = 5;
button4.Text = "Передать на тесты";
button4.UseVisualStyleBackColor = true;
button4.Click += ButtonGoToCheck_Click;
//
// button5
//
button5.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
button5.Location = new Point(2, 234);
button5.Margin = new Padding(2);
button5.Name = "button5";
button5.Size = new Size(140, 46);
button5.TabIndex = 6;
button5.Text = "Обновить";
button5.UseVisualStyleBackColor = true;
button5.Click += ButtonRefresh_Click;
//
// FormLinerCollection
//
AutoScaleDimensions = new SizeF(11F, 25F);
AutoScaleDimensions = new SizeF(17F, 41F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(857, 648);
ClientSize = new Size(1324, 1063);
Controls.Add(panelCompanyTools);
Controls.Add(pictureBox);
Controls.Add(groupBoxTools);
Margin = new Padding(2);
Name = "FormLinerCollection";
Text = "Коллекция автомобилей";
groupBoxTools.ResumeLayout(false);
@ -304,9 +277,7 @@
#endregion
private GroupBox groupBoxTools;
private Button buttonAddLiner;
private ComboBox comboBoxSelectorCompany;
private Button buttonAddCommonLiner;
private PictureBox pictureBox;
private Button buttonGoToCheck;
private Button buttonRemoveLiner;
@ -322,11 +293,10 @@
private ListBox listBoxCollection;
private Button buttonCreateCompany;
private Panel panelCompanyTools;
private Button button1;
private Button button2;
private MaskedTextBox maskedTextBox1;
private Button button5;
private Button button3;
private Button button4;
private Button buttonAddLiner;
}
}

View File

@ -34,45 +34,29 @@ public partial class FormLinerCollection : Form
panelCompanyTools.Enabled = false;
}
/// <summary>
/// Добавление грузовика
/// Добавление лайнера
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddCommonLiner_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningCommonLiner));
/// <summary>
/// Добавление подметательно-уборочной машины
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddLiner_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningLiner));
/// <summary>
/// Создание объекта класса-перемещенияв
/// </summary>
/// <param name="type"></param>
private void CreateObject(string type)
private void ButtonAddCommonLiner_Click(object sender, EventArgs e)
{
if (_company == null)
FormLinerConfig form = new();
form.Show();
form.AddEvent(SetLiner);
}
/// <summary>
/// Добавление Лайнера в коллекцию
/// </summary>
/// <param name="airplane"></param>
private void SetLiner(DrawningCommonLiner liner)
{
if (_company == null || liner == null)
{
return;
}
Random random = new();
DrawningCommonLiner drawningCommonLiner;
switch (type)
{
case nameof(DrawningCommonLiner):
drawningCommonLiner = new DrawningCommonLiner(random.Next(100, 300),
random.Next(1000, 3000), GetColor(random));
break;
case nameof(DrawningLiner):
drawningCommonLiner = new DrawningLiner(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 + drawningCommonLiner != -1)
if (_company + liner != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
@ -82,22 +66,7 @@ public partial class FormLinerCollection : Form
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>
@ -105,7 +74,7 @@ public partial class FormLinerCollection : Form
/// <param name="e"></param>
private void ButtonRemoveLiner_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text) || _company == null)
if (string.IsNullOrEmpty(maskedTextBoxPosition?.Text) || _company == null)
{
return;
}

View File

@ -0,0 +1,380 @@
namespace ProjectLiner
{
partial class FormLinerConfig
{
/// <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()
{
Label labelSimpleObject;
Label labelModifiedObject;
Label labelBodyColor;
Label labelAdditionslColor;
groupBoxConfig = new GroupBox();
groupBoxColors = new GroupBox();
panelDarkOliveGreen = new Panel();
panelAqua = new Panel();
panelSeaGreen = new Panel();
panelPaleGreen = new Panel();
panelCrimson = new Panel();
panelMediumBlue = new Panel();
panelDeepPink = new Panel();
panelBlueViolet = new Panel();
checkBoxPipe = new CheckBox();
checkBoxBoats = new CheckBox();
checkBoxAnchor = new CheckBox();
numericUpDownWeight = new NumericUpDown();
labelWeight = new Label();
numericUpDownSpeed = new NumericUpDown();
labelSpeed = new Label();
pictureBoxObject = new PictureBox();
buttonAdd = new Button();
buttonCancel = new Button();
panelObject = new Panel();
labelSimpleObject = new Label();
labelModifiedObject = new Label();
labelBodyColor = new Label();
labelAdditionslColor = new Label();
groupBoxConfig.SuspendLayout();
groupBoxColors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
panelObject.SuspendLayout();
SuspendLayout();
//
// labelSimpleObject
//
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
labelSimpleObject.Location = new Point(537, 292);
labelSimpleObject.Name = "labelSimpleObject";
labelSimpleObject.Size = new Size(224, 93);
labelSimpleObject.TabIndex = 0;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
labelSimpleObject.MouseDown += labelObject_MouseDown;
//
// labelModifiedObject
//
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
labelModifiedObject.Location = new Point(779, 292);
labelModifiedObject.Name = "labelModifiedObject";
labelModifiedObject.Size = new Size(224, 93);
labelModifiedObject.TabIndex = 1;
labelModifiedObject.Text = "Продвинутый";
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
labelModifiedObject.MouseDown += labelObject_MouseDown;
//
// labelBodyColor
//
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
labelBodyColor.Font = new Font("Segoe UI", 9.818182F, FontStyle.Regular, GraphicsUnit.Point);
labelBodyColor.Location = new Point(20, 14);
labelBodyColor.Name = "labelBodyColor";
labelBodyColor.Size = new Size(120, 56);
labelBodyColor.TabIndex = 10;
labelBodyColor.Text = "Цвет";
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
labelBodyColor.DragDrop += labelBodyColor_DragDrop;
labelBodyColor.DragEnter += labelBodyColor_DragEnter;
//
// labelAdditionslColor
//
labelAdditionslColor.BorderStyle = BorderStyle.FixedSingle;
labelAdditionslColor.Location = new Point(146, 14);
labelAdditionslColor.Name = "labelAdditionslColor";
labelAdditionslColor.Size = new Size(120, 56);
labelAdditionslColor.TabIndex = 11;
labelAdditionslColor.Text = "Доп. цвет";
labelAdditionslColor.TextAlign = ContentAlignment.MiddleCenter;
labelAdditionslColor.DragDrop += labelAdditionalColor_DragDrop;
labelAdditionslColor.DragEnter += labelAdditionalColor_DragEnter;
//
// groupBoxConfig
//
groupBoxConfig.Controls.Add(groupBoxColors);
groupBoxConfig.Controls.Add(checkBoxPipe);
groupBoxConfig.Controls.Add(checkBoxBoats);
groupBoxConfig.Controls.Add(checkBoxAnchor);
groupBoxConfig.Controls.Add(numericUpDownWeight);
groupBoxConfig.Controls.Add(labelWeight);
groupBoxConfig.Controls.Add(numericUpDownSpeed);
groupBoxConfig.Controls.Add(labelSpeed);
groupBoxConfig.Controls.Add(labelModifiedObject);
groupBoxConfig.Controls.Add(labelSimpleObject);
groupBoxConfig.Dock = DockStyle.Left;
groupBoxConfig.Location = new Point(0, 0);
groupBoxConfig.Name = "groupBoxConfig";
groupBoxConfig.Size = new Size(1079, 406);
groupBoxConfig.TabIndex = 0;
groupBoxConfig.TabStop = false;
groupBoxConfig.Text = "Параметры";
//
// groupBoxColors
//
groupBoxColors.Controls.Add(panelDarkOliveGreen);
groupBoxColors.Controls.Add(panelAqua);
groupBoxColors.Controls.Add(panelSeaGreen);
groupBoxColors.Controls.Add(panelPaleGreen);
groupBoxColors.Controls.Add(panelCrimson);
groupBoxColors.Controls.Add(panelMediumBlue);
groupBoxColors.Controls.Add(panelDeepPink);
groupBoxColors.Controls.Add(panelBlueViolet);
groupBoxColors.Location = new Point(537, 46);
groupBoxColors.Name = "groupBoxColors";
groupBoxColors.Size = new Size(466, 215);
groupBoxColors.TabIndex = 9;
groupBoxColors.TabStop = false;
groupBoxColors.Text = "Цвета";
//
// panelDarkOliveGreen
//
panelDarkOliveGreen.BackColor = Color.DarkOliveGreen;
panelDarkOliveGreen.BackgroundImageLayout = ImageLayout.None;
panelDarkOliveGreen.Location = new Point(287, 137);
panelDarkOliveGreen.Name = "panelDarkOliveGreen";
panelDarkOliveGreen.Size = new Size(56, 54);
panelDarkOliveGreen.TabIndex = 4;
panelDarkOliveGreen.MouseDown += Panel_MouseDown;
//
// panelAqua
//
panelAqua.BackColor = Color.Aqua;
panelAqua.Location = new Point(125, 137);
panelAqua.Name = "panelAqua";
panelAqua.Size = new Size(56, 54);
panelAqua.TabIndex = 6;
panelAqua.MouseDown += Panel_MouseDown;
//
// panelSeaGreen
//
panelSeaGreen.BackColor = Color.SeaGreen;
panelSeaGreen.Location = new Point(207, 137);
panelSeaGreen.Name = "panelSeaGreen";
panelSeaGreen.Size = new Size(56, 54);
panelSeaGreen.TabIndex = 5;
panelSeaGreen.MouseDown += Panel_MouseDown;
//
// panelPaleGreen
//
panelPaleGreen.BackColor = Color.PaleGreen;
panelPaleGreen.Location = new Point(38, 137);
panelPaleGreen.Name = "panelPaleGreen";
panelPaleGreen.Size = new Size(56, 54);
panelPaleGreen.TabIndex = 3;
panelPaleGreen.MouseDown += Panel_MouseDown;
//
// panelCrimson
//
panelCrimson.BackColor = Color.Crimson;
panelCrimson.Location = new Point(287, 62);
panelCrimson.Name = "panelCrimson";
panelCrimson.Size = new Size(56, 54);
panelCrimson.TabIndex = 1;
panelCrimson.MouseDown += Panel_MouseDown;
//
// panelMediumBlue
//
panelMediumBlue.BackColor = Color.MediumBlue;
panelMediumBlue.Location = new Point(125, 62);
panelMediumBlue.Name = "panelMediumBlue";
panelMediumBlue.Size = new Size(56, 54);
panelMediumBlue.TabIndex = 2;
panelMediumBlue.MouseDown += Panel_MouseDown;
//
// panelDeepPink
//
panelDeepPink.BackColor = Color.DeepPink;
panelDeepPink.Location = new Point(207, 62);
panelDeepPink.Name = "panelDeepPink";
panelDeepPink.Size = new Size(56, 54);
panelDeepPink.TabIndex = 1;
panelDeepPink.MouseDown += Panel_MouseDown;
//
// panelBlueViolet
//
panelBlueViolet.BackColor = Color.BlueViolet;
panelBlueViolet.Location = new Point(38, 62);
panelBlueViolet.Name = "panelBlueViolet";
panelBlueViolet.Size = new Size(56, 54);
panelBlueViolet.TabIndex = 0;
panelBlueViolet.MouseDown += Panel_MouseDown;
//
// checkBoxPipe
//
checkBoxPipe.AutoSize = true;
checkBoxPipe.Location = new Point(35, 340);
checkBoxPipe.Name = "checkBoxPipe";
checkBoxPipe.Size = new Size(373, 45);
checkBoxPipe.TabIndex = 8;
checkBoxPipe.Text = "Признак наличия трубы";
checkBoxPipe.UseVisualStyleBackColor = true;
//
// checkBoxBoats
//
checkBoxBoats.AutoSize = true;
checkBoxBoats.Location = new Point(35, 256);
checkBoxBoats.Name = "checkBoxBoats";
checkBoxBoats.Size = new Size(404, 45);
checkBoxBoats.TabIndex = 7;
checkBoxBoats.Text = "Признак наличия шлюпок";
checkBoxBoats.UseVisualStyleBackColor = true;
//
// checkBoxAnchor
//
checkBoxAnchor.AutoSize = true;
checkBoxAnchor.Location = new Point(35, 183);
checkBoxAnchor.Name = "checkBoxAnchor";
checkBoxAnchor.Size = new Size(371, 45);
checkBoxAnchor.TabIndex = 6;
checkBoxAnchor.Text = "Признак наличия якоря";
checkBoxAnchor.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(195, 112);
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownWeight.Name = "numericUpDownWeight";
numericUpDownWeight.Size = new Size(192, 47);
numericUpDownWeight.TabIndex = 5;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelWeight
//
labelWeight.AutoSize = true;
labelWeight.Location = new Point(35, 118);
labelWeight.Name = "labelWeight";
labelWeight.Size = new Size(72, 41);
labelWeight.TabIndex = 4;
labelWeight.Text = "Вес:";
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(195, 59);
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownSpeed.Name = "numericUpDownSpeed";
numericUpDownSpeed.Size = new Size(192, 47);
numericUpDownSpeed.TabIndex = 3;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelSpeed
//
labelSpeed.AutoSize = true;
labelSpeed.Location = new Point(35, 59);
labelSpeed.Name = "labelSpeed";
labelSpeed.Size = new Size(154, 41);
labelSpeed.TabIndex = 2;
labelSpeed.Text = "Скорость:";
//
// pictureBoxObject
//
pictureBoxObject.Location = new Point(20, 96);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(246, 172);
pictureBoxObject.TabIndex = 1;
pictureBoxObject.TabStop = false;
//
// buttonAdd
//
buttonAdd.Font = new Font("Segoe UI", 8.883117F, FontStyle.Regular, GraphicsUnit.Point);
buttonAdd.Location = new Point(1105, 320);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(120, 53);
buttonAdd.TabIndex = 2;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// buttonCancel
//
buttonCancel.Font = new Font("Segoe UI", 8.883117F, FontStyle.Regular, GraphicsUnit.Point);
buttonCancel.Location = new Point(1256, 320);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(120, 53);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
//
// panelObject
//
panelObject.AllowDrop = true;
panelObject.Controls.Add(labelAdditionslColor);
panelObject.Controls.Add(labelBodyColor);
panelObject.Controls.Add(pictureBoxObject);
panelObject.Location = new Point(1085, 12);
panelObject.Name = "panelObject";
panelObject.Size = new Size(291, 289);
panelObject.TabIndex = 4;
panelObject.DragDrop += PanelObject_DragDrop;
panelObject.DragEnter += PanelObject_DragEnter;
//
// FormLinerConfig
//
AutoScaleDimensions = new SizeF(17F, 41F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1388, 406);
Controls.Add(panelObject);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Controls.Add(groupBoxConfig);
Name = "FormLinerConfig";
Text = "Создание объекта";
groupBoxConfig.ResumeLayout(false);
groupBoxConfig.PerformLayout();
groupBoxColors.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
panelObject.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxConfig;
private NumericUpDown numericUpDownWeight;
private Label labelWeight;
private NumericUpDown numericUpDownSpeed;
private Label labelSpeed;
private CheckBox checkBoxPipe;
private CheckBox checkBoxBoats;
private CheckBox checkBoxAnchor;
private GroupBox groupBoxColors;
private Panel panelDarkOliveGreen;
private Panel panelAqua;
private Panel panelSeaGreen;
private Panel panelPaleGreen;
private Panel panelCrimson;
private Panel panelMediumBlue;
private Panel panelDeepPink;
private Panel panelBlueViolet;
private PictureBox pictureBoxObject;
private Button buttonAdd;
private Button buttonCancel;
private Panel panelObject;
}
}

View File

@ -0,0 +1,154 @@

using ProjectLiner.Drawnings;
using ProjectLiner.Entities;
namespace ProjectLiner;
/// <summary>
/// Форма конфигурации объекта
/// </summary>
public partial class FormLinerConfig : Form
{
/// <summary>
/// Объект - прорисовка самолета
/// </summary>
private DrawningCommonLiner? _commonLiner;
/// <summary>
/// Событие для передачи объекта
/// </summary>
private event Action<DrawningCommonLiner>? linerDelegate;
public FormLinerConfig()
{
InitializeComponent();
panelBlueViolet.MouseDown += Panel_MouseDown;
panelMediumBlue.MouseDown += Panel_MouseDown;
panelAqua.MouseDown += Panel_MouseDown;
panelCrimson.MouseDown += Panel_MouseDown;
panelDarkOliveGreen.MouseDown += Panel_MouseDown;
panelPaleGreen.MouseDown += Panel_MouseDown;
panelSeaGreen.MouseDown += Panel_MouseDown;
panelDeepPink.MouseDown += Panel_MouseDown;
buttonCancel.Click += (sender, e) => Close();
}
/// <summary>
/// Привязка внешнего метода к событию
/// </summary>
/// <param name="commonlinerDelegate"></param>
public void AddEvent(Action<DrawningCommonLiner> commonlinerDelegate)
{
linerDelegate += commonlinerDelegate;
}
/// <summary>
/// Прорисовка объекта
/// </summary>
private void DrawObject()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_commonLiner?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
_commonLiner?.SetPosition(5, 5);
_commonLiner?.DrawTransport(gr);
pictureBoxObject.Image = bmp;
}
/// <summary>
/// Передаем информацию при нажатии на Label
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelObject_MouseDown(object sender, MouseEventArgs e)
{
(sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy);
}
/// <summary>
/// Проверка получаемой информации (ее типа на соответствие требуемому)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PanelObject_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.Data?.GetDataPresent(DataFormats.Text) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
}
/// <summary>
/// Действия при приеме перетаскиваемой информации
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PanelObject_DragDrop(object sender, DragEventArgs e)
{
switch (e.Data?.GetData(DataFormats.Text)?.ToString())
{
case "labelSimpleObject":
_commonLiner = new DrawningCommonLiner((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
break;
case "labelModifiedObject":
_commonLiner = new DrawningLiner((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White,
Color.Black, checkBoxAnchor.Checked, checkBoxBoats.Checked, checkBoxPipe.Checked);
break;
}
DrawObject();
}
/// <summary>
/// Передаем информацию при нажатии на Panel
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Panel_MouseDown(object? sender, MouseEventArgs e)
{
(sender as Control)?.DoDragDrop((sender as Control)?.BackColor!, DragDropEffects.Move | DragDropEffects.Copy);
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
if (_commonLiner != null)
{
linerDelegate?.Invoke(_commonLiner);
Close();
}
}
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
{
if (_commonLiner == null)
return;
_commonLiner.EntityCommonLiner?.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
DrawObject();
}
private void labelBodyColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}
private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
{
if (_commonLiner?.EntityCommonLiner is EntityLiner _liner)
_liner?.SetAdditionalColor((Color)e.Data.GetData(typeof(Color)));
DrawObject();
}
private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}
}

View File

@ -0,0 +1,132 @@
<?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>
<metadata name="labelSimpleObject.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="labelModifiedObject.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="labelBodyColor.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="labelAdditionslColor.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>