mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
206 lines
12 KiB
XML
206 lines
12 KiB
XML
<ListBox
|
|
x:Class="Flow.Launcher.ResultListBox"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:converter="clr-namespace:Flow.Launcher.Converters"
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
xmlns:vm="clr-namespace:Flow.Launcher.ViewModel"
|
|
MaxHeight="{Binding MaxHeight}"
|
|
Margin="{Binding Margin}"
|
|
HorizontalContentAlignment="Stretch"
|
|
d:DataContext="{d:DesignInstance vm:ResultsViewModel}"
|
|
d:DesignHeight="100"
|
|
d:DesignWidth="100"
|
|
Focusable="False"
|
|
IsSynchronizedWithCurrentItem="True"
|
|
ItemsSource="{Binding Results}"
|
|
KeyboardNavigation.DirectionalNavigation="Cycle"
|
|
PreviewMouseDown="ListBox_PreviewMouseDown"
|
|
SelectedIndex="{Binding SelectedIndex, Mode=TwoWay}"
|
|
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
|
|
SelectionChanged="OnSelectionChanged"
|
|
SelectionMode="Single"
|
|
Style="{DynamicResource BaseListboxStyle}"
|
|
VirtualizingStackPanel.IsVirtualizing="True"
|
|
VirtualizingStackPanel.VirtualizationMode="Standard"
|
|
Visibility="{Binding Visbility}"
|
|
mc:Ignorable="d">
|
|
<!-- IsSynchronizedWithCurrentItem: http://stackoverflow.com/a/7833798/2833083 -->
|
|
|
|
<ListBox.ItemTemplate>
|
|
<DataTemplate>
|
|
<Button HorizontalAlignment="Stretch">
|
|
<Button.Template>
|
|
<ControlTemplate>
|
|
<ContentPresenter Content="{TemplateBinding Button.Content}" />
|
|
</ControlTemplate>
|
|
</Button.Template>
|
|
<Button.Content>
|
|
<Grid
|
|
Margin="0"
|
|
HorizontalAlignment="Stretch"
|
|
VerticalAlignment="Stretch"
|
|
Cursor="Hand"
|
|
UseLayoutRounding="False">
|
|
<Grid.Resources>
|
|
<converter:HighlightTextConverter x:Key="HighlightTextConverter" />
|
|
<converter:OrdinalConverter x:Key="OrdinalConverter" />
|
|
<converter:OpenResultHotkeyVisibilityConverter x:Key="OpenResultHotkeyVisibilityConverter" />
|
|
</Grid.Resources>
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="60" />
|
|
<ColumnDefinition Width="9*" />
|
|
<ColumnDefinition Width="Auto" />
|
|
</Grid.ColumnDefinitions>
|
|
<StackPanel
|
|
Grid.Column="2"
|
|
Margin="0,0,10,0"
|
|
Visibility="{Binding ShowOpenResultHotkey}">
|
|
<TextBlock
|
|
x:Name="Hotkey"
|
|
Margin="12,0,12,0"
|
|
Padding="0,10,0,10"
|
|
HorizontalAlignment="Right"
|
|
VerticalAlignment="Center"
|
|
Opacity="0.8"
|
|
Style="{DynamicResource ItemHotkeyStyle}">
|
|
<TextBlock.Visibility>
|
|
<Binding Converter="{StaticResource ResourceKey=OpenResultHotkeyVisibilityConverter}" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}" />
|
|
</TextBlock.Visibility>
|
|
<TextBlock.Text>
|
|
<MultiBinding StringFormat="{}{0}+{1}">
|
|
<Binding Path="OpenResultModifiers" />
|
|
<Binding Converter="{StaticResource ResourceKey=OrdinalConverter}" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}" />
|
|
</MultiBinding>
|
|
</TextBlock.Text>
|
|
</TextBlock>
|
|
</StackPanel>
|
|
<Border
|
|
Margin="9,0,0,0"
|
|
BorderBrush="Transparent"
|
|
BorderThickness="0">
|
|
<Image
|
|
x:Name="ImageIcon"
|
|
Width="{Binding IconXY}"
|
|
Height="{Binding IconXY}"
|
|
Margin="0,0,0,0"
|
|
HorizontalAlignment="Center"
|
|
Source="{Binding Image, TargetNullValue={x:Null}}"
|
|
Stretch="Uniform"
|
|
Visibility="{Binding ShowIcon}">
|
|
<Image.Clip>
|
|
<EllipseGeometry RadiusX="{Binding IconRadius}" RadiusY="{Binding IconRadius}" Center="16 16"/>
|
|
</Image.Clip>
|
|
</Image>
|
|
</Border>
|
|
<Border
|
|
Margin="9,0,0,0"
|
|
BorderBrush="Transparent"
|
|
BorderThickness="0">
|
|
<TextBlock
|
|
Grid.Column="0"
|
|
HorizontalAlignment="Center"
|
|
VerticalAlignment="Center"
|
|
FontFamily="{Binding Glyph.FontFamily}"
|
|
Style="{DynamicResource ItemGlyph}"
|
|
Text="{Binding Glyph.Glyph}"
|
|
Visibility="{Binding ShowGlyph}" />
|
|
</Border>
|
|
<Grid
|
|
Grid.Column="1"
|
|
Margin="6,0,10,0"
|
|
HorizontalAlignment="Stretch">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition />
|
|
<RowDefinition x:Name="SubTitleRowDefinition" Height="Auto" />
|
|
</Grid.RowDefinitions>
|
|
<ProgressBar
|
|
x:Name="progressbarResult"
|
|
Foreground="{Binding Result.ProgressBarColor}"
|
|
Value="{Binding ResultProgress, Mode=OneWay}">
|
|
<ProgressBar.Style>
|
|
<Style TargetType="ProgressBar" BasedOn="{StaticResource ProgressBarResult}">
|
|
<Setter Property="Visibility" Value="Visible"/>
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding Result.ProgressBar}" Value="{x:Null}">
|
|
<Setter Property="Visibility" Value="Collapsed"/>
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</ProgressBar.Style>
|
|
</ProgressBar>
|
|
<TextBlock
|
|
x:Name="Title"
|
|
VerticalAlignment="Center"
|
|
DockPanel.Dock="Left"
|
|
Style="{DynamicResource ItemTitleStyle}"
|
|
Text="{Binding Result.Title}"
|
|
ToolTip="{Binding ShowTitleToolTip}">
|
|
<vm:ResultsViewModel.FormattedText>
|
|
<MultiBinding Converter="{StaticResource HighlightTextConverter}">
|
|
<Binding Path="Result.Title" />
|
|
<Binding Path="Result.TitleHighlightData" />
|
|
</MultiBinding>
|
|
</vm:ResultsViewModel.FormattedText>
|
|
</TextBlock>
|
|
<TextBlock
|
|
x:Name="SubTitle"
|
|
Grid.Row="1"
|
|
Style="{DynamicResource ItemSubTitleStyle}"
|
|
Text="{Binding Result.SubTitle}"
|
|
ToolTip="{Binding ShowSubTitleToolTip}" />
|
|
|
|
</Grid>
|
|
|
|
</Grid>
|
|
</Button.Content>
|
|
</Button>
|
|
<!-- a result item height is 52 including margin -->
|
|
<DataTemplate.Triggers>
|
|
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="True">
|
|
<Setter TargetName="Title" Property="Style" Value="{DynamicResource ItemTitleSelectedStyle}" />
|
|
<Setter TargetName="SubTitle" Property="Style" Value="{DynamicResource ItemSubTitleSelectedStyle}" />
|
|
<Setter TargetName="Hotkey" Property="Style" Value="{DynamicResource ItemHotkeySelectedStyle}" />
|
|
<Setter TargetName="ImageIcon" Property="Style" Value="{DynamicResource ItemImageSelectedStyle}" />
|
|
</DataTrigger>
|
|
</DataTemplate.Triggers>
|
|
</DataTemplate>
|
|
</ListBox.ItemTemplate>
|
|
<!-- http://stackoverflow.com/questions/16819577/setting-background-color-or-wpf-4-0-listbox-windows-8/#16820062 -->
|
|
<ListBox.ItemContainerStyle>
|
|
<Style TargetType="{x:Type ListBoxItem}">
|
|
<EventSetter Event="MouseEnter" Handler="OnMouseEnter" />
|
|
<EventSetter Event="MouseMove" Handler="OnMouseMove" />
|
|
<Setter Property="Height" Value="52" />
|
|
<Setter Property="Margin" Value="0" />
|
|
<Setter Property="Padding" Value="0" />
|
|
<Setter Property="BorderThickness" Value="0" />
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate TargetType="{x:Type ListBoxItem}">
|
|
<Border
|
|
x:Name="Bd"
|
|
Background="{TemplateBinding Background}"
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
SnapsToDevicePixels="True">
|
|
<ContentPresenter
|
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
|
Content="{TemplateBinding Content}"
|
|
ContentStringFormat="{TemplateBinding ContentStringFormat}"
|
|
ContentTemplate="{TemplateBinding ContentTemplate}"
|
|
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
|
</Border>
|
|
<ControlTemplate.Triggers>
|
|
<Trigger Property="IsSelected" Value="True">
|
|
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource ItemSelectedBackgroundColor}" />
|
|
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource ItemSelectedBackgroundColor}" />
|
|
</Trigger>
|
|
</ControlTemplate.Triggers>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
</ListBox.ItemContainerStyle>
|
|
</ListBox>
|