diff --git a/.gitignore b/.gitignore
index 59e0d3b..d501859 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,6 @@ obj
releases
-*.csproj.user
+*.user
wiki/anim
\ No newline at end of file
diff --git a/readme.md b/readme.md
index 0920b41..5260957 100644
--- a/readme.md
+++ b/readme.md
@@ -13,6 +13,13 @@ I'll continue to maintain the FancyMouse repo as an incubator for new features g
FancyMouse is a Windows utility for quickly moving the mouse large distances on high-res desktops.
+See links for additional details:
+
+* [Basic Configuration](./wiki/config/basic_config.md)
+* [Advancedc Configuration](./wiki/config/advanced_config.md)
+
+---
+
## The Problem
On a modern laptop that uses an Ultra-Wide external monitor you could easily have a desktop in the region of 8000+ pixels wide, and that's a lot of ground for your mouse to cover.
@@ -21,6 +28,8 @@ What tends to happen is you end up swiping the physical mouse as far as it will
FancyMouse helps by letting you click a scaled-down preview of your entire desktop and "teleport" the mouse there in an instant.
+---
+
## Swiping
Here's an animation showing the old slow way of swiping the mouse multiple times.
@@ -29,6 +38,8 @@ Imagine you're happily working on a spreadsheet on your ultra-wide external moni

+---
+
## FancyMouse
And here's the same thing using FancyMouse. A hotkey or spare mouse button can be configured to activate the FancyMouse popup, and the pointer only needs to be moved a tiny amount on the preview thumbnail. A single mouse click then teleports the pointer to that location on the full-size desktop.
diff --git a/src/FancyMouse.NativeMethods/Core/ATOM.cs b/src/FancyMouse.NativeMethods/Core/ATOM.cs
index 5d10511..1279e4b 100644
--- a/src/FancyMouse.NativeMethods/Core/ATOM.cs
+++ b/src/FancyMouse.NativeMethods/Core/ATOM.cs
@@ -24,7 +24,7 @@ public ATOM(ushort value)
public static implicit operator ushort(ATOM value) => value.Value;
- public static implicit operator ATOM(ushort value) => new(value);
+ public static explicit operator ATOM(ushort value) => new(value);
public override string ToString()
{
diff --git a/src/FancyMouse.NativeMethods/Core/GUID.cs b/src/FancyMouse.NativeMethods/Core/GUID.cs
new file mode 100644
index 0000000..18a72aa
--- /dev/null
+++ b/src/FancyMouse.NativeMethods/Core/GUID.cs
@@ -0,0 +1,53 @@
+// Copyright (c) Microsoft Corporation
+// The Microsoft Corporation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace FancyMouse.NativeMethods;
+
+internal static partial class Core
+{
+ ///
+ /// A 32-bit signed integer.The range is -2147483648 through 2147483647 decimal.
+ /// This type is declared in WinNT.h as follows:
+ /// typedef long LONG;
+ ///
+ ///
+ /// See https://learn.microsoft.com/en-us/windows/win32/api/guiddef/ns-guiddef-guid
+ ///
+ internal readonly struct GUID
+ {
+ public readonly ulong Data1;
+ public readonly short Data2;
+ public readonly short Data3;
+ public readonly char[] Data4;
+
+ public GUID(Guid value)
+ {
+ this.Data1 = 0;
+ this.Data2 = 0;
+ this.Data3 = 0;
+ this.Data4 = new[] { (char)0, (char)0, (char)0, (char)0, (char)0, (char)0, (char)0, (char)0 };
+ }
+
+ public GUID(ulong data1, short data2, short data3, char[] data4)
+ {
+ this.Data1 = data1;
+ this.Data2 = data2;
+ this.Data3 = data3;
+ this.Data4 = data4;
+ }
+
+ public static implicit operator Guid(GUID value) => Guid.NewGuid();
+
+ public static implicit operator GUID(Guid value) => new(
+ data1: 0,
+ data2: 0,
+ data3: 0,
+ data4: new[] { (char)0, (char)0, (char)0, (char)0, (char)0, (char)0, (char)0, (char)0 });
+
+ public override string ToString()
+ {
+ return $"{this.GetType().Name}";
+ }
+ }
+}
diff --git a/src/FancyMouse.NativeMethods/Core/HANDLE.cs b/src/FancyMouse.NativeMethods/Core/HANDLE.cs
index 446a853..3eedc64 100644
--- a/src/FancyMouse.NativeMethods/Core/HANDLE.cs
+++ b/src/FancyMouse.NativeMethods/Core/HANDLE.cs
@@ -25,7 +25,7 @@ public HANDLE(IntPtr value)
public static implicit operator IntPtr(HANDLE value) => value.Value;
- public static implicit operator HANDLE(IntPtr value) => new(value);
+ public static explicit operator HANDLE(IntPtr value) => new(value);
public override string ToString()
{
diff --git a/src/FancyMouse.NativeMethods/Core/HBITMAP.cs b/src/FancyMouse.NativeMethods/Core/HBITMAP.cs
new file mode 100644
index 0000000..2de491a
--- /dev/null
+++ b/src/FancyMouse.NativeMethods/Core/HBITMAP.cs
@@ -0,0 +1,39 @@
+namespace FancyMouse.NativeMethods;
+
+internal static partial class Core
+{
+ ///
+ /// A handle to a bitmap.
+ /// This type is declared in WinDef.h as follows:
+ /// typedef HANDLE HBITMAP;
+ ///
+ ///
+ /// See https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types
+ ///
+ internal readonly struct HBITMAP
+ {
+ public static readonly HBITMAP Null = new(IntPtr.Zero);
+
+ public readonly IntPtr Value;
+
+ public HBITMAP(IntPtr value)
+ {
+ this.Value = value;
+ }
+
+ public bool IsNull => this.Value == HBITMAP.Null.Value;
+
+ public static implicit operator IntPtr(HBITMAP value) => value.Value;
+
+ public static explicit operator HBITMAP(IntPtr value) => new(value);
+
+ public static explicit operator HBITMAP(HGDIOBJ value) => new(value.Value);
+
+ public static implicit operator HGDIOBJ(HBITMAP value) => new(value.Value);
+
+ public override string ToString()
+ {
+ return $"{this.GetType().Name}({this.Value})";
+ }
+ }
+}
diff --git a/src/FancyMouse.NativeMethods/Core/HBRUSH.cs b/src/FancyMouse.NativeMethods/Core/HBRUSH.cs
index b0a6ff5..f37b832 100644
--- a/src/FancyMouse.NativeMethods/Core/HBRUSH.cs
+++ b/src/FancyMouse.NativeMethods/Core/HBRUSH.cs
@@ -25,7 +25,7 @@ public HBRUSH(IntPtr value)
public static implicit operator IntPtr(HBRUSH value) => value.Value;
- public static implicit operator HBRUSH(IntPtr value) => new(value);
+ public static explicit operator HBRUSH(IntPtr value) => new(value);
public override string ToString()
{
diff --git a/src/FancyMouse.NativeMethods/Core/HDC.cs b/src/FancyMouse.NativeMethods/Core/HDC.cs
index 9b1c83f..7dc778a 100644
--- a/src/FancyMouse.NativeMethods/Core/HDC.cs
+++ b/src/FancyMouse.NativeMethods/Core/HDC.cs
@@ -23,6 +23,10 @@ public HDC(IntPtr value)
public bool IsNull => this.Value == HDC.Null.Value;
+ public static implicit operator IntPtr(HDC value) => value.Value;
+
+ public static explicit operator HDC(IntPtr value) => new(value);
+
public override string ToString()
{
return $"{this.GetType().Name}({this.Value})";
diff --git a/src/FancyMouse.NativeMethods/Core/HDESK.cs b/src/FancyMouse.NativeMethods/Core/HDESK.cs
index 05e6056..9341ef5 100644
--- a/src/FancyMouse.NativeMethods/Core/HDESK.cs
+++ b/src/FancyMouse.NativeMethods/Core/HDESK.cs
@@ -25,11 +25,11 @@ public HDESK(IntPtr value)
public static implicit operator IntPtr(HDESK value) => value.Value;
- public static implicit operator HDESK(IntPtr value) => new(value);
+ public static explicit operator HDESK(IntPtr value) => new(value);
public static implicit operator HANDLE(HDESK value) => new(value.Value);
- public static implicit operator HDESK(HANDLE value) => new(value.Value);
+ public static explicit operator HDESK(HANDLE value) => new(value.Value);
public override string ToString()
{
diff --git a/src/FancyMouse.NativeMethods/Core/HGDIOBJ.cs b/src/FancyMouse.NativeMethods/Core/HGDIOBJ.cs
new file mode 100644
index 0000000..9892e6a
--- /dev/null
+++ b/src/FancyMouse.NativeMethods/Core/HGDIOBJ.cs
@@ -0,0 +1,35 @@
+namespace FancyMouse.NativeMethods;
+
+internal static partial class Core
+{
+ ///
+ /// A handle to a GDI object.
+ /// This type is declared in WinDef.h as follows:
+ /// typedef HANDLE HGDIOBJ;
+ ///
+ ///
+ /// See https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types
+ ///
+ internal readonly struct HGDIOBJ
+ {
+ public static readonly HGDIOBJ Null = new(IntPtr.Zero);
+
+ public readonly IntPtr Value;
+
+ public HGDIOBJ(IntPtr value)
+ {
+ this.Value = value;
+ }
+
+ public bool IsNull => this.Value == HGDIOBJ.Null.Value;
+
+ public static implicit operator IntPtr(HGDIOBJ value) => value.Value;
+
+ public static explicit operator HGDIOBJ(IntPtr value) => new(value);
+
+ public override string ToString()
+ {
+ return $"{this.GetType().Name}({this.Value})";
+ }
+ }
+}
diff --git a/src/FancyMouse.NativeMethods/Core/HINSTANCE.cs b/src/FancyMouse.NativeMethods/Core/HINSTANCE.cs
index b7e2154..8c762c9 100644
--- a/src/FancyMouse.NativeMethods/Core/HINSTANCE.cs
+++ b/src/FancyMouse.NativeMethods/Core/HINSTANCE.cs
@@ -26,7 +26,7 @@ public HINSTANCE(IntPtr value)
public static implicit operator IntPtr(HINSTANCE value) => value.Value;
- public static implicit operator HINSTANCE(IntPtr value) => new(value);
+ public static explicit operator HINSTANCE(IntPtr value) => new(value);
public override string ToString()
{
diff --git a/src/FancyMouse.NativeMethods/Core/HMODULE.cs b/src/FancyMouse.NativeMethods/Core/HMODULE.cs
index 2c4b67c..6d5bfaa 100644
--- a/src/FancyMouse.NativeMethods/Core/HMODULE.cs
+++ b/src/FancyMouse.NativeMethods/Core/HMODULE.cs
@@ -26,7 +26,7 @@ public HMODULE(IntPtr value)
public static implicit operator IntPtr(HMODULE value) => value.Value;
- public static implicit operator HMODULE(IntPtr value) => new(value);
+ public static explicit operator HMODULE(IntPtr value) => new(value);
public override string ToString()
{
diff --git a/src/FancyMouse.NativeMethods/Core/HMONITOR.cs b/src/FancyMouse.NativeMethods/Core/HMONITOR.cs
index cd528c4..b22093b 100644
--- a/src/FancyMouse.NativeMethods/Core/HMONITOR.cs
+++ b/src/FancyMouse.NativeMethods/Core/HMONITOR.cs
@@ -25,15 +25,15 @@ public HMONITOR(IntPtr value)
public static implicit operator int(HMONITOR value) => value.Value.ToInt32();
- public static implicit operator HMONITOR(int value) => new(value);
+ public static explicit operator HMONITOR(int value) => new(value);
public static implicit operator IntPtr(HMONITOR value) => value.Value;
- public static implicit operator HMONITOR(IntPtr value) => new(value);
+ public static explicit operator HMONITOR(IntPtr value) => new(value);
public static implicit operator HANDLE(HMONITOR value) => new(value.Value);
- public static implicit operator HMONITOR(HANDLE value) => new(value.Value);
+ public static explicit operator HMONITOR(HANDLE value) => new(value.Value);
public override string ToString()
{
diff --git a/src/FancyMouse.NativeMethods/Core/HWINSTA.cs b/src/FancyMouse.NativeMethods/Core/HWINSTA.cs
index 20217cc..8407fb6 100644
--- a/src/FancyMouse.NativeMethods/Core/HWINSTA.cs
+++ b/src/FancyMouse.NativeMethods/Core/HWINSTA.cs
@@ -25,7 +25,7 @@ public HWINSTA(IntPtr value)
public static implicit operator IntPtr(HWINSTA value) => value.Value;
- public static implicit operator HWINSTA(IntPtr value) => new(value);
+ public static explicit operator HWINSTA(IntPtr value) => new(value);
public override string ToString()
{
diff --git a/src/FancyMouse.NativeMethods/Core/LPARAM.cs b/src/FancyMouse.NativeMethods/Core/LPARAM.cs
index a0548b0..b629134 100644
--- a/src/FancyMouse.NativeMethods/Core/LPARAM.cs
+++ b/src/FancyMouse.NativeMethods/Core/LPARAM.cs
@@ -21,9 +21,11 @@ public LPARAM(IntPtr value)
this.Value = value;
}
+ public bool IsNull => this.Value == LPARAM.Null.Value;
+
public static implicit operator IntPtr(LPARAM value) => value.Value;
- public static implicit operator LPARAM(IntPtr value) => new(value);
+ public static explicit operator LPARAM(IntPtr value) => new(value);
public override string ToString()
{
diff --git a/src/FancyMouse.NativeMethods/Core/LPCRECT.cs b/src/FancyMouse.NativeMethods/Core/LPCRECT.cs
index 151ed7d..a43e77e 100644
--- a/src/FancyMouse.NativeMethods/Core/LPCRECT.cs
+++ b/src/FancyMouse.NativeMethods/Core/LPCRECT.cs
@@ -20,6 +20,8 @@ public LPCRECT(CRECT value)
this.Value = LPCRECT.ToPtr(value);
}
+ public bool IsNull => this.Value == LPCRECT.Null.Value;
+
private static IntPtr ToPtr(CRECT value)
{
var ptr = Marshal.AllocHGlobal(CRECT.Size);
@@ -34,7 +36,7 @@ public void Free()
public static implicit operator IntPtr(LPCRECT value) => value.Value;
- public static implicit operator LPCRECT(IntPtr value) => new(value);
+ public static explicit operator LPCRECT(IntPtr value) => new(value);
public override string ToString()
{
diff --git a/src/FancyMouse.NativeMethods/Core/LPCWSTR.cs b/src/FancyMouse.NativeMethods/Core/LPCWSTR.cs
index 6e4ea5c..c8814fa 100644
--- a/src/FancyMouse.NativeMethods/Core/LPCWSTR.cs
+++ b/src/FancyMouse.NativeMethods/Core/LPCWSTR.cs
@@ -32,7 +32,7 @@ public LPCWSTR(string value)
public static implicit operator IntPtr(LPCWSTR value) => value.Value;
- public static implicit operator LPCWSTR(IntPtr value) => new(value);
+ public static explicit operator LPCWSTR(IntPtr value) => new(value);
public static implicit operator string?(LPCWSTR value) => Marshal.PtrToStringUni(value.Value);
diff --git a/src/FancyMouse.NativeMethods/Core/LPDWORD.cs b/src/FancyMouse.NativeMethods/Core/LPDWORD.cs
index f18de27..278c4c9 100644
--- a/src/FancyMouse.NativeMethods/Core/LPDWORD.cs
+++ b/src/FancyMouse.NativeMethods/Core/LPDWORD.cs
@@ -28,6 +28,8 @@ public LPDWORD(DWORD value)
this.Value = LPDWORD.ToPtr(value);
}
+ public bool IsNull => this.Value == LPDWORD.Null.Value;
+
private static IntPtr ToPtr(DWORD value)
{
var ptr = Marshal.AllocHGlobal(DWORD.Size);
@@ -42,7 +44,7 @@ public void Free()
public static implicit operator IntPtr(LPDWORD value) => value.Value;
- public static implicit operator LPDWORD(IntPtr value) => new(value);
+ public static explicit operator LPDWORD(IntPtr value) => new(value);
public override string ToString()
{
diff --git a/src/FancyMouse.NativeMethods/Core/LPPOINT.cs b/src/FancyMouse.NativeMethods/Core/LPPOINT.cs
index 407e05a..5e829ae 100644
--- a/src/FancyMouse.NativeMethods/Core/LPPOINT.cs
+++ b/src/FancyMouse.NativeMethods/Core/LPPOINT.cs
@@ -20,6 +20,8 @@ public LPPOINT(POINT value)
this.Value = LPPOINT.ToPtr(value);
}
+ public bool IsNull => this.Value == LPPOINT.Null.Value;
+
private static IntPtr ToPtr(POINT value)
{
var ptr = Marshal.AllocHGlobal(POINT.Size);
@@ -39,7 +41,7 @@ public void Free()
public static implicit operator IntPtr(LPPOINT value) => value.Value;
- public static implicit operator LPPOINT(IntPtr value) => new(value);
+ public static explicit operator LPPOINT(IntPtr value) => new(value);
public override string ToString()
{
diff --git a/src/FancyMouse.NativeMethods/Core/LPRECT.cs b/src/FancyMouse.NativeMethods/Core/LPRECT.cs
index a64d265..ac59c66 100644
--- a/src/FancyMouse.NativeMethods/Core/LPRECT.cs
+++ b/src/FancyMouse.NativeMethods/Core/LPRECT.cs
@@ -20,6 +20,8 @@ public LPRECT(RECT value)
this.Value = LPRECT.ToPtr(value);
}
+ public bool IsNull => this.Value == LPRECT.Null.Value;
+
private static IntPtr ToPtr(RECT value)
{
var ptr = Marshal.AllocHGlobal(RECT.Size);
@@ -34,7 +36,7 @@ public void Free()
public static implicit operator IntPtr(LPRECT value) => value.Value;
- public static implicit operator LPRECT(IntPtr value) => new(value);
+ public static explicit operator LPRECT(IntPtr value) => new(value);
public override string ToString()
{
diff --git a/src/FancyMouse.NativeMethods/Core/LPTSTR.cs b/src/FancyMouse.NativeMethods/Core/LPTSTR.cs
index e0cccb6..3d947a3 100644
--- a/src/FancyMouse.NativeMethods/Core/LPTSTR.cs
+++ b/src/FancyMouse.NativeMethods/Core/LPTSTR.cs
@@ -33,9 +33,11 @@ public LPTSTR(string value)
this.Value = Marshal.StringToHGlobalAuto(value);
}
+ public bool IsNull => this.Value == LPTSTR.Null.Value;
+
public static implicit operator IntPtr(LPTSTR value) => value.Value;
- public static implicit operator LPTSTR(IntPtr value) => new(value);
+ public static explicit operator LPTSTR(IntPtr value) => new(value);
public static implicit operator string?(LPTSTR value) => Marshal.PtrToStringUni(value.Value);
diff --git a/src/FancyMouse.NativeMethods/Core/LPVOID.cs b/src/FancyMouse.NativeMethods/Core/LPVOID.cs
index c433123..b3f9b04 100644
--- a/src/FancyMouse.NativeMethods/Core/LPVOID.cs
+++ b/src/FancyMouse.NativeMethods/Core/LPVOID.cs
@@ -25,7 +25,7 @@ public LPVOID(IntPtr value)
public static implicit operator IntPtr(LPVOID value) => value.Value;
- public static implicit operator LPVOID(IntPtr value) => new(value);
+ public static explicit operator LPVOID(IntPtr value) => new(value);
public static LPVOID Allocate(int length)
{
diff --git a/src/FancyMouse.NativeMethods/Core/LRESULT.cs b/src/FancyMouse.NativeMethods/Core/LRESULT.cs
index 1e75957..60a1a4b 100644
--- a/src/FancyMouse.NativeMethods/Core/LRESULT.cs
+++ b/src/FancyMouse.NativeMethods/Core/LRESULT.cs
@@ -23,7 +23,7 @@ public LRESULT(IntPtr value)
public static implicit operator IntPtr(LRESULT value) => value.Value;
- public static implicit operator LRESULT(IntPtr value) => new(value);
+ public static explicit operator LRESULT(IntPtr value) => new(value);
public override string ToString()
{
diff --git a/src/FancyMouse.NativeMethods/Core/PCWSTR.cs b/src/FancyMouse.NativeMethods/Core/PCWSTR.cs
index 2451283..cdb4665 100644
--- a/src/FancyMouse.NativeMethods/Core/PCWSTR.cs
+++ b/src/FancyMouse.NativeMethods/Core/PCWSTR.cs
@@ -30,7 +30,7 @@ public PCWSTR(string value)
public static implicit operator IntPtr(PCWSTR value) => value.Value;
- public static implicit operator PCWSTR(IntPtr value) => new(value);
+ public static explicit operator PCWSTR(IntPtr value) => new(value);
public static implicit operator string?(PCWSTR value) => Marshal.PtrToStringUni(value.Value);
diff --git a/src/FancyMouse.NativeMethods/Core/PVOID.cs b/src/FancyMouse.NativeMethods/Core/PVOID.cs
index cbdd157..3595201 100644
--- a/src/FancyMouse.NativeMethods/Core/PVOID.cs
+++ b/src/FancyMouse.NativeMethods/Core/PVOID.cs
@@ -25,7 +25,7 @@ public PVOID(IntPtr value)
public static implicit operator IntPtr(PVOID value) => value.Value;
- public static implicit operator PVOID(IntPtr value) => new(value);
+ public static explicit operator PVOID(IntPtr value) => new(value);
public static PVOID Allocate(int length)
{
diff --git a/src/FancyMouse.NativeMethods/Core/ULONG_PTR.cs b/src/FancyMouse.NativeMethods/Core/ULONG_PTR.cs
index 7413a87..157526a 100644
--- a/src/FancyMouse.NativeMethods/Core/ULONG_PTR.cs
+++ b/src/FancyMouse.NativeMethods/Core/ULONG_PTR.cs
@@ -28,7 +28,7 @@ public ULONG_PTR(UIntPtr value)
public static implicit operator UIntPtr(ULONG_PTR value) => value.Value;
- public static implicit operator ULONG_PTR(UIntPtr value) => new(value);
+ public static explicit operator ULONG_PTR(UIntPtr value) => new(value);
public override string ToString()
{
diff --git a/src/FancyMouse.NativeMethods/Core/WCHAR.cs b/src/FancyMouse.NativeMethods/Core/WCHAR.cs
new file mode 100644
index 0000000..cfd4013
--- /dev/null
+++ b/src/FancyMouse.NativeMethods/Core/WCHAR.cs
@@ -0,0 +1,31 @@
+namespace FancyMouse.NativeMethods;
+
+internal static partial class Core
+{
+ ///
+ /// A 16-bit Unicode character.For more information, see Character Sets Used By Fonts.
+ /// This type is declared in WinNT.h as follows:
+ /// typedef wchar_t WCHAR;
+ ///
+ ///
+ /// See https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types
+ ///
+ internal readonly struct WCHAR
+ {
+ public readonly char Value;
+
+ public WCHAR(char value)
+ {
+ this.Value = value;
+ }
+
+ public static implicit operator char(WCHAR value) => value.Value;
+
+ public static implicit operator WCHAR(char value) => new(value);
+
+ public override string ToString()
+ {
+ return $"{this.GetType().Name}({this.Value})";
+ }
+ }
+}
diff --git a/src/FancyMouse.NativeMethods/Core/WPARAM.cs b/src/FancyMouse.NativeMethods/Core/WPARAM.cs
index 7b49f2a..0b23c13 100644
--- a/src/FancyMouse.NativeMethods/Core/WPARAM.cs
+++ b/src/FancyMouse.NativeMethods/Core/WPARAM.cs
@@ -23,7 +23,7 @@ public WPARAM(UIntPtr value)
public static implicit operator UIntPtr(WPARAM value) => value.Value;
- public static implicit operator WPARAM(UIntPtr value) => new(value);
+ public static explicit operator WPARAM(UIntPtr value) => new(value);
public override string ToString()
{
diff --git a/src/FancyMouse.NativeMethods/User32/UI/WindowsAndMessaging/User32.GetMessage.cs b/src/FancyMouse.NativeMethods/User32/UI/WindowsAndMessaging/User32.GetMessageW.cs
similarity index 100%
rename from src/FancyMouse.NativeMethods/User32/UI/WindowsAndMessaging/User32.GetMessage.cs
rename to src/FancyMouse.NativeMethods/User32/UI/WindowsAndMessaging/User32.GetMessageW.cs
diff --git a/src/FancyMouse.UnitTests/Helpers/DrawingHelperTests.cs b/src/FancyMouse.UnitTests/Helpers/DrawingHelperTests.cs
index 1aa0f23..8ae88eb 100644
--- a/src/FancyMouse.UnitTests/Helpers/DrawingHelperTests.cs
+++ b/src/FancyMouse.UnitTests/Helpers/DrawingHelperTests.cs
@@ -1,9 +1,11 @@
-using FancyMouse.Helpers;
+using System.Drawing;
+using System.Drawing.Imaging;
+using FancyMouse.Helpers;
using FancyMouse.Models.Drawing;
-using FancyMouse.Models.Layout;
-using FancyMouse.Models.Screen;
+using FancyMouse.Models.Settings;
+using FancyMouse.Models.Styles;
+using FancyMouse.NativeMethods;
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using static FancyMouse.NativeMethods.Core;
namespace FancyMouse.UnitTests.Helpers;
@@ -11,214 +13,106 @@ namespace FancyMouse.UnitTests.Helpers;
public static class DrawingHelperTests
{
[TestClass]
- public sealed class CalculateLayoutInfoTests
+ public sealed class GetPreviewLayoutTests
{
- public sealed class TestCase
+ private static Bitmap DrawDesktopImage(List<(RectangleInfo Bounds, Color Color)> screens)
{
- public TestCase(LayoutConfig layoutConfig, LayoutInfo expectedResult)
+ // created a "desktop" bitmap with the given screen areas drawn the specified colors.
+ var desktopBounds = LayoutHelper.GetCombinedScreenBounds(
+ screens.Select(s => s.Bounds).ToList());
+
+ // we can only create bitmaps with non-negative coordinates
+ if (desktopBounds.X < 0 || desktopBounds.Y < 0)
{
- this.LayoutConfig = layoutConfig;
- this.ExpectedResult = expectedResult;
+ throw new InvalidOperationException();
}
- public LayoutConfig LayoutConfig { get; set; }
+ // create the bitmap
+ var bitmap = new Bitmap((int)desktopBounds.Width, (int)desktopBounds.Height, PixelFormat.Format32bppArgb);
+
+ // draw the rectangles
+ using var graphics = Graphics.FromImage(bitmap);
+ foreach (var screen in screens)
+ {
+ var screenBounds = screen.Bounds.ToRectangle();
+ /*
+ using var pen = new Pen(screen.Color);
+ graphics.DrawRectangle(
+ pen, screenBounds.X, screenBounds.Y, screenBounds.Width - 1, screenBounds.Height - 1);
+ */
+ using var brush = new SolidBrush(screen.Color);
+ graphics.FillRectangle(brush, screenBounds);
+ }
- public LayoutInfo ExpectedResult { get; set; }
+ return bitmap;
}
- public static IEnumerable