mirror of
https://github.com/achiez/NebulaAuth-Steam-Desktop-Authenticator-by-Achies.git
synced 2026-07-26 14:51:42 +00:00
8ff960189e
- Update: Added "Copy Password" to Mafile context menu (if available) - Update: "Save Password" now pre-fills the current password in the "Login Again" dialog when encryption is enabled - Fix: Prevented overlapping confirmation cycles in AutoConfirmer - Fix: Added a Snackbar notification when a confirmation cycle is skipped due to a too frequent timer interval - Fix: Fixed a rare bug where the previous proxy was used instead of the current one during session refresh - Fix: Corrected "Session Permanently Expired" message showing on unrelated errors (e.g. network issues) - UI-Fix: Fixed visual glitch where proxy input appeared non-empty when switching to a mafile-specific proxy - Cleanup: Refactored and cleaned up codebase, improved styling and formatting via ReSharper
81 lines
2.1 KiB
C#
81 lines
2.1 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using System.Windows;
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
// ReSharper disable IdentifierTypo
|
|
|
|
namespace NebulaAuth.Theme.WindowStyle;
|
|
|
|
public static class WindowChromeHelper
|
|
{
|
|
public static Thickness LayoutOffsetThickness =>
|
|
new(0d, 0d, 0d, SystemParameters.WindowResizeBorderThickness.Bottom);
|
|
|
|
/// <summary>
|
|
/// Gets the properly adjusted window resize border thickness from system parameters.
|
|
/// </summary>
|
|
public static Thickness WindowResizeBorderThickness
|
|
{
|
|
get
|
|
{
|
|
var dpix = GetDpi(GetDeviceCapsIndex.LOGPIXELSX);
|
|
var dpiy = GetDpi(GetDeviceCapsIndex.LOGPIXELSY);
|
|
|
|
var dx = GetSystemMetrics(GetSystemMetricsIndex.CXFRAME);
|
|
var dy = GetSystemMetrics(GetSystemMetricsIndex.CYFRAME);
|
|
|
|
// This adjustment is needed since .NET 4.5
|
|
var d = GetSystemMetrics(GetSystemMetricsIndex.SM_CXPADDEDBORDER);
|
|
dx += d;
|
|
dy += d;
|
|
|
|
var leftBorder = dx / dpix;
|
|
var topBorder = dy / dpiy;
|
|
|
|
return new Thickness(leftBorder, topBorder, leftBorder, topBorder);
|
|
}
|
|
}
|
|
|
|
[DllImport("user32.dll")]
|
|
private static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
|
|
|
|
[DllImport("user32.dll")]
|
|
private static extern IntPtr GetDC(IntPtr hwnd);
|
|
|
|
[DllImport("gdi32.dll")]
|
|
private static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
|
|
|
|
private static float GetDpi(GetDeviceCapsIndex index)
|
|
{
|
|
var desktopWnd = IntPtr.Zero;
|
|
var dc = GetDC(desktopWnd);
|
|
float dpi;
|
|
try
|
|
{
|
|
dpi = GetDeviceCaps(dc, (int) index);
|
|
}
|
|
finally
|
|
{
|
|
ReleaseDC(desktopWnd, dc);
|
|
}
|
|
|
|
return dpi / 96f;
|
|
}
|
|
|
|
[DllImport("user32.dll")]
|
|
private static extern int GetSystemMetrics(GetSystemMetricsIndex nIndex);
|
|
|
|
private enum GetDeviceCapsIndex
|
|
{
|
|
LOGPIXELSX = 88,
|
|
LOGPIXELSY = 90
|
|
}
|
|
|
|
private enum GetSystemMetricsIndex
|
|
{
|
|
CXFRAME = 32,
|
|
CYFRAME = 33,
|
|
SM_CXPADDEDBORDER = 92
|
|
}
|
|
} |