Основа

This commit is contained in:
GokaPek 2023-11-07 12:22:58 +04:00
parent 854c7ea1b6
commit f1d9f1de88
5 changed files with 602 additions and 0 deletions

View File

@ -106,6 +106,10 @@ namespace SelfPropelledArtilleryUnit
/// <param name="e"></param>
private void ButtonAddSPAU_Click(object sender, EventArgs e)
{
var formSPAUConfig = new FormSPAUConfig();
// TODO Call method AddEvent from formCarConfig
formSPAUConfig.Show();
if (listBoxStorages.SelectedIndex == -1)
{
return;

View File

@ -0,0 +1,333 @@
namespace SelfPropelledArtilleryUnit
{
partial class FormSPAUConfig
{
/// <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()
{
groupBox_param = new GroupBox();
checkBox_zalp = new CheckBox();
label_weight = new Label();
groupBox_colors = new GroupBox();
panelGray = new Panel();
panelCian = new Panel();
panelPurple = new Panel();
panelBlack = new Panel();
panelBlue = new Panel();
panelGreen = new Panel();
panelYellow = new Panel();
panelRed = new Panel();
numericUpDownWeight = new NumericUpDown();
numericUpDownSpeed = new NumericUpDown();
label_speed = new Label();
label_orig = new Label();
label_child = new Label();
pictureBox = new PictureBox();
Panel = new Panel();
button_close = new Button();
button_add = new Button();
label_addit_color = new Label();
label_color = new Label();
groupBox_param.SuspendLayout();
groupBox_colors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
Panel.SuspendLayout();
SuspendLayout();
//
// groupBox_param
//
groupBox_param.Controls.Add(checkBox_zalp);
groupBox_param.Controls.Add(label_weight);
groupBox_param.Controls.Add(groupBox_colors);
groupBox_param.Controls.Add(numericUpDownWeight);
groupBox_param.Controls.Add(numericUpDownSpeed);
groupBox_param.Controls.Add(label_speed);
groupBox_param.Location = new Point(600, 12);
groupBox_param.Name = "groupBox_param";
groupBox_param.Size = new Size(188, 401);
groupBox_param.TabIndex = 0;
groupBox_param.TabStop = false;
groupBox_param.Text = "Параметры";
//
// checkBox_zalp
//
checkBox_zalp.AutoSize = true;
checkBox_zalp.Location = new Point(6, 154);
checkBox_zalp.Name = "checkBox_zalp";
checkBox_zalp.Size = new Size(170, 24);
checkBox_zalp.TabIndex = 5;
checkBox_zalp.Text = "Залповая установка";
checkBox_zalp.UseVisualStyleBackColor = true;
//
// label_weight
//
label_weight.AutoSize = true;
label_weight.Location = new Point(6, 86);
label_weight.Name = "label_weight";
label_weight.Size = new Size(33, 20);
label_weight.TabIndex = 3;
label_weight.Text = "Вес";
//
// groupBox_colors
//
groupBox_colors.Controls.Add(panelGray);
groupBox_colors.Controls.Add(panelCian);
groupBox_colors.Controls.Add(panelPurple);
groupBox_colors.Controls.Add(panelBlack);
groupBox_colors.Controls.Add(panelBlue);
groupBox_colors.Controls.Add(panelGreen);
groupBox_colors.Controls.Add(panelYellow);
groupBox_colors.Controls.Add(panelRed);
groupBox_colors.Location = new Point(10, 184);
groupBox_colors.Name = "groupBox_colors";
groupBox_colors.Size = new Size(166, 203);
groupBox_colors.TabIndex = 1;
groupBox_colors.TabStop = false;
groupBox_colors.Text = "Цвета";
//
// panelGray
//
panelGray.BackColor = Color.Silver;
panelGray.Location = new Point(91, 163);
panelGray.Name = "panelGray";
panelGray.Size = new Size(60, 25);
panelGray.TabIndex = 7;
//
// panelCian
//
panelCian.BackColor = Color.Cyan;
panelCian.Location = new Point(9, 163);
panelCian.Name = "panelCian";
panelCian.Size = new Size(60, 25);
panelCian.TabIndex = 6;
//
// panelPurple
//
panelPurple.BackColor = Color.FromArgb(192, 0, 192);
panelPurple.Location = new Point(91, 123);
panelPurple.Name = "panelPurple";
panelPurple.Size = new Size(60, 25);
panelPurple.TabIndex = 5;
//
// panelBlack
//
panelBlack.BackColor = Color.Black;
panelBlack.Location = new Point(9, 123);
panelBlack.Name = "panelBlack";
panelBlack.Size = new Size(60, 25);
panelBlack.TabIndex = 4;
//
// panelBlue
//
panelBlue.BackColor = Color.Blue;
panelBlue.Location = new Point(91, 79);
panelBlue.Name = "panelBlue";
panelBlue.Size = new Size(60, 25);
panelBlue.TabIndex = 3;
//
// panelGreen
//
panelGreen.BackColor = Color.Lime;
panelGreen.Location = new Point(9, 79);
panelGreen.Name = "panelGreen";
panelGreen.Size = new Size(60, 25);
panelGreen.TabIndex = 2;
//
// panelYellow
//
panelYellow.BackColor = Color.Yellow;
panelYellow.Location = new Point(91, 36);
panelYellow.Name = "panelYellow";
panelYellow.Size = new Size(60, 25);
panelYellow.TabIndex = 1;
//
// panelRed
//
panelRed.BackColor = Color.Red;
panelRed.Location = new Point(8, 38);
panelRed.Name = "panelRed";
panelRed.Size = new Size(60, 25);
panelRed.TabIndex = 0;
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(6, 109);
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(52, 27);
numericUpDownWeight.TabIndex = 2;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(6, 56);
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(56, 27);
numericUpDownSpeed.TabIndex = 1;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// label_speed
//
label_speed.AutoSize = true;
label_speed.Location = new Point(6, 33);
label_speed.Name = "label_speed";
label_speed.Size = new Size(73, 20);
label_speed.TabIndex = 0;
label_speed.Text = "Скорость";
//
// label_orig
//
label_orig.BorderStyle = BorderStyle.FixedSingle;
label_orig.Location = new Point(606, 416);
label_orig.Name = "label_orig";
label_orig.Size = new Size(81, 29);
label_orig.TabIndex = 2;
label_orig.Text = "Простой";
label_orig.MouseDown += LabelOrig_MouseDown;
//
// label_child
//
label_child.BorderStyle = BorderStyle.FixedSingle;
label_child.Location = new Point(711, 416);
label_child.Name = "label_child";
label_child.Size = new Size(77, 29);
label_child.TabIndex = 3;
label_child.Text = "Потомок";
//
// pictureBox
//
pictureBox.Location = new Point(3, 68);
pictureBox.Name = "pictureBox";
pictureBox.Size = new Size(588, 377);
pictureBox.TabIndex = 4;
pictureBox.TabStop = false;
//
// Panel
//
Panel.AllowDrop = true;
Panel.Controls.Add(button_close);
Panel.Controls.Add(button_add);
Panel.Controls.Add(label_addit_color);
Panel.Controls.Add(label_color);
Panel.Controls.Add(pictureBox);
Panel.Dock = DockStyle.Left;
Panel.Location = new Point(0, 0);
Panel.Name = "Panel";
Panel.Size = new Size(600, 450);
Panel.TabIndex = 5;
Panel.DragDrop += panel_dragDrop;
Panel.DragEnter += panel_dragEnter;
//
// button_close
//
button_close.Location = new Point(488, 21);
button_close.Name = "button_close";
button_close.Size = new Size(80, 29);
button_close.TabIndex = 8;
button_close.Text = "Отмена";
button_close.UseVisualStyleBackColor = true;
//
// button_add
//
button_add.Location = new Point(387, 21);
button_add.Name = "button_add";
button_add.Size = new Size(95, 29);
button_add.TabIndex = 7;
button_add.Text = "Добавить";
button_add.UseVisualStyleBackColor = true;
button_add.Click += button_add_Click;
//
// label_addit_color
//
label_addit_color.BorderStyle = BorderStyle.FixedSingle;
label_addit_color.Location = new Point(145, 21);
label_addit_color.Name = "label_addit_color";
label_addit_color.Size = new Size(173, 29);
label_addit_color.TabIndex = 6;
label_addit_color.Text = "Дополнительный цвет";
//
// label_color
//
label_color.BorderStyle = BorderStyle.FixedSingle;
label_color.Location = new Point(12, 21);
label_color.Name = "label_color";
label_color.Size = new Size(127, 29);
label_color.TabIndex = 5;
label_color.Text = "Основной цвет";
//
// FormSPAUConfig
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(Panel);
Controls.Add(label_child);
Controls.Add(label_orig);
Controls.Add(groupBox_param);
Name = "FormSPAUConfig";
Text = "FormSPAUConfig";
groupBox_param.ResumeLayout(false);
groupBox_param.PerformLayout();
groupBox_colors.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
Panel.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private GroupBox groupBox_param;
private Label label_weight;
private NumericUpDown numericUpDownWeight;
private NumericUpDown numericUpDownSpeed;
private Label label_speed;
private CheckBox checkBox_zalp;
private GroupBox groupBox_colors;
private Panel panelGreen;
private Panel panelYellow;
private Panel panelRed;
private Panel panelGray;
private Panel panelCian;
private Panel panelPurple;
private Panel panelBlack;
private Panel panelBlue;
private Label label_orig;
private Label label_child;
private PictureBox pictureBox;
private Panel Panel;
private Label label_addit_color;
private Label label_color;
private Button button_close;
private Button button_add;
}
}

View File

@ -0,0 +1,130 @@
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;
using SelfPropelledArtilleryUnit.DrawningObjects;
using SelfPropelledArtilleryUnit.SPAUs;
namespace SelfPropelledArtilleryUnit
{
public partial class FormSPAUConfig : Form
{
/// <summary>
/// Переменная-выбранная машина
/// </summary>
DrawningSPAU? _sPAU = null;
/// <summary>
/// Событие
/// </summary>
private event SPAUDelegate? EventAddSPAU;
/// <summary>
/// Конструктор
/// </summary>
public FormSPAUConfig()
{
InitializeComponent();
panelBlack.MouseDown += PanelColor_MouseDown;
panelPurple.MouseDown += PanelColor_MouseDown;
panelGray.MouseDown += PanelColor_MouseDown;
panelGreen.MouseDown += PanelColor_MouseDown;
panelRed.MouseDown += PanelColor_MouseDown;
panelCian.MouseDown += PanelColor_MouseDown;
panelYellow.MouseDown += PanelColor_MouseDown;
panelBlue.MouseDown += PanelColor_MouseDown;
// TODO buttonCancel.Click with lambda
}
/// <summary>
/// Отрисовать машину
/// </summary>
private void DrawSPAU()
{
Bitmap bmp = new(pictureBox.Width, pictureBox.Height);
Graphics gr = Graphics.FromImage(bmp);
_sPAU?.SetPosition(5, 5);
_sPAU?.DrawTransport(gr);
pictureBox.Image = bmp;
}
/// <summary>
/// Добавление события
/// </summary>
/// <param name="ev">Привязанный метод</param>
public void AddEvent(SPAUDelegate ev)
{
if (EventAddSPAU == null)
{
EventAddSPAU = ev;
}
else
{
EventAddSPAU += ev;
}
}
/// <summary>
/// Передаем информацию при нажатии на Label
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LabelOrig_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 panel_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 panel_dragDrop(object sender, DragEventArgs e)
{
switch (e.Data?.GetData(DataFormats.Text).ToString())
{
case "labelOriginalObject":
_sPAU = new DrawningSPAU((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, pictureBox.Width, pictureBox.Height);
break;
case "labelModifiedObject":
_sPAU = new DrawningSPAUchild((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBox_zalp.Checked, pictureBox.Width, pictureBox.Height);
break;
}
DrawSPAU();
}
// TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
/// <summary>
/// Добавление машины
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button_add_Click(object sender, EventArgs e)
{
EventAddSPAU?.Invoke(_sPAU);
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>

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SelfPropelledArtilleryUnit.DrawningObjects;
namespace SelfPropelledArtilleryUnit.SPAUs
{
/// <summary>
/// Делегат для передачи объекта-автомобиля
/// </summary>
/// <param name="car"></param>
public delegate void SPAUDelegate(DrawningSPAU sPAU);
}