[mapguide-commits] r6698 - in branches/2.4/MgDev/Desktop: MapViewer MapViewer/AppLayoutEngine MgAppLayout

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Sun May 27 19:03:52 PDT 2012


Author: jng
Date: 2012-05-27 19:03:52 -0700 (Sun, 27 May 2012)
New Revision: 6698

Modified:
   branches/2.4/MgDev/Desktop/MapViewer/AppLayoutEngine/AppLayout.cs
   branches/2.4/MgDev/Desktop/MapViewer/IMapViewer.cs
   branches/2.4/MgDev/Desktop/MapViewer/MgLegend.cs
   branches/2.4/MgDev/Desktop/MapViewer/MgMapViewer.cs
   branches/2.4/MgDev/Desktop/MgAppLayout/Sheboygan.AppLayout
Log:
mg-desktop updates:
 - Allow for layer selectability to be toggled in the MgLegend control
 - Add a new PointPixelBuffer property to IMapViewer, which allows the user to define the box size that a point should be inflated to for point-based selections from the Select tool.
 - Fix a small visual bug where the selection box remains if it produces no selection.

Modified: branches/2.4/MgDev/Desktop/MapViewer/AppLayoutEngine/AppLayout.cs
===================================================================
--- branches/2.4/MgDev/Desktop/MapViewer/AppLayoutEngine/AppLayout.cs	2012-05-25 11:57:18 UTC (rev 6697)
+++ branches/2.4/MgDev/Desktop/MapViewer/AppLayoutEngine/AppLayout.cs	2012-05-28 02:03:52 UTC (rev 6698)
@@ -47,7 +47,8 @@
                 SelectionColor = Util.ToHtmlColorWithAlpha(System.Drawing.Color.Blue),
                 ShowVertexCoordinatesWhenDigitizing = false,
                 ZoomInFactor = 0.5,
-                ZoomOutFactor = 2.0
+                ZoomOutFactor = 2.0,
+                PointPixelBuffer = 3
             };
             layout.InfoPane = new InfoPaneSettings()
             {
@@ -267,6 +268,9 @@
 
         [XmlElement]
         public double ZoomOutFactor { get; set; }
+
+        [XmlElement]
+        public int PointPixelBuffer { get; set; }
     }
 
     public class InfoPaneSettings

Modified: branches/2.4/MgDev/Desktop/MapViewer/IMapViewer.cs
===================================================================
--- branches/2.4/MgDev/Desktop/MapViewer/IMapViewer.cs	2012-05-25 11:57:18 UTC (rev 6697)
+++ branches/2.4/MgDev/Desktop/MapViewer/IMapViewer.cs	2012-05-28 02:03:52 UTC (rev 6698)
@@ -289,6 +289,11 @@
         /// Gets whether this viewer has a map loaded into it
         /// </summary>
         bool HasLoadedMap { get; }
+
+        /// <summary>
+        /// Gets or sets the amount of pixels to buffer out by when doing point-based selections with the Select tool
+        /// </summary>
+        int PointPixelBuffer { get; set; }
     }
 
     /// <summary>

Modified: branches/2.4/MgDev/Desktop/MapViewer/MgLegend.cs
===================================================================
--- branches/2.4/MgDev/Desktop/MapViewer/MgLegend.cs	2012-05-25 11:57:18 UTC (rev 6697)
+++ branches/2.4/MgDev/Desktop/MapViewer/MgLegend.cs	2012-05-28 02:03:52 UTC (rev 6698)
@@ -9,6 +9,7 @@
 using System.IO;
 using System.Xml;
 using System.Diagnostics;
+using System.Windows.Forms.VisualStyles;
 
 namespace OSGeo.MapGuide.Viewer
 {
@@ -448,7 +449,8 @@
             node.ImageKey = node.SelectedImageKey = IMG_OTHER;
             node.Tag = new LayerNodeMetadata(null) {
                 IsBaseLayer = false,
-                ThemeIcon = Properties.Resources.icon_etc
+                ThemeIcon = Properties.Resources.icon_etc,
+                IsThemeRule = true
             };
             return node;
         }
@@ -473,7 +475,8 @@
                     icon.Read(b, b.Length);
                     var tag = new LayerNodeMetadata(null)
                     {
-                        IsBaseLayer = false
+                        IsBaseLayer = false,
+                        IsThemeRule = true
                     };
                     using (var ms = new MemoryStream(b))
                     {
@@ -538,6 +541,7 @@
                 this.Layer = layer;
                 this.IsSelectable = (layer != null) ? layer.Selectable : false;
                 this.DrawSelectabilityIcon = (layer != null);
+                this.IsThemeRule = false;
             }
 
             internal MgLayerBase Layer { get; set; }
@@ -546,6 +550,8 @@
 
             public bool IsSelectable { get; set; }
 
+            public bool IsThemeRule { get; set; }
+
             public bool IsBaseLayer { get; set; }
 
             public Image ThemeIcon { get; set; }
@@ -701,13 +707,29 @@
                     foreColor = e.Node.ForeColor;
                 }
 
-                var selectabilityOffset = xoffset;
-                var iconOffsetNoSelect = xoffset;
+                var tag = e.Node.Tag as LayerNodeMetadata;
+                var checkBoxOffset = xoffset;
+                var selectabilityOffset = xoffset + 16;
+                var iconOffsetNoSelect = xoffset + 16;
+                if (tag != null && tag.IsThemeRule) //No checkbox for theme rule nodes
+                {
+                    selectabilityOffset = xoffset;
+                    iconOffsetNoSelect = xoffset;
+                }
                 var iconOffset = selectabilityOffset + 20;
                 var textOffset = iconOffset + 20;
                 var textOffsetNoSelect = iconOffsetNoSelect + 20;
 
-                var tag = e.Node.Tag as LayerNodeMetadata;
+                //Uncomment if you need to "see" the bounds of the node
+                //e.Graphics.DrawRectangle(Pens.Black, e.Node.Bounds);
+
+                if (tag != null && !tag.IsThemeRule) //No checkbox for theme rule nodes
+                {
+                    CheckBoxRenderer.DrawCheckBox(
+                        e.Graphics,
+                        new Point(e.Node.Bounds.X + checkBoxOffset, e.Node.Bounds.Y),
+                        e.Node.Checked ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal);
+                }
                 if (tag != null)
                 {
                     if (tag.DrawSelectabilityIcon)
@@ -829,6 +851,23 @@
             {
                 trvLegend.SelectedNode = e.Node;
             }
+            var meta = e.Node.Tag as LayerNodeMetadata;
+            if (meta != null && meta.DrawSelectabilityIcon)
+            {
+                //Toggle layer's selectability if it's within the bounds of the selectability icon
+                var box = new Rectangle(
+                    new Point((e.Node.Bounds.Location.X - 36) + 16, e.Node.Bounds.Location.Y), 
+                    new Size(16, e.Node.Bounds.Height));
+                if (box.Contains(e.X, e.Y))
+                {
+                    var layer = meta.Layer;
+                    layer.Selectable = !layer.Selectable;
+                    meta.IsSelectable = layer.Selectable;
+
+                    //TODO: This bounds is a guess. We should calculate the bounds as part of node rendering, so we know the exact bounds by which to invalidate
+                    trvLegend.Invalidate(new Rectangle(e.Node.Bounds.Location.X - 36, e.Node.Bounds.Location.Y, e.Node.Bounds.Width + 36, e.Node.Bounds.Height));
+                }
+            }
         }
 
         /// <summary>

Modified: branches/2.4/MgDev/Desktop/MapViewer/MgMapViewer.cs
===================================================================
--- branches/2.4/MgDev/Desktop/MapViewer/MgMapViewer.cs	2012-05-25 11:57:18 UTC (rev 6697)
+++ branches/2.4/MgDev/Desktop/MapViewer/MgMapViewer.cs	2012-05-28 02:03:52 UTC (rev 6698)
@@ -166,6 +166,7 @@
             this.ZoomInFactor = 0.5;
             this.ZoomOutFactor = 2.0;
             this.SelectionColor = Color.Blue;
+            this.PointPixelBuffer = 2;
 
             this.DigitizingFillTransparency = 100;
             this.DigitizingOutline = Brushes.Red;
@@ -530,6 +531,10 @@
             }
         }
 
+        [Category("MapGuide Viewer")]
+        [Description("The amount of pixels to buffer out by when doing point-based selections with the Select tool")]
+        public int PointPixelBuffer { get; set; }
+
         private Color _digitizingFillColor;
 
         [Category("MapGuide Viewer")]
@@ -1258,6 +1263,8 @@
             public MgViewerRenderingOptions MapRenderingOptions { get; set; }
 
             public bool RaiseEvents { get; set; }
+
+            public bool InvalidateRegardless { get; set; }
         }
 
         class RenderResult
@@ -1267,6 +1274,8 @@
             public Image SelectionImage { get; set; }
 
             public bool RaiseEvents { get; set; }
+
+            public bool InvalidateRegardless { get; set; }
         }
 
         /// <summary>
@@ -1304,6 +1313,11 @@
 
         internal void RenderSelection()
         {
+            RenderSelection(false);
+        }
+
+        internal void RenderSelection(bool invalidateRegardless)
+        {
             //This is our refresh action
             RefreshAction action = new RefreshAction(() => 
             {
@@ -1315,8 +1329,14 @@
                     {
                         SelectionRenderingOptions = _selectionRenderOpts,
                         RaiseEvents = false,
+                        InvalidateRegardless = invalidateRegardless
                     });
                 }
+                else
+                {
+                    if (invalidateRegardless)
+                        this.Invalidate();
+                }
             });
 
             //If an existing rendering operation is in progress queue it if 
@@ -1567,7 +1587,7 @@
         private void renderWorker_DoWork(object sender, DoWorkEventArgs e)
         {
             var args = (RenderWorkArgs)e.Argument;
-            var res = new RenderResult() { RaiseEvents = args.RaiseEvents };
+            var res = new RenderResult() { RaiseEvents = args.RaiseEvents, InvalidateRegardless = args.InvalidateRegardless };
             if (args.MapRenderingOptions != null)
             {
                 var br = _provider.RenderDynamicOverlay(null, args.MapRenderingOptions);
@@ -1639,7 +1659,7 @@
                 }
                 else 
                 {
-                    if (bInvalidate)
+                    if (bInvalidate || res.InvalidateRegardless)
                         Invalidate(true);
 
                     /*
@@ -2052,7 +2072,7 @@
             Trace.TraceInformation("Selection processing completed in {0}ms", sw.ElapsedMilliseconds);
 #endif
 
-            RenderSelection(); //This is either async or queued up. Either way do this before firing off selection changed
+            RenderSelection(true); //This is either async or queued up. Either way do this before firing off selection changed
             var handler = this.SelectionChanged;
             if (handler != null)
                 handler(this, EventArgs.Empty);
@@ -2194,8 +2214,8 @@
             {
                 if (this.ActiveTool == MapActiveTool.Select)
                 {
-                    var mapPt1 = ScreenToMapUnits(e.X - 2, e.Y - 2);
-                    var mapPt2 = ScreenToMapUnits(e.X + 2, e.Y + 2);
+                    var mapPt1 = ScreenToMapUnits(e.X - this.PointPixelBuffer, e.Y - this.PointPixelBuffer);
+                    var mapPt2 = ScreenToMapUnits(e.X + this.PointPixelBuffer, e.Y + this.PointPixelBuffer);
 
                     var coord1 = _geomFact.CreateCoordinateXY(mapPt1.X, mapPt1.Y);
                     var coord2 = _geomFact.CreateCoordinateXY(mapPt2.X, mapPt2.Y);

Modified: branches/2.4/MgDev/Desktop/MgAppLayout/Sheboygan.AppLayout
===================================================================
--- branches/2.4/MgDev/Desktop/MgAppLayout/Sheboygan.AppLayout	2012-05-25 11:57:18 UTC (rev 6697)
+++ branches/2.4/MgDev/Desktop/MgAppLayout/Sheboygan.AppLayout	2012-05-28 02:03:52 UTC (rev 6698)
@@ -9,6 +9,7 @@
     <ShowVertexCoordinatesWhenDigitizing>false</ShowVertexCoordinatesWhenDigitizing>
     <ZoomInFactor>0.5</ZoomInFactor>
     <ZoomOutFactor>2</ZoomOutFactor>
+    <PointPixelBuffer>3</PointPixelBuffer>
   </Settings>
   <InfoPane>
     <Width>200</Width>



More information about the mapguide-commits mailing list