From a880f38b7f44efb2aabee6c9e951eaa5a2563c0a Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 30 Jul 2018 14:32:08 +0300 Subject: Working on PPC machine settings ! --- .../ViewModels/MainViewVM.cs | 70 ++++++++++++++++++++-- 1 file changed, 66 insertions(+), 4 deletions(-) (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs index 61ce69e4e..17ad46245 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs @@ -3,9 +3,15 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.Core.Commands; using Tango.Core.DI; using Tango.PPC.Common; +using Tango.PPC.Common.Connection; using Tango.PPC.Common.ExternalBridge; +using Tango.SharedUI.Components; namespace Tango.PPC.MachineSettings.ViewModels { @@ -15,18 +21,74 @@ namespace Tango.PPC.MachineSettings.ViewModels /// public class MainViewVM : PPCViewModel { + #region Properties + + private Machine _machine; + public Machine Machine + { + get { return _machine; } + set { _machine = value; RaisePropertyChangedAuto(); } + } + + private SelectedObjectCollection _selectedJobTypes; + public SelectedObjectCollection SelectedJobTypes + { + get { return _selectedJobTypes; } + set { _selectedJobTypes = value; RaisePropertyChangedAuto(); } + } + + #endregion + + #region Commands + /// - /// Gets or sets the external bridge service. + /// Gets or sets the save command. /// - [TangoInject] - public IPPCExternalBridgeService ExternalBridgeService { get; set; } + public RelayCommand SaveCommand { get; set; } + + /// + /// Gets or sets the discard command. + /// + public RelayCommand DiscardCommand { get; set; } + + #endregion + + public MainViewVM() + { + SaveCommand = new RelayCommand(Save); + DiscardCommand = new RelayCommand(Discard); + } + + private void Discard() + { + NavigationManager.NavigateBack(); + } + + private void Save() + { + Machine.SupportedJobTypes = SelectedJobTypes.SynchedSource.ToList(); + Machine.ShallowCopyTo(MachineProvider.Machine); + MachineProvider.Machine.SaveAsync(ObservablesEntitiesAdapter.Instance.Context); + NavigationManager.NavigateBack(); + } /// /// Called when the application has been started /// public override void OnApplicationStarted() { - //Start initializing here rather then in the constructor. + + } + + public override void OnNavigatedTo() + { + base.OnNavigatedTo(); + + Machine = new Machine(); + MachineProvider.Machine.ShallowCopyTo(Machine); + RaisePropertyChanged(nameof(Machine)); + + SelectedJobTypes = new SelectedObjectCollection(Enum.GetValues(typeof(JobTypes)).Cast().ToObservableCollection(), Machine.SupportedJobTypes.ToObservableCollection()); } } } -- cgit v1.3.1