Fix #162: switch preview when calling from command-line

This commit is contained in:
Paddy Xu
2018-01-20 16:42:07 +02:00
parent 2ba3fcdf6e
commit 5c02a8c9cf
6 changed files with 14 additions and 6 deletions

View File

@@ -134,7 +134,7 @@ namespace QuickLook
private void RemoteCallShowPreview(StartupEventArgs e)
{
PipeServerManager.SendMessage(PipeMessages.Toggle, e.Args.First());
PipeServerManager.SendMessage(PipeMessages.Invoke, e.Args.First());
}
private void RunListener(StartupEventArgs e)

View File

@@ -95,6 +95,7 @@ namespace QuickLook.Helpers
File.WriteAllText(changeLogPath, notes);
PipeServerManager.SendMessage(PipeMessages.Invoke, changeLogPath);
PipeServerManager.SendMessage(PipeMessages.Forget);
}
catch (Exception e)
{

View File

@@ -31,6 +31,7 @@ namespace QuickLook
public const string Switch = "QuickLook.App.PipeMessages.Switch";
public const string Invoke = "QuickLook.App.PipeMessages.Invoke";
public const string Toggle = "QuickLook.App.PipeMessages.Toggle";
public const string Forget = "QuickLook.App.PipeMessages.Forget";
public const string Close = "QuickLook.App.PipeMessages.Close";
public const string Quit = "QuickLook.App.PipeMessages.Quit";
}
@@ -134,6 +135,11 @@ namespace QuickLook
new Action(() => ViewWindowManager.GetInstance().TogglePreview(lParam)),
DispatcherPriority.ApplicationIdle);
return false;
case PipeMessages.Forget:
Application.Current.Dispatcher.BeginInvoke(
new Action(() => ViewWindowManager.GetInstance().ForgetCurrentWindow()),
DispatcherPriority.ApplicationIdle);
return false;
case PipeMessages.Close:
Application.Current.Dispatcher.BeginInvoke(
new Action(() => ViewWindowManager.GetInstance().ClosePreview()),

View File

@@ -75,7 +75,7 @@ namespace QuickLook
public void TogglePreview(string path)
{
if (_viewerWindow.Visibility == Visibility.Visible)
if (_viewerWindow.Visibility == Visibility.Visible && path == _invokedPath)
ClosePreview();
else
InvokePreview(path);
@@ -95,6 +95,8 @@ namespace QuickLook
{
StopFocusMonitor();
_viewerWindow.Pinned = true;
var newWindow = new ViewerWindow
{
Top = _viewerWindow.Top,

View File

@@ -32,12 +32,13 @@ namespace QuickLook
};
private bool _canOldPluginResize;
private bool _pinned;
private bool Pinned
internal bool Pinned
{
get => _pinned;
set
{
_pinned = value;
buttonPin.Tag = "Pin";
OnPropertyChanged();
}
}

View File

@@ -59,9 +59,7 @@ namespace QuickLook
{
if (Pinned)
return;
Pinned = true;
buttonPin.Tag = "Pin";
ViewWindowManager.GetInstance().ForgetCurrentWindow();
};