mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
Somil55/merge wpf to master (#3840)
* Basic WPF searchbox working * Updated key navigation and removed coldstart for searhbox * refactored and added code back in commented * Removed XAML Island references * Basic searchbox+listview working * Getting a bit more back * got color there * Result list bit better now * Added image loader for WPF Image * Partially got the context menus rendering again * adjusting coldstart to load, control will load with main form * getting context menus back * mouse over works now * Click now works, started to remove Win.XAML references * being a bit more forcusful on focus * Shadow text is not aligned * fixing focus if listbox was used * small tweak to fix shadow text * inputs don't work but gotta figure out why. commenting out * preview text * adding back in delay * fixed height issue * Applied the correct context button styles * Created custom ItemContainerStyle to fix the blue highlights behind the command buttons * Applied the correct highlight / mouseover styling * Removed vertical scrollbar in listview * fixed for alt-space prompt * Fixed right click focus issue * Somil55/wpf modifier keys (#3378) * Removed DPI change as it was not required * Global key hooks for context menu items * Updated Key for shell, folder and indexer plugin * Updated key mapping for indexer plugin * Somil55/wpf context menu selection (#3389) * Removed DPI change as it was not required * Global key hooks for context menu items * Updated Key for shell, folder and indexer plugin * Updated key mapping for indexer plugin * Add trigger to selection on tabbing * Minor shadow adjustments so its more similiar to default shell shadow. Added intro/outro animations * Added UWP-like scrollbar style for the results list * Fixed formating and naming * Removed Powerlauncher UI project * Update PowerToys.sln * Commented out scrollbar and fade in/out animations * Added missing features from UWP branch * Fixed formatting for Product.wxs * Add dragging to WPF window Co-authored-by: Clint Rutkas <clint@rutkas.com> Co-authored-by: Niels Laute <niels.laute@live.nl>
This commit is contained in:
committed by
GitHub
parent
5680a34ec1
commit
397b1533f0
@@ -39,13 +39,10 @@ namespace PowerLauncher
|
||||
{
|
||||
if (SingleInstance<App>.InitializeAsFirstInstance(Unique))
|
||||
{
|
||||
using (new UI.App())
|
||||
using (var application = new App())
|
||||
{
|
||||
using (var application = new App())
|
||||
{
|
||||
application.InitializeComponent();
|
||||
application.Run();
|
||||
}
|
||||
application.InitializeComponent();
|
||||
application.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,6 +81,7 @@ namespace PowerLauncher
|
||||
// load plugin before change language, because plugin language also needs be changed
|
||||
InternationalizationManager.Instance.Settings = _settings;
|
||||
InternationalizationManager.Instance.ChangeLanguage(_settings.Language);
|
||||
|
||||
// main windows needs initialized before theme change because of blur settings
|
||||
ThemeManager.Instance.Settings = _settings;
|
||||
ThemeManager.Instance.ChangeTheme(_settings.Theme);
|
||||
@@ -93,8 +91,9 @@ namespace PowerLauncher
|
||||
RegisterExitEvents();
|
||||
|
||||
_settingsWatcher = new SettingsWatcher(_settings);
|
||||
|
||||
|
||||
_mainVM.MainWindowVisibility = Visibility.Visible;
|
||||
_mainVM.ColdStartFix();
|
||||
Log.Info("|App.OnStartup|End Wox startup ---------------------------------------------------- ");
|
||||
|
||||
bootTime.Stop();
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<Setter Property="Foreground" Value="Transparent"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Path=Text, RelativeSource={RelativeSource TemplatedParent}}" Value="">
|
||||
<Setter Property="Foreground" Value="LightGray"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextControlPlaceholderForeground}"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
@@ -79,155 +79,11 @@
|
||||
</MultiTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="TextBox" x:Key="CustomAutoSuggestBoxTextBoxStyle">
|
||||
<!--<Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}" />
|
||||
<Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}" />
|
||||
<Setter Property="Foreground" Value="{ThemeResource TextControlForeground}" />-->
|
||||
|
||||
<!--<Setter Property="BorderBrush" Value="{ThemeResource TextControlBorderBrush}" />
|
||||
<Setter Property="SelectionHighlightColor" Value="{ThemeResource TextControlSelectionHighlightColor}" />-->
|
||||
|
||||
<!--<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
|
||||
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
|
||||
<Setter Property="ScrollViewer.HorizontalScrollMode" Value="Auto" />
|
||||
<Setter Property="ScrollViewer.VerticalScrollMode" Value="Auto" />
|
||||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
|
||||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
|
||||
<Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
|
||||
-->
|
||||
|
||||
<!--<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TextBox}">
|
||||
<Grid>
|
||||
<TextBox
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Text="{TemplateBinding Tag}"
|
||||
Panel.ZIndex="0">
|
||||
<TextBox.Style>
|
||||
<Style TargetType="{x:Type TextBox}">
|
||||
<Setter Property="Foreground" Value="Transparent"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Path=Text, Source={x:Reference textSource}}" Value="">
|
||||
<Setter Property="Foreground" Value="DarkGray"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBox.Style>
|
||||
</TextBox>
|
||||
<TextBox
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
AcceptsReturn="{TemplateBinding AcceptsReturn}"
|
||||
AcceptsTab="{TemplateBinding AcceptsTab}"
|
||||
Text="{Binding Path=Text}"
|
||||
x:Name="textSource"
|
||||
Background="Transparent"
|
||||
Panel.ZIndex="2" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>-->
|
||||
<!-- <Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="TextBox">
|
||||
<Grid>
|
||||
b<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Disabled">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement" Storyboard.TargetProperty="Background">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBackgroundDisabled}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement" Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBorderBrushDisabled}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentElement" Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlForegroundDisabled}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PlaceholderTextContentPresenter" Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlPlaceholderForegroundDisabled}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Normal" />
|
||||
<VisualState x:Name="PointerOver">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement" Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBorderBrushPointerOver}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PlaceholderTextContentPresenter" Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="#FF7e7e7e" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentElement" Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource PrimaryTextColor}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Focused">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement" Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBorderBrushFocused}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentElement" Storyboard.TargetProperty="Foreground">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource PrimaryTextColor}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentElement" Storyboard.TargetProperty="RequestedTheme">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Light" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<Border
|
||||
x:Name="BorderElement"
|
||||
Grid.Row="1"
|
||||
Background="Transparent"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
Grid.ColumnSpan="3"
|
||||
Grid.RowSpan="1" />
|
||||
<ScrollViewer
|
||||
x:Name="ContentElement"
|
||||
Grid.Row="1"
|
||||
HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
|
||||
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
|
||||
VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
|
||||
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
|
||||
IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
|
||||
IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
|
||||
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
|
||||
IsTabStop="False"
|
||||
Margin="12,0,0,0"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
CornerRadius="4"
|
||||
VerticalAlignment="Center"
|
||||
AutomationProperties.AccessibilityView="Raw"
|
||||
ZoomMode="Disabled" />
|
||||
<ContentControl
|
||||
x:Name="PlaceholderTextContentPresenter"
|
||||
Grid.Row="1"
|
||||
Opacity="0.6"
|
||||
Foreground="{DynamicResource TextControlPlaceholderForeground}"
|
||||
Margin="12,0,0,0"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
IsTabStop="False"
|
||||
Grid.ColumnSpan="3"
|
||||
VerticalAlignment="Center"
|
||||
Content="{TemplateBinding PlaceholderText}"
|
||||
IsHitTestVisible="False" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>-->
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
<Grid
|
||||
Height="60"
|
||||
Height="68"
|
||||
VerticalAlignment="Top">
|
||||
<!--Background="{ThemeResource BackdropAcrylicBrush}"-->
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="64"/>
|
||||
@@ -241,6 +97,7 @@
|
||||
Margin="24, 0, 0, 0"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="24"
|
||||
Foreground="{DynamicResource TextControlPlaceholderForeground}"
|
||||
/>
|
||||
|
||||
<!--
|
||||
@@ -260,14 +117,12 @@
|
||||
/>
|
||||
|
||||
<TextBlock
|
||||
x:Name="SearchLogo"
|
||||
x:FieldModifier="public"
|
||||
Grid.Column="1"
|
||||
Text=""
|
||||
FontFamily="Segoe MDL2 Assets"
|
||||
FontSize="24"
|
||||
HorizontalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
/>
|
||||
Foreground="{DynamicResource TextControlPlaceholderForeground}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -1,20 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace PowerLauncher
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ResultList.xaml
|
||||
/// Interaction logic for LauncherControl.xaml
|
||||
/// </summary>
|
||||
public partial class LauncherControl : UserControl
|
||||
{
|
||||
@@ -23,4 +12,4 @@ namespace PowerLauncher
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,9 @@
|
||||
xmlns:vm="clr-namespace:Wox.ViewModel;assembly=Wox"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
xmlns:xaml="clr-namespace:Microsoft.Toolkit.Wpf.UI.XamlHost;assembly=Microsoft.Toolkit.Wpf.UI.XamlHost"
|
||||
xmlns:local="clr-namespace:PowerLauncher"
|
||||
Title="PowerLaunch"
|
||||
mc:Ignorable="d"
|
||||
Title="PowerToys Run"
|
||||
Topmost="True"
|
||||
SizeToContent="Height"
|
||||
ResizeMode="NoResize"
|
||||
@@ -18,16 +17,40 @@
|
||||
Icon="Images/app.png"
|
||||
AllowsTransparency="True"
|
||||
Loaded="OnLoaded"
|
||||
Initialized="OnInitialized"
|
||||
Closing="OnClosing"
|
||||
Drop="OnDrop"
|
||||
Background="Transparent"
|
||||
LocationChanged="OnLocationChanged"
|
||||
Deactivated="OnDeactivated"
|
||||
Background="Transparent"
|
||||
Width="720"
|
||||
Visibility="{Binding MainWindowVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
d:DataContext="{d:DesignInstance vm:MainViewModel}">
|
||||
<Grid Width="720"
|
||||
<Window.Resources>
|
||||
<SolidColorBrush x:Key="SystemChromeLow" Color="#FFF2F2F2" />
|
||||
<!--"key": "SystemChromeLowColor",
|
||||
"name": "ChromeLow",
|
||||
"lightHex": "#FFF2F2F2",
|
||||
"darkHex": "#FF171717"-->
|
||||
|
||||
<CubicEase x:Key="CubicEaseOut" EasingMode="EaseOut"/>
|
||||
|
||||
<!-- Some of the durations are different to give a 'parallax' feel (like start menu has as well) -->
|
||||
<!--<Storyboard x:Key="IntroStoryboard">
|
||||
<DoubleAnimation From="20" To="0" Duration="0:0:0.2" Storyboard.TargetName="SearchBoxBorder" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)" EasingFunction="{StaticResource CubicEaseOut}"/>
|
||||
<DoubleAnimation From="20" To="0" Duration="0:0:0.250" Storyboard.TargetName="SearchBox" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)" EasingFunction="{StaticResource CubicEaseOut}"/>
|
||||
<DoubleAnimation From="0.5" To="1" Duration="0:0:0.150" Storyboard.TargetName="SearchBoxBorder" Storyboard.TargetProperty="(UIElement.Opacity)" EasingFunction="{StaticResource CubicEaseOut}"/>
|
||||
<DoubleAnimation From="-10" To="0" Duration="0:0:0.2" Storyboard.TargetName="ListBoxBorder" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)" EasingFunction="{StaticResource CubicEaseOut}"/>
|
||||
<DoubleAnimation From="0.5" To="1" Duration="0:0:0.1" Storyboard.TargetName="ListBoxBorder" Storyboard.TargetProperty="(UIElement.Opacity)" EasingFunction="{StaticResource CubicEaseOut}"/>
|
||||
</Storyboard>-->
|
||||
|
||||
<!-- Duration is a bit shorter, since it's an outro animation and you want it to be gone asap -->
|
||||
<!--<Storyboard x:Key="OutroStoryboard" Completed="OutroStoryboard_Completed">
|
||||
<DoubleAnimation From="0" To="20" Duration="0:0:0.18" Storyboard.TargetName="SearchBoxBorder" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)" EasingFunction="{StaticResource CubicEaseOut}"/>
|
||||
<DoubleAnimation From="1" To="0.0" Duration="0:0:0.18" Storyboard.TargetName="SearchBoxBorder" Storyboard.TargetProperty="(UIElement.Opacity)" EasingFunction="{StaticResource CubicEaseOut}"/>
|
||||
<DoubleAnimation From="0" To="-10" Duration="0:0:0.18" Storyboard.TargetName="ListBoxBorder" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)" EasingFunction="{StaticResource CubicEaseOut}"/>
|
||||
<DoubleAnimation From="1" To="0.0" Duration="0:0:0.18" Storyboard.TargetName="ListBoxBorder" Storyboard.TargetProperty="(UIElement.Opacity)" EasingFunction="{StaticResource CubicEaseOut}"/>
|
||||
</Storyboard>-->
|
||||
|
||||
</Window.Resources>
|
||||
<Grid Width="720"
|
||||
MouseDown="OnMouseDown">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
@@ -37,30 +60,44 @@
|
||||
x:Name="SearchBoxBorder"
|
||||
Grid.Row="0"
|
||||
Margin="24,24,24,8"
|
||||
BorderThickness="4"
|
||||
CornerRadius="4">
|
||||
BorderThickness="0"
|
||||
CornerRadius="4"
|
||||
Background="{DynamicResource SystemChromeLow}"
|
||||
BorderBrush="{DynamicResource SystemChromeLow}">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect BlurRadius="16" Opacity="0.8" ShadowDepth="0" />
|
||||
<DropShadowEffect BlurRadius="12" Opacity="0.3" ShadowDepth="0" />
|
||||
</Border.Effect>
|
||||
<local:LauncherControl
|
||||
x:Name="SearchBox"
|
||||
Height="60"/>
|
||||
<local:LauncherControl
|
||||
x:Name="SearchBox">
|
||||
<!--<local:LauncherControl.RenderTransform>
|
||||
<TranslateTransform />
|
||||
</local:LauncherControl.RenderTransform>-->
|
||||
</local:LauncherControl>
|
||||
<!--<Border.RenderTransform>
|
||||
<TranslateTransform />
|
||||
</Border.RenderTransform>-->
|
||||
</Border>
|
||||
<Border
|
||||
x:Name="ListBoxBorder"
|
||||
Grid.Row="1"
|
||||
Margin="24,8,24,24"
|
||||
BorderThickness="4"
|
||||
BorderThickness="0"
|
||||
CornerRadius="4"
|
||||
Visibility="{Binding Results.Visibility}">
|
||||
Visibility="{Binding Results.Visibility}"
|
||||
Background="{DynamicResource SystemChromeLow}"
|
||||
BorderBrush="{DynamicResource SystemChromeLow}">
|
||||
<!--<Border.RenderTransform>
|
||||
<TranslateTransform />
|
||||
</Border.RenderTransform>-->
|
||||
<Border.Effect>
|
||||
<DropShadowEffect BlurRadius="16" Opacity="0.8" ShadowDepth="0" />
|
||||
<DropShadowEffect BlurRadius="12" Opacity="0.3" ShadowDepth="0" />
|
||||
</Border.Effect>
|
||||
<xaml:WindowsXamlHost
|
||||
x:Name="ListBox"
|
||||
InitialTypeName="PowerLauncher.UI.ResultList"
|
||||
ChildChanged="WindowsXamlHostListView_ChildChanged"
|
||||
PreviewMouseDown="WindowsXamlHost_PreviewMouseDown" />
|
||||
<local:ResultList x:Name="ListBox"
|
||||
PreviewMouseDown="ListBox_PreviewMouseDown" >
|
||||
<!--<local:ResultList.RenderTransform>
|
||||
<TranslateTransform />
|
||||
</local:ResultList.RenderTransform>-->
|
||||
</local:ResultList>
|
||||
</Border>
|
||||
</Grid>
|
||||
<Window.InputBindings>
|
||||
|
||||
@@ -3,29 +3,18 @@ using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Animation;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Core.Resource;
|
||||
using Wox.Helper;
|
||||
using Wox.Infrastructure.UserSettings;
|
||||
using Wox.ViewModel;
|
||||
|
||||
using Screen = System.Windows.Forms.Screen;
|
||||
using DataFormats = System.Windows.DataFormats;
|
||||
using DragEventArgs = System.Windows.DragEventArgs;
|
||||
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using Microsoft.Toolkit.Wpf.UI.XamlHost;
|
||||
using Windows.System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using System.Diagnostics;
|
||||
using Mages.Core.Runtime.Converters;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.PowerLauncher.Telemetry;
|
||||
using System.Timers;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
using System.Windows.Controls;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics;
|
||||
using System.Timers;
|
||||
using Microsoft.PowerLauncher.Telemetry;
|
||||
using Microsoft.PowerToys.Telemetry;
|
||||
|
||||
namespace PowerLauncher
|
||||
{
|
||||
@@ -38,20 +27,17 @@ namespace PowerLauncher
|
||||
private Settings _settings;
|
||||
private MainViewModel _viewModel;
|
||||
private bool _isTextSetProgramatically;
|
||||
const int ROW_HEIGHT = 75;
|
||||
const int MAX_LIST_HEIGHT = 300;
|
||||
bool isDPIChanged = false;
|
||||
bool _deletePressed = false;
|
||||
Timer _firstDeleteTimer = new Timer();
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
public MainWindow(Settings settings, MainViewModel mainVM)
|
||||
public MainWindow(Settings settings, MainViewModel mainVM) : this()
|
||||
{
|
||||
DataContext = mainVM;
|
||||
_viewModel = mainVM;
|
||||
_settings = settings;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
_firstDeleteTimer.Elapsed += CheckForFirstDelete;
|
||||
@@ -68,7 +54,6 @@ namespace PowerLauncher
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -79,15 +64,9 @@ namespace PowerLauncher
|
||||
_viewModel.Save();
|
||||
}
|
||||
|
||||
private void OnInitialized(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void OnLoaded(object sender, System.Windows.RoutedEventArgs _)
|
||||
private void OnLoaded(object sender, RoutedEventArgs _)
|
||||
{
|
||||
WindowsInteropHelper.DisableControlBox(this);
|
||||
|
||||
InitializePosition();
|
||||
|
||||
SearchBox.QueryTextBox.DataContext = _viewModel;
|
||||
@@ -95,60 +74,48 @@ namespace PowerLauncher
|
||||
SearchBox.QueryTextBox.TextChanged += QueryTextBox_TextChanged;
|
||||
SearchBox.QueryTextBox.Focus();
|
||||
|
||||
ListBox.DataContext = _viewModel;
|
||||
ListBox.SuggestionsList.SelectionChanged += SuggestionsList_SelectionChanged;
|
||||
ListBox.SuggestionsList.PreviewMouseLeftButtonUp += SuggestionsList_PreviewMouseLeftButtonUp;
|
||||
_viewModel.PropertyChanged += ViewModel_PropertyChanged;
|
||||
}
|
||||
|
||||
private void QueryTextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
|
||||
private void SuggestionsList_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (this._isTextSetProgramatically)
|
||||
var result = ((FrameworkElement)e.OriginalSource).DataContext;
|
||||
if (result != null)
|
||||
{
|
||||
var textBox = ((TextBox)sender);
|
||||
textBox.SelectionStart = textBox.Text.Length;
|
||||
var resultVM = result as ResultViewModel;
|
||||
|
||||
this._isTextSetProgramatically = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
var text = ((TextBox)sender).Text;
|
||||
if (text == string.Empty)
|
||||
//This may be null if the tapped item was one of the context buttons (run as admin etc).
|
||||
if (resultVM != null)
|
||||
{
|
||||
SearchBox.AutoCompleteTextBlock.Text = String.Empty;
|
||||
_viewModel.Results.SelectedItem = resultVM;
|
||||
_viewModel.OpenResultCommand.Execute(null);
|
||||
}
|
||||
|
||||
_viewModel.QueryText = text;
|
||||
var latestTimeOfTyping = DateTime.Now;
|
||||
|
||||
Task.Run(() => DelayedCheck(latestTimeOfTyping, text));
|
||||
s_lastTimeOfTyping = latestTimeOfTyping;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializePosition()
|
||||
{
|
||||
Top = WindowTop();
|
||||
Left = WindowLeft();
|
||||
_settings.WindowTop = Top;
|
||||
_settings.WindowLeft = Left;
|
||||
}
|
||||
|
||||
private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(MainViewModel.MainWindowVisibility))
|
||||
{
|
||||
if (Visibility == Visibility.Visible)
|
||||
if (Visibility == System.Windows.Visibility.Visible)
|
||||
{
|
||||
_deletePressed = false;
|
||||
_firstDeleteTimer.Start();
|
||||
Activate();
|
||||
//(this.FindResource("IntroStoryboard") as Storyboard).Begin();
|
||||
|
||||
UpdatePosition();
|
||||
SearchBox.QueryTextBox.Focus();
|
||||
_settings.ActivateTimes++;
|
||||
|
||||
if (!_viewModel.LastQuerySelected)
|
||||
{
|
||||
_viewModel.LastQuerySelected = true;
|
||||
}
|
||||
|
||||
// to select the text so that the user can continue to type
|
||||
if (!String.IsNullOrEmpty(SearchBox.QueryTextBox.Text))
|
||||
{
|
||||
SearchBox.QueryTextBox.SelectAll();
|
||||
@@ -171,42 +138,20 @@ namespace PowerLauncher
|
||||
if (e.ChangedButton == MouseButton.Left) DragMove();
|
||||
}
|
||||
|
||||
private void OnDrop(object sender, DragEventArgs e)
|
||||
private void InitializePosition()
|
||||
{
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||
{
|
||||
// Note that you can have more than one file.
|
||||
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
if (files[0].ToLower().EndsWith(".wox"))
|
||||
{
|
||||
PluginManager.InstallPlugin(files[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidWoxPluginFileFormat"));
|
||||
}
|
||||
}
|
||||
e.Handled = false;
|
||||
}
|
||||
|
||||
private void OnPreviewDragOver(object sender, DragEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
Top = WindowTop();
|
||||
Left = WindowLeft();
|
||||
_settings.WindowTop = Top;
|
||||
_settings.WindowLeft = Left;
|
||||
}
|
||||
|
||||
private void OnDeactivated(object sender, EventArgs e)
|
||||
{
|
||||
if (_settings.HideWhenDeactivated)
|
||||
{
|
||||
if (isDPIChanged)
|
||||
{
|
||||
isDPIChanged = false;
|
||||
InitializePosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
//(this.FindResource("OutroStoryboard") as Storyboard).Begin();
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,19 +163,9 @@ namespace PowerLauncher
|
||||
Top = _settings.WindowTop;
|
||||
}
|
||||
else
|
||||
{
|
||||
double prevTop = Top;
|
||||
double prevLeft = Left;
|
||||
{
|
||||
Top = WindowTop();
|
||||
Left = WindowLeft();
|
||||
if (prevTop != Top || prevLeft != Left)
|
||||
{
|
||||
isDPIChanged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isDPIChanged = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,78 +185,21 @@ namespace PowerLauncher
|
||||
private double WindowLeft()
|
||||
{
|
||||
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
|
||||
var dpi1 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
|
||||
var dpi2 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0);
|
||||
var left = (dpi2.X - this.Width) / 2 + dpi1.X;
|
||||
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
|
||||
var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0);
|
||||
var left = (dip2.X - ActualWidth) / 2 + dip1.X;
|
||||
return left;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates Y co-ordinate of main window top left corner
|
||||
/// </summary>
|
||||
/// <returns>Y co-ordinate of main window top left corner</returns>
|
||||
private double WindowTop()
|
||||
{
|
||||
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
|
||||
var dpi1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
|
||||
var dpi2 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height);
|
||||
var top = (dpi2.Y - this.SearchBox.Height) / 4 + dpi1.Y;
|
||||
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
|
||||
var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height);
|
||||
var top = (dip2.Y - this.SearchBox.ActualHeight) / 4 + dip1.Y;
|
||||
return top;
|
||||
}
|
||||
|
||||
private void UserControl_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == "SolidBorderBrush")
|
||||
{
|
||||
if (_resultList != null)
|
||||
{
|
||||
Windows.UI.Xaml.Media.SolidColorBrush borderBrush = _resultList.SolidBorderBrush as Windows.UI.Xaml.Media.SolidColorBrush;
|
||||
Color borderColor = Color.FromArgb(borderBrush.Color.A, borderBrush.Color.R, borderBrush.Color.G, borderBrush.Color.B);
|
||||
SolidColorBrush solidBorderBrush = new SolidColorBrush(borderColor);
|
||||
|
||||
this.SearchBoxBorder.BorderBrush = solidBorderBrush;
|
||||
this.SearchBoxBorder.Background = solidBorderBrush;
|
||||
this.ListBoxBorder.BorderBrush = solidBorderBrush;
|
||||
this.ListBoxBorder.Background = solidBorderBrush;
|
||||
|
||||
}
|
||||
}
|
||||
else if(e.PropertyName == "PrimaryTextColor")
|
||||
{
|
||||
if (_resultList != null)
|
||||
{
|
||||
Windows.UI.Xaml.Media.SolidColorBrush primaryTextBrush = _resultList.PrimaryTextColor as Windows.UI.Xaml.Media.SolidColorBrush;
|
||||
Color primaryTextColor = Color.FromArgb(primaryTextBrush.Color.A, primaryTextBrush.Color.R, primaryTextBrush.Color.G, primaryTextBrush.Color.B);
|
||||
SolidColorBrush solidPrimaryTextBrush = new SolidColorBrush(primaryTextColor);
|
||||
|
||||
this.SearchBox.QueryTextBox.Foreground = solidPrimaryTextBrush;
|
||||
this.SearchBox.QueryTextBox.CaretBrush = solidPrimaryTextBrush;
|
||||
this.SearchBox.AutoCompleteTextBlock.Foreground = solidPrimaryTextBrush;
|
||||
this.SearchBox.SearchLogo.Foreground = solidPrimaryTextBrush;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private UI.ResultList _resultList = null;
|
||||
private void WindowsXamlHostListView_ChildChanged(object sender, EventArgs ev)
|
||||
{
|
||||
if (sender == null) return;
|
||||
|
||||
var host = (WindowsXamlHost)sender;
|
||||
_resultList = (UI.ResultList)host.Child;
|
||||
_resultList.DataContext = _viewModel;
|
||||
_resultList.Tapped += SuggestionsList_Tapped;
|
||||
_resultList.SuggestionsList.Loaded += SuggestionsList_Loaded;
|
||||
_resultList.SuggestionsList.SelectionChanged += SuggestionsList_SelectionChanged;
|
||||
_resultList.SuggestionsList.ContainerContentChanging += SuggestionList_UpdateListSize;
|
||||
_resultList.PropertyChanged += UserControl_PropertyChanged;
|
||||
}
|
||||
|
||||
private void SuggestionsList_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
_viewModel.ColdStartFix();
|
||||
}
|
||||
|
||||
private void _launcher_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Tab && Keyboard.IsKeyDown(Key.LeftShift))
|
||||
@@ -358,51 +236,28 @@ namespace PowerLauncher
|
||||
_viewModel.SelectPrevPageCommand.Execute(null);
|
||||
e.Handled = true;
|
||||
}
|
||||
else if( e.Key == Key.Back)
|
||||
else if (e.Key == Key.Back)
|
||||
{
|
||||
_deletePressed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_viewModel.HandleContextMenu(e.Key, Keyboard.Modifiers);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateTextBoxToSelectedItem()
|
||||
{
|
||||
var itemText = _viewModel?.Results?.SelectedItem?.ToString() ?? null;
|
||||
if (!String.IsNullOrEmpty(itemText))
|
||||
if (!string.IsNullOrEmpty(itemText))
|
||||
{
|
||||
_viewModel.ChangeQueryText(itemText);
|
||||
}
|
||||
}
|
||||
|
||||
private void SuggestionsList_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
|
||||
private void SuggestionsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
var result = ((Windows.UI.Xaml.FrameworkElement)e.OriginalSource).DataContext;
|
||||
if (result != null)
|
||||
{
|
||||
var resultVM = result as ResultViewModel;
|
||||
|
||||
//This may be null if the tapped item was one of the context buttons (run as admin etc).
|
||||
if (resultVM != null)
|
||||
{
|
||||
_viewModel.Results.SelectedItem = resultVM;
|
||||
_viewModel.OpenResultCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Note: This function has been added because a white-background was observed when the list resized,
|
||||
* when the number of elements were lesser than the maximum capacity of the list (ie. 4).
|
||||
* Binding Height/MaxHeight Properties did not solve this issue.
|
||||
*/
|
||||
private void SuggestionList_UpdateListSize(object sender, Windows.UI.Xaml.Controls.ContainerContentChangingEventArgs e)
|
||||
{
|
||||
int count = _viewModel?.Results?.Results.Count ?? 0;
|
||||
int displayCount = Math.Min(count, _settings.MaxResultsToShow);
|
||||
_resultList.Height = displayCount * ROW_HEIGHT;
|
||||
}
|
||||
|
||||
private void SuggestionsList_SelectionChanged(object sender, Windows.UI.Xaml.Controls.SelectionChangedEventArgs e)
|
||||
{
|
||||
Windows.UI.Xaml.Controls.ListView listview = (Windows.UI.Xaml.Controls.ListView)sender;
|
||||
ListView listview = (ListView)sender;
|
||||
_viewModel.Results.SelectedItem = (ResultViewModel) listview.SelectedItem;
|
||||
if (e.AddedItems.Count > 0 && e.AddedItems[0] != null)
|
||||
{
|
||||
@@ -416,12 +271,11 @@ namespace PowerLauncher
|
||||
|
||||
private const int millisecondsToWait = 100;
|
||||
private static DateTime s_lastTimeOfTyping;
|
||||
|
||||
private string ListView_FirstItem(String input)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(input))
|
||||
if (!string.IsNullOrEmpty(input))
|
||||
{
|
||||
String selectedItem = _viewModel.Results?.SelectedItem?.ToString();
|
||||
string selectedItem = _viewModel.Results?.SelectedItem?.ToString();
|
||||
int selectedIndex = _viewModel.Results.SelectedIndex;
|
||||
if (selectedItem != null && selectedIndex == 0)
|
||||
{
|
||||
@@ -432,12 +286,29 @@ namespace PowerLauncher
|
||||
}
|
||||
}
|
||||
|
||||
return String.Empty;
|
||||
return string.Empty;
|
||||
}
|
||||
private void QueryTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (_isTextSetProgramatically)
|
||||
{
|
||||
var textBox = ((TextBox)sender);
|
||||
textBox.SelectionStart = textBox.Text.Length;
|
||||
_isTextSetProgramatically = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
var text = ((TextBox)sender).Text;
|
||||
if (text == string.Empty)
|
||||
{
|
||||
SearchBox.AutoCompleteTextBlock.Text = string.Empty;
|
||||
}
|
||||
_viewModel.QueryText = text;
|
||||
var latestTimeOfTyping = DateTime.Now;
|
||||
|
||||
private void QueryTextBox_TextChangedProgramatically(object sender, Windows.UI.Xaml.Controls.TextChangedEventArgs e)
|
||||
{
|
||||
|
||||
Task.Run(() => DelayedCheck(latestTimeOfTyping, text));
|
||||
s_lastTimeOfTyping = latestTimeOfTyping;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DelayedCheck(DateTime latestTimeOfTyping, string text)
|
||||
@@ -451,27 +322,23 @@ namespace PowerLauncher
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private void WindowsXamlHost_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
||||
|
||||
private void ListBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
// if (sender != null && e.OriginalSource != null)
|
||||
// {
|
||||
// //var r = (ResultListBox)sender;
|
||||
// //var d = (DependencyObject)e.OriginalSource;
|
||||
// //var item = ItemsControl.ContainerFromElement(r, d) as ListBoxItem;
|
||||
// //var result = (ResultViewModel)item?.DataContext;
|
||||
// //if (result != null)
|
||||
// //{
|
||||
// // if (e.ChangedButton == MouseButton.Left)
|
||||
// // {
|
||||
// // _viewModel.OpenResultCommand.Execute(null);
|
||||
// // }
|
||||
// // else if (e.ChangedButton == MouseButton.Right)
|
||||
// // {
|
||||
// // _viewModel.LoadContextMenuCommand.Execute(null);
|
||||
// // }
|
||||
// //}
|
||||
// }
|
||||
if (e.ChangedButton == MouseButton.Right)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("Changed");
|
||||
}
|
||||
|
||||
private void OutroStoryboard_Completed(object sender, EventArgs e)
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,9 +61,7 @@
|
||||
<PackageReference Include="InputSimulator" Version="1.0.4" />
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
|
||||
<PackageReference Include="Mages" Version="1.6.0" />
|
||||
<PackageReference Include="Microsoft.Toolkit.UI.XamlHost" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.Toolkit.Uwp.UI" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Toolkit.Wpf.UI.XamlHost" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.19" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="NHotkey.Wpf" Version="2.0.1" />
|
||||
<PackageReference Include="NuGet.CommandLine" Version="5.5.1">
|
||||
@@ -79,7 +77,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\core\Microsoft.PowerToys.Settings.UI.Lib\Microsoft.PowerToys.Settings.UI.Lib.csproj" />
|
||||
<ProjectReference Include="..\PowerLauncher.UI\PowerLauncher.UI.csproj" />
|
||||
<ProjectReference Include="..\Wox.Core\Wox.Core.csproj" />
|
||||
<ProjectReference Include="..\Wox.Infrastructure\Wox.Infrastructure.csproj" />
|
||||
<ProjectReference Include="..\Wox.Plugin\Wox.Plugin.csproj" />
|
||||
|
||||
225
src/modules/launcher/PowerLauncher/ResultList.xaml
Normal file
225
src/modules/launcher/PowerLauncher/ResultList.xaml
Normal file
@@ -0,0 +1,225 @@
|
||||
<UserControl
|
||||
x:Class="PowerLauncher.ResultList"
|
||||
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:Behaviors="http://schemas.microsoft.com/xaml/behaviors"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="720">
|
||||
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<!--<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/Styles/UWPScrollBarStyle.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>-->
|
||||
|
||||
|
||||
<!-- These colors are based on the UWP XAML resources -->
|
||||
|
||||
<!-- Dark theme (a.k.a. "Default") -->
|
||||
<!--<SolidColorBrush x:Key="ButtonBackgroundPointerOver" Color="#30FFFFFF" />
|
||||
<SolidColorBrush x:Key="ButtonBorderPointerOver" Color="#61FFFFFF" />
|
||||
<SolidColorBrush x:Key="ButtonBackgroundPressed" Color="#30FFFFFF" />
|
||||
<SolidColorBrush x:Key="ButtonBorderPressed" Color="#61FFFFFF" />
|
||||
<SolidColorBrush x:Key="ListViewItemBackgroundPointerOver" Color="#FFFFFFFF" />-->
|
||||
|
||||
<!-- Light theme -->
|
||||
<SolidColorBrush x:Key="ButtonBackgroundPointerOver" Color="#2E000000" />
|
||||
<SolidColorBrush x:Key="ButtonBorderPointerOver" Color="#61000000" />
|
||||
<SolidColorBrush x:Key="ButtonBackgroundPressed" Color="#33000000" />
|
||||
<SolidColorBrush x:Key="ButtonBorderPressed" Color="#61000000" />
|
||||
<SolidColorBrush x:Key="ListViewItemBackgroundPointerOver" Color="#FF000000" />
|
||||
|
||||
<!-- High contrast -->
|
||||
<!--<SolidColorBrush x:Key="ButtonBackgroundPointerOver" Color="#33FFFFFF" />
|
||||
<SolidColorBrush x:Key="ButtonBorderPointerOver" Color="#66FFFFFF" />
|
||||
<SolidColorBrush x:Key="ButtonBackgroundPressed" Color="#33FFFFFF" />
|
||||
<SolidColorBrush x:Key="ButtonBorderPressed" Color="#66FFFFFF" />-->
|
||||
|
||||
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||
<Style x:Key="FocusVisual">
|
||||
<Setter Property="Control.Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate>
|
||||
<Rectangle Margin="2" StrokeDashArray="1 2" SnapsToDevicePixels="true" StrokeThickness="1" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="IconButtonStyle" TargetType="{x:Type Button}">
|
||||
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="Padding" Value="1"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Border x:Name="border" CornerRadius="4" Background="Transparent" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="Transparent" SnapsToDevicePixels="true">
|
||||
<ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsDefaulted" Value="true">
|
||||
<Setter Property="Background" TargetName="border" Value="Transparent"/>
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="Transparent"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="true">
|
||||
<Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonBackgroundPointerOver}"/>
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonBorderPointerOver}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="true">
|
||||
<Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonBackgroundPressed}"/>
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonBorderPressed}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<!--<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/>
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/>
|
||||
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Button.Disabled.Foreground}"/>-->
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ResultsListViewItemContainerStyle" TargetType="ListViewItem">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ListViewItem}">
|
||||
<Grid Background="Transparent">
|
||||
<Border x:Name="HighlightBorder" BorderThickness="0" Background="Transparent" BorderBrush="Transparent" SnapsToDevicePixels="true"/>
|
||||
<ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<!-- Setting the opacity of the highlight border to improve the contrast of the AccentColorbrush when selected. In UWP we could call a different brush, in WPF we need to play with the opacity of the WindowGlassBrush-->
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Opacity" TargetName="HighlightBorder" Value="0.1" />
|
||||
<Setter Property="Background" TargetName="HighlightBorder" Value="{DynamicResource ListViewItemBackgroundPointerOver}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Opacity" TargetName="HighlightBorder" Value="0.4" />
|
||||
<Setter Property="Background" TargetName="HighlightBorder" Value="{Binding Source={x:Static SystemParameters.WindowGlassBrush}}"/>
|
||||
<!-- Accent color brush -->
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="CommandButtonListViewItemContainerStyle" TargetType="ListViewItem">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="Padding" Value="0" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ListViewItem}">
|
||||
<Border x:Name="border" CornerRadius="4" Background="Transparent" BorderBrush="Transparent" SnapsToDevicePixels="true">
|
||||
<ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="true">
|
||||
<Setter Property="Background" TargetName="border" Value="Transparent"/>
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="Transparent"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" TargetName="border" Value="{DynamicResource ButtonBackgroundPressed}"/>
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource ButtonBorderPressed}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid VerticalAlignment="Top">
|
||||
<ListView
|
||||
x:Name="SuggestionsList"
|
||||
x:FieldModifier="public"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
MaxHeight="{Binding Results.MaxHeight}"
|
||||
MinHeight="{Binding Results.MinHeight}"
|
||||
Margin="0"
|
||||
ItemsSource="{Binding Results.Results, Mode=OneWay}"
|
||||
Padding="0, 0"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Disabled"
|
||||
SelectionMode="Single"
|
||||
SelectedIndex="{Binding Results.SelectedIndex, Mode=TwoWay}"
|
||||
ItemContainerStyle="{StaticResource ResultsListViewItemContainerStyle}">
|
||||
|
||||
<!--AllowFocusOnInteraction="False"
|
||||
IsItemClickEnabled="True"-->
|
||||
<!--Style="{StaticResource ListViewNoAnimations}"-->
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate >
|
||||
<Grid Height="72" Width="642" Background="Transparent" >
|
||||
<Behaviors:Interaction.Triggers>
|
||||
<Behaviors:EventTrigger EventName="MouseEnter">
|
||||
<Behaviors:InvokeCommandAction Command="{Binding ActivateContextButtonsHoverCommand}"/>
|
||||
</Behaviors:EventTrigger>
|
||||
<Behaviors:EventTrigger EventName="MouseLeave">
|
||||
<Behaviors:InvokeCommandAction Command="{Binding DeactivateContextButtonsHoverCommand}"/>
|
||||
</Behaviors:EventTrigger>
|
||||
</Behaviors:Interaction.Triggers>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="64" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions >
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Image x:Name="AppIcon" Height="36" MaxWidth="56" Grid.RowSpan="2" Margin="-8,0,0,0" HorizontalAlignment="Center" Source="{Binding Image}" />
|
||||
<TextBlock x:Name="Title" Grid.Column="1" Text="{Binding Result.Title}" FontWeight="SemiBold" FontSize="20" Margin="0,0,0,-2" VerticalAlignment="Bottom"/>
|
||||
<TextBlock x:Name="Path" Grid.Column="1" Text= "{Binding Result.SubTitle}" Grid.Row="1" Opacity="0.6" Margin="0,2,0,0" VerticalAlignment="Top"/>
|
||||
<ListView
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="2"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ItemsSource="{Binding ContextMenuItems}"
|
||||
SelectionMode="Single"
|
||||
SelectedIndex="{Binding ContextMenuSelectedIndex}"
|
||||
Visibility="{Binding AreContextButtonsActive, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
ItemContainerStyle="{StaticResource CommandButtonListViewItemContainerStyle}">
|
||||
<!-- Right margin is now set to 24 to cater for the scrollbar. If we fix the weird width issue we can put it back to 0 (or 8 if there's no spacing by default) -->
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Button Style="{StaticResource IconButtonStyle}" Command="{Binding Command}" VerticalAlignment="Center" Height="42" Width="42" BorderThickness="1" >
|
||||
<ToolTipService.ToolTip>
|
||||
<TextBlock Text="{Binding Title}"/>
|
||||
</ToolTipService.ToolTip>
|
||||
<Button.Content>
|
||||
<TextBlock FontFamily="{Binding FontFamily}" FontSize="16" Text="{Binding Glyph}"/>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
15
src/modules/launcher/PowerLauncher/ResultList.xaml.cs
Normal file
15
src/modules/launcher/PowerLauncher/ResultList.xaml.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace PowerLauncher
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ResultList.xaml
|
||||
/// </summary>
|
||||
public partial class ResultList : UserControl
|
||||
{
|
||||
public ResultList()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
139
src/modules/launcher/PowerLauncher/Styles/UWPScrollBarStyle.xaml
Normal file
139
src/modules/launcher/PowerLauncher/Styles/UWPScrollBarStyle.xaml
Normal file
@@ -0,0 +1,139 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<!-- Light theme -->
|
||||
<SolidColorBrush x:Key="ThumbBrush" Color="#7a7a7a" />
|
||||
<SolidColorBrush x:Key="ThumbPointerOverBrush" Color="#a0a0a0" />
|
||||
<SolidColorBrush x:Key="ThumbPointerPressedBrush" Color="#747474" />
|
||||
|
||||
<!-- Dark theme -->
|
||||
<!--<SolidColorBrush x:Key="ThumbBrush" Color="#7a7a7a" />
|
||||
<SolidColorBrush x:Key="ThumbPointerOverBrush" Color="#767676" />
|
||||
<SolidColorBrush x:Key="ThumbPointerPressedBrush" Color="#a4a4a4" /> -->
|
||||
|
||||
<!-- High contrast -->
|
||||
<!--<SolidColorBrush x:Key="ThumbBrush" Color="#ffffff" />
|
||||
<SolidColorBrush x:Key="ThumbPointerOverBrush" Color="#1aebff" />
|
||||
<SolidColorBrush x:Key="ThumbPointerPressedBrush" Color="#1aebff" /> -->
|
||||
|
||||
<Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
|
||||
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||
<Setter Property="IsTabStop" Value="false"/>
|
||||
<Setter Property="Focusable" Value="false"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Thumb}">
|
||||
<Border x:Name="ThumbBorder" CornerRadius="2" Background="{DynamicResource ThumbBrush}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0" HorizontalAlignment="Right" Width="4" Margin="0,0,-1,0">
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates" >
|
||||
<VisualStateGroup.Transitions>
|
||||
<VisualTransition GeneratedDuration="0:0:0.15">
|
||||
<VisualTransition.GeneratedEasingFunction>
|
||||
<ExponentialEase EasingMode="EaseOut"/>
|
||||
</VisualTransition.GeneratedEasingFunction>
|
||||
</VisualTransition>
|
||||
</VisualStateGroup.Transitions>
|
||||
<VisualState x:Name="Normal" />
|
||||
<VisualState x:Name="MouseOver">
|
||||
<Storyboard>
|
||||
<!--<ThicknessAnimation Storyboard.TargetName="ThumbBorder" Duration="0:0:0.15" Storyboard.TargetProperty="Margin" To="0,0,0,0" />-->
|
||||
|
||||
<DoubleAnimation Storyboard.TargetName="ThumbBorder" Duration="0:0:0.15" Storyboard.TargetProperty="Width" To="16"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="ThumbBorder" Property="CornerRadius" Value="0" />
|
||||
<Setter TargetName="ThumbBorder" Property="Background" Value="{DynamicResource ThumbPointerOverBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseCaptured" Value="True">
|
||||
<Setter TargetName="ThumbBorder" Property="Background" Value="{DynamicResource ThumbPointerPressedBrush}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}">
|
||||
<Grid Margin="0,1,1,1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition MaxHeight="0"/>
|
||||
<RowDefinition Height="0.00001*"/>
|
||||
<RowDefinition MaxHeight="0"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Border x:Name="BackgroundBorder" Grid.RowSpan="3" CornerRadius="2" Background="Transparent" />
|
||||
<RepeatButton Grid.Row="0" Height="24" Command="ScrollBar.LineUpCommand" Content="M 0 4 L 8 4 L 4 0 Z" />
|
||||
<Track Name="PART_Track" Grid.Row="1" IsDirectionReversed="true">
|
||||
<Track.DecreaseRepeatButton>
|
||||
<RepeatButton Visibility="Hidden" Command="ScrollBar.PageUpCommand" />
|
||||
</Track.DecreaseRepeatButton>
|
||||
<Track.Thumb>
|
||||
<Thumb Style="{StaticResource ScrollBarThumb}" Margin="1,0,1,0" Background="Red" BorderBrush="Transparent" />
|
||||
</Track.Thumb>
|
||||
<Track.IncreaseRepeatButton>
|
||||
<RepeatButton Visibility="Hidden" Command="ScrollBar.PageDownCommand" />
|
||||
</Track.IncreaseRepeatButton>
|
||||
</Track>
|
||||
<RepeatButton Grid.Row="3" Height="24" Command="ScrollBar.LineDownCommand" Content="M 0 0 L 4 4 L 8 0 Z"/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}">
|
||||
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Orientation" Value="Horizontal">
|
||||
<Setter Property="Width" Value="Auto"/>
|
||||
<Setter Property="Height" Value="16" />
|
||||
</Trigger>
|
||||
<Trigger Property="Orientation" Value="Vertical">
|
||||
<Setter Property="Width" Value="16"/>
|
||||
<Setter Property="Height" Value="Auto" />
|
||||
<Setter Property="Template" Value="{StaticResource VerticalScrollBar}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="{x:Type ScrollViewer}" TargetType="{x:Type ScrollViewer}">
|
||||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ScrollViewer}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<ScrollContentPresenter Grid.ColumnSpan="2" Grid.RowSpan="2"/>
|
||||
<ScrollBar
|
||||
|
||||
Name="PART_VerticalScrollBar"
|
||||
Grid.Column="1"
|
||||
Value="{TemplateBinding VerticalOffset}"
|
||||
Maximum="{TemplateBinding ScrollableHeight}"
|
||||
ViewportSize="{TemplateBinding ViewportHeight}"
|
||||
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" />
|
||||
<ScrollBar
|
||||
|
||||
Name="PART_HorizontalScrollBar"
|
||||
Orientation="Horizontal"
|
||||
Grid.Row="1"
|
||||
Value="{TemplateBinding HorizontalOffset}"
|
||||
Maximum="{TemplateBinding ScrollableWidth}"
|
||||
ViewportSize="{TemplateBinding ViewportWidth}"
|
||||
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user