Index: Core/Gui/src/Core.Gui/Commands/MainWindowCommands.cs
===================================================================
diff -u -rd4814858f4bc4a2fe79402a990f9076ef28d16a8 -r8339a812e145eab080917a65ceb6d27472b7c076
--- Core/Gui/src/Core.Gui/Commands/MainWindowCommands.cs (.../MainWindowCommands.cs) (revision d4814858f4bc4a2fe79402a990f9076ef28d16a8)
+++ Core/Gui/src/Core.Gui/Commands/MainWindowCommands.cs (.../MainWindowCommands.cs) (revision 8339a812e145eab080917a65ceb6d27472b7c076)
@@ -62,5 +62,10 @@
/// The command for opening the log file.
///
public static readonly ICommand OpenLogFileCommand = new RoutedCommand();
+
+ ///
+ /// The command for opening the user manual.
+ ///
+ public static readonly ICommand OpenUserManualCommand = new RoutedCommand();
}
}
\ No newline at end of file
Index: Core/Gui/src/Core.Gui/Forms/Backstage/BackstageControl.xaml
===================================================================
diff -u -rd4814858f4bc4a2fe79402a990f9076ef28d16a8 -r8339a812e145eab080917a65ceb6d27472b7c076
--- Core/Gui/src/Core.Gui/Forms/Backstage/BackstageControl.xaml (.../BackstageControl.xaml) (revision d4814858f4bc4a2fe79402a990f9076ef28d16a8)
+++ Core/Gui/src/Core.Gui/Forms/Backstage/BackstageControl.xaml (.../BackstageControl.xaml) (revision 8339a812e145eab080917a65ceb6d27472b7c076)
@@ -48,7 +48,7 @@
OVER
-
+
Index: Core/Gui/src/Core.Gui/Forms/MainWindow/MainWindow.xaml
===================================================================
diff -u -rd4814858f4bc4a2fe79402a990f9076ef28d16a8 -r8339a812e145eab080917a65ceb6d27472b7c076
--- Core/Gui/src/Core.Gui/Forms/MainWindow/MainWindow.xaml (.../MainWindow.xaml) (revision d4814858f4bc4a2fe79402a990f9076ef28d16a8)
+++ Core/Gui/src/Core.Gui/Forms/MainWindow/MainWindow.xaml (.../MainWindow.xaml) (revision 8339a812e145eab080917a65ceb6d27472b7c076)
@@ -53,6 +53,8 @@
Command="{Binding Path=ToggleBackstageCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=metro:MetroWindow}}" />
+
@@ -182,11 +184,9 @@
AutomationProperties.AutomationId="ViewStateButtonBarShowLog">
-
Index: Core/Gui/src/Core.Gui/Forms/MainWindow/MainWindow.xaml.cs
===================================================================
diff -u -rd4814858f4bc4a2fe79402a990f9076ef28d16a8 -r8339a812e145eab080917a65ceb6d27472b7c076
--- Core/Gui/src/Core.Gui/Forms/MainWindow/MainWindow.xaml.cs (.../MainWindow.xaml.cs) (revision d4814858f4bc4a2fe79402a990f9076ef28d16a8)
+++ Core/Gui/src/Core.Gui/Forms/MainWindow/MainWindow.xaml.cs (.../MainWindow.xaml.cs) (revision 8339a812e145eab080917a65ceb6d27472b7c076)
@@ -94,6 +94,7 @@
TogglePropertyGridViewCommand = new RelayCommand(OnTogglePropertyGridView);
ToggleMessageWindowCommand = new RelayCommand(OnToggleMessageWindow);
OpenLogFileCommand = new RelayCommand(OnOpenLogFile);
+ OpenUserManualCommand = new RelayCommand(OnOpenUserManual, CanOpenUserManual);
}
///
@@ -328,6 +329,41 @@
UpdateProjectExplorer();
}
+ #region OnClick events
+
+ private void OnAboutDialog_Clicked(object sender, RoutedEventArgs e)
+ {
+ var aboutDialog = new SplashScreen.SplashScreen
+ {
+ VersionText = SettingsHelper.Instance.ApplicationVersion,
+ SupportEmail = settings.FixedSettings.SupportEmailAddress,
+ SupportPhoneNumber = settings.FixedSettings.SupportPhoneNumber,
+ AllowsTransparency = false,
+ WindowStyle = WindowStyle.SingleBorderWindow,
+ Title = Properties.Resources.ViewStateBar_About_ToolTip,
+ Icon = Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.information.GetHbitmap(),
+ IntPtr.Zero,
+ Int32Rect.Empty,
+ BitmapSizeOptions.FromEmptyOptions()),
+ ShowInTaskbar = false,
+ Owner = this,
+ WindowStartupLocation = WindowStartupLocation.CenterOwner
+ };
+
+ aboutDialog.PreviewKeyDown += (s, ev) =>
+ {
+ if (ev.Key == Key.Escape)
+ {
+ ev.Handled = true;
+ aboutDialog.Shutdown();
+ }
+ };
+
+ aboutDialog.ShowDialog();
+ }
+
+ #endregion
+
#region Commands
///
@@ -395,6 +431,11 @@
///
public ICommand OpenLogFileCommand { get; }
+ ///
+ /// Gets the command to open the user manual.
+ ///
+ public ICommand OpenUserManualCommand { get; }
+
private void OnNewProject(object obj)
{
commands.StorageCommands.CreateNewProject();
@@ -495,49 +536,14 @@
commands.ApplicationCommands.OpenLogFileExternal();
}
- #endregion
-
- #region OnClick events
-
- private void OnFileManual_Clicked(object sender, RoutedEventArgs e)
+ private bool CanOpenUserManual(object obj)
{
- string manualFileName = settings.FixedSettings.ManualFilePath;
-
- if (File.Exists(manualFileName))
- {
- Process.Start(manualFileName);
- }
+ return File.Exists(settings?.FixedSettings.ManualFilePath);
}
- private void OnAboutDialog_Clicked(object sender, RoutedEventArgs e)
+ private void OnOpenUserManual(object obj)
{
- var aboutDialog = new SplashScreen.SplashScreen
- {
- VersionText = SettingsHelper.Instance.ApplicationVersion,
- SupportEmail = settings.FixedSettings.SupportEmailAddress,
- SupportPhoneNumber = settings.FixedSettings.SupportPhoneNumber,
- AllowsTransparency = false,
- WindowStyle = WindowStyle.SingleBorderWindow,
- Title = Properties.Resources.ViewStateBar_About_ToolTip,
- Icon = Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.information.GetHbitmap(),
- IntPtr.Zero,
- Int32Rect.Empty,
- BitmapSizeOptions.FromEmptyOptions()),
- ShowInTaskbar = false,
- Owner = this,
- WindowStartupLocation = WindowStartupLocation.CenterOwner
- };
-
- aboutDialog.PreviewKeyDown += (s, ev) =>
- {
- if (ev.Key == Key.Escape)
- {
- ev.Handled = true;
- aboutDialog.Shutdown();
- }
- };
-
- aboutDialog.ShowDialog();
+ Process.Start(settings.FixedSettings.ManualFilePath);
}
#endregion
@@ -625,8 +631,6 @@
{
WindowState = WindowState.Maximized;
- FileManualButton.IsEnabled = File.Exists(settings.FixedSettings.ManualFilePath);
-
ValidateItems();
}
Index: Core/Gui/test/Core.Gui.Test/Commands/MainWindowCommandsTest.cs
===================================================================
diff -u -rd4814858f4bc4a2fe79402a990f9076ef28d16a8 -r8339a812e145eab080917a65ceb6d27472b7c076
--- Core/Gui/test/Core.Gui.Test/Commands/MainWindowCommandsTest.cs (.../MainWindowCommandsTest.cs) (revision d4814858f4bc4a2fe79402a990f9076ef28d16a8)
+++ Core/Gui/test/Core.Gui.Test/Commands/MainWindowCommandsTest.cs (.../MainWindowCommandsTest.cs) (revision 8339a812e145eab080917a65ceb6d27472b7c076)
@@ -39,6 +39,7 @@
ICommand closeApplicationCommand = MainWindowCommands.CloseApplicationCommand;
ICommand toggleBackstageCommand = MainWindowCommands.ToggleBackstageCommand;
ICommand openLogFileCommand = MainWindowCommands.OpenLogFileCommand;
+ ICommand openUserManualCommand = MainWindowCommands.OpenUserManualCommand;
// Assert
Assert.IsInstanceOf(newProjectCommand);
@@ -48,6 +49,7 @@
Assert.IsInstanceOf(closeApplicationCommand);
Assert.IsInstanceOf(toggleBackstageCommand);
Assert.IsInstanceOf(openLogFileCommand);
+ Assert.IsInstanceOf(openUserManualCommand);
}
}
}
\ No newline at end of file
Index: Core/Gui/test/Core.Gui.Test/Forms/MainWindow/MainWindowTest.cs
===================================================================
diff -u -r3892dc6e3a66bcd3bc86297c30aee45d916ac841 -r8339a812e145eab080917a65ceb6d27472b7c076
--- Core/Gui/test/Core.Gui.Test/Forms/MainWindow/MainWindowTest.cs (.../MainWindowTest.cs) (revision 3892dc6e3a66bcd3bc86297c30aee45d916ac841)
+++ Core/Gui/test/Core.Gui.Test/Forms/MainWindow/MainWindowTest.cs (.../MainWindowTest.cs) (revision 8339a812e145eab080917a65ceb6d27472b7c076)
@@ -24,6 +24,7 @@
using System.ComponentModel;
using System.IO;
using System.Linq;
+using System.Reflection;
using System.Threading;
using System.Windows;
using System.Windows.Input;
@@ -109,6 +110,13 @@
Assert.IsNotNull(mainWindow.OpenProjectCommand);
Assert.IsNotNull(mainWindow.CloseApplicationCommand);
Assert.IsNotNull(mainWindow.ToggleBackstageCommand);
+ Assert.IsNotNull(mainWindow.ToggleProjectExplorerCommand);
+ Assert.IsNotNull(mainWindow.ToggleMapLegendViewCommand);
+ Assert.IsNotNull(mainWindow.ToggleChartLegendViewCommand);
+ Assert.IsNotNull(mainWindow.TogglePropertyGridViewCommand);
+ Assert.IsNotNull(mainWindow.ToggleMessageWindowCommand);
+ Assert.IsNotNull(mainWindow.OpenLogFileCommand);
+ Assert.IsNotNull(mainWindow.OpenUserManualCommand);
}
}
@@ -1173,6 +1181,46 @@
mocks.VerifyAll();
}
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void GivenMainWindowWithOrWithoutUserManual_WhenCanExecuteOpenUserManualCommand_ThenExpectedValue(bool userManualPresent)
+ {
+ // Given
+ var mocks = new MockRepository();
+ var project = mocks.Stub();
+ var projectStore = mocks.Stub();
+ var projectMigrator = mocks.Stub();
+ var projectFactory = mocks.Stub();
+ projectFactory.Stub(pf => pf.CreateNewProject())
+ .Return(project);
+ mocks.ReplayAll();
+
+ string path = Uri.UnescapeDataString(new UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path);
+
+ var settings = new GuiCoreSettings
+ {
+ ManualFilePath = userManualPresent ? path : null
+ };
+
+ using (var mainWindow = new Gui.Forms.MainWindow.MainWindow())
+ using (var gui = new GuiCore(mainWindow, projectStore, projectMigrator, projectFactory, settings))
+ {
+ gui.Plugins.Add(new TestPlugin());
+ gui.Run();
+
+ mainWindow.SetGui(gui);
+
+ // When
+ bool canExecute = mainWindow.OpenUserManualCommand.CanExecute(null);
+
+ // Then
+ Assert.AreEqual(userManualPresent, canExecute);
+ }
+
+ mocks.VerifyAll();
+ }
+
private static void ToggleToolViewAndAssert(Func getToolViewFunc,
Func getCommandFunc,
bool initiallyAdded)