mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Logger and minor changes
This commit is contained in:
@@ -183,7 +183,7 @@ public class ASUSWmi
|
||||
if (curve.Length != 16) return;
|
||||
if (curve.All(singleByte => singleByte == 0)) return;
|
||||
|
||||
Debug.WriteLine(BitConverter.ToString(curve));
|
||||
Logger.WriteLine("Fans" + ((device == 1)?"GPU":"CPU") + " " + BitConverter.ToString(curve));
|
||||
|
||||
if (device == 1)
|
||||
DeviceSet(DevsGPUFanCurve, curve);
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
<System.Windows.Forms.ApplicationConfigurationSection>
|
||||
<add key="DpiAwareness" value="PerMonitorV2" />
|
||||
</System.Windows.Forms.ApplicationConfigurationSection>
|
||||
<appSettings>
|
||||
<add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
|
||||
</appSettings>
|
||||
</configuration>
|
||||
|
||||
<appSettings>
|
||||
<add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
|
||||
</appSettings>
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net7.0-windows8.0</TargetFramework>
|
||||
<TargetFramework>net7.0-windows10.0.17763.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>True</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
@@ -11,7 +11,7 @@
|
||||
<StartupObject>GHelper.Program</StartupObject>
|
||||
<ApplicationIcon>favicon.ico</ApplicationIcon>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<SupportedOSPlatformVersion>8.0</SupportedOSPlatformVersion>
|
||||
<SupportedOSPlatformVersion>10.0.17763.0</SupportedOSPlatformVersion>
|
||||
<AssemblyName>GHelper</AssemblyName>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||
|
||||
34
Program.cs
34
Program.cs
@@ -30,10 +30,28 @@ public class HardwareMonitor
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.WriteLine("Failed reading sensors");
|
||||
Logger.WriteLine("Failed reading sensors");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public static class Logger
|
||||
{
|
||||
public static void WriteLine(string logMessage)
|
||||
{
|
||||
var appPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GHelper";
|
||||
var logFile = appPath + "\\log.txt";
|
||||
|
||||
if (!Directory.Exists(appPath)) Directory.CreateDirectory(appPath);
|
||||
|
||||
using (StreamWriter w = File.AppendText(logFile))
|
||||
{
|
||||
Debug.WriteLine(logMessage);
|
||||
w.WriteLine($"{DateTime.Now.ToUniversalTime()}: {logMessage}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace GHelper
|
||||
@@ -41,6 +59,7 @@ namespace GHelper
|
||||
static class Program
|
||||
{
|
||||
|
||||
|
||||
// Native methods for sleep detection
|
||||
|
||||
[DllImport("Powrprof.dll", SetLastError = true)]
|
||||
@@ -138,7 +157,7 @@ namespace GHelper
|
||||
|
||||
private static int DeviceNotifyCallback(IntPtr context, int type, IntPtr setting)
|
||||
{
|
||||
//Debug.WriteLine($"Power callback type: {type}");
|
||||
Logger.WriteLine($"Power callback {type}");
|
||||
switch (type)
|
||||
{
|
||||
case PBT_APMRESUMEAUTOMATIC:
|
||||
@@ -146,7 +165,7 @@ namespace GHelper
|
||||
{
|
||||
// Fix for bugging buios on wake up
|
||||
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, (config.getConfig("performance_mode")+1) % 3);
|
||||
Thread.Sleep(500);
|
||||
Thread.Sleep(3000);
|
||||
|
||||
SetAutoModes();
|
||||
});
|
||||
@@ -184,7 +203,7 @@ namespace GHelper
|
||||
|
||||
}
|
||||
} catch {
|
||||
Debug.WriteLine("Failed to get update");
|
||||
Logger.WriteLine("Failed to get update");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -194,7 +213,7 @@ namespace GHelper
|
||||
{
|
||||
PowerLineStatus isPlugged = SystemInformation.PowerStatus.PowerLineStatus;
|
||||
|
||||
Debug.WriteLine(isPlugged.ToString());
|
||||
Logger.WriteLine("Power " + isPlugged.ToString());
|
||||
|
||||
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
||||
|
||||
@@ -207,6 +226,7 @@ namespace GHelper
|
||||
|
||||
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
||||
{
|
||||
Logger.WriteLine("Windows - Power Mode Changed");
|
||||
SetAutoModes();
|
||||
}
|
||||
|
||||
@@ -223,7 +243,7 @@ namespace GHelper
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.WriteLine("Failed to run " + fileName);
|
||||
Logger.WriteLine("Failed to run " + fileName);
|
||||
}
|
||||
|
||||
|
||||
@@ -300,7 +320,7 @@ namespace GHelper
|
||||
|
||||
int EventID = int.Parse(e.NewEvent["EventID"].ToString());
|
||||
|
||||
Debug.WriteLine(EventID);
|
||||
Logger.WriteLine("WMI event "+EventID);
|
||||
|
||||
switch (EventID)
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Diagnostics;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Timers;
|
||||
|
||||
|
||||
namespace GHelper
|
||||
{
|
||||
|
||||
@@ -525,7 +526,7 @@ namespace GHelper
|
||||
Program.wmi.DeviceSet(ASUSWmi.ScreenOverdrive, overdrive);
|
||||
|
||||
InitScreen();
|
||||
Debug.WriteLine(frequency);
|
||||
Logger.WriteLine("Screen "+ frequency.ToString() + "Hz");
|
||||
|
||||
}
|
||||
|
||||
@@ -559,7 +560,7 @@ namespace GHelper
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.WriteLine("Screen Overdrive not supported");
|
||||
Logger.WriteLine("Screen Overdrive not supported");
|
||||
}
|
||||
|
||||
button60Hz.FlatAppearance.BorderSize = buttonInactive;
|
||||
@@ -702,7 +703,7 @@ namespace GHelper
|
||||
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA1, limit_total);
|
||||
Program.wmi.DeviceSet(ASUSWmi.PPT_CPUB0, limit_cpu);
|
||||
|
||||
Debug.WriteLine(limit_total.ToString() + ", " + limit_cpu.ToString());
|
||||
Logger.WriteLine("PowerLimits "+limit_total.ToString() + ", " + limit_cpu.ToString());
|
||||
|
||||
|
||||
}
|
||||
@@ -760,7 +761,7 @@ namespace GHelper
|
||||
Program.config.setConfig("performance_mode", PerformanceMode);
|
||||
|
||||
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode);
|
||||
Debug.WriteLine("Perf:" + PerformanceMode);
|
||||
Logger.WriteLine("PerfMode " + perfName + " "+ PerformanceMode);
|
||||
|
||||
if (notify && (oldMode != PerformanceMode))
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@ public class Startup
|
||||
|
||||
td.Settings.StopIfGoingOnBatteries = false;
|
||||
td.Settings.DisallowStartIfOnBatteries = false;
|
||||
td.Settings.ExecutionTimeLimit = TimeSpan.Zero;
|
||||
|
||||
Debug.WriteLine(strExeFilePath);
|
||||
Debug.WriteLine(userId);
|
||||
@@ -36,9 +37,9 @@ public class Startup
|
||||
try
|
||||
{
|
||||
TaskService.Instance.RootFolder.RegisterTaskDefinition(taskName, td);
|
||||
} catch
|
||||
} catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("Can't schedule task", "Scheduler Error", MessageBoxButtons.OK);
|
||||
MessageBox.Show(e.ToString(), "Scheduler Error", MessageBoxButtons.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user