Index: Core/Gui/src/Core.Gui/Forms/Backstage/BackstageViewModel.cs =================================================================== diff -u -r5d59491a99d3e9ae9d65b24a8774d1db96e57f4f -r2ccd820a20c579a55a3752d370c30781624e6dee --- Core/Gui/src/Core.Gui/Forms/Backstage/BackstageViewModel.cs (.../BackstageViewModel.cs) (revision 5d59491a99d3e9ae9d65b24a8774d1db96e57f4f) +++ Core/Gui/src/Core.Gui/Forms/Backstage/BackstageViewModel.cs (.../BackstageViewModel.cs) (revision 2ccd820a20c579a55a3752d370c30781624e6dee) @@ -22,6 +22,7 @@ using System; using System.ComponentModel; using System.Diagnostics; +using System.IO; using System.Runtime.CompilerServices; using System.Windows.Input; using Core.Gui.Commands; @@ -65,6 +66,7 @@ OpenHelpdeskWaterWebsiteCommand = new RelayCommand(OnOpenHelpdeskWaterWebsite); EmailHelpdeskWaterSupportCommand = new RelayCommand(OnEmailHelpdeskWaterSupport); CallHelpdeskWaterSupportCommand = new RelayCommand(OnCallHelpdeskWaterSupport); + OpenUserManualCommand = new RelayCommand(OnOpenUserManual, CanOpenUserManual); SetSelectedViewModelCommand = new RelayCommand(OnSetCurrentViewModel); SelectedViewModel = InfoViewModel; @@ -86,6 +88,11 @@ public ICommand CallHelpdeskWaterSupportCommand { get; } /// + /// Gets the command to open the user manual. + /// + public ICommand OpenUserManualCommand { get; } + + /// /// Gets the command to set the selected view model. /// public ICommand SetSelectedViewModelCommand { get; } @@ -194,6 +201,16 @@ Process.Start(settings.SupportPhoneNumberUrl); } + private bool CanOpenUserManual(object obj) + { + return File.Exists(settings.ManualFilePath); + } + + private void OnOpenUserManual(object obj) + { + Process.Start(settings.ManualFilePath); + } + private void OnSetCurrentViewModel(object obj) { SelectedViewModel = (IBackstagePageViewModel) obj; Index: Core/Gui/src/Core.Gui/Forms/MainWindow/MainWindow.xaml =================================================================== diff -u -r5d59491a99d3e9ae9d65b24a8774d1db96e57f4f -r2ccd820a20c579a55a3752d370c30781624e6dee --- Core/Gui/src/Core.Gui/Forms/MainWindow/MainWindow.xaml (.../MainWindow.xaml) (revision 5d59491a99d3e9ae9d65b24a8774d1db96e57f4f) +++ Core/Gui/src/Core.Gui/Forms/MainWindow/MainWindow.xaml (.../MainWindow.xaml) (revision 2ccd820a20c579a55a3752d370c30781624e6dee) @@ -54,7 +54,7 @@ + Command="{Binding Path=BackstageViewModel.OpenUserManualCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=metro:MetroWindow}}" /> @@ -440,11 +437,6 @@ /// public ICommand OpenLogFileCommand { get; } - /// - /// Gets the command to open the user manual. - /// - public ICommand OpenUserManualCommand { get; } - private void OnNewProject(object obj) { commands.StorageCommands.CreateNewProject(); @@ -545,16 +537,6 @@ commands.ApplicationCommands.OpenLogFileExternal(); } - private bool CanOpenUserManual(object obj) - { - return File.Exists(settings?.FixedSettings.ManualFilePath); - } - - private void OnOpenUserManual(object obj) - { - Process.Start(settings.FixedSettings.ManualFilePath); - } - #endregion #region ToolWindows Index: Core/Gui/test/Core.Gui.Test/Forms/Backstage/BackstageViewModelTest.cs =================================================================== diff -u -r5d59491a99d3e9ae9d65b24a8774d1db96e57f4f -r2ccd820a20c579a55a3752d370c30781624e6dee --- Core/Gui/test/Core.Gui.Test/Forms/Backstage/BackstageViewModelTest.cs (.../BackstageViewModelTest.cs) (revision 5d59491a99d3e9ae9d65b24a8774d1db96e57f4f) +++ Core/Gui/test/Core.Gui.Test/Forms/Backstage/BackstageViewModelTest.cs (.../BackstageViewModelTest.cs) (revision 2ccd820a20c579a55a3752d370c30781624e6dee) @@ -22,9 +22,14 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.Reflection; +using Core.Common.Base.Data; +using Core.Common.Base.Storage; using Core.Gui.Forms.Backstage; using Core.Gui.Settings; +using Core.Gui.TestUtil; using NUnit.Framework; +using Rhino.Mocks; namespace Core.Gui.Test.Forms.Backstage { @@ -69,6 +74,7 @@ Assert.IsNotNull(viewModel.OpenHelpdeskWaterWebsiteCommand); Assert.IsNotNull(viewModel.CallHelpdeskWaterSupportCommand); Assert.IsNotNull(viewModel.EmailHelpdeskWaterSupportCommand); + Assert.IsNotNull(viewModel.OpenUserManualCommand); Assert.IsNotNull(viewModel.SetSelectedViewModelCommand); Assert.AreSame(viewModel.InfoViewModel, viewModel.SelectedViewModel); @@ -130,6 +136,29 @@ Assert.AreEqual(openSelected, viewModel.SupportSelected); } + [Test] + [TestCase(true)] + [TestCase(false)] + public void GivenViewModelWithSettingsWithOrWithoutUserManualPathSet_WhenCanExecuteOpenUserManualCommand_ThenExpectedValue( + bool userManualPresent) + { + // Given + string path = Uri.UnescapeDataString(new UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path); + + var settings = new GuiCoreSettings + { + ManualFilePath = userManualPresent ? path : null + }; + + var viewModel = new BackstageViewModel(settings, "1.0"); + + // When + bool canExecute = viewModel.OpenUserManualCommand.CanExecute(null); + + // Then + Assert.AreEqual(userManualPresent, canExecute); + } + private static IEnumerable GetBackstagePageViewModels() { yield return new TestCaseData(new Func( Index: Core/Gui/test/Core.Gui.Test/Forms/MainWindow/MainWindowTest.cs =================================================================== diff -u -r6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6 -r2ccd820a20c579a55a3752d370c30781624e6dee --- Core/Gui/test/Core.Gui.Test/Forms/MainWindow/MainWindowTest.cs (.../MainWindowTest.cs) (revision 6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6) +++ Core/Gui/test/Core.Gui.Test/Forms/MainWindow/MainWindowTest.cs (.../MainWindowTest.cs) (revision 2ccd820a20c579a55a3752d370c30781624e6dee) @@ -116,7 +116,6 @@ Assert.IsNotNull(mainWindow.TogglePropertyGridViewCommand); Assert.IsNotNull(mainWindow.ToggleMessageWindowCommand); Assert.IsNotNull(mainWindow.OpenLogFileCommand); - Assert.IsNotNull(mainWindow.OpenUserManualCommand); Assert.IsNull(mainWindow.BackstageViewModel); } @@ -1207,46 +1206,6 @@ 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)