From 2fe707abce023813d234b57b097a731174fd4a26 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 20 Feb 2018 15:08:22 +0200 Subject: Implemented module popping! --- .../ViewModels/MainViewVM.cs | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs') 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 679ba5ff3..503532223 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -7,6 +7,9 @@ using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; using Tango.Core.Commands; using Tango.Integration.Services; using Tango.Logging; @@ -18,8 +21,10 @@ using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.Common.StudioApplication; using Tango.MachineStudio.UI.SupervisingController; using Tango.MachineStudio.UI.Views; +using Tango.MachineStudio.UI.Windows; using Tango.PMR.Stubs; using Tango.SharedUI; +using Tango.SharedUI.Helpers; using Tango.Transport.Adapters; namespace Tango.MachineStudio.UI.ViewModels @@ -68,6 +73,11 @@ namespace Tango.MachineStudio.UI.ViewModels /// public RelayCommand StartModuleCommand { get; set; } + /// + /// Gets or sets the open module in window command. + /// + public RelayCommand OpenModuleInWindowCommand { get; set; } + /// /// Gets or sets the home command. /// @@ -157,6 +167,7 @@ namespace Tango.MachineStudio.UI.ViewModels ConnectCommand = new RelayCommand(ConnectToMachine); SignoutCommand = new RelayCommand(SignOut); DisconnectCommand = new RelayCommand(DisconnectFromMachine, (x) => ApplicationManager.IsMachineConnected && !_isDisconnecting); + OpenModuleInWindowCommand = new RelayCommand(OpenModuleInWindow); } /// @@ -302,5 +313,28 @@ namespace Tango.MachineStudio.UI.ViewModels { base.OnViewAttached(); } + + private void OpenModuleInWindow(IStudioModule module) + { + module.InNewWindow = true; + + var parent = (MainView.Self as MainView).TransitionControl.Controls.SingleOrDefault(x => x.Tag.ToString() == module.Name).Content as Grid; + + var view = parent.Children[0] as FrameworkElement; + parent.Children.Remove(view); + + ModuleWindowVM vm = new ModuleWindowVM(module, parent); + ModuleWindow window = new ModuleWindow(this, vm, view); + + window.Closing += (x, y) => + { + window.grid.Children.Remove(view); + parent.Children.Add(view); + module.InNewWindow = false; + }; + + window.Owner = MainWindow.Instance; + window.Show(); + } } } -- cgit v1.3.1