[mapguide-commits] r7510 - trunk/Tools/Maestro/Maestro.MapViewer

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue May 21 08:03:30 PDT 2013


Author: jng
Date: 2013-05-21 08:03:29 -0700 (Tue, 21 May 2013)
New Revision: 7510

Modified:
   trunk/Tools/Maestro/Maestro.MapViewer/Legend.cs
   trunk/Tools/Maestro/Maestro.MapViewer/LegendPresenter.cs
Log:
This submission contains the following changes:
 - #2248: Previous fix was incorrect. This is the proper infinite looping fix for nested groups.
 - Add ParentGroupName to LayerNodeMetadata and GroupNodeMetadata
 - Enable/Disable the Legend in a cross-thread safe manner.

Modified: trunk/Tools/Maestro/Maestro.MapViewer/Legend.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.MapViewer/Legend.cs	2013-05-20 12:26:02 UTC (rev 7509)
+++ trunk/Tools/Maestro/Maestro.MapViewer/Legend.cs	2013-05-21 15:03:29 UTC (rev 7510)
@@ -100,7 +100,13 @@
         void OnViewerPropertyChanged(object sender, PropertyChangedEventArgs e)
         {
             if (e.PropertyName == "IsBusy")
-                this.Enabled = !_viewer.IsBusy;
+            {
+                Action<bool> set = (value) => { this.Enabled = value; };
+                if (this.InvokeRequired)
+                    this.Invoke(set, !_viewer.IsBusy);
+                else
+                    set(!_viewer.IsBusy);
+            }
         }
 
         void OnMapLoaded(object sender, EventArgs e)

Modified: trunk/Tools/Maestro/Maestro.MapViewer/LegendPresenter.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.MapViewer/LegendPresenter.cs	2013-05-20 12:26:02 UTC (rev 7509)
+++ trunk/Tools/Maestro/Maestro.MapViewer/LegendPresenter.cs	2013-05-21 15:03:29 UTC (rev 7510)
@@ -393,36 +393,36 @@
                     nodesById.Add(group.ObjectId, node);
                     groupsById.Add(group.ObjectId, node);
                 }
+            }
 
-                //Process child groups
-                while (remainingNodes.Count > 0)
+            //Process child groups
+            while (remainingNodes.Count > 0)
+            {
+                List<RuntimeMapGroup> toRemove = new List<RuntimeMapGroup>();
+                //Establish parent-child relationships for any child groups here
+                for (int j = 0; j < remainingNodes.Count; j++)
                 {
-                    List<RuntimeMapGroup> toRemove = new List<RuntimeMapGroup>();
-                    //Establish parent-child relationships for any child groups here
-                    for (int j = 0; j < remainingNodes.Count; j++)
+                    var grpName = remainingNodes[j].Group;
+                    var parentGroup = _map.Groups[grpName];
+                    if (parentGroup != null && nodesById.ContainsKey(parentGroup.ObjectId))
                     {
-                        var grpName = remainingNodes[j].Group;
-                        var parentGroup = _map.Groups[grpName];
-                        if (parentGroup != null && nodesById.ContainsKey(parentGroup.ObjectId))
-                        {
-                            var node = CreateGroupNode(remainingNodes[j]);
-                            nodesById[parentGroup.ObjectId].Nodes.Add(node);
+                        var node = CreateGroupNode(remainingNodes[j]);
+                        nodesById[parentGroup.ObjectId].Nodes.Add(node);
+                        var grpId = remainingNodes[j].ObjectId;
+                        //Got to add this group node too, otherwise we could infinite
+                        //loop looking for a parent that's not registered
+                        nodesById.Add(grpId, node);
+                        groupsById.Add(grpId, node);
 
-                            //Got to add this group node too, otherwise we could infinite
-                            //loop looking for a parent that's not registered
-                            nodesById.Add(group.ObjectId, node);
-                            groupsById.Add(group.ObjectId, node);
-
-                            toRemove.Add(remainingNodes[j]);
-                        }
+                        toRemove.Add(remainingNodes[j]);
                     }
-                    //Whittle down this list
-                    if (toRemove.Count > 0)
+                }
+                //Whittle down this list
+                if (toRemove.Count > 0)
+                {
+                    foreach (var g in toRemove)
                     {
-                        foreach (var g in toRemove)
-                        {
-                            remainingNodes.Remove(g);
-                        }
+                        remainingNodes.Remove(g);
                     }
                 }
             }
@@ -880,6 +880,8 @@
 
             public string LegendLabel { get { return this.Group.LegendLabel; } }
 
+            public string ParentGroupName { get { return this.Group.Group; } }
+
             public string Name { get { return this.Group.Name; } }
 
             public override string ObjectId
@@ -990,6 +992,11 @@
             }
 
             /// <summary>
+            /// Gets the parent group name
+            /// </summary>
+            public string ParentGroupName { get { return this.Layer.Group; } }
+
+            /// <summary>
             /// Gets the name
             /// </summary>
             public string Name { get { return this.Layer.Name; } }



More information about the mapguide-commits mailing list