diff --git a/GHelper.csproj b/GHelper.csproj index 382b440b..c8f73898 100644 --- a/GHelper.csproj +++ b/GHelper.csproj @@ -2,7 +2,7 @@ WinExe - net7.0-windows + net7.0-windows10.0.17763.0 enable True enable @@ -31,6 +31,7 @@ + diff --git a/Settings.cs b/Settings.cs index dc9a2083..8554d10f 100644 --- a/Settings.cs +++ b/Settings.cs @@ -3,6 +3,8 @@ using System.Diagnostics; using System.Management; using System.Timers; using System.Windows.Forms; +using Windows.UI.Notifications; +using Microsoft.Toolkit.Uwp.Notifications; namespace GHelper { @@ -331,28 +333,37 @@ namespace GHelper buttonBalanced.FlatAppearance.BorderSize = buttonInactive; buttonTurbo.FlatAppearance.BorderSize = buttonInactive; + string[] mode = new string[]{ + "Balanced", + "Turbo", + "Silent" + }; + switch (PerformanceMode) { case ASUSWmi.PerformanceSilent: buttonSilent.FlatAppearance.BorderSize = buttonActive; - labelPerf.Text = "Performance Mode: Silent"; break; case ASUSWmi.PerformanceTurbo: buttonTurbo.FlatAppearance.BorderSize = buttonActive; - labelPerf.Text = "Performance Mode: Turbo"; break; default: buttonBalanced.FlatAppearance.BorderSize = buttonActive; - labelPerf.Text = "Performance Mode: Balanced"; PerformanceMode = ASUSWmi.PerformanceBalanced; break; } + labelPerf.Text = "Performance Mode: " + mode[PerformanceMode]; + + string notifTitle = "Performance Mode Changed"; + string notifBody = "Switched to: " + mode[PerformanceMode]; Program.config.setConfig("performance_mode", PerformanceMode); try { Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode); + if(notify) + sendNotification(notifTitle, notifBody); } catch { labelPerf.Text = "Performance Mode: not supported"; @@ -363,9 +374,27 @@ namespace GHelper public void CyclePerformanceMode() { - SetPerformanceMode(Program.config.getConfig("performance_mode") + 1); + SetPerformanceMode(Program.config.getConfig("performance_mode") + 1, true); } + + public void sendNotification(string title, string message) + { + var content = new ToastContentBuilder() + .AddText(title) + .AddText(message) + .SetToastDuration(ToastDuration.Short) + .GetToastContent(); + + var notification = new ToastNotification(content.GetXml()) + { + Priority = ToastNotificationPriority.High + }; + + ToastNotificationManagerCompat.CreateToastNotifier().Show(notification); + } + + public void AutoScreen(int Plugged = 1) { int ScreenAuto = Program.config.getConfig("screen_auto");