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

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Sep 13 09:34:10 PDT 2012


Author: jng
Date: 2012-09-13 09:34:10 -0700 (Thu, 13 Sep 2012)
New Revision: 7011

Modified:
   trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs
Log:
#2115: Prevent drops of groups into child groups. Similarly, prevent drops of groups onto child layers. Also fix inability to move tiled layers between different base layer groups

Modified: trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs	2012-09-13 15:38:46 UTC (rev 7010)
+++ trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs	2012-09-13 16:34:10 UTC (rev 7011)
@@ -275,8 +275,11 @@
 
         private void btnAddGroup_Click(object sender, EventArgs e)
         {
-            var selGroup = GetSelectedLayerGroupItem() as IMapLayerGroup;
-            var newGroup = CreateNewGroup(selGroup);
+            var selGroup = GetSelectedLayerGroupItem() as GroupItem;
+            IMapLayerGroup parent = null;
+            if (selGroup != null)
+                parent = selGroup.Tag;
+            var newGroup = CreateNewGroup(parent);
 
             _grpLayerModel.Invalidate();
             RestoreGroupSelection(newGroup);
@@ -1040,9 +1043,17 @@
                     var gi = node.Tag as GroupItem;
                     var li = node.Tag as LayerItem;
                     if (gi != null)
+                    {
+                        if (TargetIsDescendant(nodes, gi))
+                            return;
+
                         parent = gi.Tag;
+                    }
                     else if (li != null)
-                        parent = _map.GetGroupByName(li.Tag.Group);
+                    {
+                        return;
+                        //parent = _map.GetGroupByName(li.Tag.Group);
+                    }
                 }
 
                 int moved = 0;
@@ -1076,6 +1087,27 @@
             }
         }
 
+        private bool TargetIsDescendant(TreeNodeAdv[] nodes, GroupItem target)
+        {
+            foreach (var n in nodes)
+            {
+                var gi = n.Tag as GroupItem;
+                if (gi != null)
+                {
+                    var grp = target.Tag;
+                    while (!string.IsNullOrEmpty(grp.Group))
+                    {
+                        var parent = _map.GetGroupByName(grp.Group);
+                        if (parent == gi.Tag)
+                            return true;
+
+                        grp = parent;
+                    }
+                }        
+            }
+            return false;
+        }
+
         private void trvLayersGroup_DragOver(object sender, DragEventArgs e)
         {
             var data = e.Data.GetData(typeof(TreeNodeAdv[])) as TreeNodeAdv[];
@@ -1094,6 +1126,7 @@
                 }
                 else
                 {
+
                     e.Effect = DragDropEffects.Move;
                 }
             }
@@ -1293,9 +1326,21 @@
                             targetGroup = tlg.Tag;
                     }
 
-                    if (sourceLayer != null && targetLayer != null && sourceLayer != targetLayer)
+                    if (sourceLayer != null && targetGroup != null && targetGroup.GetIndex(sourceLayer) < 0) //Dropping to a different base layer group
                     {
                         var srcGroup = _map.BaseMap.GetGroupForLayer(sourceLayer);
+                        srcGroup.RemoveBaseMapLayer(sourceLayer);
+                        targetGroup.InsertLayer(0, sourceLayer);
+
+                        _tiledLayerModel.Invalidate();
+
+                        //Keep group expanded
+                        if (tli != null)
+                            RestoreBaseLayerSelection(sourceLayer);
+                    }
+                    else if (sourceLayer != null && targetLayer != null && sourceLayer != targetLayer)
+                    {
+                        var srcGroup = _map.BaseMap.GetGroupForLayer(sourceLayer);
                         var dstGroup = _map.BaseMap.GetGroupForLayer(targetLayer);
 
                         if (srcGroup != null)



More information about the mapguide-commits mailing list