diff --git a/NHotkey.sln b/NHotkey.sln
index d293aee..b9d7dba 100644
--- a/NHotkey.sln
+++ b/NHotkey.sln
@@ -14,6 +14,9 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NHotkey.Wpf.Demo", "samples\NHotkey.Wpf.Demo\NHotkey.Wpf.Demo.csproj", "{338F60F0-F9FE-42AB-9EAE-31E9C3E3CEC3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{CEE3E414-E343-43C9-8CB9-72CA02FD0299}"
+ ProjectSection(SolutionItems) = preProject
+ samples\Directory.Build.props = samples\Directory.Build.props
+ EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{FBA6085F-DD7E-4E18-9BC8-8F709157EC33}"
ProjectSection(SolutionItems) = preProject
diff --git a/samples/Directory.Build.props b/samples/Directory.Build.props
new file mode 100644
index 0000000..0b3c588
--- /dev/null
+++ b/samples/Directory.Build.props
@@ -0,0 +1,5 @@
+
+
+ net481;net8.0-windows
+
+
diff --git a/samples/NHotkey.WindowsForms.Demo/Form1.Designer.cs b/samples/NHotkey.WindowsForms.Demo/Form1.Designer.cs
index 2ea8daa..b2d9c28 100644
--- a/samples/NHotkey.WindowsForms.Demo/Form1.Designer.cs
+++ b/samples/NHotkey.WindowsForms.Demo/Form1.Designer.cs
@@ -31,7 +31,6 @@ private void InitializeComponent()
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.lblValue = new System.Windows.Forms.Label();
- this.trayIcon = new System.Windows.Forms.NotifyIcon(this.components);
this.panel1 = new System.Windows.Forms.Panel();
this.label4 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
@@ -53,12 +52,6 @@ private void InitializeComponent()
this.lblValue.Text = "0";
this.lblValue.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
- // trayIcon
- //
- this.trayIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("trayIcon.Icon")));
- this.trayIcon.Text = "NHotkey demo";
- this.trayIcon.Visible = true;
- //
// panel1
//
this.panel1.Controls.Add(this.label4);
@@ -144,7 +137,6 @@ private void InitializeComponent()
#endregion
private System.Windows.Forms.Label lblValue;
- private System.Windows.Forms.NotifyIcon trayIcon;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label2;
@@ -153,4 +145,3 @@ private void InitializeComponent()
private System.Windows.Forms.CheckBox chkEnableGlobalHotkeys;
}
}
-
diff --git a/samples/NHotkey.WindowsForms.Demo/Form1.resx b/samples/NHotkey.WindowsForms.Demo/Form1.resx
index ebe7691..3328b3e 100644
--- a/samples/NHotkey.WindowsForms.Demo/Form1.resx
+++ b/samples/NHotkey.WindowsForms.Demo/Form1.resx
@@ -58,28 +58,4 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAABMLAAATCwAAAAAAAAAA
- AAAAAAAAbGxt/2xsbf9sbG3/bGxt/2xsbf9sbG3/bGxt/2xsbf9sbG3/bGxt/2xsbf9sbG3/bGxt/2xs
- bf8AAAAAAAAAAGxsbf9sbG3/bGxt/2xsbf9sbG3/bGxt/2xsbf9sbG3/bGxt/2xsbf9sbG3/bGxt/2xs
- bf9sbG3/AAAAAAAAAABsbG3/bGxt/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
- AABsbG3/bGxt/wAAAAAAAAAAbGxt/2xsbf8AAAAAbGxt/2xsbf9sbG3/bGxt/2xsbf9sbG3/bGxt/2xs
- bf8AAAAAbGxt/2xsbf8AAAAAAAAAAGxsbf9sbG3/AAAAAGxsbf9sbG3/bGxt/2xsbf9sbG3/bGxt/2xs
- bf9sbG3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
- ////DwAA/g8AAA==
-
-
\ No newline at end of file
diff --git a/samples/NHotkey.WindowsForms.Demo/NHotkey.WindowsForms.Demo.csproj b/samples/NHotkey.WindowsForms.Demo/NHotkey.WindowsForms.Demo.csproj
index 72915fd..c0129ec 100644
--- a/samples/NHotkey.WindowsForms.Demo/NHotkey.WindowsForms.Demo.csproj
+++ b/samples/NHotkey.WindowsForms.Demo/NHotkey.WindowsForms.Demo.csproj
@@ -1,6 +1,6 @@
- netcoreapp3.1
+ $(DemoTargetFrameworks)
true
WinExe
false
diff --git a/samples/NHotkey.WindowsForms.Demo/Program.cs b/samples/NHotkey.WindowsForms.Demo/Program.cs
index 9fab627..0493016 100644
--- a/samples/NHotkey.WindowsForms.Demo/Program.cs
+++ b/samples/NHotkey.WindowsForms.Demo/Program.cs
@@ -13,7 +13,9 @@ static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
+#if !NETFRAMEWORK
Application.SetHighDpiMode(HighDpiMode.PerMonitorV2);
+#endif
Application.Run(new Form1());
}
}
diff --git a/samples/NHotkey.Wpf.Demo/NHotkey.Wpf.Demo.csproj b/samples/NHotkey.Wpf.Demo/NHotkey.Wpf.Demo.csproj
index 88ee7f9..8a0509a 100644
--- a/samples/NHotkey.Wpf.Demo/NHotkey.Wpf.Demo.csproj
+++ b/samples/NHotkey.Wpf.Demo/NHotkey.Wpf.Demo.csproj
@@ -1,6 +1,6 @@
- netcoreapp3.1
+ $(DemoTargetFrameworks)
true
WinExe
false
@@ -9,4 +9,4 @@
-
\ No newline at end of file
+
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 093c6af..cc2f779 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -1,6 +1,7 @@
+ net462;net6.0-windows
$(MSBuildThisFileDirectory)NHotkey.snk
true
diff --git a/src/NHotkey.WindowsForms/NHotkey.WindowsForms.csproj b/src/NHotkey.WindowsForms/NHotkey.WindowsForms.csproj
index 4c1fa90..157451a 100644
--- a/src/NHotkey.WindowsForms/NHotkey.WindowsForms.csproj
+++ b/src/NHotkey.WindowsForms/NHotkey.WindowsForms.csproj
@@ -1,6 +1,6 @@
- net40;net45;netcoreapp3.0
+ $(LibraryTargetFrameworks)
true
@@ -9,4 +9,4 @@
-
\ No newline at end of file
+
diff --git a/src/NHotkey.Wpf/NHotkey.Wpf.csproj b/src/NHotkey.Wpf/NHotkey.Wpf.csproj
index a8241de..5bfdb5b 100644
--- a/src/NHotkey.Wpf/NHotkey.Wpf.csproj
+++ b/src/NHotkey.Wpf/NHotkey.Wpf.csproj
@@ -1,6 +1,6 @@
- net40;net45;netcoreapp3.0
+ $(LibraryTargetFrameworks)
true
@@ -9,4 +9,4 @@
-
\ No newline at end of file
+
diff --git a/src/NHotkey/NHotkey.csproj b/src/NHotkey/NHotkey.csproj
index b8cec27..23f3e7e 100644
--- a/src/NHotkey/NHotkey.csproj
+++ b/src/NHotkey/NHotkey.csproj
@@ -1,10 +1,10 @@
- net40;net45;netcoreapp3.0
+ $(LibraryTargetFrameworks)
A managed library to handle global hotkeys in Windows Forms and WPF applications. NOTE: this package doesn't contain a concrete HotkeyManager implementation; you should add either the NHotkey.Wpf or NHotkey.WindowsForms package to get one.
-
\ No newline at end of file
+
diff --git a/tools/build/Build.cs b/tools/build/Build.cs
deleted file mode 100644
index d2518e7..0000000
--- a/tools/build/Build.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using System;
-using System.IO;
-using System.Runtime.CompilerServices;
-using McMaster.Extensions.CommandLineUtils;
-using static Bullseye.Targets;
-using static SimpleExec.Command;
-
-namespace build
-{
- [Command(ThrowOnUnexpectedArgument = false)]
- [SuppressDefaultHelpOption]
- class Build
- {
- static void Main(string[] args) =>
- CommandLineApplication.Execute(args);
-
- [Option("-h|-?|--help", "Show help message", CommandOptionType.NoValue)]
- public bool ShowHelp { get; } = false;
-
- [Option("-c|--configuration", "The configuration to build", CommandOptionType.SingleValue)]
- public string Configuration { get; } = "Release";
-
- public string[] RemainingArguments { get; } = null;
-
- public void OnExecute(CommandLineApplication app)
- {
- if (ShowHelp)
- {
- app.ShowHelp();
- app.Out.WriteLine("Bullseye help:");
- app.Out.WriteLine();
- RunTargetsAndExit(new[] { "-h" });
- return;
- }
-
- Directory.SetCurrentDirectory(GetSolutionDirectory());
-
- string artifactsDir = Path.GetFullPath("artifacts");
- string logsDir = Path.Combine(artifactsDir, "logs");
- string buildLogFile = Path.Combine(logsDir, "build.binlog");
- string packagesDir = Path.Combine(artifactsDir, "packages");
-
- string solutionFile = "NHotkey.sln";
-
- Target(
- "artifactDirectories",
- () =>
- {
- Directory.CreateDirectory(artifactsDir);
- Directory.CreateDirectory(logsDir);
- Directory.CreateDirectory(packagesDir);
- });
-
- Target(
- "build",
- DependsOn("artifactDirectories"),
- () => Run(
- "dotnet",
- $"build -c \"{Configuration}\" /bl:\"{buildLogFile}\" \"{solutionFile}\""));
-
- Target(
- "pack",
- DependsOn("artifactDirectories", "build"),
- () => Run(
- "dotnet",
- $"pack -c \"{Configuration}\" --no-build -o \"{packagesDir}\""));
-
- Target("default", DependsOn("pack"));
-
- RunTargetsWithoutExiting(RemainingArguments);
- }
-
- private static string GetSolutionDirectory() =>
- Path.GetFullPath(Path.Combine(GetScriptDirectory(), @"..\.."));
-
- private static string GetScriptDirectory([CallerFilePath] string filename = null) => Path.GetDirectoryName(filename);
- }
-}
\ No newline at end of file
diff --git a/tools/build/CommandLineOptions.cs b/tools/build/CommandLineOptions.cs
new file mode 100644
index 0000000..2fd3b73
--- /dev/null
+++ b/tools/build/CommandLineOptions.cs
@@ -0,0 +1,55 @@
+using static Bullseye.Targets;
+
+internal record CommandLineOptions(string Configuration, bool ShowHelp, string[] BullseyeArgs)
+{
+ public static CommandLineOptions Parse(string[] args)
+ {
+ var bullseyeArgs = new List();
+ string configuration = "Release";
+ bool showHelp = false;
+ using var enumerator = ((IEnumerable)args).GetEnumerator();
+ while (enumerator.MoveNext())
+ {
+ var arg = enumerator.Current;
+ if (arg is "-h" or "--help")
+ {
+ showHelp = true;
+ break;
+ }
+ else if (arg is "-c" or "--configuration")
+ {
+ configuration = ReadOptionValue(arg);
+ }
+ else
+ {
+ bullseyeArgs.Add(arg);
+ }
+ }
+
+ return new(configuration, showHelp, bullseyeArgs.ToArray());
+
+ string ReadOptionValue(string arg)
+ {
+ if (!enumerator.MoveNext())
+ throw new InvalidOperationException($"Expected value for option '{arg}', but none was found.");
+
+ return enumerator.Current;
+ }
+ }
+
+ public static async Task PrintUsageAsync()
+ {
+ Console.WriteLine("Usage:");
+ Console.WriteLine(" build [-c|--configuration ] ");
+ Console.WriteLine();
+ Console.WriteLine("Arguments:");
+ Console.WriteLine(" Arguments to pass to Bullseye (targets and options, see below)");
+ Console.WriteLine();
+ Console.WriteLine("Options:");
+ Console.WriteLine(" -c, --configuration The configuration to build [default: Release]");
+ Console.WriteLine(" -? -h, --help Show help and usage information");
+ Console.WriteLine();
+ Console.WriteLine("Bullseye help:");
+ await RunTargetsWithoutExitingAsync(["--help"]);
+ }
+}
\ No newline at end of file
diff --git a/tools/build/Program.cs b/tools/build/Program.cs
new file mode 100644
index 0000000..4220200
--- /dev/null
+++ b/tools/build/Program.cs
@@ -0,0 +1,52 @@
+using System.Runtime.CompilerServices;
+using static Bullseye.Targets;
+using static SimpleExec.Command;
+
+var commandLineOptions = CommandLineOptions.Parse(args);
+
+Directory.SetCurrentDirectory(GetSolutionDirectory());
+
+string artifactsDir = Path.GetFullPath("artifacts");
+string logsDir = Path.Combine(artifactsDir, "logs");
+string buildLogFile = Path.Combine(logsDir, "build.binlog");
+string packagesDir = Path.Combine(artifactsDir, "packages");
+
+string solutionFile = "NHotkey.sln";
+
+Target(
+ "artifactDirectories",
+ () =>
+ {
+ Directory.CreateDirectory(artifactsDir);
+ Directory.CreateDirectory(logsDir);
+ Directory.CreateDirectory(packagesDir);
+ });
+
+Target(
+ "build",
+ DependsOn("artifactDirectories"),
+ () => Run(
+ "dotnet",
+ $"build -c \"{commandLineOptions.Configuration}\" /bl:\"{buildLogFile}\" \"{solutionFile}\""));
+
+Target(
+ "pack",
+ DependsOn("artifactDirectories", "build"),
+ () => Run(
+ "dotnet",
+ $"pack -c \"{commandLineOptions.Configuration}\" --no-build -o \"{packagesDir}\""));
+
+Target("default", DependsOn("pack"));
+
+if (commandLineOptions.ShowHelp)
+{
+ await CommandLineOptions.PrintUsageAsync();
+ return;
+}
+
+await RunTargetsAndExitAsync(commandLineOptions.BullseyeArgs);
+
+static string GetSolutionDirectory() =>
+ Path.GetFullPath(Path.Combine(GetScriptDirectory(), @"..\.."));
+
+static string GetScriptDirectory([CallerFilePath] string filename = null) => Path.GetDirectoryName(filename);
\ No newline at end of file
diff --git a/tools/build/build.csproj b/tools/build/build.csproj
index cac21ae..f808588 100644
--- a/tools/build/build.csproj
+++ b/tools/build/build.csproj
@@ -2,14 +2,13 @@
Exe
- netcoreapp2.1
- false
+ net8.0
+ true
-
-
-
+
+