Tab: Now adds Next s Title to tbQuery

This commit is contained in:
Aaron Campf 2014-05-08 14:05:48 -07:00
parent b07d1b027c
commit 0b70c5225d

View File

@ -40,10 +40,11 @@ using Rectangle = System.Drawing.Rectangle;
using TextBox = System.Windows.Controls.TextBox; using TextBox = System.Windows.Controls.TextBox;
using ToolTip = System.Windows.Controls.ToolTip; using ToolTip = System.Windows.Controls.ToolTip;
namespace Wox namespace Wox {
{ public partial class MainWindow {
public partial class MainWindow
{ #region Properties
private static readonly object locker = new object(); private static readonly object locker = new object();
public static bool initialized = false; public static bool initialized = false;
@ -56,8 +57,60 @@ namespace Wox
private bool queryHasReturn; private bool queryHasReturn;
private string lastQuery; private string lastQuery;
private ToolTip toolTip = new ToolTip(); private ToolTip toolTip = new ToolTip();
public MainWindow()
{ private bool isCMDMode = false;
private bool ignoreTextChange = false;
#endregion
#region Public API
public void ChangeQuery(string query, bool requery = false) {
tbQuery.Text = query;
tbQuery.CaretIndex = tbQuery.Text.Length;
if (requery) {
TextBoxBase_OnTextChanged(null, null);
}
}
public void CloseApp() {
notifyIcon.Visible = false;
Close();
Environment.Exit(0);
}
public void HideApp() {
HideWox();
}
public void ShowApp() {
ShowWox();
}
public void ShowMsg(string title, string subTitle, string iconPath) {
var m = new Msg { Owner = GetWindow(this) };
m.Show(title, subTitle, iconPath);
}
public void OpenSettingDialog() {
WindowOpener.Open<SettingWindow>(this);
}
public void ShowCurrentResultItemTooltip(string text) {
toolTip.Content = text;
toolTip.IsOpen = true;
}
public void StartLoadingBar() {
Dispatcher.Invoke(new Action(StartProgress));
}
public void StopLoadingBar() {
Dispatcher.Invoke(new Action(StopProgress));
}
#endregion
public MainWindow() {
InitializeComponent(); InitializeComponent();
initialized = true; initialized = true;
@ -71,12 +124,10 @@ namespace Wox
resultCtrl.OnMouseClickItem += AcceptSelect; resultCtrl.OnMouseClickItem += AcceptSelect;
ThreadPool.SetMaxThreads(30, 10); ThreadPool.SetMaxThreads(30, 10);
try try {
{
SetTheme(UserSettingStorage.Instance.Theme); SetTheme(UserSettingStorage.Instance.Theme);
} }
catch (Exception) catch (Exception) {
{
SetTheme(UserSettingStorage.Instance.Theme = "Dark"); SetTheme(UserSettingStorage.Instance.Theme = "Dark");
} }
@ -88,14 +139,12 @@ namespace Wox
this.Closing += MainWindow_Closing; this.Closing += MainWindow_Closing;
} }
void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
{
this.HideWox(); this.HideWox();
e.Cancel = true; e.Cancel = true;
} }
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) {
{
Left = (SystemParameters.PrimaryScreenWidth - ActualWidth) / 2; Left = (SystemParameters.PrimaryScreenWidth - ActualWidth) / 2;
Top = (SystemParameters.PrimaryScreenHeight - ActualHeight) / 3; Top = (SystemParameters.PrimaryScreenHeight - ActualHeight) / 3;
@ -113,56 +162,44 @@ namespace Wox
WindowIntelopHelper.DisableControlBox(this); WindowIntelopHelper.DisableControlBox(this);
} }
public void SetHotkey(string hotkeyStr, EventHandler<HotkeyEventArgs> action) public void SetHotkey(string hotkeyStr, EventHandler<HotkeyEventArgs> action) {
{
var hotkey = new HotkeyModel(hotkeyStr); var hotkey = new HotkeyModel(hotkeyStr);
try try {
{
HotkeyManager.Current.AddOrReplace(hotkeyStr, hotkey.CharKey, hotkey.ModifierKeys, action); HotkeyManager.Current.AddOrReplace(hotkeyStr, hotkey.CharKey, hotkey.ModifierKeys, action);
} }
catch (Exception) catch (Exception) {
{
MessageBox.Show("Register hotkey: " + hotkeyStr + " failed."); MessageBox.Show("Register hotkey: " + hotkeyStr + " failed.");
} }
} }
public void RemoveHotkey(string hotkeyStr) public void RemoveHotkey(string hotkeyStr) {
{ if (!string.IsNullOrEmpty(hotkeyStr)) {
if (!string.IsNullOrEmpty(hotkeyStr))
{
HotkeyManager.Current.Remove(hotkeyStr); HotkeyManager.Current.Remove(hotkeyStr);
} }
} }
private void SetCustomPluginHotkey() private void SetCustomPluginHotkey() {
{
if (UserSettingStorage.Instance.CustomPluginHotkeys == null) return; if (UserSettingStorage.Instance.CustomPluginHotkeys == null) return;
foreach (CustomPluginHotkey hotkey in UserSettingStorage.Instance.CustomPluginHotkeys) foreach (CustomPluginHotkey hotkey in UserSettingStorage.Instance.CustomPluginHotkeys) {
{
CustomPluginHotkey hotkey1 = hotkey; CustomPluginHotkey hotkey1 = hotkey;
SetHotkey(hotkey.Hotkey, delegate SetHotkey(hotkey.Hotkey, delegate {
{
ShowApp(); ShowApp();
ChangeQuery(hotkey1.ActionKeyword, true); ChangeQuery(hotkey1.ActionKeyword, true);
}); });
} }
} }
private void OnHotkey(object sender, HotkeyEventArgs e) private void OnHotkey(object sender, HotkeyEventArgs e) {
{ if (!IsVisible) {
if (!IsVisible)
{
ShowWox(); ShowWox();
} }
else else {
{
HideWox(); HideWox();
} }
e.Handled = true; e.Handled = true;
} }
private void InitProgressbarAnimation() private void InitProgressbarAnimation() {
{
var da = new DoubleAnimation(progressBar.X2, ActualWidth + 100, new Duration(new TimeSpan(0, 0, 0, 0, 1600))); var da = new DoubleAnimation(progressBar.X2, ActualWidth + 100, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
var da1 = new DoubleAnimation(progressBar.X1, ActualWidth, new Duration(new TimeSpan(0, 0, 0, 0, 1600))); var da1 = new DoubleAnimation(progressBar.X1, ActualWidth, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
Storyboard.SetTargetProperty(da, new PropertyPath("(Line.X2)")); Storyboard.SetTargetProperty(da, new PropertyPath("(Line.X2)"));
@ -174,8 +211,7 @@ namespace Wox
progressBar.BeginStoryboard(progressBarStoryboard); progressBar.BeginStoryboard(progressBarStoryboard);
} }
private void InitialTray() private void InitialTray() {
{
notifyIcon = new NotifyIcon { Text = "Wox", Icon = Properties.Resources.app, Visible = true }; notifyIcon = new NotifyIcon { Text = "Wox", Icon = Properties.Resources.app, Visible = true };
notifyIcon.Click += (o, e) => ShowWox(); notifyIcon.Click += (o, e) => ShowWox();
var open = new MenuItem("Open"); var open = new MenuItem("Open");
@ -188,20 +224,15 @@ namespace Wox
notifyIcon.ContextMenu = new ContextMenu(childen); notifyIcon.ContextMenu = new ContextMenu(childen);
} }
private bool isCMDMode = false; private void TextBoxBase_OnTextChanged(object sender, TextChangedEventArgs e) {
private bool ignoreTextChange = false;
private void TextBoxBase_OnTextChanged(object sender, TextChangedEventArgs e)
{
if (ignoreTextChange) { ignoreTextChange = false; return; } if (ignoreTextChange) { ignoreTextChange = false; return; }
lastQuery = tbQuery.Text; lastQuery = tbQuery.Text;
toolTip.IsOpen = false; toolTip.IsOpen = false;
resultCtrl.Dirty = true; resultCtrl.Dirty = true;
Dispatcher.DelayInvoke("UpdateSearch", Dispatcher.DelayInvoke("UpdateSearch",
o => o => {
{ Dispatcher.DelayInvoke("ClearResults", i => {
Dispatcher.DelayInvoke("ClearResults", i =>
{
// first try to use clear method inside resultCtrl, which is more closer to the add new results // first try to use clear method inside resultCtrl, which is more closer to the add new results
// and this will not bring splash issues.After waiting 30ms, if there still no results added, we // and this will not bring splash issues.After waiting 30ms, if there still no results added, we
// must clear the result. otherwise, it will be confused why the query changed, but the results // must clear the result. otherwise, it will be confused why the query changed, but the results
@ -211,12 +242,9 @@ namespace Wox
var q = new Query(lastQuery); var q = new Query(lastQuery);
CommandFactory.DispatchCommand(q); CommandFactory.DispatchCommand(q);
queryHasReturn = false; queryHasReturn = false;
if (Plugins.HitThirdpartyKeyword(q)) if (Plugins.HitThirdpartyKeyword(q)) {
{ Dispatcher.DelayInvoke("ShowProgressbar", originQuery => {
Dispatcher.DelayInvoke("ShowProgressbar", originQuery => if (!queryHasReturn && originQuery == lastQuery) {
{
if (!queryHasReturn && originQuery == lastQuery)
{
StartProgress(); StartProgress();
} }
}, TimeSpan.FromSeconds(0), lastQuery); }, TimeSpan.FromSeconds(0), lastQuery);
@ -224,36 +252,30 @@ namespace Wox
}, TimeSpan.FromMilliseconds((isCMDMode = tbQuery.Text.StartsWith(">")) ? 0 : 150)); }, TimeSpan.FromMilliseconds((isCMDMode = tbQuery.Text.StartsWith(">")) ? 0 : 150));
} }
private void Border_OnMouseDown(object sender, MouseButtonEventArgs e) private void Border_OnMouseDown(object sender, MouseButtonEventArgs e) {
{
if (e.ChangedButton == MouseButton.Left) DragMove(); if (e.ChangedButton == MouseButton.Left) DragMove();
} }
private void StartProgress() private void StartProgress() {
{
progressBar.Visibility = Visibility.Visible; progressBar.Visibility = Visibility.Visible;
} }
private void StopProgress() private void StopProgress() {
{
progressBar.Visibility = Visibility.Hidden; progressBar.Visibility = Visibility.Hidden;
} }
private void HideWox() private void HideWox() {
{
Hide(); Hide();
} }
private void ShowWox(bool selectAll = true) private void ShowWox(bool selectAll = true) {
{ if (!double.IsNaN(Left) && !double.IsNaN(Top)) {
if (!double.IsNaN(Left) && !double.IsNaN(Top)) var origScreen = Screen.FromRectangle(new Rectangle((int)Left, (int)Top, (int)ActualWidth, (int)ActualHeight));
{
var origScreen = Screen.FromRectangle(new Rectangle((int) Left, (int) Top, (int) ActualWidth, (int) ActualHeight));
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position); var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
var coordX = (Left - origScreen.WorkingArea.Left)/(origScreen.WorkingArea.Width - ActualWidth); var coordX = (Left - origScreen.WorkingArea.Left) / (origScreen.WorkingArea.Width - ActualWidth);
var coordY = (Top - origScreen.WorkingArea.Top)/(origScreen.WorkingArea.Height - ActualHeight); var coordY = (Top - origScreen.WorkingArea.Top) / (origScreen.WorkingArea.Height - ActualHeight);
Left = (screen.WorkingArea.Width - ActualWidth)*coordX + screen.WorkingArea.Left; Left = (screen.WorkingArea.Width - ActualWidth) * coordX + screen.WorkingArea.Left;
Top = (screen.WorkingArea.Height - ActualHeight)*coordY + screen.WorkingArea.Top; Top = (screen.WorkingArea.Height - ActualHeight) * coordY + screen.WorkingArea.Top;
} }
Show(); Show();
@ -263,19 +285,15 @@ namespace Wox
if (selectAll) tbQuery.SelectAll(); if (selectAll) tbQuery.SelectAll();
} }
public void ParseArgs(string[] args) public void ParseArgs(string[] args) {
{ if (args != null && args.Length > 0) {
if (args != null && args.Length > 0) switch (args[0].ToLower()) {
{
switch (args[0].ToLower())
{
case "reloadplugin": case "reloadplugin":
Plugins.Init(); Plugins.Init();
break; break;
case "query": case "query":
if (args.Length > 1) if (args.Length > 1) {
{
string query = args[1]; string query = args[1];
tbQuery.Text = query; tbQuery.Text = query;
tbQuery.SelectAll(); tbQuery.SelectAll();
@ -288,8 +306,7 @@ namespace Wox
case "installplugin": case "installplugin":
var path = args[1]; var path = args[1];
if (!File.Exists(path)) if (!File.Exists(path)) {
{
MessageBox.Show("Plugin " + path + " didn't exist"); MessageBox.Show("Plugin " + path + " didn't exist");
return; return;
} }
@ -299,27 +316,21 @@ namespace Wox
} }
} }
private void MainWindow_OnDeactivated(object sender, EventArgs e) private void MainWindow_OnDeactivated(object sender, EventArgs e) {
{ if (UserSettingStorage.Instance.HideWhenDeactive) {
if (UserSettingStorage.Instance.HideWhenDeactive)
{
HideWox(); HideWox();
} }
} }
private bool KListener_hookedKeyboardCallback(KeyEvent keyevent, int vkcode, SpecialKeyState state) private bool KListener_hookedKeyboardCallback(KeyEvent keyevent, int vkcode, SpecialKeyState state) {
{ if (UserSettingStorage.Instance.ReplaceWinR) {
if (UserSettingStorage.Instance.ReplaceWinR)
{
//todo:need refatoring. move those codes to CMD file or expose events //todo:need refatoring. move those codes to CMD file or expose events
if (keyevent == KeyEvent.WM_KEYDOWN && vkcode == (int)Keys.R && state.WinPressed) if (keyevent == KeyEvent.WM_KEYDOWN && vkcode == (int)Keys.R && state.WinPressed) {
{
WinRStroked = true; WinRStroked = true;
Dispatcher.BeginInvoke(new Action(OnWinRPressed)); Dispatcher.BeginInvoke(new Action(OnWinRPressed));
return false; return false;
} }
if (keyevent == KeyEvent.WM_KEYUP && WinRStroked && vkcode == (int)Keys.LWin) if (keyevent == KeyEvent.WM_KEYUP && WinRStroked && vkcode == (int)Keys.LWin) {
{
WinRStroked = false; WinRStroked = false;
keyboardSimulator.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.CONTROL); keyboardSimulator.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.CONTROL);
return false; return false;
@ -328,11 +339,9 @@ namespace Wox
return true; return true;
} }
private void OnWinRPressed() private void OnWinRPressed() {
{
ShowWox(false); ShowWox(false);
if (!tbQuery.Text.StartsWith(">")) if (!tbQuery.Text.StartsWith(">")) {
{
resultCtrl.Clear(); resultCtrl.Clear();
ChangeQuery(">"); ChangeQuery(">");
} }
@ -341,23 +350,19 @@ namespace Wox
tbQuery.SelectionLength = tbQuery.Text.Length - 1; tbQuery.SelectionLength = tbQuery.Text.Length - 1;
} }
private void updateCmdMode() private void updateCmdMode() {
{
var selected = resultCtrl.AcceptSelect(); var selected = resultCtrl.AcceptSelect();
if (selected != null) if (selected != null) {
{
ignoreTextChange = true; ignoreTextChange = true;
tbQuery.Text = ">" + selected.Title; tbQuery.Text = ">" + selected.Title;
tbQuery.CaretIndex = tbQuery.Text.Length; tbQuery.CaretIndex = tbQuery.Text.Length;
} }
} }
private void TbQuery_OnPreviewKeyDown(object sender, KeyEventArgs e) private void TbQuery_OnPreviewKeyDown(object sender, KeyEventArgs e) {
{
//when alt is pressed, the real key should be e.SystemKey //when alt is pressed, the real key should be e.SystemKey
Key key = (e.Key == Key.System ? e.SystemKey : e.Key); Key key = (e.Key == Key.System ? e.SystemKey : e.Key);
switch (key) switch (key) {
{
case Key.Escape: case Key.Escape:
HideWox(); HideWox();
e.Handled = true; e.Handled = true;
@ -395,21 +400,31 @@ namespace Wox
AcceptSelect(resultCtrl.AcceptSelect()); AcceptSelect(resultCtrl.AcceptSelect());
e.Handled = true; e.Handled = true;
break; break;
case Key.Tab:
var SelectedItem = resultCtrl.lbResults.SelectedItem as Wox.Plugin.Result;
if (SelectedItem != null) {
if (tbQuery.Text.Contains("\\")) {
var index = tbQuery.Text.LastIndexOf("\\");
tbQuery.Text = tbQuery.Text.Remove(index) + "\\";
}
tbQuery.Text += SelectedItem.Title;
tbQuery.CaretIndex = int.MaxValue;
}
e.Handled = true;
break;
} }
} }
private void AcceptSelect(Result result) private void AcceptSelect(Result result) {
{ if (!resultCtrl.Dirty && result != null) {
if (!resultCtrl.Dirty && result != null) if (result.Action != null) {
{ bool hideWindow = result.Action(new ActionContext() {
if (result.Action != null)
{
bool hideWindow = result.Action(new ActionContext()
{
SpecialKeyState = new GlobalHotkey().CheckModifiers() SpecialKeyState = new GlobalHotkey().CheckModifiers()
}); });
if (hideWindow) if (hideWindow) {
{
HideWox(); HideWox();
} }
UserSelectedRecordStorage.Instance.Add(result); UserSelectedRecordStorage.Instance.Add(result);
@ -417,26 +432,21 @@ namespace Wox
} }
} }
public void OnUpdateResultView(List<Result> list) public void OnUpdateResultView(List<Result> list) {
{
if (list == null) return; if (list == null) return;
queryHasReturn = true; queryHasReturn = true;
progressBar.Dispatcher.Invoke(new Action(StopProgress)); progressBar.Dispatcher.Invoke(new Action(StopProgress));
if (list.Count > 0) if (list.Count > 0) {
{
//todo:this should be opened to users, it's their choise to use it or not in thier workflows //todo:this should be opened to users, it's their choise to use it or not in thier workflows
list.ForEach( list.ForEach(
o => o => {
{
if (o.AutoAjustScore) o.Score += UserSelectedRecordStorage.Instance.GetSelectedCount(o); if (o.AutoAjustScore) o.Score += UserSelectedRecordStorage.Instance.GetSelectedCount(o);
}); });
lock (locker) lock (locker) {
{
waitShowResultList.AddRange(list); waitShowResultList.AddRange(list);
} }
Dispatcher.DelayInvoke("ShowResult", k => resultCtrl.Dispatcher.Invoke(new Action(() => Dispatcher.DelayInvoke("ShowResult", k => resultCtrl.Dispatcher.Invoke(new Action(() => {
{
List<Result> l = waitShowResultList.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == lastQuery).ToList(); List<Result> l = waitShowResultList.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == lastQuery).ToList();
waitShowResultList.Clear(); waitShowResultList.Clear();
resultCtrl.AddResults(l); resultCtrl.AddResults(l);
@ -444,17 +454,14 @@ namespace Wox
} }
} }
public void SetTheme(string themeName) public void SetTheme(string themeName) {
{ var dict = new ResourceDictionary {
var dict = new ResourceDictionary
{
Source = new Uri(Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Themes\\" + themeName + ".xaml"), UriKind.Absolute) Source = new Uri(Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Themes\\" + themeName + ".xaml"), UriKind.Absolute)
}; };
Style queryBoxStyle = dict["QueryBoxStyle"] as Style; Style queryBoxStyle = dict["QueryBoxStyle"] as Style;
if (queryBoxStyle != null) if (queryBoxStyle != null) {
{
queryBoxStyle.Setters.Add(new Setter(TextBox.FontFamilyProperty, new FontFamily(UserSettingStorage.Instance.QueryBoxFont))); queryBoxStyle.Setters.Add(new Setter(TextBox.FontFamilyProperty, new FontFamily(UserSettingStorage.Instance.QueryBoxFont)));
queryBoxStyle.Setters.Add(new Setter(TextBox.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(UserSettingStorage.Instance.QueryBoxFontStyle))); queryBoxStyle.Setters.Add(new Setter(TextBox.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(UserSettingStorage.Instance.QueryBoxFontStyle)));
queryBoxStyle.Setters.Add(new Setter(TextBox.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(UserSettingStorage.Instance.QueryBoxFontWeight))); queryBoxStyle.Setters.Add(new Setter(TextBox.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(UserSettingStorage.Instance.QueryBoxFontWeight)));
@ -465,9 +472,7 @@ namespace Wox
Style resultSubItemStyle = dict["ItemSubTitleStyle"] as Style; Style resultSubItemStyle = dict["ItemSubTitleStyle"] as Style;
Style resultItemSelectedStyle = dict["ItemTitleSelectedStyle"] as Style; Style resultItemSelectedStyle = dict["ItemTitleSelectedStyle"] as Style;
Style resultSubItemSelectedStyle = dict["ItemSubTitleSelectedStyle"] as Style; Style resultSubItemSelectedStyle = dict["ItemSubTitleSelectedStyle"] as Style;
if (resultItemStyle != null && resultSubItemStyle != null if (resultItemStyle != null && resultSubItemStyle != null && resultSubItemSelectedStyle != null && resultItemSelectedStyle != null) {
&& resultSubItemSelectedStyle != null && resultItemSelectedStyle != null)
{
Setter fontFamily = new Setter(TextBlock.FontFamilyProperty, new FontFamily(UserSettingStorage.Instance.ResultItemFont)); Setter fontFamily = new Setter(TextBlock.FontFamilyProperty, new FontFamily(UserSettingStorage.Instance.ResultItemFont));
Setter fontStyle = new Setter(TextBlock.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontStyle)); Setter fontStyle = new Setter(TextBlock.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontStyle));
Setter fontWeight = new Setter(TextBlock.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontWeight)); Setter fontWeight = new Setter(TextBlock.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontWeight));
@ -480,87 +485,22 @@ namespace Wox
Application.Current.Resources.MergedDictionaries.Clear(); Application.Current.Resources.MergedDictionaries.Clear();
Application.Current.Resources.MergedDictionaries.Add(dict); Application.Current.Resources.MergedDictionaries.Add(dict);
if (this.AllowsTransparency) this.Opacity = this.AllowsTransparency ? UserSettingStorage.Instance.Opacity : 1;
this.Opacity = UserSettingStorage.Instance.Opacity;
else
this.Opacity = 1;
} }
#region Public API public bool ShellRun(string cmd) {
try {
public void ChangeQuery(string query, bool requery = false)
{
tbQuery.Text = query;
tbQuery.CaretIndex = tbQuery.Text.Length;
if (requery)
{
TextBoxBase_OnTextChanged(null, null);
}
}
public void CloseApp()
{
notifyIcon.Visible = false;
Close();
Environment.Exit(0);
}
public void HideApp()
{
HideWox();
}
public void ShowApp()
{
ShowWox();
}
public void ShowMsg(string title, string subTitle, string iconPath)
{
var m = new Msg { Owner = GetWindow(this) };
m.Show(title, subTitle, iconPath);
}
public void OpenSettingDialog()
{
WindowOpener.Open<SettingWindow>(this);
}
public void ShowCurrentResultItemTooltip(string text)
{
toolTip.Content = text;
toolTip.IsOpen = true;
}
public void StartLoadingBar()
{
Dispatcher.Invoke(new Action(StartProgress));
}
public void StopLoadingBar()
{
Dispatcher.Invoke(new Action(StopProgress));
}
#endregion
public bool ShellRun(string cmd)
{
try
{
if (string.IsNullOrEmpty(cmd)) if (string.IsNullOrEmpty(cmd))
throw new ArgumentNullException(); throw new ArgumentNullException();
Wox.Infrastructure.WindowsShellRun.Start(cmd); Wox.Infrastructure.WindowsShellRun.Start(cmd);
return true; return true;
} }
catch (Exception ex) catch (Exception ex) {
{
ShowMsg("Could not start " + cmd, ex.Message, null); ShowMsg("Could not start " + cmd, ex.Message, null);
} }
return false; return false;
} }
} }
} }