mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Merge pull request #14 from Albert24GG/notification-feature
Send notification on performance mode cycling
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net7.0-windows8.0</TargetFramework>
|
<TargetFramework>net7.0-windows10.0.17763.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWindowsForms>True</UseWindowsForms>
|
<UseWindowsForms>True</UseWindowsForms>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="hidlibrary" Version="3.3.40" />
|
<PackageReference Include="hidlibrary" Version="3.3.40" />
|
||||||
|
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
|
||||||
<PackageReference Include="LibreHardwareMonitorLib" Version="0.9.1" />
|
<PackageReference Include="LibreHardwareMonitorLib" Version="0.9.1" />
|
||||||
<PackageReference Include="System.Management" Version="7.0.0" />
|
<PackageReference Include="System.Management" Version="7.0.0" />
|
||||||
<PackageReference Include="TaskScheduler" Version="2.10.1" />
|
<PackageReference Include="TaskScheduler" Version="2.10.1" />
|
||||||
|
|||||||
36
Settings.cs
36
Settings.cs
@@ -1,5 +1,8 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using Windows.UI.Notifications;
|
||||||
|
using Microsoft.Toolkit.Uwp.Notifications;
|
||||||
|
|
||||||
namespace GHelper
|
namespace GHelper
|
||||||
{
|
{
|
||||||
@@ -374,6 +377,12 @@ namespace GHelper
|
|||||||
buttonBalanced.FlatAppearance.BorderSize = buttonInactive;
|
buttonBalanced.FlatAppearance.BorderSize = buttonInactive;
|
||||||
buttonTurbo.FlatAppearance.BorderSize = buttonInactive;
|
buttonTurbo.FlatAppearance.BorderSize = buttonInactive;
|
||||||
|
|
||||||
|
string[] mode = new string[]{
|
||||||
|
"Balanced",
|
||||||
|
"Turbo",
|
||||||
|
"Silent"
|
||||||
|
};
|
||||||
|
|
||||||
switch (PerformanceMode)
|
switch (PerformanceMode)
|
||||||
{
|
{
|
||||||
case ASUSWmi.PerformanceSilent:
|
case ASUSWmi.PerformanceSilent:
|
||||||
@@ -391,24 +400,45 @@ namespace GHelper
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string notifTitle = "Performance Mode Changed";
|
||||||
|
string notifBody = "Switched to: " + mode[PerformanceMode];
|
||||||
Program.config.setConfig("performance_mode", PerformanceMode);
|
Program.config.setConfig("performance_mode", PerformanceMode);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode);
|
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode);
|
||||||
}
|
} catch
|
||||||
catch
|
|
||||||
{
|
{
|
||||||
labelPerf.Text = "Performance Mode: not supported";
|
labelPerf.Text = "Performance Mode: not supported";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(notify)
|
||||||
|
sendNotification(notifTitle, notifBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void CyclePerformanceMode()
|
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)
|
public void AutoScreen(int Plugged = 1)
|
||||||
{
|
{
|
||||||
int ScreenAuto = Program.config.getConfig("screen_auto");
|
int ScreenAuto = Program.config.getConfig("screen_auto");
|
||||||
|
|||||||
Reference in New Issue
Block a user