From feae8d83d97a9f31ca8fd78b64c9e121380f15bb Mon Sep 17 00:00:00 2001 From: redmanmale Date: Wed, 11 Nov 2015 18:25:24 +0300 Subject: [PATCH] Implemented marker double click --- .../GMap.NET.WindowsForms/GMapControl.cs | 42 +++++++++++++++++++ .../GMap.NET.WindowsForms/GMapMarker.cs | 1 + 2 files changed, 43 insertions(+) diff --git a/GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapControl.cs b/GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapControl.cs index 07968b8d..a9aef559 100644 --- a/GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapControl.cs +++ b/GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapControl.cs @@ -30,6 +30,11 @@ namespace GMap.NET.WindowsForms public partial class GMapControl : UserControl, Interface { #if !PocketPC + /// + /// occurs when double clicked on marker + /// + public event MarkerDoubleClick OnMarkerDoubleClick; + /// /// occurs when clicked on marker /// @@ -1832,6 +1837,43 @@ protected override void OnMouseUp(MouseEventArgs e) } #if !PocketPC + protected override void OnMouseDoubleClick(MouseEventArgs e) + { + base.OnMouseDoubleClick(e); + + if (!Core.IsDragging) + { + for (int i = Overlays.Count - 1; i >= 0; i--) + { + GMapOverlay o = Overlays[i]; + if (o != null && o.IsVisibile) + { + foreach (var m in o.Markers) + { + if (m.IsVisible && m.IsHitTestVisible) + { + 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; + } + } + } + } + } + } + } + protected override void OnMouseClick(MouseEventArgs e) { base.OnMouseClick(e); diff --git a/GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapMarker.cs b/GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapMarker.cs index 93fba73e..224a7fe9 100644 --- a/GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapMarker.cs +++ b/GMap.NET.WindowsForms/GMap.NET.WindowsForms/GMapMarker.cs @@ -339,6 +339,7 @@ public virtual void Dispose() #endregion } + public delegate void MarkerDoubleClick(GMapMarker item, MouseEventArgs e); public delegate void MarkerClick(GMapMarker item, MouseEventArgs e); public delegate void MarkerEnter(GMapMarker item); public delegate void MarkerLeave(GMapMarker item);