gg
This commit is contained in:
parent
fe2b37f882
commit
18b809d6b8
@ -1,134 +0,0 @@
|
|||||||
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 HoistingCrane
|
|
||||||
{
|
|
||||||
public partial class FormHoistingCraneConfig : Form
|
|
||||||
{
|
|
||||||
//переменная-выбранный кран
|
|
||||||
DrawingHoistingCrane _hoistingCrane = null;
|
|
||||||
public DrawingHoistingCrane SelectedHoistingCrane { get; private set; }
|
|
||||||
//событие
|
|
||||||
private event Action<DrawingHoistingCrane> EventAddHoistingCrane;
|
|
||||||
//конструктор
|
|
||||||
public FormHoistingCraneConfig()
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
buttonCancel.Click += (object sender, EventArgs e) => Close();
|
|
||||||
}
|
|
||||||
//отрисовка кран
|
|
||||||
private void DrawHoistingCrane()
|
|
||||||
{
|
|
||||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
|
||||||
_hoistingCrane?.SetPosition(5, 5, pictureBoxObject.Width, pictureBoxObject.Height);
|
|
||||||
_hoistingCrane?.DrawTransport(gr);
|
|
||||||
pictureBoxObject.Image = bmp;
|
|
||||||
}
|
|
||||||
//добавление события
|
|
||||||
public void AddEvent(Action<DrawingHoistingCrane> ev)
|
|
||||||
{
|
|
||||||
if (EventAddHoistingCrane == null)
|
|
||||||
{
|
|
||||||
EventAddHoistingCrane = new Action<DrawingHoistingCrane>(ev);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EventAddHoistingCrane += ev;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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":
|
|
||||||
_hoistingCrane = new DrawingHoistingCrane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelBaseColor.BackColor);
|
|
||||||
break;
|
|
||||||
case "labelModifiedObject":
|
|
||||||
_hoistingCrane = new DrawingAdvancedHoistingCrane((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, labelBaseColor.BackColor, labelDopColor.BackColor,
|
|
||||||
checkBoxCounterweight.Checked, checkBoxCrane.Checked);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawHoistingCrane();
|
|
||||||
}
|
|
||||||
//отправляем цвет с панели
|
|
||||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
(sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
|
||||||
}
|
|
||||||
//проверка получаемой информации (её типа на соответсвие требуемому)
|
|
||||||
private void LabelColor_DragEnter(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Data.GetDataPresent(typeof(Color)))
|
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.Copy;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
e.Effect = DragDropEffects.None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//принимаем основной цвет
|
|
||||||
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
//проверка на пустоту объекта
|
|
||||||
if (_hoistingCrane != null)
|
|
||||||
{
|
|
||||||
_hoistingCrane.HoistingCrane.BodyColor = (Color)e.Data.GetData(typeof(Color));
|
|
||||||
|
|
||||||
DrawHoistingCrane();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//принимаем дополнительный цвет
|
|
||||||
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
|
||||||
{
|
|
||||||
//проверка на пустоту объекта и правильную сущноть
|
|
||||||
if (_hoistingCrane != null && _hoistingCrane.HoistingCrane is EntityAdvancedHoistingCrane entityHoistingCrane)
|
|
||||||
{
|
|
||||||
entityHoistingCrane.DopColor = (Color)e.Data.GetData(typeof(Color));
|
|
||||||
DrawHoistingCrane();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//добавление крана
|
|
||||||
private void ButtonAddObject_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
EventAddHoistingCrane?.Invoke(_hoistingCrane);
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,120 +0,0 @@
|
|||||||
<?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>
|
|
@ -1,155 +0,0 @@
|
|||||||
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 HoistingCrane
|
|
||||||
{
|
|
||||||
public partial class FormMapWithSetHoistingCrane : Form
|
|
||||||
{
|
|
||||||
|
|
||||||
private MapWithSetHoistingCraneGeneric<DrawingObjectHoistingCrane, AbstractMap> _mapHoistingCraneCollectionGeneric;
|
|
||||||
|
|
||||||
public FormMapWithSetHoistingCrane()
|
|
||||||
{
|
|
||||||
{ "Простая карта", new SimpleMap() },
|
|
||||||
{ "Вторая карта", new SecondMap() },
|
|
||||||
};
|
|
||||||
/// <summary>
|
|
||||||
/// Объект от коллекции карт
|
|
||||||
/// Логер
|
|
||||||
/// </summary>
|
|
||||||
private readonly ILogger _logger;
|
|
||||||
/// <summary>
|
|
||||||
private readonly MapsCollection _mapsCollection;
|
|
||||||
/// <summary>
|
|
||||||
public FormMapWithSetHoistingCrane(ILogger<FormMapWithSetHoistingCrane> logger)
|
|
||||||
{
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
AbstractMap map = null;
|
|
||||||
switch (comboBoxSelectorMap.Text)
|
|
||||||
{
|
|
||||||
case "Первая карта":
|
|
||||||
map = new SimpleMap();
|
|
||||||
break;
|
|
||||||
case "Вторая карта":
|
|
||||||
map = new SecondMap();
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
if (map != null)
|
|
||||||
{
|
|
||||||
_mapHoistingCraneCollectionGeneric = new MapWithSetHoistingCraneGeneric<DrawingObjectHoistingCrane, AbstractMap>(
|
|
||||||
pictureBox.Width, pictureBox.Height, map);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_mapHoistingCraneCollectionGeneric = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAddHoistingCrane_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_mapHoistingCraneCollectionGeneric == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
FormHoistingCrane form = new();
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
DrawingObjectHoistingCrane hoistingCrane = new(form.SelectedHoistingCrane);
|
|
||||||
if (_mapHoistingCraneCollectionGeneric + hoistingCrane == 1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект добавлен");
|
|
||||||
pictureBox.Image = _mapHoistingCraneCollectionGeneric.ShowSet();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonRemoveHoistingCrane_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
|
||||||
if (_mapHoistingCraneCollectionGeneric - pos == null)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект удален");
|
|
||||||
pictureBox.Image = _mapHoistingCraneCollectionGeneric.ShowSet();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось удалить объект");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_mapHoistingCraneCollectionGeneric == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pictureBox.Image = _mapHoistingCraneCollectionGeneric.ShowSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_mapHoistingCraneCollectionGeneric == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pictureBox.Image = _mapHoistingCraneCollectionGeneric.ShowOnMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (_mapHoistingCraneCollectionGeneric == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
|
||||||
Direction enums = Direction.None;
|
|
||||||
switch (name)
|
|
||||||
{
|
|
||||||
case "buttonUp":
|
|
||||||
enums = Direction.Up;
|
|
||||||
break;
|
|
||||||
case "buttonDown":
|
|
||||||
enums = Direction.Down;
|
|
||||||
break;
|
|
||||||
case "buttonLeft":
|
|
||||||
enums = Direction.Left;
|
|
||||||
break;
|
|
||||||
case "buttonRight":
|
|
||||||
enums = Direction.Right;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pictureBox.Image = _mapHoistingCraneCollectionGeneric.MoveObject(enums);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void pictureBox_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user