Залил лаб5
This commit is contained in:
parent
7b3777a796
commit
d9904c783e
@ -102,6 +102,13 @@ namespace Trolleybus.DrawingObjects
|
||||
_busHeight = busHeight;
|
||||
EntityBus = new EntityBus(speed, weight, bodyColor);
|
||||
}
|
||||
//Метод для того, чтобы изменить размеры окна, т.к. pictureBoxObject в FormBusConfig и pictureBoxCollection в FormBusesCollection
|
||||
//имеют разные размеры, из-за чего объекты некорректно отрисовываются в FormBusesCollection после FormBusConfig
|
||||
public void ChangePictureSize(int width, int height)
|
||||
{
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
}
|
||||
/// <summary>
|
||||
/// Установка позиции
|
||||
/// </summary>
|
||||
|
@ -39,5 +39,9 @@ namespace Trolleybus.Entities
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
public void ChangeBodyColor(Color color)
|
||||
{
|
||||
BodyColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,10 @@ namespace Trolleybus.Entities
|
||||
Horns = horns;
|
||||
Batteries = batteries;
|
||||
}
|
||||
public void ChangeAdditionalColor(Color color)
|
||||
{
|
||||
AdditionalColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
357
Trolleybus/Trolleybus/FormBusConfig.Designer.cs
generated
Normal file
357
Trolleybus/Trolleybus/FormBusConfig.Designer.cs
generated
Normal file
@ -0,0 +1,357 @@
|
||||
namespace Trolleybus
|
||||
{
|
||||
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();
|
||||
labelAdvancedObject = new Label();
|
||||
labelSimpleObject = new Label();
|
||||
groupBoxColor = new GroupBox();
|
||||
panelLightBlue = new Panel();
|
||||
panelBlue = new Panel();
|
||||
panelPurple = new Panel();
|
||||
panelGray = new Panel();
|
||||
panelGreen = new Panel();
|
||||
panelYellow = new Panel();
|
||||
panelOrange = new Panel();
|
||||
panelRed = new Panel();
|
||||
checkBoxBatteries = new CheckBox();
|
||||
checkBoxHorns = new CheckBox();
|
||||
numericUpDownSpeed = new NumericUpDown();
|
||||
numericUpDownWeight = new NumericUpDown();
|
||||
labelWeight = new Label();
|
||||
labelSpeed = new Label();
|
||||
pictureBoxObject = new PictureBox();
|
||||
panelObject = new Panel();
|
||||
labelAdditionalColor = new Label();
|
||||
labelMainColor = new Label();
|
||||
buttonAdd = new Button();
|
||||
buttonCancel = new Button();
|
||||
groupBoxConfig.SuspendLayout();
|
||||
groupBoxColor.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||
panelObject.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBoxConfig
|
||||
//
|
||||
groupBoxConfig.Controls.Add(labelAdvancedObject);
|
||||
groupBoxConfig.Controls.Add(labelSimpleObject);
|
||||
groupBoxConfig.Controls.Add(groupBoxColor);
|
||||
groupBoxConfig.Controls.Add(checkBoxBatteries);
|
||||
groupBoxConfig.Controls.Add(checkBoxHorns);
|
||||
groupBoxConfig.Controls.Add(numericUpDownSpeed);
|
||||
groupBoxConfig.Controls.Add(numericUpDownWeight);
|
||||
groupBoxConfig.Controls.Add(labelWeight);
|
||||
groupBoxConfig.Controls.Add(labelSpeed);
|
||||
groupBoxConfig.Location = new Point(12, 81);
|
||||
groupBoxConfig.Name = "groupBoxConfig";
|
||||
groupBoxConfig.Size = new Size(570, 250);
|
||||
groupBoxConfig.TabIndex = 0;
|
||||
groupBoxConfig.TabStop = false;
|
||||
groupBoxConfig.Text = "Параметры";
|
||||
//
|
||||
// labelAdvancedObject
|
||||
//
|
||||
labelAdvancedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelAdvancedObject.Location = new Point(440, 188);
|
||||
labelAdvancedObject.Name = "labelAdvancedObject";
|
||||
labelAdvancedObject.Size = new Size(120, 30);
|
||||
labelAdvancedObject.TabIndex = 8;
|
||||
labelAdvancedObject.Text = "Продвинутый";
|
||||
labelAdvancedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelAdvancedObject.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelSimpleObject.Location = new Point(283, 188);
|
||||
labelSimpleObject.Name = "labelSimpleObject";
|
||||
labelSimpleObject.Size = new Size(120, 30);
|
||||
labelSimpleObject.TabIndex = 7;
|
||||
labelSimpleObject.Text = "Простой";
|
||||
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// groupBoxColor
|
||||
//
|
||||
groupBoxColor.Controls.Add(panelLightBlue);
|
||||
groupBoxColor.Controls.Add(panelBlue);
|
||||
groupBoxColor.Controls.Add(panelPurple);
|
||||
groupBoxColor.Controls.Add(panelGray);
|
||||
groupBoxColor.Controls.Add(panelGreen);
|
||||
groupBoxColor.Controls.Add(panelYellow);
|
||||
groupBoxColor.Controls.Add(panelOrange);
|
||||
groupBoxColor.Controls.Add(panelRed);
|
||||
groupBoxColor.Location = new Point(283, 32);
|
||||
groupBoxColor.Name = "groupBoxColor";
|
||||
groupBoxColor.Size = new Size(277, 145);
|
||||
groupBoxColor.TabIndex = 6;
|
||||
groupBoxColor.TabStop = false;
|
||||
groupBoxColor.Text = "Цвета";
|
||||
//
|
||||
// panelLightBlue
|
||||
//
|
||||
panelLightBlue.BackColor = Color.FromArgb(128, 255, 255);
|
||||
panelLightBlue.Location = new Point(5, 85);
|
||||
panelLightBlue.Name = "panelLightBlue";
|
||||
panelLightBlue.Size = new Size(50, 40);
|
||||
panelLightBlue.TabIndex = 0;
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
panelBlue.BackColor = Color.FromArgb(0, 0, 192);
|
||||
panelBlue.Location = new Point(75, 85);
|
||||
panelBlue.Name = "panelBlue";
|
||||
panelBlue.Size = new Size(50, 40);
|
||||
panelBlue.TabIndex = 0;
|
||||
//
|
||||
// panelPurple
|
||||
//
|
||||
panelPurple.BackColor = Color.DarkViolet;
|
||||
panelPurple.Location = new Point(145, 85);
|
||||
panelPurple.Name = "panelPurple";
|
||||
panelPurple.Size = new Size(50, 40);
|
||||
panelPurple.TabIndex = 0;
|
||||
//
|
||||
// panelGray
|
||||
//
|
||||
panelGray.BackColor = Color.Gray;
|
||||
panelGray.Location = new Point(215, 85);
|
||||
panelGray.Name = "panelGray";
|
||||
panelGray.Size = new Size(50, 40);
|
||||
panelGray.TabIndex = 0;
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
panelGreen.BackColor = Color.FromArgb(0, 192, 0);
|
||||
panelGreen.Location = new Point(215, 25);
|
||||
panelGreen.Name = "panelGreen";
|
||||
panelGreen.Size = new Size(50, 40);
|
||||
panelGreen.TabIndex = 0;
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
panelYellow.BackColor = Color.Yellow;
|
||||
panelYellow.Location = new Point(145, 25);
|
||||
panelYellow.Name = "panelYellow";
|
||||
panelYellow.Size = new Size(50, 40);
|
||||
panelYellow.TabIndex = 0;
|
||||
//
|
||||
// panelOrange
|
||||
//
|
||||
panelOrange.BackColor = Color.FromArgb(255, 128, 0);
|
||||
panelOrange.Location = new Point(75, 25);
|
||||
panelOrange.Name = "panelOrange";
|
||||
panelOrange.Size = new Size(50, 40);
|
||||
panelOrange.TabIndex = 0;
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
panelRed.BackColor = Color.Firebrick;
|
||||
panelRed.Location = new Point(5, 25);
|
||||
panelRed.Name = "panelRed";
|
||||
panelRed.Size = new Size(50, 40);
|
||||
panelRed.TabIndex = 0;
|
||||
//
|
||||
// checkBoxBatteries
|
||||
//
|
||||
checkBoxBatteries.AutoSize = true;
|
||||
checkBoxBatteries.Location = new Point(13, 149);
|
||||
checkBoxBatteries.Name = "checkBoxBatteries";
|
||||
checkBoxBatteries.Size = new Size(230, 24);
|
||||
checkBoxBatteries.TabIndex = 5;
|
||||
checkBoxBatteries.Text = "Наличие отсека для батарей";
|
||||
checkBoxBatteries.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxHorns
|
||||
//
|
||||
checkBoxHorns.AutoSize = true;
|
||||
checkBoxHorns.Location = new Point(13, 119);
|
||||
checkBoxHorns.Name = "checkBoxHorns";
|
||||
checkBoxHorns.Size = new Size(149, 24);
|
||||
checkBoxHorns.TabIndex = 4;
|
||||
checkBoxHorns.Text = "Наличие \"рогов\"";
|
||||
checkBoxHorns.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
numericUpDownSpeed.Location = new Point(94, 32);
|
||||
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(150, 27);
|
||||
numericUpDownSpeed.TabIndex = 3;
|
||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
numericUpDownWeight.Location = new Point(94, 83);
|
||||
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(150, 27);
|
||||
numericUpDownWeight.TabIndex = 2;
|
||||
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// labelWeight
|
||||
//
|
||||
labelWeight.AutoSize = true;
|
||||
labelWeight.Location = new Point(6, 85);
|
||||
labelWeight.Name = "labelWeight";
|
||||
labelWeight.Size = new Size(36, 20);
|
||||
labelWeight.TabIndex = 1;
|
||||
labelWeight.Text = "Вес:";
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
labelSpeed.AutoSize = true;
|
||||
labelSpeed.Location = new Point(6, 32);
|
||||
labelSpeed.Name = "labelSpeed";
|
||||
labelSpeed.Size = new Size(76, 20);
|
||||
labelSpeed.TabIndex = 0;
|
||||
labelSpeed.Text = "Скорость:";
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
pictureBoxObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
pictureBoxObject.Location = new Point(35, 84);
|
||||
pictureBoxObject.Name = "pictureBoxObject";
|
||||
pictureBoxObject.Size = new Size(327, 204);
|
||||
pictureBoxObject.TabIndex = 1;
|
||||
pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// panelObject
|
||||
//
|
||||
panelObject.AllowDrop = true;
|
||||
panelObject.Controls.Add(labelAdditionalColor);
|
||||
panelObject.Controls.Add(labelMainColor);
|
||||
panelObject.Controls.Add(pictureBoxObject);
|
||||
panelObject.Location = new Point(612, 29);
|
||||
panelObject.Name = "panelObject";
|
||||
panelObject.Size = new Size(401, 302);
|
||||
panelObject.TabIndex = 2;
|
||||
panelObject.DragDrop += PanelObject_DragDrop;
|
||||
panelObject.DragEnter += PanelObject_DragEnter;
|
||||
//
|
||||
// labelAdditionalColor
|
||||
//
|
||||
labelAdditionalColor.AllowDrop = true;
|
||||
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelAdditionalColor.Location = new Point(272, 19);
|
||||
labelAdditionalColor.Name = "labelAdditionalColor";
|
||||
labelAdditionalColor.Size = new Size(90, 50);
|
||||
labelAdditionalColor.TabIndex = 3;
|
||||
labelAdditionalColor.Text = "Доп. цвет";
|
||||
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelAdditionalColor.DragDrop += LabelAdditionalColor_DragDrop;
|
||||
labelAdditionalColor.DragEnter += LabelAdditionalColor_DragEnter;
|
||||
//
|
||||
// labelMainColor
|
||||
//
|
||||
labelMainColor.AllowDrop = true;
|
||||
labelMainColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelMainColor.Location = new Point(35, 19);
|
||||
labelMainColor.Name = "labelMainColor";
|
||||
labelMainColor.Size = new Size(90, 50);
|
||||
labelMainColor.TabIndex = 2;
|
||||
labelMainColor.Text = "Цвет";
|
||||
labelMainColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelMainColor.DragDrop += LabelMainColor_DragDrop;
|
||||
labelMainColor.DragEnter += LabelMainColor_DragEnter;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(647, 337);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(94, 29);
|
||||
buttonAdd.TabIndex = 3;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += ButtonAdd_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(884, 337);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 4;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormBusConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1032, 383);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(panelObject);
|
||||
Controls.Add(groupBoxConfig);
|
||||
Name = "FormBusConfig";
|
||||
Text = "FormBusConfig";
|
||||
groupBoxConfig.ResumeLayout(false);
|
||||
groupBoxConfig.PerformLayout();
|
||||
groupBoxColor.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||
panelObject.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxConfig;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private Label labelWeight;
|
||||
private Label labelSpeed;
|
||||
private CheckBox checkBoxBatteries;
|
||||
private CheckBox checkBoxHorns;
|
||||
private GroupBox groupBoxColor;
|
||||
private Panel panelLightBlue;
|
||||
private Panel panelBlue;
|
||||
private Panel panelPurple;
|
||||
private Panel panelGray;
|
||||
private Panel panelGreen;
|
||||
private Panel panelYellow;
|
||||
private Panel panelOrange;
|
||||
private Panel panelRed;
|
||||
private Label labelAdvancedObject;
|
||||
private Label labelSimpleObject;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Panel panelObject;
|
||||
private Label labelAdditionalColor;
|
||||
private Label labelMainColor;
|
||||
private Button buttonAdd;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
198
Trolleybus/Trolleybus/FormBusConfig.cs
Normal file
198
Trolleybus/Trolleybus/FormBusConfig.cs
Normal file
@ -0,0 +1,198 @@
|
||||
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;
|
||||
using Trolleybus.DrawingObjects;
|
||||
using Trolleybus.Entities;
|
||||
|
||||
namespace Trolleybus
|
||||
{
|
||||
public partial class FormBusConfig : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Переменная-выбранный автобус
|
||||
/// </summary>
|
||||
DrawingBus? _bus = null;
|
||||
/// <summary>
|
||||
/// Событие
|
||||
/// </summary>
|
||||
private event Action<DrawingBus>? EventAddBus;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormBusConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelRed.MouseDown += PanelColor_MouseDown;
|
||||
panelOrange.MouseDown += PanelColor_MouseDown;
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||
panelLightBlue.MouseDown += PanelColor_MouseDown;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
panelPurple.MouseDown += PanelColor_MouseDown;
|
||||
panelGray.MouseDown += PanelColor_MouseDown;
|
||||
buttonCancel.Click += (s, e) => Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Отрисовка объекта
|
||||
/// </summary>
|
||||
private void DrawBus()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_bus?.SetPosition(5, 5);
|
||||
_bus?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление события
|
||||
/// </summary>
|
||||
/// <param name="ev">Привязанный метод</param>
|
||||
public void AddEvent(Action<DrawingBus> ev)
|
||||
{
|
||||
if (EventAddBus == null)
|
||||
{
|
||||
EventAddBus = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddBus += ev;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Передача информации (имени Label) при нажатии на 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,
|
||||
DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
/// <summary>
|
||||
/// Проверка получаемой информации (ее типа на соответствие требуемому: текст) для панели
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Действия при приеме перетаскиваемой информации (имени Label)
|
||||
/// </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 DrawingBus(
|
||||
(int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value,
|
||||
Color.White,
|
||||
pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
break;
|
||||
|
||||
case "labelAdvancedObject":
|
||||
_bus = new DrawingTrolleybus(
|
||||
(int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value,
|
||||
Color.White, Color.Black,
|
||||
checkBoxHorns.Checked, checkBoxBatteries.Checked,
|
||||
pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
break;
|
||||
}
|
||||
DrawBus();
|
||||
}
|
||||
/// <summary>
|
||||
/// Передача цвета при нажатии на одну из Panel с цветом
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
|
||||
DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
/// <summary>
|
||||
/// Проверка получаемой информации (ее типа на соответствие требуемому: цвет) для Label с основным цветом
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelMainColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)) && _bus != null)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Действия при приеме перетаскиваемого цвета
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelMainColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
var color = (Color)e.Data.GetData(typeof(Color));
|
||||
_bus.EntityBus.ChangeBodyColor(color);
|
||||
DrawBus();
|
||||
}
|
||||
/// <summary>
|
||||
/// Проверка получаемой информации (ее типа на соответствие требуемому: цвет) для Label с доп. цветом
|
||||
/// и проверка, что создаётся троллейбус
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelAdditionalColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)) && _bus != null && _bus is DrawingTrolleybus)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
private void LabelAdditionalColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
var color = (Color)e.Data.GetData(typeof(Color));
|
||||
//Приведение к EntityTrolleybus для замены доп. цвета
|
||||
EntityTrolleybus? _trolleybus = _bus.EntityBus as EntityTrolleybus;
|
||||
_trolleybus.ChangeAdditionalColor(color);
|
||||
DrawBus();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление автобуса
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddBus?.Invoke(_bus);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
Trolleybus/Trolleybus/FormBusConfig.resx
Normal file
120
Trolleybus/Trolleybus/FormBusConfig.resx
Normal 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>
|
@ -97,6 +97,12 @@ namespace Trolleybus
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddBus_Click(object sender, EventArgs e)
|
||||
{
|
||||
var formBusConfig = new FormBusConfig();
|
||||
formBusConfig.AddEvent(AddBus);
|
||||
formBusConfig.Show();
|
||||
}
|
||||
private void AddBus(DrawingBus selectedBus)
|
||||
{
|
||||
if (listBoxSets.SelectedIndex == -1)
|
||||
{
|
||||
@ -107,11 +113,9 @@ namespace Trolleybus
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FormTrolleybus form = new FormTrolleybus();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (obj + form.SelectedBus != -1)
|
||||
//Возвращение объекту размеров pictureBox с этой формы (до этого создался с размерами pictureBox с FormBusConfig)
|
||||
selectedBus.ChangePictureSize(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
if (obj + selectedBus != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowBuses();
|
||||
@ -121,7 +125,6 @@ namespace Trolleybus
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user