aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs104
1 files changed, 103 insertions, 1 deletions
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;
+ /// <summary>
+ /// Gets or sets the job selected segment.
+ /// </summary>
+ public Segment SelectedSegment
+ {
+ get { return _selectedSegment; }
+ set { _selectedSegment = value; RaisePropertyChangedAuto(); }
}
private Rml _selectedRML;
@@ -184,6 +199,26 @@ namespace Tango.MachineStudio.Developer.ViewModels
/// </summary>
public RelayCommand SaveLiquidFactorsCommand { get; set; }
+ /// <summary>
+ /// Gets or sets the add segment command.
+ /// </summary>
+ public RelayCommand AddSegmentCommand { get; set; }
+
+ /// <summary>
+ /// Gets or sets the remove segment command.
+ /// </summary>
+ public RelayCommand RemoveSegmentCommand { get; set; }
+
+ /// <summary>
+ /// Gets or sets the add job command.
+ /// </summary>
+ public RelayCommand AddJobCommand { get; set; }
+
+ /// <summary>
+ /// Gets or sets the remove job command.
+ /// </summary>
+ 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
@@ -240,6 +279,17 @@ namespace Tango.MachineStudio.Developer.ViewModels
#region Virtual Methods
/// <summary>
+ /// Called when the selected job has been changed.
+ /// </summary>
+ private void OnSelectedJobChanged()
+ {
+ if (SelectedJob != null)
+ {
+ SelectedSegment = SelectedJob.Segments.FirstOrDefault();
+ }
+ }
+
+ /// <summary>
/// Called when the selected group history has been changed
/// </summary>
protected virtual void OnSelectedGroupHistoryChanged()
@@ -358,6 +408,58 @@ namespace Tango.MachineStudio.Developer.ViewModels
}
}
+ /// <summary>
+ /// Removes the selected segment.
+ /// </summary>
+ private void RemoveSegment()
+ {
+ if (SelectedJob != null && SelectedSegment != null)
+ {
+ SelectedSegment.DefferedDelete();
+ SelectedJob.Segments.Remove(SelectedSegment);
+ }
+ }
+
+ /// <summary>
+ /// Adds a new segment.
+ /// </summary>
+ private void AddSegment()
+ {
+ if (SelectedJob != null)
+ {
+ Segment seg = new Segment();
+ seg.Name = "New Seg";
+ SelectedJob.Segments.Add(seg);
+ }
+ }
+
+ /// <summary>
+ /// Removes the selected job.
+ /// </summary>
+ private void RemoveJob()
+ {
+ if (SelectedMachine != null && SelectedJob != null)
+ {
+ SelectedJob.Delete();
+ SelectedMachine.Jobs.Remove(SelectedJob);
+ }
+ }
+
+ /// <summary>
+ /// Adds a new job to the selected machine.
+ /// </summary>
+ private void AddJob()
+ {
+ if (SelectedMachine != null)
+ {
+ SelectedMachine.Jobs.Add(new Job()
+ {
+ Name = "New Job",
+ CreationDate = DateTime.UtcNow,
+ });
+ }
+ }
+
#endregion
#region Public Events