Minor fixes

This commit is contained in:
seerge
2023-04-02 11:56:59 +02:00
parent 75c397d7a4
commit 5d86c821f6
7 changed files with 49 additions and 31 deletions

View File

@@ -294,11 +294,17 @@ public class ASUSWmi
public void SubscribeToEvents(Action<object, EventArrivedEventArgs> EventHandler)
{
ManagementEventWatcher watcher = new ManagementEventWatcher();
watcher.EventArrived += new EventArrivedEventHandler(EventHandler);
watcher.Scope = new ManagementScope("root\\wmi");
watcher.Query = new WqlEventQuery("SELECT * FROM AsusAtkWmiEvent");
watcher.Start();
try
{
ManagementEventWatcher watcher = new ManagementEventWatcher();
watcher.EventArrived += new EventArrivedEventHandler(EventHandler);
watcher.Scope = new ManagementScope("root\\wmi");
watcher.Query = new WqlEventQuery("SELECT * FROM AsusAtkWmiEvent");
watcher.Start();
} catch
{
Logger.WriteLine("Can't connect to ASUS WMI events");
}
}
}

View File

@@ -47,7 +47,7 @@ namespace GHelper
chart.ChartAreas[0].AxisY.LabelStyle.Font = new Font("Arial", 7F);
var foreAccent = Color.FromArgb(255, 100, 100, 100);
var foreAccent = Color.FromArgb(255, 180, 180, 180);
chart.ChartAreas[0].AxisX.MajorGrid.LineColor = foreAccent;
chart.ChartAreas[0].AxisY.MajorGrid.LineColor = foreAccent;

View File

@@ -16,7 +16,7 @@
<PlatformTarget>x64</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.45</AssemblyVersion>
<AssemblyVersion>0.46</AssemblyVersion>
</PropertyGroup>
<ItemGroup>
@@ -48,7 +48,7 @@
<PackageReference Include="NvAPIWrapper.Net" Version="0.8.1.101" />
<PackageReference Include="System.Management" Version="7.0.0" />
<PackageReference Include="TaskScheduler" Version="2.10.1" />
<PackageReference Include="WinForms.DataVisualization" Version="1.7.0" />
<PackageReference Include="WinForms.DataVisualization" Version="1.8.0" />
</ItemGroup>
<ItemGroup>

View File

@@ -78,7 +78,7 @@ public static class HardwareMonitor
Logger.WriteLine(ex.ToString());
}
if (gpuTemp < 0)
if (gpuTemp is null || gpuTemp < 0)
gpuTemp = Program.wmi.DeviceGet(ASUSWmi.Temp_GPU);

View File

@@ -131,6 +131,7 @@ namespace GHelper
bool switched = settingsForm.AutoGPUMode();
if (!switched) settingsForm.AutoScreen();
settingsForm.AutoKeyboard();
settingsForm.SetMatrix();
}
@@ -139,7 +140,6 @@ namespace GHelper
if (SystemInformation.PowerStatus.PowerLineStatus == isPlugged) return;
Logger.WriteLine("Windows - Power Mode Changed");
settingsForm.AutoKeyboard();
SetAutoModes();
}

View File

@@ -1011,10 +1011,10 @@ namespace GHelper
if (SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online)
Aura.ApplyBrightness(3);
//Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Up);
//Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Up);
else
Aura.ApplyBrightness(0);
//Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Down);
//Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Down);
}

View File

@@ -22,31 +22,43 @@ public class Startup
var userId = WindowsIdentity.GetCurrent().Name;
TaskDefinition td = TaskService.Instance.NewTask();
td.RegistrationInfo.Description = "GHelper Auto Start";
td.Triggers.Add(new LogonTrigger { UserId = userId });
td.Actions.Add(strExeFilePath);
td.Settings.StopIfGoingOnBatteries = false;
td.Settings.DisallowStartIfOnBatteries = false;
td.Settings.ExecutionTimeLimit = TimeSpan.Zero;
Debug.WriteLine(strExeFilePath);
Debug.WriteLine(userId);
try
using (TaskDefinition td = TaskService.Instance.NewTask())
{
TaskService.Instance.RootFolder.RegisterTaskDefinition(taskName, td);
} catch (Exception e)
{
MessageBox.Show(e.ToString(), "Scheduler Error", MessageBoxButtons.OK);
td.RegistrationInfo.Description = "G-Helper Auto Start";
td.Triggers.Add(new LogonTrigger { UserId = userId });
td.Actions.Add(strExeFilePath);
td.Settings.StopIfGoingOnBatteries = false;
td.Settings.DisallowStartIfOnBatteries = false;
td.Settings.ExecutionTimeLimit = TimeSpan.Zero;
Debug.WriteLine(strExeFilePath);
Debug.WriteLine(userId);
try
{
TaskService.Instance.RootFolder.RegisterTaskDefinition(taskName, td);
}
catch (Exception e)
{
MessageBox.Show("Can't create a start up task. Try running Task Scheduler by hand and manually deleting GHelper task if it exists there.", "Scheduler Error", MessageBoxButtons.OK);
}
}
}
public static void UnSchedule()
{
TaskService taskService = new TaskService();
taskService.RootFolder.DeleteTask(taskName);
using (TaskService taskService = new TaskService())
{
try
{
taskService.RootFolder.DeleteTask(taskName);
}
catch (Exception e)
{
MessageBox.Show("Can't remove task. Try running Task Scheduler by hand and manually deleting GHelper task if it exists there.", "Scheduler Error", MessageBoxButtons.OK);
}
}
}
}