aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-12-30 19:25:18 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-12-30 19:25:18 +0200
commitcfe28eaf0adcd54776c0a369210e6f7b4bca9558 (patch)
treedc1057d095ca3187668c8f2a6b31fc0e8d1338de /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels
parent4760444d7276aec024dac5fbbc202becc41105dd (diff)
downloadTango-cfe28eaf0adcd54776c0a369210e6f7b4bca9558.tar.gz
Tango-cfe28eaf0adcd54776c0a369210e6f7b4bca9558.zip
Added machine clone in machine designer !
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs31
1 files changed, 24 insertions, 7 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 a5b54fed2..2f77b0d14 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
@@ -158,6 +158,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
/// </summary>
public RelayCommand RemoveSpoolCommand { get; set; }
+ public RelayCommand CloneMachineCommand { get; set; }
#endregion
#region Constructors
@@ -182,12 +183,11 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
BackToMachinesCommand = new RelayCommand(() => View.NavigateTo(MachineDesignerNavigationView.MachinesView));
SaveCommand = new RelayCommand(SaveMachine);
AddMachineCommand = new RelayCommand(AddNewMachine);
- RemoveMachineCommand = new RelayCommand(RemoveSelectedMachine,() => SelectedMachine != null);
+ RemoveMachineCommand = new RelayCommand(RemoveSelectedMachine, () => SelectedMachine != null);
AddSpoolCommand = new RelayCommand(AddNewSpool);
- RemoveSpoolCommand = new RelayCommand(RemoveSpool,() => SelectedSpool != null);
+ RemoveSpoolCommand = new RelayCommand(RemoveSpool, () => SelectedSpool != null);
+ CloneMachineCommand = new RelayCommand(CloneMachine, () => SelectedMachine != null);
}
-
-
#endregion
#region Application Ready
@@ -349,7 +349,7 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
InvalidateRelayCommands();
}
- private async void LoadSelectedMachine(bool newMachine = false)
+ private async void LoadSelectedMachine(bool newMachine = false, bool clone = false)
{
using (_notification.PushTaskItem("Loading machine details..."))
{
@@ -385,6 +385,14 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
if (!newMachine)
{
ActiveMachine = (await new MachineBuilder(ActiveMachineAdapter.Context).Set(SelectedMachine.Guid).WithOrganization().WithConfiguration().WithSpools().BuildAsync());
+
+ if (clone)
+ {
+ ActiveMachine = ActiveMachine.Clone();
+ ActiveMachine.Name = "Untitled";
+ ActiveMachine.SerialNumber = "";
+ ActiveMachineAdapter.Context.Machines.Add(ActiveMachine);
+ }
}
else
{
@@ -534,7 +542,11 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
ActiveMachine.LastUpdated = DateTime.UtcNow;
ActiveMachine.ProductionDate = DateTime.UtcNow;
await ActiveMachineAdapter.Context.SaveChangesAsync();
- await SelectedMachine.Reload(MachinesAdapter.Context);
+
+ if (SelectedMachine != null)
+ {
+ await SelectedMachine.Reload(MachinesAdapter.Context);
+ }
}
}
catch (Exception ex)
@@ -581,11 +593,16 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels
#endregion
+ private void CloneMachine()
+ {
+ LoadSelectedMachine(false, true);
+ }
+
private void AddNewSpool()
{
_activeMachineAdapter.Context.Spools.Add(new Spool()
{
- Machine = ActiveMachine,
+ Machine = ActiveMachine,
});
}