Allow to minimize the client by Crtl+Click on its thumbnail

This commit is contained in:
Anton Kasyanov
2017-06-17 18:45:15 +03:00
parent 1fe2023b51
commit 5277a52bae
4 changed files with 134 additions and 95 deletions

View File

@@ -119,6 +119,10 @@ namespace EveOPreview
public const UInt32 WS_EX_NOACTIVATE = 0x08000000;
public const int WM_SIZE = 5;
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MINIMIZE = 0xf020;
public const int SIZE_RESTORED = 0;
public const int SIZE_MINIMIZED = 1;
public const int SIZE_MAXIMIZED = 2;

View File

@@ -227,6 +227,7 @@ namespace EveOPreview.UI
view.ThumbnailFocused = this.ThumbnailViewFocused;
view.ThumbnailLostFocus = this.ThumbnailViewLostFocus;
view.ThumbnailActivated = this.ThumbnailActivated;
view.ThumbnailDeactivated = this.ThumbnailDeactivated;
view.RegisterHotkey(this._configuration.GetClientHotkey(processTitle));
@@ -353,6 +354,29 @@ namespace EveOPreview.UI
view?.Refresh(true);
}
private void ThumbnailDeactivated(IntPtr id)
{
IThumbnailView view;
this._thumbnailViews.TryGetValue(id, out view);
if (view?.Id == this._activeClientHandle)
{
WindowManagerNativeMethods.SendMessage(view.Id, WindowManagerNativeMethods.WM_SYSCOMMAND, WindowManagerNativeMethods.SC_MINIMIZE, 0);
}
else
{
int style = WindowManagerNativeMethods.GetWindowLong(id, WindowManagerNativeMethods.GWL_STYLE);
// If the window is not already minimized then minimize it
if ((style & WindowManagerNativeMethods.WS_MINIMIZE) != WindowManagerNativeMethods.WS_MINIMIZE)
{
WindowManagerNativeMethods.ShowWindowAsync(id, WindowManagerNativeMethods.SW_SHOWMINIMIZED);
}
}
this.RefreshThumbnails();
}
private void ThumbnailViewResized(IntPtr id)
{
if (this._ignoreViewEvents)

View File

@@ -101,6 +101,8 @@ namespace EveOPreview.UI
public Action<IntPtr> ThumbnailActivated { get; set; }
public Action<IntPtr> ThumbnailDeactivated { get; set; }
public new void Show()
{
base.Show();
@@ -434,9 +436,16 @@ namespace EveOPreview.UI
private void MouseDown_Handler(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
if (Control.ModifierKeys == Keys.Control)
{
this.ThumbnailDeactivated?.Invoke(this.Id);
}
else
{
this.ThumbnailActivated?.Invoke(this.Id);
}
}
if ((e.Button == MouseButtons.Right) || (e.Button == (MouseButtons.Left | MouseButtons.Right)))
{

View File

@@ -35,6 +35,8 @@ namespace EveOPreview.UI
Action<IntPtr> ThumbnailMoved { get; set; }
Action<IntPtr> ThumbnailFocused { get; set; }
Action<IntPtr> ThumbnailLostFocus { get; set; }
Action<IntPtr> ThumbnailActivated { get; set; }
Action<IntPtr> ThumbnailDeactivated { get; set; }
}
}