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

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri May 25 04:18:52 EDT 2012


Author: jng
Date: 2012-05-25 01:18:51 -0700 (Fri, 25 May 2012)
New Revision: 6695

Modified:
   branches/2.4/MgDev/Desktop/MapViewer/AppLayoutEngine/AppLayout.cs
   branches/2.4/MgDev/Desktop/MapViewer/AppLayoutEngine/Shell.cs
   branches/2.4/MgDev/Desktop/MapViewer/IMapLegend.cs
   branches/2.4/MgDev/Desktop/MapViewer/MgLegend.Designer.cs
   branches/2.4/MgDev/Desktop/MapViewer/MgLegend.cs
   branches/2.4/MgDev/Desktop/MapViewer/Properties/Resources.Designer.cs
   branches/2.4/MgDev/Desktop/MapViewer/Properties/Resources.resx
   branches/2.4/MgDev/Desktop/MgAppLayout/Sheboygan.AppLayout
Log:
mg-desktop: Update MgLegend control to show selectability and basic layer information through tooltips if ShowTooltips is true. AppLayout support also included.

Modified: branches/2.4/MgDev/Desktop/MapViewer/AppLayoutEngine/AppLayout.cs
===================================================================
--- branches/2.4/MgDev/Desktop/MapViewer/AppLayoutEngine/AppLayout.cs	2012-05-25 07:00:59 UTC (rev 6694)
+++ branches/2.4/MgDev/Desktop/MapViewer/AppLayoutEngine/AppLayout.cs	2012-05-25 08:18:51 UTC (rev 6695)
@@ -289,7 +289,11 @@
         [XmlElement]
         public bool Visible { get; set; }
 
+        [XmlElement]
         public int? ThemeCompressionLimit { get; set; }
+
+        [XmlElement]
+        public bool ShowTooltips { get; set; }
     }
 
     public class PropertyPaneSettings

Modified: branches/2.4/MgDev/Desktop/MapViewer/AppLayoutEngine/Shell.cs
===================================================================
--- branches/2.4/MgDev/Desktop/MapViewer/AppLayoutEngine/Shell.cs	2012-05-25 07:00:59 UTC (rev 6694)
+++ branches/2.4/MgDev/Desktop/MapViewer/AppLayoutEngine/Shell.cs	2012-05-25 08:18:51 UTC (rev 6695)
@@ -35,6 +35,7 @@
             if (_layout.InfoPane.IsVisible)
             {
                 SetLegendVisbility(_layout.InfoPane.Legend.Visible);
+                legend.ShowTooltips = _layout.InfoPane.Legend.ShowTooltips;
                 if (_layout.InfoPane.Legend.ThemeCompressionLimit.HasValue)
                     legend.ThemeCompressionLimit = _layout.InfoPane.Legend.ThemeCompressionLimit.Value;
                 SetPropertyPaneVisbility(_layout.InfoPane.PropertyPane.Visible);

Modified: branches/2.4/MgDev/Desktop/MapViewer/IMapLegend.cs
===================================================================
--- branches/2.4/MgDev/Desktop/MapViewer/IMapLegend.cs	2012-05-25 07:00:59 UTC (rev 6694)
+++ branches/2.4/MgDev/Desktop/MapViewer/IMapLegend.cs	2012-05-25 08:18:51 UTC (rev 6695)
@@ -43,6 +43,11 @@
         int ThemeCompressionLimit { get; set; }
 
         /// <summary>
+        /// Gets whether to show tooltips over nodes in the legend control
+        /// </summary>
+        bool ShowTooltips { get; set; }
+
+        /// <summary>
         /// Gets the selected layer
         /// </summary>
         /// <returns></returns>

Modified: branches/2.4/MgDev/Desktop/MapViewer/MgLegend.Designer.cs
===================================================================
--- branches/2.4/MgDev/Desktop/MapViewer/MgLegend.Designer.cs	2012-05-25 07:00:59 UTC (rev 6694)
+++ branches/2.4/MgDev/Desktop/MapViewer/MgLegend.Designer.cs	2012-05-25 08:18:51 UTC (rev 6695)
@@ -44,6 +44,7 @@
             this.trvLegend.Name = "trvLegend";
             this.trvLegend.SelectedImageIndex = 0;
             this.trvLegend.ShowLines = false;
+            this.trvLegend.ShowNodeToolTips = true;
             this.trvLegend.Size = new System.Drawing.Size(150, 150);
             this.trvLegend.TabIndex = 0;
             this.trvLegend.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.trvLegend_AfterCheck);

Modified: branches/2.4/MgDev/Desktop/MapViewer/MgLegend.cs
===================================================================
--- branches/2.4/MgDev/Desktop/MapViewer/MgLegend.cs	2012-05-25 07:00:59 UTC (rev 6694)
+++ branches/2.4/MgDev/Desktop/MapViewer/MgLegend.cs	2012-05-25 08:18:51 UTC (rev 6695)
@@ -39,6 +39,9 @@
         private MgMapViewerProvider _provider;
         private MgMapBase _map;
 
+        private Image _selectableIcon;
+        private Image _unselectableIcon;
+
         /// <summary>
         /// Initializes a new instance of the <see cref="MgLegend"/> class.
         /// </summary>
@@ -52,6 +55,8 @@
             _provider = provider;
             _map = _provider.GetMap();
             _resSvc = (MgResourceService)_provider.CreateService(MgServiceType.ResourceService);
+            _selectableIcon = Properties.Resources.lc_select;
+            _unselectableIcon = Properties.Resources.lc_unselect;
             RefreshLegend();
         }
 
@@ -235,9 +240,27 @@
             }
         }
 
+        private static void ClearNodes(TreeNodeCollection nodes)
+        {
+            foreach (TreeNode node in nodes)
+            {
+                if (node.Nodes.Count > 0)
+                    ClearNodes(node.Nodes);
+
+                var layerMeta = node.Tag as LayerNodeMetadata;
+                if (layerMeta != null && layerMeta.ThemeIcon != null)
+                {
+                    layerMeta.Layer = null;
+                    layerMeta.ThemeIcon.Dispose();
+                    layerMeta.ThemeIcon = null;
+                }
+            }
+            nodes.Clear();
+        }
+
         private void ResetTreeView()
         {
-            trvLegend.Nodes.Clear();
+            ClearNodes(trvLegend.Nodes);
             imgLegend.Images.Clear();
 
             imgLegend.Images.Add(IMG_BROKEN, Properties.Resources.lc_broken);
@@ -264,6 +287,7 @@
             {
                 node.SelectedImageKey = node.ImageKey = IMG_DWF;
                 node.Tag = new LayerNodeMetadata(layer);
+                node.ToolTipText = string.Format(Properties.Resources.DrawingLayerTooltip, Environment.NewLine, layer.Name, layer.FeatureSourceId);
             }
             else
             {
@@ -318,8 +342,12 @@
 
                                 imgLegend.Images.Add(id, img);
                                 node.SelectedImageKey = node.ImageKey = id;
+                                node.Tag = new LayerNodeMetadata(layer)
+                                {
+                                    ThemeIcon = img
+                                };
+                                node.ToolTipText = string.Format(Properties.Resources.DefaultLayerTooltip, Environment.NewLine, layer.Name, layer.FeatureSourceId, layer.FeatureClassName);
                             }
-                            node.Tag = new LayerNodeMetadata(layer);
                         }
                         finally
                         {
@@ -368,6 +396,12 @@
                             if (rules.Count > 1)
                             {
                                 node.SelectedImageKey = node.ImageKey = IMG_THEME;
+                                var layerMeta = node.Tag as LayerNodeMetadata;
+                                if (layerMeta != null)
+                                {
+                                    layerMeta.ThemeIcon = Properties.Resources.lc_theme;
+                                    node.ToolTipText = string.Format(Properties.Resources.ThemedLayerTooltip, Environment.NewLine, layer.Name, layer.FeatureSourceId, layer.FeatureClassName, rules.Count);
+                                }
                                 if (this.ThemeCompressionLimit > 0 && rules.Count > this.ThemeCompressionLimit)
                                 {
                                     AddThemeRuleNode(layer, node, geomType, 0, rules, 0);
@@ -502,10 +536,16 @@
             { 
                 base.IsGroup = false;
                 this.Layer = layer;
+                this.IsSelectable = (layer != null) ? layer.Selectable : false;
+                this.DrawSelectabilityIcon = (layer != null);
             }
 
             internal MgLayerBase Layer { get; set; }
 
+            public bool DrawSelectabilityIcon { get; set; }
+
+            public bool IsSelectable { get; set; }
+
             public bool IsBaseLayer { get; set; }
 
             public Image ThemeIcon { get; set; }
@@ -629,9 +669,15 @@
             return false;
         }
 
+        private static bool IsLayerNode(TreeNode node)
+        {
+            var meta = node.Tag as LayerNodeMetadata;
+            return meta != null;
+        }
+
         private void trvLegend_DrawNode(object sender, DrawTreeNodeEventArgs e)
         {
-            if (IsThemeLayerNode(e.Node) && !e.Bounds.IsEmpty)
+            if (IsLayerNode(e.Node) && !e.Bounds.IsEmpty)
             {
                 Color backColor, foreColor;
 
@@ -655,29 +701,46 @@
                     foreColor = e.Node.ForeColor;
                 }
 
-                /*
-                using (SolidBrush brush = new SolidBrush(backColor))
+                var selectabilityOffset = xoffset;
+                var iconOffsetNoSelect = xoffset;
+                var iconOffset = selectabilityOffset + 20;
+                var textOffset = iconOffset + 20;
+                var textOffsetNoSelect = iconOffsetNoSelect + 20;
+
+                var tag = e.Node.Tag as LayerNodeMetadata;
+                if (tag != null)
                 {
-                    e.Graphics.FillRectangle(brush, e.Node.Bounds);
-                }*/
+                    if (tag.DrawSelectabilityIcon)
+                    {
+                        var icon = tag.IsSelectable ? _selectableIcon : _unselectableIcon;
+                        e.Graphics.DrawImage(icon, e.Node.Bounds.X + selectabilityOffset, e.Node.Bounds.Y);
+                        Trace.TraceInformation("Painted icon at ({0},{1})", e.Node.Bounds.X, e.Node.Bounds.Y);
+                    }
+                    if (tag.ThemeIcon != null)
+                    {
+                        if (tag.DrawSelectabilityIcon)
+                        {
+                            e.Graphics.DrawImage(tag.ThemeIcon, e.Node.Bounds.X + iconOffset, e.Node.Bounds.Y);
+                            Trace.TraceInformation("Painted icon at ({0},{1})", e.Node.Bounds.X, e.Node.Bounds.Y);
+                        }
+                        else
+                        {
+                            e.Graphics.DrawImage(tag.ThemeIcon, e.Node.Bounds.X + iconOffsetNoSelect, e.Node.Bounds.Y);
+                            Trace.TraceInformation("Painted icon at ({0},{1})", e.Node.Bounds.X, e.Node.Bounds.Y);
+                        }
+                    }
 
-                //TextRenderer.DrawText(e.Graphics, e.Node.Text, trvLegend.Font, e.Node.Bounds, foreColor, backColor);
-                using (SolidBrush brush = new SolidBrush(Color.Black))
-                {
-                    e.Graphics.DrawString(e.Node.Text, trvLegend.Font, brush, e.Node.Bounds.X + 17.0f + xoffset, e.Node.Bounds.Y);
+                    using (SolidBrush brush = new SolidBrush(Color.Black))
+                    {
+                        e.Graphics.DrawString(e.Node.Text, trvLegend.Font, brush, e.Node.Bounds.X + (tag.DrawSelectabilityIcon ? textOffset : textOffsetNoSelect), e.Node.Bounds.Y);
+                    }
                 }
-
-                /*
-                if ((e.State & TreeNodeStates.Focused) == TreeNodeStates.Focused)
+                else
                 {
-                    ControlPaint.DrawFocusRectangle(e.Graphics, e.Node.Bounds, foreColor, backColor);
-                }*/
-
-                var tag = e.Node.Tag as LayerNodeMetadata;
-                if (tag != null && tag.ThemeIcon != null)
-                {
-                    e.Graphics.DrawImage(tag.ThemeIcon, e.Node.Bounds.X + xoffset, e.Node.Bounds.Y);
-                    Trace.TraceInformation("Painted icon at ({0},{1})", e.Node.Bounds.X, e.Node.Bounds.Y);
+                    using (SolidBrush brush = new SolidBrush(Color.Black))
+                    {
+                        e.Graphics.DrawString(e.Node.Text, trvLegend.Font, brush, e.Node.Bounds.X + 17.0f + xoffset, e.Node.Bounds.Y);
+                    }
                 }
 
                 e.DrawDefault = false;
@@ -805,5 +868,11 @@
 
             return null;
         }
+
+        public bool ShowTooltips
+        {
+            get { return trvLegend.ShowNodeToolTips; }
+            set { trvLegend.ShowNodeToolTips = value; }
+        }
     }
 }

Modified: branches/2.4/MgDev/Desktop/MapViewer/Properties/Resources.Designer.cs
===================================================================
--- branches/2.4/MgDev/Desktop/MapViewer/Properties/Resources.Designer.cs	2012-05-25 07:00:59 UTC (rev 6694)
+++ branches/2.4/MgDev/Desktop/MapViewer/Properties/Resources.Designer.cs	2012-05-25 08:18:51 UTC (rev 6695)
@@ -1,7 +1,7 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     This code was generated by a tool.
-//     Runtime Version:2.0.50727.5420
+//     Runtime Version:2.0.50727.4971
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     the code is regenerated.
@@ -145,6 +145,24 @@
             }
         }
         
+        /// <summary>
+        ///   Looks up a localized string similar to Name: {1}{0}Feature Source: {2}{0}Feature Class: {3}.
+        /// </summary>
+        internal static string DefaultLayerTooltip {
+            get {
+                return ResourceManager.GetString("DefaultLayerTooltip", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Name: {1}{0}Feature Source: {2}.
+        /// </summary>
+        internal static string DrawingLayerTooltip {
+            get {
+                return ResourceManager.GetString("DrawingLayerTooltip", resourceCulture);
+            }
+        }
+        
         internal static System.Drawing.Bitmap edit_copy {
             get {
                 object obj = ResourceManager.GetObject("edit_copy", resourceCulture);
@@ -757,6 +775,15 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Name: {1}{0}Feature Source: {2}{0}Feature Class: {3}{0}Number of Rules: {4}.
+        /// </summary>
+        internal static string ThemedLayerTooltip {
+            get {
+                return ResourceManager.GetString("ThemedLayerTooltip", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Buffer.
         /// </summary>
         internal static string TitleBuffer {

Modified: branches/2.4/MgDev/Desktop/MapViewer/Properties/Resources.resx
===================================================================
--- branches/2.4/MgDev/Desktop/MapViewer/Properties/Resources.resx	2012-05-25 07:00:59 UTC (rev 6694)
+++ branches/2.4/MgDev/Desktop/MapViewer/Properties/Resources.resx	2012-05-25 08:18:51 UTC (rev 6695)
@@ -436,4 +436,13 @@
   <data name="TextExitApplication" xml:space="preserve">
     <value>Exit</value>
   </data>
+  <data name="DefaultLayerTooltip" xml:space="preserve">
+    <value>Name: {1}{0}Feature Source: {2}{0}Feature Class: {3}</value>
+  </data>
+  <data name="DrawingLayerTooltip" xml:space="preserve">
+    <value>Name: {1}{0}Feature Source: {2}</value>
+  </data>
+  <data name="ThemedLayerTooltip" xml:space="preserve">
+    <value>Name: {1}{0}Feature Source: {2}{0}Feature Class: {3}{0}Number of Rules: {4}</value>
+  </data>
 </root>
\ No newline at end of file

Modified: branches/2.4/MgDev/Desktop/MgAppLayout/Sheboygan.AppLayout
===================================================================
--- branches/2.4/MgDev/Desktop/MgAppLayout/Sheboygan.AppLayout	2012-05-25 07:00:59 UTC (rev 6694)
+++ branches/2.4/MgDev/Desktop/MgAppLayout/Sheboygan.AppLayout	2012-05-25 08:18:51 UTC (rev 6695)
@@ -14,6 +14,7 @@
     <Width>200</Width>
     <Legend>
       <Visible>true</Visible>
+      <ShowTooltips>true</ShowTooltips>
       <ThemeCompressionLimit>25</ThemeCompressionLimit>
     </Legend>
     <PropertyPane>



More information about the mapguide-commits mailing list