[mapguide-commits] r5647 -
trunk/Tools/Maestro/Maestro.Editors/MapDefinition
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Mon Mar 21 07:58:26 EDT 2011
Author: jng
Date: 2011-03-21 04:58:26 -0700 (Mon, 21 Mar 2011)
New Revision: 5647
Modified:
trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs
trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapTreeModels.cs
Log:
#1631: Fix Drag/drop of an existing layer reference or group into a group ("Layers by Group" tab) does nothing.
Modified: trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs 2011-03-21 11:43:48 UTC (rev 5646)
+++ trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs 2011-03-21 11:58:26 UTC (rev 5647)
@@ -680,39 +680,101 @@
private void trvLayersGroup_DragDrop(object sender, DragEventArgs e)
{
var rids = e.Data.GetData(typeof(ResourceIdentifier[])) as ResourceIdentifier[];
- if (rids == null || rids.Length == 0)
- return;
+ var nodes = e.Data.GetData(typeof(TreeNodeAdv[])) as TreeNodeAdv[];
+ if (rids != null && rids.Length > 0)
+ {
+ IMapLayerGroup parent = null;
+ var node = trvLayersGroup.GetNodeAt(trvLayersGroup.PointToClient(new Point(e.X, e.Y)));
+ if (node != null)
+ {
+ var gi = node.Tag as GroupItem;
+ if (gi != null)
+ parent = gi.Tag;
+ }
- IMapLayerGroup parent = null;
- var node = trvLayersGroup.GetNodeAt(trvLayersGroup.PointToClient(new Point(e.X, e.Y)));
- if (node != null)
- {
- var gi = node.Tag as GroupItem;
- if (gi != null)
- parent = gi.Tag;
+ int added = 0;
+ foreach (var rid in rids)
+ {
+ if (rid.ResourceType == ResourceTypes.LayerDefinition)
+ {
+ var name = GenerateLayerName(rid.ToString(), _map);
+ var layer = _map.AddLayer(parent == null ? null : parent.Name, name, rid.ToString());
+ added++;
+ }
+ }
+
+ if (added > 0)
+ {
+ //TODO: Fine-grain invalidation
+ RefreshModels();
+ }
}
-
- int added = 0;
- foreach (var rid in rids)
+ else if (nodes != null && nodes.Length > 0)
{
- if (rid.ResourceType == ResourceTypes.LayerDefinition)
- {
- var name = GenerateLayerName(rid.ToString(), _map);
- var layer = _map.AddLayer(parent == null ? null : parent.Name, name, rid.ToString());
- added++;
+ IMapLayerGroup parent = null;
+ var node = trvLayersGroup.GetNodeAt(trvLayersGroup.PointToClient(new Point(e.X, e.Y)));
+ if (node != null)
+ {
+ var gi = node.Tag as GroupItem;
+ var li = node.Tag as LayerItem;
+ if (gi != null)
+ parent = gi.Tag;
+ else if (li != null)
+ parent = _map.GetGroupByName(li.Tag.Group);
}
- }
- if (added > 0)
- {
- //TODO: Fine-grain invalidation
- RefreshModels();
+ if (parent != null)
+ {
+ int moved = 0;
+ //Add to this group
+ foreach (var n in nodes)
+ {
+ var gi = n.Tag as GroupItem;
+ var li = n.Tag as LayerItem;
+
+ //Re-assign parent
+ if (gi != null)
+ {
+ gi.Tag.Group = parent.Name;
+ moved++;
+ }
+ else if (li != null)
+ {
+ li.Tag.Group = parent.Name;
+ moved++;
+ }
+ }
+
+ if (moved > 0)
+ {
+ //TODO: Fine-grain invalidation
+ RefreshModels();
+ }
+ }
}
}
private void trvLayersGroup_DragOver(object sender, DragEventArgs e)
{
- HandleDragOver(e);
+ var data = e.Data.GetData(typeof(TreeNodeAdv[])) as TreeNodeAdv[];
+ if (data == null)
+ {
+ HandleDragOver(e);
+ }
+ else
+ {
+ var li = data[0].Tag as LayerItem;
+ var gi = data[0].Tag as GroupItem;
+ if (li == null && gi == null)
+ {
+ e.Effect = DragDropEffects.None;
+ return;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.Move;
+ }
+ }
}
private static void HandleDragOver(DragEventArgs e)
@@ -887,7 +949,24 @@
private void trvBaseLayers_DragOver(object sender, DragEventArgs e)
{
- HandleDragOver(e);
+ var data = e.Data.GetData(typeof(TreeNodeAdv[])) as TreeNodeAdv[];
+ if (data == null)
+ {
+ HandleDragOver(e);
+ }
+ else
+ {
+ var li = data[0].Tag as BaseLayerItem;
+ if (li == null)
+ {
+ e.Effect = DragDropEffects.None;
+ return;
+ }
+ else
+ {
+ e.Effect = DragDropEffects.Move;
+ }
+ }
}
}
}
Modified: trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapTreeModels.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapTreeModels.cs 2011-03-21 11:43:48 UTC (rev 5646)
+++ trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapTreeModels.cs 2011-03-21 11:58:26 UTC (rev 5647)
@@ -217,7 +217,8 @@
{
foreach (var group in _map.MapLayerGroup)
{
- yield return new GroupItem(group);
+ if (string.IsNullOrEmpty(group.Group))
+ yield return new GroupItem(group);
}
foreach (var layer in _map.GetLayersWithoutGroups())
More information about the mapguide-commits
mailing list