aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/ViewModels/MainViewVM.cs31
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml6
2 files changed, 30 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,
});
}
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml
index 91eda3491..096beee39 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachinesView.xaml
@@ -36,6 +36,12 @@
<TextBlock Margin="5 0 0 0" FontSize="16">DELETE</TextBlock>
</StackPanel>
</Button>
+ <Button Margin="0 0 10 0" MinWidth="160" Height="50" Background="#FFA65F" BorderBrush="#FFA65F" Command="{Binding CloneMachineCommand}">
+ <StackPanel Orientation="Horizontal">
+ <materialDesign:PackIcon Kind="ContentCopy" Width="20" Height="20" />
+ <TextBlock Margin="5 0 0 0" FontSize="16">CLONE</TextBlock>
+ </StackPanel>
+ </Button>
<Button Margin="0 0 10 0" MinWidth="160" Height="50" Background="#65C682" BorderBrush="#65C682" Command="{Binding AddMachineCommand}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Plus" Width="20" Height="20" />