diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-01-07 12:53:01 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-01-07 12:53:01 +0200 |
| commit | 8d2dc68fdddc51bc24ac6f41feb97460a7d27372 (patch) | |
| tree | 32876416b128d93a47d5b0a228fc405aca0479e9 /Software/Visual_Studio/MachineStudio/Modules | |
| parent | 3d97a759dc712eca6750443b2367c8f755ebb11b (diff) | |
| download | Tango-8d2dc68fdddc51bc24ac6f41feb97460a7d27372.tar.gz Tango-8d2dc68fdddc51bc24ac6f41feb97460a7d27372.zip | |
Implemented validation on machine designer.
Machine Designer seems to be working properly...
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
5 files changed, 155 insertions, 30 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj index 96d7ddb8f..1a2564e0c 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Tango.MachineStudio.MachineDesigner.csproj @@ -55,6 +55,9 @@ <Reference Include="Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <HintPath>..\..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath> </Reference> + <Reference Include="SimpleValidator, Version=0.6.1.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\..\packages\SimpleValidator.0.6.1.0\lib\net40\SimpleValidator.dll</HintPath> + </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> 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 22e350745..be28f92b5 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 @@ -12,6 +12,7 @@ using Tango.Core.Helpers; using Tango.DAL.Observables; using Tango.MachineStudio.Common.Notifications; using Tango.SharedUI; +using SimpleValidator.Extensions; namespace Tango.MachineStudio.MachineDesigner.ViewModels { @@ -133,6 +134,11 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } } + public void DropIdsPack(IdsPack idsPack1, IdsPack idsPack2) + { + Configuration.IdsPacks.Swap(idsPack1, idsPack2); + } + private void OnHistoryConfigurationSelected() { if (SelectedHistoryConfiguration != null) @@ -240,7 +246,10 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels if (value != null) { - return value.ToLower().Contains(Filter.ToLower()); + if (value.ToLower().Contains(Filter.ToLower())) + { + return true; + } } } @@ -251,9 +260,115 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels private async void Save() { + //Validate + + List<String> errors = new List<string>(); + + if (Machine.MachineVersions == null) + { + errors.Add("Machine Version is required."); + } + + if (Machine.Name.IsNullOrWhiteSpace()) + { + errors.Add("Machine name is required."); + } + + if (Machine.Organization == null) + { + errors.Add("Machine organization is required."); + } + + if (Machine.SerialNumber.IsNullOrWhiteSpace()) + { + errors.Add("Machine serial number is required."); + } + + if (Configuration.Name.IsNullOrWhiteSpace()) + { + errors.Add("Configuration name is required."); + } + + if (Configuration.ApplicationDisplayPanelVersions == null) + { + errors.Add("Touch Panel is required."); + } + + if (Configuration.ApplicationFirmwareVersions == null) + { + errors.Add("Application Firmware is required."); + } + + if (Configuration.ApplicationOsVersions == null) + { + errors.Add("Application OS Version is required."); + } + + if (Configuration.ApplicationVersions == null) + { + errors.Add("Application Version is required."); + } + + if (Configuration.EmbeddedFirmwareVersions == null) + { + errors.Add("Embedded Firmware is required."); + } + + if (Configuration.EmbeddedSoftwareVersions == null) + { + errors.Add("Embedded Software is required."); + } + + if (Configuration.HardwareVersions == null) + { + errors.Add("Hardware Version is required."); + } + + foreach (var pack in Configuration.IdsPacks) + { + if (pack.Name.IsNullOrWhiteSpace()) + { + 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)); + } + if (pack.Dispenser == null) + { + 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)); + } + if (pack.MidTankTypes == null) + { + errors.Add(String.Format("Mid Tank type is required on IDS pack {0}.", pack.Name)); + } + } + + if (errors.Count > 0) + { + String errorsString = "Please fix the following validation errors before trying to save." + Environment.NewLine + Environment.NewLine; + errorsString += String.Join(Environment.NewLine, errors); + _notification.ShowError(errorsString); + return; + } + + //Validate + _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...")) @@ -282,12 +397,6 @@ namespace Tango.MachineStudio.MachineDesigner.ViewModels } else { - foreach (var ids in Configuration.IdsPacks) - { - ids.Configuration = Configuration; - ids.ConfigurationGuid = Configuration.Guid; - } - var machine = Adapter.Machines.Single(x => x.SerialNumber.ToLower() == Machine.SerialNumber.ToLower()); //Set 'Real machine' parameters... 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 03a3e2636..68c772c0c 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 @@ -85,19 +85,21 @@ <Grid ClipToBounds="False"> <StackPanel> - <TextBlock FontSize="30" FontStyle="Italic" VerticalAlignment="Center" Margin="50 10 10 0" Foreground="Silver" FontWeight="Bold">MACHINE DESIGNER</TextBlock> - <StackPanel Orientation="Horizontal" Margin="280 10 0 0"> - <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.ItemTemplate> - <DataTemplate> - <TextBlock Text="{Binding SerialNumber}"></TextBlock> - </DataTemplate> - </autoComplete:AutoCompleteTextBox.ItemTemplate> - <autoComplete:AutoCompleteTextBox.LoadingContent> - <TextBlock Text="Loading..." Margin="5" FontSize="14" /> - </autoComplete:AutoCompleteTextBox.LoadingContent> - </autoComplete:AutoCompleteTextBox> + <StackPanel Orientation="Horizontal"> + <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.ItemTemplate> + <DataTemplate> + <TextBlock Text="{Binding SerialNumber}"></TextBlock> + </DataTemplate> + </autoComplete:AutoCompleteTextBox.ItemTemplate> + <autoComplete:AutoCompleteTextBox.LoadingContent> + <TextBlock Text="Loading..." Margin="5" FontSize="14" /> + </autoComplete:AutoCompleteTextBox.LoadingContent> + </autoComplete:AutoCompleteTextBox> + </StackPanel> </StackPanel> </StackPanel> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0 0 50 0"> @@ -321,8 +323,14 @@ <Rectangle Stroke="Gray" HorizontalAlignment="Left" StrokeThickness="1" StrokeDashArray="5" RenderTransformOrigin="0.5,0.5"/> </Grid> - <TextBlock Canvas.Top="420" Canvas.Left="340" FontStyle="Italic" Foreground="Gray">Mid Tanks</TextBlock> - <Grid Width="53" Height="44" Canvas.Top="441" Canvas.Left="362"> + <TextBlock Canvas.Top="395" Canvas.Left="331" FontStyle="Italic" Foreground="Gray">Mid Tanks</TextBlock> + <Grid Width="62" Height="29" Canvas.Top="418" Canvas.Left="357"> + <Rectangle Stroke="Gray" VerticalAlignment="Bottom" StrokeThickness="1" StrokeDashArray="5" RenderTransformOrigin="0.5,0.5"/> + <Rectangle Stroke="Gray" HorizontalAlignment="Left" StrokeThickness="1" StrokeDashArray="5" RenderTransformOrigin="0.5,0.5"/> + </Grid> + + <TextBlock Canvas.Top="469" Canvas.Left="304" FontStyle="Italic" Foreground="Gray">Cartridges</TextBlock> + <Grid Width="87" Height="10" Canvas.Top="487" Canvas.Left="332"> <Rectangle Stroke="Gray" VerticalAlignment="Bottom" StrokeThickness="1" StrokeDashArray="5" RenderTransformOrigin="0.5,0.5"/> <Rectangle Stroke="Gray" HorizontalAlignment="Left" StrokeThickness="1" StrokeDashArray="5" RenderTransformOrigin="0.5,0.5"/> </Grid> @@ -510,8 +518,8 @@ </ListBox> </Expander> <Border Height="1" HorizontalAlignment="Stretch" Background="{DynamicResource MaterialDesignDivider}" SnapsToDevicePixels="True" /> - <Expander HorizontalAlignment="Stretch" Header="Cartridges"> - <ListBox ItemsSource="{Binding Adapter.CartridgeTypesViewSource}" HorizontalContentAlignment="Stretch"> + <Expander HorizontalAlignment="Stretch" Header="Mid Tanks"> + <ListBox ItemsSource="{Binding Adapter.MidTankTypesViewSource}" HorizontalContentAlignment="Stretch"> <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}"> <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter> @@ -523,7 +531,7 @@ <DataTemplate> <Grid Background="Transparent" IsHitTestVisible="True" dragAndDrop:DragAndDropService.DraggableBorderBrush="{StaticResource AccentColorBrush}" dragAndDrop:DragAndDropService.Draggable="True" dragAndDrop:DragAndDropService.DraggingSurface="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DraggingSurface}"> <StackPanel Orientation="Horizontal" Margin="2 8"> - <Image IsHitTestVisible="False" Width="24" Height="24" Source="../Images/cartridge.png" Stretch="Fill" RenderOptions.BitmapScalingMode="Fant"></Image> + <Image IsHitTestVisible="False" Width="24" Height="24" Source="../Images/tank.png" Stretch="Fill" RenderOptions.BitmapScalingMode="Fant"></Image> <StackPanel Margin="5 0 0 0" IsHitTestVisible="False"> <TextBlock IsHitTestVisible="False" FontSize="10" Foreground="DimGray"><Run Text="{Binding Name}"></Run></TextBlock> </StackPanel> @@ -536,8 +544,8 @@ </ListBox> </Expander> <Border Height="1" HorizontalAlignment="Stretch" Background="{DynamicResource MaterialDesignDivider}" SnapsToDevicePixels="True" /> - <Expander HorizontalAlignment="Stretch" Header="Mid Tanks"> - <ListBox ItemsSource="{Binding Adapter.MidTankTypesViewSource}" HorizontalContentAlignment="Stretch"> + <Expander HorizontalAlignment="Stretch" Header="Cartridges"> + <ListBox ItemsSource="{Binding Adapter.CartridgeTypesViewSource}" HorizontalContentAlignment="Stretch"> <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}"> <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter> @@ -549,7 +557,7 @@ <DataTemplate> <Grid Background="Transparent" IsHitTestVisible="True" dragAndDrop:DragAndDropService.DraggableBorderBrush="{StaticResource AccentColorBrush}" dragAndDrop:DragAndDropService.Draggable="True" dragAndDrop:DragAndDropService.DraggingSurface="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DraggingSurface}"> <StackPanel Orientation="Horizontal" Margin="2 8"> - <Image IsHitTestVisible="False" Width="24" Height="24" Source="../Images/tank.png" Stretch="Fill" RenderOptions.BitmapScalingMode="Fant"></Image> + <Image IsHitTestVisible="False" Width="24" Height="24" Source="../Images/cartridge.png" Stretch="Fill" RenderOptions.BitmapScalingMode="Fant"></Image> <StackPanel Margin="5 0 0 0" IsHitTestVisible="False"> <TextBlock IsHitTestVisible="False" FontSize="10" Foreground="DimGray"><Run Text="{Binding Name}"></Run></TextBlock> </StackPanel> @@ -762,9 +770,9 @@ </ScrollViewer> <Grid Grid.Row="1" Margin="10"> - <Button Height="50" Command="{Binding SaveCommand}"> + <Button Height="50" Command="{Binding SaveCommand}" Margin="0 0 15 0"> <StackPanel Orientation="Horizontal"> - <materialDesign:PackIcon Width="24" Height="24" VerticalAlignment="Center" Kind="ContentSave"></materialDesign:PackIcon> + <materialDesign:PackIcon Width="24" Height="24" VerticalAlignment="Center" Kind="ContentSaveSettings"></materialDesign:PackIcon> <TextBlock FontSize="18" Margin="10 0 0 0" VerticalAlignment="Center">SAVE</TextBlock> </StackPanel> </Button> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs index 7c2a38401..f38c8f8d6 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs @@ -102,6 +102,10 @@ namespace Tango.MachineStudio.MachineDesigner.Views { _vm.DropMidTankType(e.Draggable.DataContext as MidTankType, e.Droppable.DataContext as IdsPack); } + else if (e.Draggable.DataContext is IdsPack) + { + _vm.DropIdsPack(e.Draggable.DataContext as IdsPack, e.Droppable.DataContext as IdsPack); + } } private void OnTabletDrop(object sender, DropEventArgs e) diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/packages.config index 42945b407..aada4ebd7 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/packages.config +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/packages.config @@ -6,4 +6,5 @@ <package id="MaterialDesignColors" version="1.1.2" targetFramework="net46" /> <package id="MaterialDesignThemes" version="2.3.1.953" targetFramework="net46" /> <package id="MvvmLightLibs" version="5.3.0.0" targetFramework="net46" /> + <package id="SimpleValidator" version="0.6.1.0" targetFramework="net46" /> </packages>
\ No newline at end of file |
