From bfc6aeabda4b320f9365f5eef4c8f1bcab9b24af Mon Sep 17 00:00:00 2001 From: Roy Date: Sat, 27 Jan 2018 22:57:48 +0200 Subject: Added IDS_PACK_FORMULA. Added necessary login to machine designer & db module. Started working on job segments. --- .../ViewModels/MainViewVM.cs | 104 ++++++++++++++++++++- 1 file changed, 103 insertions(+), 1 deletion(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs') 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 8f3d2a7e3..e77093eee 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 @@ -106,7 +106,22 @@ namespace Tango.MachineStudio.Developer.ViewModels public Job SelectedJob { get { return _selectedJob; } - set { _selectedJob = value; RaisePropertyChangedAuto(); } + set + { + _selectedJob = value; + RaisePropertyChangedAuto(); + OnSelectedJobChanged(); + } + } + + private Segment _selectedSegment; + /// + /// Gets or sets the job selected segment. + /// + public Segment SelectedSegment + { + get { return _selectedSegment; } + set { _selectedSegment = value; RaisePropertyChangedAuto(); } } private Rml _selectedRML; @@ -184,6 +199,26 @@ namespace Tango.MachineStudio.Developer.ViewModels /// public RelayCommand SaveLiquidFactorsCommand { get; set; } + /// + /// Gets or sets the add segment command. + /// + public RelayCommand AddSegmentCommand { get; set; } + + /// + /// Gets or sets the remove segment command. + /// + public RelayCommand RemoveSegmentCommand { get; set; } + + /// + /// Gets or sets the add job command. + /// + public RelayCommand AddJobCommand { get; set; } + + /// + /// Gets or sets the remove job command. + /// + public RelayCommand RemoveJobCommand { get; set; } + #endregion #region Constructors @@ -219,6 +254,10 @@ namespace Tango.MachineStudio.Developer.ViewModels ToggleSideBarCommand = new RelayCommand(() => IsSideBarOpened = !IsSideBarOpened); SaveProcessParametersCommand = new RelayCommand(SaveProcessParameters); SaveLiquidFactorsCommand = new RelayCommand(SaveLiquidFactors); + AddSegmentCommand = new RelayCommand(AddSegment); + RemoveSegmentCommand = new RelayCommand(RemoveSegment); + AddJobCommand = new RelayCommand(AddJob); + RemoveJobCommand = new RelayCommand(RemoveJob); } #endregion @@ -239,6 +278,17 @@ namespace Tango.MachineStudio.Developer.ViewModels #region Virtual Methods + /// + /// Called when the selected job has been changed. + /// + private void OnSelectedJobChanged() + { + if (SelectedJob != null) + { + SelectedSegment = SelectedJob.Segments.FirstOrDefault(); + } + } + /// /// Called when the selected group history has been changed /// @@ -358,6 +408,58 @@ namespace Tango.MachineStudio.Developer.ViewModels } } + /// + /// Removes the selected segment. + /// + private void RemoveSegment() + { + if (SelectedJob != null && SelectedSegment != null) + { + SelectedSegment.DefferedDelete(); + SelectedJob.Segments.Remove(SelectedSegment); + } + } + + /// + /// Adds a new segment. + /// + private void AddSegment() + { + if (SelectedJob != null) + { + Segment seg = new Segment(); + seg.Name = "New Seg"; + SelectedJob.Segments.Add(seg); + } + } + + /// + /// Removes the selected job. + /// + private void RemoveJob() + { + if (SelectedMachine != null && SelectedJob != null) + { + SelectedJob.Delete(); + SelectedMachine.Jobs.Remove(SelectedJob); + } + } + + /// + /// Adds a new job to the selected machine. + /// + private void AddJob() + { + if (SelectedMachine != null) + { + SelectedMachine.Jobs.Add(new Job() + { + Name = "New Job", + CreationDate = DateTime.UtcNow, + }); + } + } + #endregion #region Public Events -- cgit v1.3.1