Yahontov O.U. LabWork5 #6
@ -13,6 +13,7 @@ namespace Trolleybus
|
||||
public partial class FormTrolleybusConfig : Form
|
||||
{
|
||||
DrawingTrolleybus _trolleybus = null;
|
||||
private event TrolleybusDelegate EventAddTrolleybus;
|
||||
|
||||
public FormTrolleybusConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -27,6 +28,18 @@ namespace Trolleybus
|
||||
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)
|
||||
{
|
||||
|
||||
@ -37,7 +50,7 @@ namespace Trolleybus
|
||||
(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))
|
||||
{
|
||||
@ -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())
|
||||
{
|
||||
@ -63,5 +76,10 @@ namespace Trolleybus
|
||||
}
|
||||
DrawTrolleybus();
|
||||
}
|
||||
private void ButtonOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddTrolleybus?.Invoke(_trolleybus);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,6 +87,7 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SetTrolleybusGeneric.cs" />
|
||||
<Compile Include="SimpleMap.cs" />
|
||||
<Compile Include="TrolleybusDelegate.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</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…
Reference in New Issue
Block a user
Делегат следовало заменить на встроенный