From c17430f76df2784b82b4e1d22cfde31be08cba80 Mon Sep 17 00:00:00 2001 From: AnnaLioness Date: Fri, 17 Nov 2023 15:21:02 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=BF=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Lab1ContainersShip/FormShipConfig.cs | 45 +++---------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/Lab1ContainersShip/Lab1ContainersShip/FormShipConfig.cs b/Lab1ContainersShip/Lab1ContainersShip/FormShipConfig.cs index ab70430..23bf7b7 100644 --- a/Lab1ContainersShip/Lab1ContainersShip/FormShipConfig.cs +++ b/Lab1ContainersShip/Lab1ContainersShip/FormShipConfig.cs @@ -65,34 +65,12 @@ namespace Lab1ContainersShip private void LabelObject_MouseDown(object sender, MouseEventArgs e) { - //(sender as Label)?.DoDragDrop((sender as Label)?.Name,DragDropEffects.Move | DragDropEffects.Copy); - if((sender as Label).Name == "labelSimpleObject") - {_ship = new DrawingShip((int)numericUpDownSpeed.Value, - (int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width, - pictureBoxObject.Height); - } - else { - _ship = new DrawingContainerShip((int)numericUpDownSpeed.Value, - (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxCrane.Checked, - checkBoxContainers.Checked, pictureBoxObject.Width, pictureBoxObject.Height); - } - DoDragDrop(_ship, DragDropEffects.Move | DragDropEffects.Copy); + (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) ?? false) - { - e.Effect = DragDropEffects.Copy; - } - else - { - e.Effect = DragDropEffects.None; - }*/ - if (e.Data?.GetDataPresent(typeof(DrawingShip)) ?? false) - { - e.Effect = DragDropEffects.Copy; - } - else if (e.Data?.GetDataPresent(typeof(DrawingContainerShip)) ?? false) + if (e.Data?.GetDataPresent(DataFormats.Text) ?? false) { e.Effect = DragDropEffects.Copy; } @@ -100,14 +78,14 @@ namespace Lab1ContainersShip { e.Effect = DragDropEffects.None; } + } private void PanelObject_DragDrop(object sender, DragEventArgs e) { - /*switch (e.Data?.GetData(DataFormats.Text).ToString()) + switch (e.Data?.GetData(DataFormats.Text).ToString()) { case "labelSimpleObject": - _ship = - new DrawingShip((int)numericUpDownSpeed.Value, + _ship = new DrawingShip((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width, pictureBoxObject.Height); break; @@ -116,18 +94,7 @@ namespace Lab1ContainersShip (int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxCrane.Checked, checkBoxContainers.Checked, pictureBoxObject.Width,pictureBoxObject.Height); break; - }*/ - var eeee = e.Data?.GetData(typeof(DrawingShip)); - var gggg = e.Data?.GetData(typeof(DrawingContainerShip)); - if(eeee != null) - { - _ship = (DrawingShip)eeee; } - else - { - _ship = (DrawingContainerShip)gggg; - } - DrawShip(); }