Change Window to Resizable

This commit is contained in:
DB p 2024-05-14 16:54:15 +09:00
parent 106760ca66
commit 2e3b61cec6
7 changed files with 473 additions and 305 deletions

View file

@ -54,6 +54,13 @@ namespace Flow.Launcher.Infrastructure.UserSettings
} }
} }
public bool UseDropShadowEffect { get; set; } = false; public bool UseDropShadowEffect { get; set; } = false;
/* Appearance Settings. It should be separated from the setting later.*/
public double WindowHeightSize { get; set; } = 40;
public double ItemHeightSize { get; set; } = 58;
public double QueryBoxFontSize { get; set; } = 18;
public double ResultItemFontSize { get; set; } = 16;
public double ResultSubItemFontSize { get; set; } = 13;
public string QueryBoxFont { get; set; } = FontFamily.GenericSansSerif.Name; public string QueryBoxFont { get; set; } = FontFamily.GenericSansSerif.Name;
public string QueryBoxFontStyle { get; set; } public string QueryBoxFontStyle { get; set; }
public string QueryBoxFontWeight { get; set; } public string QueryBoxFontWeight { get; set; }

View file

@ -7,12 +7,14 @@
xmlns:flowlauncher="clr-namespace:Flow.Launcher" xmlns:flowlauncher="clr-namespace:Flow.Launcher"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:svgc="http://sharpvectors.codeplex.com/svgc/" xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
xmlns:theme="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
xmlns:ui="http://schemas.modernwpf.com/2019" xmlns:ui="http://schemas.modernwpf.com/2019"
xmlns:vm="clr-namespace:Flow.Launcher.ViewModel" xmlns:vm="clr-namespace:Flow.Launcher.ViewModel"
Name="FlowMainWindow" Name="FlowMainWindow"
Title="Flow Launcher" Title="Flow Launcher"
MinWidth="{Binding MainWindowWidth, Mode=OneWay}" Width="{Binding MainWindowWidth, Mode=TwoWay}"
MaxWidth="{Binding MainWindowWidth, Mode=OneWay}" MinWidth="430"
MinHeight="30"
d:DataContext="{d:DesignInstance Type=vm:MainViewModel}" d:DataContext="{d:DesignInstance Type=vm:MainViewModel}"
AllowDrop="True" AllowDrop="True"
AllowsTransparency="True" AllowsTransparency="True"
@ -25,15 +27,19 @@
LocationChanged="OnLocationChanged" LocationChanged="OnLocationChanged"
Opacity="{Binding MainWindowOpacity, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" Opacity="{Binding MainWindowOpacity, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
PreviewKeyDown="OnKeyDown" PreviewKeyDown="OnKeyDown"
ResizeMode="NoResize" ResizeMode="CanResize"
ShowInTaskbar="False" ShowInTaskbar="False"
SizeChanged="OnSizeChanged"
SizeToContent="Height" SizeToContent="Height"
Style="{DynamicResource WindowStyle}"
Topmost="True" Topmost="True"
Visibility="{Binding MainWindowVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding MainWindowVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
WindowStartupLocation="Manual" WindowStartupLocation="Manual"
WindowStyle="None" WindowStyle="None"
mc:Ignorable="d"> mc:Ignorable="d">
<!-- WindowChrome -->
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="8" ResizeBorderThickness="0 4 32 32" />
</WindowChrome.WindowChrome>
<Window.Resources> <Window.Resources>
<converters:QuerySuggestionBoxConverter x:Key="QuerySuggestionBoxConverter" /> <converters:QuerySuggestionBoxConverter x:Key="QuerySuggestionBoxConverter" />
<converters:BorderClipConverter x:Key="BorderClipConverter" /> <converters:BorderClipConverter x:Key="BorderClipConverter" />
@ -198,311 +204,314 @@
Command="{Binding SelectPrevPageCommand}" Command="{Binding SelectPrevPageCommand}"
Modifiers="{Binding SelectPrevPageHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='modifiers'}" /> Modifiers="{Binding SelectPrevPageHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='modifiers'}" />
</Window.InputBindings> </Window.InputBindings>
<Grid>
<Border MouseDown="OnMouseDown" Style="{DynamicResource WindowBorderStyle}"> <Border MouseDown="OnMouseDown" Style="{DynamicResource WindowBorderStyle}">
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
<Grid> <Grid>
<Border Style="{DynamicResource QueryBoxBgStyle}"> <Border MinHeight="30" Style="{DynamicResource QueryBoxBgStyle}">
<Grid> <Grid>
<TextBox <TextBox
x:Name="QueryTextSuggestionBox" x:Name="QueryTextSuggestionBox"
IsEnabled="False" Height="{Binding MainWindowHeight, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Style="{DynamicResource QuerySuggestionBoxStyle}"> IsEnabled="False"
<TextBox.Text> Style="{DynamicResource QuerySuggestionBoxStyle}">
<MultiBinding Converter="{StaticResource QuerySuggestionBoxConverter}"> <TextBox.Text>
<Binding ElementName="QueryTextBox" Mode="OneTime" /> <MultiBinding Converter="{StaticResource QuerySuggestionBoxConverter}">
<Binding ElementName="ResultListBox" Path="SelectedItem" /> <Binding ElementName="QueryTextBox" Mode="OneTime" />
<Binding ElementName="QueryTextBox" Path="Text" /> <Binding ElementName="ResultListBox" Path="SelectedItem" />
</MultiBinding> <Binding ElementName="QueryTextBox" Path="Text" />
</TextBox.Text> </MultiBinding>
</TextBox> </TextBox.Text>
<TextBox </TextBox>
x:Name="QueryTextBox" <TextBox
AllowDrop="True" x:Name="QueryTextBox"
AutomationProperties.Name="{Binding Results.SelectedItem.Result.Title}" Height="{Binding MainWindowHeight, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
InputMethod.PreferredImeConversionMode="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEConversionModeConverter}}" AllowDrop="True"
InputMethod.PreferredImeState="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEStateConverter}}" AutomationProperties.Name="{Binding Results.SelectedItem.Result.Title}"
PreviewDragOver="OnPreviewDragOver" InputMethod.PreferredImeConversionMode="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEConversionModeConverter}}"
PreviewKeyUp="QueryTextBox_KeyUp" InputMethod.PreferredImeState="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEStateConverter}}"
Style="{DynamicResource QueryBoxStyle}" PreviewDragOver="OnPreviewDragOver"
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" PreviewKeyUp="QueryTextBox_KeyUp"
Visibility="Visible"> Style="{DynamicResource QueryBoxStyle}"
<TextBox.CommandBindings> Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
<CommandBinding Command="ApplicationCommands.Copy" Executed="OnCopy" /> Visibility="Visible"
</TextBox.CommandBindings> WindowChrome.IsHitTestVisibleInChrome="True">
<TextBox.ContextMenu> <TextBox.CommandBindings>
<ContextMenu MinWidth="160"> <CommandBinding Command="ApplicationCommands.Copy" Executed="OnCopy" />
<MenuItem Command="ApplicationCommands.Cut" Header="{DynamicResource cut}"> </TextBox.CommandBindings>
<MenuItem.Icon> <TextBox.ContextMenu>
<ui:FontIcon Glyph="&#xe8c6;" /> <ContextMenu MinWidth="160">
</MenuItem.Icon> <MenuItem Command="ApplicationCommands.Cut" Header="{DynamicResource cut}">
</MenuItem> <MenuItem.Icon>
<MenuItem Command="ApplicationCommands.Copy" Header="{DynamicResource copy}"> <ui:FontIcon Glyph="&#xe8c6;" />
<MenuItem.Icon> </MenuItem.Icon>
<ui:FontIcon Glyph="&#xe8c8;" /> </MenuItem>
</MenuItem.Icon> <MenuItem Command="ApplicationCommands.Copy" Header="{DynamicResource copy}">
</MenuItem> <MenuItem.Icon>
<MenuItem Command="ApplicationCommands.Paste" Header="{DynamicResource paste}"> <ui:FontIcon Glyph="&#xe8c8;" />
<MenuItem.Icon> </MenuItem.Icon>
<ui:FontIcon Glyph="&#xe77f;" /> </MenuItem>
</MenuItem.Icon> <MenuItem Command="ApplicationCommands.Paste" Header="{DynamicResource paste}">
</MenuItem> <MenuItem.Icon>
<Separator <ui:FontIcon Glyph="&#xe77f;" />
Margin="0" </MenuItem.Icon>
Padding="0,4,0,4" </MenuItem>
Background="{DynamicResource ContextSeparator}" /> <Separator
<MenuItem Click="OnContextMenusForSettingsClick" Header="{DynamicResource flowlauncher_settings}"> Margin="0"
<MenuItem.Icon> Padding="0,4,0,4"
<ui:FontIcon Glyph="&#xe713;" /> Background="{DynamicResource ContextSeparator}" />
</MenuItem.Icon> <MenuItem Click="OnContextMenusForSettingsClick" Header="{DynamicResource flowlauncher_settings}">
</MenuItem> <MenuItem.Icon>
<MenuItem Command="{Binding EscCommand}" Header="{DynamicResource closeWindow}"> <ui:FontIcon Glyph="&#xe713;" />
<MenuItem.Icon> </MenuItem.Icon>
<ui:FontIcon Glyph="&#xe711;" /> </MenuItem>
</MenuItem.Icon> <MenuItem Command="{Binding EscCommand}" Header="{DynamicResource closeWindow}">
</MenuItem> <MenuItem.Icon>
</ContextMenu> <ui:FontIcon Glyph="&#xe711;" />
</TextBox.ContextMenu> </MenuItem.Icon>
</TextBox> </MenuItem>
</Grid> </ContextMenu>
</TextBox.ContextMenu>
</TextBox>
</Grid>
</Border>
<StackPanel
x:Name="ClockPanel"
IsHitTestVisible="False"
Style="{DynamicResource ClockPanel}">
<TextBlock
x:Name="ClockBox"
Style="{DynamicResource ClockBox}"
Text="{Binding ClockText}"
Visibility="{Binding Settings.UseClock, Converter={StaticResource BoolToVisibilityConverter}}" />
<TextBlock
x:Name="DateBox"
Style="{DynamicResource DateBox}"
Text="{Binding DateText}"
Visibility="{Binding Settings.UseDate, Converter={StaticResource BoolToVisibilityConverter}}" />
</StackPanel>
<Border>
<Grid WindowChrome.IsHitTestVisibleInChrome="True">
<Image
x:Name="PluginActivationIcon"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Panel.ZIndex="2"
RenderOptions.BitmapScalingMode="HighQuality"
Source="{Binding PluginIconPath}"
Stretch="Uniform"
Style="{DynamicResource PluginActivationIcon}" />
<Canvas Style="{DynamicResource SearchIconPosition}">
<Path
Name="SearchIcon"
Margin="0"
Data="{DynamicResource SearchIconImg}"
Stretch="Fill"
Style="{DynamicResource SearchIconStyle}"
Visibility="{Binding SearchIconVisibility}" />
</Canvas>
</Grid>
</Border>
<Line
x:Name="ProgressBar"
Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}, Path=ActualWidth}"
Height="2"
Margin="12,0,12,0"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
StrokeThickness="2"
Style="{DynamicResource PendingLineStyle}"
Visibility="{Binding ProgressBarVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
X1="-100"
X2="0"
Y1="0"
Y2="0" />
</Grid>
<Grid ClipToBounds="True">
<ContentControl>
<ContentControl.Style>
<Style TargetType="ContentControl">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=ResultListBox, Path=Visibility}" Value="Visible">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=ContextMenu, Path=Visibility}" Value="Visible">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=History, Path=Visibility}" Value="Visible">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</ContentControl.Style>
<Rectangle
Name="MiddleSeparator"
Width="Auto"
HorizontalAlignment="Stretch"
Style="{DynamicResource SeparatorStyle}" />
</ContentControl>
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="100" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="0.85*" MinWidth="244" />
</Grid.ColumnDefinitions>
<StackPanel
x:Name="ResultArea"
Grid.Column="0"
Grid.ColumnSpan="{Binding ResultAreaColumn}">
<Border Style="{DynamicResource WindowRadius}">
<Border.Clip>
<MultiBinding Converter="{StaticResource BorderClipConverter}">
<Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}" />
<Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}" />
<Binding Path="CornerRadius" RelativeSource="{RelativeSource Self}" />
</MultiBinding>
</Border.Clip>
<ContentControl>
<flowlauncher:ResultListBox
x:Name="ResultListBox"
DataContext="{Binding Results}"
LeftClickResultCommand="{Binding LeftClickResultCommand}"
RightClickResultCommand="{Binding RightClickResultCommand}" />
</ContentControl>
</Border> </Border>
<Border Style="{DynamicResource WindowRadius}">
<StackPanel <Border.Clip>
x:Name="ClockPanel" <MultiBinding Converter="{StaticResource BorderClipConverter}">
IsHitTestVisible="False" <Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}" />
Style="{DynamicResource ClockPanel}"> <Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}" />
<TextBlock <Binding Path="CornerRadius" RelativeSource="{RelativeSource Self}" />
x:Name="ClockBox" </MultiBinding>
Style="{DynamicResource ClockBox}" </Border.Clip>
Text="{Binding ClockText}" <ContentControl>
Visibility="{Binding Settings.UseClock, Converter={StaticResource BoolToVisibilityConverter}}" /> <flowlauncher:ResultListBox
<TextBlock x:Name="ContextMenu"
x:Name="DateBox" DataContext="{Binding ContextMenu}"
Style="{DynamicResource DateBox}" LeftClickResultCommand="{Binding LeftClickResultCommand}"
Text="{Binding DateText}" RightClickResultCommand="{Binding RightClickResultCommand}" />
Visibility="{Binding Settings.UseDate, Converter={StaticResource BoolToVisibilityConverter}}" /> </ContentControl>
</StackPanel>
<Border>
<Grid>
<Image
x:Name="PluginActivationIcon"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Panel.ZIndex="2"
RenderOptions.BitmapScalingMode="HighQuality"
Source="{Binding PluginIconPath}"
Stretch="Uniform"
Style="{DynamicResource PluginActivationIcon}" />
<Canvas Style="{DynamicResource SearchIconPosition}">
<Path
Name="SearchIcon"
Margin="0"
Data="{DynamicResource SearchIconImg}"
Stretch="Fill"
Style="{DynamicResource SearchIconStyle}"
Visibility="{Binding SearchIconVisibility}" />
</Canvas>
</Grid>
</Border> </Border>
<Line <Border Style="{DynamicResource WindowRadius}">
x:Name="ProgressBar" <Border.Clip>
Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}, Path=ActualWidth}" <MultiBinding Converter="{StaticResource BorderClipConverter}">
Height="2" <Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}" />
Margin="12,0,12,0" <Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}" />
HorizontalAlignment="Center" <Binding Path="CornerRadius" RelativeSource="{RelativeSource Self}" />
VerticalAlignment="Bottom" </MultiBinding>
StrokeThickness="2" </Border.Clip>
Style="{DynamicResource PendingLineStyle}" <ContentControl>
Visibility="{Binding ProgressBarVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" <flowlauncher:ResultListBox
X1="-100" x:Name="History"
X2="0" DataContext="{Binding History}"
Y1="0" LeftClickResultCommand="{Binding LeftClickResultCommand}"
Y2="0" /> RightClickResultCommand="{Binding RightClickResultCommand}" />
</Grid> </ContentControl>
</Border>
<Grid ClipToBounds="True"> </StackPanel>
<ContentControl> <GridSplitter
<ContentControl.Style> Grid.Column="1"
<Style TargetType="ContentControl"> Width="{Binding PreviewVisible, Converter={StaticResource SplitterConverter}}"
<Setter Property="Visibility" Value="Collapsed" /> HorizontalAlignment="Center"
<Style.Triggers> VerticalAlignment="Stretch"
<DataTrigger Binding="{Binding ElementName=ResultListBox, Path=Visibility}" Value="Visible"> Background="Transparent"
<Setter Property="Visibility" Value="Visible" /> ShowsPreview="True" />
</DataTrigger> <Grid
<DataTrigger Binding="{Binding ElementName=ContextMenu, Path=Visibility}" Value="Visible"> x:Name="Preview"
<Setter Property="Visibility" Value="Visible" /> Grid.Column="2"
</DataTrigger> VerticalAlignment="Stretch"
<DataTrigger Binding="{Binding ElementName=History, Path=Visibility}" Value="Visible"> Style="{DynamicResource PreviewArea}"
<Setter Property="Visibility" Value="Visible" /> Visibility="{Binding PreviewVisible, Converter={StaticResource BoolToVisibilityConverter}}">
</DataTrigger> <Border
</Style.Triggers> d:DataContext="{d:DesignInstance vm:ResultViewModel}"
</Style> DataContext="{Binding SelectedItem, ElementName=ResultListBox}"
</ContentControl.Style> Style="{DynamicResource PreviewBorderStyle}"
<Rectangle Visibility="{Binding ShowDefaultPreview}">
Name="MiddleSeparator" <Grid
Width="Auto" Margin="20,0,10,0"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
Style="{DynamicResource SeparatorStyle}" /> Background="Transparent">
</ContentControl> <Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid> <RowDefinition Height="Auto" />
<Grid> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid Grid.Row="0" VerticalAlignment="Center">
<ColumnDefinition Width="*" MinWidth="100" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="0.85*" MinWidth="244" />
</Grid.ColumnDefinitions>
<StackPanel
x:Name="ResultArea"
Grid.Column="0"
Grid.ColumnSpan="{Binding ResultAreaColumn}">
<Border Style="{DynamicResource WindowRadius}">
<Border.Clip>
<MultiBinding Converter="{StaticResource BorderClipConverter}">
<Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}" />
<Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}" />
<Binding Path="CornerRadius" RelativeSource="{RelativeSource Self}" />
</MultiBinding>
</Border.Clip>
<ContentControl>
<flowlauncher:ResultListBox
x:Name="ResultListBox"
DataContext="{Binding Results}"
LeftClickResultCommand="{Binding LeftClickResultCommand}"
RightClickResultCommand="{Binding RightClickResultCommand}" />
</ContentControl>
</Border>
<Border Style="{DynamicResource WindowRadius}">
<Border.Clip>
<MultiBinding Converter="{StaticResource BorderClipConverter}">
<Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}" />
<Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}" />
<Binding Path="CornerRadius" RelativeSource="{RelativeSource Self}" />
</MultiBinding>
</Border.Clip>
<ContentControl>
<flowlauncher:ResultListBox
x:Name="ContextMenu"
DataContext="{Binding ContextMenu}"
LeftClickResultCommand="{Binding LeftClickResultCommand}"
RightClickResultCommand="{Binding RightClickResultCommand}" />
</ContentControl>
</Border>
<Border Style="{DynamicResource WindowRadius}">
<Border.Clip>
<MultiBinding Converter="{StaticResource BorderClipConverter}">
<Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}" />
<Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}" />
<Binding Path="CornerRadius" RelativeSource="{RelativeSource Self}" />
</MultiBinding>
</Border.Clip>
<ContentControl>
<flowlauncher:ResultListBox
x:Name="History"
DataContext="{Binding History}"
LeftClickResultCommand="{Binding LeftClickResultCommand}"
RightClickResultCommand="{Binding RightClickResultCommand}" />
</ContentControl>
</Border>
</StackPanel>
<GridSplitter
Grid.Column="1"
Width="{Binding PreviewVisible, Converter={StaticResource SplitterConverter}}"
HorizontalAlignment="Center"
VerticalAlignment="Stretch"
Background="Transparent"
ShowsPreview="True" />
<Grid
x:Name="Preview"
Grid.Column="2"
VerticalAlignment="Stretch"
Style="{DynamicResource PreviewArea}"
Visibility="{Binding PreviewVisible, Converter={StaticResource BoolToVisibilityConverter}}">
<Border
d:DataContext="{d:DesignInstance vm:ResultViewModel}"
DataContext="{Binding SelectedItem, ElementName=ResultListBox}"
Style="{DynamicResource PreviewBorderStyle}"
Visibility="{Binding ShowDefaultPreview}">
<Grid
Margin="20,0,10,0"
VerticalAlignment="Stretch"
Background="Transparent">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid Grid.Row="0" VerticalAlignment="Center"> <TextBlock
<Grid.RowDefinitions> x:Name="PreviewGlyphIcon"
<RowDefinition Height="Auto" /> Grid.Row="0"
<RowDefinition Height="Auto" /> Height="Auto"
</Grid.RowDefinitions> Margin="0,16,0,0"
<TextBlock FontFamily="{Binding Glyph.FontFamily}"
x:Name="PreviewGlyphIcon" Style="{DynamicResource PreviewGlyph}"
Grid.Row="0" Text="{Binding Glyph.Glyph}"
Height="Auto" Visibility="{Binding ShowGlyph}" />
Margin="0,16,0,0" <Image
FontFamily="{Binding Glyph.FontFamily}" x:Name="PreviewImageIcon"
Style="{DynamicResource PreviewGlyph}" Grid.Row="0"
Text="{Binding Glyph.Glyph}" MaxHeight="320"
Visibility="{Binding ShowGlyph}" /> Margin="0,16,0,0"
<Image HorizontalAlignment="Center"
x:Name="PreviewImageIcon" Source="{Binding PreviewImage}"
Grid.Row="0" StretchDirection="DownOnly"
MaxHeight="320" Visibility="{Binding ShowPreviewImage}">
Margin="0,16,0,0" <Image.Style>
HorizontalAlignment="Center" <Style TargetType="{x:Type Image}">
Source="{Binding PreviewImage}" <Setter Property="MaxWidth" Value="96" />
StretchDirection="DownOnly"
Visibility="{Binding ShowPreviewImage}">
<Image.Style>
<Style TargetType="{x:Type Image}">
<Setter Property="MaxWidth" Value="96" />
<Style.Triggers>
<DataTrigger Binding="{Binding UseBigThumbnail}" Value="True">
<Setter Property="MaxWidth" Value="{Binding ElementName=Preview, Path=ActualWidth}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
<TextBlock
x:Name="PreviewTitle"
Grid.Row="1"
Margin="0,6,0,16"
HorizontalAlignment="Stretch"
Style="{DynamicResource PreviewItemTitleStyle}"
Text="{Binding Result.Title}"
TextAlignment="Center"
TextWrapping="Wrap" />
</Grid>
<StackPanel Grid.Row="1">
<StackPanel.Style>
<Style TargetType="{x:Type StackPanel}">
<Style.Triggers> <Style.Triggers>
<DataTrigger Binding="{Binding ElementName=PreviewSubTitle, UpdateSourceTrigger=PropertyChanged, Path=Text.Length}" Value="0"> <DataTrigger Binding="{Binding UseBigThumbnail}" Value="True">
<Setter Property="Visibility" Value="Collapsed" /> <Setter Property="MaxWidth" Value="{Binding ElementName=Preview, Path=ActualWidth}" />
</DataTrigger> </DataTrigger>
</Style.Triggers> </Style.Triggers>
</Style> </Style>
</StackPanel.Style> </Image.Style>
<Separator Style="{DynamicResource PreviewSep}" /> </Image>
<TextBlock <TextBlock
x:Name="PreviewSubTitle" x:Name="PreviewTitle"
Style="{DynamicResource PreviewItemSubTitleStyle}" Grid.Row="1"
Text="{Binding Result.SubTitle}" /> Margin="0,6,0,16"
</StackPanel> HorizontalAlignment="Stretch"
Style="{DynamicResource PreviewItemTitleStyle}"
Text="{Binding Result.Title}"
TextAlignment="Center"
TextWrapping="Wrap" />
</Grid> </Grid>
</Border> <StackPanel Grid.Row="1">
<Border <StackPanel.Style>
d:DataContext="{d:DesignInstance vm:ResultViewModel}" <Style TargetType="{x:Type StackPanel}">
DataContext="{Binding SelectedItem, ElementName=ResultListBox}" <Style.Triggers>
Style="{DynamicResource PreviewBorderStyle}" <DataTrigger Binding="{Binding ElementName=PreviewSubTitle, UpdateSourceTrigger=PropertyChanged, Path=Text.Length}" Value="0">
Visibility="{Binding ShowCustomizedPreview}"> <Setter Property="Visibility" Value="Collapsed" />
<ContentControl Content="{Binding Result.PreviewPanel.Value}" /> </DataTrigger>
</Border> </Style.Triggers>
</Grid> </Style>
</StackPanel.Style>
<Separator Style="{DynamicResource PreviewSep}" />
<TextBlock
x:Name="PreviewSubTitle"
Style="{DynamicResource PreviewItemSubTitleStyle}"
Text="{Binding Result.SubTitle}" />
</StackPanel>
</Grid>
</Border>
<Border
d:DataContext="{d:DesignInstance vm:ResultViewModel}"
DataContext="{Binding SelectedItem, ElementName=ResultListBox}"
Style="{DynamicResource PreviewBorderStyle}"
Visibility="{Binding ShowCustomizedPreview}">
<ContentControl Content="{Binding Result.PreviewPanel.Value}" />
</Border>
</Grid> </Grid>
</StackPanel> </Grid>
</Border> </StackPanel>
</Grid> </Border>
</Window> </Window>

View file

@ -29,6 +29,8 @@ using DataObject = System.Windows.DataObject;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Interop; using System.Windows.Interop;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Windows.Media.Media3D;
namespace Flow.Launcher namespace Flow.Launcher
{ {
@ -62,14 +64,73 @@ namespace Flow.Launcher
animationSound.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav")); animationSound.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav"));
DataObject.AddPastingHandler(QueryTextBox, OnPaste); DataObject.AddPastingHandler(QueryTextBox, OnPaste);
this.Loaded += (obj, args) =>
{
var handle = new WindowInteropHelper(this).Handle;
var win = HwndSource.FromHwnd(handle);
win.AddHook(new HwndSourceHook(WndProc));
};
} }
DispatcherTimer timer = new DispatcherTimer
{
Interval = new TimeSpan(0, 0, 0, 0, 500),
IsEnabled = false
};
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
} }
private void OnCopy(object sender, ExecutedRoutedEventArgs e) private void OnSizeChanged(object sender, SizeChangedEventArgs e)
{
}
private const int WM_ENTERSIZEMOVE = 0x0231;
private const int WM_EXITSIZEMOVE = 0x0232;
public event EventHandler ResizeBegin;
public event EventHandler ResizeEnd;
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
if (msg == WM_ENTERSIZEMOVE)
{
OnResizeBegin();
handled = true;
}
if (msg == WM_EXITSIZEMOVE)
{
OnResizeEnd();
handled = true;
}
return IntPtr.Zero;
}
private void OnResizeBegin()
{
}
private void OnResizeEnd()
{
int shadowMargin = 0;
if (_settings.UseDropShadowEffect)
{
shadowMargin = 32;
}
if (System.Convert.ToInt32((Height - (_settings.WindowHeightSize + 14) - shadowMargin) / _settings.ItemHeightSize) < 1)
{
_settings.MaxResultsToShow = 2;
}
else
{
_settings.MaxResultsToShow = System.Convert.ToInt32(Math.Truncate((Height - (_settings.WindowHeightSize + 14) - shadowMargin) / _settings.ItemHeightSize));
}
_settings.WindowSize = Width;
FlowMainWindow.SizeToContent = SizeToContent.Height;
}
private void OnCopy(object sender, ExecutedRoutedEventArgs e)
{ {
var result = _viewModel.Results.SelectedItem?.Result; var result = _viewModel.Results.SelectedItem?.Result;
if (QueryTextBox.SelectionLength == 0 && result != null) if (QueryTextBox.SelectionLength == 0 && result != null)

View file

@ -219,7 +219,7 @@
<Style TargetType="{x:Type ListBoxItem}"> <Style TargetType="{x:Type ListBoxItem}">
<EventSetter Event="MouseEnter" Handler="OnMouseEnter" /> <EventSetter Event="MouseEnter" Handler="OnMouseEnter" />
<EventSetter Event="MouseMove" Handler="OnMouseMove" /> <EventSetter Event="MouseMove" Handler="OnMouseMove" />
<Setter Property="Height" Value="{DynamicResource ResultItemHeight}" /> <Setter Property="Height" Value="{Binding ItemHeightSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<Setter Property="Margin" Value="0" /> <Setter Property="Margin" Value="0" />
<Setter Property="Padding" Value="0" /> <Setter Property="Padding" Value="0" />
<Setter Property="BorderThickness" Value="0" /> <Setter Property="BorderThickness" Value="0" />

View file

@ -25,6 +25,7 @@ using CommunityToolkit.Mvvm.Input;
using System.Globalization; using System.Globalization;
using System.Windows.Input; using System.Windows.Input;
using System.ComponentModel; using System.ComponentModel;
using Windows.UI.Core.AnimationMetrics;
namespace Flow.Launcher.ViewModel namespace Flow.Launcher.ViewModel
{ {
@ -71,6 +72,21 @@ namespace Flow.Launcher.ViewModel
case nameof(Settings.WindowSize): case nameof(Settings.WindowSize):
OnPropertyChanged(nameof(MainWindowWidth)); OnPropertyChanged(nameof(MainWindowWidth));
break; break;
case nameof(Settings.WindowHeightSize):
OnPropertyChanged(nameof(MainWindowHeight));
break;
case nameof(Settings.QueryBoxFontSize):
OnPropertyChanged(nameof(QueryBoxFontSize));
break;
case nameof(Settings.ItemHeightSize):
OnPropertyChanged(nameof(ItemHeightSize));
break;
case nameof(Settings.ResultItemFontSize):
OnPropertyChanged(nameof(ResultItemFontSize));
break;
case nameof(Settings.ResultSubItemFontSize):
OnPropertyChanged(nameof(ResultSubItemFontSize));
break;
case nameof(Settings.AlwaysStartEn): case nameof(Settings.AlwaysStartEn):
OnPropertyChanged(nameof(StartWithEnglishMode)); OnPropertyChanged(nameof(StartWithEnglishMode));
break; break;
@ -660,6 +676,36 @@ namespace Flow.Launcher.ViewModel
set => Settings.WindowSize = value; set => Settings.WindowSize = value;
} }
public double MainWindowHeight
{
get => Settings.WindowHeightSize;
set => Settings.WindowHeightSize = value;
}
public double QueryBoxFontSize
{
get => Settings.QueryBoxFontSize;
set => Settings.QueryBoxFontSize = value;
}
public double ItemHeightSize
{
get => Settings.ItemHeightSize;
set => Settings.ItemHeightSize = value;
}
public double ResultItemFontSize
{
get => Settings.ResultItemFontSize;
set => Settings.ResultItemFontSize = value;
}
public double ResultSubItemFontSize
{
get => Settings.ResultSubItemFontSize;
set => Settings.ResultSubItemFontSize = value;
}
public string PluginIconPath { get; set; } = null; public string PluginIconPath { get; set; } = null;
public string OpenResultCommandModifiers => Settings.OpenResultModifiers; public string OpenResultCommandModifiers => Settings.OpenResultModifiers;

View file

@ -21,6 +21,23 @@ namespace Flow.Launcher.ViewModel
{ {
Settings = settings; Settings = settings;
Settings.PropertyChanged += (_, args) =>
{
switch (args.PropertyName)
{
case nameof(Settings.ItemHeightSize):
OnPropertyChanged(nameof(ItemHeightSize));
break;
case nameof(Settings.ResultItemFontSize):
OnPropertyChanged(nameof(ResultItemFontSize));
break;
case nameof(Settings.ResultSubItemFontSize):
OnPropertyChanged(nameof(ResultSubItemFontSize));
break;
}
};
if (result == null) if (result == null)
{ {
return; return;
@ -119,6 +136,23 @@ namespace Flow.Launcher.ViewModel
} }
public double ItemHeightSize
{
get => Settings.ItemHeightSize;
set => Settings.ItemHeightSize = value;
}
public double ResultItemFontSize
{
get => Settings.ResultItemFontSize;
set => Settings.ResultItemFontSize = value;
}
public double ResultSubItemFontSize
{
get => Settings.ResultSubItemFontSize;
set => Settings.ResultSubItemFontSize = value;
}
public Visibility ShowGlyph public Visibility ShowGlyph
{ {
get get

View file

@ -32,9 +32,15 @@ namespace Flow.Launcher.ViewModel
_settings = settings; _settings = settings;
_settings.PropertyChanged += (s, e) => _settings.PropertyChanged += (s, e) =>
{ {
if (e.PropertyName == nameof(_settings.MaxResultsToShow)) switch (e.PropertyName)
{ {
OnPropertyChanged(nameof(MaxHeight)); case nameof(_settings.MaxResultsToShow):
OnPropertyChanged(nameof(MaxHeight));
break;
case nameof(_settings.ItemHeightSize):
OnPropertyChanged(nameof(ItemHeightSize));
OnPropertyChanged(nameof(MaxHeight));
break;
} }
}; };
} }
@ -43,7 +49,12 @@ namespace Flow.Launcher.ViewModel
#region Properties #region Properties
public double MaxHeight => MaxResults * (double)Application.Current.FindResource("ResultItemHeight")!; public double MaxHeight => MaxResults * _settings.ItemHeightSize!;
public double ItemHeightSize
{
get => _settings.ItemHeightSize;
set => _settings.ItemHeightSize = value;
}
public int SelectedIndex { get; set; } public int SelectedIndex { get; set; }