mirror of
https://github.com/QL-Win/QuickLook.git
synced 2026-02-28 01:00:17 +08:00
switch by arrow keys and by mouse click should repel each other
This commit is contained in:
@@ -17,7 +17,6 @@ namespace QuickLook
|
|||||||
private readonly MainWindowNoTransparent _viewWindowNoTransparent;
|
private readonly MainWindowNoTransparent _viewWindowNoTransparent;
|
||||||
private readonly MainWindowTransparent _viewWindowTransparentTransparent;
|
private readonly MainWindowTransparent _viewWindowTransparentTransparent;
|
||||||
private MainWindowTransparent _currentMainWindow;
|
private MainWindowTransparent _currentMainWindow;
|
||||||
private long _lastSwitchTick;
|
|
||||||
|
|
||||||
private string _path = string.Empty;
|
private string _path = string.Empty;
|
||||||
|
|
||||||
@@ -99,8 +98,6 @@ namespace QuickLook
|
|||||||
|
|
||||||
private void TogglePreview()
|
private void TogglePreview()
|
||||||
{
|
{
|
||||||
_lastSwitchTick = DateTime.Now.Ticks;
|
|
||||||
|
|
||||||
if (_currentMainWindow.Visibility == Visibility.Visible)
|
if (_currentMainWindow.Visibility == Visibility.Visible)
|
||||||
{
|
{
|
||||||
ClosePreview();
|
ClosePreview();
|
||||||
@@ -117,23 +114,25 @@ namespace QuickLook
|
|||||||
if (_currentMainWindow.Visibility != Visibility.Visible)
|
if (_currentMainWindow.Visibility != Visibility.Visible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_lastSwitchTick = DateTime.Now.Ticks;
|
// if the switch has been done by SwitchPreviewRemoteInvoke, we'll not do anything
|
||||||
|
var select = NativeMethods.QuickLook.GetCurrentSelection();
|
||||||
|
if (_path == select)
|
||||||
|
return;
|
||||||
|
|
||||||
_path = NativeMethods.QuickLook.GetCurrentSelection();
|
_path = select;
|
||||||
|
|
||||||
|
Debug.WriteLine($"SwitchPreview: {_path}");
|
||||||
|
|
||||||
InvokeViewer();
|
InvokeViewer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SwitchPreviewRemoteInvoke(HeartbeatEventArgs e)
|
private void SwitchPreviewRemoteInvoke(HeartbeatEventArgs e)
|
||||||
{
|
{
|
||||||
// sleep for 0.6s
|
// if the switch has been done by SwitchPreview, we'll not do anything
|
||||||
if (e.InvokeTick - _lastSwitchTick < 0.6 * TimeSpan.TicksPerSecond)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (e.FocusedFile == _path)
|
if (e.FocusedFile == _path)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Debug.WriteLine("SwitchPreviewRemoteInvoke:" + (e.InvokeTick - _lastSwitchTick));
|
Debug.WriteLine($"SwitchPreviewRemoteInvoke: {e.FocusedFile}");
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(e.FocusedFile))
|
if (string.IsNullOrEmpty(e.FocusedFile))
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user