[MouseJump]Reduce winforms dependency, thumbnail size settings, shortcut keys(#25487)

* [Mouse Jump] - reorganise existing NativeMethods (#25482)

* Mouse Jump] - reorganise Helper classes / main form code (#25482)

* Mouse Jump] - replace use of System.Windows.Forms.Screen with Native Methods (#25482)

* Mouse Jump] - replace use of System.Windows.Forms.SystemInformation with Native Methods (#25482)

* [Mouse Jump] - replace use of System.Windows.Forms.Cursor with Native Methods (#25482)

* [Mouse Jump] - improve popup responsiveness (#25484)

* [Mouse Jump] - fixed spellchecker errors (#25484)

* [Mouse Jump] - add settings card for thumbnail size (#24564)

* [Mouse Jump] - shortcut keys to jump to centres of screens (#25069)

* [Mouse Jump] - fix spelling (#25069)

* [Mouse Jump] - fix spelling - numpad (#25069)

* [Mouse Jump] - updated "thumbnail size" settings text (#24564)
This commit is contained in:
Michael Clayton
2023-04-24 16:15:07 +01:00
committed by GitHub
parent 467fcfee2d
commit fda75e48d5
75 changed files with 2336 additions and 588 deletions

View File

@@ -3,10 +3,12 @@
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MouseJumpUI.Drawing.Models;
using MouseJumpUI.Helpers;
using MouseJumpUI.Models.Drawing;
using MouseJumpUI.Models.Layout;
using MouseJumpUI.Models.Screen;
using static MouseJumpUI.NativeMethods.Core;
namespace MouseJumpUI.UnitTests.Helpers;
@@ -14,9 +16,9 @@ namespace MouseJumpUI.UnitTests.Helpers;
public static class DrawingHelperTests
{
[TestClass]
public class CalculateLayoutInfoTests
public sealed class CalculateLayoutInfoTests
{
public class TestCase
public sealed class TestCase
{
public TestCase(LayoutConfig layoutConfig, LayoutInfo expectedResult)
{
@@ -40,13 +42,14 @@ public static class DrawingHelperTests
// | |
// +----------------+
var layoutConfig = new LayoutConfig(
virtualScreen: new(0, 0, 5120, 1440),
screenBounds: new List<Rectangle>
virtualScreenBounds: new(0, 0, 5120, 1440),
screens: new List<ScreenInfo>
{
new(0, 0, 5120, 1440),
new ScreenInfo(HMONITOR.Null, false, new(0, 0, 5120, 1440), new(0, 0, 5120, 1440)),
},
activatedLocation: new(5120 / 2, 1440 / 2),
activatedScreen: 0,
activatedScreenIndex: 0,
activatedScreenNumber: 1,
maximumFormSize: new(1600, 1200),
formPadding: new(5, 5, 5, 5),
previewPadding: new(0, 0, 0, 0));
@@ -58,7 +61,7 @@ public static class DrawingHelperTests
{
new(0, 0, 1590, 447.1875M),
},
activatedScreen: new(0, 0, 5120, 1440));
activatedScreenBounds: new(0, 0, 5120, 1440));
yield return new[] { new TestCase(layoutConfig, layoutInfo) };
// primary monitor not topmost / leftmost - if there are screens
@@ -74,14 +77,15 @@ public static class DrawingHelperTests
// | |
// +----------------+
layoutConfig = new LayoutConfig(
virtualScreen: new(-1920, -472, 7040, 1912),
screenBounds: new List<Rectangle>
virtualScreenBounds: new(-1920, -472, 7040, 1912),
screens: new List<ScreenInfo>
{
new(-1920, -472, 1920, 1080),
new(0, 0, 5120, 1440),
new ScreenInfo(HMONITOR.Null, false, new(-1920, -472, 1920, 1080), new(-1920, -472, 1920, 1080)),
new ScreenInfo(HMONITOR.Null, false, new(0, 0, 5120, 1440), new(0, 0, 5120, 1440)),
},
activatedLocation: new(-960, -236),
activatedScreen: 0,
activatedScreenIndex: 0,
activatedScreenNumber: 1,
maximumFormSize: new(1600, 1200),
formPadding: new(5, 5, 5, 5),
previewPadding: new(0, 0, 0, 0));
@@ -99,7 +103,7 @@ public static class DrawingHelperTests
new(0, 0, 433.63636M, 243.92045M),
new(433.63636M, 106.602270M, 1156.36363M, 325.22727M),
},
activatedScreen: new(-1920, -472, 1920, 1080));
activatedScreenBounds: new(-1920, -472, 1920, 1080));
yield return new[] { new TestCase(layoutConfig, layoutInfo) };
// check we handle rounding errors in scaling the preview form
@@ -115,14 +119,15 @@ public static class DrawingHelperTests
// | | 0 |
// +----------------+-------+
layoutConfig = new LayoutConfig(
virtualScreen: new(0, 0, 7168, 1440),
screenBounds: new List<Rectangle>
virtualScreenBounds: new(0, 0, 7168, 1440),
screens: new List<ScreenInfo>
{
new(6144, 0, 1024, 768),
new(0, 0, 6144, 1440),
new ScreenInfo(HMONITOR.Null, false, new(6144, 0, 1024, 768), new(6144, 0, 1024, 768)),
new ScreenInfo(HMONITOR.Null, false, new(0, 0, 6144, 1440), new(0, 0, 6144, 1440)),
},
activatedLocation: new(6656, 384),
activatedScreen: 0,
activatedScreenIndex: 0,
activatedScreenNumber: 1,
maximumFormSize: new(1600, 1200),
formPadding: new(5, 5, 5, 5),
previewPadding: new(0, 0, 0, 0));
@@ -135,7 +140,7 @@ public static class DrawingHelperTests
new(869.14285M, 0, 144.85714M, 108.642857M),
new(0, 0, 869.142857M, 203.705357M),
},
activatedScreen: new(6144, 0, 1024, 768));
activatedScreenBounds: new(6144, 0, 1024, 768));
yield return new[] { new TestCase(layoutConfig, layoutInfo) };
// check we handle rounding errors in scaling the preview form
@@ -151,14 +156,15 @@ public static class DrawingHelperTests
// | | 0 |
// +----------------+-------+
layoutConfig = new LayoutConfig(
virtualScreen: new(0, 0, 7424, 1440),
screenBounds: new List<Rectangle>
virtualScreenBounds: new(0, 0, 7424, 1440),
screens: new List<ScreenInfo>
{
new(6144, 0, 1280, 768),
new(0, 0, 6144, 1440),
new ScreenInfo(HMONITOR.Null, false, new(6144, 0, 1280, 768), new(6144, 0, 1280, 768)),
new ScreenInfo(HMONITOR.Null, false, new(0, 0, 6144, 1440), new(0, 0, 6144, 1440)),
},
activatedLocation: new(6784, 384),
activatedScreen: 0,
activatedScreenIndex: 0,
activatedScreenNumber: 1,
maximumFormSize: new(1600, 1200),
formPadding: new(5, 5, 5, 5),
previewPadding: new(0, 0, 0, 0));
@@ -176,7 +182,7 @@ public static class DrawingHelperTests
new(1051.03448M, 0, 218.96551M, 131.37931M),
new(0, 0M, 1051.03448M, 246.33620M),
},
activatedScreen: new(6144, 0, 1280, 768));
activatedScreenBounds: new(6144, 0, 1280, 768));
yield return new[] { new TestCase(layoutConfig, layoutInfo) };
}
@@ -191,7 +197,7 @@ public static class DrawingHelperTests
// (int)1280.000000000000 -> 1280
// so we'll compare the raw values, *and* convert to an int-based
// Rectangle to compare rounded values
var actual = DrawingHelper.CalculateLayoutInfo(data.LayoutConfig);
var actual = LayoutHelper.CalculateLayoutInfo(data.LayoutConfig);
var expected = data.ExpectedResult;
Assert.AreEqual(expected.FormBounds.X, actual.FormBounds.X, 0.00001M, "FormBounds.X");
Assert.AreEqual(expected.FormBounds.Y, actual.FormBounds.Y, 0.00001M, "FormBounds.Y");
@@ -213,11 +219,11 @@ public static class DrawingHelperTests
Assert.AreEqual(expected.ScreenBounds[i].ToRectangle(), actual.ScreenBounds[i].ToRectangle(), "ActivatedScreen.ToRectangle");
}
Assert.AreEqual(expected.ActivatedScreen.X, actual.ActivatedScreen.X, "ActivatedScreen.X");
Assert.AreEqual(expected.ActivatedScreen.Y, actual.ActivatedScreen.Y, "ActivatedScreen.Y");
Assert.AreEqual(expected.ActivatedScreen.Width, actual.ActivatedScreen.Width, "ActivatedScreen.Width");
Assert.AreEqual(expected.ActivatedScreen.Height, actual.ActivatedScreen.Height, "ActivatedScreen.Height");
Assert.AreEqual(expected.ActivatedScreen.ToRectangle(), actual.ActivatedScreen.ToRectangle(), "ActivatedScreen.ToRectangle");
Assert.AreEqual(expected.ActivatedScreenBounds.X, actual.ActivatedScreenBounds.X, "ActivatedScreen.X");
Assert.AreEqual(expected.ActivatedScreenBounds.Y, actual.ActivatedScreenBounds.Y, "ActivatedScreen.Y");
Assert.AreEqual(expected.ActivatedScreenBounds.Width, actual.ActivatedScreenBounds.Width, "ActivatedScreen.Width");
Assert.AreEqual(expected.ActivatedScreenBounds.Height, actual.ActivatedScreenBounds.Height, "ActivatedScreen.Height");
Assert.AreEqual(expected.ActivatedScreenBounds.ToRectangle(), actual.ActivatedScreenBounds.ToRectangle(), "ActivatedScreen.ToRectangle");
}
}
}

View File

@@ -4,8 +4,8 @@
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MouseJumpUI.Drawing.Models;
using MouseJumpUI.Helpers;
using MouseJumpUI.Models.Drawing;
namespace MouseJumpUI.UnitTests.Helpers;
@@ -13,9 +13,9 @@ namespace MouseJumpUI.UnitTests.Helpers;
public static class MouseHelperTests
{
[TestClass]
public class GetJumpLocationTests
public sealed class GetJumpLocationTests
{
public class TestCase
public sealed class TestCase
{
public TestCase(PointInfo previewLocation, SizeInfo previewSize, RectangleInfo desktopBounds, PointInfo expectedResult)
{

View File

@@ -4,17 +4,17 @@
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MouseJumpUI.Drawing.Models;
using MouseJumpUI.Models.Drawing;
namespace MouseJumpUI.UnitTests.Drawing;
namespace MouseJumpUI.UnitTests.Models.Drawing;
[TestClass]
public static class RectangleInfoTests
{
[TestClass]
public class CenterTests
public sealed class CenterTests
{
public class TestCase
public sealed class TestCase
{
public TestCase(RectangleInfo rectangle, PointInfo point, RectangleInfo expectedResult)
{
@@ -63,9 +63,9 @@ public static class RectangleInfoTests
}
[TestClass]
public class ClampTests
public sealed class ClampTests
{
public class TestCase
public sealed class TestCase
{
public TestCase(RectangleInfo inner, RectangleInfo outer, RectangleInfo expectedResult)
{

View File

@@ -4,16 +4,17 @@
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MouseJumpUI.Drawing.Models;
using MouseJumpUI.Models.Drawing;
namespace MouseJumpUI.UnitTests.Drawing;
public sealed class SizeInfoTests
[TestClass]
public static class SizeInfoTests
{
[TestClass]
public class ScaleToFitTests
public sealed class ScaleToFitTests
{
public class TestCase
public sealed class TestCase
{
public TestCase(SizeInfo obj, SizeInfo bounds, SizeInfo expectedResult)
{
@@ -58,9 +59,9 @@ public sealed class SizeInfoTests
}
[TestClass]
public class ScaleToFitRatioTests
public sealed class ScaleToFitRatioTests
{
public class TestCase
public sealed class TestCase
{
public TestCase(SizeInfo obj, SizeInfo bounds, decimal expectedResult)
{