mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 19:57:57 +01:00
fix some small UI issue
This commit is contained in:
@@ -28,6 +28,8 @@ namespace Wox
|
|||||||
private NotifyIcon notifyIcon;
|
private NotifyIcon notifyIcon;
|
||||||
Storyboard progressBarStoryboard = new Storyboard();
|
Storyboard progressBarStoryboard = new Storyboard();
|
||||||
private bool queryHasReturn = false;
|
private bool queryHasReturn = false;
|
||||||
|
private static object locker = new object();
|
||||||
|
private static List<Result> waitShowResultList = new List<Result>();
|
||||||
|
|
||||||
private KeyboardListener keyboardListener = new KeyboardListener();
|
private KeyboardListener keyboardListener = new KeyboardListener();
|
||||||
private bool WinRStroked = false;
|
private bool WinRStroked = false;
|
||||||
@@ -51,12 +53,7 @@ namespace Wox
|
|||||||
SetTheme(CommonStorage.Instance.UserSetting.Theme = "Default");
|
SetTheme(CommonStorage.Instance.UserSetting.Theme = "Default");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Closing += MainWindow_Closing;
|
Plugins.Init();
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
|
||||||
{
|
|
||||||
e.Cancel = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WakeupApp()
|
private void WakeupApp()
|
||||||
@@ -203,8 +200,7 @@ namespace Wox
|
|||||||
Left = (SystemParameters.PrimaryScreenWidth - ActualWidth) / 2;
|
Left = (SystemParameters.PrimaryScreenWidth - ActualWidth) / 2;
|
||||||
Top = (SystemParameters.PrimaryScreenHeight - ActualHeight) / 3;
|
Top = (SystemParameters.PrimaryScreenHeight - ActualHeight) / 3;
|
||||||
|
|
||||||
WakeupApp();
|
//WakeupApp();
|
||||||
Plugins.Init();
|
|
||||||
|
|
||||||
keyboardListener.hookedKeyboardCallback += KListener_hookedKeyboardCallback;
|
keyboardListener.hookedKeyboardCallback += KListener_hookedKeyboardCallback;
|
||||||
}
|
}
|
||||||
@@ -293,13 +289,22 @@ namespace Wox
|
|||||||
{
|
{
|
||||||
if (o.AutoAjustScore) o.Score += CommonStorage.Instance.UserSelectedRecords.GetSelectedCount(o);
|
if (o.AutoAjustScore) o.Score += CommonStorage.Instance.UserSelectedRecords.GetSelectedCount(o);
|
||||||
});
|
});
|
||||||
resultCtrl.Dispatcher.Invoke(new Action(() =>
|
lock(locker)
|
||||||
|
{
|
||||||
|
waitShowResultList.AddRange(list);
|
||||||
|
}
|
||||||
|
Dispatcher.DelayInvoke("ShowResult", k => resultCtrl.Dispatcher.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
var t1 = Environment.TickCount;
|
var t1 = Environment.TickCount;
|
||||||
List<Result> l = list.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == tbQuery.Text).ToList();
|
|
||||||
|
List<Result> l = waitShowResultList.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == tbQuery.Text).ToList();
|
||||||
|
waitShowResultList.Clear();
|
||||||
|
|
||||||
resultCtrl.AddResults(l);
|
resultCtrl.AddResults(l);
|
||||||
|
|
||||||
Debug.WriteLine("Time:" + (Environment.TickCount - t1) + " Count:" + l.Count);
|
Debug.WriteLine("Time:" + (Environment.TickCount - t1) + " Count:" + l.Count);
|
||||||
}));
|
})), TimeSpan.FromMilliseconds(50));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,6 +332,7 @@ namespace Wox
|
|||||||
public void CloseApp()
|
public void CloseApp()
|
||||||
{
|
{
|
||||||
notifyIcon.Visible = false;
|
notifyIcon.Visible = false;
|
||||||
|
Close();
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
<UserControl x:Class="Wox.ResultItem"
|
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
mc:Ignorable="d"
|
|
||||||
d:DesignWidth="400"
|
|
||||||
x:Name="resultItemControl"
|
|
||||||
Style="{DynamicResource ItemStyle}"
|
|
||||||
Height="50">
|
|
||||||
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5" Cursor="Hand">
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="32"></ColumnDefinition>
|
|
||||||
<ColumnDefinition/>
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<Image x:Name="imgIco" Width="32" Height="32" HorizontalAlignment="Left" ></Image>
|
|
||||||
<Grid Margin="5 0 5 0" Grid.Column="1">
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="*"></RowDefinition>
|
|
||||||
<RowDefinition x:Name="SubTitleRowDefinition"></RowDefinition>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<TextBlock Style="{DynamicResource ItemTitleStyle}" VerticalAlignment="Center" x:Name="tbTitle">Title</TextBlock>
|
|
||||||
<TextBlock Style="{DynamicResource ItemSubTitleStyle}" Grid.Row="1" x:Name="tbSubTitle">sub title</TextBlock>
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
</UserControl>
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.IO;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
using Wox.Annotations;
|
|
||||||
using Wox.Helper;
|
|
||||||
using Wox.Infrastructure;
|
|
||||||
using Wox.Plugin;
|
|
||||||
using Brush = System.Windows.Media.Brush;
|
|
||||||
|
|
||||||
namespace Wox
|
|
||||||
{
|
|
||||||
public partial class ResultItem : UserControl, INotifyPropertyChanged
|
|
||||||
{
|
|
||||||
private bool selected;
|
|
||||||
|
|
||||||
public Result Result { get; private set; }
|
|
||||||
|
|
||||||
public bool Selected
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return selected;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
selected = value;
|
|
||||||
OnPropertyChanged("Selected");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResultItem(Result result)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
Result = result;
|
|
||||||
|
|
||||||
tbTitle.Text = result.Title;
|
|
||||||
tbSubTitle.Text = result.SubTitle;
|
|
||||||
if (string.IsNullOrEmpty(result.SubTitle))
|
|
||||||
{
|
|
||||||
SubTitleRowDefinition.Height = new GridLength(0);
|
|
||||||
}
|
|
||||||
string path = string.Empty;
|
|
||||||
if (!string.IsNullOrEmpty(result.IcoPath) && result.IcoPath.Contains(":\\") && File.Exists(result.IcoPath))
|
|
||||||
{
|
|
||||||
path = result.IcoPath;
|
|
||||||
}
|
|
||||||
else if (!string.IsNullOrEmpty(result.IcoPath) && File.Exists(result.PluginDirectory + result.IcoPath))
|
|
||||||
{
|
|
||||||
path = result.PluginDirectory + result.IcoPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(path))
|
|
||||||
{
|
|
||||||
if (path.ToLower().EndsWith(".exe") || path.ToLower().EndsWith(".lnk"))
|
|
||||||
{
|
|
||||||
imgIco.Source = GetIcon(path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
imgIco.Source = new BitmapImage(new Uri(path));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AddHandler(MouseLeftButtonUpEvent, new RoutedEventHandler((o, e) =>
|
|
||||||
{
|
|
||||||
if (Result.Action != null)
|
|
||||||
Result.Action(new ActionContext()
|
|
||||||
{
|
|
||||||
SpecialKeyState = new KeyboardListener().CheckModifiers()
|
|
||||||
});
|
|
||||||
|
|
||||||
CommonStorage.Instance.UserSelectedRecords.Add(result);
|
|
||||||
if (!result.DontHideWoxAfterSelect)
|
|
||||||
{
|
|
||||||
App.Window.HideApp();
|
|
||||||
}
|
|
||||||
e.Handled = true;
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ImageSource GetIcon(string fileName)
|
|
||||||
{
|
|
||||||
Icon icon = Icon.ExtractAssociatedIcon(fileName);
|
|
||||||
return System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(
|
|
||||||
icon.Handle,
|
|
||||||
new Int32Rect(0, 0, icon.Width, icon.Height),
|
|
||||||
BitmapSizeOptions.FromEmptyOptions());
|
|
||||||
}
|
|
||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
|
||||||
|
|
||||||
[NotifyPropertyChangedInvocator]
|
|
||||||
protected virtual void OnPropertyChanged(string propertyName)
|
|
||||||
{
|
|
||||||
PropertyChangedEventHandler handler = PropertyChanged;
|
|
||||||
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,13 +10,13 @@
|
|||||||
<wox:ImagePathConverter x:Key="ImagePathConverter"/>
|
<wox:ImagePathConverter x:Key="ImagePathConverter"/>
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
|
|
||||||
<Grid>
|
<Grid x:Name="gridContainer">
|
||||||
<ListBox x:Name="lbResults" ScrollViewer.CanContentScroll="False" ScrollViewer.HorizontalScrollBarVisibility="Hidden" SelectionChanged ="lbResults_SelectionChanged" Focusable="False" KeyboardNavigation.DirectionalNavigation="Cycle" SelectionMode="Single" BorderBrush="Transparent" Background="Transparent" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling">
|
<ListBox x:Name="lbResults" Style="{DynamicResource listboxStyle}" SelectionChanged ="lbResults_SelectionChanged" Focusable="False" KeyboardNavigation.DirectionalNavigation="Cycle" SelectionMode="Single" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling">
|
||||||
<ListBox.Resources>
|
<ListBox.Resources>
|
||||||
<!--SelectedItem with focus-->
|
<!--SelectedItem with focus-->
|
||||||
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#4F6180"/>
|
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="{DynamicResource ResultItemHighlightBackgroundColor}"/>
|
||||||
<!--SelectedItem without focus-->
|
<!--SelectedItem without focus-->
|
||||||
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="#4F6180"/>
|
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="{DynamicResource ResultItemHighlightBackgroundColor}"/>
|
||||||
</ListBox.Resources>
|
</ListBox.Resources>
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using Wox.Helper;
|
using Wox.Helper;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
using Point = System.Windows.Point;
|
|
||||||
|
|
||||||
namespace Wox
|
namespace Wox
|
||||||
{
|
{
|
||||||
@@ -23,6 +22,7 @@ namespace Wox
|
|||||||
int position = GetInsertLocation(result.Score);
|
int position = GetInsertLocation(result.Score);
|
||||||
lbResults.Items.Insert(position, result);
|
lbResults.Items.Insert(position, result);
|
||||||
}
|
}
|
||||||
|
gridContainer.Margin = lbResults.Items.Count > 0 ? new Thickness { Top = 8 } : new Thickness { Top = 0 };
|
||||||
lbResults.UpdateLayout();
|
lbResults.UpdateLayout();
|
||||||
SelectFirst();
|
SelectFirst();
|
||||||
}
|
}
|
||||||
@@ -119,6 +119,7 @@ namespace Wox
|
|||||||
public void Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
lbResults.Items.Clear();
|
lbResults.Items.Clear();
|
||||||
|
gridContainer.Margin = new Thickness { Top = 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
private void lbResults_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void lbResults_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
|||||||
@@ -33,13 +33,25 @@
|
|||||||
<Style x:Key="ItemSubTitleStyle" TargetType="{x:Type TextBlock}">
|
<Style x:Key="ItemSubTitleStyle" TargetType="{x:Type TextBlock}">
|
||||||
<Setter Property="Foreground" Value="#D9D9D4" />
|
<Setter Property="Foreground" Value="#D9D9D4" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style x:Key="ItemStyle" TargetType="{x:Type UserControl}">
|
|
||||||
<Setter Property="Background" Value="Transparent" />
|
<Color x:Key="ResultItemHighlightBackgroundColor">#4F6180</Color>
|
||||||
<Style.Triggers>
|
|
||||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Selected}" Value="true">
|
<Style x:Key="listboxStyle" TargetType="{x:Type ListBox}">
|
||||||
<Setter Property="Background" Value="#4F6180" />
|
<Setter Property="BorderBrush" Value="Transparent"/>
|
||||||
</DataTrigger>
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
</Style.Triggers>
|
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||||
|
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||||
|
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
|
||||||
|
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="ListBox">
|
||||||
|
<ScrollViewer Focusable="false" Template="{DynamicResource ScrollViewerControlTemplate}">
|
||||||
|
<StackPanel IsItemsHost="True" />
|
||||||
|
</ScrollViewer>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<!-- ScrollViewer Style -->
|
<!-- ScrollViewer Style -->
|
||||||
|
|||||||
@@ -23,32 +23,37 @@
|
|||||||
<Setter Property="Stroke" Value="Blue"></Setter>
|
<Setter Property="Stroke" Value="Blue"></Setter>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
<Color x:Key="ResultItemHighlightBackgroundColor">#543BFD</Color>
|
||||||
|
|
||||||
<!-- Item Style -->
|
<!-- Item Style -->
|
||||||
<Style x:Key="ItemTitleStyle" TargetType="{x:Type TextBlock}" >
|
<Style x:Key="ItemTitleStyle" TargetType="{x:Type TextBlock}" >
|
||||||
<Setter Property="Foreground" Value="#141411"></Setter>
|
<Setter Property="Foreground" Value="#141411"></Setter>
|
||||||
<Setter Property="FontSize" Value="16"></Setter>
|
<Setter Property="FontSize" Value="16"></Setter>
|
||||||
<Setter Property="FontWeight" Value="Medium"></Setter>
|
<Setter Property="FontWeight" Value="Medium"></Setter>
|
||||||
<Style.Triggers>
|
|
||||||
<DataTrigger Binding="{Binding ElementName=resultItemControl, Path=Selected}" Value="true">
|
|
||||||
<Setter Property="Foreground" Value="#F6F6FF"></Setter>
|
|
||||||
</DataTrigger>
|
|
||||||
</Style.Triggers>
|
|
||||||
</Style>
|
</Style>
|
||||||
<Style x:Key="ItemSubTitleStyle" TargetType="{x:Type TextBlock}" >
|
<Style x:Key="ItemSubTitleStyle" TargetType="{x:Type TextBlock}" >
|
||||||
<Setter Property="Foreground" Value="#B3B2B0"></Setter>
|
<Setter Property="Foreground" Value="#B3B2B0"></Setter>
|
||||||
<Style.Triggers>
|
|
||||||
<DataTrigger Binding="{Binding ElementName=resultItemControl, Path=Selected}" Value="true">
|
|
||||||
<Setter Property="Foreground" Value="#F6F6FF"></Setter>
|
|
||||||
</DataTrigger>
|
|
||||||
</Style.Triggers>
|
|
||||||
</Style>
|
</Style>
|
||||||
<Style x:Key="ItemStyle" TargetType="{x:Type UserControl}" >
|
<Style x:Key="ItemStyle" TargetType="{x:Type UserControl}" >
|
||||||
<Setter Property="Background" Value="Transparent"></Setter>
|
<Setter Property="Background" Value="Transparent"></Setter>
|
||||||
<Style.Triggers>
|
</Style>
|
||||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Selected}" Value="true">
|
|
||||||
<Setter Property="Background" Value="#543BFD"></Setter>
|
<Style x:Key="listboxStyle" TargetType="{x:Type ListBox}">
|
||||||
</DataTrigger>
|
<Setter Property="BorderBrush" Value="Transparent"/>
|
||||||
</Style.Triggers>
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
|
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||||
|
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||||
|
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
|
||||||
|
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="ListBox">
|
||||||
|
<ScrollViewer Focusable="false" Template="{DynamicResource ScrollViewerControlTemplate}">
|
||||||
|
<StackPanel IsItemsHost="True" />
|
||||||
|
</ScrollViewer>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<!-- ScrollViewer Style -->
|
<!-- ScrollViewer Style -->
|
||||||
|
|||||||
@@ -138,9 +138,6 @@
|
|||||||
<Compile Include="ResultPanel.xaml.cs">
|
<Compile Include="ResultPanel.xaml.cs">
|
||||||
<DependentUpon>ResultPanel.xaml</DependentUpon>
|
<DependentUpon>ResultPanel.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="ResultItem.xaml.cs">
|
|
||||||
<DependentUpon>ResultItem.xaml</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="SettingWindow.xaml.cs">
|
<Compile Include="SettingWindow.xaml.cs">
|
||||||
<DependentUpon>SettingWindow.xaml</DependentUpon>
|
<DependentUpon>SettingWindow.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -168,10 +165,6 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="ResultItem.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</Page>
|
|
||||||
<Page Include="SettingWindow.xaml">
|
<Page Include="SettingWindow.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|||||||
Reference in New Issue
Block a user