PowerToys/src/modules/powerrename/PowerRenameUILib/ExplorerItem.xaml
Stefan Markovic 13db8575e0
[PowerRename] Show UI info if item cannot be renamed (#19934)
* PowerRename cleanup

* Extract ExplorerItem as a UserControl

* Add VisualStateManager

* UI fixes

* Implement error UI logic

Highlight items that couldn't be renamed and add error message flyout

* Update src/modules/powerrename/lib/PowerRenameManager.cpp

Address PR comment

Co-authored-by: Jay <65828559+Jay-o-Way@users.noreply.github.com>

* Update src/modules/powerrename/lib/PowerRenameManager.cpp

Address PR comment

Co-authored-by: Jay <65828559+Jay-o-Way@users.noreply.github.com>

* Folder max path is 247

* Implement State() properly

Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Jay <65828559+Jay-o-Way@users.noreply.github.com>
2022-08-24 10:47:27 +02:00

124 lines
4.9 KiB
XML

<UserControl
x:Class="PowerRenameUI.ExplorerItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:PowerRenameUI"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Height="28" Padding="0,0,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="4" />
<!-- Some spacing in between -->
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<!-- Error tooltip -->
</Grid.ColumnDefinitions>
<Border
Name="HighlightBorder"
Grid.ColumnSpan="4"
Margin="0,0,0,-1"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="Transparent" />
<Grid
Grid.Column="0"
Margin="10,4,0,4"
HorizontalAlignment="Left">
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="{x:Bind Indentation}" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<CheckBox
Name="{x:Bind IdStr}"
Grid.Column="1"
Width="28"
Height="28"
MinWidth="0"
AutomationProperties.HelpText="{x:Bind Renamed}"
AutomationProperties.Name="{x:Bind Original}"
Content=""
IsChecked="{x:Bind Checked, Mode=TwoWay}"
IsTabStop="True"
TabIndex="0"
XYFocusKeyboardNavigation="Enabled" />
<Image
Grid.Column="2"
Width="16"
Margin="4,0,0,0"
HorizontalAlignment="Left"
Source="{x:Bind ImagePath}" />
<TextBlock
Grid.Column="3"
Margin="6,0,4,0"
VerticalAlignment="Center"
FontSize="12"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Text="{x:Bind Original, Mode=OneWay}"
TextTrimming="CharacterEllipsis" />
</Grid>
<TextBlock
Grid.Column="2"
Margin="0,0,4,0"
VerticalAlignment="Center"
FontSize="12"
FontWeight="SemiBold"
Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
Text="{x:Bind Renamed, Mode=OneWay}"
TextTrimming="CharacterEllipsis" />
<Border
x:Name="ErrorIcon"
Grid.Column="3"
Width="12"
Height="12"
CornerRadius="12"
Margin="4,0,8,0"
Background="{ThemeResource SystemFillColorCriticalBrush}"
Visibility="Collapsed">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="{ThemeResource SymbolThemeFontFamily}"
Foreground="White"
FontSize="8"
Text="&#xE10A;" />
<ToolTipService.ToolTip>
<TextBlock
x:Name="ErrorMessageTxt"
Text="Error message goes here"
TextWrapping="Wrap" />
</ToolTipService.ToolTip>
</Border>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Highlight">
<VisualState.Setters>
<Setter Target="HighlightBorder.Opacity" Value="0.1" />
<Setter Target="HighlightBorder.BorderBrush" Value="{ThemeResource AccentTextFillColorPrimaryBrush}" />
<Setter Target="HighlightBorder.Background" Value="{ThemeResource AccentTextFillColorPrimaryBrush}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Error">
<VisualState.Setters>
<Setter Target="HighlightBorder.Opacity" Value="1" />
<Setter Target="HighlightBorder.BorderBrush" Value="{ThemeResource SystemFillColorCriticalBackgroundBrush}" />
<Setter Target="HighlightBorder.Background" Value="{ThemeResource SystemFillColorCriticalBackgroundBrush}" />
<Setter Target="ErrorIcon.Visibility" Value="Visible" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</UserControl>