forked from sourcegit-scm/sourcegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWin32HitTestHelper.cs
More file actions
40 lines (36 loc) · 1.32 KB
/
Win32HitTestHelper.cs
File metadata and controls
40 lines (36 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using Avalonia;
namespace SourceGit.Native
{
/// <summary>
/// Helper for Windows 11 Snap Layouts support with custom caption buttons.
/// Based on Avalonia PR #17380.
/// </summary>
internal static class Win32HitTestHelper
{
/// <summary>
/// Attached property to mark UI elements with their non-client hit test result.
/// This enables Windows 11 Snap Layouts on custom caption buttons.
/// </summary>
public static readonly AttachedProperty<HitTestValue> HitTestResultProperty =
AvaloniaProperty.RegisterAttached<Visual, HitTestValue>(
"HitTestResult",
typeof(Win32HitTestHelper),
inherits: true,
defaultValue: HitTestValue.Client);
public static void SetHitTestResult(Visual element, HitTestValue value)
=> element.SetValue(HitTestResultProperty, value);
public static HitTestValue GetHitTestResult(Visual element)
=> element.GetValue(HitTestResultProperty);
/// <summary>
/// Hit test values matching Windows WM_NCHITTEST return codes.
/// </summary>
public enum HitTestValue
{
Client = 1,
Caption = 2,
MinButton = 8,
MaxButton = 9,
Close = 20,
}
}
}