Skip to content

Commit

Permalink
(chocolateyGH-685) Create converters only once
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Mar 3, 2021
1 parent 09dd527 commit bfe614f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
3 changes: 3 additions & 0 deletions Source/ChocolateyGui.Common.Windows/Resources/Controls.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@

<converters:BooleanToVisibility x:Key="BooleanToVisibility" />
<converters:BooleanToVisibilityInverted x:Key="BooleanToVisibilityInverted" />
<converters:BooleanToVisibilityHidden x:Key="BooleanToVisibilityHidden" />
<converters:StringListToString x:Key="StringListToString" />
<converters:EnumToBoolConverter x:Key="EnumToBoolConverter" />
<converters:MultiBooleanAndToVisibility x:Key="MultiBooleanAndToVisibility" />
<converters:BooleanInverter x:Key="BooleanInverter" />

<Style BasedOn="{StaticResource MahApps.Styles.TabItem}" TargetType="TabItem">
Expand Down
24 changes: 9 additions & 15 deletions Source/ChocolateyGui.Common.Windows/Views/LocalSourceView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
xmlns:properties="clr-namespace:ChocolateyGui.Common.Properties;assembly=ChocolateyGui.Common"
xmlns:viewModels="clr-namespace:ChocolateyGui.Common.Windows.ViewModels;assembly=ChocolateyGui.Common.Windows"
xmlns:enums="clr-namespace:ChocolateyGui.Common.Enums;assembly=ChocolateyGui.Common"
xmlns:converters="clr-namespace:ChocolateyGui.Common.Windows.Utilities.Converters"
xmlns:utilities="clr-namespace:ChocolateyGui.Common.Windows.Utilities"
xmlns:commands="clr-namespace:ChocolateyGui.Common.Windows.Commands"
xmlns:controls="clr-namespace:ChocolateyGui.Common.Windows.Controls"
Expand All @@ -21,11 +20,6 @@
Background="{DynamicResource MahApps.Brushes.ThemeBackground}">

<UserControl.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVis" />
<converters:BooleanToVisibilityInverted x:Key="BoolToVisInverted" />
<converters:BooleanToVisibilityHidden x:Key="BoolToHidden" />
<converters:StringListToString x:Key="ListToString" />
<converters:EnumToBoolConverter x:Key="EnumToBoolConverter" />
<utilities:BindingProxy x:Key="BindingProxy" Data="{Binding}" />
<utilities:PackageAuthorsComparer x:Key="PackageAuthorsComparer" />

Expand Down Expand Up @@ -59,11 +53,11 @@
<iconPacks:PackIconEntypo Width="24" Height="24"
ToolTip="{x:Static properties:Resources.LocalSourceView_ToolTip_Pinned}"
Kind="Pin" Margin="0 2"
Visibility="{Binding IsPinned, Mode=OneWay, Converter={StaticResource BoolToVis}}" />
Visibility="{Binding IsPinned, Mode=OneWay, Converter={StaticResource BooleanToVisibility}}" />
<iconPacks:PackIconEntypo Width="24" Height="24"
ToolTip="{x:Static properties:Resources.LocalSourceView_ToolTip_InstalledSideBySide}"
Kind="Bookmarks" Margin="0 2"
Visibility="{Binding IsSideBySide, Mode=OneWay, Converter={StaticResource BoolToVis}}" />
Visibility="{Binding IsSideBySide, Mode=OneWay, Converter={StaticResource BooleanToVisibility}}" />
</StackPanel>

<TextBlock Grid.Row="2"
Expand Down Expand Up @@ -278,8 +272,8 @@
<DataGridTemplateColumn.CellTemplate>
<DataTemplate DataType="{x:Type items:IPackageViewModel}">
<StackPanel Orientation="Horizontal">
<iconPacks:PackIconEntypo ToolTip="{x:Static properties:Resources.LocalSourceView_ToolTip_Pinned}" Kind="Pin" Visibility="{Binding IsPinned, Converter={StaticResource BoolToHidden}}" />
<iconPacks:PackIconEntypo ToolTip="{x:Static properties:Resources.LocalSourceView_ToolTip_InstalledSideBySide}" Kind="Bookmarks" Visibility="{Binding IsSideBySide, Converter={StaticResource BoolToHidden}}" />
<iconPacks:PackIconEntypo ToolTip="{x:Static properties:Resources.LocalSourceView_ToolTip_Pinned}" Kind="Pin" Visibility="{Binding IsPinned, Converter={StaticResource BooleanToVisibilityHidden}}" />
<iconPacks:PackIconEntypo ToolTip="{x:Static properties:Resources.LocalSourceView_ToolTip_InstalledSideBySide}" Kind="Bookmarks" Visibility="{Binding IsSideBySide, Converter={StaticResource BooleanToVisibilityHidden}}" />
<TextBlock Text="{Binding Title}"/>
</StackPanel>
</DataTemplate>
Expand All @@ -288,14 +282,14 @@
<DataGridTextColumn Header="{x:Static properties:Resources.LocalSourceView_Grid_Id}"
Width="1*"
Binding="{Binding LowerCaseId}"
Visibility="{Binding Source={StaticResource BindingProxy}, Path=Data.ShowAdditionalPackageInformation, Converter={StaticResource BoolToVis}}"/>
Visibility="{Binding Source={StaticResource BindingProxy}, Path=Data.ShowAdditionalPackageInformation, Converter={StaticResource BooleanToVisibility}}"/>
<DataGridTextColumn Header="{x:Static properties:Resources.LocalSourceView_Grid_Authors}"
utilities:DataGridCustomSortBehavior.CustomComparer="{StaticResource PackageAuthorsComparer}"
Binding="{Binding Authors, Converter={StaticResource ListToString}}" Width="1*" />
Binding="{Binding Authors, Converter={StaticResource StringListToString}}" Width="1*" />
<DataGridTextColumn Header="{x:Static properties:Resources.LocalSourceView_Grid_Version}" Binding="{Binding Version}" Width="1*" />
<DataGridTemplateColumn Width="0.5*"
Header="{x:Static properties:Resources.LocalSourceView_Grid_Prerelease}"
Visibility="{Binding Source={StaticResource BindingProxy}, Path=Data.ShowAdditionalPackageInformation, Converter={StaticResource BoolToVis}}">
Visibility="{Binding Source={StaticResource BindingProxy}, Path=Data.ShowAdditionalPackageInformation, Converter={StaticResource BooleanToVisibility}}">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate DataType="{x:Type items:IPackageViewModel}">
<TextBlock Text="{x:Static properties:Resources.LocalSourceView_Grid_Prerelease}"
Expand All @@ -305,7 +299,7 @@
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
TextAlignment="Center"
Visibility="{Binding IsPrerelease, Converter={StaticResource BoolToVis}}"/>
Visibility="{Binding IsPrerelease, Converter={StaticResource BooleanToVisibility}}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Expand All @@ -315,7 +309,7 @@
<DataTemplate DataType="{x:Type items:IPackageViewModel}">
<Grid Background="{DynamicResource {x:Static theming:ChocolateyBrushes.OutOfDateKey}}"
TextElement.Foreground="{DynamicResource {x:Static theming:ChocolateyBrushes.OutOfDateForegroundKey}}"
Visibility="{Binding IsLatestVersion, Converter={StaticResource BoolToVisInverted}}"
Visibility="{Binding IsLatestVersion, Converter={StaticResource BooleanToVisibilityInverted}}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<Grid.ColumnDefinitions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
xmlns:properties="clr-namespace:ChocolateyGui.Common.Properties;assembly=ChocolateyGui.Common"
xmlns:viewModels="clr-namespace:ChocolateyGui.Common.Windows.ViewModels;assembly=ChocolateyGui.Common.Windows"
xmlns:enums="clr-namespace:ChocolateyGui.Common.Enums;assembly=ChocolateyGui.Common"
xmlns:converters="clr-namespace:ChocolateyGui.Common.Windows.Utilities.Converters"
xmlns:utilities="clr-namespace:ChocolateyGui.Common.Windows.Utilities"
xmlns:commands="clr-namespace:ChocolateyGui.Common.Windows.Commands"
xmlns:controls="clr-namespace:ChocolateyGui.Common.Windows.Controls"
xmlns:theming="clr-namespace:ChocolateyGui.Common.Windows.Theming"
Expand All @@ -21,10 +19,6 @@

<UserControl.Resources>
<ResourceDictionary>
<converters:MultiBooleanAndToVisibility x:Key="MultiBooleanAndToVisibility" />
<converters:EnumToBoolConverter x:Key="EnumToBoolConverter" />
<utilities:BindingProxy x:Key="BindingProxy" Data="{Binding}" />

<DataTemplate x:Key="PackageListTemplate" DataType="{x:Type items:IPackageViewModel}">
<Grid Height="115" Margin="5"
Background="Transparent"
Expand Down

0 comments on commit bfe614f

Please sign in to comment.