Skip to content

Commit

Permalink
Merge pull request radioman#2 from luxiaoxun/master
Browse files Browse the repository at this point in the history
Add mouse double click event on marker polygon route
  • Loading branch information
jelinj8 authored Mar 27, 2018
2 parents 9ad037f + dd8e440 commit e9c3ea9
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 0 deletions.
100 changes: 100 additions & 0 deletions GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,31 @@ public partial class GMapControl : UserControl, Interface
/// </summary>
public event MarkerClick OnMarkerClick;

/// <summary>
/// occurs when double clicked on marker
/// </summary>
public event MarkerDoubleClick OnMarkerDoubleClick;

/// <summary>
/// occurs when clicked on polygon
/// </summary>
public event PolygonClick OnPolygonClick;

/// <summary>
/// occurs when double clicked on polygon
/// </summary>
public event PolygonDoubleClick OnPolygonDoubleClick;

/// <summary>
/// occurs when clicked on route
/// </summary>
public event RouteClick OnRouteClick;

/// <summary>
/// occurs when double clicked on route
/// </summary>
public event RouteDoubleClick OnRouteDoubleClick;

/// <summary>
/// occurs on mouse enters route area
/// </summary>
Expand Down Expand Up @@ -1920,7 +1935,92 @@ protected override void OnMouseClick(MouseEventArgs e)
// base.Invalidate();
//}
}

protected override void OnMouseDoubleClick(MouseEventArgs e)
{
base.OnMouseClick(e);

if (!Core.IsDragging)
{
for (int i = Overlays.Count - 1; i >= 0; i--)
{
GMapOverlay o = Overlays[i];
if (o != null && o.IsVisibile)
{
foreach (GMapMarker m in o.Markers)
{
if (m.IsVisible && m.IsHitTestVisible)
{
#region -- check --

GPoint rp = new GPoint(e.X, e.Y);
#if !PocketPC
if (!MobileMode)
{
rp.OffsetNegative(Core.renderOffset);
}
#endif
if (m.LocalArea.Contains((int)rp.X, (int)rp.Y))
{
if (OnMarkerDoubleClick != null)
{
OnMarkerDoubleClick(m, e);
}
break;
}

#endregion
}
}

foreach (GMapRoute m in o.Routes)
{
if (m.IsVisible && m.IsHitTestVisible)
{
#region -- check --

GPoint rp = new GPoint(e.X, e.Y);
#if !PocketPC
if (!MobileMode)
{
rp.OffsetNegative(Core.renderOffset);
}
#endif
if (m.IsInside((int)rp.X, (int)rp.Y))
{
if (OnRouteDoubleClick != null)
{
OnRouteDoubleClick(m, e);
}
break;
}
#endregion
}
}

foreach (GMapPolygon m in o.Polygons)
{
if (m.IsVisible && m.IsHitTestVisible)
{
#region -- check --
if (m.IsInside(FromLocalToLatLng(e.X, e.Y)))
{
if (OnPolygonDoubleClick != null)
{
OnPolygonDoubleClick(m, e);
}
break;
}
#endregion
}
}
}
}
}
}

#endif

#if !PocketPC
/// <summary>
/// apply transformation if in rotation mode
Expand Down
1 change: 1 addition & 0 deletions GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapMarker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ public virtual void Dispose()
public delegate void MarkerClick(GMapMarker item, MouseEventArgs e);
public delegate void MarkerEnter(GMapMarker item);
public delegate void MarkerLeave(GMapMarker item);
public delegate void MarkerDoubleClick(GMapMarker item, MouseEventArgs e);

/// <summary>
/// modeof tooltip
Expand Down
1 change: 1 addition & 0 deletions GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapPolygon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,5 @@ public virtual void Dispose()
public delegate void PolygonClick(GMapPolygon item, MouseEventArgs e);
public delegate void PolygonEnter(GMapPolygon item);
public delegate void PolygonLeave(GMapPolygon item);
public delegate void PolygonDoubleClick(GMapPolygon item, MouseEventArgs e);
}
1 change: 1 addition & 0 deletions GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapRoute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,5 @@ public virtual void Dispose()
public delegate void RouteClick(GMapRoute item, MouseEventArgs e);
public delegate void RouteEnter(GMapRoute item);
public delegate void RouteLeave(GMapRoute item);
public delegate void RouteDoubleClick(GMapRoute item, MouseEventArgs e);
}

0 comments on commit e9c3ea9

Please sign in to comment.