ISEbd-12_Skvortsov-A.K._AccordionBus_Simple_Lab5 #6

Closed
Aleksey-Skvortsov wants to merge 1 commits from lab5 into lab4
10 changed files with 801 additions and 135 deletions
Showing only changes of commit 3cfd932bc1 - Show all commits

View File

@ -0,0 +1,11 @@
using AccordionBus.Drawnings;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccordionBus
{
public delegate void BusDelegate(DrawningBus bus);
}

View File

@ -19,13 +19,14 @@ namespace AccordionBus.Drawnings
/// <param name="weight"></param>
/// <param name="bodyColor"></param>
/// <param name="additionalColor"></param>
/// <param name="onePart"></param>
/// <param name="hatch"></param>
/// <param name="fiveDoors"></param>
public DrawningAccordionBus(int speed, double weight, Color bodyColor, Color
additionalColor, bool onePart, bool fiveDoors): base(130, 20)
additionalColor, bool hatch, bool fiveDoors): base(130, 20)
{
EntityBus = new EntityAccordionBus(speed, weight, bodyColor, additionalColor, onePart, fiveDoors);
EntityBus = new EntityAccordionBus(speed, weight, bodyColor, additionalColor, hatch, fiveDoors);
}
/// <summary>
/// Отрисовка транспорта
/// </summary>
@ -40,60 +41,66 @@ namespace AccordionBus.Drawnings
base.DrawTransport(g);
if (!accordionBus.OnePart)
Pen pen = new(Color.Black);
Brush brWhite = new SolidBrush(Color.White);
Brush br = new SolidBrush(accordionBus.BodyColor);
Brush brBlue = new SolidBrush(Color.LightBlue);
Brush additionalBrush = new SolidBrush(accordionBus.AdditionalColor);
//корпус
g.FillRectangle(br, _startPosX.Value + 70, _startPosY.Value, 60, 15);
g.DrawRectangle(pen, _startPosX.Value + 70, _startPosY.Value, 60, 15);
//колёса
g.FillEllipse(brWhite, _startPosX.Value + 75, _startPosY.Value + 10, 10, 10);
g.FillEllipse(brWhite, _startPosX.Value + 110, _startPosY.Value + 10, 10, 10);
g.DrawEllipse(pen, _startPosX.Value + 110, _startPosY.Value + 10, 10, 10);
g.DrawEllipse(pen, _startPosX.Value + 75, _startPosY.Value + 10, 10, 10);
//стёкла
g.FillRectangle(brBlue, _startPosX.Value + 72, _startPosY.Value + 3, 5, 5);
g.DrawRectangle(pen, _startPosX.Value + 72, _startPosY.Value + 3, 5, 5);
g.FillRectangle(brBlue, _startPosX.Value + 82, _startPosY.Value + 3, 5, 5);
g.DrawRectangle(pen, _startPosX.Value + 82, _startPosY.Value + 3, 5, 5);
g.FillRectangle(brBlue, _startPosX.Value + 92, _startPosY.Value + 3, 5, 5);
g.DrawRectangle(pen, _startPosX.Value + 92, _startPosY.Value + 3, 5, 5);
g.FillRectangle(brBlue, _startPosX.Value + 102, _startPosY.Value + 3, 5, 5);
g.DrawRectangle(pen, _startPosX.Value + 102, _startPosY.Value + 3, 5, 5);
g.FillRectangle(brBlue, _startPosX.Value + 112, _startPosY.Value + 3, 5, 5);
g.DrawRectangle(pen, _startPosX.Value + 112, _startPosY.Value + 3, 5, 5);
//гормошка
g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value, _startPosX.Value + 62, _startPosY.Value + 3);
g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 3, _startPosX.Value + 65, _startPosY.Value);
g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value, _startPosX.Value + 67, _startPosY.Value + 3);
g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 3, _startPosX.Value + 70, _startPosY.Value);
g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value + 15, _startPosX.Value + 62, _startPosY.Value + 12);
g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 12, _startPosX.Value + 65, _startPosY.Value + 15);
g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value + 15, _startPosX.Value + 67, _startPosY.Value + 12);
g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 12, _startPosX.Value + 70, _startPosY.Value + 15);
g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 3, _startPosX.Value + 62, _startPosY.Value + 12);
g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 3, _startPosX.Value + 67, _startPosY.Value + 12);
g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value, _startPosX.Value + 65, _startPosY.Value + 15);
//двери
g.FillRectangle(additionalBrush, _startPosX.Value + 123, _startPosY.Value + 5, 5, 10);
g.DrawRectangle(pen, _startPosX.Value + 123, _startPosY.Value + 5, 5, 10);
if (accordionBus.FiveDoors)
{
Pen pen = new(Color.Black);
Brush brWhite = new SolidBrush(Color.White);
Brush br = new SolidBrush(accordionBus.BodyColor);
Brush brBlue = new SolidBrush(Color.LightBlue);
Brush additionalBrush = new SolidBrush(accordionBus.AdditionalColor);
//корпус
g.FillRectangle(br, _startPosX.Value + 70, _startPosY.Value, 60, 15);
g.DrawRectangle(pen, _startPosX.Value + 70, _startPosY.Value, 60, 15);
g.FillRectangle(additionalBrush, _startPosX.Value + 87, _startPosY.Value + 9, 21, 5);
g.DrawRectangle(pen, _startPosX.Value + 87, _startPosY.Value + 9, 21, 5);
g.FillRectangle(additionalBrush, _startPosX.Value + 53, _startPosY.Value + 5, 5, 10);
g.DrawRectangle(pen, _startPosX.Value + 53, _startPosY.Value + 5, 5, 10);
g.FillRectangle(additionalBrush, _startPosX.Value + 27, _startPosY.Value + 9, 11, 5);
g.DrawRectangle(pen, _startPosX.Value + 27, _startPosY.Value + 9, 11, 5);
}
//колёса
g.FillEllipse(brWhite, _startPosX.Value + 75, _startPosY.Value + 10, 10, 10);
g.FillEllipse(brWhite, _startPosX.Value + 110, _startPosY.Value + 10, 10, 10);
g.DrawEllipse(pen, _startPosX.Value + 110, _startPosY.Value + 10, 10, 10);
g.DrawEllipse(pen, _startPosX.Value + 75, _startPosY.Value + 10, 10, 10);
//стёкла
g.FillRectangle(brBlue, _startPosX.Value + 72, _startPosY.Value + 3, 5, 5);
g.DrawRectangle(pen, _startPosX.Value + 72, _startPosY.Value + 3, 5, 5);
g.FillRectangle(brBlue, _startPosX.Value + 82, _startPosY.Value + 3, 5, 5);
g.DrawRectangle(pen, _startPosX.Value + 82, _startPosY.Value + 3, 5, 5);
g.FillRectangle(brBlue, _startPosX.Value + 92, _startPosY.Value + 3, 5, 5);
g.DrawRectangle(pen, _startPosX.Value + 92, _startPosY.Value + 3, 5, 5);
g.FillRectangle(brBlue, _startPosX.Value + 102, _startPosY.Value + 3, 5, 5);
g.DrawRectangle(pen, _startPosX.Value + 102, _startPosY.Value + 3, 5, 5);
g.FillRectangle(brBlue, _startPosX.Value + 112, _startPosY.Value + 3, 5, 5);
g.DrawRectangle(pen, _startPosX.Value + 112, _startPosY.Value + 3, 5, 5);
//гормошка
g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value, _startPosX.Value + 62, _startPosY.Value + 3);
g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 3, _startPosX.Value + 65, _startPosY.Value);
g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value, _startPosX.Value + 67, _startPosY.Value + 3);
g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 3, _startPosX.Value + 70, _startPosY.Value);
g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value + 15, _startPosX.Value + 62, _startPosY.Value + 12);
g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 12, _startPosX.Value + 65, _startPosY.Value + 15);
g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value + 15, _startPosX.Value + 67, _startPosY.Value + 12);
g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 12, _startPosX.Value + 70, _startPosY.Value + 15);
g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 3, _startPosX.Value + 62, _startPosY.Value + 12);
g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 3, _startPosX.Value + 67, _startPosY.Value + 12);
g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value, _startPosX.Value + 65, _startPosY.Value + 15);
//двери
g.FillRectangle(additionalBrush, _startPosX.Value + 123, _startPosY.Value + 5, 5, 10);
g.DrawRectangle(pen, _startPosX.Value + 123, _startPosY.Value + 5, 5, 10);
if (accordionBus.FiveDoors)
{
g.FillRectangle(additionalBrush, _startPosX.Value + 87, _startPosY.Value + 9, 21, 5);
g.DrawRectangle(pen, _startPosX.Value + 87, _startPosY.Value + 9, 21, 5);
g.FillRectangle(additionalBrush, _startPosX.Value + 53, _startPosY.Value + 5, 5, 10);
g.DrawRectangle(pen, _startPosX.Value + 53, _startPosY.Value + 5, 5, 10);
g.FillRectangle(additionalBrush, _startPosX.Value + 27, _startPosY.Value + 9, 11, 5);
g.DrawRectangle(pen, _startPosX.Value + 27, _startPosY.Value + 9, 11, 5);
}
//люки
if (accordionBus.Hatch)
{
g.FillRectangle(additionalBrush, _startPosX.Value + 10, _startPosY.Value - 3, 10, 3);
g.FillRectangle(additionalBrush, _startPosX.Value + 90, _startPosY.Value - 3, 10, 3);
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value - 3, 10, 3);
g.DrawRectangle(pen, _startPosX.Value + 90, _startPosY.Value - 3, 10, 3);
}
}
}

View File

@ -68,6 +68,7 @@ namespace AccordionBus.Drawnings
_startPosX = null;
_startPosY = null;
}
/// <summary>
/// Конструктор границ объекта
/// </summary>

View File

@ -18,7 +18,7 @@ namespace AccordionBus.Entities
/// <summary>
/// Одна часть
/// </summary>
public bool OnePart { get; set; }
public bool Hatch { get; set; }
/// <summary>
/// 5 дверей
/// </summary>
@ -30,14 +30,20 @@ namespace AccordionBus.Entities
/// <param name="weight">вес</param>
/// <param name="bodyColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="onePart">1 часть</param>
/// <param name="hatch">1 часть</param>
/// <param name="fiveDoors">5 дверей</param>
public EntityAccordionBus(int speed, double weight, Color bodyColor,
Color additionalColor, bool onePart, bool fiveDoors) : base(speed, weight, bodyColor)
Color additionalColor, bool hatch, bool fiveDoors) : base(speed, weight, bodyColor)
{
AdditionalColor = additionalColor;
OnePart = onePart;
Hatch = hatch;
FiveDoors = fiveDoors;
}
/// <summary>
/// Новый дополнительный цвет
/// </summary>
/// <param name="color"></param>
public void SetAdditionalColor(Color color) { AdditionalColor = color; }
}
}

View File

@ -14,15 +14,15 @@ namespace AccordionBus.Entities
/// <summary>
/// Скорость
/// </summary>
public int Speed { get; set; }
public int Speed { get; private set; }
/// <summary>
/// Вес
/// </summary>
public double Weight { get; set; }
public double Weight { get; private set; }
/// <summary>
/// Основной цвет
/// </summary>
public Color BodyColor { get; set; }
public Color BodyColor { get; private set; }
/// <summary>
/// Шаг
/// </summary>
@ -39,5 +39,11 @@ namespace AccordionBus.Entities
Weight = weight;
BodyColor = bodyColor;
}
/// <summary>
/// Новый основной цвет
/// </summary>
/// <param name="color"></param>
public void SetBodyColor(Color color) { BodyColor = color; }
}
}

View File

@ -29,6 +29,8 @@
private void InitializeComponent()
{
groupBoxTools = new GroupBox();
buttonCreateCompany = new Button();
comboBoxSelectedCompany = new ComboBox();
panelStorage = new Panel();
buttonCollectionDel = new Button();
listBoxCollection = new ListBox();
@ -38,10 +40,7 @@
textBoxCollectionName = new TextBox();
labelCollectionName = new Label();
panelTools = new Panel();
buttonCreateCompany = new Button();
comboBoxSelectedCompany = new ComboBox();
buttonAddBus = new Button();
buttonAddAccordionBus = new Button();
buttonRefresh = new Button();
maskedTextBox = new MaskedTextBox();
buttonGoToCheck = new Button();
@ -67,6 +66,28 @@
groupBoxTools.TabStop = false;
groupBoxTools.Text = "Инструменты";
//
// buttonCreateCompany
//
buttonCreateCompany.Location = new Point(12, 361);
buttonCreateCompany.Name = "buttonCreateCompany";
buttonCreateCompany.Size = new Size(207, 29);
buttonCreateCompany.TabIndex = 7;
buttonCreateCompany.Text = "Создать компанию";
buttonCreateCompany.UseVisualStyleBackColor = true;
buttonCreateCompany.Click += buttonCreateCompany_Click;
//
// comboBoxSelectedCompany
//
comboBoxSelectedCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
comboBoxSelectedCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectedCompany.FormattingEnabled = true;
comboBoxSelectedCompany.Items.AddRange(new object[] { "Станция" });
comboBoxSelectedCompany.Location = new Point(12, 327);
comboBoxSelectedCompany.Name = "comboBoxSelectedCompany";
comboBoxSelectedCompany.Size = new Size(207, 28);
comboBoxSelectedCompany.TabIndex = 0;
comboBoxSelectedCompany.SelectedIndexChanged += comboBoxSelectedCompany_SelectedIndexChanged;
//
// panelStorage
//
panelStorage.Controls.Add(buttonCollectionDel);
@ -151,7 +172,6 @@
// panelTools
//
panelTools.Controls.Add(buttonAddBus);
panelTools.Controls.Add(buttonAddAccordionBus);
panelTools.Controls.Add(buttonRefresh);
panelTools.Controls.Add(maskedTextBox);
panelTools.Controls.Add(buttonGoToCheck);
@ -163,28 +183,6 @@
panelTools.Size = new Size(228, 354);
panelTools.TabIndex = 7;
//
// buttonCreateCompany
//
buttonCreateCompany.Location = new Point(12, 361);
buttonCreateCompany.Name = "buttonCreateCompany";
buttonCreateCompany.Size = new Size(207, 29);
buttonCreateCompany.TabIndex = 7;
buttonCreateCompany.Text = "Создать компанию";
buttonCreateCompany.UseVisualStyleBackColor = true;
buttonCreateCompany.Click += buttonCreateCompany_Click;
//
// comboBoxSelectedCompany
//
comboBoxSelectedCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
comboBoxSelectedCompany.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSelectedCompany.FormattingEnabled = true;
comboBoxSelectedCompany.Items.AddRange(new object[] { "Станция" });
comboBoxSelectedCompany.Location = new Point(12, 327);
comboBoxSelectedCompany.Name = "comboBoxSelectedCompany";
comboBoxSelectedCompany.Size = new Size(207, 28);
comboBoxSelectedCompany.TabIndex = 0;
comboBoxSelectedCompany.SelectedIndexChanged += comboBoxSelectedCompany_SelectedIndexChanged;
//
// buttonAddBus
//
buttonAddBus.Location = new Point(9, 13);
@ -195,16 +193,6 @@
buttonAddBus.UseVisualStyleBackColor = true;
buttonAddBus.Click += buttonAddBus_Click;
//
// buttonAddAccordionBus
//
buttonAddAccordionBus.Location = new Point(9, 73);
buttonAddAccordionBus.Name = "buttonAddAccordionBus";
buttonAddAccordionBus.Size = new Size(207, 54);
buttonAddAccordionBus.TabIndex = 2;
buttonAddAccordionBus.Text = "Добавить автобус с гормошкой";
buttonAddAccordionBus.UseVisualStyleBackColor = true;
buttonAddAccordionBus.Click += buttonAddAccordionBus_Click;
//
// buttonRefresh
//
buttonRefresh.Location = new Point(9, 286);
@ -277,7 +265,6 @@
private GroupBox groupBoxTools;
private ComboBox comboBoxSelectedCompany;
private Button buttonAddBus;
private Button buttonAddAccordionBus;
private PictureBox pictureBox;
private Button buttonRemoveBus;
private MaskedTextBox maskedTextBox;

View File

@ -30,29 +30,20 @@ namespace AccordionBus
panelTools.Enabled = false;
}
private void CreateObject(string type)
private void buttonAddBus_Click(object sender, EventArgs e)
{
if (_company == null) return;
FormBusConfig form = new FormBusConfig();
form.Show();
form.AddEvent(SetCar);
}
Random random = new();
DrawningBus _drawningBus;
switch (type)
{
case nameof(DrawningBus):
_drawningBus = new DrawningBus(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
_drawningBus.SetPictureSize(pictureBox.Width, pictureBox.Height);
break;
case nameof(DrawningAccordionBus):
_drawningBus = new DrawningAccordionBus(random.Next(100, 300), random.Next(1000, 3000),
GetColor(random), GetColor(random),
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
_drawningBus.SetPictureSize(pictureBox.Width, pictureBox.Height);
break;
default:
return;
}
private void SetCar(DrawningBus bus)
{
if (_company == null || bus == null) return;
if (_company + _drawningBus != -1)
bus.SetPictureSize(pictureBox.Width, pictureBox.Height);
if (_company + bus != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
@ -63,22 +54,6 @@ namespace AccordionBus
}
}
private static Color GetColor(Random rnd)
{
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
ColorDialog dialog = new();
if (dialog.ShowDialog() == DialogResult.OK)
{
color = dialog.Color;
}
return color;
}
private void buttonAddBus_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningBus));
private void buttonAddAccordionBus_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAccordionBus));
private void buttonRemoveBus_Click(object sender, EventArgs e)
{
if (_company == null || string.IsNullOrEmpty(maskedTextBox.Text)) return;
@ -117,6 +92,7 @@ namespace AccordionBus
SetBus = bus
};
form.ShowDialog();
bus.SetPictureSize(pictureBox.Width, pictureBox.Height);
}
private void buttonRefresh_Click(object sender, EventArgs e)

View File

@ -0,0 +1,368 @@
namespace AccordionBus
{
partial class FormBusConfig
{
/// <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()
{
groupBoxConfig = new GroupBox();
groupBoxColor = new GroupBox();
panelPurple = new Panel();
panelBlack = new Panel();
panelGray = new Panel();
panelWhite = new Panel();
panelYellow = new Panel();
panelBlue = new Panel();
panelGreen = new Panel();
panelRed = new Panel();
checkBoxFiveDoors = new CheckBox();
checkBoxHatch = new CheckBox();
numericUpDownWeight = new NumericUpDown();
labelWeight = new Label();
numericUpDownSpeed = new NumericUpDown();
labelSpeed = new Label();
labelModifiedObject = new Label();
labelSimpleObject = new Label();
pictureBoxObject = new PictureBox();
buttonAdd = new Button();
buttonCancel = new Button();
panelObject = new Panel();
labelAdditionalColor = new Label();
labelBodyColor = new Label();
groupBoxConfig.SuspendLayout();
groupBoxColor.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
panelObject.SuspendLayout();
SuspendLayout();
//
// groupBoxConfig
//
groupBoxConfig.Controls.Add(groupBoxColor);
groupBoxConfig.Controls.Add(checkBoxFiveDoors);
groupBoxConfig.Controls.Add(checkBoxHatch);
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(493, 229);
groupBoxConfig.TabIndex = 0;
groupBoxConfig.TabStop = false;
groupBoxConfig.Text = "Параметры";
//
// groupBoxColor
//
groupBoxColor.Controls.Add(panelPurple);
groupBoxColor.Controls.Add(panelBlack);
groupBoxColor.Controls.Add(panelGray);
groupBoxColor.Controls.Add(panelWhite);
groupBoxColor.Controls.Add(panelYellow);
groupBoxColor.Controls.Add(panelBlue);
groupBoxColor.Controls.Add(panelGreen);
groupBoxColor.Controls.Add(panelRed);
groupBoxColor.Location = new Point(221, 17);
groupBoxColor.Name = "groupBoxColor";
groupBoxColor.Size = new Size(262, 147);
groupBoxColor.TabIndex = 8;
groupBoxColor.TabStop = false;
groupBoxColor.Text = "Цвета";
//
// panelPurple
//
panelPurple.AllowDrop = true;
panelPurple.BackColor = Color.Purple;
panelPurple.Location = new Point(205, 90);
panelPurple.Name = "panelPurple";
panelPurple.Size = new Size(35, 35);
panelPurple.TabIndex = 6;
//
// panelBlack
//
panelBlack.AllowDrop = true;
panelBlack.BackColor = Color.Black;
panelBlack.Location = new Point(143, 90);
panelBlack.Name = "panelBlack";
panelBlack.Size = new Size(35, 35);
panelBlack.TabIndex = 1;
//
// panelGray
//
panelGray.AllowDrop = true;
panelGray.BackColor = Color.Gray;
panelGray.Location = new Point(77, 90);
panelGray.Name = "panelGray";
panelGray.Size = new Size(35, 35);
panelGray.TabIndex = 5;
//
// panelWhite
//
panelWhite.AllowDrop = true;
panelWhite.BackColor = Color.White;
panelWhite.Location = new Point(15, 90);
panelWhite.Name = "panelWhite";
panelWhite.Size = new Size(35, 35);
panelWhite.TabIndex = 4;
//
// panelYellow
//
panelYellow.AllowDrop = true;
panelYellow.BackColor = Color.Yellow;
panelYellow.Location = new Point(205, 26);
panelYellow.Name = "panelYellow";
panelYellow.Size = new Size(35, 35);
panelYellow.TabIndex = 3;
//
// panelBlue
//
panelBlue.AllowDrop = true;
panelBlue.BackColor = Color.Blue;
panelBlue.Location = new Point(143, 26);
panelBlue.Name = "panelBlue";
panelBlue.Size = new Size(35, 35);
panelBlue.TabIndex = 2;
//
// panelGreen
//
panelGreen.AllowDrop = true;
panelGreen.BackColor = Color.Green;
panelGreen.Location = new Point(77, 26);
panelGreen.Name = "panelGreen";
panelGreen.Size = new Size(35, 35);
panelGreen.TabIndex = 1;
//
// panelRed
//
panelRed.AllowDrop = true;
panelRed.BackColor = Color.Red;
panelRed.Location = new Point(15, 26);
panelRed.Name = "panelRed";
panelRed.Size = new Size(35, 35);
panelRed.TabIndex = 0;
//
// checkBoxFiveDoors
//
checkBoxFiveDoors.AutoSize = true;
checkBoxFiveDoors.Location = new Point(24, 160);
checkBoxFiveDoors.Name = "checkBoxFiveDoors";
checkBoxFiveDoors.Size = new Size(93, 24);
checkBoxFiveDoors.TabIndex = 7;
checkBoxFiveDoors.Text = "5 дверей";
checkBoxFiveDoors.UseVisualStyleBackColor = true;
//
// checkBoxOnePart
//
checkBoxHatch.AutoSize = true;
checkBoxHatch.Location = new Point(24, 118);
checkBoxHatch.Name = "checkBoxOnePart";
checkBoxHatch.Size = new Size(69, 24);
checkBoxHatch.TabIndex = 6;
checkBoxHatch.Text = "Люки";
checkBoxHatch.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(94, 78);
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(106, 27);
numericUpDownWeight.TabIndex = 5;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelWeight
//
labelWeight.AutoSize = true;
labelWeight.Location = new Point(12, 78);
labelWeight.Name = "labelWeight";
labelWeight.Size = new Size(36, 20);
labelWeight.TabIndex = 4;
labelWeight.Text = "Вес:";
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(94, 37);
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(106, 27);
numericUpDownSpeed.TabIndex = 3;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelSpeed
//
labelSpeed.AutoSize = true;
labelSpeed.Location = new Point(12, 37);
labelSpeed.Name = "labelSpeed";
labelSpeed.Size = new Size(76, 20);
labelSpeed.TabIndex = 2;
labelSpeed.Text = "Скорость:";
//
// labelModifiedObject
//
labelModifiedObject.AllowDrop = true;
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
labelModifiedObject.Location = new Point(361, 176);
labelModifiedObject.Name = "labelModifiedObject";
labelModifiedObject.Size = new Size(122, 39);
labelModifiedObject.TabIndex = 1;
labelModifiedObject.Text = "Продвинутый";
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
labelModifiedObject.MouseDown += labelObject_MouseDown;
//
// labelSimpleObject
//
labelSimpleObject.AllowDrop = true;
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
labelSimpleObject.Location = new Point(221, 176);
labelSimpleObject.Name = "labelSimpleObject";
labelSimpleObject.Size = new Size(122, 39);
labelSimpleObject.TabIndex = 0;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
labelSimpleObject.MouseDown += labelObject_MouseDown;
//
// pictureBoxObject
//
pictureBoxObject.Location = new Point(16, 64);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(200, 100);
pictureBoxObject.TabIndex = 1;
pictureBoxObject.TabStop = false;
//
// buttonAdd
//
buttonAdd.Location = new Point(515, 186);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 29);
buttonAdd.TabIndex = 2;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(621, 186);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
//
// panelObject
//
panelObject.AllowDrop = true;
panelObject.Controls.Add(labelAdditionalColor);
panelObject.Controls.Add(labelBodyColor);
panelObject.Controls.Add(pictureBoxObject);
panelObject.Location = new Point(499, 0);
panelObject.Name = "panelObject";
panelObject.Size = new Size(226, 178);
panelObject.TabIndex = 4;
panelObject.DragDrop += panelObject_DragDrop;
panelObject.DragEnter += panelObject_DragEnter;
//
// labelAdditionalColor
//
labelAdditionalColor.AllowDrop = true;
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
labelAdditionalColor.Location = new Point(128, 26);
labelAdditionalColor.Name = "labelAdditionalColor";
labelAdditionalColor.Size = new Size(88, 25);
labelAdditionalColor.TabIndex = 3;
labelAdditionalColor.Text = "Доп. цвет";
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
labelAdditionalColor.DragDrop += labelAdditionalColor_DragDrop;
labelAdditionalColor.DragEnter += labelColor_DragEnter;
//
// labelBodyColor
//
labelBodyColor.AllowDrop = true;
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
labelBodyColor.Location = new Point(16, 26);
labelBodyColor.Name = "labelBodyColor";
labelBodyColor.Size = new Size(94, 25);
labelBodyColor.TabIndex = 2;
labelBodyColor.Text = "Цвет";
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
labelBodyColor.DragDrop += labelBodyColor_DragDrop;
labelBodyColor.DragEnter += labelColor_DragEnter;
//
// FormBusConfig
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(737, 229);
Controls.Add(panelObject);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Controls.Add(groupBoxConfig);
Name = "FormBusConfig";
StartPosition = FormStartPosition.CenterScreen;
Text = "Создание объекта";
groupBoxConfig.ResumeLayout(false);
groupBoxConfig.PerformLayout();
groupBoxColor.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 Label labelSimpleObject;
private Label labelModifiedObject;
private Label labelSpeed;
private Label labelWeight;
private NumericUpDown numericUpDownSpeed;
private NumericUpDown numericUpDownWeight;
private CheckBox checkBoxHatch;
private CheckBox checkBoxFiveDoors;
private GroupBox groupBoxColor;
private Panel panelRed;
private Panel panelPurple;
private Panel panelBlack;
private Panel panelGray;
private Panel panelWhite;
private Panel panelYellow;
private Panel panelBlue;
private Panel panelGreen;
private PictureBox pictureBoxObject;
private Button buttonAdd;
private Button buttonCancel;
private Panel panelObject;
private Label labelBodyColor;
private Label labelAdditionalColor;
}
}

View File

@ -0,0 +1,184 @@
using AccordionBus.Drawnings;
using AccordionBus.Entities;
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 AccordionBus
{
public partial class FormBusConfig : Form
{
private DrawningBus _bus;
private event Action<DrawningBus> _busDelegate;
public FormBusConfig()
{
InitializeComponent();
panelRed.MouseDown += Panel_MouseDown;
panelBlue.MouseDown += Panel_MouseDown;
panelGreen.MouseDown += Panel_MouseDown;
panelYellow.MouseDown += Panel_MouseDown;
panelGray.MouseDown += Panel_MouseDown;
panelBlack.MouseDown += Panel_MouseDown;
panelWhite.MouseDown += Panel_MouseDown;
panelPurple.MouseDown += Panel_MouseDown;
buttonCancel.Click += (sender, e) => Close();
}
public void AddEvent(Action<DrawningBus> busDelegate)
{
_busDelegate += busDelegate;
}
private void Panel_MouseDown(object? sender, MouseEventArgs e)
{
Panel panel = sender as Panel;
panel.DoDragDrop(panel.Name, DragDropEffects.Copy);
}
private void DrawObject()
{
if (_bus == null) return;
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_bus.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
_bus.SetPosition(5, 5);
_bus.DrawTransport(gr);
pictureBoxObject.Image = bmp;
}
private void labelObject_MouseDown(object sender, MouseEventArgs e)
{
Label label = sender as Label;
label.DoDragDrop(label.Name, DragDropEffects.Copy);
}
private void panelObject_DragEnter(object sender, DragEventArgs e)
{
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void panelObject_DragDrop(object sender, DragEventArgs e)
{
switch (e.Data?.GetData(DataFormats.Text)?.ToString())
{
case "labelSimpleObject":
_bus = new DrawningBus((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
break;
case "labelModifiedObject":
_bus = new DrawningAccordionBus((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White,
Color.Black, checkBoxHatch.Checked, checkBoxFiveDoors.Checked);
break;
}
DrawObject();
}
private void labelColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
{
switch (e.Data?.GetData(DataFormats.Text)?.ToString())
{
case "panelRed":
_bus.EntityBus.SetBodyColor(Color.Red);
break;
case "panelBlue":
_bus.EntityBus.SetBodyColor(Color.Blue);
break;
case "panelGreen":
_bus.EntityBus.SetBodyColor(Color.Green);
break;
case "panelYellow":
_bus.EntityBus.SetBodyColor(Color.Yellow);
break;
case "panelWhite":
_bus.EntityBus.SetBodyColor(Color.White);
break;
case "panelGray":
_bus.EntityBus.SetBodyColor(Color.Gray);
break;
case "panelBlack":
_bus.EntityBus.SetBodyColor(Color.Black);
break;
case "panelPurple":
_bus.EntityBus.SetBodyColor(Color.Purple);
break;
}
DrawObject();
}
private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
{
if (_bus.EntityBus is EntityAccordionBus entityAccordionBus)
{
switch (e.Data?.GetData(DataFormats.Text)?.ToString())
{
case "panelRed":
entityAccordionBus.SetAdditionalColor(Color.Red);
break;
case "panelBlue":
entityAccordionBus.SetAdditionalColor(Color.Blue);
break;
case "panelGreen":
entityAccordionBus.SetAdditionalColor(Color.Green);
break;
case "panelYellow":
entityAccordionBus.SetAdditionalColor(Color.Yellow);
break;
case "panelWhite":
entityAccordionBus.SetAdditionalColor(Color.White);
break;
case "panelGray":
entityAccordionBus.SetAdditionalColor(Color.Gray);
break;
case "panelBlack":
entityAccordionBus.SetAdditionalColor(Color.Black);
break;
case "panelPurple":
entityAccordionBus.SetAdditionalColor(Color.Purple);
break;
}
DrawObject() ;
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
if (_bus != null)
{
_busDelegate.Invoke(_bus);
Close();
}
}
}
}

View 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>