Возможность добавлять потомок и родительский на форму

This commit is contained in:
GokaPek 2023-11-07 13:44:40 +04:00
parent f1d9f1de88
commit 667598f1d3
2 changed files with 40 additions and 30 deletions

View File

@ -43,8 +43,8 @@
numericUpDownWeight = new NumericUpDown();
numericUpDownSpeed = new NumericUpDown();
label_speed = new Label();
label_orig = new Label();
label_child = new Label();
labelOriginalObject = new Label();
labelModifiedObject = new Label();
pictureBox = new PictureBox();
Panel = new Panel();
button_close = new Button();
@ -203,24 +203,25 @@
label_speed.TabIndex = 0;
label_speed.Text = "Скорость";
//
// label_orig
// labelOriginalObject
//
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;
labelOriginalObject.BorderStyle = BorderStyle.FixedSingle;
labelOriginalObject.Location = new Point(606, 416);
labelOriginalObject.Name = "labelOriginalObject";
labelOriginalObject.Size = new Size(81, 29);
labelOriginalObject.TabIndex = 2;
labelOriginalObject.Text = "Простой";
labelOriginalObject.MouseDown += Label_MouseDown;
//
// label_child
// labelModifiedObject
//
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 = "Потомок";
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
labelModifiedObject.Location = new Point(711, 416);
labelModifiedObject.Name = "labelModifiedObject";
labelModifiedObject.Size = new Size(77, 29);
labelModifiedObject.TabIndex = 3;
labelModifiedObject.Text = "Потомок";
labelModifiedObject.MouseDown += Label_MouseDown;
//
// pictureBox
//
@ -289,8 +290,8 @@
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(Panel);
Controls.Add(label_child);
Controls.Add(label_orig);
Controls.Add(labelModifiedObject);
Controls.Add(labelOriginalObject);
Controls.Add(groupBox_param);
Name = "FormSPAUConfig";
Text = "FormSPAUConfig";
@ -321,8 +322,8 @@
private Panel panelPurple;
private Panel panelBlack;
private Panel panelBlue;
private Label label_orig;
private Label label_child;
private Label labelOriginalObject;
private Label labelModifiedObject;
private PictureBox pictureBox;
private Panel Panel;
private Label label_addit_color;

View File

@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
using SelfPropelledArtilleryUnit.DrawningObjects;
using SelfPropelledArtilleryUnit.SPAUs;
@ -29,17 +30,25 @@ namespace SelfPropelledArtilleryUnit
{
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;
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
button_close.Click += (s, e) => Close();
}
public void panelColor_MouseDown(object sender, MouseEventArgs e)
{
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
}
/// <summary>
/// Отрисовать машину
/// </summary>
@ -73,7 +82,7 @@ namespace SelfPropelledArtilleryUnit
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LabelOrig_MouseDown(object sender, MouseEventArgs e)
private void Label_MouseDown(object sender, MouseEventArgs e)
{
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
}