mirror of
https://github.com/greenshot/greenshot
synced 2025-08-20 05:23:24 -07:00
This should fix most icon scaling issues
Improved the IniReader a bit and replaced some old code.
This commit is contained in:
parent
41baf27d84
commit
4a958be8b5
35 changed files with 2767 additions and 301 deletions
34
GreenshotPlugin/Core/Enums/DialogDpiChangeBehaviors.cs
Normal file
34
GreenshotPlugin/Core/Enums/DialogDpiChangeBehaviors.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
// Copyright (c) Dapplo and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
using System;
|
||||
|
||||
namespace GreenshotPlugin.Core.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// In Per Monitor v2 contexts, dialogs will automatically respond to DPI changes by resizing themselves and re-computing the positions of their child windows (here referred to as re-layouting). This enum works in conjunction with SetDialogDpiChangeBehavior in order to override the default DPI scaling behavior for dialogs.
|
||||
/// This does not affect DPI scaling behavior for the child windows of dialogs(beyond re-layouting), which is controlled by DIALOG_CONTROL_DPI_CHANGE_BEHAVIORS.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum DialogDpiChangeBehaviors
|
||||
{
|
||||
/// <summary>
|
||||
/// The default behavior of the dialog manager. In response to a DPI change, the dialog manager will re-layout each control, update the font on each control, resize the dialog, and update the dialog's own font.
|
||||
/// </summary>
|
||||
Default = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Prevents the dialog manager from responding to WM_GETDPISCALEDSIZE and WM_DPICHANGED, disabling all default DPI scaling behavior.
|
||||
/// </summary>
|
||||
DisableAll = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Prevents the dialog manager from resizing the dialog in response to a DPI change.
|
||||
/// </summary>
|
||||
DisableResize = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Prevents the dialog manager from re-layouting all of the dialogue's immediate children HWNDs in response to a DPI change.
|
||||
/// </summary>
|
||||
DisableControlRelayout = 3
|
||||
}
|
||||
}
|
32
GreenshotPlugin/Core/Enums/DialogScalingBehaviors.cs
Normal file
32
GreenshotPlugin/Core/Enums/DialogScalingBehaviors.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Copyright (c) Dapplo and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
using System;
|
||||
|
||||
namespace GreenshotPlugin.Core.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes per-monitor DPI scaling behavior overrides for child windows within dialogs. The values in this enumeration are bitfields and can be combined.
|
||||
///
|
||||
/// This enum is used with SetDialogControlDpiChangeBehavior in order to override the default per-monitor DPI scaling behavior for a child window within a dialog.
|
||||
///
|
||||
/// These settings only apply to individual controls within dialogs. The dialog-wide per-monitor DPI scaling behavior of a dialog is controlled by DIALOG_DPI_CHANGE_BEHAVIORS.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum DialogScalingBehaviors
|
||||
{
|
||||
/// <summary>
|
||||
/// The default behavior of the dialog manager. The dialog managed will update the font, size, and position of the child window on DPI changes.
|
||||
/// </summary>
|
||||
Default = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Prevents the dialog manager from sending an updated font to the child window via WM_SETFONT in response to a DPI change.
|
||||
/// </summary>
|
||||
DisableFontUpdate = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Prevents the dialog manager from resizing and repositioning the child window in response to a DPI change.
|
||||
/// </summary>
|
||||
DisableRelayout = 2
|
||||
}
|
||||
}
|
40
GreenshotPlugin/Core/Enums/DpiAwareness.cs
Normal file
40
GreenshotPlugin/Core/Enums/DpiAwareness.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Copyright (c) Dapplo and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace GreenshotPlugin.Core.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the dots per inch (dpi) setting for a thread, process, or window.
|
||||
/// Can be used everywhere ProcessDpiAwareness is passed.
|
||||
/// </summary>
|
||||
public enum DpiAwareness
|
||||
{
|
||||
/// <summary>
|
||||
/// Invalid DPI awareness. This is an invalid DPI awareness value.
|
||||
/// </summary>
|
||||
Invalid = -1,
|
||||
|
||||
/// <summary>
|
||||
/// DPI unaware.
|
||||
/// This process does not scale for DPI changes and is always assumed to have a scale factor of 100% (96 DPI).
|
||||
/// It will be automatically scaled by the system on any other DPI setting.
|
||||
/// </summary>
|
||||
Unaware = 0,
|
||||
|
||||
/// <summary>
|
||||
/// System DPI aware.
|
||||
/// This process does not scale for DPI changes.
|
||||
/// It will query for the DPI once and use that value for the lifetime of the process.
|
||||
/// If the DPI changes, the process will not adjust to the new DPI value.
|
||||
/// It will be automatically scaled up or down by the system when the DPI changes from the system value.
|
||||
/// </summary>
|
||||
SystemAware = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Per monitor DPI aware.
|
||||
/// This process checks for the DPI when it is created and adjusts the scale factor whenever the DPI changes.
|
||||
/// These processes are not automatically scaled by the system.
|
||||
/// </summary>
|
||||
PerMonitorAware = 2
|
||||
}
|
||||
}
|
46
GreenshotPlugin/Core/Enums/DpiAwarenessContext.cs
Normal file
46
GreenshotPlugin/Core/Enums/DpiAwarenessContext.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
// Copyright (c) Dapplo and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace GreenshotPlugin.Core.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
public enum DpiAwarenessContext
|
||||
{
|
||||
/// <summary>
|
||||
/// DPI unaware.
|
||||
/// This window does not scale for DPI changes and is always assumed to have a scale factor of 100% (96 DPI).
|
||||
/// It will be automatically scaled by the system on any other DPI setting.
|
||||
/// </summary>
|
||||
Unaware = -1,
|
||||
|
||||
/// <summary>
|
||||
/// System DPI aware.
|
||||
/// This window does not scale for DPI changes.
|
||||
/// It will query for the DPI once and use that value for the lifetime of the process.
|
||||
/// If the DPI changes, the process will not adjust to the new DPI value.
|
||||
/// It will be automatically scaled up or down by the system when the DPI changes from the system value.
|
||||
/// </summary>
|
||||
SystemAware = -2,
|
||||
|
||||
/// <summary>
|
||||
/// Per monitor DPI aware.
|
||||
/// This window checks for the DPI when it is created and adjusts the scale factor whenever the DPI changes.
|
||||
/// These processes are not automatically scaled by the system.
|
||||
/// </summary>
|
||||
PerMonitorAware = -3,
|
||||
|
||||
/// <summary>
|
||||
/// Also known as Per Monitor v2. An advancement over the original per-monitor DPI awareness mode, which enables applications to access new DPI-related scaling behaviors on a per top-level window basis.
|
||||
/// Per Monitor v2 was made available in the Creators Update of Windows 10, and is not available on earlier versions of the operating system.
|
||||
/// The additional behaviors introduced are as follows:
|
||||
/// * Child window DPI change notifications - In Per Monitor v2 contexts, the entire window tree is notified of any DPI changes that occur.
|
||||
/// * Scaling of non-client area - All windows will automatically have their non-client area drawn in a DPI sensitive fashion. Calls to EnableNonClientDpiScaling are unnecessary.
|
||||
/// * Scaling of Win32 menus - All NTUSER menus created in Per Monitor v2 contexts will be scaling in a per-monitor fashion.
|
||||
/// * Dialog Scaling - Win32 dialogs created in Per Monitor v2 contexts will automatically respond to DPI changes.
|
||||
/// * Improved scaling of comctl32 controls - Various comctl32 controls have improved DPI scaling behavior in Per Monitor v2 contexts.
|
||||
/// * Improved theming behavior - UxTheme handles opened in the context of a Per Monitor v2 window will operate in terms of the DPI associated with that window.
|
||||
/// </summary>
|
||||
PerMonitorAwareV2 = -4
|
||||
}
|
||||
}
|
28
GreenshotPlugin/Core/Enums/DpiHostingBehavior.cs
Normal file
28
GreenshotPlugin/Core/Enums/DpiHostingBehavior.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) Dapplo and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace GreenshotPlugin.Core.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the DPI hosting behavior for a window.
|
||||
/// This behavior allows windows created in the thread to host child windows with a different DPI_AWARENESS_CONTEXT
|
||||
/// </summary>
|
||||
public enum DpiHostingBehavior
|
||||
{
|
||||
/// <summary>
|
||||
/// Invalid DPI hosting behavior. This usually occurs if the previous SetThreadDpiHostingBehavior call used an invalid parameter.
|
||||
/// </summary>
|
||||
Invalid = -1,
|
||||
|
||||
/// <summary>
|
||||
/// Default DPI hosting behavior. The associated window behaves as normal, and cannot create or re-parent child windows with a different DPI_AWARENESS_CONTEXT.
|
||||
/// </summary>
|
||||
Default = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Mixed DPI hosting behavior. This enables the creation and re-parenting of child windows with different DPI_AWARENESS_CONTEXT. These child windows will be independently scaled by the OS.
|
||||
/// </summary>
|
||||
Mixed = 1
|
||||
|
||||
}
|
||||
}
|
56
GreenshotPlugin/Core/Enums/HResult.cs
Normal file
56
GreenshotPlugin/Core/Enums/HResult.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
// Greenshot - a free and open source screenshot tool
|
||||
// Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
|
||||
//
|
||||
// For more information see: http://getgreenshot.org/
|
||||
// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace GreenshotPlugin.Core.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// The HRESULT represents Windows error codes
|
||||
/// See <a href="https://en.wikipedia.org/wiki/HRESULT">wikipedia</a>
|
||||
/// </summary>
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum HResult
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
S_OK = 0,
|
||||
S_FALSE = 1,
|
||||
E_FAIL = unchecked((int)0x80004005),
|
||||
E_INVALIDARG = unchecked((int)0x80070057),
|
||||
E_NOTIMPL = unchecked((int)0x80004001),
|
||||
E_POINTER = unchecked((int)0x80004003),
|
||||
E_PENDING = unchecked((int)0x8000000A),
|
||||
E_NOINTERFACE = unchecked((int)0x80004002),
|
||||
E_ABORT = unchecked((int)0x80004004),
|
||||
E_ACCESSDENIED = unchecked((int)0x80070006),
|
||||
E_HANDLE = unchecked((int)0x80070006),
|
||||
E_UNEXPECTED = unchecked((int)0x8000FFFF),
|
||||
E_FILENOTFOUND = unchecked((int)0x80070002),
|
||||
E_PATHNOTFOUND = unchecked((int)0x80070003),
|
||||
E_INVALID_DATA = unchecked((int)0x8007000D),
|
||||
E_OUTOFMEMORY = unchecked((int)0x8007000E),
|
||||
E_INSUFFICIENT_BUFFER = unchecked((int)0x8007007A),
|
||||
WSAECONNABORTED = unchecked((int)0x80072745),
|
||||
WSAECONNRESET = unchecked((int)0x80072746),
|
||||
ERROR_TOO_MANY_CMDS = unchecked((int)0x80070038),
|
||||
ERROR_NOT_SUPPORTED = unchecked((int)0x80070032),
|
||||
TYPE_E_ELEMENTNOTFOUND = unchecked((int)0x8002802B)
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
}
|
40
GreenshotPlugin/Core/Enums/MonitorDpiType.cs
Normal file
40
GreenshotPlugin/Core/Enums/MonitorDpiType.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Copyright (c) Dapplo and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
using System;
|
||||
|
||||
namespace GreenshotPlugin.Core.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// See
|
||||
/// <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/dn280511(v=vs.85).aspx">
|
||||
/// MONITOR_DPI_TYPE
|
||||
/// enumeration
|
||||
/// </a>
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum MonitorDpiType
|
||||
{
|
||||
/// <summary>
|
||||
/// The effective DPI.
|
||||
/// This value should be used when determining the correct scale factor for scaling UI elements.
|
||||
/// This incorporates the scale factor set by the user for this specific display.
|
||||
/// </summary>
|
||||
EffectiveDpi = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The angular DPI.
|
||||
/// This DPI ensures rendering at a compliant angular resolution on the screen.
|
||||
/// This does not include the scale factor set by the user for this specific display
|
||||
/// </summary>
|
||||
AngularDpi = 1,
|
||||
|
||||
/// <summary>
|
||||
/// The raw DPI.
|
||||
/// This value is the linear DPI of the screen as measured on the screen itself.
|
||||
/// Use this value when you want to read the pixel density and not the recommended scaling setting.
|
||||
/// This does not include the scale factor set by the user for this specific display and is not guaranteed to be a
|
||||
/// supported DPI value.
|
||||
/// </summary>
|
||||
RawDpi = 2
|
||||
}
|
||||
}
|
30
GreenshotPlugin/Core/Enums/MonitorFrom.cs
Normal file
30
GreenshotPlugin/Core/Enums/MonitorFrom.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Copyright (c) Dapplo and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
using System;
|
||||
|
||||
namespace GreenshotPlugin.Core.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// Flags for the MonitorFromRect / MonitorFromWindow "flags" field
|
||||
/// see <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd145063(v=vs.85).aspx">MonitorFromRect function</a>
|
||||
/// or see <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd145064(v=vs.85).aspx">MonitorFromWindow function</a>
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum MonitorFrom : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns a handle to the display monitor that is nearest to the rectangle.
|
||||
/// </summary>
|
||||
DefaultToNearest = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Returns NULL. (why??)
|
||||
/// </summary>
|
||||
DefaultToNull = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Returns a handle to the primary display monitor.
|
||||
/// </summary>
|
||||
DefaultToPrimary = 2
|
||||
}
|
||||
}
|
1390
GreenshotPlugin/Core/Enums/SystemParametersInfoActions.cs
Normal file
1390
GreenshotPlugin/Core/Enums/SystemParametersInfoActions.cs
Normal file
File diff suppressed because it is too large
Load diff
28
GreenshotPlugin/Core/Enums/SystemParametersInfoBehaviors.cs
Normal file
28
GreenshotPlugin/Core/Enums/SystemParametersInfoBehaviors.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) Dapplo and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
namespace GreenshotPlugin.Core.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// If a system parameter is being set, specifies whether the user profile is to be updated, and if so, whether the
|
||||
/// WM_SETTINGCHANGE message is to be broadcast to all top-level windows to notify them of the change.
|
||||
/// This parameter can be zero if you do not want to update the user profile or broadcast the WM_SETTINGCHANGE message,
|
||||
/// or it can be one or more of the following values.
|
||||
/// </summary>
|
||||
public enum SystemParametersInfoBehaviors : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// Do nothing
|
||||
/// </summary>
|
||||
None = 0x00,
|
||||
|
||||
/// <summary>Writes the new system-wide parameter setting to the user profile.</summary>
|
||||
UpdateIniFile = 0x01,
|
||||
|
||||
/// <summary>Broadcasts the WM_SETTINGCHANGE message after updating the user profile.</summary>
|
||||
SendChange = 0x02,
|
||||
|
||||
/// <summary>Same as SPIF_SENDCHANGE.</summary>
|
||||
SendWinIniChange = SendChange
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue