[mapguide-commits] r7018 - in trunk/Tools/Maestro: Maestro.MapViewer OSGeo.MapGuide.MaestroAPI/Mapping

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Sep 14 06:17:23 PDT 2012


Author: jng
Date: 2012-09-14 06:17:23 -0700 (Fri, 14 Sep 2012)
New Revision: 7018

Modified:
   trunk/Tools/Maestro/Maestro.MapViewer/MapViewer.cs
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs
Log:
#2018: Port over mg-desktop viewer enhancements to the Maestro MapViewer component. This includes the delayed tooltips and mouse interaction suppression when viewer is busy

Modified: trunk/Tools/Maestro/Maestro.MapViewer/MapViewer.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.MapViewer/MapViewer.cs	2012-09-14 12:56:47 UTC (rev 7017)
+++ trunk/Tools/Maestro/Maestro.MapViewer/MapViewer.cs	2012-09-14 13:17:23 UTC (rev 7018)
@@ -195,6 +195,7 @@
             this.TooltipFillColor = Color.LightYellow;
             this.TooltipFillTransparency = 200;
             this.MouseWheelDelayRenderInterval = 800;
+            this.TooltipDelayInterval = 1000;
 
             this.ActiveTool = MapActiveTool.None;
             this.DoubleBuffered = true;
@@ -229,6 +230,7 @@
             base.MouseHover += OnMapMouseHover;
             base.MouseEnter += OnMouseEnter;
             base.MouseWheel += OnMapMouseWheel;
+            base.MouseLeave += OnMapMouseLeave;
         }
 
         /// <summary>
@@ -298,6 +300,7 @@
                 base.MouseDoubleClick -= OnMapMouseDoubleClick;
                 base.MouseHover -= OnMapMouseHover;
                 base.MouseEnter -= OnMouseEnter;
+                base.MouseLeave -= OnMapMouseLeave; 
 
                 if (renderWorker != null)
                 {
@@ -329,6 +332,13 @@
         [Description("The amount of time (in ms) to wait to re-render after a mouse wheel scroll")]
         public int MouseWheelDelayRenderInterval { get; set; }
 
+        /// <summary> 
+        /// The amount of time (in ms) to wait to re-render after a mouse wheel scroll 
+        /// </summary> 
+        [Category("MapGuide Viewer")]
+        [Description("The amount of time (in ms) to wait to fire off a tooltip request after the mouse pointer becomes stationary")]
+        public int TooltipDelayInterval { get; set; } 
+
         private Color _selColor;
 
         /// <summary>
@@ -1928,8 +1938,6 @@
             return "POLYGON((" + x1 + " " + y1 + ", " + x2 + " " + y1 + ", " + x2 + " " + y2 + ", " + x1 + " " + y2 + ", " + x1 + " " + y1 + "))";
         }
 
-        
-
         private int? _lastTooltipX;
         private int? _lastTooltipY;
 
@@ -1969,9 +1977,8 @@
                 });
             try
             {
-                var doc = new XmlDocument();
-                doc.LoadXml(res);
-                return doc.DocumentElement["Tooltip"].InnerText;
+                _tooltipDoc.LoadXml(res);
+                return _tooltipDoc.DocumentElement["Tooltip"].InnerText;
             }
             catch
             {
@@ -1979,6 +1986,8 @@
             }
         }
 
+        private XmlDocument _tooltipDoc = new XmlDocument();
+
         private static string[] GetAllLayerNames(RuntimeMap map)
         {
             var names = new List<string>();
@@ -2065,35 +2074,48 @@
 
         #region Mouse handlers
 
+        private void OnMapMouseLeave(object sender, EventArgs e)
+        {
+            //Need to do this otherwise a tooltip query is made at the viewer boundary 
+ 		    if (delayTooltipTimer != null && delayTooltipTimer.Enabled) 
+ 		        delayTooltipTimer.Stop(); 
+        }
+
         private void OnMapMouseDown(object sender, MouseEventArgs e)
         {
+            if (IsBusy) return;
             HandleMouseDown(e);
         }
 
         private void OnMapMouseMove(object sender, MouseEventArgs e)
         {
+            if (IsBusy) return;
             HandleMouseMove(e);
         }
         
         private void OnMapMouseUp(object sender, MouseEventArgs e)
         {
+            if (IsBusy) return;
             HandleMouseUp(e);
         }
 
         private void OnMapMouseWheel(object sender, MouseEventArgs e)
         {
+            if (IsBusy) return;
             this.Focus();
             HandleMouseWheel(e);
         }
 
         private void OnMapMouseClick(object sender, MouseEventArgs e)
         {
+            if (IsBusy) return;
             this.Focus();
             HandleMouseClick(e);
         }
 
         private void OnMapMouseDoubleClick(object sender, MouseEventArgs e)
         {
+            if (IsBusy) return;
             this.Focus();
             HandleMouseDoubleClick(e);
         }
@@ -2468,15 +2490,22 @@
                    (this.ActiveTool == MapActiveTool.Select || this.ActiveTool == MapActiveTool.Pan) &&
                     this.TooltipsEnabled)
                 {
-#if TRACE
-                    var sw = new Stopwatch();
-                    sw.Start();
-#endif
-                    _activeTooltipText = QueryFirstVisibleTooltip(e.X, e.Y);
-#if TRACE
-                    sw.Stop();
-                    Trace.TraceInformation("QueryFirstVisibleTooltip() executed in {0}ms", sw.ElapsedMilliseconds);
-#endif
+                    if (delayTooltipTimer == null) 
+ 		            { 
+ 		                delayTooltipTimer = new System.Timers.Timer(); 
+ 		                delayTooltipTimer.Enabled = false; 
+ 		                delayTooltipTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnDelayTooltipTimerElapsed); 
+ 		                delayTooltipTimer.Interval = this.TooltipDelayInterval; 
+ 		            } 
+ 		 
+ 		            _delayTooltipQueryPoint = new Point(e.X, e.Y); 
+ 		            delayTooltipTimer.Start(); 
+ 		 
+ 		            if (Math.Abs(e.X - _lastTooltipQueryX) > 2 || Math.Abs(e.Y - _lastTooltipQueryY) > 2) 
+ 		            { 
+ 		                _activeTooltipText = null; 
+ 		                Invalidate(); 
+ 		            } 
                 }
                 else
                 {
@@ -2499,6 +2528,24 @@
             }
         }
 
+        void OnDelayTooltipTimerElapsed(object sender, System.Timers.ElapsedEventArgs e) 
+ 		{ 
+ 		    delayTooltipTimer.Stop(); 
+ 		    if (_delayTooltipQueryPoint.HasValue) 
+ 		    { 
+ 		        _activeTooltipText = QueryFirstVisibleTooltip(_delayTooltipQueryPoint.Value.X, _delayTooltipQueryPoint.Value.Y); 
+ 		        _lastTooltipQueryX = _delayTooltipQueryPoint.Value.X; 
+ 		        _lastTooltipQueryY = _delayTooltipQueryPoint.Value.Y; 
+ 		        _delayTooltipQueryPoint = null; 
+ 		        Invalidate(); 
+ 		    } 
+ 		} 
+ 		 
+ 		private int _lastTooltipQueryX; 
+ 		private int _lastTooltipQueryY; 
+ 		private Point? _delayTooltipQueryPoint = null; 
+ 		private System.Timers.Timer delayTooltipTimer = null; 
+
         private void HandleMouseUp(MouseEventArgs e)
         {
             if (isDragging)

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs	2012-09-14 12:56:47 UTC (rev 7017)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs	2012-09-14 13:17:23 UTC (rev 7018)
@@ -1577,7 +1577,7 @@
             if (_mapSvc == null)
                 throw new NotSupportedException();
 
-            var ret = _mapSvc.QueryMapFeatures(this, maxFeatures, wkt, true, selectionVariant, extraOptions);
+            var ret = _mapSvc.QueryMapFeatures(this, maxFeatures, wkt, persist, selectionVariant, extraOptions);
 
             //Need to re-sync the selection as this will probably have been changed
             ReloadSelection();



More information about the mapguide-commits mailing list