Сделано по образцу из лекции
This commit is contained in:
parent
5fd7d40add
commit
12ec39dd21
@ -13,6 +13,7 @@ namespace Trolleybus
|
|||||||
public partial class FormTrolleybusConfig : Form
|
public partial class FormTrolleybusConfig : Form
|
||||||
{
|
{
|
||||||
DrawingTrolleybus _trolleybus = null;
|
DrawingTrolleybus _trolleybus = null;
|
||||||
|
private event TrolleybusDelegate EventAddTrolleybus;
|
||||||
public FormTrolleybusConfig()
|
public FormTrolleybusConfig()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -27,6 +28,18 @@ namespace Trolleybus
|
|||||||
pictureBoxObject.Image = btm;
|
pictureBoxObject.Image = btm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddEvent(TrolleybusDelegate ev)
|
||||||
|
{
|
||||||
|
if (EventAddTrolleybus == null)
|
||||||
|
{
|
||||||
|
EventAddTrolleybus = new TrolleybusDelegate(ev);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EventAddTrolleybus += ev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void groupBox2_Enter(object sender, EventArgs e)
|
private void groupBox2_Enter(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -37,7 +50,7 @@ namespace Trolleybus
|
|||||||
(sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy);
|
(sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void panelObject_DragDrop(object sender, DragEventArgs e)
|
private void panelObject_DragEnter(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Data.GetDataPresent(DataFormats.Text))
|
if (e.Data.GetDataPresent(DataFormats.Text))
|
||||||
{
|
{
|
||||||
@ -49,7 +62,7 @@ namespace Trolleybus
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void panelObject_DragEnter(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())
|
||||||
{
|
{
|
||||||
@ -63,5 +76,10 @@ namespace Trolleybus
|
|||||||
}
|
}
|
||||||
DrawTrolleybus();
|
DrawTrolleybus();
|
||||||
}
|
}
|
||||||
|
private void ButtonOk_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
EventAddTrolleybus?.Invoke(_trolleybus);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,7 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="SetTrolleybusGeneric.cs" />
|
<Compile Include="SetTrolleybusGeneric.cs" />
|
||||||
<Compile Include="SimpleMap.cs" />
|
<Compile Include="SimpleMap.cs" />
|
||||||
|
<Compile Include="TrolleybusDelegate.cs" />
|
||||||
<EmbeddedResource Include="Form1.resx">
|
<EmbeddedResource Include="Form1.resx">
|
||||||
<DependentUpon>Form1.cs</DependentUpon>
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
10
Trolleybus/Trolleybus/TrolleybusDelegate.cs
Normal file
10
Trolleybus/Trolleybus/TrolleybusDelegate.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Trolleybus
|
||||||
|
{
|
||||||
|
public delegate void TrolleybusDelegate(DrawingTrolleybus trolleybus);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user