PIBD-13_Marinenkova_V.A._LabWork05_Base #5

Closed
marva wants to merge 3 commits from LabWork05 into LabWork04
9 changed files with 727 additions and 44 deletions

View File

@ -0,0 +1,10 @@
using ProjectAccordionBus.Drawnings;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAccordionBus;
public delegate void BusDelegate(DrawningBus bus);
Review

Не используется

Не используется

View File

@ -28,35 +28,38 @@ public class DrawningAccordionBus : DrawningBus
Brush brushBlue = new SolidBrush(Color.Blue);
// отсек
g.FillRectangle(additionalBrush, _startPosX.Value + 60, _startPosY.Value, 50, 30);
g.FillRectangle(additionalBrush, _startPosX.Value + 50, _startPosY.Value + 5, 10, 20);
g.DrawRectangle(pen, _startPosX.Value + 60, _startPosY.Value, 50, 30);
g.DrawRectangle(pen, _startPosX.Value + 50, _startPosY.Value + 5, 10, 20);
// колеса
g.FillEllipse(additionalBrush, _startPosX.Value + 65, _startPosY.Value + 25, 10, 10);
g.FillEllipse(additionalBrush, _startPosX.Value + 95, _startPosY.Value + 25, 10, 10);
g.DrawEllipse(pen, _startPosX.Value + 65, _startPosY.Value + 25, 10, 10);
g.DrawEllipse(pen, _startPosX.Value + 95, _startPosY.Value + 25, 10, 10);
if (accordionBus.Entrance)
if (accordionBus.Compartment)
{
g.FillRectangle(additionalBrush, _startPosX.Value + 78, _startPosY.Value + 10, 10, 20);
g.FillRectangle(additionalBrush, _startPosX.Value + 60, _startPosY.Value, 50, 30);
g.FillRectangle(additionalBrush, _startPosX.Value + 50, _startPosY.Value + 5, 10, 20);
g.DrawRectangle(pen, _startPosX.Value + 78, _startPosY.Value + 10, 10, 20);
}
g.DrawRectangle(pen, _startPosX.Value + 60, _startPosY.Value, 50, 30);
g.DrawRectangle(pen, _startPosX.Value + 50, _startPosY.Value + 5, 10, 20);
if (accordionBus.Windows)
{
g.FillEllipse(brushBlue, _startPosX.Value + 65, _startPosY.Value + 5, 5, 10);
g.FillEllipse(brushBlue, _startPosX.Value + 100, _startPosY.Value + 5, 5, 10);
g.FillEllipse(brushBlue, _startPosX.Value + 90, _startPosY.Value + 5, 5, 10);
// колеса
g.FillEllipse(additionalBrush, _startPosX.Value + 65, _startPosY.Value + 25, 10, 10);
g.FillEllipse(additionalBrush, _startPosX.Value + 95, _startPosY.Value + 25, 10, 10);
g.DrawEllipse(pen, _startPosX.Value + 65, _startPosY.Value + 5, 5, 10);
g.DrawEllipse(pen, _startPosX.Value + 100, _startPosY.Value + 5, 5, 10);
g.DrawEllipse(pen, _startPosX.Value + 90, _startPosY.Value + 5, 5, 10);
g.DrawEllipse(pen, _startPosX.Value + 65, _startPosY.Value + 25, 10, 10);
g.DrawEllipse(pen, _startPosX.Value + 95, _startPosY.Value + 25, 10, 10);
if (accordionBus.Entrance)
{
g.FillRectangle(additionalBrush, _startPosX.Value + 78, _startPosY.Value + 10, 10, 20);
g.DrawRectangle(pen, _startPosX.Value + 78, _startPosY.Value + 10, 10, 20);
}
if (accordionBus.Windows)
{
g.FillEllipse(brushBlue, _startPosX.Value + 65, _startPosY.Value + 5, 5, 10);
g.FillEllipse(brushBlue, _startPosX.Value + 100, _startPosY.Value + 5, 5, 10);
g.FillEllipse(brushBlue, _startPosX.Value + 90, _startPosY.Value + 5, 5, 10);
g.DrawEllipse(pen, _startPosX.Value + 65, _startPosY.Value + 5, 5, 10);
g.DrawEllipse(pen, _startPosX.Value + 100, _startPosY.Value + 5, 5, 10);
g.DrawEllipse(pen, _startPosX.Value + 90, _startPosY.Value + 5, 5, 10);
}
}
}
}

View File

@ -10,6 +10,8 @@ public class EntityAccordionBus : EntityBus
{
public Color AdditionalColor { get; private set; }
public void SetAdditionalColor(Color color) => AdditionalColor = color;
public bool Compartment { get; private set; }
public bool Entrance { get; private set; }

View File

@ -14,6 +14,8 @@ public class EntityBus
public Color BodyColor { get; private set; }
public void SetBodyColor(Color color) => BodyColor = color;
public double Step => Speed * 50 / Weight;
/// <summary>

View File

@ -32,7 +32,6 @@
panelCompanyTools = new Panel();
buttonDeleteBus = new Button();
maskedTextBox = new MaskedTextBox();
buttonAddAccordionBus = new Button();
buttonRefresh = new Button();
buttonGoToCheck = new Button();
buttonAddBus = new Button();
@ -69,7 +68,6 @@
//
panelCompanyTools.Controls.Add(buttonDeleteBus);
panelCompanyTools.Controls.Add(maskedTextBox);
panelCompanyTools.Controls.Add(buttonAddAccordionBus);
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Controls.Add(buttonGoToCheck);
panelCompanyTools.Controls.Add(buttonAddBus);
@ -102,17 +100,6 @@
maskedTextBox.ValidatingType = typeof(int);
maskedTextBox.MaskInputRejected += maskedTextBox_MaskInputRejected;
//
// buttonAddAccordionBus
//
buttonAddAccordionBus.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddAccordionBus.Location = new Point(6, 36);
buttonAddAccordionBus.Name = "buttonAddAccordionBus";
buttonAddAccordionBus.Size = new Size(160, 38);
buttonAddAccordionBus.TabIndex = 3;
buttonAddAccordionBus.Text = "Добавление автобуса-гармошки";
buttonAddAccordionBus.UseVisualStyleBackColor = true;
buttonAddAccordionBus.Click += buttonAddAccordionBus_Click;
//
// buttonRefresh
//
buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
@ -138,9 +125,9 @@
// buttonAddBus
//
buttonAddBus.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddBus.Location = new Point(6, 3);
buttonAddBus.Location = new Point(6, 17);
buttonAddBus.Name = "buttonAddBus";
buttonAddBus.Size = new Size(160, 27);
buttonAddBus.Size = new Size(160, 37);
buttonAddBus.TabIndex = 2;
buttonAddBus.Text = "Добавление автобуса";
buttonAddBus.UseVisualStyleBackColor = true;
@ -285,7 +272,6 @@
private GroupBox groupBoxTools;
private ComboBox comboBoxSelectorCompany;
private Button buttonAddAccordionBus;
private Button buttonAddBus;
private PictureBox pictureBox;
private Button buttonRefresh;

View File

@ -99,12 +99,26 @@ public partial class FormBusCollection : Form
private void buttonAddBus_Click(object sender, EventArgs e)
{
CreateObject(nameof(DrawningBus));
FormBusConfig form = new();
form.Show();
form.AddEvent(SetBus);
}
private void buttonAddAccordionBus_Click(object sender, EventArgs e)
private void SetBus(DrawningBus bus)
{
CreateObject(nameof(DrawningAccordionBus));
if (_company == null || bus == null) return;
bus.SetPictureSize(pictureBox.Width, pictureBox.Height);
if (_company + bus != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
}
else
{
MessageBox.Show("Объект не удалось добавить");
}
}
private void buttonDeleteBus_Click(object sender, EventArgs e)

View File

@ -0,0 +1,382 @@
namespace ProjectAccordionBus
{
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();
groupBoxColors = new GroupBox();
panelPurple = new Panel();
panelBlack = new Panel();
panelYellow = new Panel();
panelBlue = new Panel();
panelGreen = new Panel();
panelWhite = new Panel();
panelGray = new Panel();
panelRed = new Panel();
checkBoxWindows = new CheckBox();
checkBoxEntrance = new CheckBox();
checkBoxCompartment = new CheckBox();
numericUpDownWeight = new NumericUpDown();
numericUpDownSpeed = new NumericUpDown();
labelWeight = new Label();
labelSpeed = new Label();
labelModifiedObject = new Label();
labelSimpleObject = new Label();
pictureBoxObject = new PictureBox();
buttonAdd = new Button();
buttonCancel = new Button();
panelObjects = new Panel();
labelAdditionalColor = new Label();
labelBodyColor = new Label();
groupBoxConfig.SuspendLayout();
groupBoxColors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
panelObjects.SuspendLayout();
SuspendLayout();
//
// groupBoxConfig
//
groupBoxConfig.Controls.Add(groupBoxColors);
groupBoxConfig.Controls.Add(checkBoxWindows);
groupBoxConfig.Controls.Add(checkBoxEntrance);
groupBoxConfig.Controls.Add(checkBoxCompartment);
groupBoxConfig.Controls.Add(numericUpDownWeight);
groupBoxConfig.Controls.Add(numericUpDownSpeed);
groupBoxConfig.Controls.Add(labelWeight);
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(479, 208);
groupBoxConfig.TabIndex = 0;
groupBoxConfig.TabStop = false;
groupBoxConfig.Text = "Параметры";
//
// groupBoxColors
//
groupBoxColors.Controls.Add(panelPurple);
groupBoxColors.Controls.Add(panelBlack);
groupBoxColors.Controls.Add(panelYellow);
groupBoxColors.Controls.Add(panelBlue);
groupBoxColors.Controls.Add(panelGreen);
groupBoxColors.Controls.Add(panelWhite);
groupBoxColors.Controls.Add(panelGray);
groupBoxColors.Controls.Add(panelRed);
groupBoxColors.Location = new Point(211, 22);
groupBoxColors.Name = "groupBoxColors";
groupBoxColors.Size = new Size(239, 130);
groupBoxColors.TabIndex = 9;
groupBoxColors.TabStop = false;
groupBoxColors.Text = "Цвета";
//
// panelPurple
//
panelPurple.BackColor = Color.Purple;
panelPurple.Location = new Point(180, 73);
panelPurple.Name = "panelPurple";
panelPurple.Size = new Size(38, 38);
panelPurple.TabIndex = 1;
//
// panelBlack
//
panelBlack.BackColor = Color.Black;
panelBlack.Location = new Point(123, 73);
panelBlack.Name = "panelBlack";
panelBlack.Size = new Size(38, 38);
panelBlack.TabIndex = 1;
//
// panelYellow
//
panelYellow.BackColor = Color.Yellow;
panelYellow.Location = new Point(180, 22);
panelYellow.Name = "panelYellow";
panelYellow.Size = new Size(38, 38);
panelYellow.TabIndex = 1;
//
// panelBlue
//
panelBlue.BackColor = Color.Blue;
panelBlue.Location = new Point(123, 22);
panelBlue.Name = "panelBlue";
panelBlue.Size = new Size(38, 38);
panelBlue.TabIndex = 1;
//
// panelGreen
//
panelGreen.BackColor = Color.Green;
panelGreen.Location = new Point(69, 22);
panelGreen.Name = "panelGreen";
panelGreen.Size = new Size(38, 38);
panelGreen.TabIndex = 1;
//
// panelWhite
//
panelWhite.BackColor = Color.White;
panelWhite.Location = new Point(13, 73);
panelWhite.Name = "panelWhite";
panelWhite.Size = new Size(38, 38);
panelWhite.TabIndex = 1;
//
// panelGray
//
panelGray.BackColor = Color.Gray;
panelGray.Location = new Point(69, 73);
panelGray.Name = "panelGray";
panelGray.Size = new Size(38, 38);
panelGray.TabIndex = 1;
//
// panelRed
//
panelRed.BackColor = Color.Red;
panelRed.Location = new Point(13, 22);
panelRed.Name = "panelRed";
panelRed.Size = new Size(38, 38);
panelRed.TabIndex = 0;
//
// checkBoxWindows
//
checkBoxWindows.AutoSize = true;
checkBoxWindows.Location = new Point(6, 155);
checkBoxWindows.Name = "checkBoxWindows";
checkBoxWindows.Size = new Size(153, 19);
checkBoxWindows.TabIndex = 8;
checkBoxWindows.Text = "Признак наличие окон";
checkBoxWindows.UseVisualStyleBackColor = true;
//
// checkBoxEntrance
//
checkBoxEntrance.AutoSize = true;
checkBoxEntrance.Location = new Point(6, 120);
checkBoxEntrance.Name = "checkBoxEntrance";
checkBoxEntrance.Size = new Size(158, 19);
checkBoxEntrance.TabIndex = 7;
checkBoxEntrance.Text = "Признак наличие двери";
checkBoxEntrance.UseVisualStyleBackColor = true;
//
// checkBoxCompartment
//
checkBoxCompartment.AutoSize = true;
checkBoxCompartment.Location = new Point(6, 86);
checkBoxCompartment.Name = "checkBoxCompartment";
checkBoxCompartment.Size = new Size(188, 19);
checkBoxCompartment.TabIndex = 6;
checkBoxCompartment.Text = "Признак наличие доп. отсека";
checkBoxCompartment.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(74, 46);
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(120, 23);
numericUpDownWeight.TabIndex = 5;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(74, 17);
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(120, 23);
numericUpDownSpeed.TabIndex = 4;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelWeight
//
labelWeight.AutoSize = true;
labelWeight.Location = new Point(6, 48);
labelWeight.Name = "labelWeight";
labelWeight.Size = new Size(29, 15);
labelWeight.TabIndex = 3;
labelWeight.Text = "Вес:";
//
// labelSpeed
//
labelSpeed.AutoSize = true;
labelSpeed.Location = new Point(6, 19);
labelSpeed.Name = "labelSpeed";
labelSpeed.Size = new Size(62, 15);
labelSpeed.TabIndex = 2;
labelSpeed.Text = "Скорость:";
//
// labelModifiedObject
//
labelModifiedObject.AllowDrop = true;
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
labelModifiedObject.Location = new Point(350, 165);
labelModifiedObject.Name = "labelModifiedObject";
labelModifiedObject.Size = new Size(100, 31);
labelModifiedObject.TabIndex = 1;
labelModifiedObject.Text = "Продвинутый";
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
labelModifiedObject.Click += buttonAdd_Click;
labelModifiedObject.DragDrop += panelObject_DragDrop;
labelModifiedObject.DragEnter += panelObjects_DragEnter;
labelModifiedObject.MouseDown += labelObject_MouseDown;
//
// labelSimpleObject
//
labelSimpleObject.AllowDrop = true;
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
labelSimpleObject.Location = new Point(224, 164);
labelSimpleObject.Name = "labelSimpleObject";
labelSimpleObject.Size = new Size(100, 32);
labelSimpleObject.TabIndex = 0;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
labelSimpleObject.Click += buttonAdd_Click;
labelSimpleObject.DragDrop += panelObject_DragDrop;
labelSimpleObject.DragEnter += panelObjects_DragEnter;
labelSimpleObject.MouseDown += labelObject_MouseDown;
//
// pictureBoxObject
//
pictureBoxObject.Location = new Point(19, 57);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(173, 95);
pictureBoxObject.TabIndex = 1;
pictureBoxObject.TabStop = false;
pictureBoxObject.DragDrop += panelObject_DragDrop;
pictureBoxObject.DragEnter += panelObjects_DragEnter;
pictureBoxObject.MouseDown += panel_MouseDown;
//
// buttonAdd
//
buttonAdd.Location = new Point(504, 173);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(75, 23);
buttonAdd.TabIndex = 2;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(602, 173);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
//
// panelObjects
//
panelObjects.AllowDrop = true;
panelObjects.Controls.Add(labelAdditionalColor);
panelObjects.Controls.Add(labelBodyColor);
panelObjects.Controls.Add(pictureBoxObject);
panelObjects.Location = new Point(485, 0);
panelObjects.Name = "panelObjects";
panelObjects.Size = new Size(204, 167);
panelObjects.TabIndex = 4;
panelObjects.DragDrop += panelObject_DragDrop;
panelObjects.DragEnter += panelObjects_DragEnter;
panelObjects.MouseDown += panel_MouseDown;
//
// labelAdditionalColor
//
labelAdditionalColor.AllowDrop = true;
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
labelAdditionalColor.Location = new Point(117, 10);
labelAdditionalColor.Name = "labelAdditionalColor";
labelAdditionalColor.Size = new Size(75, 32);
labelAdditionalColor.TabIndex = 3;
labelAdditionalColor.Text = "Доп. цвет";
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
labelAdditionalColor.DragDrop += labelAdditionalColor_DragDrop;
labelAdditionalColor.DragEnter += labelAdditionalColor_DragEnter;
//
// labelBodyColor
//
labelBodyColor.AllowDrop = true;
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
labelBodyColor.Location = new Point(19, 10);
labelBodyColor.Name = "labelBodyColor";
labelBodyColor.Size = new Size(75, 32);
labelBodyColor.TabIndex = 2;
labelBodyColor.Text = "Цвет";
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
labelBodyColor.DragDrop += labelBodyColor_DragDrop;
labelBodyColor.DragEnter += labelBodyColor_DragEnter;
//
// FormBusConfig
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(689, 208);
Controls.Add(panelObjects);
Controls.Add(buttonAdd);
Controls.Add(buttonCancel);
Controls.Add(groupBoxConfig);
Name = "FormBusConfig";
Text = "Создание объекта";
groupBoxConfig.ResumeLayout(false);
groupBoxConfig.PerformLayout();
groupBoxColors.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
panelObjects.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxConfig;
private Label labelModifiedObject;
private Label labelSimpleObject;
private NumericUpDown numericUpDownWeight;
private NumericUpDown numericUpDownSpeed;
private Label labelWeight;
private Label labelSpeed;
private CheckBox checkBoxCompartment;
private CheckBox checkBoxEntrance;
private CheckBox checkBoxWindows;
private GroupBox groupBoxColors;
private Panel panelPurple;
private Panel panelBlack;
private Panel panelYellow;
private Panel panelBlue;
private Panel panelGreen;
private Panel panelWhite;
private Panel panelGray;
private Panel panelRed;
private PictureBox pictureBoxObject;
private Button buttonAdd;
private Button buttonCancel;
private Panel panelObjects;
private Label labelAdditionalColor;
private Label labelBodyColor;
}
}

View File

@ -0,0 +1,164 @@
using ProjectAccordionBus.Drawnings;
using ProjectAccordionBus.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 ProjectAccordionBus;
public partial class FormBusConfig : Form
{
/// <summary>
/// Объект прорисовки класса
/// </summary>
private DrawningBus? _bus = null;
private event Action<DrawningAccordionBus>? BusDelegate;
/// <summary>
/// Конструктор
/// </summary>
public FormBusConfig()
{
InitializeComponent();
panelRed.MouseDown += panel_MouseDown;
panelGreen.MouseDown += panel_MouseDown;
panelBlue.MouseDown += panel_MouseDown;
panelWhite.MouseDown += panel_MouseDown;
panelBlack.MouseDown += panel_MouseDown;
panelGray.MouseDown += panel_MouseDown;
panelPurple.MouseDown += panel_MouseDown;
panelYellow.MouseDown += panel_MouseDown;
buttonCancel.Click += (sender, e) => Close();
}
public void AddEvent(Action<DrawningAccordionBus> busDelegate)
{
BusDelegate += busDelegate;
}
// <summary>
/// Прорисовка объекта
/// </summary>
private void DrawObject()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_bus?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
_bus?.SetPosition(15, 15);
_bus?.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 panelObjects_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":
_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, checkBoxCompartment.Checked,
checkBoxEntrance.Checked, checkBoxWindows.Checked);
break;
}
labelBodyColor.BackColor = Color.Empty;
labelAdditionalColor.BackColor = Color.Empty;
DrawObject();
}
private void panel_MouseDown(object sender, MouseEventArgs e)
{
(sender as Control)?.DoDragDrop((sender as Control)?.BackColor ?? Color.Black, DragDropEffects.Move | DragDropEffects.Copy);
}
private void buttonAdd_Click(object sender, EventArgs e)
{
if (_bus != null)
{
BusDelegate?.Invoke((DrawningAccordionBus)_bus);
Close();
}
}
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 labelBodyColor_DragDrop(object sender, DragEventArgs e)
{
if (_bus != null)
{
_bus.EntityBus.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
DrawObject();
}
}
private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e)
{
if (_bus is DrawningBus)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
}
private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
{
if (_bus?.EntityBus is EntityAccordionBus _accordionBus)
{
_accordionBus.SetAdditionalColor((Color)e.Data.GetData(typeof(Color)));
}
DrawObject();
}
}

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>