Reenabled Compatibility-Mode thumbnails back
This reverts commit de7edfa2c1
.
This commit is contained in:
@@ -24,6 +24,8 @@ namespace EveOPreview.Configuration.Implementation
|
||||
this.MinimizeToTray = false;
|
||||
this.ThumbnailRefreshPeriod = 500;
|
||||
|
||||
this.EnableCompatibilityMode = false;
|
||||
|
||||
this.ThumbnailOpacity = 0.5;
|
||||
|
||||
this.EnableClientLayoutTracking = false;
|
||||
@@ -54,6 +56,9 @@ namespace EveOPreview.Configuration.Implementation
|
||||
public bool MinimizeToTray { get; set; }
|
||||
public int ThumbnailRefreshPeriod { get; set; }
|
||||
|
||||
[JsonProperty("CompatibilityMode")]
|
||||
public bool EnableCompatibilityMode { get; set; }
|
||||
|
||||
[JsonProperty("ThumbnailsOpacity")]
|
||||
public double ThumbnailOpacity { get; set; }
|
||||
|
||||
@@ -145,7 +150,8 @@ namespace EveOPreview.Configuration.Implementation
|
||||
// If there is no layout too then use the default one
|
||||
if (this.EnablePerClientThumbnailLayouts && !string.IsNullOrEmpty(activeClient))
|
||||
{
|
||||
if (this.PerClientLayout.TryGetValue(activeClient, out Dictionary<string, Point> layoutSource) && layoutSource.TryGetValue(currentClient, out location))
|
||||
Dictionary<string, Point> layoutSource;
|
||||
if (this.PerClientLayout.TryGetValue(activeClient, out layoutSource) && layoutSource.TryGetValue(currentClient, out location))
|
||||
{
|
||||
return location;
|
||||
}
|
||||
@@ -181,7 +187,8 @@ namespace EveOPreview.Configuration.Implementation
|
||||
|
||||
public ClientLayout GetClientLayout(string currentClient)
|
||||
{
|
||||
this.ClientLayout.TryGetValue(currentClient, out ClientLayout layout);
|
||||
ClientLayout layout;
|
||||
this.ClientLayout.TryGetValue(currentClient, out layout);
|
||||
|
||||
return layout;
|
||||
}
|
||||
@@ -193,7 +200,8 @@ namespace EveOPreview.Configuration.Implementation
|
||||
|
||||
public Keys GetClientHotkey(string currentClient)
|
||||
{
|
||||
if (this.ClientHotkey.TryGetValue(currentClient, out string hotkey))
|
||||
string hotkey;
|
||||
if (this.ClientHotkey.TryGetValue(currentClient, out hotkey))
|
||||
{
|
||||
// Protect from incorrect values
|
||||
object rawValue = (new KeysConverter()).ConvertFromInvariantString(hotkey);
|
||||
|
@@ -8,6 +8,8 @@ namespace EveOPreview.Configuration
|
||||
bool MinimizeToTray { get; set; }
|
||||
int ThumbnailRefreshPeriod { get; set; }
|
||||
|
||||
bool EnableCompatibilityMode { get; set; }
|
||||
|
||||
double ThumbnailOpacity { get; set; }
|
||||
|
||||
bool EnableClientLayoutTracking { get; set; }
|
||||
|
@@ -147,6 +147,7 @@
|
||||
<Compile Include="Services\Interop\DWM_THUMBNAIL_PROPERTIES.cs" />
|
||||
<Compile Include="Services\Interop\DWM_TNP_CONSTANTS.cs" />
|
||||
<Compile Include="Services\Interface\IWindowManager.cs" />
|
||||
<Compile Include="Services\Interop\Gdi32NativeMethods.cs" />
|
||||
<Compile Include="Services\Interop\MARGINS.cs" />
|
||||
<Compile Include="Services\Interop\RECT.cs" />
|
||||
<Compile Include="Configuration\Interface\ClientLayout.cs" />
|
||||
@@ -163,6 +164,9 @@
|
||||
<Compile Include="View\Implementation\StaticThumbnailImage.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="View\Implementation\StaticThumbnailView.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="View\Interface\IThumbnailViewFactory.cs" />
|
||||
<Compile Include="Services\Interface\IThumbnailManager.cs" />
|
||||
<Compile Include="View\Implementation\ThumbnailDescription.cs" />
|
||||
|
@@ -99,6 +99,7 @@ namespace EveOPreview
|
||||
IApplicationController controller = new ApplicationController(container);
|
||||
|
||||
// UI classes
|
||||
controller.RegisterView<StaticThumbnailView, StaticThumbnailView>();
|
||||
controller.RegisterView<LiveThumbnailView, LiveThumbnailView>();
|
||||
|
||||
controller.RegisterView<IMainFormView, MainForm>();
|
||||
|
@@ -89,5 +89,35 @@ namespace EveOPreview.Services.Implementation
|
||||
|
||||
return thumbnail;
|
||||
}
|
||||
|
||||
public Image GetStaticThumbnail(IntPtr source)
|
||||
{
|
||||
var sourceContext = User32NativeMethods.GetDC(source);
|
||||
|
||||
User32NativeMethods.GetClientRect(source, out RECT windowRect);
|
||||
|
||||
var width = windowRect.Right - windowRect.Left;
|
||||
var height = windowRect.Bottom - windowRect.Top;
|
||||
|
||||
// Check if there is anything to make thumbnail of
|
||||
if ((width < WINDOW_SIZE_THRESHOLD) || (height < WINDOW_SIZE_THRESHOLD))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var destContext = Gdi32NativeMethods.CreateCompatibleDC(sourceContext);
|
||||
var bitmap = Gdi32NativeMethods.CreateCompatibleBitmap(sourceContext, width, height);
|
||||
|
||||
var oldBitmap = Gdi32NativeMethods.SelectObject(destContext, bitmap);
|
||||
Gdi32NativeMethods.BitBlt(destContext, 0, 0, width, height, sourceContext, 0, 0, Gdi32NativeMethods.SRCCOPY);
|
||||
Gdi32NativeMethods.SelectObject(destContext, oldBitmap);
|
||||
Gdi32NativeMethods.DeleteDC(destContext);
|
||||
User32NativeMethods.ReleaseDC(source, sourceContext);
|
||||
|
||||
Image image = Image.FromHbitmap(bitmap);
|
||||
Gdi32NativeMethods.DeleteObject(bitmap);
|
||||
|
||||
return image;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace EveOPreview.Services
|
||||
{
|
||||
@@ -15,5 +16,6 @@ namespace EveOPreview.Services
|
||||
bool IsWindowMaximized(IntPtr handle);
|
||||
bool IsWindowMinimized(IntPtr handle);
|
||||
IDwmThumbnail GetLiveThumbnail(IntPtr destination, IntPtr source);
|
||||
Image GetStaticThumbnail(IntPtr source);
|
||||
}
|
||||
}
|
@@ -1,12 +1,28 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Drawing;
|
||||
|
||||
namespace EveOPreview.Services.Interop
|
||||
{
|
||||
static class DwmNativeMethods
|
||||
{
|
||||
[DllImport("dwmapi.dll", PreserveSig = false)]
|
||||
public static extern void DwmEnableBlurBehindWindow(IntPtr hWnd, DWM_BLURBEHIND pBlurBehind);
|
||||
|
||||
[DllImport("dwmapi.dll", PreserveSig = false)]
|
||||
public static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, MARGINS pMargins);
|
||||
|
||||
[DllImport("dwmapi.dll", PreserveSig = false)]
|
||||
public static extern bool DwmIsCompositionEnabled();
|
||||
|
||||
[DllImport("dwmapi.dll", PreserveSig = false)]
|
||||
public static extern void DwmGetColorizationColor(
|
||||
out int pcrColorization,
|
||||
[MarshalAs(UnmanagedType.Bool)]out bool pfOpaqueBlend);
|
||||
|
||||
[DllImport("dwmapi.dll", PreserveSig = false)]
|
||||
public static extern void DwmEnableComposition(bool bEnable);
|
||||
|
||||
[DllImport("dwmapi.dll", PreserveSig = false)]
|
||||
public static extern IntPtr DwmRegisterThumbnail(IntPtr dest, IntPtr source);
|
||||
|
||||
@@ -15,5 +31,8 @@ namespace EveOPreview.Services.Interop
|
||||
|
||||
[DllImport("dwmapi.dll", PreserveSig = false)]
|
||||
public static extern void DwmUpdateThumbnailProperties(IntPtr hThumbnail, DWM_THUMBNAIL_PROPERTIES props);
|
||||
|
||||
[DllImport("dwmapi.dll", PreserveSig = false)]
|
||||
public static extern void DwmQueryThumbnailSourceSize(IntPtr hThumbnail, out Size size);
|
||||
}
|
||||
}
|
28
Eve-O-Preview/Services/Interop/Gdi32NativeMethods.cs
Normal file
28
Eve-O-Preview/Services/Interop/Gdi32NativeMethods.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace EveOPreview.Services.Interop
|
||||
{
|
||||
static class Gdi32NativeMethods
|
||||
{
|
||||
public const int SRCCOPY = 13369376;
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
public static extern IntPtr CreateCompatibleDC(IntPtr hdc);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
public static extern bool DeleteDC(IntPtr hdc);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
public static extern IntPtr CreateCompatibleBitmap(IntPtr hdc, int width, int height);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
public static extern IntPtr SelectObject(IntPtr hdc, IntPtr hObject);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
public static extern bool DeleteObject(IntPtr hObject);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
public static extern bool BitBlt(IntPtr hObject, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hObjectSource, int nXSrc, int nYSrc, int dwRop);
|
||||
}
|
||||
}
|
@@ -14,6 +14,9 @@ namespace EveOPreview.Services.Interop
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
public static extern bool ReleaseCapture();
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
|
||||
|
||||
@@ -23,6 +26,9 @@ namespace EveOPreview.Services.Interop
|
||||
[DllImport("user32.dll")]
|
||||
public static extern int GetWindowRect(IntPtr hWnd, out RECT rect);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool GetClientRect(IntPtr hWnd, out RECT rect);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl);
|
||||
@@ -39,5 +45,14 @@ namespace EveOPreview.Services.Interop
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool IsZoomed(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetWindowDC(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetDC(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hdc);
|
||||
}
|
||||
}
|
70
Eve-O-Preview/View/Implementation/StaticThumbnailView.cs
Normal file
70
Eve-O-Preview/View/Implementation/StaticThumbnailView.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using EveOPreview.Services;
|
||||
|
||||
namespace EveOPreview.View
|
||||
{
|
||||
sealed class StaticThumbnailView : ThumbnailView
|
||||
{
|
||||
#region Private fields
|
||||
private readonly PictureBox _thumbnail;
|
||||
#endregion
|
||||
|
||||
public StaticThumbnailView(IWindowManager windowManager)
|
||||
: base(windowManager)
|
||||
{
|
||||
this._thumbnail = new StaticThumbnailImage
|
||||
{
|
||||
TabStop = false,
|
||||
SizeMode = PictureBoxSizeMode.StretchImage,
|
||||
Location = new Point(0, 0),
|
||||
Size = new Size(this.ClientSize.Width, this.ClientSize.Height)
|
||||
};
|
||||
this.Controls.Add(this._thumbnail);
|
||||
}
|
||||
|
||||
protected override void RefreshThumbnail(bool forceRefresh)
|
||||
{
|
||||
if (!forceRefresh)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var thumbnail = this.WindowManager.GetStaticThumbnail(this.Id);
|
||||
if (thumbnail != null)
|
||||
{
|
||||
var oldImage = this._thumbnail.Image;
|
||||
this._thumbnail.Image = thumbnail;
|
||||
oldImage?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ResizeThumbnail(int baseWidth, int baseHeight, int highlightWidthTop, int highlightWidthRight, int highlightWidthBottom, int highlightWidthLeft)
|
||||
{
|
||||
var left = 0 + highlightWidthLeft;
|
||||
var top = 0 + highlightWidthTop;
|
||||
if (this.IsLocationUpdateRequired(this._thumbnail.Location, left, top))
|
||||
{
|
||||
this._thumbnail.Location = new Point(left, top);
|
||||
}
|
||||
|
||||
var width = baseWidth - highlightWidthLeft - highlightWidthRight;
|
||||
var height = baseHeight - highlightWidthTop - highlightWidthBottom;
|
||||
if (this.IsSizeUpdateRequired(this._thumbnail.Size, width, height))
|
||||
{
|
||||
this._thumbnail.Size = new Size(width, height);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsLocationUpdateRequired(Point currentLocation, int left, int top)
|
||||
{
|
||||
return (currentLocation.X != left) || (currentLocation.Y != top);
|
||||
}
|
||||
|
||||
private bool IsSizeUpdateRequired(Size currentSize, int width, int height)
|
||||
{
|
||||
return (currentSize.Width != width) || (currentSize.Height != height);
|
||||
}
|
||||
}
|
||||
}
|
@@ -7,15 +7,19 @@ namespace EveOPreview.View
|
||||
sealed class ThumbnailViewFactory : IThumbnailViewFactory
|
||||
{
|
||||
private readonly IApplicationController _controller;
|
||||
private readonly bool _isCompatibilityModeEnabled;
|
||||
|
||||
public ThumbnailViewFactory(IApplicationController controller, IThumbnailConfiguration configuration)
|
||||
{
|
||||
this._controller = controller;
|
||||
this._isCompatibilityModeEnabled = configuration.EnableCompatibilityMode;
|
||||
}
|
||||
|
||||
public IThumbnailView Create(IntPtr id, string title, Size size)
|
||||
{
|
||||
IThumbnailView view = this._controller.Create<LiveThumbnailView>();
|
||||
IThumbnailView view = this._isCompatibilityModeEnabled
|
||||
? (IThumbnailView)this._controller.Create<StaticThumbnailView>()
|
||||
: (IThumbnailView)this._controller.Create<LiveThumbnailView>();
|
||||
|
||||
view.Id = id;
|
||||
view.Title = title;
|
||||
|
@@ -91,6 +91,7 @@ Some of the application options are not exposed in the GUI. They can be adjusted
|
||||
| Option | Description |
|
||||
| --- | --- |
|
||||
| **ActiveClientHighlightThickness** | Thickness of the border used to highlight the active client's thumbnail.<br />Allowed values are **1**...**6**.<br />The default value is **3**<br />For example: **"ActiveClientHighlightThickness": 3** |
|
||||
| **CompatibilityMode** | Enables the alternative render mode (see below)<br />The default value is **false**<br />For example: **"CompatibilityMode": true** |
|
||||
| **EnableThumbnailSnap** | Allows to disable thumbnails snap feature by setting its value to **false**<br />The default value is **true**<br />For example: **"EnableThumbnailSnap": true** |
|
||||
| **PriorityClients** | Allows to set a list of clients that are not auto-minimized on inactivity even if the **Minimize inactive EVE clients** option is enabled. Listed clients still can be minimized using Windows hotkeys or via _Ctrl+Click_ on the corresponding thumbnail<br />The default value is empty list **[]**<br />For example: **"PriorityClients": [ "EVE - Phrynohyas Tig-Rah", "EVE - Ondatra Patrouette" ]** |
|
||||
| **ThumbnailMinimumSize** | Minimum thumbnail size that can be set either via GUI or by resizing a thumbnail window. Value is written in the form "width, height"<br />The default value is **"100, 80"**.<br />For example: **"ThumbnailMinimumSize": "100, 80"** |
|
||||
@@ -124,6 +125,14 @@ The following hotkey is described as `modifier+key` where `modifier` can be **Co
|
||||
|
||||
**Note:** Do not set hotkeys to use the key combinations already used by EVE. It won't work as "_I set hotkey for my DPS char to F1 and when I'll press F1 it will automatically open the DPS char's window and activate guns_". Key combination will be swallowed by EVE-O Preview and NOT retranslated to EVE window. So it will be only "_it will automatically open the DPS char's window_".
|
||||
|
||||
## Compatibility Mode
|
||||
|
||||
This setting allows to enable an alternate thumbnail render. This render doesn't use advanced DWM API to create live previews. Instead it is a screenshot-based render with the following pros and cons:
|
||||
* `+` Should work even in remote desktop environments
|
||||
* `-` Consumes significantly more memory. In the testing environment EVE-O Preview did consume around 180 MB to manage 3 thumbnails using this render. At the same time the primary render did consume around 50 MB when run in the same environment.
|
||||
* `-` Thumbnail images are refreshed at 1 FPS rate
|
||||
* `-` Possible short mouse cursor freezes
|
||||
|
||||
---
|
||||
|
||||
# Credits
|
||||
|
Reference in New Issue
Block a user