diff --git a/GHelper.csproj b/GHelper.csproj index 3032eb4b..603da06f 100644 --- a/GHelper.csproj +++ b/GHelper.csproj @@ -2,7 +2,7 @@ WinExe - net7.0-windows8.0 + net7.0-windows10.0.17763.0 enable True enable @@ -33,6 +33,7 @@ + diff --git a/Settings.cs b/Settings.cs index 9fbeb6e0..aea70793 100644 --- a/Settings.cs +++ b/Settings.cs @@ -1,5 +1,8 @@ using System.Diagnostics; using System.Timers; +using System.Windows.Forms; +using Windows.UI.Notifications; +using Microsoft.Toolkit.Uwp.Notifications; namespace GHelper { @@ -374,6 +377,12 @@ namespace GHelper buttonBalanced.FlatAppearance.BorderSize = buttonInactive; buttonTurbo.FlatAppearance.BorderSize = buttonInactive; + string[] mode = new string[]{ + "Balanced", + "Turbo", + "Silent" + }; + switch (PerformanceMode) { case ASUSWmi.PerformanceSilent: @@ -391,24 +400,45 @@ namespace GHelper break; } + string notifTitle = "Performance Mode Changed"; + string notifBody = "Switched to: " + mode[PerformanceMode]; Program.config.setConfig("performance_mode", PerformanceMode); try { Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode); - } - catch + } catch { labelPerf.Text = "Performance Mode: not supported"; } + if(notify) + sendNotification(notifTitle, notifBody); } 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");