Лабораторная работа 5
This commit is contained in:
parent
c1f6009f6e
commit
d41a44ec2c
@ -183,6 +183,10 @@ namespace Monorail
|
||||
_startPosY = _pictureHeight.Value - _locomotiveHeight;
|
||||
}
|
||||
}
|
||||
public void SetBodyColor(Color color)
|
||||
{
|
||||
(Locomotive as EntityLocomotive).setColor(color);
|
||||
}
|
||||
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
|
@ -33,7 +33,6 @@ namespace Monorail
|
||||
}
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
Brush dopBrush = new SolidBrush(monorailLocomotive.DopColor);
|
||||
|
||||
base.DrawTransport(g);
|
||||
|
||||
@ -48,12 +47,18 @@ namespace Monorail
|
||||
|
||||
if (monorailLocomotive.Monorail)
|
||||
{
|
||||
Brush brBlack = new SolidBrush(Color.Black);
|
||||
|
||||
Brush dopBrush = new SolidBrush(monorailLocomotive.DopColor);
|
||||
//монорельса
|
||||
g.FillRectangle(brBlack, _startPosX + 10, _startPosY + 45, 130, 20);
|
||||
g.FillRectangle(dopBrush, _startPosX + 10, _startPosY + 45, 130, 20);
|
||||
g.DrawRectangle(pen, _startPosX + 10, _startPosY + 45, 130, 20);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetExtraColor(Color color)
|
||||
{
|
||||
(Locomotive as EntityMonorailLocomotive).DopColor = color;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -10,16 +10,19 @@ namespace Monorail
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
public float Weight { get; private set; }
|
||||
public Color BodyColor { get; private set; }
|
||||
public Color BodyColor { get; set; }
|
||||
public float Step => Speed * 100 / Weight;
|
||||
public EntityLocomotive(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Random rnd = new();
|
||||
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
||||
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
|
||||
Random rnd = new Random();
|
||||
Speed = speed <= 0 ? rnd.Next(40, 120) : speed;
|
||||
Weight = weight <= 0 ? rnd.Next(150, 200) : weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
|
||||
|
||||
public void setColor(Color color)
|
||||
{
|
||||
BodyColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ namespace Monorail
|
||||
{
|
||||
internal class EntityMonorailLocomotive : EntityLocomotive
|
||||
{
|
||||
public Color DopColor { get; private set; }
|
||||
public Color DopColor { get; set; }
|
||||
public bool Monorail { get; private set; }
|
||||
public bool DopCabin { get; private set; }
|
||||
|
||||
@ -22,5 +22,6 @@ namespace Monorail
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
365
Monorail/Monorail/FormLocomotiveConfig.Designer.cs
generated
Normal file
365
Monorail/Monorail/FormLocomotiveConfig.Designer.cs
generated
Normal file
@ -0,0 +1,365 @@
|
||||
namespace Monorail
|
||||
{
|
||||
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();
|
||||
labelModifiedObject = new Label();
|
||||
labelSimpleObject = new Label();
|
||||
groupBoxColors = 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();
|
||||
checkBoxMonorail = new CheckBox();
|
||||
checkBoxDopCabin = new CheckBox();
|
||||
numericUpDownWeight = new NumericUpDown();
|
||||
numericUpDownSpeed = new NumericUpDown();
|
||||
labelWeight = new Label();
|
||||
labelSpeed = new Label();
|
||||
pictureBoxObject = new PictureBox();
|
||||
panelObject = new Panel();
|
||||
labelDopColor = new Label();
|
||||
labelBaseColor = new Label();
|
||||
buttonOk = new Button();
|
||||
buttonCancel = new Button();
|
||||
groupBoxConfig.SuspendLayout();
|
||||
groupBoxColors.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||
panelObject.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBoxConfig
|
||||
//
|
||||
groupBoxConfig.Controls.Add(labelModifiedObject);
|
||||
groupBoxConfig.Controls.Add(labelSimpleObject);
|
||||
groupBoxConfig.Controls.Add(groupBoxColors);
|
||||
groupBoxConfig.Controls.Add(checkBoxMonorail);
|
||||
groupBoxConfig.Controls.Add(checkBoxDopCabin);
|
||||
groupBoxConfig.Controls.Add(numericUpDownWeight);
|
||||
groupBoxConfig.Controls.Add(numericUpDownSpeed);
|
||||
groupBoxConfig.Controls.Add(labelWeight);
|
||||
groupBoxConfig.Controls.Add(labelSpeed);
|
||||
groupBoxConfig.Location = new Point(12, 29);
|
||||
groupBoxConfig.Name = "groupBoxConfig";
|
||||
groupBoxConfig.Size = new Size(479, 218);
|
||||
groupBoxConfig.TabIndex = 0;
|
||||
groupBoxConfig.TabStop = false;
|
||||
groupBoxConfig.Text = "Параметры:";
|
||||
//
|
||||
// labelModifiedObject
|
||||
//
|
||||
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelModifiedObject.Location = new Point(365, 152);
|
||||
labelModifiedObject.Name = "labelModifiedObject";
|
||||
labelModifiedObject.Size = new Size(90, 45);
|
||||
labelModifiedObject.TabIndex = 8;
|
||||
labelModifiedObject.Text = "Продвинутый";
|
||||
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelSimpleObject.Location = new Point(245, 152);
|
||||
labelSimpleObject.Name = "labelSimpleObject";
|
||||
labelSimpleObject.Size = new Size(90, 45);
|
||||
labelSimpleObject.TabIndex = 7;
|
||||
labelSimpleObject.Text = "Простой";
|
||||
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// groupBoxColors
|
||||
//
|
||||
groupBoxColors.Controls.Add(panelPurple);
|
||||
groupBoxColors.Controls.Add(panelBlack);
|
||||
groupBoxColors.Controls.Add(panelGray);
|
||||
groupBoxColors.Controls.Add(panelWhite);
|
||||
groupBoxColors.Controls.Add(panelYellow);
|
||||
groupBoxColors.Controls.Add(panelBlue);
|
||||
groupBoxColors.Controls.Add(panelGreen);
|
||||
groupBoxColors.Controls.Add(panelRed);
|
||||
groupBoxColors.Location = new Point(245, 22);
|
||||
groupBoxColors.Name = "groupBoxColors";
|
||||
groupBoxColors.Size = new Size(210, 116);
|
||||
groupBoxColors.TabIndex = 6;
|
||||
groupBoxColors.TabStop = false;
|
||||
groupBoxColors.Text = "Цвета:";
|
||||
//
|
||||
// panelPurple
|
||||
//
|
||||
panelPurple.BackColor = Color.Purple;
|
||||
panelPurple.Location = new Point(153, 63);
|
||||
panelPurple.Name = "panelPurple";
|
||||
panelPurple.Size = new Size(40, 35);
|
||||
panelPurple.TabIndex = 7;
|
||||
panelPurple.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelBlack
|
||||
//
|
||||
panelBlack.BackColor = Color.Black;
|
||||
panelBlack.Location = new Point(107, 63);
|
||||
panelBlack.Name = "panelBlack";
|
||||
panelBlack.Size = new Size(40, 35);
|
||||
panelBlack.TabIndex = 6;
|
||||
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelGray
|
||||
//
|
||||
panelGray.BackColor = Color.Gray;
|
||||
panelGray.Location = new Point(61, 63);
|
||||
panelGray.Name = "panelGray";
|
||||
panelGray.Size = new Size(40, 35);
|
||||
panelGray.TabIndex = 5;
|
||||
panelGray.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelWhite
|
||||
//
|
||||
panelWhite.BackColor = Color.White;
|
||||
panelWhite.Location = new Point(15, 63);
|
||||
panelWhite.Name = "panelWhite";
|
||||
panelWhite.Size = new Size(40, 35);
|
||||
panelWhite.TabIndex = 4;
|
||||
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
panelYellow.BackColor = Color.Yellow;
|
||||
panelYellow.Location = new Point(153, 22);
|
||||
panelYellow.Name = "panelYellow";
|
||||
panelYellow.Size = new Size(40, 35);
|
||||
panelYellow.TabIndex = 3;
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
panelBlue.BackColor = Color.Blue;
|
||||
panelBlue.Location = new Point(107, 22);
|
||||
panelBlue.Name = "panelBlue";
|
||||
panelBlue.Size = new Size(40, 35);
|
||||
panelBlue.TabIndex = 2;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
panelGreen.BackColor = Color.Green;
|
||||
panelGreen.Location = new Point(61, 22);
|
||||
panelGreen.Name = "panelGreen";
|
||||
panelGreen.Size = new Size(40, 35);
|
||||
panelGreen.TabIndex = 1;
|
||||
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
panelRed.BackColor = Color.Red;
|
||||
panelRed.Location = new Point(15, 22);
|
||||
panelRed.Name = "panelRed";
|
||||
panelRed.Size = new Size(40, 35);
|
||||
panelRed.TabIndex = 0;
|
||||
panelRed.MouseDown += PanelColor_MouseDown;
|
||||
//
|
||||
// checkBoxMonorail
|
||||
//
|
||||
checkBoxMonorail.AutoSize = true;
|
||||
checkBoxMonorail.Location = new Point(18, 144);
|
||||
checkBoxMonorail.Name = "checkBoxMonorail";
|
||||
checkBoxMonorail.Size = new Size(194, 19);
|
||||
checkBoxMonorail.TabIndex = 5;
|
||||
checkBoxMonorail.Text = "Признак наличия монорельса";
|
||||
checkBoxMonorail.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxDopCabin
|
||||
//
|
||||
checkBoxDopCabin.AutoSize = true;
|
||||
checkBoxDopCabin.Location = new Point(18, 119);
|
||||
checkBoxDopCabin.Name = "checkBoxDopCabin";
|
||||
checkBoxDopCabin.Size = new Size(208, 19);
|
||||
checkBoxDopCabin.TabIndex = 4;
|
||||
checkBoxDopCabin.Text = "Признак наличия задней кабины";
|
||||
checkBoxDopCabin.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
numericUpDownWeight.Location = new Point(83, 70);
|
||||
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(83, 34);
|
||||
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(18, 72);
|
||||
labelWeight.Name = "labelWeight";
|
||||
labelWeight.Size = new Size(26, 15);
|
||||
labelWeight.TabIndex = 1;
|
||||
labelWeight.Text = "Вес";
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
labelSpeed.AutoSize = true;
|
||||
labelSpeed.Location = new Point(18, 36);
|
||||
labelSpeed.Name = "labelSpeed";
|
||||
labelSpeed.Size = new Size(59, 15);
|
||||
labelSpeed.TabIndex = 0;
|
||||
labelSpeed.Text = "Скорость";
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
pictureBoxObject.Location = new Point(14, 65);
|
||||
pictureBoxObject.Name = "pictureBoxObject";
|
||||
pictureBoxObject.Size = new Size(186, 125);
|
||||
pictureBoxObject.TabIndex = 1;
|
||||
pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// panelObject
|
||||
//
|
||||
panelObject.AllowDrop = true;
|
||||
panelObject.Controls.Add(labelDopColor);
|
||||
panelObject.Controls.Add(labelBaseColor);
|
||||
panelObject.Controls.Add(pictureBoxObject);
|
||||
panelObject.Location = new Point(520, 15);
|
||||
panelObject.Name = "panelObject";
|
||||
panelObject.Size = new Size(215, 211);
|
||||
panelObject.TabIndex = 2;
|
||||
panelObject.DragDrop += panelObject_DragDrop;
|
||||
panelObject.DragEnter += panelObject_DragEnter;
|
||||
//
|
||||
// labelDopColor
|
||||
//
|
||||
labelDopColor.AllowDrop = true;
|
||||
labelDopColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelDopColor.Location = new Point(110, 14);
|
||||
labelDopColor.Name = "labelDopColor";
|
||||
labelDopColor.Size = new Size(90, 45);
|
||||
labelDopColor.TabIndex = 3;
|
||||
labelDopColor.Text = "Доп. Цвет";
|
||||
labelDopColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelDopColor.DragDrop += LabelDopColor_DragDrop;
|
||||
labelDopColor.DragEnter += LabelDopColor_DragEnter;
|
||||
//
|
||||
// labelBaseColor
|
||||
//
|
||||
labelBaseColor.AllowDrop = true;
|
||||
labelBaseColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelBaseColor.Location = new Point(14, 14);
|
||||
labelBaseColor.Name = "labelBaseColor";
|
||||
labelBaseColor.Size = new Size(90, 45);
|
||||
labelBaseColor.TabIndex = 2;
|
||||
labelBaseColor.Text = "Цвет";
|
||||
labelBaseColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelBaseColor.DragDrop += LabelBaseColor_DragDrop;
|
||||
labelBaseColor.DragEnter += LabelBaseColor_DragEnter;
|
||||
//
|
||||
// buttonOk
|
||||
//
|
||||
buttonOk.Location = new Point(520, 242);
|
||||
buttonOk.Name = "buttonOk";
|
||||
buttonOk.Size = new Size(90, 30);
|
||||
buttonOk.TabIndex = 3;
|
||||
buttonOk.Text = "Добавить";
|
||||
buttonOk.UseVisualStyleBackColor = true;
|
||||
buttonOk.Click += buttonOk_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(645, 242);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(90, 30);
|
||||
buttonCancel.TabIndex = 4;
|
||||
buttonCancel.Text = "Отменить";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// FormLocomotiveConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 299);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonOk);
|
||||
Controls.Add(panelObject);
|
||||
Controls.Add(groupBoxConfig);
|
||||
Name = "FormLocomotiveConfig";
|
||||
Text = "Создание объекта";
|
||||
groupBoxConfig.ResumeLayout(false);
|
||||
groupBoxConfig.PerformLayout();
|
||||
groupBoxColors.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||
panelObject.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxConfig;
|
||||
private CheckBox checkBoxMonorail;
|
||||
private CheckBox checkBoxDopCabin;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private Label labelWeight;
|
||||
private Label labelSpeed;
|
||||
private GroupBox groupBoxColors;
|
||||
private Panel panelPurple;
|
||||
private Panel panelBlack;
|
||||
private Panel panelGray;
|
||||
private Panel panelWhite;
|
||||
private Panel panelYellow;
|
||||
private Panel panelBlue;
|
||||
private Panel panelGreen;
|
||||
private Panel panelRed;
|
||||
private Label labelModifiedObject;
|
||||
private Label labelSimpleObject;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Panel panelObject;
|
||||
private Label labelDopColor;
|
||||
private Label labelBaseColor;
|
||||
private Button buttonOk;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
145
Monorail/Monorail/FormLocomotiveConfig.cs
Normal file
145
Monorail/Monorail/FormLocomotiveConfig.cs
Normal file
@ -0,0 +1,145 @@
|
||||
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 Monorail
|
||||
{
|
||||
public partial class FormLocomotiveConfig : Form
|
||||
{
|
||||
private event Action<DrawingLocomotive> EventAddLocomotive;
|
||||
DrawingLocomotive _locomotive = null;
|
||||
public FormLocomotiveConfig()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
public void AddEvent(Action<DrawingLocomotive> ev)
|
||||
{
|
||||
if (EventAddLocomotive == null)
|
||||
{
|
||||
EventAddLocomotive = new Action<DrawingLocomotive>(ev);
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddLocomotive += ev;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawLocomotive()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_locomotive?.SetPosition(5, 5, pictureBoxObject.Width,
|
||||
pictureBoxObject.Height);
|
||||
_locomotive?.DrawTransport(gr);
|
||||
pictureBoxObject.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))
|
||||
{
|
||||
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);
|
||||
}
|
||||
break;
|
||||
case "labelModifiedObject":
|
||||
{
|
||||
_locomotive = new DrawingMonorailLocomotive((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxMonorail.Checked, checkBoxDopCabin.Checked);
|
||||
}
|
||||
break;
|
||||
}
|
||||
DrawLocomotive();
|
||||
}
|
||||
|
||||
private void buttonOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddLocomotive?.Invoke(_locomotive);
|
||||
Close();
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
_locomotive.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||
DrawLocomotive();
|
||||
}
|
||||
|
||||
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_locomotive is not DrawingMonorailLocomotive HardLocomotive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
HardLocomotive.SetExtraColor((Color)e.Data.GetData(typeof(Color)));
|
||||
DrawLocomotive();
|
||||
}
|
||||
|
||||
private void LabelBaseColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void LabelDopColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
60
Monorail/Monorail/FormLocomotiveConfig.resx
Normal file
60
Monorail/Monorail/FormLocomotiveConfig.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
@ -87,25 +87,29 @@ namespace Monorail
|
||||
}
|
||||
|
||||
private void ButtonAddLocomotive_Click(object sender, EventArgs e)
|
||||
{
|
||||
var FormLocmotiveConfig = new FormLocomotiveConfig();
|
||||
FormLocmotiveConfig.AddEvent(new(AddLocomotive));
|
||||
FormLocmotiveConfig.Show();
|
||||
}
|
||||
|
||||
public void AddLocomotive(DrawingLocomotive locomotive)
|
||||
{
|
||||
if (listBoxMaps.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormLocomotive form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawingObjectLocomotive(locomotive) != -1)
|
||||
{
|
||||
DrawingObjectLocomotive locomotive = new(form.SelectedLocomotive);
|
||||
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + locomotive >= 0)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxLocomotive.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
MessageBox.Show("Object is added");
|
||||
pictureBoxLocomotive.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Unable to add object");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ButtonRemoveLocomotive_Click(object sender, EventArgs e)
|
||||
|
Loading…
x
Reference in New Issue
Block a user