Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Added tooltips to Layout Picker #14852

Merged
merged 16 commits into from
Feb 27, 2024
32 changes: 32 additions & 0 deletions src/Files.App/Converters/EnumValueToEnumNameConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Microsoft.UI.Xaml.Data;

namespace Files.App.Converters
{
internal sealed class EnumValueToEnumNameConverter : IValueConverter
{
public string EnumTypeName { get; set; } = string.Empty;

public object Convert(object value, Type targetType, object parameter, string language)
{
var stringValue = value.ToString() ?? string.Empty;

return EnumTypeName switch
0x5bfa marked this conversation as resolved.
Show resolved Hide resolved
{
"DetailsViewSizeKind" => Enum.Parse<DetailsViewSizeKind>(stringValue).ToString(),
"ListViewSizeKind" => Enum.Parse<ListViewSizeKind>(stringValue).ToString(),
"TilesViewSizeKind" => Enum.Parse<TilesViewSizeKind>(stringValue).ToString(),
"GridViewSizeKind" => Enum.Parse<GridViewSizeKind>(stringValue).ToString(),
"ColumnsViewSizeKind" => Enum.Parse<ColumnsViewSizeKind>(stringValue).ToString(),
_ => string.Empty,
};
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}
18 changes: 14 additions & 4 deletions src/Files.App/UserControls/InnerNavigationToolbar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
<SolidColorBrush x:Key="CommandBarBorderBrushOpen" Color="Transparent" />

<converters:GenericEnumConverter x:Key="GenericEnumConverter" />
<converters:EnumValueToEnumNameConverter x:Key="EnumDetailsViewSizeKindToEnumNameConverter" EnumTypeName="DetailsViewSizeKind" />
<converters:EnumValueToEnumNameConverter x:Key="EnumListViewSizeKindToEnumNameConverter" EnumTypeName="ListViewSizeKind" />
<converters:EnumValueToEnumNameConverter x:Key="EnumTilesViewSizeKindToEnumNameConverter" EnumTypeName="TilesViewSizeKind" />
<converters:EnumValueToEnumNameConverter x:Key="EnumGridViewSizeKindToEnumNameConverter" EnumTypeName="GridViewSizeKind" />
<converters:EnumValueToEnumNameConverter x:Key="EnumColumnsViewSizeKindToEnumNameConverter" EnumTypeName="ColumnsViewSizeKind" />
<wctconverters:BoolNegationConverter x:Key="BoolNegationConverter" />
<wctconverters:BoolToVisibilityConverter
x:Key="NegatedBoolToVisibilityConverter"
Expand Down Expand Up @@ -770,6 +775,7 @@
<!-- Sizes -->
<TextBlock FontWeight="Medium" Text="{helpers:ResourceString Name=Size}" />
<Grid>

<!-- Details -->
<StackPanel
x:Name="DetailsView"
Expand All @@ -778,10 +784,11 @@
<Slider
x:Name="DetailsViewSlider"
Padding="4,0,4,0"
IsThumbToolTipEnabled="False"
IsThumbToolTipEnabled="True"
Maximum="5"
Minimum="1"
SnapsTo="Ticks"
ThumbToolTipValueConverter="{StaticResource EnumDetailsViewSizeKindToEnumNameConverter}"
TickFrequency="1"
TickPlacement="BottomRight"
Value="{x:Bind UserSettingsService.LayoutSettingsService.DetailsViewSize, Mode=TwoWay, Converter={StaticResource GenericEnumConverter}, ConverterParameter='1-1,2-2,3-3,4-4,5-5'}" />
Expand Down Expand Up @@ -844,10 +851,11 @@
<Slider
x:Name="ListViewSlider"
Padding="4,0,4,0"
IsThumbToolTipEnabled="False"
IsThumbToolTipEnabled="True"
Maximum="5"
Minimum="1"
SnapsTo="Ticks"
ThumbToolTipValueConverter="{StaticResource EnumListViewSizeKindToEnumNameConverter}"
TickFrequency="1"
TickPlacement="BottomRight"
Value="{x:Bind UserSettingsService.LayoutSettingsService.ListViewSize, Mode=TwoWay, Converter={StaticResource GenericEnumConverter}, ConverterParameter='1-1,2-2,3-3,4-4,5-5'}" />
Expand Down Expand Up @@ -927,10 +935,11 @@
<Slider
x:Name="GridViewSlider"
Padding="4,0,4,0"
IsThumbToolTipEnabled="False"
IsThumbToolTipEnabled="True"
Maximum="12"
Minimum="1"
SnapsTo="Ticks"
ThumbToolTipValueConverter="{StaticResource EnumGridViewSizeKindToEnumNameConverter}"
TickFrequency="1"
TickPlacement="BottomRight"
Value="{x:Bind UserSettingsService.LayoutSettingsService.GridViewSize, Mode=TwoWay, Converter={StaticResource GenericEnumConverter}, ConverterParameter='1-1,2-2,3-3,4-4,5-5,6-6,7-7,8-8,9-9,10-10,11-11,12-12'}" />
Expand Down Expand Up @@ -1000,10 +1009,11 @@
<Slider
x:Name="ColumnViewSlider"
Padding="4,0,4,0"
IsThumbToolTipEnabled="False"
IsThumbToolTipEnabled="True"
Maximum="5"
Minimum="1"
SnapsTo="Ticks"
ThumbToolTipValueConverter="{StaticResource EnumColumnsViewSizeKindToEnumNameConverter}"
TickFrequency="1"
TickPlacement="BottomRight"
Value="{x:Bind UserSettingsService.LayoutSettingsService.ColumnsViewSize, Mode=TwoWay, Converter={StaticResource GenericEnumConverter}, ConverterParameter='1-1,2-2,3-3,4-4,5-5'}" />
Expand Down
Loading