Index: Application/Application.Ringtoets/DeltaShellGui.cs =================================================================== diff -u -r5bf7162daa83726f44ab976d48057fdae2f88d0a -r15921b5312f19713e98530b4f852ba2c7e898b03 --- Application/Application.Ringtoets/DeltaShellGui.cs (.../DeltaShellGui.cs) (revision 5bf7162daa83726f44ab976d48057fdae2f88d0a) +++ Application/Application.Ringtoets/DeltaShellGui.cs (.../DeltaShellGui.cs) (revision 15921b5312f19713e98530b4f852ba2c7e898b03) @@ -804,103 +804,17 @@ private void ActiveViewChanging(object sender, ActiveViewChangeEventArgs e) { - // TODO: if view removes controls - we will have a problem here, view controls won't be unsubscribed - var activeViewControl = (Control) e.OldView; - if (e.OldView != null) - { - activeViewControl.DragEnter -= DeltaShellGuiDragEnter; - activeViewControl.DragOver -= DeltaShellGui_DragOver; - activeViewControl.DragDrop -= DeltaShellGuiDragDrop; - foreach (Control control in activeViewControl.Controls) - { - control.DragEnter -= DeltaShellGuiDragEnter; - control.DragOver -= DeltaShellGui_DragOver; - control.DragDrop -= DeltaShellGuiDragDrop; - } - } - if (e.View == null || mainWindow == null || mainWindow.IsWindowDisposed) { return; } - activeViewControl = (Control) e.View; - activeViewControl.DragEnter += DeltaShellGuiDragEnter; - activeViewControl.DragOver += DeltaShellGui_DragOver; - activeViewControl.DragDrop += DeltaShellGuiDragDrop; - foreach (Control control in activeViewControl.Controls) - { - control.DragEnter += DeltaShellGuiDragEnter; - control.DragOver += DeltaShellGui_DragOver; - control.DragDrop += DeltaShellGuiDragDrop; - } - if (mainWindow.ProjectExplorer != null) { SetToolTipForView(e.View); } } - private void DeltaShellGuiDragEnter(object sender, DragEventArgs e) - { - dropTargetPluginGuis.Clear(); - foreach (var pluginGui in Plugins) - { - var formats = e.Data.GetFormats(); - foreach (var format in formats) - { - if (DocumentViews.ActiveView != null && pluginGui.CanDrop(e.Data.GetData(format), DocumentViews.ActiveView.Data)) - { - if (e.Effect != DragDropEffects.Link) - { - e.Effect = DragDropEffects.Link; - } - - dropTargetPluginGuis.Add(pluginGui); - } - } - } - } - - private void DeltaShellGuiDragDrop(object sender, DragEventArgs e) - { - if (e.Effect == DragDropEffects.None) // already handled - { - log.Debug(Resources.DeltaShellGui_DeltaShellGuiDragDrop_DragDrop_is_already_handled_in_control_itself); - return; - } - - foreach (var pluginGui in dropTargetPluginGuis) - { - var formats = e.Data.GetFormats(); - foreach (var format in formats) - { - if (DocumentViews.ActiveView == null) - { - return; - } - - var source = e.Data.GetData(format); - - pluginGui.OnDragDrop(source, DocumentViews.ActiveView.Data); - - if (DocumentViews.ActiveView is ICompositeView) - { - // try to drop on one of child views - foreach (var view in ((ICompositeView) DocumentViews.ActiveView).ChildViews) - { - pluginGui.OnDragDrop(source, view.Data); - } - } - } - } - } - - private void DeltaShellGui_DragOver(object sender, DragEventArgs e) - { - // check if we can drop things here - } - // TODO: incapsulate any knowledge of the plugin XML inside plugin configurator, the rest of the system should not know about it! private void InitToolWindows() { Index: Core/Common/src/Core.Common.Gui/GuiPlugin.cs =================================================================== diff -u -rb122512eeb3c282818c0f7f387071c188f6c671d -r15921b5312f19713e98530b4f852ba2c7e898b03 --- Core/Common/src/Core.Common.Gui/GuiPlugin.cs (.../GuiPlugin.cs) (revision b122512eeb3c282818c0f7f387071c188f6c671d) +++ Core/Common/src/Core.Common.Gui/GuiPlugin.cs (.../GuiPlugin.cs) (revision 15921b5312f19713e98530b4f852ba2c7e898b03) @@ -94,23 +94,6 @@ yield break; } - /// - /// TODO: is it not part of IView? - /// - /// - /// - public virtual void OnDragDrop(object source, object target) {} - - /// - /// TODO: is it not part of IView? - /// - /// - /// - public virtual bool CanDrop(object source, object target) - { - return false; - } - public virtual void Dispose() { Gui = null; Index: Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/SharpMapGisGuiPlugin.cs =================================================================== diff -u -rfb6f952991193be2c30995f3f8e60312c12dc052 -r15921b5312f19713e98530b4f852ba2c7e898b03 --- Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/SharpMapGisGuiPlugin.cs (.../SharpMapGisGuiPlugin.cs) (revision fb6f952991193be2c30995f3f8e60312c12dc052) +++ Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/SharpMapGisGuiPlugin.cs (.../SharpMapGisGuiPlugin.cs) (revision 15921b5312f19713e98530b4f852ba2c7e898b03) @@ -13,9 +13,7 @@ using Core.Common.Gui.Forms; using Core.Common.Utils; using Core.GIS.GeoAPI.Extensions.Feature; -using Core.GIS.GeoAPI.Geometries; using Core.GIS.SharpMap.Api.Layers; -using Core.GIS.SharpMap.Data.Providers; using Core.GIS.SharpMap.Layers; using Core.GIS.SharpMap.Map; using Core.GIS.SharpMap.UI.Forms; @@ -324,71 +322,6 @@ }; } - public override bool CanDrop(object source, object target) - { - if (source is ILayer && target is Map) - { - return true; - } - - if (source is IList && target is Map && ((IEnumerable) source).Cast().FirstOrDefault() is IGeometry) - { - return true; - } - - return false; - } - - public override void OnDragDrop(object source, object target) - { - var map = target as Map; - - if (map == null) - { - return; - } - - if (source is ILayer) - { - map.Layers.Add((ILayer) source); - } - - if (source is IList) - { - var items = (IList) source; - - if (items.Count > 0 && items[0] is IGeometry) - { - var provider = new FeatureCollection(); - foreach (var item in items) - { - var geometry = (IGeometry) item; - provider.Features.Add(geometry); - } - ILayer layer = new VectorLayer - { - DataSource = provider - }; - map.Layers.Add(layer); - } - - if (items.Count > 0 && items[0] is IFeature) - { - var provider = new FeatureCollection - { - Features = items - }; - ILayer layer = new VectorLayer - { - DataSource = provider - }; - map.Layers.Add(layer); - } - } - - map.NotifyObservers(); - } - internal static MapView GetFocusedMapView(IView view = null) { return gui.GetFocusedMapView(view);