mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Send notification on performance mode cycling
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net7.0-windows</TargetFramework>
|
||||
<TargetFramework>net7.0-windows10.0.17763.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>True</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="hidlibrary" Version="3.3.40" />
|
||||
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
|
||||
<PackageReference Include="System.Management" Version="7.0.0" />
|
||||
<PackageReference Include="TaskScheduler" Version="2.10.1" />
|
||||
</ItemGroup>
|
||||
|
||||
37
Settings.cs
37
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");
|
||||
|
||||
Reference in New Issue
Block a user