diff --git a/Quick Link/CustomApplicationContext.cs b/Quick Link/CustomApplicationContext.cs index 4205e61..852aabf 100644 --- a/Quick Link/CustomApplicationContext.cs +++ b/Quick Link/CustomApplicationContext.cs @@ -1,10 +1,12 @@ using QuickLink.Properties; using System; using System.Diagnostics; +using System.Runtime.Versioning; using System.Windows.Forms; namespace QuickLink { + [SupportedOSPlatform("windows")] class CustomApplicationContext : ApplicationContext { private NotifyIcon trayIcon; @@ -27,11 +29,10 @@ public CustomApplicationContext() } }, Visible = true, - }; trayIcon.MouseClick += new MouseEventHandler(OnLeftClick); - hotkey.KeyPressed += new EventHandler((object sender, KeyPressedEventArgs e) => ShowQuickInputForm()); + hotkey.KeyPressed += (sender, e) => ShowQuickInputForm(); hotkey.RegisterHotKey(ModifierKeys.Control | ModifierKeys.Win, Keys.R); } diff --git a/Quick Link/GlobalKeyboardHotkey.cs b/Quick Link/GlobalKeyboardHotkey.cs index 300f314..a35d51c 100644 --- a/Quick Link/GlobalKeyboardHotkey.cs +++ b/Quick Link/GlobalKeyboardHotkey.cs @@ -1,9 +1,11 @@ using System; using System.Runtime.InteropServices; +using System.Runtime.Versioning; using System.Windows.Forms; namespace QuickLink { + [SupportedOSPlatform("windows")] public sealed class GlobalKeyboardHotkey : IDisposable { // Registers a hot key with Windows. @@ -65,7 +67,7 @@ public void Dispose() public GlobalKeyboardHotkey() { // register the event of the inner native window. - _window.KeyPressed += delegate (object sender, KeyPressedEventArgs args) + _window.KeyPressed += (sender, args) => { if (KeyPressed != null) KeyPressed(this, args); diff --git a/Quick Link/Program.cs b/Quick Link/Program.cs index e952868..8129f27 100644 --- a/Quick Link/Program.cs +++ b/Quick Link/Program.cs @@ -6,7 +6,8 @@ namespace QuickLink { internal static class Program { - static Mutex mutex = new Mutex(true, "{6d5a148c-92e2-42ee-bf0e-f8cc887619fd}"); + private static readonly Mutex mutex = new Mutex(true, "{6d5a148c-92e2-42ee-bf0e-f8cc887619fd}"); + [STAThread] static void Main() { @@ -22,7 +23,6 @@ static void Main() { MessageBox.Show("Quick Link is already running."); } - } } } diff --git a/Quick Link/Properties/AssemblyInfo.cs b/Quick Link/Properties/AssemblyInfo.cs index 658f1c3..07df3f1 100644 --- a/Quick Link/Properties/AssemblyInfo.cs +++ b/Quick Link/Properties/AssemblyInfo.cs @@ -1,6 +1,7 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Runtime.Versioning; // Allgemeine Informationen über eine Assembly werden über die folgenden // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, @@ -10,10 +11,13 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Benjamin Knoop")] [assembly: AssemblyProduct("Quick Link")] -[assembly: AssemblyCopyright("Copyright © 2024, 2025")] +[assembly: AssemblyCopyright("Copyright © 2024-2026, Benjamin Knoop")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] +// Diese Assembly ist Windows-spezifisch; reduziert CA1416-Warnungen für Windows-APIs. +[assembly: SupportedOSPlatform("windows")] + // Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly // für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von // COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen. diff --git a/Quick Link/Quick Link.csproj b/Quick Link/Quick Link.csproj index 45af866..0eacd55 100644 --- a/Quick Link/Quick Link.csproj +++ b/Quick Link/Quick Link.csproj @@ -1,110 +1,28 @@  - - + - Debug - AnyCPU - {EF4B0D54-A24D-4E76-AB9D-40DB857AC8DE} WinExe + net10.0-windows + true QuickLink QuickLink - v4.7.2 - 512 - true - true - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - x64 - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - x64 - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - QuickLink.Program - - SpiraPlan-FavIcon.ico + enable + enable + + true + true + + false + + - - - - - - - - - - - - - - - - - Form - - - QuickInputForm.cs - - - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - True - - - QuickInputForm.cs - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - + + @@ -112,17 +30,5 @@ - - - False - Microsoft .NET Framework 4.7.2 %28x86 und x64%29 - true - - - False - .NET Framework 3.5 SP1 - false - - - + \ No newline at end of file diff --git a/Quick Link/QuickInputForm.cs b/Quick Link/QuickInputForm.cs index bfca62c..b718d52 100644 --- a/Quick Link/QuickInputForm.cs +++ b/Quick Link/QuickInputForm.cs @@ -2,10 +2,12 @@ using System.Windows.Forms; using System.Diagnostics; using System.Text.RegularExpressions; +using System.Runtime.Versioning; using QuickLink.Properties; namespace QuickLink { + [SupportedOSPlatform("windows")] public partial class QuickInputForm : Form { private const int CP_NOCLOSE_BUTTON = 0x200; @@ -16,11 +18,11 @@ private enum TicketType { REQUIREMENT, INCIDENT, TESTCASE }; public QuickInputForm() { InitializeComponent(); - this.Deactivate += new System.EventHandler((object sender, EventArgs e) => Hide()); - this.KeyDown += new KeyEventHandler(OnEnterPressed); + TopMost = true; + Deactivate += (sender, e) => Hide(); + KeyDown += new KeyEventHandler(OnEnterPressed); TextBox.KeyDown += new KeyEventHandler(OnEnterPressed); TextBox.Select(); - this.TopMost = true; } public void ShowAndInitialize() @@ -168,8 +170,30 @@ private void OpenTicket(string validatedTicketString) } string url = CreateSpiraUrl(ticketType, "1011", number); Console.WriteLine("Opening {0}", url); - Process.Start(url); + OpenUrl(url); } + private void OpenUrl(string url) + { + if (!Uri.IsWellFormedUriString(url, UriKind.Absolute)) + { + Console.WriteLine("Invalid URL: " + url); + return; + } + + try + { + var psi = new ProcessStartInfo + { + FileName = url, + UseShellExecute = true + }; + Process.Start(psi); + } + catch (Exception ex) + { + Console.WriteLine("Error opening URL: " + ex.Message); + } + } } }