Index: Core/Plugins/src/Core.Plugins.Map/MapPlugin.cs =================================================================== diff -u -r03553598857cf6c0d3471c43e22d7b1d12f640fe -r6a8af47ae6931242c54ded4c8ef86559b5154b74 --- Core/Plugins/src/Core.Plugins.Map/MapPlugin.cs (.../MapPlugin.cs) (revision 03553598857cf6c0d3471c43e22d7b1d12f640fe) +++ Core/Plugins/src/Core.Plugins.Map/MapPlugin.cs (.../MapPlugin.cs) (revision 6a8af47ae6931242c54ded4c8ef86559b5154b74) @@ -61,15 +61,6 @@ activated = true; } - private static void OnViewOpened(object sender, ViewChangeEventArgs e) - { - var view = e.View as IMapView; - if (view != null) - { - view.Map.ZoomToAllVisibleLayers(); - } - } - public override IEnumerable GetPropertyInfos() { yield return new PropertyInfo(); @@ -118,6 +109,15 @@ UpdateComponentsForActiveDocumentView(); } + private static void OnViewOpened(object sender, ViewChangeEventArgs e) + { + var view = e.View as IMapView; + if (view != null) + { + view.Map.ZoomToAllVisibleLayers(); + } + } + /// /// Updates the components which the knows about so that it reflects /// the currently active view. Index: Core/Plugins/test/Core.Plugins.Map.Test/MapPluginTest.cs =================================================================== diff -u -r03553598857cf6c0d3471c43e22d7b1d12f640fe -r6a8af47ae6931242c54ded4c8ef86559b5154b74 --- Core/Plugins/test/Core.Plugins.Map.Test/MapPluginTest.cs (.../MapPluginTest.cs) (revision 03553598857cf6c0d3471c43e22d7b1d12f640fe) +++ Core/Plugins/test/Core.Plugins.Map.Test/MapPluginTest.cs (.../MapPluginTest.cs) (revision 6a8af47ae6931242c54ded4c8ef86559b5154b74) @@ -26,11 +26,11 @@ using Core.Common.Base.Data; using Core.Common.Base.Storage; using Core.Common.Controls.Views; +using Core.Common.Gui; using Core.Common.Gui.Forms.MainWindow; using Core.Common.Gui.Forms.ViewHost; using Core.Common.Gui.Plugin; using Core.Common.Gui.Settings; -using Core.Common.Gui; using Core.Common.Gui.TestUtil; using Core.Components.DotSpatial.Forms; using Core.Components.Gis.Data; @@ -173,18 +173,15 @@ using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { var plugin = new MapPlugin(); - var testMapView = new TestMapView(); - var map = new MapControl(); - IView viewMock = visible ? (IView) testMapView : new TestView(); - testMapView.Data = map; + IView view = visible ? (IView) new TestMapView() : new TestView(); gui.Plugins.Add(plugin); plugin.Gui = gui; gui.Run(); // When - gui.ViewHost.AddDocumentView(viewMock); + gui.ViewHost.AddDocumentView(view); // Then Assert.AreEqual(visible ? Visibility.Visible : Visibility.Collapsed, plugin.RibbonCommandHandler.GetRibbonControl().ContextualGroups[0].Visibility); @@ -209,23 +206,18 @@ { var plugin = new MapPlugin(); var testMapView = new TestMapView(); - var mapControl = new MapControl(); - IView viewMock = testMapView; - - testMapView.Data = mapControl; - gui.Plugins.Add(plugin); plugin.Gui = gui; gui.Run(); - DotSpatialMap map = (DotSpatialMap) mapControl.Controls[0]; + DotSpatialMap map = (DotSpatialMap) ((MapControl) testMapView.Map).Controls[0]; // Precondition var initialExtents = map.ViewExtents; // When - gui.ViewHost.AddDocumentView(viewMock); + gui.ViewHost.AddDocumentView(testMapView); // Then Assert.AreNotEqual(initialExtents, map.ViewExtents); Index: Core/Plugins/test/Core.Plugins.Map.Test/TestMapView.cs =================================================================== diff -u -r03553598857cf6c0d3471c43e22d7b1d12f640fe -r6a8af47ae6931242c54ded4c8ef86559b5154b74 --- Core/Plugins/test/Core.Plugins.Map.Test/TestMapView.cs (.../TestMapView.cs) (revision 03553598857cf6c0d3471c43e22d7b1d12f640fe) +++ Core/Plugins/test/Core.Plugins.Map.Test/TestMapView.cs (.../TestMapView.cs) (revision 6a8af47ae6931242c54ded4c8ef86559b5154b74) @@ -34,16 +34,15 @@ /// public class TestMapView : Control, IMapView { - private object data; - private readonly MapDataCollection mapDataCollection; + private readonly MapControl mapControl; /// - /// Creates a new instance of - /// and initializes some . + /// Creates a new instance of and initializes some . /// public TestMapView() { - mapDataCollection = new MapDataCollection("test"); + var mapDataCollection = new MapDataCollection("test"); + mapDataCollection.Add(new MapPointData("test points") { Features = new[] @@ -70,30 +69,22 @@ }) } }); - } - public object Data - { - get + mapControl = new MapControl { - return data; - } - set - { - data = value; + Data = mapDataCollection + }; - if (data != null) - { - Map.Data = mapDataCollection; - } - } + Controls.Add(mapControl); } + public object Data { get; set; } + public IMapControl Map { get { - return (MapControl) Data; + return mapControl; } } }