[mapguide-commits] r5648 - in trunk/Tools/Maestro:
Maestro.Editors/MapDefinition OSGeo.MapGuide.MaestroAPI/ObjectModels
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Mon Mar 21 08:40:41 EDT 2011
Author: jng
Date: 2011-03-21 05:40:40 -0700 (Mon, 21 Mar 2011)
New Revision: 5648
Modified:
trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinition.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinitionInterfaces.cs
Log:
#1631: Fix Drag/drop reordering of layers in a base layer group does nothing
Modified: trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs 2011-03-21 11:58:26 UTC (rev 5647)
+++ trunk/Tools/Maestro/Maestro.Editors/MapDefinition/MapLayersSectionCtrl.cs 2011-03-21 12:40:40 UTC (rev 5648)
@@ -907,10 +907,11 @@
private void trvBaseLayers_DragDrop(object sender, DragEventArgs e)
{
- int added = 0;
var rids = e.Data.GetData(typeof(ResourceIdentifier[])) as ResourceIdentifier[];
+ var data = e.Data.GetData(typeof(TreeNodeAdv[])) as TreeNodeAdv[];
if (rids != null && rids.Length > 0)
{
+ int added = 0;
var node = trvBaseLayers.GetNodeAt(trvBaseLayers.PointToClient(new Point(e.X, e.Y)));
IBaseMapGroup group = null;
@@ -934,11 +935,59 @@
added++;
}
}
+
+ if (added > 0)
+ {
+ _tiledLayerModel.Invalidate();
+ }
}
+ else if (data != null && data.Length == 1)
+ {
+ var li = data[0].Tag as BaseLayerItem;
+ if (li != null)
+ {
+ IBaseMapLayer sourceLayer = li.Tag;
+ IBaseMapLayer targetLayer = null;
+ IBaseMapGroup targetGroup = null;
+ var node = trvBaseLayers.GetNodeAt(trvBaseLayers.PointToClient(new Point(e.X, e.Y)));
+ if (node != null)
+ {
+ var tli = node.Tag as BaseLayerItem;
+ var tlg = node.Tag as BaseLayerGroupItem;
+ if (tli != null)
+ targetLayer = tli.Tag;
+ else if (tlg != null)
+ targetGroup = tlg.Tag;
+ }
- if (added > 0)
- {
- _tiledLayerModel.Invalidate();
+ if (sourceLayer != null && targetLayer != null && sourceLayer != targetLayer)
+ {
+ var srcGroup = _map.BaseMap.GetGroupForLayer(sourceLayer);
+ var dstGroup = _map.BaseMap.GetGroupForLayer(targetLayer);
+
+ if (srcGroup != null)
+ {
+ if (srcGroup == dstGroup)
+ {
+ int idx = srcGroup.GetIndex(targetLayer);
+ if (idx >= 0)
+ {
+ srcGroup.RemoveBaseMapLayer(sourceLayer);
+ srcGroup.InsertLayer(idx, sourceLayer);
+
+ _tiledLayerModel.Invalidate();
+ }
+ }
+ else
+ {
+ srcGroup.RemoveBaseMapLayer(sourceLayer);
+ dstGroup.InsertLayer(0, targetLayer);
+
+ _tiledLayerModel.Invalidate();
+ }
+ }
+ }
+ }
}
}
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinition.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinition.cs 2011-03-21 11:58:26 UTC (rev 5647)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinition.cs 2011-03-21 12:40:40 UTC (rev 5648)
@@ -639,6 +639,25 @@
}
}
+ public int GetIndex(IBaseMapLayer layer)
+ {
+ var bl = layer as BaseMapLayerType;
+ if (bl != null)
+ {
+ return this.BaseMapLayer.IndexOf(bl);
+ }
+ return -1;
+ }
+
+ public void InsertLayer(int index, IBaseMapLayer layer)
+ {
+ var bl = layer as BaseMapLayerType;
+ if (bl != null)
+ {
+ this.BaseMapLayer.Insert(index, bl);
+ }
+ }
+
public IBaseMapLayer AddLayer(string layerName, string resourceId)
{
BaseMapLayerType layer = new BaseMapLayerType()
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinitionInterfaces.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinitionInterfaces.cs 2011-03-21 11:58:26 UTC (rev 5647)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/ObjectModels/MapDefinitionInterfaces.cs 2011-03-21 12:40:40 UTC (rev 5648)
@@ -250,6 +250,26 @@
}
/// <summary>
+ /// Gets the parent group for the specified layer
+ /// </summary>
+ /// <param name="map"></param>
+ /// <param name="layer"></param>
+ /// <returns></returns>
+ public static IBaseMapGroup GetGroupForLayer(this IBaseMapDefinition map, IBaseMapLayer layer)
+ {
+ Check.NotNull(map, "map");
+ foreach (var group in map.BaseMapLayerGroup)
+ {
+ foreach (var tl in group.BaseMapLayer)
+ {
+ if (tl == layer)
+ return group;
+ }
+ }
+ return null;
+ }
+
+ /// <summary>
/// Gets whether this base map group has tiled layers
/// </summary>
/// <param name="grp"></param>
@@ -640,6 +660,20 @@
void RemoveBaseMapLayer(IBaseMapLayer layer);
/// <summary>
+ /// Insert the base map layer at the specified index
+ /// </summary>
+ /// <param name="index"></param>
+ /// <param name="layer"></param>
+ void InsertLayer(int index, IBaseMapLayer layer);
+
+ /// <summary>
+ /// Gets the index of the specified layer
+ /// </summary>
+ /// <param name="layer"></param>
+ /// <returns></returns>
+ int GetIndex(IBaseMapLayer layer);
+
+ /// <summary>
/// Moves the specified layer up.
/// </summary>
/// <param name="layer">The layer.</param>
More information about the mapguide-commits
mailing list