diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics')
5 files changed, 81 insertions, 91 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/HeadCleaningConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/HeadCleaningConverter.cs deleted file mode 100644 index 478a1deba..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Converters/HeadCleaningConverter.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Data; - -namespace Tango.MachineStudio.Statistics.Converters -{ - public class HeadCleaningConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - return (bool)value ? "Only" : "Exclude"; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Tango.MachineStudio.Statistics.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Tango.MachineStudio.Statistics.csproj index 23b7c594c..4ce0ea87d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Tango.MachineStudio.Statistics.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Tango.MachineStudio.Statistics.csproj @@ -78,7 +78,6 @@ <ItemGroup> <Compile Include="Converters\CollectionConverter .cs" /> <Compile Include="Converters\DateTimeToStringFormatConverter.cs" /> - <Compile Include="Converters\HeadCleaningConverter.cs" /> <Compile Include="Converters\JobLengthConverter.cs" /> <Compile Include="Converters\LiquidQuantityToFormatStringConverter.cs" /> <Compile Include="Converters\LiquidTypeToColorConverter.cs" /> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs index 0ecb12ba7..ae1592d8d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs @@ -23,9 +23,21 @@ using Tango.BL.ValueObjects; using System.Diagnostics; using Microsoft.Win32; using Tango.CSV; +using System.ComponentModel; namespace Tango.MachineStudio.Statistics.ViewModels { + public enum HeadCleaningSelectionEnum + { + [Description("Exclude")] + Exclude = 0, + [Description("Include")] + Include = 1, + [Description("Only")] + Only = 2 + }; + + public class JobRunsViewVM : ViewModel { private INotificationProvider _notification; @@ -33,6 +45,8 @@ namespace Tango.MachineStudio.Statistics.ViewModels private List<User> _allUsers; private List<RmlModel> _rmlsModels; + + #region Properties private ObservableCollection<JobRunModel> _jobRuns; @@ -175,14 +189,14 @@ namespace Tango.MachineStudio.Statistics.ViewModels } } - private SelectedObjectCollection<bool> _isHeadCleaningSelection; + private HeadCleaningSelectionEnum _headCleaningSelected; - public SelectedObjectCollection<bool> IsHeadCleaningSelection + public HeadCleaningSelectionEnum HeadCleaningSelected { - get { return _isHeadCleaningSelection; } + get { return _headCleaningSelected; } set { - _isHeadCleaningSelection = value; + _headCleaningSelected = value; RaisePropertyChangedAuto(); } } @@ -270,17 +284,8 @@ namespace Tango.MachineStudio.Statistics.ViewModels IsGradientSelection.SelectionChanged -= (x, y) => RaisePropertyChanged(nameof(IsGradientSelection)); IsGradientSelection.SelectionChanged += (x, y) => RaisePropertyChanged(nameof(IsGradientSelection)); - IsHeadCleaningSelection = new SelectedObjectCollection<bool>(new ObservableCollection<bool>() - { - true, - false - }, new ObservableCollection<bool>() - { - true, - false - }); - IsHeadCleaningSelection.SelectionChanged -= (x, y) => RaisePropertyChanged(nameof(IsHeadCleaningSelection)); - IsHeadCleaningSelection.SelectionChanged += (x, y) => RaisePropertyChanged(nameof(IsHeadCleaningSelection)); + HeadCleaningSelected = HeadCleaningSelectionEnum.Exclude; + JobsProvider = new SuggestionProvider((filter) => { try @@ -336,8 +341,9 @@ namespace Tango.MachineStudio.Statistics.ViewModels IsFree = true; } } + } - + /// <summary> /// Loads the job runs by filters. /// </summary> @@ -407,10 +413,11 @@ namespace Tango.MachineStudio.Statistics.ViewModels { db_JobRuns = db_JobRuns.Where(x => isGradientArr.Contains(x.IsGradient)); } - bool[] isHeadCleaningArr = IsHeadCleaningSelection.SynchedSource.Select(x => (bool)x).ToArray(); - if(isHeadCleaningArr.Length > 0) + + if(HeadCleaningSelected != HeadCleaningSelectionEnum.Include) { - db_JobRuns = db_JobRuns.Where(x => isHeadCleaningArr.Contains(x.IsHeadCleaning)); + bool isHeadCleaning = HeadCleaningSelected == HeadCleaningSelectionEnum.Only; + db_JobRuns = db_JobRuns.Where(x => isHeadCleaning == x.IsHeadCleaning); } List<String> rmlGuids = SelectedThreads.SynchedSource.Select(y => y.Guid).ToList(); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml index 9e4a9603e..8724fcc2b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml @@ -13,8 +13,10 @@ xmlns:tooltips="clr-namespace:Tango.MachineStudio.Statistics.Tooltips" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:enumerations="clr-namespace:Tango.BL.Enumerations;assembly=Tango.BL" + xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:local="clr-namespace:Tango.MachineStudio.Statistics.Views" xmlns:model="clr-namespace:Tango.MachineStudio.Statistics.Models" + xmlns:vs="clr-namespace:Tango.MachineStudio.Statistics.ViewModels" xmlns:wellknowntypes="clr-namespace:Google.Protobuf.WellKnownTypes;assembly=Google.Protobuf" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="1800" Foreground="{StaticResource JobFieldForeground}"> @@ -33,7 +35,6 @@ <localConverters:NanoLiterToLiterFormatConverter x:Key="NanoLiterToLiterFormatConverter"/> <localConverters:LiquidQuantityToFormatStringConverter x:Key="LiquidQuantityToFormatStringConverter"/> <localConverters:TooltipLiquidQuantityFormatConverter x:Key="TooltipLiquidQuantityFormatConverter"/> - <localConverters:HeadCleaningConverter x:Key="HeadCleaningConverter"/> <ResourceDictionary x:Key="SelectAllTextBoxResource"> <Style TargetType="TextBox"> @@ -42,6 +43,12 @@ </Style> </ResourceDictionary> + <ObjectDataProvider x:Key="HeadCleaning" MethodName="GetValues" ObjectType="{x:Type sys:Enum}"> + <ObjectDataProvider.MethodParameters> + <x:Type TypeName="vs:HeadCleaningSelectionEnum"/> + </ObjectDataProvider.MethodParameters> + </ObjectDataProvider> + <Style TargetType="{x:Type TextBlock}" x:Key="WrapText"> <Setter Property="TextWrapping" Value="Wrap"/> </Style> @@ -55,7 +62,7 @@ <Setter Property="Background" Value="Transparent"/> <Setter Property="LegendLocation" Value="None"/> </Style> - + <DataTemplate x:Key="PopUpDataTemplate"> <CheckBox VerticalAlignment="Center" FontSize="11" DockPanel.Dock="Left" IsChecked="{Binding IsSelected}"> <CheckBox.Content> @@ -64,14 +71,6 @@ </CheckBox> </DataTemplate> - <DataTemplate x:Key="PopUpSNDataTemplate"> - <CheckBox VerticalAlignment="Center" FontSize="11" DockPanel.Dock="Left" IsChecked="{Binding IsSelected}" > - <CheckBox.Content> - <TextBlock Margin="5 0 0 0" VerticalAlignment="Center" Text="{Binding Data.SerialNumber}" ToolTip="{Binding Data.SerialNumber}" FontFamily="{StaticResource FontName}"></TextBlock> - </CheckBox.Content> - </CheckBox> - </DataTemplate> - <DataTemplate x:Key="PopupBoolDataTemplate"> <CheckBox VerticalAlignment="Center" FontSize="11" DockPanel.Dock="Left" IsChecked="{Binding IsSelected}"> <CheckBox.Content> @@ -80,22 +79,6 @@ </CheckBox> </DataTemplate> - <DataTemplate x:Key="PopupThreadDataTemplate"> - <CheckBox VerticalAlignment="Center" FontSize="11" DockPanel.Dock="Left" IsChecked="{Binding IsSelected}" > - <CheckBox.Content> - <TextBlock Margin="5 0 5 0" VerticalAlignment="Center" Text="{Binding Data.Name}" ToolTip="{Binding Data.Name}" FontFamily="{StaticResource FontName}" FontSize="11"></TextBlock> - </CheckBox.Content> - </CheckBox> - </DataTemplate> - - <DataTemplate x:Key="PopupIsHeadHeatingDataTemplate"> - <CheckBox VerticalAlignment="Center" FontSize="11" DockPanel.Dock="Left" IsChecked="{Binding IsSelected}"> - <CheckBox.Content> - <TextBlock Margin="5 0 0 0" VerticalAlignment="Center" Text="{Binding Data, Converter={StaticResource HeadCleaningConverter}}"/> - </CheckBox.Content> - </CheckBox> - </DataTemplate> - <Style x:Key="{x:Type ToolTip}" TargetType="{x:Type ToolTip}" BasedOn="{StaticResource MaterialDesignToolTip}"> <Setter Property="Background" Value="{StaticResource Logging.Background}" /> @@ -158,13 +141,18 @@ </DockPanel> </Border> <Popup AllowsTransparency="True" StaysOpen="False" IsOpen="{Binding RelativeSource={RelativeSource AncestorType=ToggleButton},Path=IsChecked }"> - <Border Padding="3" CornerRadius="0 0 3 3" MinWidth="{Binding RelativeSource={RelativeSource AncestorType=ToggleButton},Path=Width}" Margin="5" Background="{StaticResource TransparentBackgroundBrush200}" BorderBrush="{StaticResource AutoCompleteTextBox.Popup.BorderBrush}" > + <Border Padding="3" CornerRadius="0 0 3 3" MinWidth="{Binding RelativeSource={RelativeSource AncestorType=ToggleButton},Path=Width}" Margin="5" BorderBrush="{StaticResource AutoCompleteTextBox.Popup.BorderBrush}" > <Border.Effect> <DropShadowEffect Opacity="0.2" /> </Border.Effect> - <ScrollViewer MaxHeight="600" Background="{StaticResource TransparentBackgroundBrush}" > - <ItemsControl ItemsSource="{Binding SelectedMachines}" Foreground="{StaticResource MainWindow.Foreground}" ItemTemplate="{StaticResource PopUpSNDataTemplate}"/> - </ScrollViewer> + <controls:AllSelectedCheckboxList Style="{StaticResource AllSelectedCheckBoxListStyle}" MaxHeight="600" ItemsSource="{Binding SelectedMachines}" Background="{StaticResource ComboBox.Floating.Background}" Foreground="{StaticResource MainWindow.Foreground}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" SelectionMode="Multiple" AllSelected="True" > + <controls:AllSelectedCheckboxList.ItemTemplate> + <DataTemplate > + <TextBlock Margin="5 0 0 0" VerticalAlignment="Center" Text="{Binding Data.SerialNumber}" ToolTip="{Binding Data.SerialNumber}" FontFamily="{StaticResource FontName}" Background="{DynamicResource TransparentBackgroundBrush}" FontSize="11"></TextBlock> + + </DataTemplate> + </controls:AllSelectedCheckboxList.ItemTemplate> + </controls:AllSelectedCheckboxList> </Border> </Popup> </Grid> @@ -342,10 +330,13 @@ <Border.Effect> <DropShadowEffect Opacity="0.2" /> </Border.Effect> - <ScrollViewer MaxHeight="600" Background="{StaticResource TransparentBackgroundBrush200}"> - <ItemsControl ItemsSource="{Binding SelectedThreads}" Foreground="{StaticResource MainWindow.Foreground}" ItemTemplate="{StaticResource PopupThreadDataTemplate}"/> - - </ScrollViewer> + <controls:AllSelectedCheckboxList Style="{StaticResource AllSelectedCheckBoxListStyle}" MaxHeight="600" ItemsSource="{Binding SelectedThreads}" Background="{StaticResource ComboBox.Floating.Background}" Foreground="{StaticResource MainWindow.Foreground}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" SelectionMode="Multiple" AllSelected="True" FontSize="11"> + <controls:AllSelectedCheckboxList.ItemTemplate> + <DataTemplate > + <TextBlock Margin="5 0 0 0" VerticalAlignment="Center" Text="{Binding Data.Name}" ToolTip="{Binding Data.Name}" FontFamily="{StaticResource FontName}"></TextBlock> + </DataTemplate> + </controls:AllSelectedCheckboxList.ItemTemplate> + </controls:AllSelectedCheckboxList> </Border> </Popup> </Grid> @@ -364,18 +355,8 @@ <Button x:Name="IsHeadCleaningButton" Width="18" Padding="0" Height="16" DockPanel.Dock="Right" BorderBrush="{x:Null}" HorizontalAlignment="Left" Click="IsHeadCleaningButton_Click" Style="{StaticResource MaterialDesignFlatButton}" Foreground="{StaticResource MainWindow.Foreground}"> <materialDesign:PackIcon Width="16" Height="16" Kind="ChevronDown" VerticalAlignment="Center" Foreground="{StaticResource MainWindow.Foreground}" HorizontalAlignment="Right"/> </Button> - <TextBlock VerticalAlignment="Center" Foreground="{StaticResource MainWindow.Foreground}" FontSize="11" Margin="5 0 2 0"> - <TextBlock.Style> - <Style TargetType="{x:Type TextBlock}"> - <Setter Property="Text" Value="{Binding IsHeadCleaningSelection.SynchedSource, Converter={StaticResource CollectionConverter}, ConverterParameter='Exclude, Only'}"> - </Setter> - <Style.Triggers> - <DataTrigger Binding="{Binding IsHeadCleaningSelection.SynchedSource.Count}" Value="2"> - <Setter Property="Text" Value="Include"/> - </DataTrigger> - </Style.Triggers> - </Style> - </TextBlock.Style> + <TextBlock VerticalAlignment="Center" Foreground="{StaticResource MainWindow.Foreground}" FontSize="11" Margin="5 0 2 0" Text="{Binding HeadCleaningSelected, Converter={StaticResource EnumToDescriptionConverter}}"> + </TextBlock> </DockPanel> </Border> @@ -384,8 +365,17 @@ <Border.Effect> <DropShadowEffect Opacity="0.2" /> </Border.Effect> - <ItemsControl ItemsSource="{Binding IsHeadCleaningSelection}" Foreground="{StaticResource MainWindow.Foreground}" ItemTemplate="{StaticResource PopupIsHeadHeatingDataTemplate}"/> - + <ListBox x:Name="HeadCleaningListBoxItem" ItemsSource="{Binding Source={StaticResource HeadCleaning}}" Foreground="{StaticResource MainWindow.Foreground}" SelectedItem="{Binding HeadCleaningSelected, Mode=TwoWay}" SelectionMode="Single" > + <ListBox.ItemTemplate> + <DataTemplate> + <CheckBox x:Name="HeadCleaningCheckBox" Selector.IsSelected="True" VerticalAlignment="Center" FontSize="11" DockPanel.Dock="Left" IsChecked="{Binding IsSelected, Mode=TwoWay, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}, UpdateSourceTrigger=PropertyChanged}" Click="CheckBox_PreventUndoCheck"> + <CheckBox.Content> + <TextBlock Margin="5 0 0 0" VerticalAlignment="Center" Text="{Binding Converter={StaticResource EnumToDescriptionConverter}}"/> + </CheckBox.Content> + </CheckBox> + </DataTemplate> + </ListBox.ItemTemplate> + </ListBox> </Border> </Popup> </Grid> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml.cs index 9bfed23e3..226478a7d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/Views/JobRunsView.xaml.cs @@ -28,6 +28,8 @@ namespace Tango.MachineStudio.Statistics.Views InitializeComponent(); _lastSelectedGridItemIndex = -1; } + + private void Button_Click(object sender, RoutedEventArgs e) { selectMachineButton.IsChecked = true; @@ -127,5 +129,20 @@ namespace Tango.MachineStudio.Statistics.Views } } } + + private void CheckBox_PreventUndoCheck(object sender, RoutedEventArgs e) + { + if( sender is CheckBox) + { + CheckBox cb = sender as CheckBox; + if (cb.IsChecked == false) + { + cb.IsChecked = true; + e.Handled = true; + return; + } + } + e.Handled = false; + } } } |
