aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-07-30 14:32:08 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-07-30 14:32:08 +0300
commita880f38b7f44efb2aabee6c9e951eaa5a2563c0a (patch)
treec36b11db044c203f6cadccae1e411fe5808d313b /Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs
parent019bc4dca9a0655e5adf1e26d8e3f513563113db (diff)
downloadTango-a880f38b7f44efb2aabee6c9e951eaa5a2563c0a.tar.gz
Tango-a880f38b7f44efb2aabee6c9e951eaa5a2563c0a.zip
Working on PPC machine settings !
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/ViewModels/MainViewVM.cs70
1 files changed, 66 insertions, 4 deletions
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
/// <seealso cref="Tango.PPC.Common.PPCViewModel" />
public class MainViewVM : PPCViewModel
{
+ #region Properties
+
+ private Machine _machine;
+ public Machine Machine
+ {
+ get { return _machine; }
+ set { _machine = value; RaisePropertyChangedAuto(); }
+ }
+
+ private SelectedObjectCollection<JobTypes> _selectedJobTypes;
+ public SelectedObjectCollection<JobTypes> SelectedJobTypes
+ {
+ get { return _selectedJobTypes; }
+ set { _selectedJobTypes = value; RaisePropertyChangedAuto(); }
+ }
+
+ #endregion
+
+ #region Commands
+
/// <summary>
- /// Gets or sets the external bridge service.
+ /// Gets or sets the save command.
/// </summary>
- [TangoInject]
- public IPPCExternalBridgeService ExternalBridgeService { get; set; }
+ public RelayCommand SaveCommand { get; set; }
+
+ /// <summary>
+ /// Gets or sets the discard command.
+ /// </summary>
+ 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();
+ }
/// <summary>
/// Called when the application has been started
/// </summary>
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<JobTypes>(Enum.GetValues(typeof(JobTypes)).Cast<JobTypes>().ToObservableCollection(), Machine.SupportedJobTypes.ToObservableCollection());
}
}
}