diff options
| author | Avi Levkovich <avi@twine-s.com> | 2018-04-25 09:44:13 +0300 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2018-04-25 09:44:13 +0300 |
| commit | d352d3b3bd785d9eb8a93347333de0b357f7ce0e (patch) | |
| tree | 2488173ea7e4f9d5ddb6ef53de57998815732847 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs | |
| parent | c82908b6d5314bc2602ea10c373267b79fbdd810 (diff) | |
| parent | a89077bae848d010ae70da6be572dee3b824a895 (diff) | |
| download | Tango-d352d3b3bd785d9eb8a93347333de0b357f7ce0e.tar.gz Tango-d352d3b3bd785d9eb8a93347333de0b357f7ce0e.zip | |
Start SPI ADS1220
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs | 69 |
1 files changed, 53 insertions, 16 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index b97825d34..0882267e8 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -1,6 +1,4 @@ -using GalaSoft.MvvmLight.Ioc; -using GalaSoft.MvvmLight.Messaging; -using System; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; @@ -14,6 +12,7 @@ using System.Windows.Controls; using System.Windows.Media; using Tango.BL.Entities; using Tango.Core.Commands; +using Tango.Core.DI; using Tango.Integration.Services; using Tango.Logging; using Tango.MachineStudio.Common; @@ -30,6 +29,7 @@ using Tango.MachineStudio.Common.StudioApplication; using Tango.MachineStudio.Common.Update; using Tango.MachineStudio.UI.StudioApplication; using Tango.MachineStudio.UI.SupervisingController; +using Tango.MachineStudio.UI.TFS; using Tango.MachineStudio.UI.Views; using Tango.MachineStudio.UI.Windows; using Tango.PMR.Stubs; @@ -45,7 +45,7 @@ namespace Tango.MachineStudio.UI.ViewModels /// Represents the Machine Studio main view, view model. /// </summary> /// <seealso cref="Tango.SharedUI.ViewModel{Tango.MachineStudio.UI.SupervisingController.IMainView}" /> - public class MainViewVM : ViewModel<IMainView> + public class MainViewVM : ViewModel { private IStudioModule _currentModule; private INavigationManager _navigation; @@ -143,6 +143,11 @@ namespace Tango.MachineStudio.UI.ViewModels /// </summary> public RelayCommand<MachinesEvent> ResolveMachineEventCommand { get; set; } + /// <summary> + /// Gets or sets the report issue command. + /// </summary> + public RelayCommand ReportIssueCommand { get; set; } + private IAuthenticationProvider _authenticationProvider; /// <summary> /// Gets or sets the authentication provider. @@ -184,6 +189,11 @@ namespace Tango.MachineStudio.UI.ViewModels } /// <summary> + /// Gets or sets the TFS client. + /// </summary> + public TeamFoundationServiceExtendedClient TFSClient { get; set; } + + /// <summary> /// Gets or sets the speech provider. /// </summary> public ISpeechProvider SpeechProvider { get; set; } @@ -240,7 +250,6 @@ namespace Tango.MachineStudio.UI.ViewModels /// <param name="applicationManager">The application manager.</param> /// <param name="navigationManager">The navigation manager.</param> public MainViewVM( - IMainView view, IAuthenticationProvider authenticationProvider, IStudioModuleLoader studioModuleLoader, INotificationProvider notificationProvider, @@ -249,8 +258,9 @@ namespace Tango.MachineStudio.UI.ViewModels IEventLogger eventLogger, IDiagnosticsFrameProvider frameProvider, ISpeechProvider speechProvider, - IHtmlPresenter htmlPresenter) : base(view) + IHtmlPresenter htmlPresenter, TeamFoundationServiceExtendedClient tfs) : base() { + TFSClient = tfs; _eventLogger = eventLogger; _navigation = navigationManager; AuthenticationProvider = authenticationProvider; @@ -290,6 +300,8 @@ namespace Tango.MachineStudio.UI.ViewModels ToggleSpeechCommand = new RelayCommand(() => { SpeechProvider.Mute = !SpeechProvider.Mute; }); ResolveMachineEventCommand = new RelayCommand<MachinesEvent>(ResolveMachineEvent); + + ReportIssueCommand = new RelayCommand(ReportIssue); } private void MachineEventsStateProvider_EventsResolved(object sender, IEnumerable<MachinesEvent> e) @@ -500,17 +512,22 @@ namespace Tango.MachineStudio.UI.ViewModels if (module != null) { + LogManager.Log(String.Format("Starting module '{0}'...", module.Name)); + if (!(MainView.Self as MainView).TransitionControl.Elements.ToList().Exists(x => x.GetType() == module.MainViewType)) { + LogManager.Log("Module was not initialized. Initializing..."); + FrameworkElement view = Activator.CreateInstance(module.MainViewType) as FrameworkElement; NavigationControl.SetNavigationName(view, module.Name); (MainView.Self as MainView).TransitionControl.Elements.Add(view); } } - foreach (var m in StudioModuleLoader.AllModules.Where(x => x != module)) + foreach (var m in StudioModuleLoader.AllModules.Where(x => x != module && !x.InNewWindow)) { m.IsLoaded = false; + TangoIOC.Default.GetModuleViewModels(m).ToList().ForEach(x => x.OnNavigatedFrom()); } if (module != null) @@ -518,24 +535,21 @@ namespace Tango.MachineStudio.UI.ViewModels CurrentModule = module; CurrentModule.IsLoaded = true; IsModuleLoaded = true; + + LogManager.Log(String.Format("Navigating to module '{0}'...", module.Name)); (MainView.Self as MainView).TransitionControl.NavigateTo(module.Name); + + TangoIOC.Default.GetModuleViewModels(module).ToList().ForEach(x => x.OnNavigatedTo()); } else { IsModuleLoaded = false; + LogManager.Log(String.Format("Navigating to Home...")); (MainView.Self as MainView).TransitionControl.NavigateTo("Home"); } } /// <summary> - /// Called when the <see cref="T:Tango.SharedUI.IView" /> is loaded and attached. - /// </summary> - protected override void OnViewAttached() - { - base.OnViewAttached(); - } - - /// <summary> /// Opens the module in a new window. /// </summary> /// <param name="module">The module.</param> @@ -545,17 +559,21 @@ namespace Tango.MachineStudio.UI.ViewModels try { + module.InNewWindow = true; + StartModule(null); - module.InNewWindow = true; + LogManager.Log(String.Format("Starting module '{0}' in new window...", module.Name)); if (!(MainView.Self as MainView).TransitionControl.Elements.ToList().Exists(x => x.GetType() == module.MainViewType)) { + LogManager.Log("Module was not initialized. Initializing..."); FrameworkElement v = Activator.CreateInstance(module.MainViewType) as FrameworkElement; NavigationControl.SetNavigationName(v, module.Name); (MainView.Self as MainView).TransitionControl.Elements.Add(v); } + LogManager.Log("Detaching module view..."); var view = (MainView.Self as MainView).TransitionControl.GetAndDetach(module.Name); ModuleWindowVM vm = new ModuleWindowVM(module); @@ -563,13 +581,20 @@ namespace Tango.MachineStudio.UI.ViewModels window.Closing += (x, y) => { + LogManager.Log(String.Format("Closing module '{0}' on new window...", module.Name)); + window.grid.Children.Remove(view); module.InNewWindow = false; + TangoIOC.Default.GetModuleViewModels(module).ToList().ForEach(v => v.OnNavigatedFrom()); }; window.Owner = MainWindow.Instance; + + LogManager.Log("Opening new window..."); window.Show(); + TangoIOC.Default.GetModuleViewModels(module).ToList().ForEach(x => x.OnNavigatedTo()); + (_applicationManager as DefaultStudioApplicationManager).RegisterOpenedWindow(window); } catch (Exception ex) @@ -617,5 +642,17 @@ namespace Tango.MachineStudio.UI.ViewModels _notificationProvider.ShowWarning("Could not locate guidance content for the specified event."); } } + + private void ReportIssue() + { + _notificationProvider.ShowModalDialog<ReportIssueViewVM, ReportIssueView>(new ReportIssueViewVM(TFSClient.Project, TFSClient.CreateBug()), async (vm) => + { + using (_notificationProvider.PushTaskItem("Uploading bug report...")) + { + await TFSClient.UploadWorkItem(vm.WorkItem); + } + + }, null); + } } } |
