Лёвушкина Анна, ПИбд-21, лаб5 простая #11
@ -20,8 +20,9 @@ namespace Lab1ContainersShip
|
|||||||
/// Событие
|
/// Событие
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
private event ShipDelegate EventAddShip;
|
|
||||||
public void AddEvent(ShipDelegate ev)
|
private event Action<DrawingShip> EventAddShip;
|
||||||
|
public void AddEvent(Action<DrawingShip> ev)
|
||||||
{
|
{
|
||||||
if (EventAddShip == null)
|
if (EventAddShip == null)
|
||||||
{
|
{
|
||||||
@ -63,11 +64,35 @@ namespace Lab1ContainersShip
|
|||||||
|
|
||||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name,DragDropEffects.Move | DragDropEffects.Copy);
|
|
||||||
|
//(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);
|
||||||
}
|
}
|
||||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
/*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)
|
||||||
{
|
{
|
||||||
e.Effect = DragDropEffects.Copy;
|
e.Effect = DragDropEffects.Copy;
|
||||||
}
|
}
|
||||||
@ -78,10 +103,11 @@ namespace Lab1ContainersShip
|
|||||||
}
|
}
|
||||||
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
/*switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||||
{
|
{
|
||||||
case "labelSimpleObject":
|
case "labelSimpleObject":
|
||||||
_ship = new DrawingShip((int)numericUpDownSpeed.Value,
|
_ship =
|
||||||
|
new DrawingShip((int)numericUpDownSpeed.Value,
|
||||||
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
|
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
|
||||||
pictureBoxObject.Height);
|
pictureBoxObject.Height);
|
||||||
break;
|
break;
|
||||||
@ -90,7 +116,18 @@ namespace Lab1ContainersShip
|
|||||||
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxCrane.Checked,
|
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxCrane.Checked,
|
||||||
checkBoxContainers.Checked, pictureBoxObject.Width,pictureBoxObject.Height);
|
checkBoxContainers.Checked, pictureBoxObject.Width,pictureBoxObject.Height);
|
||||||
break;
|
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();
|
DrawShip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,6 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="SetGeneric.cs" />
|
<Compile Include="SetGeneric.cs" />
|
||||||
<Compile Include="ShipGenericStorage.cs" />
|
<Compile Include="ShipGenericStorage.cs" />
|
||||||
<Compile Include="ShipDelegate.cs" />
|
|
||||||
<Compile Include="Status.cs" />
|
<Compile Include="Status.cs" />
|
||||||
<EmbeddedResource Include="FormContainerShip.resx">
|
<EmbeddedResource Include="FormContainerShip.resx">
|
||||||
<DependentUpon>FormContainerShip.cs</DependentUpon>
|
<DependentUpon>FormContainerShip.cs</DependentUpon>
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
using Lab1ContainersShip.DrawingObjects;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Lab1ContainersShip
|
|
||||||
{
|
|
||||||
public delegate void ShipDelegate(DrawingShip ship);
|
|
||||||
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user