Mavrina J.E. Lab work 5 #6
11
DoubleDeckerBus/DoubleDeckerBus/BusDelegate.cs
Normal file
11
DoubleDeckerBus/DoubleDeckerBus/BusDelegate.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DoubleDeckerBus.DrawningObjects;
|
||||
|
||||
namespace DoubleDeckerBus
|
||||
{
|
||||
public delegate void BusDelegate(DrawningBus bus);
|
||||
|
||||
}
|
@ -12,8 +12,8 @@ namespace DoubleDeckerBus.DrawningObjects
|
||||
{
|
||||
public EntityBus? EntityBus { get; protected set; }
|
||||
public IMoveableObject GetMoveableObject => new DrawningObjectBus(this);
|
||||
private int? _pictureWidth;
|
||||
private int? _pictureHeight;
|
||||
public int? _pictureWidth;
|
||||
public int? _pictureHeight;
|
||||
protected int _startPosX;
|
||||
protected int _startPosY;
|
||||
protected readonly int _busWidth = 110;
|
||||
|
@ -10,7 +10,7 @@ namespace DoubleDeckerBus.Entities
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
public double Weight { get; private set; }
|
||||
public Color BodyColor { get; private set; }
|
||||
public Color BodyColor { get; set; }
|
||||
public double Step => (double)Speed * 100 / Weight;
|
||||
public EntityBus(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
@ -18,7 +18,10 @@ namespace DoubleDeckerBus.Entities
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
public void setBodyColor(Color color)
|
||||
{
|
||||
BodyColor = color;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ namespace DoubleDeckerBus.Entities
|
||||
public bool Ladder { get; private set; }
|
||||
public bool LineBetweenFloor { get; private set; }
|
||||
public EntityDoubleDeckerBus(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, bool secondFloor, bool ladder, bool lineBetweenFloor) :
|
||||
additionalColor, bool secondFloor, bool ladder, bool lineBetweenFloor) :
|
||||
base(speed, weight, bodyColor)
|
||||
{
|
||||
AdditionalColor = additionalColor;
|
||||
@ -21,6 +21,9 @@ namespace DoubleDeckerBus.Entities
|
||||
Ladder = ladder;
|
||||
LineBetweenFloor = lineBetweenFloor;
|
||||
}
|
||||
public void setAdditionalColor(Color color)
|
||||
{
|
||||
AdditionalColor = color;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ using DoubleDeckerBus.DrawningObjects;
|
||||
using DoubleDeckerBus.Generics;
|
||||
using DoubleDeckerBus.Generics.ProjectSportCar.Generics;
|
||||
using DoubleDeckerBus.MovementStrategy;
|
||||
using static System.Windows.Forms.DataFormats;
|
||||
|
||||
namespace DoubleDeckerBus
|
||||
{
|
||||
@ -82,18 +83,23 @@ namespace DoubleDeckerBus
|
||||
{
|
||||
return;
|
||||
}
|
||||
DoubleDeckerBus form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
FormBusConfig form = new FormBusConfig();
|
||||
form.AddEvent(AddBus);
|
||||
form.Show();
|
||||
}
|
||||
private void AddBus(DrawningBus boat)
|
||||
{
|
||||
boat._pictureWidth = pictureBoxCollection.Width;
|
||||
boat._pictureHeight = pictureBoxCollection.Height; if (listBoxStorages.SelectedIndex == -1) return;
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty]; if (obj == null) return;
|
||||
if (obj + boat)
|
||||
{
|
||||
if (obj + form.SelectedBus)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowBuses();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowBuses();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
private void buttonRemoveBus_Click(object sender, EventArgs e)
|
||||
|
380
DoubleDeckerBus/DoubleDeckerBus/FormBusConfig.Designer.cs
generated
Normal file
380
DoubleDeckerBus/DoubleDeckerBus/FormBusConfig.Designer.cs
generated
Normal file
@ -0,0 +1,380 @@
|
||||
namespace DoubleDeckerBus
|
||||
{
|
||||
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()
|
||||
{
|
||||
groupBox1 = new GroupBox();
|
||||
labelModifiedObject = new Label();
|
||||
labelSimpleObject = new Label();
|
||||
groupBox2 = 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();
|
||||
checkBoxLine = new CheckBox();
|
||||
checkBoxLadder = new CheckBox();
|
||||
checkBoxSecondFloor = new CheckBox();
|
||||
numericUpDownWeight = new NumericUpDown();
|
||||
numericUpDownSpeed = new NumericUpDown();
|
||||
label2 = new Label();
|
||||
label1 = new Label();
|
||||
pictureBoxObject = new PictureBox();
|
||||
PanelObject = new Panel();
|
||||
labelDopColor = new Label();
|
||||
labelColor = new Label();
|
||||
ButtonOk = new Button();
|
||||
buttonCancel = new Button();
|
||||
groupBox1.SuspendLayout();
|
||||
groupBox2.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||
PanelObject.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
groupBox1.Controls.Add(labelModifiedObject);
|
||||
groupBox1.Controls.Add(labelSimpleObject);
|
||||
groupBox1.Controls.Add(groupBox2);
|
||||
groupBox1.Controls.Add(checkBoxLine);
|
||||
groupBox1.Controls.Add(checkBoxLadder);
|
||||
groupBox1.Controls.Add(checkBoxSecondFloor);
|
||||
groupBox1.Controls.Add(numericUpDownWeight);
|
||||
groupBox1.Controls.Add(numericUpDownSpeed);
|
||||
groupBox1.Controls.Add(label2);
|
||||
groupBox1.Controls.Add(label1);
|
||||
groupBox1.Location = new Point(12, 12);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(508, 187);
|
||||
groupBox1.TabIndex = 0;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "Параметры";
|
||||
//
|
||||
// labelModifiedObject
|
||||
//
|
||||
labelModifiedObject.BorderStyle = BorderStyle.Fixed3D;
|
||||
labelModifiedObject.Location = new Point(386, 150);
|
||||
labelModifiedObject.Name = "labelModifiedObject";
|
||||
labelModifiedObject.Size = new Size(100, 23);
|
||||
labelModifiedObject.TabIndex = 9;
|
||||
labelModifiedObject.Text = "Продвинутый";
|
||||
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
labelSimpleObject.BorderStyle = BorderStyle.Fixed3D;
|
||||
labelSimpleObject.Location = new Point(263, 150);
|
||||
labelSimpleObject.Name = "labelSimpleObject";
|
||||
labelSimpleObject.Size = new Size(100, 23);
|
||||
labelSimpleObject.TabIndex = 8;
|
||||
labelSimpleObject.Text = "Простой";
|
||||
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
groupBox2.Controls.Add(panelPurple);
|
||||
groupBox2.Controls.Add(panelBlack);
|
||||
groupBox2.Controls.Add(panelGray);
|
||||
groupBox2.Controls.Add(panelWhite);
|
||||
groupBox2.Controls.Add(panelYellow);
|
||||
groupBox2.Controls.Add(panelBlue);
|
||||
groupBox2.Controls.Add(panelGreen);
|
||||
groupBox2.Controls.Add(panelRed);
|
||||
groupBox2.Location = new Point(246, 12);
|
||||
groupBox2.Name = "groupBox2";
|
||||
groupBox2.Size = new Size(240, 124);
|
||||
groupBox2.TabIndex = 7;
|
||||
groupBox2.TabStop = false;
|
||||
groupBox2.Text = "Цвета";
|
||||
//
|
||||
// panelPurple
|
||||
//
|
||||
panelPurple.BackColor = Color.Purple;
|
||||
panelPurple.ForeColor = Color.Purple;
|
||||
panelPurple.Location = new Point(183, 73);
|
||||
panelPurple.Name = "panelPurple";
|
||||
panelPurple.Size = new Size(38, 38);
|
||||
panelPurple.TabIndex = 3;
|
||||
panelPurple.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelBlack
|
||||
//
|
||||
panelBlack.BackColor = Color.Black;
|
||||
panelBlack.Location = new Point(126, 73);
|
||||
panelBlack.Name = "panelBlack";
|
||||
panelBlack.Size = new Size(38, 38);
|
||||
panelBlack.TabIndex = 2;
|
||||
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelGray
|
||||
//
|
||||
panelGray.BackColor = Color.Gray;
|
||||
panelGray.Location = new Point(67, 73);
|
||||
panelGray.Name = "panelGray";
|
||||
panelGray.Size = new Size(38, 38);
|
||||
panelGray.TabIndex = 1;
|
||||
panelGray.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelWhite
|
||||
//
|
||||
panelWhite.BackColor = Color.White;
|
||||
panelWhite.Location = new Point(6, 73);
|
||||
panelWhite.Name = "panelWhite";
|
||||
panelWhite.Size = new Size(38, 38);
|
||||
panelWhite.TabIndex = 1;
|
||||
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
panelYellow.BackColor = Color.Yellow;
|
||||
panelYellow.Location = new Point(183, 25);
|
||||
panelYellow.Name = "panelYellow";
|
||||
panelYellow.Size = new Size(38, 38);
|
||||
panelYellow.TabIndex = 1;
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
panelBlue.BackColor = Color.Blue;
|
||||
panelBlue.Location = new Point(126, 25);
|
||||
panelBlue.Name = "panelBlue";
|
||||
panelBlue.Size = new Size(38, 38);
|
||||
panelBlue.TabIndex = 1;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
panelGreen.BackColor = Color.FromArgb(0, 192, 0);
|
||||
panelGreen.Location = new Point(67, 25);
|
||||
panelGreen.Name = "panelGreen";
|
||||
panelGreen.Size = new Size(38, 38);
|
||||
panelGreen.TabIndex = 1;
|
||||
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
panelRed.BackColor = Color.Red;
|
||||
panelRed.Location = new Point(6, 25);
|
||||
panelRed.Name = "panelRed";
|
||||
panelRed.Size = new Size(38, 38);
|
||||
panelRed.TabIndex = 0;
|
||||
panelRed.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// checkBoxLine
|
||||
//
|
||||
checkBoxLine.AutoSize = true;
|
||||
checkBoxLine.Location = new Point(6, 154);
|
||||
checkBoxLine.Name = "checkBoxLine";
|
||||
checkBoxLine.Size = new Size(251, 19);
|
||||
checkBoxLine.TabIndex = 6;
|
||||
checkBoxLine.Text = "Признак наличия линии между этажами";
|
||||
checkBoxLine.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxLadder
|
||||
//
|
||||
checkBoxLadder.AutoSize = true;
|
||||
checkBoxLadder.Location = new Point(6, 129);
|
||||
checkBoxLadder.Name = "checkBoxLadder";
|
||||
checkBoxLadder.Size = new Size(234, 19);
|
||||
checkBoxLadder.TabIndex = 5;
|
||||
checkBoxLadder.Text = "Признак наличия лестницы на 2 этаж";
|
||||
checkBoxLadder.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxSecondFloor
|
||||
//
|
||||
checkBoxSecondFloor.AutoSize = true;
|
||||
checkBoxSecondFloor.Location = new Point(6, 104);
|
||||
checkBoxSecondFloor.Name = "checkBoxSecondFloor";
|
||||
checkBoxSecondFloor.Size = new Size(191, 19);
|
||||
checkBoxSecondFloor.TabIndex = 4;
|
||||
checkBoxSecondFloor.Text = "Признак наличия 2-ого этажа";
|
||||
checkBoxSecondFloor.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
numericUpDownWeight.Location = new Point(71, 60);
|
||||
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(82, 23);
|
||||
numericUpDownWeight.TabIndex = 3;
|
||||
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
numericUpDownSpeed.Location = new Point(71, 31);
|
||||
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(82, 23);
|
||||
numericUpDownSpeed.TabIndex = 2;
|
||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(39, 60);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(29, 15);
|
||||
label2.TabIndex = 1;
|
||||
label2.Text = "Вес:";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(6, 31);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(62, 15);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Скорость:";
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
pictureBoxObject.Location = new Point(10, 38);
|
||||
pictureBoxObject.Name = "pictureBoxObject";
|
||||
pictureBoxObject.Size = new Size(231, 113);
|
||||
pictureBoxObject.TabIndex = 1;
|
||||
pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// PanelObject
|
||||
//
|
||||
PanelObject.AllowDrop = true;
|
||||
PanelObject.Controls.Add(labelDopColor);
|
||||
PanelObject.Controls.Add(labelColor);
|
||||
PanelObject.Controls.Add(pictureBoxObject);
|
||||
PanelObject.Location = new Point(526, 12);
|
||||
PanelObject.Name = "PanelObject";
|
||||
PanelObject.Size = new Size(251, 158);
|
||||
PanelObject.TabIndex = 2;
|
||||
PanelObject.DragDrop += PanelObject_DragDrop;
|
||||
PanelObject.DragEnter += PanelObject_DragEnter;
|
||||
//
|
||||
// labelDopColor
|
||||
//
|
||||
labelDopColor.AllowDrop = true;
|
||||
labelDopColor.BorderStyle = BorderStyle.Fixed3D;
|
||||
labelDopColor.Location = new Point(141, 12);
|
||||
labelDopColor.Name = "labelDopColor";
|
||||
labelDopColor.Size = new Size(100, 23);
|
||||
labelDopColor.TabIndex = 3;
|
||||
labelDopColor.Text = "Доп. цвет";
|
||||
labelDopColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelDopColor.DragDrop += LabelDopColor_DragDrop;
|
||||
labelDopColor.DragEnter += LabelDopColor_DragEnter;
|
||||
labelDopColor.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// labelColor
|
||||
//
|
||||
labelColor.AllowDrop = true;
|
||||
labelColor.BorderStyle = BorderStyle.Fixed3D;
|
||||
labelColor.Location = new Point(10, 12);
|
||||
labelColor.Name = "labelColor";
|
||||
labelColor.Size = new Size(100, 24);
|
||||
labelColor.TabIndex = 2;
|
||||
labelColor.Text = "Цвет";
|
||||
labelColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelColor.DragDrop += LabelColor_DragDrop;
|
||||
labelColor.DragEnter += LabelColor_DragEnter;
|
||||
labelColor.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// ButtonOk
|
||||
//
|
||||
ButtonOk.Location = new Point(561, 176);
|
||||
ButtonOk.Name = "ButtonOk";
|
||||
ButtonOk.Size = new Size(75, 23);
|
||||
ButtonOk.TabIndex = 3;
|
||||
ButtonOk.Text = "Добавить";
|
||||
ButtonOk.UseVisualStyleBackColor = true;
|
||||
ButtonOk.Click += ButtonOk_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(667, 176);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(75, 23);
|
||||
buttonCancel.TabIndex = 4;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormBusConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 212);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(ButtonOk);
|
||||
Controls.Add(PanelObject);
|
||||
Controls.Add(groupBox1);
|
||||
Name = "FormBusConfig";
|
||||
Text = "FormBusConfig";
|
||||
groupBox1.ResumeLayout(false);
|
||||
groupBox1.PerformLayout();
|
||||
groupBox2.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 groupBox1;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private Label label2;
|
||||
private Label label1;
|
||||
private GroupBox groupBox2;
|
||||
private Panel panelWhite;
|
||||
private Panel panelYellow;
|
||||
private Panel panelBlue;
|
||||
private Panel panelGreen;
|
||||
private Panel panelRed;
|
||||
private CheckBox checkBoxLine;
|
||||
private CheckBox checkBoxLadder;
|
||||
private CheckBox checkBoxSecondFloor;
|
||||
private Label labelModifiedObject;
|
||||
private Label labelSimpleObject;
|
||||
private Panel panelBlack;
|
||||
private Panel panelGray;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Panel PanelObject;
|
||||
private Label labelDopColor;
|
||||
private Label labelColor;
|
||||
private Button ButtonOk;
|
||||
private Button buttonCancel;
|
||||
private Panel panelPurple;
|
||||
}
|
||||
}
|
151
DoubleDeckerBus/DoubleDeckerBus/FormBusConfig.cs
Normal file
151
DoubleDeckerBus/DoubleDeckerBus/FormBusConfig.cs
Normal file
@ -0,0 +1,151 @@
|
||||
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 DoubleDeckerBus.DrawningObjects;
|
||||
using DoubleDeckerBus.Entities;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button;
|
||||
|
||||
|
||||
namespace DoubleDeckerBus
|
||||
{
|
||||
public partial class FormBusConfig : Form
|
||||
{
|
||||
DrawningBus? _bus = null;
|
||||
private event Action<DrawningBus>? EventAddBus;
|
||||
|
||||
public FormBusConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||
panelPurple.MouseDown += PanelColor_MouseDown;
|
||||
panelGray.MouseDown += PanelColor_MouseDown;
|
||||
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||
panelRed.MouseDown += PanelColor_MouseDown;
|
||||
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
||||
buttonCancel.Click += (s, e) => Close();
|
||||
}
|
||||
public void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
|
||||
DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
public void DrawBus()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_bus?.SetPosition(5, 5);
|
||||
_bus?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
public void AddEvent(Action<DrawningBus>? ev)
|
||||
{
|
||||
if (EventAddBus == null)
|
||||
{
|
||||
EventAddBus = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddBus += ev;
|
||||
}
|
||||
}
|
||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | 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,
|
||||
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
|
||||
pictureBoxObject.Height);
|
||||
break;
|
||||
case "labelModifiedObject":
|
||||
_bus = new DrawningDoubleDeckerBus((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxSecondFloor.Checked,
|
||||
checkBoxLadder.Checked, checkBoxLine.Checked, pictureBoxObject.Width,
|
||||
pictureBoxObject.Height);
|
||||
break;
|
||||
}
|
||||
DrawBus();
|
||||
}
|
||||
private void LabelColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_bus == null)
|
||||
return;
|
||||
switch (((Label)sender).Name)
|
||||
{
|
||||
case "labelColor":
|
||||
_bus?.EntityBus?.setBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||
break;
|
||||
case "labelDopColor":
|
||||
if (!(_bus is DoubleDeckerBus))
|
||||
return;
|
||||
(_bus.EntityBus as EntityDoubleDeckerBus)?.setAdditionalColor(color:
|
||||
(Color)e.Data.GetData(typeof(Color)));
|
||||
break;
|
||||
}
|
||||
DrawBus();
|
||||
}
|
||||
private void LabelColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if ((_bus?.EntityBus == null) || (_bus is DrawningDoubleDeckerBus == false))
|
||||
return;
|
||||
Color additionalColor = (Color)e.Data.GetData(typeof(Color));
|
||||
_bus = new DrawningDoubleDeckerBus((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, _bus.EntityBus.BodyColor, additionalColor, checkBoxSecondFloor.Checked,
|
||||
checkBoxLadder.Checked, checkBoxLine.Checked, pictureBoxObject.Width,
|
||||
pictureBoxObject.Height);
|
||||
DrawBus();
|
||||
}
|
||||
private void LabelDopColor_DragEnter(object sender, DragEventArgs e)
|
||||
eegov
commented
Логика DragEnter основного цвета идентична логике DragEnter дополнительного цвета и отдельная обработка тут не нужна Логика DragEnter основного цвета идентична логике DragEnter дополнительного цвета и отдельная обработка тут не нужна
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
private void ButtonOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddBus?.Invoke(_bus);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
DoubleDeckerBus/DoubleDeckerBus/FormBusConfig.resx
Normal file
120
DoubleDeckerBus/DoubleDeckerBus/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>
|
Loading…
Reference in New Issue
Block a user
Не используется