mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-17 13:52:40 +00:00
improve ENTER key handle
This commit is contained in:
@@ -24,7 +24,7 @@ namespace QuickLook
|
||||
if (e.Modifiers != Keys.None)
|
||||
return;
|
||||
|
||||
ViewWindowManager.GetInstance().InvokeRoutine(e.KeyCode);
|
||||
ViewWindowManager.GetInstance().InvokeRoutine(e);
|
||||
}
|
||||
|
||||
private void InstallKeyHook(KeyEventHandler handler)
|
||||
|
@@ -42,12 +42,12 @@ namespace QuickLook
|
||||
OpenWithAssocApp();
|
||||
};*/
|
||||
|
||||
buttonOpenWith.Click += (sender, e) => OpenWithAssocApp();
|
||||
buttonOpenWith.Click += (sender, e) => RunAndClose();
|
||||
}
|
||||
|
||||
public ContextObject ContextObject { get; private set; }
|
||||
|
||||
internal void OpenWithAssocApp()
|
||||
internal void RunAndClose()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_path))
|
||||
return;
|
||||
|
@@ -27,40 +27,48 @@ namespace QuickLook
|
||||
_currentMainWindow = _viewWindowTransparentTransparent;
|
||||
}
|
||||
|
||||
internal void InvokeRoutine(Keys key)
|
||||
internal void InvokeRoutine(KeyEventArgs kea)
|
||||
{
|
||||
Debug.WriteLine(key);
|
||||
Debug.WriteLine(kea.KeyCode);
|
||||
|
||||
switch (key)
|
||||
switch (kea.KeyCode)
|
||||
{
|
||||
case Keys.Up:
|
||||
case Keys.Down:
|
||||
case Keys.Left:
|
||||
case Keys.Right:
|
||||
SwitchPreviewToAnotherFile();
|
||||
SwitchPreview(kea);
|
||||
break;
|
||||
case Keys.Space:
|
||||
TogglePreview();
|
||||
TogglePreview(kea);
|
||||
break;
|
||||
case Keys.Escape:
|
||||
ClosePreview(kea, false);
|
||||
break;
|
||||
case Keys.Enter:
|
||||
ClosePreview();
|
||||
ClosePreview(kea, true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void ClosePreview()
|
||||
private void ClosePreview(KeyEventArgs kea, bool runBeforeClose)
|
||||
{
|
||||
if (!WindowHelper.IsFocusedControlExplorerItem() && !WindowHelper.IsFocusedWindowSelf())
|
||||
return;
|
||||
|
||||
if (_currentMainWindow.Visibility == Visibility.Visible)
|
||||
if (_currentMainWindow.Visibility != Visibility.Visible)
|
||||
return;
|
||||
|
||||
if (runBeforeClose)
|
||||
_currentMainWindow.RunAndClose();
|
||||
else
|
||||
_currentMainWindow.BeginHide();
|
||||
kea.Handled = true;
|
||||
}
|
||||
|
||||
private void TogglePreview()
|
||||
private void TogglePreview(KeyEventArgs kea)
|
||||
{
|
||||
if (!WindowHelper.IsFocusedControlExplorerItem() && !WindowHelper.IsFocusedWindowSelf())
|
||||
return;
|
||||
@@ -69,9 +77,10 @@ namespace QuickLook
|
||||
_currentMainWindow.BeginHide();
|
||||
else
|
||||
InvokeViewer(GetCurrentSelection());
|
||||
kea.Handled = true;
|
||||
}
|
||||
|
||||
private void SwitchPreviewToAnotherFile()
|
||||
private void SwitchPreview(KeyEventArgs kea)
|
||||
{
|
||||
if (_currentMainWindow.Visibility != Visibility.Visible)
|
||||
return;
|
||||
@@ -81,6 +90,7 @@ namespace QuickLook
|
||||
|
||||
_currentMainWindow.UnloadPlugin();
|
||||
InvokeViewer(GetCurrentSelection());
|
||||
kea.Handled = false;
|
||||
}
|
||||
|
||||
internal void InvokeViewer(string path)
|
||||
|
Reference in New Issue
Block a user