Index: src/DeltaShell/DeltaShell.Plugins.SharpMapGis.Gui/Forms/MapLegendView/MapLayerTreeViewNodePresenter.cs =================================================================== diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -r5fc71a385897af92ccb092f2f969b5709afab85a --- src/DeltaShell/DeltaShell.Plugins.SharpMapGis.Gui/Forms/MapLegendView/MapLayerTreeViewNodePresenter.cs (.../MapLayerTreeViewNodePresenter.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9) +++ src/DeltaShell/DeltaShell.Plugins.SharpMapGis.Gui/Forms/MapLegendView/MapLayerTreeViewNodePresenter.cs (.../MapLayerTreeViewNodePresenter.cs) (revision 5fc71a385897af92ccb092f2f969b5709afab85a) @@ -13,9 +13,7 @@ { public class MapLayerTreeViewNodePresenter : TreeViewNodePresenterBaseForPluginGui { - public MapLayerTreeViewNodePresenter(GuiPlugin guiPlugin) : base(guiPlugin) - { - } + public MapLayerTreeViewNodePresenter(GuiPlugin guiPlugin) : base(guiPlugin) {} public override bool CanRenameNode(ITreeNode node) { @@ -94,6 +92,49 @@ return DragOperations.Move; } + public override DragOperations CanDrop(object item, ITreeNode sourceNode, ITreeNode targetNode, DragOperations validOperations) + { + var groupLayer = targetNode.Tag as IGroupLayer; + if (groupLayer != null && item is Layer) + { + return groupLayer.LayersReadOnly + ? DragOperations.None // No dropping into 'readonly' grouplayers + : DragOperations.Move; + } + + return DragOperations.None; // No dropping into non grouplayers + } + + public override void OnDragDrop(object item, object sourceParentNodeData, ILayer target, DragOperations operation, int position) + { + if (TreeView == null) + { + throw new NullReferenceException("TreeView not assigned to foldernodepresenter"); + } + + var sourceMap = sourceParentNodeData as Map; + var sourceLayerGroup = sourceParentNodeData as GroupLayer; + var targetLayerGroup = (GroupLayer) target; + + if ((operation & DragOperations.Move) != 0) + { + if (sourceLayerGroup != null) + { + sourceLayerGroup.Layers.Remove((ILayer) item); + } + else if (sourceMap != null) + { + sourceMap.Layers.Remove((ILayer) item); + } + else + { + throw new NotSupportedException("Can not drag layer from the source node: " + item); + } + + targetLayerGroup.Layers.Insert(position, (ILayer) item); + } + } + protected override bool CanRemove(ILayer nodeData) { var parentNode = TreeView.GetNodeByTag(nodeData).Parent; @@ -112,7 +153,10 @@ protected override void OnPropertyChanged(ILayer layer, ITreeNode node, PropertyChangedEventArgs e) { - if (node == null) return; + if (node == null) + { + return; + } if (e.PropertyName.Equals("Name", StringComparison.Ordinal)) { @@ -148,48 +192,5 @@ return true; } - - public override DragOperations CanDrop(object item, ITreeNode sourceNode, ITreeNode targetNode, DragOperations validOperations) - { - var groupLayer = targetNode.Tag as IGroupLayer; - if (groupLayer != null && item is Layer) - { - return groupLayer.LayersReadOnly - ? DragOperations.None // No dropping into 'readonly' grouplayers - : DragOperations.Move; - } - - return DragOperations.None; // No dropping into non grouplayers - } - - public override void OnDragDrop(object item, object sourceParentNodeData, ILayer target, DragOperations operation, int position) - { - if (TreeView == null) - { - throw new NullReferenceException("TreeView not assigned to foldernodepresenter"); - } - - var sourceMap = sourceParentNodeData as Map; - var sourceLayerGroup = sourceParentNodeData as GroupLayer; - var targetLayerGroup = (GroupLayer)target; - - if ((operation & DragOperations.Move) != 0) - { - if (sourceLayerGroup != null) - { - sourceLayerGroup.Layers.Remove((ILayer) item); - } - else if (sourceMap != null) - { - sourceMap.Layers.Remove((ILayer) item); - } - else - { - throw new NotSupportedException("Can not drag layer from the source node: " + item); - } - - targetLayerGroup.Layers.Insert(position, (ILayer) item); - } - } } } \ No newline at end of file