gg
This commit is contained in:
parent
92e63e2a69
commit
de7bd7a7e5
134
HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs
Normal file
134
HoistingCrane/HoistingCrane/FormHoistingCraneConfig.cs
Normal file
@ -0,0 +1,134 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
60
HoistingCrane/HoistingCrane/FormHoistingCraneConfig.resx
Normal file
60
HoistingCrane/HoistingCrane/FormHoistingCraneConfig.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
Loading…
Reference in New Issue
Block a user