diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-01-07 14:18:58 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-01-07 14:18:58 +0200 |
| commit | 3f5ba302842a906950b118c7f6683c061819d76e (patch) | |
| tree | c49f8d2f8d1683d0c2655b0705d03765aac8621f /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner | |
| parent | 6ed849ee54a2f30315a622242f38dce92a309991 (diff) | |
| download | Tango-3f5ba302842a906950b118c7f6683c061819d76e.tar.gz Tango-3f5ba302842a906950b118c7f6683c061819d76e.zip | |
Warning on dispenser conflict in Machine Designer.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner')
2 files changed, 22 insertions, 13 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 457be98b2..ca1c95a03 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 @@ -265,6 +265,13 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels private async void Save() { + foreach (var ids in Configuration.IdsPacks) + { + ids.PackIndex = Configuration.IdsPacks.IndexOf(ids); + ids.Configuration = Configuration; + ids.ConfigurationGuid = Configuration.Guid; + } + //Validate List<String> errors = new List<string>(); @@ -333,24 +340,33 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels { if (pack.Name.IsNullOrWhiteSpace()) { - errors.Add(String.Format("Name is required on IDS pack number {0}.", Configuration.IdsPacks.IndexOf(pack) + 1)); + errors.Add(String.Format("Name is required on IDS pack number '{0}'.", Configuration.IdsPacks.IndexOf(pack) + 1)); continue; } if (pack.CartridgeTypes == null) { - errors.Add(String.Format("Cartridge type is required on IDS pack {0}.", pack.Name)); + errors.Add(String.Format("Cartridge type is required on IDS pack '{0}'.", pack.Name)); } if (pack.Dispenser == null) { - errors.Add(String.Format("Dispenser is required on IDS pack {0}.", pack.Name)); + errors.Add(String.Format("Dispenser is required on IDS pack '{0}'.", pack.Name)); } if (pack.LiquidTypes == null) { - errors.Add(String.Format("Liquid type is required on IDS pack {0}.", pack.Name)); + errors.Add(String.Format("Liquid type is required on IDS pack '{0}'.", pack.Name)); } if (pack.MidTankTypes == null) { - errors.Add(String.Format("Mid Tank type is required on IDS pack {0}.", pack.Name)); + errors.Add(String.Format("Mid Tank type is required on IDS pack '{0}'.", pack.Name)); + } + + var taken_ids = Adapter.Machines.Where(x => x.SerialNumber.ToLower() != Machine.SerialNumber).SelectMany(x => x.MachinesConfigurations).Select(x => x.Configuration).SelectMany(x => x.IdsPacks).ToList().FirstOrDefault(x => x.Dispenser.SerialNumber.ToLower() == pack.Dispenser.SerialNumber.ToLower()); + if (taken_ids != null && taken_ids.Configuration.MachinesConfigurations.Count > 0) + { + if (!_notification.ShowQuestion(String.Format("The Dispenser '{1}' on IDS pack '{0}' is already taken by another machine ('{2}', '{3}'). Are you sure you want to assign it to this machine?", pack.Name, pack.Dispenser.SerialNumber, taken_ids.Configuration.MachinesConfigurations.First().Machine.Name, taken_ids.Configuration.MachinesConfigurations.First().Machine.SerialNumber))) + { + return; + } } } @@ -367,13 +383,6 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels _isSaving = true; InvalidateRelayCommands(); - foreach (var ids in Configuration.IdsPacks) - { - ids.PackIndex = Configuration.IdsPacks.IndexOf(ids); - ids.Configuration = Configuration; - ids.ConfigurationGuid = Configuration.Guid; - } - try { using (_notification.PushTaskItem("Saving Machine Configuration...")) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml index 26a98a802..5324959e4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml @@ -89,7 +89,7 @@ <TextBlock FontSize="30" FontStyle="Italic" VerticalAlignment="Center" Margin="50 10 10 0" Foreground="Silver" FontWeight="Bold">MACHINE DESIGNER</TextBlock> <StackPanel Orientation="Horizontal" Margin="20 10 0 0" VerticalAlignment="Center"> <fa:ImageAwesome Icon="Key" Width="24" Height="24" Foreground="Silver"></fa:ImageAwesome> - <autoComplete:AutoCompleteTextBox FontSize="16" Width="300" Margin="5 0 0 0" materialDesign:HintAssist.Hint="Enter serial number" DisplayMember="SerialNumber" Provider="{StaticResource ResourceKey=MachinesProvider}" SelectedItem="{Binding SelectedMachine,Mode=TwoWay}"> + <autoComplete:AutoCompleteTextBox FontSize="16" FontWeight="Bold" FontStyle="Italic" Width="300" Margin="5 0 0 0" materialDesign:HintAssist.Hint="Enter serial number" DisplayMember="SerialNumber" Provider="{StaticResource ResourceKey=MachinesProvider}" SelectedItem="{Binding SelectedMachine,Mode=TwoWay}"> <autoComplete:AutoCompleteTextBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding SerialNumber}"></TextBlock> |
