diff --git a/App/App.csproj b/App/App.csproj
index 59376d3..84860a4 100644
--- a/App/App.csproj
+++ b/App/App.csproj
@@ -16,7 +16,7 @@
10.0.22000.0
PerMonitorV2
AnyCPU;x64;ARM64;x86
- 2.1.5
+ 2.1.6
https://github.com/soleon/Percentage
https://github.com/soleon/Percentage?tab=MIT-1-ov-file
Icon.png
diff --git a/App/App.xaml.cs b/App/App.xaml.cs
index f8e0d0c..b473ba9 100644
--- a/App/App.xaml.cs
+++ b/App/App.xaml.cs
@@ -27,12 +27,14 @@ public partial class App
internal const string DefaultBatteryLowColour = "#FFCA5010";
internal const bool DefaultBatteryLowNotification = true;
internal const int DefaultBatteryLowNotificationValue = 20;
+ internal const bool DefaultDoubleClickActivation = false;
internal const bool DefaultHideAtStartup = false;
internal const bool DefaultIsAutoBatteryChargingColour = false;
internal const bool DefaultIsAutoBatteryCriticalColour = false;
internal const bool DefaultIsAutoBatteryLowColour = false;
internal const bool DefaultIsAutoBatteryNormalColour = true;
internal const int DefaultRefreshSeconds = 60;
+ internal const bool DefaultShutDownWithoutConfirmation = false;
internal const bool DefaultTrayIconFontBold = false;
internal const int DefaultTrayIconFontSize = 16;
internal const bool DefaultTrayIconFontUnderline = false;
diff --git a/App/Extensions/ExternalProcessExtensions.cs b/App/Extensions/ExternalProcessExtensions.cs
index e606c4c..d5da26e 100644
--- a/App/Extensions/ExternalProcessExtensions.cs
+++ b/App/Extensions/ExternalProcessExtensions.cs
@@ -29,6 +29,14 @@ internal static void ShowRatingView()
StartShellExecutedProgress("ms-windows-store://review/?ProductId=9PCKT2B7DZMW");
}
+ public static void ShutDownDevice()
+ {
+ Process.Start(new ProcessStartInfo("shutdown", "/s /t 0")
+ {
+ CreateNoWindow = true
+ });
+ }
+
internal static void SleepDevice()
{
// Parameter 0,0,0 for "SetSuspendState" native function:
diff --git a/App/NotifyIconWindow.xaml b/App/NotifyIconWindow.xaml
index a1eaca1..da7b912 100644
--- a/App/NotifyIconWindow.xaml
+++ b/App/NotifyIconWindow.xaml
@@ -12,7 +12,8 @@
+ LeftDoubleClick="OnNotifyIconLeftDoubleClick"
+ LeftClick="OnNotifyIconLeftClick">
+
_batteryStatusUpdateSubject.OnNext(false);
}
+ private static async Task ShutDownAsync()
+ {
+ if (!Default.ShutDownWithoutConfirmation)
+ {
+ var result = await new MessageBox
+ {
+ Title = "Shut Down",
+ Content = "Are you sure you want to shut down your device?",
+ PrimaryButtonAppearance = ControlAppearance.Caution,
+ PrimaryButtonText = "Yes",
+ SecondaryButtonAppearance = ControlAppearance.Caution,
+ SecondaryButtonText = "Always Yes",
+ CloseButtonText = "No"
+ }.ShowDialogAsync().ConfigureAwait(false);
+
+ switch (result)
+ {
+ case MessageBoxResult.None:
+ return;
+ case MessageBoxResult.Primary:
+ break;
+ case MessageBoxResult.Secondary:
+ Default.ShutDownWithoutConfirmation = true;
+ Default.Save();
+ break;
+ default:
+ throw new InvalidEnumArgumentException($"{result} is not a supported enum value.");
+ }
+ }
+
+ ExternalProcessExtensions.ShutDownDevice();
+ }
+
private void OnAboutMenuItemClick(object sender, RoutedEventArgs e)
{
Application.Current.ActivateMainWindow().NavigateToPage();
@@ -107,9 +144,21 @@ private void OnLoaded(object sender, RoutedEventArgs args)
_refreshTimer.Start();
}
+ private void OnNotifyIconLeftClick(NotifyIcon sender, RoutedEventArgs e)
+ {
+ if (!Default.DoubleClickActivation)
+ Application.Current.ActivateMainWindow().NavigateToPage();
+ }
+
private void OnNotifyIconLeftDoubleClick(NotifyIcon sender, RoutedEventArgs e)
{
- Application.Current.ActivateMainWindow().NavigateToPage();
+ if (Default.DoubleClickActivation)
+ Application.Current.ActivateMainWindow().NavigateToPage();
+ }
+
+ private void OnShutDownMenuItemClick(object sender, RoutedEventArgs e)
+ {
+ _ = ShutDownAsync();
}
private void OnSleepMenuItemClick(object sender, RoutedEventArgs e)
diff --git a/App/Pages/SettingsPage.xaml b/App/Pages/SettingsPage.xaml
index 8b3aa16..417ed33 100644
--- a/App/Pages/SettingsPage.xaml
+++ b/App/Pages/SettingsPage.xaml
@@ -54,6 +54,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -63,7 +93,7 @@
FontTypography="BodyStrong"
Text="Refresh" />
+ Text="How frequent the battery status is refreshed" />
+ Text="Change tray icon font, size and style" />
@@ -132,7 +162,7 @@
FontTypography="BodyStrong"
Text="Tray icon colour" />
+ Text="Change tray icon colour for different battery levels" />
@@ -183,7 +213,7 @@
FontTypography="BodyStrong"
Text="Battery levels & notifications" />
+ Text="Change notifications for different battery levels" />
@@ -208,7 +238,8 @@
-
+
@@ -217,7 +248,7 @@
FontTypography="BodyStrong"
Text="Power & battery" />
+ Text="Open system power and battery settings" />
diff --git a/App/Pages/SettingsPage.xaml.cs b/App/Pages/SettingsPage.xaml.cs
index 6508389..6bea4ea 100644
--- a/App/Pages/SettingsPage.xaml.cs
+++ b/App/Pages/SettingsPage.xaml.cs
@@ -131,6 +131,8 @@ private void OnResetButtonClick(object sender, RoutedEventArgs e)
Default.IsAutoBatteryChargingColour = App.DefaultIsAutoBatteryChargingColour;
Default.IsAutoBatteryLowColour = App.DefaultIsAutoBatteryLowColour;
Default.IsAutoBatteryCriticalColour = App.DefaultIsAutoBatteryCriticalColour;
+ Default.DoubleClickActivation = App.DefaultDoubleClickActivation;
+ Default.ShutDownWithoutConfirmation = App.DefaultShutDownWithoutConfirmation;
_ = EnableAutoStart();
}
diff --git a/App/Properties/Settings.Designer.cs b/App/Properties/Settings.Designer.cs
index afbc258..a88f168 100644
--- a/App/Properties/Settings.Designer.cs
+++ b/App/Properties/Settings.Designer.cs
@@ -285,5 +285,29 @@ public double TrayIconFontSize {
this["TrayIconFontSize"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ public bool DoubleClickActivation {
+ get {
+ return ((bool)(this["DoubleClickActivation"]));
+ }
+ set {
+ this["DoubleClickActivation"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ public bool ShutDownWithoutConfirmation {
+ get {
+ return ((bool)(this["ShutDownWithoutConfirmation"]));
+ }
+ set {
+ this["ShutDownWithoutConfirmation"] = value;
+ }
+ }
}
}
diff --git a/App/Properties/Settings.settings b/App/Properties/Settings.settings
index 133ca2f..7cdb1c7 100644
--- a/App/Properties/Settings.settings
+++ b/App/Properties/Settings.settings
@@ -68,6 +68,12 @@
16
+
+ False
+
+
+ False
+
diff --git a/Pack/Package.appxmanifest b/Pack/Package.appxmanifest
index ac42f11..ba93d05 100644
--- a/Pack/Package.appxmanifest
+++ b/Pack/Package.appxmanifest
@@ -12,7 +12,7 @@
+ Version="2.1.6.0" />
Battery Percentage Icon