From 18ee6ecf80f670c9bcd0801fdaeccde7ad9c0dfc Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Thu, 20 Feb 2014 21:46:23 +0800 Subject: [PATCH] fix some small UI issue --- Wox/MainWindow.xaml.cs | 28 ++++++----- Wox/ResultItem.xaml | 26 ---------- Wox/ResultItem.xaml.cs | 105 ---------------------------------------- Wox/ResultPanel.xaml | 8 +-- Wox/ResultPanel.xaml.cs | 5 +- Wox/Themes/Default.xaml | 26 +++++++--- Wox/Themes/Light.xaml | 35 ++++++++------ Wox/Wox.csproj | 7 --- 8 files changed, 63 insertions(+), 177 deletions(-) delete mode 100644 Wox/ResultItem.xaml delete mode 100644 Wox/ResultItem.xaml.cs diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index bd3702c066..01e0a65a2c 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -28,6 +28,8 @@ namespace Wox private NotifyIcon notifyIcon; Storyboard progressBarStoryboard = new Storyboard(); private bool queryHasReturn = false; + private static object locker = new object(); + private static List waitShowResultList = new List(); private KeyboardListener keyboardListener = new KeyboardListener(); private bool WinRStroked = false; @@ -51,12 +53,7 @@ namespace Wox SetTheme(CommonStorage.Instance.UserSetting.Theme = "Default"); } - this.Closing += MainWindow_Closing; - } - - void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) - { - e.Cancel = true; + Plugins.Init(); } private void WakeupApp() @@ -203,8 +200,7 @@ namespace Wox Left = (SystemParameters.PrimaryScreenWidth - ActualWidth) / 2; Top = (SystemParameters.PrimaryScreenHeight - ActualHeight) / 3; - WakeupApp(); - Plugins.Init(); + //WakeupApp(); keyboardListener.hookedKeyboardCallback += KListener_hookedKeyboardCallback; } @@ -293,13 +289,22 @@ namespace Wox { 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; - List l = list.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == tbQuery.Text).ToList(); + + List l = waitShowResultList.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == tbQuery.Text).ToList(); + waitShowResultList.Clear(); + resultCtrl.AddResults(l); + Debug.WriteLine("Time:" + (Environment.TickCount - t1) + " Count:" + l.Count); - })); + })), TimeSpan.FromMilliseconds(50)); + } } @@ -327,6 +332,7 @@ namespace Wox public void CloseApp() { notifyIcon.Visible = false; + Close(); Environment.Exit(0); } diff --git a/Wox/ResultItem.xaml b/Wox/ResultItem.xaml deleted file mode 100644 index ea5b63db5b..0000000000 --- a/Wox/ResultItem.xaml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - Title - sub title - - - diff --git a/Wox/ResultItem.xaml.cs b/Wox/ResultItem.xaml.cs deleted file mode 100644 index 7671c70fc2..0000000000 --- a/Wox/ResultItem.xaml.cs +++ /dev/null @@ -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)); - } - } -} diff --git a/Wox/ResultPanel.xaml b/Wox/ResultPanel.xaml index 70406144ec..3e0965699c 100644 --- a/Wox/ResultPanel.xaml +++ b/Wox/ResultPanel.xaml @@ -10,13 +10,13 @@ - - + + - + - + diff --git a/Wox/ResultPanel.xaml.cs b/Wox/ResultPanel.xaml.cs index 10896ccf7f..10413e1648 100644 --- a/Wox/ResultPanel.xaml.cs +++ b/Wox/ResultPanel.xaml.cs @@ -1,9 +1,8 @@ using System.Collections.Generic; -using System.Diagnostics; +using System.Windows; using System.Windows.Controls; using Wox.Helper; using Wox.Plugin; -using Point = System.Windows.Point; namespace Wox { @@ -23,6 +22,7 @@ namespace Wox int position = GetInsertLocation(result.Score); lbResults.Items.Insert(position, result); } + gridContainer.Margin = lbResults.Items.Count > 0 ? new Thickness { Top = 8 } : new Thickness { Top = 0 }; lbResults.UpdateLayout(); SelectFirst(); } @@ -119,6 +119,7 @@ namespace Wox public void Clear() { lbResults.Items.Clear(); + gridContainer.Margin = new Thickness { Top = 0 }; } private void lbResults_SelectionChanged(object sender, SelectionChangedEventArgs e) diff --git a/Wox/Themes/Default.xaml b/Wox/Themes/Default.xaml index 33e17dd46f..b4f0546a4e 100644 --- a/Wox/Themes/Default.xaml +++ b/Wox/Themes/Default.xaml @@ -33,13 +33,25 @@ - diff --git a/Wox/Themes/Light.xaml b/Wox/Themes/Light.xaml index 3fc48c9873..31c6a7c2df 100644 --- a/Wox/Themes/Light.xaml +++ b/Wox/Themes/Light.xaml @@ -23,32 +23,37 @@ + #543BFD + + + diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index 8b6a91e461..103976fc3f 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -138,9 +138,6 @@ ResultPanel.xaml - - ResultItem.xaml - SettingWindow.xaml @@ -168,10 +165,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - Designer MSBuild:Compile