5 Лаба. Создание формы, класса Delegate, несколько методов.
This commit is contained in:
parent
275b551026
commit
a63bca3d27
@ -46,5 +46,9 @@ namespace ProjectElectricLocomotive.DrawingObjects
|
||||
g.DrawLine(pen, _startPosX + 40, _startPosY + 15, _startPosX + 60, _startPosY + 2);
|
||||
base.DrawTransport(g);
|
||||
}
|
||||
public void SetAddColor(Color color)
|
||||
{
|
||||
(EntityLocomotive as EntityElectricLocomotive).SetAdditionalColor(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -166,5 +166,9 @@ namespace ProjectElectricLocomotive.DrawingObjects
|
||||
}
|
||||
public IMoveableObject GetMoveableObject => new
|
||||
DrawingObjectLocomotive(this);
|
||||
public void SetColor(Color color)
|
||||
{
|
||||
(EntityLocomotive as EntityLocomotive).SetColor(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,5 +23,9 @@ namespace ProjectElectricLocomotive.Entities
|
||||
Pantograph = pantograph;
|
||||
Compartment = compartment;
|
||||
}
|
||||
public void SetAdditionalColor(Color color)
|
||||
{
|
||||
AdditionalColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,5 +22,9 @@ namespace ProjectElectricLocomotive.Entities
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
public void SetColor(Color color)
|
||||
{
|
||||
BodyColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,12 @@ namespace ProjectElectricLocomotive
|
||||
}
|
||||
}
|
||||
private void buttonAddLocomotive_Click(object sender, EventArgs e)
|
||||
{
|
||||
var formLocomotiveConfig = new FormLocomotiveConfig();
|
||||
formLocomotiveConfig.AddEvent(AddLocomotive);
|
||||
formLocomotiveConfig.Show();
|
||||
}
|
||||
public void AddLocomotive(DrawingLocomotive loco)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1) return;
|
||||
|
||||
|
355
ElectricLocomotive/ElectricLocomotive/FormLocomotiveConfig.Designer.cs
generated
Normal file
355
ElectricLocomotive/ElectricLocomotive/FormLocomotiveConfig.Designer.cs
generated
Normal file
@ -0,0 +1,355 @@
|
||||
namespace ProjectElectricLocomotive
|
||||
{
|
||||
partial class FormLocomotiveConfig
|
||||
{
|
||||
/// <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();
|
||||
checkBoxCompartment = new CheckBox();
|
||||
labelAdvancedObject = new Label();
|
||||
labelSimpleObject = new Label();
|
||||
groupBoxColors = new GroupBox();
|
||||
panelColorPurple = new Panel();
|
||||
panelColorBlack = new Panel();
|
||||
panelColorGray = new Panel();
|
||||
panelColorWhite = new Panel();
|
||||
panelColorYellow = new Panel();
|
||||
panelColorBlue = new Panel();
|
||||
panelColorGreen = new Panel();
|
||||
panelColorRed = new Panel();
|
||||
checkBoxPantograph = new CheckBox();
|
||||
numericUpDownWeight = new NumericUpDown();
|
||||
numericUpDownSpeed = new NumericUpDown();
|
||||
labelWeight = new Label();
|
||||
labelSpeed = new Label();
|
||||
pictureBoxLoco = new PictureBox();
|
||||
panelWithPictureBox = new Panel();
|
||||
labelAdvancedColor = new Label();
|
||||
labelSimpleColor = new Label();
|
||||
buttonAddObject = new Button();
|
||||
buttonCancelObject = new Button();
|
||||
groupBoxConfig.SuspendLayout();
|
||||
groupBoxColors.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxLoco).BeginInit();
|
||||
panelWithPictureBox.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBoxConfig
|
||||
//
|
||||
groupBoxConfig.Controls.Add(checkBoxCompartment);
|
||||
groupBoxConfig.Controls.Add(labelAdvancedObject);
|
||||
groupBoxConfig.Controls.Add(labelSimpleObject);
|
||||
groupBoxConfig.Controls.Add(groupBoxColors);
|
||||
groupBoxConfig.Controls.Add(checkBoxPantograph);
|
||||
groupBoxConfig.Controls.Add(numericUpDownWeight);
|
||||
groupBoxConfig.Controls.Add(numericUpDownSpeed);
|
||||
groupBoxConfig.Controls.Add(labelWeight);
|
||||
groupBoxConfig.Controls.Add(labelSpeed);
|
||||
groupBoxConfig.Location = new Point(2, 4);
|
||||
groupBoxConfig.Name = "groupBoxConfig";
|
||||
groupBoxConfig.Size = new Size(474, 255);
|
||||
groupBoxConfig.TabIndex = 0;
|
||||
groupBoxConfig.TabStop = false;
|
||||
groupBoxConfig.Text = "Параметры";
|
||||
//
|
||||
// checkBoxCompartment
|
||||
//
|
||||
checkBoxCompartment.AutoSize = true;
|
||||
checkBoxCompartment.Location = new Point(10, 149);
|
||||
checkBoxCompartment.Name = "checkBoxCompartment";
|
||||
checkBoxCompartment.Size = new Size(121, 19);
|
||||
checkBoxCompartment.TabIndex = 10;
|
||||
checkBoxCompartment.Text = "Наличие отсеков";
|
||||
checkBoxCompartment.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// labelAdvancedObject
|
||||
//
|
||||
labelAdvancedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelAdvancedObject.Location = new Point(324, 175);
|
||||
labelAdvancedObject.Name = "labelAdvancedObject";
|
||||
labelAdvancedObject.Size = new Size(119, 51);
|
||||
labelAdvancedObject.TabIndex = 9;
|
||||
labelAdvancedObject.Text = "Продвинутый";
|
||||
labelAdvancedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelAdvancedObject.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelSimpleObject.Location = new Point(181, 174);
|
||||
labelSimpleObject.Name = "labelSimpleObject";
|
||||
labelSimpleObject.Size = new Size(119, 51);
|
||||
labelSimpleObject.TabIndex = 8;
|
||||
labelSimpleObject.Text = "Простой";
|
||||
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// groupBoxColors
|
||||
//
|
||||
groupBoxColors.Controls.Add(panelColorPurple);
|
||||
groupBoxColors.Controls.Add(panelColorBlack);
|
||||
groupBoxColors.Controls.Add(panelColorGray);
|
||||
groupBoxColors.Controls.Add(panelColorWhite);
|
||||
groupBoxColors.Controls.Add(panelColorYellow);
|
||||
groupBoxColors.Controls.Add(panelColorBlue);
|
||||
groupBoxColors.Controls.Add(panelColorGreen);
|
||||
groupBoxColors.Controls.Add(panelColorRed);
|
||||
groupBoxColors.Location = new Point(181, 18);
|
||||
groupBoxColors.Name = "groupBoxColors";
|
||||
groupBoxColors.Size = new Size(287, 150);
|
||||
groupBoxColors.TabIndex = 7;
|
||||
groupBoxColors.TabStop = false;
|
||||
groupBoxColors.Text = "Цвета";
|
||||
//
|
||||
// panelColorPurple
|
||||
//
|
||||
panelColorPurple.BackColor = Color.Purple;
|
||||
panelColorPurple.Location = new Point(199, 84);
|
||||
panelColorPurple.Name = "panelColorPurple";
|
||||
panelColorPurple.Size = new Size(50, 50);
|
||||
panelColorPurple.TabIndex = 7;
|
||||
//
|
||||
// panelColorBlack
|
||||
//
|
||||
panelColorBlack.BackColor = Color.Black;
|
||||
panelColorBlack.Location = new Point(143, 84);
|
||||
panelColorBlack.Name = "panelColorBlack";
|
||||
panelColorBlack.Size = new Size(50, 50);
|
||||
panelColorBlack.TabIndex = 6;
|
||||
//
|
||||
// panelColorGray
|
||||
//
|
||||
panelColorGray.BackColor = Color.Silver;
|
||||
panelColorGray.Location = new Point(87, 84);
|
||||
panelColorGray.Name = "panelColorGray";
|
||||
panelColorGray.Size = new Size(50, 50);
|
||||
panelColorGray.TabIndex = 5;
|
||||
//
|
||||
// panelColorWhite
|
||||
//
|
||||
panelColorWhite.BackColor = Color.White;
|
||||
panelColorWhite.Location = new Point(31, 84);
|
||||
panelColorWhite.Name = "panelColorWhite";
|
||||
panelColorWhite.Size = new Size(50, 50);
|
||||
panelColorWhite.TabIndex = 4;
|
||||
//
|
||||
// panelColorYellow
|
||||
//
|
||||
panelColorYellow.BackColor = Color.Yellow;
|
||||
panelColorYellow.Location = new Point(199, 28);
|
||||
panelColorYellow.Name = "panelColorYellow";
|
||||
panelColorYellow.Size = new Size(50, 50);
|
||||
panelColorYellow.TabIndex = 3;
|
||||
//
|
||||
// panelColorBlue
|
||||
//
|
||||
panelColorBlue.BackColor = Color.Blue;
|
||||
panelColorBlue.Location = new Point(143, 28);
|
||||
panelColorBlue.Name = "panelColorBlue";
|
||||
panelColorBlue.Size = new Size(50, 50);
|
||||
panelColorBlue.TabIndex = 2;
|
||||
//
|
||||
// panelColorGreen
|
||||
//
|
||||
panelColorGreen.BackColor = Color.FromArgb(0, 192, 0);
|
||||
panelColorGreen.Location = new Point(87, 28);
|
||||
panelColorGreen.Name = "panelColorGreen";
|
||||
panelColorGreen.Size = new Size(50, 50);
|
||||
panelColorGreen.TabIndex = 1;
|
||||
//
|
||||
// panelColorRed
|
||||
//
|
||||
panelColorRed.BackColor = Color.Red;
|
||||
panelColorRed.Location = new Point(31, 28);
|
||||
panelColorRed.Name = "panelColorRed";
|
||||
panelColorRed.Size = new Size(50, 50);
|
||||
panelColorRed.TabIndex = 0;
|
||||
panelColorRed.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// checkBoxPantograph
|
||||
//
|
||||
checkBoxPantograph.AutoSize = true;
|
||||
checkBoxPantograph.Location = new Point(10, 124);
|
||||
checkBoxPantograph.Name = "checkBoxPantograph";
|
||||
checkBoxPantograph.Size = new Size(172, 19);
|
||||
checkBoxPantograph.TabIndex = 4;
|
||||
checkBoxPantograph.Text = "Наличие токоприемников";
|
||||
checkBoxPantograph.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
numericUpDownWeight.Location = new Point(10, 95);
|
||||
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 = 3;
|
||||
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
numericUpDownSpeed.Location = new Point(10, 51);
|
||||
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 = 2;
|
||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// labelWeight
|
||||
//
|
||||
labelWeight.AutoSize = true;
|
||||
labelWeight.Location = new Point(10, 77);
|
||||
labelWeight.Name = "labelWeight";
|
||||
labelWeight.Size = new Size(26, 15);
|
||||
labelWeight.TabIndex = 1;
|
||||
labelWeight.Text = "Вес";
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
labelSpeed.AutoSize = true;
|
||||
labelSpeed.Location = new Point(10, 33);
|
||||
labelSpeed.Name = "labelSpeed";
|
||||
labelSpeed.Size = new Size(59, 15);
|
||||
labelSpeed.TabIndex = 0;
|
||||
labelSpeed.Text = "Скорость";
|
||||
//
|
||||
// pictureBoxLoco
|
||||
//
|
||||
pictureBoxLoco.Location = new Point(14, 38);
|
||||
pictureBoxLoco.Name = "pictureBoxLoco";
|
||||
pictureBoxLoco.Size = new Size(284, 147);
|
||||
pictureBoxLoco.TabIndex = 1;
|
||||
pictureBoxLoco.TabStop = false;
|
||||
//
|
||||
// panelWithPictureBox
|
||||
//
|
||||
panelWithPictureBox.AllowDrop = true;
|
||||
panelWithPictureBox.Controls.Add(labelAdvancedColor);
|
||||
panelWithPictureBox.Controls.Add(labelSimpleColor);
|
||||
panelWithPictureBox.Controls.Add(pictureBoxLoco);
|
||||
panelWithPictureBox.Location = new Point(482, 12);
|
||||
panelWithPictureBox.Name = "panelWithPictureBox";
|
||||
panelWithPictureBox.Size = new Size(316, 195);
|
||||
panelWithPictureBox.TabIndex = 2;
|
||||
//
|
||||
// labelAdvancedColor
|
||||
//
|
||||
labelAdvancedColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelAdvancedColor.Location = new Point(159, 10);
|
||||
labelAdvancedColor.Name = "labelAdvancedColor";
|
||||
labelAdvancedColor.Size = new Size(139, 23);
|
||||
labelAdvancedColor.TabIndex = 3;
|
||||
labelAdvancedColor.Text = "Доп. Цвет";
|
||||
labelAdvancedColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelAdvancedColor.DragDrop += LabelColor_DragDrop;
|
||||
labelAdvancedColor.DragEnter += LabelColor_DragDrop;
|
||||
//
|
||||
// labelSimpleColor
|
||||
//
|
||||
labelSimpleColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelSimpleColor.Location = new Point(14, 10);
|
||||
labelSimpleColor.Name = "labelSimpleColor";
|
||||
labelSimpleColor.Size = new Size(139, 23);
|
||||
labelSimpleColor.TabIndex = 2;
|
||||
labelSimpleColor.Text = "Цвет";
|
||||
labelSimpleColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelSimpleColor.DragDrop += LabelColor_DragDrop;
|
||||
labelSimpleColor.DragEnter += LabelColor_DragDrop;
|
||||
//
|
||||
// buttonAddObject
|
||||
//
|
||||
buttonAddObject.Location = new Point(496, 213);
|
||||
buttonAddObject.Name = "buttonAddObject";
|
||||
buttonAddObject.Size = new Size(139, 41);
|
||||
buttonAddObject.TabIndex = 3;
|
||||
buttonAddObject.Text = "Добавить";
|
||||
buttonAddObject.UseVisualStyleBackColor = true;
|
||||
buttonAddObject.Click += buttonAddObject_Click;
|
||||
//
|
||||
// buttonCancelObject
|
||||
//
|
||||
buttonCancelObject.Location = new Point(641, 213);
|
||||
buttonCancelObject.Name = "buttonCancelObject";
|
||||
buttonCancelObject.Size = new Size(139, 41);
|
||||
buttonCancelObject.TabIndex = 4;
|
||||
buttonCancelObject.Text = "Отмена";
|
||||
buttonCancelObject.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormLocomotiveConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 266);
|
||||
Controls.Add(buttonCancelObject);
|
||||
Controls.Add(buttonAddObject);
|
||||
Controls.Add(panelWithPictureBox);
|
||||
Controls.Add(groupBoxConfig);
|
||||
Name = "FormLocomotiveConfig";
|
||||
Text = "FormLocomotiveConfig";
|
||||
groupBoxConfig.ResumeLayout(false);
|
||||
groupBoxConfig.PerformLayout();
|
||||
groupBoxColors.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxLoco).EndInit();
|
||||
panelWithPictureBox.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxConfig;
|
||||
private Label labelWeight;
|
||||
private Label labelSpeed;
|
||||
private CheckBox checkBox3;
|
||||
private CheckBox checkBox2;
|
||||
private CheckBox checkBoxPantograph;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private GroupBox groupBoxColors;
|
||||
private Panel panelColorYellow;
|
||||
private Panel panelColorBlue;
|
||||
private Panel panelColorGreen;
|
||||
private Panel panelColorRed;
|
||||
private Panel panelColorPurple;
|
||||
private Panel panelColorBlack;
|
||||
private Panel panelColorGray;
|
||||
private Panel panelColorWhite;
|
||||
private Label labelAdvancedObject;
|
||||
private Label labelSimpleObject;
|
||||
private PictureBox pictureBoxLoco;
|
||||
private Panel panelWithPictureBox;
|
||||
private Label labelAdvancedColor;
|
||||
private Label labelSimpleColor;
|
||||
private Button buttonAddObject;
|
||||
private Button buttonCancelObject;
|
||||
private CheckBox checkBoxCompartment;
|
||||
}
|
||||
}
|
131
ElectricLocomotive/ElectricLocomotive/FormLocomotiveConfig.cs
Normal file
131
ElectricLocomotive/ElectricLocomotive/FormLocomotiveConfig.cs
Normal file
@ -0,0 +1,131 @@
|
||||
using Microsoft.VisualBasic.Devices;
|
||||
using ProjectElectricLocomotive.DrawingObjects;
|
||||
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 ProjectElectricLocomotive
|
||||
{
|
||||
public partial class FormLocomotiveConfig : Form
|
||||
{
|
||||
DrawingLocomotive? _locomotive = null;
|
||||
private event LocomotiveDelegate? EventAddLocomotive;
|
||||
|
||||
public FormLocomotiveConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelColorBlack.MouseDown += PanelColor_MouseDown;
|
||||
panelColorPurple.MouseDown += PanelColor_MouseDown;
|
||||
panelColorGray.MouseDown += PanelColor_MouseDown;
|
||||
panelColorGreen.MouseDown += PanelColor_MouseDown;
|
||||
panelColorRed.MouseDown += PanelColor_MouseDown;
|
||||
panelColorWhite.MouseDown += PanelColor_MouseDown;
|
||||
panelColorYellow.MouseDown += PanelColor_MouseDown;
|
||||
panelColorBlue.MouseDown += PanelColor_MouseDown;
|
||||
|
||||
buttonCancelObject.Click += (sender, e) => Close();
|
||||
|
||||
}
|
||||
public void AddEvent(LocomotiveDelegate ev)
|
||||
{
|
||||
if (EventAddLocomotive == null)
|
||||
{
|
||||
EventAddLocomotive = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddLocomotive += ev;
|
||||
}
|
||||
}
|
||||
private void DrawLocomotive()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxLoco.Width, pictureBoxLoco.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_locomotive?.SetPosition(5, 5);
|
||||
_locomotive?.DrawTransport(gr);
|
||||
pictureBoxLoco.Image = bmp;
|
||||
}
|
||||
|
||||
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":
|
||||
_locomotive = new DrawingLocomotive((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, pictureBoxLoco.Width,
|
||||
pictureBoxLoco.Height);
|
||||
break;
|
||||
case "labelModifiedObject":
|
||||
_locomotive = new DrawingElectricLocomotive((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxPantograph.Checked,
|
||||
checkBoxCompartment.Checked, pictureBoxLoco.Width,
|
||||
pictureBoxLoco.Height);
|
||||
break;
|
||||
}
|
||||
DrawLocomotive();
|
||||
}
|
||||
|
||||
private void buttonAddObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddLocomotive?.Invoke(_locomotive);
|
||||
Close();
|
||||
}
|
||||
|
||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void LabelColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
((Label)sender).BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||
switch (((Label)sender).Name)
|
||||
{
|
||||
case "labelColor":
|
||||
_locomotive.SetColor((Color)e.Data.GetData(typeof(Color)));
|
||||
break;
|
||||
case "labelAddColor":
|
||||
if (_locomotive is not DrawingLocomotive) return;
|
||||
else
|
||||
{
|
||||
(_locomotive as DrawingElectricLocomotive).SetAddColor((Color)e.Data.GetData(typeof(Color)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
DrawLocomotive();
|
||||
}
|
||||
|
||||
private void LabelColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
ElectricLocomotive/ElectricLocomotive/FormLocomotiveConfig.resx
Normal file
120
ElectricLocomotive/ElectricLocomotive/FormLocomotiveConfig.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>
|
11
ElectricLocomotive/ElectricLocomotive/LocomotiveDelegate.cs
Normal file
11
ElectricLocomotive/ElectricLocomotive/LocomotiveDelegate.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectElectricLocomotive.DrawingObjects;
|
||||
|
||||
namespace ProjectElectricLocomotive
|
||||
{
|
||||
public delegate void LocomotiveDelegate(DrawingLocomotive locomotive);
|
||||
}
|
Loading…
Reference in New Issue
Block a user