From 160ec4042539e69a7494bcde5c893c6dffcbf1b6 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 19 Feb 2018 19:09:12 +0200 Subject: Working on developer module.. --- .../DeveloperModule.cs | 2 +- .../Navigation/DeveloperNavigationManager.cs | 2 +- .../Tango.MachineStudio.Developer.csproj | 6 +- .../ViewModelLocator.cs | 2 +- .../ViewModels/MainViewVM.cs | 76 ++-- .../Views/DeveloperView.xaml | 414 --------------------- .../Views/DeveloperView.xaml.cs | 31 -- .../Views/JobView.xaml | 2 +- .../Views/MachineJobSelectionView.xaml | 30 +- .../Views/MainView.xaml | 414 +++++++++++++++++++++ .../Views/MainView.xaml.cs | 44 +++ 11 files changed, 536 insertions(+), 487 deletions(-) delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/DeveloperView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/DeveloperView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs index 17c08adc4..6cdda4bc8 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/DeveloperModule.cs @@ -36,7 +36,7 @@ namespace Tango.MachineStudio.Developer /// /// Gets the module entry point view. /// - public override FrameworkElement MainView => new DeveloperView(); + public override FrameworkElement MainView => new MainView(); /// /// Gets the permission required to see and load this module. diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Navigation/DeveloperNavigationManager.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Navigation/DeveloperNavigationManager.cs index 297caf2dc..5be50231d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Navigation/DeveloperNavigationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Navigation/DeveloperNavigationManager.cs @@ -12,7 +12,7 @@ namespace Tango.MachineStudio.Developer.Navigation { public void NavigateTo(DeveloperNavigationView view) { - DeveloperView.Instance.TransitionControl.AutoNavigate(view.ToString()); + MainView.Instance.TransitionControl.AutoNavigate(view.ToString()); } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj index 3253fc551..91a9602be 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Tango.MachineStudio.Developer.csproj @@ -124,8 +124,8 @@ - - DeveloperView.xaml + + MainView.xaml @@ -148,7 +148,7 @@ MSBuild:Compile Designer - + Designer MSBuild:Compile diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModelLocator.cs index b397f1912..c5ed7d385 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModelLocator.cs @@ -20,7 +20,7 @@ namespace Tango.MachineStudio.Developer { ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); - //SimpleIoc.Default.Register(() => MainView.Self); + SimpleIoc.Default.Register(() => MainView.Instance); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index 199183c12..62b742390 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -45,7 +45,7 @@ namespace Tango.MachineStudio.Developer.ViewModels /// Represents the developer module main view, view model. /// /// - public class MainViewVM : ViewModel, IShutdownRequestBlocker + public class MainViewVM : ViewModel, IShutdownRequestBlocker, IShutdownListener { private static object _syncLock = new object(); @@ -464,6 +464,14 @@ namespace Tango.MachineStudio.Developer.ViewModels } } + private String _jobFilter; + + public String JobFilter + { + get { return _jobFilter; } + set { _jobFilter = value; RaisePropertyChangedAuto(); OnJobFilterChanged(); } + } + #endregion #region Commands @@ -575,7 +583,7 @@ namespace Tango.MachineStudio.Developer.ViewModels /// /// Initializes a new instance of the class. /// - public MainViewVM() : base() + public MainViewVM(IMainView view) : base(view, true) { } @@ -586,16 +594,22 @@ namespace Tango.MachineStudio.Developer.ViewModels /// The application manager. /// The notification provider. [PreferredConstructor] - public MainViewVM(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, IAuthenticationProvider authentication) : this() + public MainViewVM(IMainView view, IStudioApplicationManager applicationManager, INotificationProvider notificationProvider, IDiagnosticsFrameProvider diagnosticsFrameProvider, IVideoCaptureProvider videoCaptureProvider, DeveloperNavigationManager navigation, IAuthenticationProvider authentication) : this(view) { - using (var db = ObservablesContext.CreateDefault()) + SelectedJobs = new ObservableCollection(); + + _machineDBContext = ObservablesContext.CreateDefault(); + + if (SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid != null) { - Machines = db.Machines.ToObservableCollection(); + SelectedMachine = _machineDBContext.Machines.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid); } - _machineDBContext = ObservablesContext.CreateDefault(); + if (SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid != null && SelectedMachine != null) + { + SelectedMachineJob = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid); + } - SelectedJobs = new ObservableCollection(); _authentication = authentication; @@ -748,7 +762,6 @@ namespace Tango.MachineStudio.Developer.ViewModels ReloadMachine(); JobsCollectionView = CollectionViewSource.GetDefaultView(SelectedMachine.Jobs); JobsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Job.LastUpdated), ListSortDirection.Descending)); - InvalidateLiquidFactorsAndProcessTables(); } } @@ -757,7 +770,8 @@ namespace Tango.MachineStudio.Developer.ViewModels _machineDBContext.Dispose(); _machineDBContext = ObservablesContext.CreateDefault(); _machineDBContext.Configuration.LazyLoadingEnabled = true; - _selectedMachine = _machineDBContext.Machines.SingleOrDefault(x => x.Guid == _selectedMachine.Guid); + Machines = _machineDBContext.Machines.ToObservableCollection(); + _selectedMachine = Machines.SingleOrDefault(x => x.Guid == _selectedMachine.Guid); RaisePropertyChanged(nameof(SelectedMachine)); JobsCollectionView = CollectionViewSource.GetDefaultView(SelectedMachine.Jobs); @@ -768,6 +782,17 @@ namespace Tango.MachineStudio.Developer.ViewModels #region Private Methods + private void OnJobFilterChanged() + { + JobsCollectionView.Filter = (job) => + { + Job j = job as Job; + return String.IsNullOrWhiteSpace(JobFilter) + || + j.Name.ToLower().Contains(JobFilter.ToLower()); + }; + } + private void OnActiveJobChanged() { if (ActiveJob != null) @@ -998,7 +1023,7 @@ namespace Tango.MachineStudio.Developer.ViewModels { using (_notification.PushTaskItem("Saving Liquid Factors...")) { - await SelectedRML.SaveAsync(); + await SelectedRML.SaveAsync(_dbJobContext); InvalidateLiquidFactorsAndProcessTables(); } } @@ -1053,7 +1078,7 @@ namespace Tango.MachineStudio.Developer.ViewModels } SelectedRML.ProcessParametersTablesGroups.Add(group); - await SelectedRML.SaveAsync(); + await SelectedRML.SaveAsync(_dbJobContext); InvalidateLiquidFactorsAndProcessTables(); } @@ -1398,30 +1423,27 @@ namespace Tango.MachineStudio.Developer.ViewModels return Task.FromResult(false); } - SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid = SelectedMachine != null ? SelectedMachine.Guid : null; - SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid = ActiveJob != null ? ActiveJob.Guid : null; - return Task.FromResult(true); } #endregion - #region IMainView + #region IShutdownListener + + public void OnShuttingDown() + { + SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid = SelectedMachine != null ? SelectedMachine.Guid : null; + SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid = SelectedMachineJob != null ? SelectedMachineJob.Guid : null; + } - //protected override void OnViewAttached() - //{ - // base.OnViewAttached(); + #endregion - // //if (SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid != null) - // //{ - // // SelectedMachine = Adapter.Machines.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedMachineGuid); - // //} + #region IMainView - // //if (SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid != null && SelectedMachine != null) - // //{ - // // ActiveJob = SelectedMachine.Jobs.SingleOrDefault(x => x.Guid == SettingsManager.Default.MachineStudio.DeveloperModule.LastSelectedJobGuid); - // //} - //} + protected override void OnViewAttached() + { + base.OnViewAttached(); + } #endregion } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/DeveloperView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/DeveloperView.xaml deleted file mode 100644 index 276f6c99a..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/DeveloperView.xaml +++ /dev/null @@ -1,414 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Transparent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Job Completed Successfully - - - - - - - - - - - - - - - - - - - - - - - Job Failed To Complete - - - - - - - - - - - - - - - - - - - - - - - - - Job Aborted By User - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/DeveloperView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/DeveloperView.xaml.cs deleted file mode 100644 index dfa7a2441..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/DeveloperView.xaml.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace Tango.MachineStudio.Developer.Views -{ - /// - /// Interaction logic for DeveloperView.xaml - /// - public partial class DeveloperView : UserControl - { - public static DeveloperView Instance { get; set; } - - public DeveloperView() - { - InitializeComponent(); - Instance = this; - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml index 580e2438b..4467b1f28 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/JobView.xaml @@ -852,7 +852,7 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Job Completed Successfully + + + + + + + + + + + + + + + + + + + + + + + Job Failed To Complete + + + + + + + + + + + + + + + + + + + + + + + + + Job Aborted By User + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs new file mode 100644 index 000000000..ab181e8dc --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.SharedUI; + +namespace Tango.MachineStudio.Developer.Views +{ + /// + /// Interaction logic for DeveloperView.xaml + /// + public partial class MainView : UserControl, IMainView + { + private bool _loaded; + public static MainView Instance { get; set; } + + public MainView() + { + InitializeComponent(); + Instance = this; + + Loaded += (x, y) => + { + if (!_loaded) + { + _loaded = true; + ViewAttached?.Invoke(this, this); + } + }; + } + + public event EventHandler ViewAttached; + } +} -- cgit v1.3.1