mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 03:07:56 +01:00
[PowerRename] Add row highlighting (#14746)
* Add Highlight property to ExplorerItem * Change property type * Initialize property * Update MainWindow.xaml * Update MainWindow.xaml * Update MainWindow.xaml * Updated brush Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
This commit is contained in:
@@ -13,6 +13,7 @@ namespace winrt::PowerRenameUILib::implementation
|
||||
m_id{ id }, m_idStr{ std::to_wstring(id) }, m_original{ original }, m_renamed{ renamed }, m_type{ type }, m_depth{ depth }, m_checked{ checked }
|
||||
{
|
||||
m_imagePath = (m_type == static_cast<UINT>(ExplorerItemType::Folder)) ? folderImagePath : fileImagePath;
|
||||
m_highlight = m_checked && !m_renamed.empty() ? Windows::UI::Xaml::Visibility::Visible : Windows::UI::Xaml::Visibility::Collapsed;
|
||||
}
|
||||
|
||||
int32_t ExplorerItem::Id()
|
||||
@@ -50,6 +51,13 @@ namespace winrt::PowerRenameUILib::implementation
|
||||
{
|
||||
m_renamed = value;
|
||||
m_propertyChanged(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"Renamed" });
|
||||
|
||||
auto visibility = m_checked && !m_renamed.empty() ? Windows::UI::Xaml::Visibility::Visible : Windows::UI::Xaml::Visibility::Collapsed;
|
||||
if (m_highlight != visibility)
|
||||
{
|
||||
m_highlight = visibility;
|
||||
m_propertyChanged(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"Highlight" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,9 +95,21 @@ namespace winrt::PowerRenameUILib::implementation
|
||||
{
|
||||
m_checked = value;
|
||||
m_propertyChanged(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"Checked" });
|
||||
|
||||
auto visibility = m_checked && !m_renamed.empty() ? Windows::UI::Xaml::Visibility::Visible : Windows::UI::Xaml::Visibility::Collapsed;
|
||||
if (m_highlight != visibility)
|
||||
{
|
||||
m_highlight = visibility;
|
||||
m_propertyChanged(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"Highlight" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
winrt::Windows::UI::Xaml::Visibility ExplorerItem::Highlight()
|
||||
{
|
||||
return m_highlight;
|
||||
}
|
||||
|
||||
winrt::event_token ExplorerItem::PropertyChanged(winrt::Windows::UI::Xaml::Data::PropertyChangedEventHandler const& handler)
|
||||
{
|
||||
return m_propertyChanged.add(handler);
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace winrt::PowerRenameUILib::implementation
|
||||
void Type(int32_t value);
|
||||
bool Checked();
|
||||
void Checked(bool value);
|
||||
winrt::Windows::UI::Xaml::Visibility Highlight();
|
||||
Windows::Foundation::Collections::IObservableVector<PowerRenameUILib::ExplorerItem> Children();
|
||||
void Children(Windows::Foundation::Collections::IObservableVector<PowerRenameUILib::ExplorerItem> const& value);
|
||||
winrt::event_token PropertyChanged(Windows::UI::Xaml::Data::PropertyChangedEventHandler const& handler);
|
||||
@@ -41,6 +42,7 @@ namespace winrt::PowerRenameUILib::implementation
|
||||
winrt::Windows::Foundation::Collections::IObservableVector<PowerRenameUILib::ExplorerItem> m_children;
|
||||
int32_t m_type;
|
||||
bool m_checked;
|
||||
winrt::Windows::UI::Xaml::Visibility m_highlight;
|
||||
winrt::event<Windows::UI::Xaml::Data::PropertyChangedEventHandler> m_propertyChanged;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12,5 +12,6 @@ namespace PowerRenameUILib
|
||||
String ImagePath { get; };
|
||||
Int32 Type;
|
||||
Boolean Checked;
|
||||
Windows.UI.Xaml.Visibility Highlight { get; };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
<ControlTemplate TargetType="ListViewItem">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<ContentPresenter />
|
||||
<Rectangle Height="1" Margin="0,4,0,0" Opacity="0.8" Grid.ColumnSpan="5" Fill="{ThemeResource CardStrokeColorDefaultBrush}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" />
|
||||
<Rectangle Height="1" Margin="0,0,0,0" Opacity="0.8" Grid.ColumnSpan="5" Fill="{ThemeResource CardStrokeColorDefaultBrush}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" />
|
||||
|
||||
</StackPanel>
|
||||
</ControlTemplate>
|
||||
@@ -87,33 +87,55 @@
|
||||
</ListView.ItemContainerStyle>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:Name="ExplorerItemTemplate" x:DataType="local:ExplorerItem">
|
||||
<Grid Height="20" Margin="10,4,0,0">
|
||||
<Grid Height="28" Padding="0,0,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Grid.Column="0">
|
||||
<StackPanel MinWidth="{x:Bind Indentation}"/>
|
||||
<CheckBox TabIndex="0"
|
||||
MinWidth="0"
|
||||
XYFocusKeyboardNavigation="Enabled"
|
||||
Checked="Checked_ids"
|
||||
IsTabStop="True"
|
||||
Unchecked="Checked_ids"
|
||||
Content=""
|
||||
Name="{x:Bind IdStr}"
|
||||
AutomationProperties.Name="{x:Bind Original}"
|
||||
AutomationProperties.HelpText="{x:Bind Renamed}"
|
||||
IsChecked="{x:Bind Checked, Mode=TwoWay}" />
|
||||
<Image Width="16" Margin="4,0,0,0" Source="{x:Bind ImagePath}" HorizontalAlignment="Left" />
|
||||
<TextBlock Margin="6,0,0,0"
|
||||
Text="{x:Bind Original, Mode=OneWay}"
|
||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="12" />
|
||||
</StackPanel>
|
||||
<TextBlock Text="{x:Bind Renamed, Mode=OneWay}" Grid.Column="1" FontWeight="Bold" VerticalAlignment="Center" FontSize="12" />
|
||||
<Border HorizontalAlignment="Stretch" Grid.ColumnSpan="2" BorderThickness="0,0,0,1" Margin="0,0,0,-1" BorderBrush="{ThemeResource SystemAccentColor}" VerticalAlignment="Stretch" Background="{ThemeResource AccentTextFillColorPrimaryBrush}" Opacity="0.1" Visibility="{x:Bind Highlight, Mode=OneWay}" />
|
||||
|
||||
<Grid Grid.Column="0" HorizontalAlignment="Left" Margin="10,4,0,4">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition MinWidth="{x:Bind Indentation}"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
|
||||
<CheckBox TabIndex="0"
|
||||
MinWidth="0"
|
||||
Width="28"
|
||||
Height="28"
|
||||
Grid.Column="1"
|
||||
XYFocusKeyboardNavigation="Enabled"
|
||||
Checked="Checked_ids"
|
||||
IsTabStop="True"
|
||||
Unchecked="Checked_ids"
|
||||
Content=""
|
||||
Name="{x:Bind IdStr}"
|
||||
AutomationProperties.Name="{x:Bind Original}"
|
||||
AutomationProperties.HelpText="{x:Bind Renamed}"
|
||||
IsChecked="{x:Bind Checked, Mode=TwoWay}" />
|
||||
<Image Width="16"
|
||||
Grid.Column="2"
|
||||
Margin="4,0,0,0"
|
||||
Source="{x:Bind ImagePath}"
|
||||
HorizontalAlignment="Left" />
|
||||
<TextBlock Margin="6,0,0,0"
|
||||
Grid.Column="3"
|
||||
Text="{x:Bind Original, Mode=OneWay}"
|
||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="12" />
|
||||
</Grid>
|
||||
<TextBlock Text="{x:Bind Renamed, Mode=OneWay}"
|
||||
Grid.Column="1"
|
||||
FontWeight="Bold"
|
||||
Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="12" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
|
||||
Reference in New Issue
Block a user