aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules
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
parent4760444d7276aec024dac5fbbc202becc41105dd (diff)
downloadTango-cfe28eaf0adcd54776c0a369210e6f7b4bca9558.tar.gz
Tango-cfe28eaf0adcd54776c0a369210e6f7b4bca9558.zip
Added machine clone in machine designer !
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/ViewModels/MainViewVM.cs5
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/Views/DispensersView.xaml2
-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
4 files changed, 35 insertions, 9 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/ViewModels/MainViewVM.cs
index ca384f6bf..d92d86580 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/ViewModels/MainViewVM.cs
@@ -170,7 +170,10 @@ namespace Tango.MachineStudio.Dispensers.ViewModels
{
IsFree = false;
await _activeContext.SaveChangesAsync();
- await SelectedDispenser.Reload(_dbContext);
+ if (SelectedDispenser != null)
+ {
+ await SelectedDispenser.Reload(_dbContext);
+ }
}
catch (Exception ex)
{
diff --git a/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/Views/DispensersView.xaml b/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/Views/DispensersView.xaml
index 91ee5a189..9f36ee78a 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/Views/DispensersView.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/MachineStudio.Dispensers/Views/DispensersView.xaml
@@ -67,7 +67,7 @@
<DataGridTextColumn Header="TYPE" Binding="{Binding DispenserType.Name}" Width="Auto" />
<DataGridTextColumn Header="NANOLITER / PULSE" Binding="{Binding NlPerPulse}" Width="Auto" />
<DataGridTextColumn Header="INSTALLED" Binding="{Binding IsInstalled}" Width="Auto" />
- <DataGridTextColumn Header="LAST UPDATED" Binding="{Binding LastUpdated,Converter={StaticResource DateTimeUTCToShortDateTimeConverter}}" Width="Auto" />
+ <DataGridTextColumn Header="LAST UPDATED" Binding="{Binding LastUpdated,Converter={StaticResource DateTimeUTCToShortDateTimeConverter}}" Width="1*" />
</DataGrid.Columns>
</DataGrid>
</Grid>
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" />