diff --git a/Installer/Product.wxs b/Installer/Product.wxs index c34e210..4859d49 100644 --- a/Installer/Product.wxs +++ b/Installer/Product.wxs @@ -3,7 +3,7 @@ diff --git a/NfcActions-Setup-v1.0.2.msi b/NfcActions-Setup-v1.0.2.msi new file mode 100644 index 0000000..9939a48 Binary files /dev/null and b/NfcActions-Setup-v1.0.2.msi differ diff --git a/NfcActions/App.xaml.cs b/NfcActions/App.xaml.cs index 90cb1d8..cf971fd 100644 --- a/NfcActions/App.xaml.cs +++ b/NfcActions/App.xaml.cs @@ -1,7 +1,9 @@ using System; using System.Drawing; +using System.Threading; using System.Windows; using System.Windows.Forms; +using System.Windows.Media; using NfcActions.Services; using NfcActions.ViewModels; using Application = System.Windows.Application; @@ -13,6 +15,7 @@ namespace NfcActions; /// public partial class App : Application { + private static Mutex? _instanceMutex; private NotifyIcon? _notifyIcon; private Icon? _customIcon; private MainWindow? _mainWindow; @@ -24,6 +27,29 @@ public partial class App : Application private void Application_Startup(object sender, StartupEventArgs e) { + // Ensure only one instance runs at a time + bool createdNew; + _instanceMutex = new Mutex(true, "NfcActions_SingleInstance_Mutex", out createdNew); + + if (!createdNew) + { + System.Windows.MessageBox.Show("NFC Actions is already running. Check the system tray.", + "NFC Actions", + MessageBoxButton.OK, + MessageBoxImage.Information); + Shutdown(); + return; + } + + // Workaround for DirectWrite crash - force software rendering + try + { + RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly; + } + catch + { + // Ignore if this fails + } // Initialize services _logService = new LogService(); _cardReaderService = new CardReaderService(_logService); @@ -107,5 +133,7 @@ public partial class App : Application _notifyIcon?.Dispose(); _customIcon?.Dispose(); _cardReaderService?.Dispose(); + _instanceMutex?.ReleaseMutex(); + _instanceMutex?.Dispose(); } } diff --git a/NfcActions/NfcActions.csproj b/NfcActions/NfcActions.csproj index 526e501..1eec0c7 100644 --- a/NfcActions/NfcActions.csproj +++ b/NfcActions/NfcActions.csproj @@ -7,9 +7,9 @@ true true Resources\icon.ico - 1.0.0 - 1.0.0.0 - 1.0.0.0 + 1.0.2 + 1.0.2.0 + 1.0.2.0 Dangerous Things NFC Actions NFC card reader monitoring and action automation