I think it's done ???
This commit is contained in:
parent
a1fb13fe90
commit
9e78c3a41b
@ -19,6 +19,11 @@ namespace Monorail.DrawningObjects
|
||||
addWheelsNumb, additionalColor, secondCabine, magniteRail);
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeAddColor(Color col)
|
||||
{
|
||||
((EntityLocomotive)EntityMonorail).AdditionalColor = col;
|
||||
}
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
base.DrawTransport(g);
|
||||
|
@ -55,17 +55,19 @@ namespace Monorail.DrawningObjects
|
||||
wheelSz = _monoRailHeight - _monoRailHeight * 7 / 10;
|
||||
EntityMonorail = new EntityMonorail(speed, weight, bodyColor, wheelColor, tireColor);
|
||||
}
|
||||
|
||||
public void ChangeColor(Color col)
|
||||
{
|
||||
if (EntityMonorail == null)
|
||||
return;
|
||||
EntityMonorail.BodyColor = col;
|
||||
}
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (EntityMonorail == null)
|
||||
return;
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
if(x + _monoRailWidth >= _pictureWidth || y + _monoRailHeight>= _pictureHeight)
|
||||
{
|
||||
_startPosX = 1;
|
||||
_startPosY = 1;
|
||||
}
|
||||
}
|
||||
public IMoveableObject GetMoveableObject => new
|
||||
DrawningObjectMonorail(this);
|
||||
|
@ -9,7 +9,7 @@ namespace Monorail.Entities
|
||||
{
|
||||
public class EntityLocomotive : EntityMonorail
|
||||
{
|
||||
public Color AdditionalColor { get; private set; }
|
||||
public Color AdditionalColor { get; set; }
|
||||
public int AddWheelsNumb { get; private set; }
|
||||
|
||||
public bool SecondCabine { get; private set; }
|
||||
|
@ -12,7 +12,7 @@ namespace Monorail.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 Color WheelColor { get; private set; }
|
||||
|
||||
public Color TireColor { get; private set; }
|
||||
|
@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics.Metrics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -58,10 +59,12 @@ namespace Monorail
|
||||
{
|
||||
return;
|
||||
}
|
||||
MonorailForm form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
FormMonorailConfig form = new();
|
||||
form.Show();
|
||||
form.EventAddMonorail += (m) =>
|
||||
{
|
||||
if (obj + form.SelectedMonorail)
|
||||
bool q = (obj + m);
|
||||
if (q)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowMonorails();
|
||||
@ -70,8 +73,8 @@ namespace Monorail
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteMonorailButton_Click(object sender, EventArgs e)
|
||||
|
366
Monorail/Monorail/FormMonorailConfig.Designer.cs
generated
Normal file
366
Monorail/Monorail/FormMonorailConfig.Designer.cs
generated
Normal file
@ -0,0 +1,366 @@
|
||||
namespace Monorail
|
||||
{
|
||||
partial class FormMonorailConfig
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
configGroupBox = new System.Windows.Forms.GroupBox();
|
||||
colorGroupBox = new System.Windows.Forms.GroupBox();
|
||||
yellowPanel = new System.Windows.Forms.Panel();
|
||||
bluePanel = new System.Windows.Forms.Panel();
|
||||
greenPanel = new System.Windows.Forms.Panel();
|
||||
purplePanel = new System.Windows.Forms.Panel();
|
||||
blackPanel = new System.Windows.Forms.Panel();
|
||||
greyPanel = new System.Windows.Forms.Panel();
|
||||
whitePanel = new System.Windows.Forms.Panel();
|
||||
redPanel = new System.Windows.Forms.Panel();
|
||||
locomotiveLabel = new System.Windows.Forms.Label();
|
||||
monorailLabel = new System.Windows.Forms.Label();
|
||||
checkMagniteRail = new System.Windows.Forms.CheckBox();
|
||||
checkSecondCabine = new System.Windows.Forms.CheckBox();
|
||||
numericWeight = new System.Windows.Forms.NumericUpDown();
|
||||
numericSpeed = new System.Windows.Forms.NumericUpDown();
|
||||
weightLabel = new System.Windows.Forms.Label();
|
||||
speedLabel = new System.Windows.Forms.Label();
|
||||
allowPanel = new System.Windows.Forms.Panel();
|
||||
addColorLabel = new System.Windows.Forms.Label();
|
||||
pictureBox = new System.Windows.Forms.PictureBox();
|
||||
colorLabel = new System.Windows.Forms.Label();
|
||||
addButton = new System.Windows.Forms.Button();
|
||||
cancelButton = new System.Windows.Forms.Button();
|
||||
configGroupBox.SuspendLayout();
|
||||
colorGroupBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericWeight).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericSpeed).BeginInit();
|
||||
allowPanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// configGroupBox
|
||||
//
|
||||
configGroupBox.Controls.Add(colorGroupBox);
|
||||
configGroupBox.Controls.Add(locomotiveLabel);
|
||||
configGroupBox.Controls.Add(monorailLabel);
|
||||
configGroupBox.Controls.Add(checkMagniteRail);
|
||||
configGroupBox.Controls.Add(checkSecondCabine);
|
||||
configGroupBox.Controls.Add(numericWeight);
|
||||
configGroupBox.Controls.Add(numericSpeed);
|
||||
configGroupBox.Controls.Add(weightLabel);
|
||||
configGroupBox.Controls.Add(speedLabel);
|
||||
configGroupBox.Location = new System.Drawing.Point(12, 12);
|
||||
configGroupBox.Name = "configGroupBox";
|
||||
configGroupBox.Size = new System.Drawing.Size(511, 279);
|
||||
configGroupBox.TabIndex = 0;
|
||||
configGroupBox.TabStop = false;
|
||||
configGroupBox.Text = "Параметры";
|
||||
//
|
||||
// colorGroupBox
|
||||
//
|
||||
colorGroupBox.Controls.Add(yellowPanel);
|
||||
colorGroupBox.Controls.Add(bluePanel);
|
||||
colorGroupBox.Controls.Add(greenPanel);
|
||||
colorGroupBox.Controls.Add(purplePanel);
|
||||
colorGroupBox.Controls.Add(blackPanel);
|
||||
colorGroupBox.Controls.Add(greyPanel);
|
||||
colorGroupBox.Controls.Add(whitePanel);
|
||||
colorGroupBox.Controls.Add(redPanel);
|
||||
colorGroupBox.Location = new System.Drawing.Point(171, 23);
|
||||
colorGroupBox.Name = "colorGroupBox";
|
||||
colorGroupBox.Size = new System.Drawing.Size(234, 143);
|
||||
colorGroupBox.TabIndex = 7;
|
||||
colorGroupBox.TabStop = false;
|
||||
colorGroupBox.Text = "Цвета";
|
||||
//
|
||||
// yellowPanel
|
||||
//
|
||||
yellowPanel.AllowDrop = true;
|
||||
yellowPanel.BackColor = System.Drawing.Color.Yellow;
|
||||
yellowPanel.Location = new System.Drawing.Point(174, 27);
|
||||
yellowPanel.Name = "yellowPanel";
|
||||
yellowPanel.Size = new System.Drawing.Size(50, 50);
|
||||
yellowPanel.TabIndex = 3;
|
||||
//
|
||||
// bluePanel
|
||||
//
|
||||
bluePanel.AllowDrop = true;
|
||||
bluePanel.BackColor = System.Drawing.Color.Blue;
|
||||
bluePanel.Location = new System.Drawing.Point(118, 27);
|
||||
bluePanel.Name = "bluePanel";
|
||||
bluePanel.Size = new System.Drawing.Size(50, 50);
|
||||
bluePanel.TabIndex = 2;
|
||||
//
|
||||
// greenPanel
|
||||
//
|
||||
greenPanel.AllowDrop = true;
|
||||
greenPanel.BackColor = System.Drawing.Color.Green;
|
||||
greenPanel.Location = new System.Drawing.Point(62, 27);
|
||||
greenPanel.Name = "greenPanel";
|
||||
greenPanel.Size = new System.Drawing.Size(50, 50);
|
||||
greenPanel.TabIndex = 1;
|
||||
//
|
||||
// purplePanel
|
||||
//
|
||||
purplePanel.AllowDrop = true;
|
||||
purplePanel.BackColor = System.Drawing.Color.Purple;
|
||||
purplePanel.Location = new System.Drawing.Point(174, 82);
|
||||
purplePanel.Name = "purplePanel";
|
||||
purplePanel.Size = new System.Drawing.Size(50, 50);
|
||||
purplePanel.TabIndex = 3;
|
||||
//
|
||||
// blackPanel
|
||||
//
|
||||
blackPanel.AllowDrop = true;
|
||||
blackPanel.BackColor = System.Drawing.Color.Black;
|
||||
blackPanel.Location = new System.Drawing.Point(118, 83);
|
||||
blackPanel.Name = "blackPanel";
|
||||
blackPanel.Size = new System.Drawing.Size(50, 50);
|
||||
blackPanel.TabIndex = 2;
|
||||
//
|
||||
// greyPanel
|
||||
//
|
||||
greyPanel.AllowDrop = true;
|
||||
greyPanel.BackColor = System.Drawing.Color.Silver;
|
||||
greyPanel.Location = new System.Drawing.Point(62, 83);
|
||||
greyPanel.Name = "greyPanel";
|
||||
greyPanel.Size = new System.Drawing.Size(50, 50);
|
||||
greyPanel.TabIndex = 1;
|
||||
//
|
||||
// whitePanel
|
||||
//
|
||||
whitePanel.AllowDrop = true;
|
||||
whitePanel.BackColor = System.Drawing.Color.White;
|
||||
whitePanel.Location = new System.Drawing.Point(6, 83);
|
||||
whitePanel.Name = "whitePanel";
|
||||
whitePanel.Size = new System.Drawing.Size(50, 50);
|
||||
whitePanel.TabIndex = 1;
|
||||
//
|
||||
// redPanel
|
||||
//
|
||||
redPanel.AllowDrop = true;
|
||||
redPanel.BackColor = System.Drawing.Color.Red;
|
||||
redPanel.Location = new System.Drawing.Point(6, 27);
|
||||
redPanel.Name = "redPanel";
|
||||
redPanel.Size = new System.Drawing.Size(50, 50);
|
||||
redPanel.TabIndex = 0;
|
||||
//
|
||||
// locomotiveLabel
|
||||
//
|
||||
locomotiveLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
locomotiveLabel.Location = new System.Drawing.Point(297, 169);
|
||||
locomotiveLabel.Name = "locomotiveLabel";
|
||||
locomotiveLabel.Size = new System.Drawing.Size(120, 50);
|
||||
locomotiveLabel.TabIndex = 9;
|
||||
locomotiveLabel.Text = "Продвинутый";
|
||||
locomotiveLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// monorailLabel
|
||||
//
|
||||
monorailLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
monorailLabel.Location = new System.Drawing.Point(171, 169);
|
||||
monorailLabel.Name = "monorailLabel";
|
||||
monorailLabel.Size = new System.Drawing.Size(120, 50);
|
||||
monorailLabel.TabIndex = 8;
|
||||
monorailLabel.Text = "Простой";
|
||||
monorailLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// checkMagniteRail
|
||||
//
|
||||
checkMagniteRail.AutoSize = true;
|
||||
checkMagniteRail.Location = new System.Drawing.Point(6, 162);
|
||||
checkMagniteRail.Name = "checkMagniteRail";
|
||||
checkMagniteRail.Size = new System.Drawing.Size(145, 24);
|
||||
checkMagniteRail.TabIndex = 5;
|
||||
checkMagniteRail.Text = "наличие рельсы";
|
||||
checkMagniteRail.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkSecondCabine
|
||||
//
|
||||
checkSecondCabine.AutoSize = true;
|
||||
checkSecondCabine.Location = new System.Drawing.Point(6, 132);
|
||||
checkSecondCabine.Name = "checkSecondCabine";
|
||||
checkSecondCabine.Size = new System.Drawing.Size(159, 24);
|
||||
checkSecondCabine.TabIndex = 4;
|
||||
checkSecondCabine.Text = "наличие 2 кабины";
|
||||
checkSecondCabine.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericWeight
|
||||
//
|
||||
numericWeight.Location = new System.Drawing.Point(6, 99);
|
||||
numericWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||
numericWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
numericWeight.Name = "numericWeight";
|
||||
numericWeight.Size = new System.Drawing.Size(150, 27);
|
||||
numericWeight.TabIndex = 3;
|
||||
numericWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// numericSpeed
|
||||
//
|
||||
numericSpeed.Location = new System.Drawing.Point(6, 46);
|
||||
numericSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||
numericSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
numericSpeed.Name = "numericSpeed";
|
||||
numericSpeed.Size = new System.Drawing.Size(150, 27);
|
||||
numericSpeed.TabIndex = 2;
|
||||
numericSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// weightLabel
|
||||
//
|
||||
weightLabel.AutoSize = true;
|
||||
weightLabel.Location = new System.Drawing.Point(6, 76);
|
||||
weightLabel.Name = "weightLabel";
|
||||
weightLabel.Size = new System.Drawing.Size(33, 20);
|
||||
weightLabel.TabIndex = 1;
|
||||
weightLabel.Text = "Вес";
|
||||
//
|
||||
// speedLabel
|
||||
//
|
||||
speedLabel.AutoSize = true;
|
||||
speedLabel.Location = new System.Drawing.Point(6, 23);
|
||||
speedLabel.Name = "speedLabel";
|
||||
speedLabel.Size = new System.Drawing.Size(73, 20);
|
||||
speedLabel.TabIndex = 0;
|
||||
speedLabel.Text = "Скорость";
|
||||
//
|
||||
// allowPanel
|
||||
//
|
||||
allowPanel.AllowDrop = true;
|
||||
allowPanel.Controls.Add(addColorLabel);
|
||||
allowPanel.Controls.Add(pictureBox);
|
||||
allowPanel.Controls.Add(colorLabel);
|
||||
allowPanel.Location = new System.Drawing.Point(538, 12);
|
||||
allowPanel.Name = "allowPanel";
|
||||
allowPanel.Size = new System.Drawing.Size(250, 247);
|
||||
allowPanel.TabIndex = 1;
|
||||
allowPanel.DragDrop += allowPanel_DragDrop;
|
||||
allowPanel.DragEnter += allowPanel_DragEnter;
|
||||
//
|
||||
// addColorLabel
|
||||
//
|
||||
addColorLabel.AllowDrop = true;
|
||||
addColorLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
addColorLabel.Location = new System.Drawing.Point(141, 10);
|
||||
addColorLabel.Name = "addColorLabel";
|
||||
addColorLabel.Size = new System.Drawing.Size(104, 33);
|
||||
addColorLabel.TabIndex = 2;
|
||||
addColorLabel.Text = "Доп. цвет";
|
||||
addColorLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
addColorLabel.DragDrop += addColorLabel_DragDrop;
|
||||
addColorLabel.DragEnter += addColorLabel_DragEnter;
|
||||
//
|
||||
// pictureBox
|
||||
//
|
||||
pictureBox.Location = new System.Drawing.Point(17, 50);
|
||||
pictureBox.Name = "pictureBox";
|
||||
pictureBox.Size = new System.Drawing.Size(218, 190);
|
||||
pictureBox.TabIndex = 0;
|
||||
pictureBox.TabStop = false;
|
||||
//
|
||||
// colorLabel
|
||||
//
|
||||
colorLabel.AllowDrop = true;
|
||||
colorLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
colorLabel.Location = new System.Drawing.Point(17, 10);
|
||||
colorLabel.Name = "colorLabel";
|
||||
colorLabel.Size = new System.Drawing.Size(104, 33);
|
||||
colorLabel.TabIndex = 1;
|
||||
colorLabel.Text = "Цвет";
|
||||
colorLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
colorLabel.DragDrop += colorLabel_DragDrop;
|
||||
colorLabel.DragEnter += colorLabel_DragEnter;
|
||||
//
|
||||
// addButton
|
||||
//
|
||||
addButton.Location = new System.Drawing.Point(555, 262);
|
||||
addButton.Name = "addButton";
|
||||
addButton.Size = new System.Drawing.Size(94, 29);
|
||||
addButton.TabIndex = 2;
|
||||
addButton.Text = "Добавить";
|
||||
addButton.UseVisualStyleBackColor = true;
|
||||
addButton.Click += addButton_Click;
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
cancelButton.Location = new System.Drawing.Point(679, 262);
|
||||
cancelButton.Name = "cancelButton";
|
||||
cancelButton.Size = new System.Drawing.Size(94, 29);
|
||||
cancelButton.TabIndex = 3;
|
||||
cancelButton.Text = "Отменить";
|
||||
cancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormMonorailConfig
|
||||
//
|
||||
AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
ClientSize = new System.Drawing.Size(800, 303);
|
||||
Controls.Add(cancelButton);
|
||||
Controls.Add(addButton);
|
||||
Controls.Add(allowPanel);
|
||||
Controls.Add(configGroupBox);
|
||||
Name = "FormMonorailConfig";
|
||||
Text = "FormMonorailConfig";
|
||||
configGroupBox.ResumeLayout(false);
|
||||
configGroupBox.PerformLayout();
|
||||
colorGroupBox.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)numericWeight).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericSpeed).EndInit();
|
||||
allowPanel.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox configGroupBox;
|
||||
private System.Windows.Forms.CheckBox checkSecondCabine;
|
||||
private System.Windows.Forms.NumericUpDown numericWeight;
|
||||
private System.Windows.Forms.NumericUpDown numericSpeed;
|
||||
private System.Windows.Forms.Label weightLabel;
|
||||
private System.Windows.Forms.Label speedLabel;
|
||||
private System.Windows.Forms.CheckBox checkMagniteRail;
|
||||
private System.Windows.Forms.GroupBox colorGroupBox;
|
||||
private System.Windows.Forms.Panel panel5;
|
||||
private System.Windows.Forms.Panel panel4;
|
||||
private System.Windows.Forms.Panel panel3;
|
||||
private System.Windows.Forms.Panel panel2;
|
||||
private System.Windows.Forms.Panel redPanel;
|
||||
private System.Windows.Forms.Panel purplePanel;
|
||||
private System.Windows.Forms.Panel blackPanel;
|
||||
private System.Windows.Forms.Panel greyPanel;
|
||||
private System.Windows.Forms.Panel whitePanel;
|
||||
private System.Windows.Forms.Label locomotiveLabel;
|
||||
private System.Windows.Forms.Label monorailLabel;
|
||||
private System.Windows.Forms.Panel yellowPanel;
|
||||
private System.Windows.Forms.Panel bluePanel;
|
||||
private System.Windows.Forms.Panel greenPanel;
|
||||
private System.Windows.Forms.Panel allowPanel;
|
||||
private System.Windows.Forms.PictureBox pictureBox;
|
||||
private System.Windows.Forms.Label addColorLabel;
|
||||
private System.Windows.Forms.Label colorLabel;
|
||||
private System.Windows.Forms.Button addButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
}
|
||||
}
|
157
Monorail/Monorail/FormMonorailConfig.cs
Normal file
157
Monorail/Monorail/FormMonorailConfig.cs
Normal file
@ -0,0 +1,157 @@
|
||||
using Monorail.DrawningObjects;
|
||||
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 FormMonorailConfig : Form
|
||||
{
|
||||
DrawningMonorail? _monorail = null;
|
||||
|
||||
public event MonorailDelegate? EventAddMonorail;
|
||||
|
||||
DrawningMonorail SelectedMonorail(DrawningMonorail monorail)
|
||||
{
|
||||
return _monorail;
|
||||
}
|
||||
|
||||
public void AddEvent(MonorailDelegate ev)
|
||||
{
|
||||
if (EventAddMonorail == null)
|
||||
{
|
||||
EventAddMonorail = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddMonorail += ev;
|
||||
}
|
||||
}
|
||||
|
||||
public FormMonorailConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
blackPanel.MouseDown += PanelColor_MouseDown;
|
||||
greenPanel.MouseDown += PanelColor_MouseDown;
|
||||
redPanel.MouseDown += PanelColor_MouseDown;
|
||||
bluePanel.MouseDown += PanelColor_MouseDown;
|
||||
greyPanel.MouseDown += PanelColor_MouseDown;
|
||||
yellowPanel.MouseDown += PanelColor_MouseDown;
|
||||
bluePanel.MouseDown += PanelColor_MouseDown;
|
||||
whitePanel.MouseDown += PanelColor_MouseDown;
|
||||
monorailLabel.MouseDown += LabelObject_MouseDown;
|
||||
locomotiveLabel.MouseDown += LabelObject_MouseDown;
|
||||
cancelButton.Click += (s, e) => Close();
|
||||
}
|
||||
|
||||
public void DrawMonorail()
|
||||
{
|
||||
Bitmap bmp = new Bitmap(pictureBox.Width, pictureBox.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_monorail?.SetPosition(5, 5);
|
||||
_monorail?.DrawTransport(gr);
|
||||
pictureBox.Image = bmp;
|
||||
}
|
||||
|
||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
|
||||
DragDropEffects.Move | DragDropEffects.Copy);
|
||||
|
||||
}
|
||||
|
||||
private void allowPanel_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "monorailLabel":
|
||||
_monorail = new DrawningMonorail((int)numericSpeed.Value,
|
||||
(int)numericWeight.Value, Color.White, Color.Silver, Color.Black, pictureBox.Width,
|
||||
pictureBox.Height);
|
||||
break;
|
||||
case "locomotiveLabel":
|
||||
_monorail = new DrawningLocomotive((int)numericSpeed.Value,
|
||||
(int)numericWeight.Value, Color.White, Color.Silver, Color.Black, pictureBox.Width,
|
||||
pictureBox.Height, 4, Color.Silver, checkSecondCabine.Checked, checkMagniteRail.Checked);
|
||||
break;
|
||||
}
|
||||
colorLabel.BackColor = Color.Empty;
|
||||
addColorLabel.BackColor = Color.Empty;
|
||||
DrawMonorail();
|
||||
|
||||
}
|
||||
|
||||
private void allowPanel_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddMonorail?.Invoke(_monorail);
|
||||
Close();
|
||||
}
|
||||
|
||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
|
||||
private void colorLabel_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_monorail == null)
|
||||
return;
|
||||
colorLabel.BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||
_monorail.ChangeColor(colorLabel.BackColor);
|
||||
DrawMonorail();
|
||||
}
|
||||
|
||||
private void colorLabel_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void addColorLabel_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if ((_monorail == null) || (_monorail is DrawningLocomotive == false))
|
||||
return;
|
||||
addColorLabel.BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||
((DrawningLocomotive)_monorail).ChangeAddColor(addColorLabel.BackColor);
|
||||
DrawMonorail();
|
||||
}
|
||||
|
||||
private void addColorLabel_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
Monorail/Monorail/FormMonorailConfig.resx
Normal file
120
Monorail/Monorail/FormMonorailConfig.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>
|
12
Monorail/Monorail/MonorailDelegate.cs
Normal file
12
Monorail/Monorail/MonorailDelegate.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Monorail.DrawningObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Monorail
|
||||
{
|
||||
public delegate void MonorailDelegate(DrawningMonorail monorail);
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user