aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs44
1 files changed, 44 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs
index b0b97d7d4..a5b54fed2 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs
@@ -101,6 +101,14 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
set { _filter = value; RaisePropertyChangedAuto(); OnFilterChanged(); }
}
+ private Spool _selectedSpool;
+ public Spool SelectedSpool
+ {
+ get { return _selectedSpool; }
+ set { _selectedSpool = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
+ }
+
+
#endregion
#region Commands
@@ -140,6 +148,16 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
/// </summary>
public RelayCommand BackToMachinesCommand { get; set; }
+ /// <summary>
+ /// Gets or sets the add spool command.
+ /// </summary>
+ public RelayCommand AddSpoolCommand { get; set; }
+
+ /// <summary>
+ /// Gets or sets the remove spool command.
+ /// </summary>
+ public RelayCommand RemoveSpoolCommand { get; set; }
+
#endregion
#region Constructors
@@ -165,8 +183,11 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
SaveCommand = new RelayCommand(SaveMachine);
AddMachineCommand = new RelayCommand(AddNewMachine);
RemoveMachineCommand = new RelayCommand(RemoveSelectedMachine,() => SelectedMachine != null);
+ AddSpoolCommand = new RelayCommand(AddNewSpool);
+ RemoveSpoolCommand = new RelayCommand(RemoveSpool,() => SelectedSpool != null);
}
+
#endregion
#region Application Ready
@@ -489,6 +510,11 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
}
}
+ if (ActiveMachine.Spools.GroupBy(x => x.SpoolType).Any(x => x.Count() > 1))
+ {
+ errors.Add($"Same spool type is registered multiple times.");
+ }
+
if (errors.Count > 0)
{
String errorsString = "Please fix the following validation errors before trying to save." + Environment.NewLine + Environment.NewLine;
@@ -508,6 +534,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
ActiveMachine.LastUpdated = DateTime.UtcNow;
ActiveMachine.ProductionDate = DateTime.UtcNow;
await ActiveMachineAdapter.Context.SaveChangesAsync();
+ await SelectedMachine.Reload(MachinesAdapter.Context);
}
}
catch (Exception ex)
@@ -554,6 +581,23 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
#endregion
+ private void AddNewSpool()
+ {
+ _activeMachineAdapter.Context.Spools.Add(new Spool()
+ {
+ Machine = ActiveMachine,
+ });
+ }
+
+ private void RemoveSpool()
+ {
+ if (SelectedSpool != null)
+ {
+ _activeMachineAdapter.Context.Spools.Remove(SelectedSpool);
+ ActiveMachine.Spools.Remove(SelectedSpool);
+ }
+ }
+
private async void OnFilterChanged()
{
if (Filter != null)