Refactoring visibility related events

1. remove unnecessary events from MainViewModel
2. remove usage of Obsolete api (show, hide etc)
3. fix space problem in #660
4. part of #486
5. fix up/down key bug introduced in 92b7ca6a1bafd254e39ee92812ff691906cd85c1
6. fix #678
This commit is contained in:
bao-qian
2016-05-25 01:00:10 +01:00
parent 3aada68eb9
commit 245cffc4f7
14 changed files with 187 additions and 193 deletions

View File

@@ -291,9 +291,7 @@ namespace Wox.ViewModel
}
}
public double Left { get; set; }
public double Top { get; set; }
public bool QueryTextSelected { get; set; }
public Visibility ContextMenuVisibility
@@ -308,7 +306,6 @@ namespace Wox.ViewModel
{
QueryText = _queryTextBeforeLoadContextMenu;
ResultListBoxVisibility = Visibility.Visible;
OnCursorMovedToEnd();
}
else
{
@@ -572,12 +569,11 @@ namespace Wox.ViewModel
if (_settings.CustomPluginHotkeys == null) return;
foreach (CustomPluginHotkey hotkey in _settings.CustomPluginHotkeys)
{
CustomPluginHotkey hotkey1 = hotkey;
SetHotkey(hotkey.Hotkey, delegate
SetHotkey(hotkey.Hotkey, (s, e) =>
{
if (ShouldIgnoreHotkeys()) return;
App.API.ShowApp();
App.API.ChangeQuery(hotkey1.ActionKeyword, true);
QueryText = hotkey.ActionKeyword;
MainWindowVisibility = Visibility.Visible;
});
}
}
@@ -585,6 +581,7 @@ namespace Wox.ViewModel
private void OnHotkey(object sender, HotkeyEventArgs e)
{
if (ShouldIgnoreHotkeys()) return;
QueryTextSelected = true;
ToggleWox();
e.Handled = true;
}
@@ -594,7 +591,6 @@ namespace Wox.ViewModel
if (!MainWindowVisibility.IsVisible())
{
MainWindowVisibility = Visibility.Visible;
OnTextBoxSelected();
}
else
{
@@ -653,19 +649,5 @@ namespace Wox.ViewModel
}
#endregion
public event EventHandler CursorMovedToEnd;
public void OnCursorMovedToEnd()
{
CursorMovedToEnd?.Invoke(this, new EventArgs());
}
public event EventHandler TextBoxSelected;
public void OnTextBoxSelected()
{
TextBoxSelected?.Invoke(this, new EventArgs());
}
}
}