diff --git a/Constant/SearchType.cs b/Constant/SearchType.cs
new file mode 100644
index 0000000..994125a
--- /dev/null
+++ b/Constant/SearchType.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GeekDesk.Constant
+{
+ public enum SearchType
+ {
+ HOT_KEY = 0, //快捷键
+ KEY_DOWN = 1, //按下即搜
+ }
+}
diff --git a/Converts/SearchTypeConvert.cs b/Converts/SearchTypeConvert.cs
new file mode 100644
index 0000000..cac62c1
--- /dev/null
+++ b/Converts/SearchTypeConvert.cs
@@ -0,0 +1,25 @@
+using GeekDesk.Constant;
+using System;
+using System.Globalization;
+using System.Windows.Data;
+
+namespace GeekDesk.Converts
+{
+ public class SearchTypeConvert : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return (SearchType)value == (SearchType)int.Parse(parameter.ToString());
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ bool isChecked = (bool)value;
+ if (!isChecked)
+ {
+ return null;
+ }
+ return (SearchType)int.Parse(parameter.ToString());
+ }
+ }
+}
diff --git a/GeekDesk.csproj b/GeekDesk.csproj
index 677a1d9..6162e6b 100644
--- a/GeekDesk.csproj
+++ b/GeekDesk.csproj
@@ -147,6 +147,7 @@
+
@@ -222,6 +223,7 @@
+
@@ -248,6 +250,7 @@
+
diff --git a/MainWindow.xaml b/MainWindow.xaml
index 65f0483..6625a21 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -29,7 +29,7 @@
-
+
@@ -41,10 +41,10 @@
-
+
-
+
@@ -132,11 +132,10 @@
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index b4ae315..c26eee1 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -59,11 +59,19 @@ namespace GeekDesk
///
///
///
- private void SearchItem(object sender, CanExecuteRoutedEventArgs e)
+ private void SearchHotKeyDown(object sender, CanExecuteRoutedEventArgs e)
+ {
+ if (appData.AppConfig.SearchType == SearchType.HOT_KEY)
+ {
+ ShowSearchBox();
+ }
+ }
+
+ private void ShowSearchBox()
{
RunTimeStatus.SEARCH_BOX_SHOW = true;
RightCard.VisibilitySearchCard(Visibility.Visible);
- SearchBox.Visibility = Visibility.Visible;
+ SearchBox.Width = 400;
SearchBox.Focus();
}
///
@@ -73,6 +81,14 @@ namespace GeekDesk
///
private void SearchBox_TextChanged(object sender, TextChangedEventArgs e)
{
+ if (!RunTimeStatus.SEARCH_BOX_SHOW && appData.AppConfig.SearchType != SearchType.KEY_DOWN)
+ {
+ SearchBox.Text = "";
+ return;
+ }
+
+ if (!RunTimeStatus.SEARCH_BOX_SHOW) ShowSearchBox();
+
string inputText = SearchBox.Text.ToLower();
RightCard.VerticalUFG.Visibility = Visibility.Collapsed;
if (!string.IsNullOrEmpty(inputText))
@@ -102,7 +118,8 @@ namespace GeekDesk
public void HidedSearchBox()
{
RunTimeStatus.SEARCH_BOX_SHOW = false;
- SearchBox.Visibility = Visibility.Collapsed;
+ SearchBox.Width = 0;
+ App.DoEvents();
SearchIconList.IconList.Clear();
RightCard.VisibilitySearchCard(Visibility.Collapsed);
SearchBox.Text = "";
@@ -190,9 +207,8 @@ namespace GeekDesk
{
try
{
- if (appData.AppConfig.HotkeyModifiers != 0)
+ if (appData.AppConfig.HotkeyModifiers != GlobalHotKey.HotkeyModifiers.None)
{
-
hotKeyId = GlobalHotKey.RegisterHotKey(appData.AppConfig.HotkeyModifiers, appData.AppConfig.Hotkey, () =>
{
if (MotionControl.hotkeyFinished)
@@ -211,6 +227,8 @@ namespace GeekDesk
{
HandyControl.Controls.Growl.Success("GeekDesk快捷键注册成功(" + appData.AppConfig.HotkeyStr + ")!", "HotKeyGrowl");
}
+ } else
+ {
}
}
catch (Exception)
@@ -237,7 +255,7 @@ namespace GeekDesk
try
{
- if (appData.AppConfig.ToDoHotkeyModifiers != 0)
+ if (appData.AppConfig.HotkeyModifiers != GlobalHotKey.HotkeyModifiers.None)
{
//加载完毕注册热键
toDoHotKeyId = GlobalHotKey.RegisterHotKey(appData.AppConfig.ToDoHotkeyModifiers, appData.AppConfig.ToDoHotkey, () =>
@@ -274,7 +292,7 @@ namespace GeekDesk
{
try
{
- if (appData.AppConfig.ColorPickerHotkeyModifiers != 0)
+ if (appData.AppConfig.HotkeyModifiers != GlobalHotKey.HotkeyModifiers.None)
{
//加载完毕注册热键
colorPickerHotKeyId = GlobalHotKey.RegisterHotKey(appData.AppConfig.ColorPickerHotkeyModifiers, appData.AppConfig.ColorPickerHotkey, () =>
@@ -363,14 +381,7 @@ namespace GeekDesk
///
private void CloseButtonClick(object sender, RoutedEventArgs e)
{
- if (appData.AppConfig.AppAnimation)
- {
- FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
- }
- else
- {
- this.Visibility = Visibility.Collapsed;
- }
+ HideApp();
}
@@ -422,7 +433,7 @@ namespace GeekDesk
FadeStoryBoard(1, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Visible);
- Keyboard.Focus(mainWindow.EmptyTextBox);
+ Keyboard.Focus(mainWindow.SearchBox);
}
public static void HideApp()
@@ -432,17 +443,7 @@ namespace GeekDesk
if (RunTimeStatus.SEARCH_BOX_SHOW)
{
mainWindow.HidedSearchBox();
-
- Thread t = new Thread(() =>
- {
- Thread.Sleep(100);
- App.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
- }));
- });
- t.IsBackground = true;
- t.Start();
+ FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
}
else
{
@@ -656,12 +657,26 @@ namespace GeekDesk
public void OnKeyDown(object sender, KeyEventArgs e)
{
+ char c = (char)e.Key;
+
if (e.Key == Key.Escape)
{
HideApp();
}
+ //else if (
+ // appData.AppConfig.SearchType == SearchType.KEY_DOWN &&
+ // (
+ // (e.Key >= Key.D0 && e.Key <= Key.Z)
+ // || (e.Key >= Key.NumPad0 && e.Key < Key.NumPad9)
+ // )
+ // )
+ //{
+ // ShowSearchBox();
+ //}
}
+
+
///
/// 为了让修改菜单的textBox失去焦点
///
@@ -669,7 +684,7 @@ namespace GeekDesk
///
private void MainWindow_MouseDown(object sender, MouseButtonEventArgs e)
{
- EmptyTextBox.Focus();
+ SearchBox.Focus();
}
///