копирование кода из пдф

This commit is contained in:
bekodeg 2023-11-04 13:18:36 +04:00
parent c6059a9dfa
commit 26a589af93
5 changed files with 615 additions and 34 deletions

View File

@ -0,0 +1,343 @@
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()
{
groupBox1 = new GroupBox();
label4 = new Label();
labelSimpleObject = new Label();
groupBox2 = new GroupBox();
panel8 = new Panel();
panel7 = new Panel();
panel6 = new Panel();
panel5 = new Panel();
panel4 = new Panel();
panel3 = new Panel();
panel2 = new Panel();
panel1 = new Panel();
checkBoxBattery = new CheckBox();
checkBoxHorns = new CheckBox();
numericUpDownWeight = new NumericUpDown();
numericUpDownSpeed = new NumericUpDown();
label2 = new Label();
label1 = new Label();
pictureBoxObject = new PictureBox();
label5 = new Label();
label6 = new Label();
label7 = new Label();
button1 = new Button();
button2 = new Button();
groupBox1.SuspendLayout();
groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
SuspendLayout();
//
// groupBox1
//
groupBox1.Controls.Add(label4);
groupBox1.Controls.Add(labelSimpleObject);
groupBox1.Controls.Add(groupBox2);
groupBox1.Controls.Add(checkBoxBattery);
groupBox1.Controls.Add(checkBoxHorns);
groupBox1.Controls.Add(numericUpDownWeight);
groupBox1.Controls.Add(numericUpDownSpeed);
groupBox1.Controls.Add(label2);
groupBox1.Controls.Add(label1);
groupBox1.Location = new Point(12, 31);
groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(568, 293);
groupBox1.TabIndex = 0;
groupBox1.TabStop = false;
groupBox1.Text = "Параметры";
//
// label4
//
label4.BorderStyle = BorderStyle.FixedSingle;
label4.Location = new Point(404, 219);
label4.Name = "label4";
label4.Size = new Size(113, 35);
label4.TabIndex = 8;
label4.Text = "Продвинутый";
label4.TextAlign = ContentAlignment.MiddleCenter;
//
// labelSimpleObject
//
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
labelSimpleObject.Location = new Point(278, 219);
labelSimpleObject.Name = "labelSimpleObject";
labelSimpleObject.Size = new Size(113, 35);
labelSimpleObject.TabIndex = 7;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
//
// groupBox2
//
groupBox2.Controls.Add(panel8);
groupBox2.Controls.Add(panel7);
groupBox2.Controls.Add(panel6);
groupBox2.Controls.Add(panel5);
groupBox2.Controls.Add(panel4);
groupBox2.Controls.Add(panel3);
groupBox2.Controls.Add(panel2);
groupBox2.Controls.Add(panel1);
groupBox2.Location = new Point(278, 57);
groupBox2.Name = "groupBox2";
groupBox2.Size = new Size(239, 135);
groupBox2.TabIndex = 6;
groupBox2.TabStop = false;
groupBox2.Text = "Цвета";
//
// panel8
//
panel8.BackColor = Color.Purple;
panel8.Location = new Point(184, 81);
panel8.Name = "panel8";
panel8.Size = new Size(40, 40);
panel8.TabIndex = 3;
//
// panel7
//
panel7.BackColor = Color.Black;
panel7.Location = new Point(129, 81);
panel7.Name = "panel7";
panel7.Size = new Size(40, 40);
panel7.TabIndex = 3;
//
// panel6
//
panel6.BackColor = Color.Gray;
panel6.Location = new Point(73, 81);
panel6.Name = "panel6";
panel6.Size = new Size(40, 40);
panel6.TabIndex = 3;
//
// panel5
//
panel5.BackColor = Color.White;
panel5.Location = new Point(15, 81);
panel5.Name = "panel5";
panel5.Size = new Size(40, 40);
panel5.TabIndex = 4;
//
// panel4
//
panel4.BackColor = Color.Yellow;
panel4.Location = new Point(184, 26);
panel4.Name = "panel4";
panel4.Size = new Size(40, 40);
panel4.TabIndex = 3;
//
// panel3
//
panel3.BackColor = Color.Blue;
panel3.Location = new Point(129, 26);
panel3.Name = "panel3";
panel3.Size = new Size(40, 40);
panel3.TabIndex = 2;
//
// panel2
//
panel2.BackColor = Color.Green;
panel2.Location = new Point(73, 26);
panel2.Name = "panel2";
panel2.Size = new Size(40, 40);
panel2.TabIndex = 1;
//
// panel1
//
panel1.BackColor = Color.Red;
panel1.Location = new Point(15, 26);
panel1.Name = "panel1";
panel1.Size = new Size(40, 40);
panel1.TabIndex = 0;
//
// checkBoxBattery
//
checkBoxBattery.AutoSize = true;
checkBoxBattery.Location = new Point(27, 230);
checkBoxBattery.Name = "checkBoxBattery";
checkBoxBattery.Size = new Size(215, 24);
checkBoxBattery.TabIndex = 5;
checkBoxBattery.Text = "Признак наличия батареи";
checkBoxBattery.UseVisualStyleBackColor = true;
//
// checkBoxHorns
//
checkBoxHorns.AutoSize = true;
checkBoxHorns.Location = new Point(27, 186);
checkBoxHorns.Name = "checkBoxHorns";
checkBoxHorns.Size = new Size(199, 24);
checkBoxHorns.TabIndex = 4;
checkBoxHorns.Text = "Признак наличия рогов";
checkBoxHorns.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(109, 105);
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(86, 27);
numericUpDownWeight.TabIndex = 3;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(109, 57);
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(86, 27);
numericUpDownSpeed.TabIndex = 2;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(27, 107);
label2.Name = "label2";
label2.Size = new Size(36, 20);
label2.TabIndex = 1;
label2.Text = "Вес:";
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(27, 59);
label1.Name = "label1";
label1.Size = new Size(76, 20);
label1.TabIndex = 0;
label1.Text = "Скорость:";
//
// pictureBoxObject
//
pictureBoxObject.Location = new Point(608, 90);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(244, 181);
pictureBoxObject.TabIndex = 1;
pictureBoxObject.TabStop = false;
//
// label5
//
label5.BorderStyle = BorderStyle.FixedSingle;
label5.Location = new Point(586, 42);
label5.Name = "label5";
label5.Size = new Size(287, 243);
label5.TabIndex = 2;
//
// label6
//
label6.BorderStyle = BorderStyle.FixedSingle;
label6.Location = new Point(608, 52);
label6.Name = "label6";
label6.Size = new Size(113, 35);
label6.TabIndex = 8;
label6.Text = "Цвет";
label6.TextAlign = ContentAlignment.MiddleCenter;
//
// label7
//
label7.BorderStyle = BorderStyle.FixedSingle;
label7.Location = new Point(739, 52);
label7.Name = "label7";
label7.Size = new Size(113, 35);
label7.TabIndex = 9;
label7.Text = "Доп. цвет";
label7.TextAlign = ContentAlignment.MiddleCenter;
//
// button1
//
button1.Location = new Point(608, 295);
button1.Name = "button1";
button1.Size = new Size(113, 29);
button1.TabIndex = 10;
button1.Text = "Добавить";
button1.UseVisualStyleBackColor = true;
//
// button2
//
button2.Location = new Point(739, 295);
button2.Name = "button2";
button2.Size = new Size(113, 29);
button2.TabIndex = 11;
button2.Text = "Отмена";
button2.UseVisualStyleBackColor = true;
//
// FormLocomotiveConfig
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1149, 339);
Controls.Add(button2);
Controls.Add(button1);
Controls.Add(label7);
Controls.Add(label6);
Controls.Add(pictureBoxObject);
Controls.Add(groupBox1);
Controls.Add(label5);
Name = "FormLocomotiveConfig";
Text = "FormLocomotiveConfig";
groupBox1.ResumeLayout(false);
groupBox1.PerformLayout();
groupBox2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
ResumeLayout(false);
}
#endregion
private GroupBox groupBox1;
private Label label1;
private NumericUpDown numericUpDownWeight;
private NumericUpDown numericUpDownSpeed;
private Label label2;
private CheckBox checkBoxBattery;
private CheckBox checkBoxHorns;
private GroupBox groupBox2;
private Panel panel1;
private Panel panel8;
private Panel panel7;
private Panel panel6;
private Panel panel5;
private Panel panel4;
private Panel panel3;
private Panel panel2;
private Label label4;
private Label labelSimpleObject;
private PictureBox pictureBoxObject;
private Label label5;
private Label label6;
private Label label7;
private Button button1;
private Button button2;
}
}

View File

@ -0,0 +1,16 @@
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
{
}
}

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>

View File

@ -97,17 +97,6 @@ namespace ProjectElectricLocomotive
ReloadObjects();
}
}
/// <summary>
/// Добавление набора в коллекцию
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <summary>
/// Выбор набора
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <summary>
/// Добавление объекта в набор
@ -116,29 +105,9 @@ namespace ProjectElectricLocomotive
/// <param name="e"></param>
private void ButtonAddLocomotive_Click(object sender, EventArgs e)
{
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
FormLocomotive form = new();
if (form.ShowDialog() == DialogResult.OK)
{
if (obj + form.SelectedLocomotive > 0)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowLocomotives();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
var formCarConfig = new FormLocomotiveConfig();
// TODO Call method AddEvent from formCarConfig
formCarConfig.Show();
}
/// <summary>
/// Удаление объекта из набора

View File

@ -0,0 +1,133 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ProjectElectricLocomotive.DrawningObjects;
namespace ProjectElectricLocomotive
{
partial class FormLocomotiveConfig : Form
{
/// <summary>
/// Переменная-выбранный локомотив
/// </summary>
DrawningLocomotive? _locomotive = null;
/// <summary>
/// Событие
/// </summary>
private event Action<DrawningLocomotive>? EventAddLocomotive;
/// <summary>
/// Конструктор
/// </summary>
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;
// TODO buttonCancel.Click with lambda
}
/// <summary>
/// Отрисовать локомотив
/// </summary>
private void DrawLocomotive()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_locomotive?.SetPosition(5, 5);
_locomotive?.DrawTransport(gr);
pictureBoxObject.Image = bmp;
}
/// <summary>
/// Добавление события
/// </summary>
/// <param name="ev">Привязанный метод</param>
public void AddEvent(Action<DrawningLocomotive>? ev)
{
if (EventAddLocomotive == null)
{
EventAddLocomotive = ev;
}
else
{
EventAddLocomotive += ev;
}
}
/// <summary>
/// Передаем информацию при нажатии на Label
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
{
(sender as Label)?.DoDragDrop((sender as Label)?.Name,
DragDropEffects.Move | DragDropEffects.Copy);
}
/// <summary>
/// Проверка получаемой информации (ее типа на соответствие требуемому)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PanelObject_DragEnter(object sender, DragEventArgs e)
{
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
/// <summary>
/// Действия при приеме перетаскиваемой информации
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PanelObject_DragDrop(object sender, DragEventArgs e)
{
switch (e.Data?.GetData(DataFormats.Text).ToString())
{
case "labelSimpleObject":
_locomotive = new DrawningLocomotive((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
pictureBoxObject.Height);
break;
case "labelModifiedObject":
_locomotive = new DrawningElectricLocomotive((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, Color.Black,
checkBoxHorns.Checked, checkBoxBattery.Checked,
pictureBoxObject.Width, pictureBoxObject.Height);
break;
}
DrawLocomotive();
// TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
}
/// <summary>
/// Добавление локомотива
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonOk_Click(object sender, EventArgs e)
{
EventAddLocomotive?.Invoke(_locomotive);
Close();
}
}
}