Начало1

This commit is contained in:
DyCTaTOR 2023-11-10 19:34:39 +04:00
parent debf63ef08
commit f7a094b36b
4 changed files with 605 additions and 3 deletions

View File

@ -89,12 +89,11 @@ EventArgs e)
return; return;
} }
FormMonorail form = new(); FormMonorailConfig form = new();
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
{ {
int addedIndex = obj + form.SelectedMonorail; if (obj != null)
if (addedIndex != -1 && addedIndex <= 20)
{ {
MessageBox.Show("Объект добавлен"); MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowMonorails(); pictureBoxCollection.Image = obj.ShowMonorails();

View File

@ -0,0 +1,386 @@
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()
{
groupBox1 = new GroupBox();
label5 = new Label();
label3 = new Label();
GroupColor = new GroupBox();
panelPurple = new Panel();
panelYellow = new Panel();
panelBlack = new Panel();
panelBlue = new Panel();
panelGray = new Panel();
panelGreen = new Panel();
panelWhite = new Panel();
panelRed = new Panel();
checkBoxSecondCabin = new CheckBox();
checkBoxReil = new CheckBox();
label2 = new Label();
label1 = new Label();
numericUpDownWeight = new NumericUpDown();
numericUpDownSpeed = new NumericUpDown();
pictureBoxObject = new PictureBox();
label4 = new Label();
label6 = new Label();
label7 = new Label();
ButtonOk = new Button();
ButtonCancel = new Button();
PanelLables = new Panel();
groupBox1.SuspendLayout();
GroupColor.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
PanelLables.SuspendLayout();
SuspendLayout();
//
// groupBox1
//
groupBox1.Controls.Add(label5);
groupBox1.Controls.Add(label3);
groupBox1.Controls.Add(GroupColor);
groupBox1.Controls.Add(checkBoxSecondCabin);
groupBox1.Controls.Add(checkBoxReil);
groupBox1.Controls.Add(label2);
groupBox1.Controls.Add(label1);
groupBox1.Controls.Add(numericUpDownWeight);
groupBox1.Controls.Add(numericUpDownSpeed);
groupBox1.ForeColor = SystemColors.ControlLightLight;
groupBox1.Location = new Point(12, 12);
groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(721, 330);
groupBox1.TabIndex = 0;
groupBox1.TabStop = false;
groupBox1.Text = "Параметры";
//
// label5
//
label5.BackColor = SystemColors.Info;
label5.BorderStyle = BorderStyle.FixedSingle;
label5.ForeColor = SystemColors.ControlText;
label5.Location = new Point(528, 235);
label5.Name = "label5";
label5.Size = new Size(150, 70);
label5.TabIndex = 9;
label5.Text = "Продвинутый";
label5.TextAlign = ContentAlignment.MiddleCenter;
//
// label3
//
label3.BackColor = SystemColors.Info;
label3.BorderStyle = BorderStyle.FixedSingle;
label3.ForeColor = SystemColors.ControlText;
label3.Location = new Point(348, 235);
label3.Name = "label3";
label3.Size = new Size(150, 70);
label3.TabIndex = 7;
label3.Text = "Простой";
label3.TextAlign = ContentAlignment.MiddleCenter;
//
// GroupColor
//
GroupColor.Controls.Add(panelPurple);
GroupColor.Controls.Add(panelYellow);
GroupColor.Controls.Add(panelBlack);
GroupColor.Controls.Add(panelBlue);
GroupColor.Controls.Add(panelGray);
GroupColor.Controls.Add(panelGreen);
GroupColor.Controls.Add(panelWhite);
GroupColor.Controls.Add(panelRed);
GroupColor.ForeColor = SystemColors.ControlLightLight;
GroupColor.Location = new Point(342, 26);
GroupColor.Name = "GroupColor";
GroupColor.Size = new Size(345, 175);
GroupColor.TabIndex = 6;
GroupColor.TabStop = false;
GroupColor.Text = "Цвета";
//
// panelPurple
//
panelPurple.BackColor = Color.Purple;
panelPurple.Location = new Point(258, 102);
panelPurple.Name = "panelPurple";
panelPurple.Size = new Size(78, 55);
panelPurple.TabIndex = 3;
panelPurple.MouseDown += LabelObject_MouseDown;
//
// panelYellow
//
panelYellow.BackColor = Color.Yellow;
panelYellow.Location = new Point(258, 32);
panelYellow.Name = "panelYellow";
panelYellow.Size = new Size(78, 55);
panelYellow.TabIndex = 1;
panelYellow.MouseDown += LabelObject_MouseDown;
//
// panelBlack
//
panelBlack.BackColor = Color.Black;
panelBlack.Location = new Point(174, 102);
panelBlack.Name = "panelBlack";
panelBlack.Size = new Size(78, 55);
panelBlack.TabIndex = 4;
panelBlack.MouseDown += LabelObject_MouseDown;
//
// panelBlue
//
panelBlue.BackColor = Color.FromArgb(0, 0, 192);
panelBlue.Location = new Point(174, 32);
panelBlue.Name = "panelBlue";
panelBlue.Size = new Size(78, 55);
panelBlue.TabIndex = 1;
panelBlue.MouseDown += LabelObject_MouseDown;
//
// panelGray
//
panelGray.BackColor = Color.Gray;
panelGray.Location = new Point(90, 102);
panelGray.Name = "panelGray";
panelGray.Size = new Size(78, 55);
panelGray.TabIndex = 5;
panelGray.MouseDown += LabelObject_MouseDown;
//
// panelGreen
//
panelGreen.BackColor = Color.Lime;
panelGreen.Location = new Point(90, 32);
panelGreen.Name = "panelGreen";
panelGreen.Size = new Size(78, 55);
panelGreen.TabIndex = 1;
panelGreen.MouseDown += LabelObject_MouseDown;
//
// panelWhite
//
panelWhite.BackColor = Color.White;
panelWhite.Location = new Point(6, 102);
panelWhite.Name = "panelWhite";
panelWhite.Size = new Size(78, 55);
panelWhite.TabIndex = 2;
panelWhite.MouseDown += LabelObject_MouseDown;
//
// panelRed
//
panelRed.BackColor = Color.FromArgb(192, 0, 0);
panelRed.Location = new Point(6, 32);
panelRed.Name = "panelRed";
panelRed.Size = new Size(78, 55);
panelRed.TabIndex = 0;
panelRed.MouseDown += LabelObject_MouseDown;
//
// checkBoxSecondCabin
//
checkBoxSecondCabin.AutoSize = true;
checkBoxSecondCabin.ForeColor = SystemColors.ControlLightLight;
checkBoxSecondCabin.Location = new Point(20, 207);
checkBoxSecondCabin.Name = "checkBoxSecondCabin";
checkBoxSecondCabin.Size = new Size(134, 24);
checkBoxSecondCabin.TabIndex = 5;
checkBoxSecondCabin.Text = "Вторая кабина";
checkBoxSecondCabin.UseVisualStyleBackColor = true;
//
// checkBoxReil
//
checkBoxReil.AutoSize = true;
checkBoxReil.ForeColor = SystemColors.ControlLightLight;
checkBoxReil.Location = new Point(20, 177);
checkBoxReil.Name = "checkBoxReil";
checkBoxReil.Size = new Size(78, 24);
checkBoxReil.TabIndex = 4;
checkBoxReil.Text = "Рельса";
checkBoxReil.UseVisualStyleBackColor = true;
//
// label2
//
label2.AutoSize = true;
label2.ForeColor = SystemColors.ControlLightLight;
label2.Location = new Point(6, 93);
label2.Name = "label2";
label2.Size = new Size(36, 20);
label2.TabIndex = 3;
label2.Text = "Вес:";
//
// label1
//
label1.AutoSize = true;
label1.ForeColor = SystemColors.ControlLightLight;
label1.Location = new Point(6, 50);
label1.Name = "label1";
label1.Size = new Size(76, 20);
label1.TabIndex = 2;
label1.Text = "Скорость:";
//
// numericUpDownWeight
//
numericUpDownWeight.BackColor = SystemColors.Info;
numericUpDownWeight.Location = new Point(100, 91);
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownWeight.Name = "numericUpDownWeight";
numericUpDownWeight.Size = new Size(150, 27);
numericUpDownWeight.TabIndex = 1;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// numericUpDownSpeed
//
numericUpDownSpeed.BackColor = SystemColors.Info;
numericUpDownSpeed.Location = new Point(100, 48);
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownSpeed.Name = "numericUpDownSpeed";
numericUpDownSpeed.Size = new Size(150, 27);
numericUpDownSpeed.TabIndex = 0;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// pictureBoxObject
//
pictureBoxObject.Location = new Point(12, 357);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(471, 237);
pictureBoxObject.TabIndex = 1;
pictureBoxObject.TabStop = false;
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(513, 371);
label4.Name = "label4";
label4.Size = new Size(0, 20);
label4.TabIndex = 2;
//
// label6
//
label6.BackColor = SystemColors.Info;
label6.BorderStyle = BorderStyle.FixedSingle;
label6.ForeColor = SystemColors.ControlText;
label6.Location = new Point(3, 12);
label6.Name = "label6";
label6.Size = new Size(115, 70);
label6.TabIndex = 10;
label6.Text = "Простой";
label6.TextAlign = ContentAlignment.MiddleCenter;
//
// label7
//
label7.BackColor = SystemColors.Info;
label7.BorderStyle = BorderStyle.FixedSingle;
label7.ForeColor = SystemColors.ControlText;
label7.Location = new Point(134, 12);
label7.Name = "label7";
label7.Size = new Size(109, 70);
label7.TabIndex = 11;
label7.Text = "Продвинутый";
label7.TextAlign = ContentAlignment.MiddleCenter;
//
// ButtonOk
//
ButtonOk.BackColor = SystemColors.Info;
ButtonOk.Location = new Point(2, 188);
ButtonOk.Name = "ButtonOk";
ButtonOk.Size = new Size(115, 46);
ButtonOk.TabIndex = 12;
ButtonOk.Text = "Добавить";
ButtonOk.UseVisualStyleBackColor = false;
ButtonOk.Click += ButtonOk_Click;
//
// ButtonCancel
//
ButtonCancel.BackColor = SystemColors.Info;
ButtonCancel.Location = new Point(128, 188);
ButtonCancel.Name = "ButtonCancel";
ButtonCancel.Size = new Size(115, 46);
ButtonCancel.TabIndex = 13;
ButtonCancel.Text = "Отмена";
ButtonCancel.UseVisualStyleBackColor = false;
ButtonCancel.Click += ButtonCancel_Click;
//
// PanelLables
//
PanelLables.Controls.Add(label6);
PanelLables.Controls.Add(ButtonCancel);
PanelLables.Controls.Add(label7);
PanelLables.Controls.Add(ButtonOk);
PanelLables.Location = new Point(489, 357);
PanelLables.Name = "PanelLables";
PanelLables.Size = new Size(246, 237);
PanelLables.TabIndex = 14;
PanelLables.MouseUp += LabelObject_MouseDown;
//
// FormMonorailConfig
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
BackColor = SystemColors.ControlDarkDark;
ClientSize = new Size(747, 606);
Controls.Add(PanelLables);
Controls.Add(label4);
Controls.Add(pictureBoxObject);
Controls.Add(groupBox1);
Name = "FormMonorailConfig";
Text = "FormMonorailConfig";
groupBox1.ResumeLayout(false);
groupBox1.PerformLayout();
GroupColor.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
PanelLables.ResumeLayout(false);
ResumeLayout(false);
PerformLayout();
}
#endregion
private GroupBox groupBox1;
private Label label2;
private Label label1;
private NumericUpDown numericUpDownWeight;
private NumericUpDown numericUpDownSpeed;
private GroupBox GroupColor;
private Panel panelYellow;
private Panel panelBlue;
private Panel panelGreen;
private Panel panelRed;
private CheckBox checkBoxSecondCabin;
private CheckBox checkBoxReil;
private Label label5;
private Label label3;
private Panel panelPurple;
private Panel panelBlack;
private Panel panelGray;
private Panel panelWhite;
private PictureBox pictureBoxObject;
private Label label4;
private Label label6;
private Label label7;
private Button ButtonOk;
private Button ButtonCancel;
private Panel PanelLables;
}
}

View File

@ -0,0 +1,97 @@
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 delegate void MonorailDelegate(DrawningMonorail Monorail);
private event MonorailDelegate? EventAddMonorail;
public FormMonorailConfig()
{
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;
}
private void DrawMonorail()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_monorail?.SetPosition(5, 5);
_monorail?.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) ?? 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":
_monorail = new DrawningMonorail((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
pictureBoxObject.Height);
break;
case "labelModifiedObject":
_monorail = new DrawningSecondMonorail((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxReil.Checked,
checkBoxSecondCabin.Checked, pictureBoxObject.Width,
pictureBoxObject.Height);
break;
}
DrawMonorail();
}
public void AddEvent(MonorailDelegate ev)
{
if (EventAddMonorail == null)
{
EventAddMonorail = ev;
}
else
{
EventAddMonorail += ev;
}
}
private void ButtonOk_Click(object sender, EventArgs e)
{
EventAddMonorail?.Invoke(_monorail);
Close();
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
Close();
}
}
}

View 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>