142: Add a mouse action to switch out to the last used external app
This commit is contained in:
@@ -32,6 +32,7 @@ namespace EveOPreview.Services
|
|||||||
private readonly Dictionary<IntPtr, IThumbnailView> _thumbnailViews;
|
private readonly Dictionary<IntPtr, IThumbnailView> _thumbnailViews;
|
||||||
|
|
||||||
private (IntPtr Handle, string Title) _activeClient;
|
private (IntPtr Handle, string Title) _activeClient;
|
||||||
|
private IntPtr _externalApplication;
|
||||||
|
|
||||||
private readonly object _locationChangeNotificationSyncRoot;
|
private readonly object _locationChangeNotificationSyncRoot;
|
||||||
private (IntPtr Handle, string Title, string ActiveClient, Point Location, int Delay) _enqueuedLocationChangeNotification;
|
private (IntPtr Handle, string Title, string ActiveClient, Point Location, int Delay) _enqueuedLocationChangeNotification;
|
||||||
@@ -181,6 +182,9 @@ namespace EveOPreview.Services
|
|||||||
IntPtr foregroundWindowHandle = this._windowManager.GetForegroundWindowHandle();
|
IntPtr foregroundWindowHandle = this._windowManager.GetForegroundWindowHandle();
|
||||||
string foregroundWindowTitle = null;
|
string foregroundWindowTitle = null;
|
||||||
|
|
||||||
|
// Check if the foreground window handle is one of the known handles for client windows or their thumbnails
|
||||||
|
bool isClientWindow = this.IsClientWindowActive(foregroundWindowHandle);
|
||||||
|
|
||||||
if (foregroundWindowHandle == this._activeClient.Handle)
|
if (foregroundWindowHandle == this._activeClient.Handle)
|
||||||
{
|
{
|
||||||
foregroundWindowTitle = this._activeClient.Title;
|
foregroundWindowTitle = this._activeClient.Title;
|
||||||
@@ -190,6 +194,10 @@ namespace EveOPreview.Services
|
|||||||
// This code will work only on Alt+Tab switch between clients
|
// This code will work only on Alt+Tab switch between clients
|
||||||
foregroundWindowTitle = foregroundView.Title;
|
foregroundWindowTitle = foregroundView.Title;
|
||||||
}
|
}
|
||||||
|
else if (!isClientWindow)
|
||||||
|
{
|
||||||
|
this._externalApplication = foregroundWindowHandle;
|
||||||
|
}
|
||||||
|
|
||||||
// No need to minimize EVE clients when switching out to non-EVE window (like thumbnail)
|
// No need to minimize EVE clients when switching out to non-EVE window (like thumbnail)
|
||||||
if (!string.IsNullOrEmpty(foregroundWindowTitle))
|
if (!string.IsNullOrEmpty(foregroundWindowTitle))
|
||||||
@@ -197,7 +205,7 @@ namespace EveOPreview.Services
|
|||||||
this.SwitchActiveClient(foregroundWindowHandle, foregroundWindowTitle);
|
this.SwitchActiveClient(foregroundWindowHandle, foregroundWindowTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hideAllThumbnails = this._configuration.HideThumbnailsOnLostFocus && !this.IsClientWindowActive(foregroundWindowHandle);
|
bool hideAllThumbnails = this._configuration.HideThumbnailsOnLostFocus && !isClientWindow;
|
||||||
|
|
||||||
this._refreshCycleCount++;
|
this._refreshCycleCount++;
|
||||||
|
|
||||||
@@ -324,10 +332,10 @@ namespace EveOPreview.Services
|
|||||||
this._ignoreViewEvents = true;
|
this._ignoreViewEvents = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SwitchActiveClient(IntPtr foregroungClientHandle, string foregroundClientTitle)
|
private void SwitchActiveClient(IntPtr foregroundClientHandle, string foregroundClientTitle)
|
||||||
{
|
{
|
||||||
// Check if any actions are needed
|
// Check if any actions are needed
|
||||||
if (this._activeClient.Handle == foregroungClientHandle)
|
if (this._activeClient.Handle == foregroundClientHandle)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -338,7 +346,7 @@ namespace EveOPreview.Services
|
|||||||
this._windowManager.MinimizeWindow(this._activeClient.Handle, false);
|
this._windowManager.MinimizeWindow(this._activeClient.Handle, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._activeClient = (foregroungClientHandle, foregroundClientTitle);
|
this._activeClient = (foregroundClientHandle, foregroundClientTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ThumbnailViewFocused(IntPtr id)
|
private void ThumbnailViewFocused(IntPtr id)
|
||||||
@@ -398,15 +406,22 @@ namespace EveOPreview.Services
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ThumbnailDeactivated(IntPtr id)
|
private void ThumbnailDeactivated(IntPtr id, bool switchOut)
|
||||||
{
|
{
|
||||||
if (!this._thumbnailViews.TryGetValue(id, out IThumbnailView view))
|
if (switchOut)
|
||||||
{
|
{
|
||||||
return;
|
this._windowManager.ActivateWindow(this._externalApplication);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!this._thumbnailViews.TryGetValue(id, out IThumbnailView view))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._windowManager.MinimizeWindow(view.Id, true);
|
this._windowManager.MinimizeWindow(view.Id, true);
|
||||||
this.RefreshThumbnails();
|
this.RefreshThumbnails();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void ThumbnailViewResized(IntPtr id)
|
private async void ThumbnailViewResized(IntPtr id)
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ namespace EveOPreview.View
|
|||||||
|
|
||||||
public Action<IntPtr> ThumbnailActivated { get; set; }
|
public Action<IntPtr> ThumbnailActivated { get; set; }
|
||||||
|
|
||||||
public Action<IntPtr> ThumbnailDeactivated { get; set; }
|
public Action<IntPtr, bool> ThumbnailDeactivated { get; set; }
|
||||||
|
|
||||||
public new void Show()
|
public new void Show()
|
||||||
{
|
{
|
||||||
@@ -159,7 +159,7 @@ namespace EveOPreview.View
|
|||||||
|
|
||||||
// Overlay opacity settings
|
// Overlay opacity settings
|
||||||
// Of the thumbnail's opacity is almost full then set the overlay's one to
|
// Of the thumbnail's opacity is almost full then set the overlay's one to
|
||||||
// full. Otherwise set it to half of the thumnail opacity
|
// full. Otherwise set it to half of the thumbnail opacity
|
||||||
// Opacity value is stored even if the overlay is not displayed atm
|
// Opacity value is stored even if the overlay is not displayed atm
|
||||||
this._overlay.Opacity = this.Opacity > 0.9 ? 1.0 : 1.0 - (1.0 - this.Opacity) / 2;
|
this._overlay.Opacity = this.Opacity > 0.9 ? 1.0 : 1.0 - (1.0 - this.Opacity) / 2;
|
||||||
}
|
}
|
||||||
@@ -231,7 +231,7 @@ namespace EveOPreview.View
|
|||||||
|
|
||||||
// First change size, THEN move the window
|
// First change size, THEN move the window
|
||||||
// Otherwise there is a chance to fail in a loop
|
// Otherwise there is a chance to fail in a loop
|
||||||
// Zoom requied -> Moved the windows 1st -> Focus is lost -> Window is moved back -> Focus is back on -> Zoom required -> ...
|
// Zoom required -> Moved the windows 1st -> Focus is lost -> Window is moved back -> Focus is back on -> Zoom required -> ...
|
||||||
this.MaximumSize = new Size(0, 0);
|
this.MaximumSize = new Size(0, 0);
|
||||||
this.Size = new Size(newWidth, newHeight);
|
this.Size = new Size(newWidth, newHeight);
|
||||||
|
|
||||||
@@ -439,7 +439,12 @@ namespace EveOPreview.View
|
|||||||
{
|
{
|
||||||
if (Control.ModifierKeys == Keys.Control)
|
if (Control.ModifierKeys == Keys.Control)
|
||||||
{
|
{
|
||||||
this.ThumbnailDeactivated?.Invoke(this.Id);
|
this.ThumbnailDeactivated?.Invoke(this.Id, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (Control.ModifierKeys == (Keys.Control | Keys.Shift))
|
||||||
|
{
|
||||||
|
this.ThumbnailDeactivated?.Invoke(this.Id, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -490,7 +495,7 @@ namespace EveOPreview.View
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Custom Mouse mode
|
#region Custom Mouse mode
|
||||||
// This pair of methods saves/restores certain window propeties
|
// This pair of methods saves/restores certain window properties
|
||||||
// Methods are used to remove the 'Zoom' effect (if any) when the
|
// Methods are used to remove the 'Zoom' effect (if any) when the
|
||||||
// custom resize/move mode is activated
|
// custom resize/move mode is activated
|
||||||
// Methods are kept on this level because moving to the presenter
|
// Methods are kept on this level because moving to the presenter
|
||||||
|
|||||||
@@ -36,6 +36,6 @@ namespace EveOPreview.View
|
|||||||
Action<IntPtr> ThumbnailLostFocus { get; set; }
|
Action<IntPtr> ThumbnailLostFocus { get; set; }
|
||||||
|
|
||||||
Action<IntPtr> ThumbnailActivated { get; set; }
|
Action<IntPtr> ThumbnailActivated { get; set; }
|
||||||
Action<IntPtr> ThumbnailDeactivated { get; set; }
|
Action<IntPtr, bool> ThumbnailDeactivated { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user