From 84673f26f344fd6145a6a6529f2b6b94e4c8a32f Mon Sep 17 00:00:00 2001 From: jhdxr Date: Sun, 23 Dec 2018 00:30:31 +0800 Subject: [PATCH 1/5] support user defined theme files in %appdata% (close #1267, #662) --- Wox.Core/Resource/Theme.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Wox.Core/Resource/Theme.cs b/Wox.Core/Resource/Theme.cs index 99e5d89e2..7343a7b90 100644 --- a/Wox.Core/Resource/Theme.cs +++ b/Wox.Core/Resource/Theme.cs @@ -22,10 +22,12 @@ namespace Wox.Core.Resource private const string Folder = "Themes"; private const string Extension = ".xaml"; private string DirectoryPath => Path.Combine(Constant.ProgramDirectory, Folder); + private string UserDirectoryPath => Path.Combine(Constant.DataDirectory, Folder); public Theme() { _themeDirectories.Add(DirectoryPath); + _themeDirectories.Add(UserDirectoryPath); MakesureThemeDirectoriesExist(); var dicts = Application.Current.Resources.MergedDictionaries; @@ -94,6 +96,7 @@ namespace Wox.Core.Resource if (_oldTheme != theme) { dicts.Remove(_oldResource); + //fixme if something goes wrong here var newResource = GetResourceDictionary(); dicts.Add(newResource); _oldResource = newResource; From 580c2b9e845938607747a3f48a67509d4d90826f Mon Sep 17 00:00:00 2001 From: jhdxr Date: Sun, 23 Dec 2018 00:44:07 +0800 Subject: [PATCH 2/5] use Pack URIs for Base.xaml (as a demo for 3rd party themes) --- Wox/Themes/BlurBlack.xaml | 2 +- Wox/Themes/BlurWhite.xaml | 2 +- Wox/Themes/Dark.xaml | 2 +- Wox/Themes/Gray.xaml | 2 +- Wox/Themes/Light.xaml | 2 +- Wox/Themes/Metro Server.xaml | 2 +- Wox/Themes/Pink.xaml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Wox/Themes/BlurBlack.xaml b/Wox/Themes/BlurBlack.xaml index ebd1ef0df..488048cf4 100644 --- a/Wox/Themes/BlurBlack.xaml +++ b/Wox/Themes/BlurBlack.xaml @@ -2,7 +2,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib"> - + True diff --git a/Wox/Themes/BlurWhite.xaml b/Wox/Themes/BlurWhite.xaml index 4c52ee4d3..2fe9e3185 100644 --- a/Wox/Themes/BlurWhite.xaml +++ b/Wox/Themes/BlurWhite.xaml @@ -2,7 +2,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib"> - + True diff --git a/Wox/Themes/Dark.xaml b/Wox/Themes/Dark.xaml index 9ef1609b2..5bd54b0ed 100644 --- a/Wox/Themes/Dark.xaml +++ b/Wox/Themes/Dark.xaml @@ -2,7 +2,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib"> - + - \ No newline at end of file + diff --git a/Wox/ResultListBox.xaml.cs b/Wox/ResultListBox.xaml.cs index ce6de8afb..d448d02ca 100644 --- a/Wox/ResultListBox.xaml.cs +++ b/Wox/ResultListBox.xaml.cs @@ -1,4 +1,5 @@ using System.Runtime.Remoting.Contexts; +using System.Windows; using System.Windows.Controls; using System.Windows.Input; @@ -7,6 +8,8 @@ namespace Wox [Synchronization] public partial class ResultListBox { + private Point _lastpos; + private ListBoxItem curItem = null; public ResultListBox() { InitializeComponent(); @@ -22,7 +25,26 @@ namespace Wox private void OnMouseEnter(object sender, MouseEventArgs e) { - ((ListBoxItem) sender).IsSelected = true; + curItem = (ListBoxItem)sender; + var p = e.GetPosition((IInputElement)sender); + _lastpos = p; + } + + private void OnMouseMove(object sender, MouseEventArgs e) + { + var p = e.GetPosition((IInputElement)sender); + if (_lastpos != p) + { + ((ListBoxItem) sender).IsSelected = true; + } + } + + private void ListBox_PreviewMouseDown(object sender, MouseButtonEventArgs e) + { + if (curItem != null) + { + curItem.IsSelected = true; + } } } -} \ No newline at end of file +}