Yahontov O.U. LabWork5 #6

Closed
Arklightning wants to merge 5 commits from LabWork5 into LabWork4
3 changed files with 31 additions and 2 deletions
Showing only changes of commit 12ec39dd21 - Show all commits

View File

@ -13,6 +13,7 @@ namespace Trolleybus
public partial class FormTrolleybusConfig : Form
{
DrawingTrolleybus _trolleybus = null;
private event TrolleybusDelegate EventAddTrolleybus;
Review

Делегат следовало заменить на встроенный

Делегат следовало заменить на встроенный
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();
}
}
}

View File

@ -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>

View 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);
}