[mapguide-commits] r5938 - trunk/Tools/Maestro/Maestro.Editors/MapDefinition

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Jun 22 08:40:41 EDT 2011


Author: jng
Date: 2011-06-22 05:40:40 -0700 (Wed, 22 Jun 2011)
New Revision: 5938

Modified:
   trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs
Log:
Small Map Definition editor usability tweak. Expand the item that is being dropped on.


Modified: trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs	2011-06-22 12:18:32 UTC (rev 5937)
+++ trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs	2011-06-22 12:40:40 UTC (rev 5938)
@@ -387,6 +387,31 @@
                 tree.SelectedNode = selectedNode;
         }
 
+        private static void ExpandNode<TaggedType>(TreeViewAdv tree, Predicate<TaggedType> predicate) where TaggedType : class
+        {
+            //Restore selection
+            TreeNodeAdv selectedNode = null;
+            foreach (var node in tree.AllNodes)
+            {
+                var tag = node.Tag as TaggedType;
+
+                if (tag != null && predicate(tag))
+                {
+                    selectedNode = node;
+                    break;
+                }
+            }
+            if (selectedNode != null)
+            {
+                var n = selectedNode;
+                while (n != null)
+                {
+                    n.Expand();
+                    n = n.Parent;
+                }
+            }
+        }
+
         private void RestoreBaseLayerSelection(BaseLayerItem item)
         {
             //The node tag will probably be different, but the wrapped
@@ -723,7 +748,8 @@
             if (rids != null && rids.Length > 0)
             {
                 IMapLayerGroup parent = null;
-                var node = trvLayersGroup.GetNodeAt(trvLayersGroup.PointToClient(new Point(e.X, e.Y)));
+                var clientPt = trvLayersGroup.PointToClient(new Point(e.X, e.Y));
+                var node = trvLayersGroup.GetNodeAt(clientPt);
                 if (node != null)
                 {
                     var gi = node.Tag as GroupItem;
@@ -746,12 +772,15 @@
                 {
                     //TODO: Fine-grain invalidation
                     RefreshModels();
+                    if (parent != null)
+                        ExpandNode<GroupItem>(trvLayersGroup, (tag) => { return tag.Tag == parent; });
                 }
             }
             else if (nodes != null && nodes.Length > 0)
             {
                 IMapLayerGroup parent = null;
-                var node = trvLayersGroup.GetNodeAt(trvLayersGroup.PointToClient(new Point(e.X, e.Y)));
+                var clientPt = trvLayersGroup.PointToClient(new Point(e.X, e.Y));
+                var node = trvLayersGroup.GetNodeAt(clientPt);
                 if (node != null)
                 {
                     var gi = node.Tag as GroupItem;
@@ -786,6 +815,8 @@
                 {
                     //TODO: Fine-grain invalidation
                     RefreshModels();
+                    if (parent != null)
+                        ExpandNode<GroupItem>(trvLayersGroup, (tag) => { return tag.Tag == parent; });
                     OnResourceChanged();
                 }
             }



More information about the mapguide-commits mailing list