forked from microsoft/PowerToys
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MouseJump] added Mouse Jump style controls to Settings UI (microsoft…
- Loading branch information
1 parent
6dcbd29
commit 1cfb30b
Showing
25 changed files
with
1,256 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/modules/MouseUtils/MouseJump.Common/Helpers/ConfigHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// 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. | ||
|
||
using System; | ||
using System.Drawing; | ||
using System.Globalization; | ||
using System.Linq; | ||
|
||
namespace MouseJump.Common.Helpers; | ||
|
||
public static class ConfigHelper | ||
{ | ||
public static Color? ToUnnamedColor(Color? value) | ||
{ | ||
if (!value.HasValue) | ||
{ | ||
return null; | ||
} | ||
|
||
var color = value.Value; | ||
return Color.FromArgb(color.A, color.R, color.G, color.B); | ||
} | ||
|
||
public static string? SerializeToConfigColorString(Color? value) | ||
{ | ||
if (!value.HasValue) | ||
{ | ||
return null; | ||
} | ||
|
||
var color = value.Value; | ||
return color switch | ||
{ | ||
Color { IsNamedColor: true } => | ||
$"{nameof(Color)}.{color.Name}", | ||
Color { IsSystemColor: true } => | ||
$"{nameof(SystemColors)}.{color.Name}", | ||
_ => | ||
$"#{color.R:X2}{color.G:X2}{color.B:X2}", | ||
}; | ||
} | ||
|
||
public static Color? DeserializeFromConfigColorString(string? value) | ||
{ | ||
if (string.IsNullOrEmpty(value)) | ||
{ | ||
return null; | ||
} | ||
|
||
// e.g. "#AABBCC" | ||
if (value.StartsWith('#')) | ||
{ | ||
var culture = CultureInfo.InvariantCulture; | ||
if ((value.Length == 7) | ||
&& int.TryParse(value[1..3], NumberStyles.HexNumber, culture, out var r) | ||
&& int.TryParse(value[3..5], NumberStyles.HexNumber, culture, out var g) | ||
&& int.TryParse(value[5..7], NumberStyles.HexNumber, culture, out var b)) | ||
{ | ||
return Color.FromArgb(0xFF, r, g, b); | ||
} | ||
} | ||
|
||
const StringComparison comparison = StringComparison.InvariantCulture; | ||
|
||
// e.g. "Color.Red" | ||
const string colorPrefix = $"{nameof(Color)}."; | ||
if (value.StartsWith(colorPrefix, comparison)) | ||
{ | ||
var colorName = value[colorPrefix.Length..]; | ||
var property = typeof(Color).GetProperties() | ||
.SingleOrDefault(property => property.Name == colorName); | ||
if (property is not null) | ||
{ | ||
return (Color?)property.GetValue(null, null); | ||
} | ||
} | ||
|
||
// e.g. "SystemColors.Highlight" | ||
const string systemColorPrefix = $"{nameof(SystemColors)}."; | ||
if (value.StartsWith(systemColorPrefix, comparison)) | ||
{ | ||
var colorName = value[systemColorPrefix.Length..]; | ||
var property = typeof(SystemColors).GetProperties() | ||
.SingleOrDefault(property => property.Name == colorName); | ||
if (property is not null) | ||
{ | ||
return (Color?)property.GetValue(null, null); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
1cfb30b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@check-spelling-bot Report
🔴 Please review
See the 📜action log or 📝 job summary for details.
Unrecognized words (1)
bezelled
Previously acknowledged words that are now absent
applayout appsfolder buildtask cswinrt directshow DOPUS GBarm netcore nugets QDir SYSTEMSETTINGS SYSTEMWOW telem TOTALCMD USEPOSITION USESIZE winappdriver xplorer 🫥To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands
... in a clone of the [email protected]:mikeclayton/PowerToys.git repository
on the
dev/mikeclayton/mousejump-styles-part-3
branch (ℹ️ how do I use this?):Available 📚 dictionaries could cover words (expected and unrecognized) not in the 📘 dictionary
This includes both expected items (1932) from .github/actions/spell-check/expect.txt and unrecognized words (1)
Consider adding them (in
.github/workflows/spelling2.yml
) foruses: check-spelling/[email protected]
in itswith
:To stop checking additional dictionaries, add (in
.github/workflows/spelling2.yml
) foruses: check-spelling/[email protected]
in itswith
:If the flagged items are 🤯 false positives
If items relate to a ...
binary file (or some other file you wouldn't want to check at all).
Please add a file path to the
excludes.txt
file matching the containing file.File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
^
refers to the file's path from the root of the repository, so^README\.md$
would exclude README.md (on whichever branch you're using).well-formed pattern.
If you can write a pattern that would match it,
try adding it to the
patterns.txt
file.Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.