Compare commits

..

6 Commits
v0.36 ... v0.38

Author SHA1 Message Date
seerge
9053764930 Speedup update checker 2023-03-23 13:26:09 +01:00
seerge
64871e5554 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-23 00:38:06 +01:00
seerge
b1c778b30d Minor tweaks 2023-03-23 00:38:03 +01:00
Serge
6932bb1889 Update README.md 2023-03-22 17:55:10 +01:00
seerge
c90a342ce8 Fixed possible memory leack with clock ticks 2023-03-22 17:28:09 +01:00
seerge
f223ca4a33 Added informational toolip 2023-03-22 17:15:20 +01:00
8 changed files with 113 additions and 103 deletions

View File

@@ -1,7 +1,6 @@
// Source thanks to https://github.com/vddCore/Starlight with some adjustments from me
using Starlight.Communication;
using System.Drawing;
using System.Management;
using System.Text;
@@ -91,7 +90,7 @@ namespace Starlight.AnimeMatrix
MaxColumns = 33;
FullRows = 7;
FullEvenRows = 6;
FullEvenRows = 1;
MaxRows = 55;
LedCount = 1214;
@@ -193,16 +192,14 @@ namespace Starlight.AnimeMatrix
Set(Packet<AnimeMatrixPacket>(0xC0, 0x03));
}
public int SetLedPlanar(int x, int y, byte value)
public void SetLedPlanar(int x, int y, byte value)
{
EnsureRowInRange(y);
var start = RowToLinearAddress(y) - XStart(y);
if (x >= XStart(y) && x < XEnd(y))
{
SetLedLinear(start + x, value);
return start + x;
}
return -1;
}
public void Clear(bool present = false)
@@ -270,41 +267,34 @@ namespace Starlight.AnimeMatrix
Set(Packet<AnimeMatrixPacket>(0xC5, animation.AsByte));
}
static int GetColor(Bitmap bmp, int x, int y)
public void PresentText(string text, float fontSize = 8F)
{
var pixel = bmp.GetPixel(Math.Max(0, Math.Min(bmp.Width - 1, x)), Math.Max(0, Math.Min(bmp.Height - 1, y)));
return (Math.Min((pixel.R + pixel.G + pixel.B) / 3, 255));
}
public void PresentText(string text, int fontSize = 8)
{
int width = MaxColumns * 3;
int height = MaxRows;
Bitmap bmp = new Bitmap(width, height);
using (Graphics g = Graphics.FromImage(bmp))
using (Bitmap bmp = new Bitmap(MaxColumns * 3, MaxRows))
{
using (Font font = new Font("Arial", fontSize))
using (Graphics g = Graphics.FromImage(bmp))
{
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
SizeF textSize = g.MeasureString(text, font);
/*
g.TranslateTransform(bmp.Width / 2, bmp.Height / 2);
g.RotateTransform(33);
g.DrawString(text, font, Brushes.White, -textSize.Width/2, -textSize.Height / 2);
*/
using (Font font = new Font("Arial", fontSize))
{
g.DrawString(text, font, Brushes.White, bmp.Width - textSize.Width + 5, 0);
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
/*
SizeF textSize = g.MeasureString(text, font);
g.TranslateTransform(bmp.Width / 2, bmp.Height / 2);
g.RotateTransform(33);
g.DrawString(text, font, Brushes.White, -textSize.Width/2, -textSize.Height / 2);
*/
g.DrawString(text, font, Brushes.White, 12, -2);
}
}
}
GenerateFrame(bmp);
Present();
GenerateFrame(bmp);
Present();
}
}
@@ -315,34 +305,36 @@ namespace Starlight.AnimeMatrix
int height = MaxRows;
float scale;
Bitmap canvas = new Bitmap(width, height);
scale = Math.Min((float)width / (float)image.Width, (float)height / (float)image.Height);
var graph = Graphics.FromImage(canvas);
var scaleWidth = (int)(image.Width * scale);
var scaleHeight = (int)(image.Height * scale);
graph.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
graph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
graph.DrawImage(image, ((int)width - scaleWidth), 0, scaleWidth, scaleHeight);
Bitmap bmp = new Bitmap(canvas, MaxColumns * 2, MaxRows);
for (int y = 0; y < bmp.Height; y++)
using (Bitmap canvas = new Bitmap(width, height))
{
for (int x = 0; x < bmp.Width; x++)
scale = Math.Min((float)width / (float)image.Width, (float)height / (float)image.Height);
using (var graph = Graphics.FromImage(canvas))
{
if (x % 2 == y % 2)
{
var color = GetColor(bmp, x, y);
SetLedPlanar(x / 2, y, (byte)color);
}
var scaleWidth = (int)(image.Width * scale);
var scaleHeight = (int)(image.Height * scale);
graph.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
graph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
graph.DrawImage(image, ((int)width - scaleWidth), 0, scaleWidth, scaleHeight);
}
using (Bitmap bmp = new Bitmap(canvas, MaxColumns * 2, MaxRows))
{
for (int y = 0; y < bmp.Height; y++)
for (int x = 0; x < bmp.Width; x++)
if (x % 2 == y % 2)
{
var pixel = bmp.GetPixel(x, y);
SetLedPlanar(x / 2, y, (byte)((pixel.R + pixel.G + pixel.B)/3));
}
}
}
}
private void EnsureRowInRange(int row)

20
app/Fans.Designer.cs generated
View File

@@ -259,7 +259,7 @@ namespace GHelper
buttonApply.Secondary = true;
buttonApply.Size = new Size(248, 44);
buttonApply.TabIndex = 14;
buttonApply.Text = "Apply Fan Curve";
buttonApply.Text = "Apply Custom Curve";
buttonApply.UseVisualStyleBackColor = false;
//
// panelPower
@@ -346,12 +346,11 @@ namespace GHelper
//
// labelCPU
//
labelCPU.AutoSize = true;
labelCPU.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelCPU.Location = new Point(44, 40);
labelCPU.Location = new Point(13, 40);
labelCPU.Margin = new Padding(4, 0, 4, 0);
labelCPU.Name = "labelCPU";
labelCPU.Size = new Size(61, 32);
labelCPU.Size = new Size(120, 32);
labelCPU.TabIndex = 13;
labelCPU.Text = "CPU";
labelCPU.TextAlign = ContentAlignment.MiddleCenter;
@@ -393,25 +392,24 @@ namespace GHelper
//
// labelTotal
//
labelTotal.AutoSize = true;
labelTotal.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelTotal.Location = new Point(46, 40);
labelTotal.Location = new Point(16, 40);
labelTotal.Margin = new Padding(4, 0, 4, 0);
labelTotal.Name = "labelTotal";
labelTotal.Size = new Size(70, 32);
labelTotal.Size = new Size(122, 32);
labelTotal.TabIndex = 12;
labelTotal.Text = "Total";
labelTotal.Text = "Platform";
labelTotal.TextAlign = ContentAlignment.MiddleCenter;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(48, 8);
label1.Location = new Point(26, 8);
label1.Margin = new Padding(4, 0, 4, 0);
label1.Name = "label1";
label1.Size = new Size(65, 32);
label1.Size = new Size(104, 32);
label1.TabIndex = 11;
label1.Text = "Total";
label1.Text = "Platform";
label1.TextAlign = ContentAlignment.MiddleCenter;
//
// trackTotal

View File

@@ -16,7 +16,7 @@
<PlatformTarget>x64</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.36</AssemblyVersion>
<AssemblyVersion>0.37</AssemblyVersion>
</PropertyGroup>
<ItemGroup>

View File

@@ -85,6 +85,7 @@ public static class HardwareMonitor
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
}
}

View File

@@ -49,14 +49,16 @@ namespace GHelper
}
SystemEvents.UserPreferenceChanged += new
UserPreferenceChangedEventHandler(SystemEvents_UserPreferenceChanged);
Application.EnableVisualStyles();
SystemEvents.UserPreferenceChanged += new
UserPreferenceChangedEventHandler(SystemEvents_UserPreferenceChanged);
ds = settingsForm.Handle;
trayIcon.MouseClick += TrayIcon_MouseClick; ;
trayIcon.MouseClick += TrayIcon_MouseClick;
wmi.SubscribeToEvents(WatcherEventArrived);
@@ -76,8 +78,10 @@ namespace GHelper
// Subscribing for system power change events
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
settingsForm.SetVersionLabel("Version: " + Assembly.GetExecutingAssembly().GetName().Version);
CheckForUpdates();
if (Environment.CurrentDirectory.Trim('\\') == Application.StartupPath.Trim('\\'))
{
SettingsToggle();
@@ -116,9 +120,6 @@ namespace GHelper
static async void CheckForUpdates()
{
var assembly = Assembly.GetExecutingAssembly().GetName().Version.ToString();
settingsForm.SetVersionLabel("Version: " + assembly);
try
{
using (var httpClient = new HttpClient())
@@ -130,19 +131,21 @@ namespace GHelper
var url = config.GetProperty("assets")[0].GetProperty("browser_download_url").ToString();
var gitVersion = new Version(tag);
var appVersion = new Version(assembly);
var result = gitVersion.CompareTo(appVersion);
if (result > 0)
var appVersion = new Version(Assembly.GetExecutingAssembly().GetName().Version.ToString());
if (gitVersion.CompareTo(appVersion) > 0)
{
settingsForm.SetVersionLabel("Download Update: " + tag, url);
settingsForm.BeginInvoke(delegate
{
settingsForm.SetVersionLabel("Download Update: " + tag, url);
});
}
}
}
catch
catch (Exception ex)
{
Logger.WriteLine("Failed to get update");
Logger.WriteLine("Failed to check for updates:"+ ex.Message);
}
}
@@ -151,7 +154,7 @@ namespace GHelper
public static void SetAutoModes(bool wait = false)
{
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastAuto) < 1000) return;
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastAuto) < 2000) return;
lastAuto = DateTimeOffset.Now.ToUnixTimeMilliseconds();
PowerLineStatus isPlugged = SystemInformation.PowerStatus.PowerLineStatus;

View File

@@ -393,6 +393,7 @@ namespace GHelper
// labelCPUFan
//
labelCPUFan.Anchor = AnchorStyles.Top | AnchorStyles.Right;
labelCPUFan.Cursor = Cursors.Hand;
labelCPUFan.Location = new Point(384, 15);
labelCPUFan.Margin = new Padding(8, 0, 8, 0);
labelCPUFan.Name = "labelCPUFan";

View File

@@ -10,7 +10,9 @@ namespace GHelper
public partial class SettingsForm : RForm
{
static System.Timers.Timer aTimer = default!;
public static System.Timers.Timer aTimer = default!;
public static Point trayPoint;
static System.Timers.Timer matrixTimer = default!;
public string versionUrl = "http://github.com/seerge/g-helper/releases";
@@ -21,7 +23,7 @@ namespace GHelper
public Keyboard keyb;
static AnimeMatrixDevice mat;
static int matrixMode = 0;
static long lastTip;
public SettingsForm()
{
@@ -115,12 +117,29 @@ namespace GHelper
button120Hz.MouseMove += Button120Hz_MouseHover;
button120Hz.MouseLeave += ButtonScreen_MouseLeave;
Program.trayIcon.MouseMove += TrayIcon_MouseMove;
//buttonStandard.Image = (Image)(new Bitmap(buttonStandard.Image, new Size(16, 16)));
SetTimer();
aTimer = new System.Timers.Timer(500);
aTimer.Elapsed += OnTimedEvent;
}
private static void TrayIcon_MouseMove(object? sender, MouseEventArgs e)
{
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastTip) < 2000) return;
lastTip = DateTimeOffset.Now.ToUnixTimeMilliseconds();
RefreshSensors();
}
private static void OnTimedEvent(Object? source, ElapsedEventArgs? e)
{
aTimer.Interval = 2000;
if (Program.settingsForm.Visible)
RefreshSensors();
}
private void Button120Hz_MouseHover(object? sender, EventArgs e)
{
@@ -253,8 +272,9 @@ namespace GHelper
Program.config.setConfig("matrix_auto", check.Checked ? 1 : 0);
}
private static void StartMatrixTimer()
private static void StartMatrixTimer(int interval = 100)
{
matrixTimer.Interval = interval;
matrixTimer.Enabled = true;
}
@@ -350,6 +370,8 @@ namespace GHelper
if (fileName is not null)
{
Program.config.setConfig("matrix_picture", fileName);
Program.config.setConfig("matrix_running", 2);
SetMatrixPicture(fileName);
BeginInvoke(delegate
{
@@ -408,12 +430,11 @@ namespace GHelper
switch (running)
{
case 2:
string fileName = Program.config.getConfigString("matrix_picture");
SetMatrixPicture(fileName);
SetMatrixPicture(Program.config.getConfigString("matrix_picture"));
break;
case 3:
mat.SetBuiltInAnimation(false);
StartMatrixTimer();
StartMatrixTimer(1000);
break;
default:
mat.SetBuiltInAnimation(true, animation);
@@ -421,6 +442,7 @@ namespace GHelper
}
//mat.SetBrightness((BrightnessMode)brightness);
}
}
@@ -762,14 +784,6 @@ namespace GHelper
SetGPUMode(ASUSWmi.GPUModeEco);
}
private static void SetTimer()
{
aTimer = new System.Timers.Timer(500);
aTimer.Elapsed += OnTimedEvent;
aTimer.AutoReset = true;
aTimer.Enabled = false;
}
private static string FormatFan(int fan)
{
@@ -811,14 +825,12 @@ namespace GHelper
Program.settingsForm.labelGPUFan.Text = "GPU" + gpuTemp + gpuFan;
if (midFan is not null) Program.settingsForm.labelMidFan.Text = "Mid" + midFan;
Program.settingsForm.labelBattery.Text = battery;
Program.trayIcon.Text = "CPU" + cpuTemp + cpuFan + "\n" + "GPU" + gpuTemp + gpuFan + ((battery.Length > 0) ? ("\n" + battery) : "");
});
}
private static void OnTimedEvent(Object? source, ElapsedEventArgs? e)
{
RefreshSensors();
aTimer.Interval = 2000;
}
private void SettingsForm_VisibleChanged(object? sender, EventArgs e)
{

View File

@@ -68,6 +68,9 @@ Ultimate mode is supported (by hardware) only on G14 2022 (and possibly other mo
#### App doesn't start / or crashes, what should I do ?
Open "Event Viewer" from start menu, go to Windows Logs -> Application and check for recent Errors mentioning G-Helper. If you see one - please post a [new issue](https://github.com/seerge/g-helper/issues) with all details from this error.
#### How do I uninstall G-helper?
G-helper is a single exe, and it doesn't install anything in the system. To remove it - you can simply delete exe :) If you have applied any custom fan profiles or PPTs - before removing I would recommend selecting your favorite perfromance mode (for example balanced) and clicking "Factory defaults" under Fans + Power.
----------------------------
### How to install