Index: Core/Gui/src/Core.Gui/Forms/MainWindow/MainWindow.xaml
===================================================================
diff -u -r76fb7e42934ada3ec6ec79f986ff5fe3e026433b -ra5a3c17b09c5cc24e5cfa6d986182fb213bc4cbf
--- Core/Gui/src/Core.Gui/Forms/MainWindow/MainWindow.xaml (.../MainWindow.xaml) (revision 76fb7e42934ada3ec6ec79f986ff5fe3e026433b)
+++ Core/Gui/src/Core.Gui/Forms/MainWindow/MainWindow.xaml (.../MainWindow.xaml) (revision a5a3c17b09c5cc24e5cfa6d986182fb213bc4cbf)
@@ -175,8 +175,10 @@
AutomationProperties.AutomationId="ViewStateButtonBarShowMap">
-
Index: Core/Gui/src/Core.Gui/Forms/MainWindow/MainWindow.xaml.cs
===================================================================
diff -u -re25cbbd88e41c07ec5be2ba2f686f2e85e0f3706 -ra5a3c17b09c5cc24e5cfa6d986182fb213bc4cbf
--- Core/Gui/src/Core.Gui/Forms/MainWindow/MainWindow.xaml.cs (.../MainWindow.xaml.cs) (revision e25cbbd88e41c07ec5be2ba2f686f2e85e0f3706)
+++ Core/Gui/src/Core.Gui/Forms/MainWindow/MainWindow.xaml.cs (.../MainWindow.xaml.cs) (revision a5a3c17b09c5cc24e5cfa6d986182fb213bc4cbf)
@@ -32,6 +32,7 @@
using Core.Common.Util.Settings;
using Core.Components.Gis.Forms;
using Core.Gui.Commands;
+using Core.Gui.Forms.Chart;
using Core.Gui.Forms.Map;
using Core.Gui.Forms.MessageWindow;
using Core.Gui.Forms.ViewHost;
@@ -78,11 +79,6 @@
public bool IsWindowDisposed { get; private set; }
///
- /// Gets the log messages tool window.
- ///
- public IMessageWindow MessageWindow { get; private set; }
-
- ///
/// Gets the view host.
///
public IViewHost ViewHost => AvalonDockViewHost;
@@ -128,10 +124,20 @@
public ProjectExplorer.ProjectExplorer ProjectExplorer { get; private set; }
///
+ /// Gets the log messages tool window.
+ ///
+ public IMessageWindow MessageWindow { get; private set; }
+
+ ///
/// Gets the .
///
public MapLegendView MapLegendView { get; private set; }
+ ///
+ /// Gets the
+ ///
+ public ChartLegendView ChartLegendView { get; private set; }
+
public IView PropertyGrid => propertyGrid;
public IntPtr Handle => windowInteropHelper.Handle;
@@ -189,6 +195,7 @@
{
InitProjectExplorerWindowOrBringToFront();
InitMapLegendWindowOrBringToFront();
+ InitChartLegendWindowOrBringToFront();
InitMessagesWindowOrBringToFront();
InitPropertiesWindowOrBringToFront();
}
@@ -339,6 +346,22 @@
ButtonShowMapLegendView.IsChecked = !active;
}
+ private void ButtonShowChartLegendView_Click(object sender, RoutedEventArgs e)
+ {
+ bool active = viewController.ViewHost.ToolViews.Contains(ChartLegendView);
+
+ if (active)
+ {
+ viewController.ViewHost.Remove(ChartLegendView);
+ }
+ else
+ {
+ InitChartLegendWindowOrBringToFront();
+ }
+
+ ButtonShowChartLegendView.IsChecked = !active;
+ }
+
private void OnFileHelpShowLog_Clicked(object sender, RoutedEventArgs e)
{
commands.ApplicationCommands.OpenLogFileExternal();
@@ -437,6 +460,7 @@
ButtonShowMessages.IsChecked = viewController.ViewHost.ToolViews.Contains(MessageWindow);
ButtonShowProperties.IsChecked = viewController.ViewHost.ToolViews.Contains(PropertyGrid);
ButtonShowMapLegendView.IsChecked = viewController.ViewHost.ToolViews.Contains(MapLegendView);
+ ButtonShowChartLegendView.IsChecked = viewController.ViewHost.ToolViews.Contains(ChartLegendView);
}
}
@@ -504,6 +528,26 @@
}
}
+ private void InitChartLegendWindowOrBringToFront()
+ {
+ if (gui == null)
+ {
+ throw new InvalidOperationException("Must call 'SetGui(IGui)' before calling 'InitMessagesWindowOrActivate'.");
+ }
+
+ if (ChartLegendView == null)
+ {
+ ChartLegendView = new ChartLegendView(gui);
+
+ viewController.ViewHost.AddToolView(ChartLegendView, ToolViewLocation.Left);
+ viewController.ViewHost.SetImage(ChartLegendView, Properties.Resources.application_view_list);
+ }
+ else
+ {
+ viewController.ViewHost.BringToFront(ChartLegendView);
+ }
+ }
+
#endregion
#region Events
@@ -549,6 +593,11 @@
MapLegendView = null;
}
+ if (ReferenceEquals(e.View, ChartLegendView))
+ {
+ ChartLegendView = null;
+ }
+
if (ReferenceEquals(e.View, currentMapView))
{
UpdateComponentsForMapView(null);
Index: Core/Gui/test/Core.Gui.Test/Forms/MainWindow/MainWindowTest.cs
===================================================================
diff -u -r89e16fb45c79e575b0c335e71705694a9dac87c8 -ra5a3c17b09c5cc24e5cfa6d986182fb213bc4cbf
--- Core/Gui/test/Core.Gui.Test/Forms/MainWindow/MainWindowTest.cs (.../MainWindowTest.cs) (revision 89e16fb45c79e575b0c335e71705694a9dac87c8)
+++ Core/Gui/test/Core.Gui.Test/Forms/MainWindow/MainWindowTest.cs (.../MainWindowTest.cs) (revision a5a3c17b09c5cc24e5cfa6d986182fb213bc4cbf)
@@ -29,9 +29,11 @@
using Core.Common.Controls.TreeView;
using Core.Common.Controls.Views;
using Core.Common.Util.Reflection;
+using Core.Components.Chart.Forms;
using Core.Components.DotSpatial.Forms;
using Core.Components.Gis.Forms;
using Core.Gui.Commands;
+using Core.Gui.Forms.Chart;
using Core.Gui.Forms.MainWindow;
using Core.Gui.Forms.Map;
using Core.Gui.Forms.MessageWindow;
@@ -435,6 +437,9 @@
Assert.IsInstanceOf(mainWindow.MapLegendView);
Assert.IsNull(GetMapControl(mainWindow.MapLegendView));
+ Assert.IsInstanceOf(mainWindow.ChartLegendView);
+ Assert.IsNull(GetChartControl(mainWindow.ChartLegendView));
+
Assert.IsNull(viewHost.ActiveDocumentView);
}
@@ -574,6 +579,39 @@
}
[Test]
+ public void GivenGuiWithChartLegendView_WhenClosingChartLegendView_ThenChartLegendViewSetToNull()
+ {
+ // Given
+ var mocks = new MockRepository();
+ var projectStore = mocks.Stub();
+ var projectMigrator = mocks.Stub();
+ var projectFactory = mocks.Stub();
+ projectFactory.Stub(pf => pf.CreateNewProject()).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ using (var mainWindow = new Gui.Forms.MainWindow.MainWindow())
+ using (var gui = new GuiCore(mainWindow, projectStore, projectMigrator, projectFactory, new GuiCoreSettings()))
+ {
+ gui.Plugins.Add(new TestPlugin());
+ gui.Run();
+
+ mainWindow.SetGui(gui);
+ mainWindow.InitializeToolWindows();
+
+ // Precondition
+ Assert.IsNotNull(mainWindow.ChartLegendView);
+
+ // When
+ mainWindow.ViewHost.Remove(mainWindow.ChartLegendView);
+
+ // Then
+ Assert.IsNull(mainWindow.ChartLegendView);
+ }
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
public void GivenGuiWithProjectExplorer_WhenUpdateProjectExplorer_ThenDataSetOnProjectExplorer()
{
// Given
@@ -805,5 +843,10 @@
{
return TypeUtils.GetProperty(mapLegendView, "MapControl");
}
+
+ private static IChartControl GetChartControl(ChartLegendView chartLegendView)
+ {
+ return TypeUtils.GetProperty(chartLegendView, "ChartControl");
+ }
}
}
\ No newline at end of file
Index: Core/Gui/test/Core.Gui.Test/GuiCoreTest.cs
===================================================================
diff -u -r76fb7e42934ada3ec6ec79f986ff5fe3e026433b -ra5a3c17b09c5cc24e5cfa6d986182fb213bc4cbf
--- Core/Gui/test/Core.Gui.Test/GuiCoreTest.cs (.../GuiCoreTest.cs) (revision 76fb7e42934ada3ec6ec79f986ff5fe3e026433b)
+++ Core/Gui/test/Core.Gui.Test/GuiCoreTest.cs (.../GuiCoreTest.cs) (revision a5a3c17b09c5cc24e5cfa6d986182fb213bc4cbf)
@@ -34,6 +34,7 @@
using Core.Common.Util.Settings;
using Core.Gui.Commands;
using Core.Gui.ContextMenu;
+using Core.Gui.Forms.Chart;
using Core.Gui.Forms.MainWindow;
using Core.Gui.Forms.Map;
using Core.Gui.Forms.MessageWindow;
@@ -1015,11 +1016,12 @@
CollectionAssert.IsEmpty(gui.ViewHost.DocumentViews);
Assert.IsNull(gui.ViewHost.ActiveDocumentView);
- Assert.AreEqual(4, gui.ViewHost.ToolViews.Count());
+ Assert.AreEqual(5, gui.ViewHost.ToolViews.Count());
Assert.AreEqual(1, gui.ViewHost.ToolViews.Count(v => v is ProjectExplorer));
Assert.AreEqual(1, gui.ViewHost.ToolViews.Count(v => v is PropertyGridView));
Assert.AreEqual(1, gui.ViewHost.ToolViews.Count(v => v is MessageWindow));
Assert.AreEqual(1, gui.ViewHost.ToolViews.Count(v => v is MapLegendView));
+ Assert.AreEqual(1, gui.ViewHost.ToolViews.Count(v => v is ChartLegendView));
Assert.IsNotNull(gui.DocumentViewController);
}