From b12aecd9c72ecdb9d5d4a16c3649080860b57de2 Mon Sep 17 00:00:00 2001 From: Maxhy Date: Wed, 22 May 2024 21:55:17 +0200 Subject: [PATCH] Ensure User Elevation on application global Settings Update version --- .../KeyManager.Library.KeyGen.csproj | 2 +- .../KeyManager.Library.KeyStore.File.csproj | 2 +- .../KeyManager.Library.KeyStore.LCP.UI.csproj | 2 +- .../KeyManager.Library.KeyStore.LCP.csproj | 2 +- .../KeyManager.Library.KeyStore.NXP_SAM.UI.csproj | 2 +- .../KeyManager.Library.KeyStore.SAM_SE.UI.csproj | 2 +- .../KeyManager.Library.Plugin.UI.csproj | 2 +- .../KeyManager.Library.Plugin.csproj | 2 +- KeyManager.Library.UI/Favorites.cs | 2 +- KeyManager.Library.UI/KeyManager.Library.UI.csproj | 4 ++-- KeyManager.Library/KeyManager.Library.csproj | 2 +- KeyManager.Setup/Product.wxs | 8 +++++++- KeyManager.Setup/config.wxi | 2 +- KeyManager/KMLeosacAppInfo.cs | 10 +++++++--- KeyManager/KeyManager.csproj | 4 ++-- KeyManager/SettingsWindow.xaml.cs | 10 +++++++++- 16 files changed, 38 insertions(+), 20 deletions(-) diff --git a/KeyManager.Library.KeyGen/KeyManager.Library.KeyGen.csproj b/KeyManager.Library.KeyGen/KeyManager.Library.KeyGen.csproj index 62cb9f7..9dec738 100644 --- a/KeyManager.Library.KeyGen/KeyManager.Library.KeyGen.csproj +++ b/KeyManager.Library.KeyGen/KeyManager.Library.KeyGen.csproj @@ -10,7 +10,7 @@ True Leosac.$(AssemblyName) - 1.16.0 + 1.16.1 Leosac Key Manager Key Generation Library Leosac SAS Leosac Key Manager diff --git a/KeyManager.Library.KeyStore.File/KeyManager.Library.KeyStore.File.csproj b/KeyManager.Library.KeyStore.File/KeyManager.Library.KeyStore.File.csproj index 3db4967..3673dcc 100644 --- a/KeyManager.Library.KeyStore.File/KeyManager.Library.KeyStore.File.csproj +++ b/KeyManager.Library.KeyStore.File/KeyManager.Library.KeyStore.File.csproj @@ -11,7 +11,7 @@ True Leosac.$(AssemblyName) - 1.16.0 + 1.16.1 Leosac Key Manager File Key Store Library Leosac SAS Leosac Key Manager diff --git a/KeyManager.Library.KeyStore.LCP.UI/KeyManager.Library.KeyStore.LCP.UI.csproj b/KeyManager.Library.KeyStore.LCP.UI/KeyManager.Library.KeyStore.LCP.UI.csproj index 12fda31..d3e7447 100644 --- a/KeyManager.Library.KeyStore.LCP.UI/KeyManager.Library.KeyStore.LCP.UI.csproj +++ b/KeyManager.Library.KeyStore.LCP.UI/KeyManager.Library.KeyStore.LCP.UI.csproj @@ -10,7 +10,7 @@ - + runtime diff --git a/KeyManager.Library.KeyStore.LCP/KeyManager.Library.KeyStore.LCP.csproj b/KeyManager.Library.KeyStore.LCP/KeyManager.Library.KeyStore.LCP.csproj index 6978f15..91074e3 100644 --- a/KeyManager.Library.KeyStore.LCP/KeyManager.Library.KeyStore.LCP.csproj +++ b/KeyManager.Library.KeyStore.LCP/KeyManager.Library.KeyStore.LCP.csproj @@ -11,7 +11,7 @@ True Leosac.$(AssemblyName) - 1.16.0 + 1.16.1 Leosac Key Manager LCP Key Store Library Leosac SAS Leosac Key Manager diff --git a/KeyManager.Library.KeyStore.NXP_SAM.UI/KeyManager.Library.KeyStore.NXP_SAM.UI.csproj b/KeyManager.Library.KeyStore.NXP_SAM.UI/KeyManager.Library.KeyStore.NXP_SAM.UI.csproj index f695005..91aa2e0 100644 --- a/KeyManager.Library.KeyStore.NXP_SAM.UI/KeyManager.Library.KeyStore.NXP_SAM.UI.csproj +++ b/KeyManager.Library.KeyStore.NXP_SAM.UI/KeyManager.Library.KeyStore.NXP_SAM.UI.csproj @@ -10,7 +10,7 @@ - + runtime diff --git a/KeyManager.Library.KeyStore.SAM_SE.UI/KeyManager.Library.KeyStore.SAM_SE.UI.csproj b/KeyManager.Library.KeyStore.SAM_SE.UI/KeyManager.Library.KeyStore.SAM_SE.UI.csproj index 60eb64d..0418846 100644 --- a/KeyManager.Library.KeyStore.SAM_SE.UI/KeyManager.Library.KeyStore.SAM_SE.UI.csproj +++ b/KeyManager.Library.KeyStore.SAM_SE.UI/KeyManager.Library.KeyStore.SAM_SE.UI.csproj @@ -10,7 +10,7 @@ - + runtime diff --git a/KeyManager.Library.Plugin.UI/KeyManager.Library.Plugin.UI.csproj b/KeyManager.Library.Plugin.UI/KeyManager.Library.Plugin.UI.csproj index ed47460..0884844 100644 --- a/KeyManager.Library.Plugin.UI/KeyManager.Library.Plugin.UI.csproj +++ b/KeyManager.Library.Plugin.UI/KeyManager.Library.Plugin.UI.csproj @@ -10,7 +10,7 @@ True Leosac.$(AssemblyName) - 1.16.0 + 1.16.1 Leosac Key Manager Plugin UI Library Leosac SAS Leosac Key Manager diff --git a/KeyManager.Library.Plugin/KeyManager.Library.Plugin.csproj b/KeyManager.Library.Plugin/KeyManager.Library.Plugin.csproj index a4221ab..b794163 100644 --- a/KeyManager.Library.Plugin/KeyManager.Library.Plugin.csproj +++ b/KeyManager.Library.Plugin/KeyManager.Library.Plugin.csproj @@ -9,7 +9,7 @@ True Leosac.$(AssemblyName) - 1.16.0 + 1.16.1 Leosac Key Manager Plugin Library Leosac SAS Leosac Key Manager diff --git a/KeyManager.Library.UI/Favorites.cs b/KeyManager.Library.UI/Favorites.cs index 37ec1c1..859d037 100644 --- a/KeyManager.Library.UI/Favorites.cs +++ b/KeyManager.Library.UI/Favorites.cs @@ -35,7 +35,7 @@ public Favorites() { try { - _settings = KMSettings.LoadFromFile(true); + _settings = KMSettings.LoadFromFile(false); if (!string.IsNullOrEmpty(_settings?.FavoritesPath)) { _singleton = LoadFromFile(_settings.FavoritesPath); diff --git a/KeyManager.Library.UI/KeyManager.Library.UI.csproj b/KeyManager.Library.UI/KeyManager.Library.UI.csproj index 5fe83dc..4ce342c 100644 --- a/KeyManager.Library.UI/KeyManager.Library.UI.csproj +++ b/KeyManager.Library.UI/KeyManager.Library.UI.csproj @@ -11,7 +11,7 @@ True Leosac.$(AssemblyName) - 1.16.0 + 1.16.1 Leosac Key Manager UI Library Leosac SAS Leosac Key Manager @@ -31,7 +31,7 @@ - + diff --git a/KeyManager.Library/KeyManager.Library.csproj b/KeyManager.Library/KeyManager.Library.csproj index 1e2b4f6..2af7c50 100644 --- a/KeyManager.Library/KeyManager.Library.csproj +++ b/KeyManager.Library/KeyManager.Library.csproj @@ -10,7 +10,7 @@ True Leosac.$(AssemblyName) - 1.16.0 + 1.16.1 Leosac Key Manager Core Library Leosac SAS Leosac Key Manager diff --git a/KeyManager.Setup/Product.wxs b/KeyManager.Setup/Product.wxs index 2fc3473..31ec14c 100644 --- a/KeyManager.Setup/Product.wxs +++ b/KeyManager.Setup/Product.wxs @@ -125,7 +125,13 @@ - + + + + + + + diff --git a/KeyManager.Setup/config.wxi b/KeyManager.Setup/config.wxi index 131191d..083cfe6 100644 --- a/KeyManager.Setup/config.wxi +++ b/KeyManager.Setup/config.wxi @@ -1,7 +1,7 @@  - + diff --git a/KeyManager/KMLeosacAppInfo.cs b/KeyManager/KMLeosacAppInfo.cs index 3c845d5..1867463 100644 --- a/KeyManager/KMLeosacAppInfo.cs +++ b/KeyManager/KMLeosacAppInfo.cs @@ -25,9 +25,13 @@ public KMLeosacAppInfo() ApplicationLogo = "/images/leosac_key.png"; SettingsCommand = new RelayCommand(() => { - var settingsWindow = new SettingsWindow(); - settingsWindow.DataContext = KMSettings.LoadFromFile(false); - settingsWindow.ShowDialog(); + var settings = KMSettings.LoadFromFile(false); + if (settings != null && settings.EnsureElevation()) + { + var settingsWindow = new SettingsWindow(); + settingsWindow.DataContext = settings; + settingsWindow.ShowDialog(); + } }); PerUserInstallation = null; // Automatic decision based on program installation } diff --git a/KeyManager/KeyManager.csproj b/KeyManager/KeyManager.csproj index b9aaaf4..d52cc0e 100644 --- a/KeyManager/KeyManager.csproj +++ b/KeyManager/KeyManager.csproj @@ -5,7 +5,7 @@ net8.0-windows7.0 enable true - 1.16.0 + 1.16.1 Leosac Key Manager Key Manager for Access Control and RFID related technologies, by Leosac. Leosac SAS @@ -25,7 +25,7 @@ - + diff --git a/KeyManager/SettingsWindow.xaml.cs b/KeyManager/SettingsWindow.xaml.cs index 3f8e6be..cca5e3b 100644 --- a/KeyManager/SettingsWindow.xaml.cs +++ b/KeyManager/SettingsWindow.xaml.cs @@ -1,5 +1,6 @@ using Leosac.KeyManager.Library.UI; using Microsoft.Win32; +using System; using System.Windows; namespace Leosac.KeyManager @@ -18,7 +19,14 @@ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs { if (DataContext is KMSettings settings) { - settings.SaveToFile(); + try + { + settings.SaveToFile(); + } + catch(Exception ex) + { + MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); + } } }