mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3e9022111 | ||
|
|
24014dd20f | ||
|
|
321bc2623d | ||
|
|
52b07843a2 |
@@ -2,6 +2,7 @@
|
||||
using System.Management;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
public class ASUSWmi
|
||||
{
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Source thanks to https://github.com/vddCore/Starlight :)
|
||||
// Source thanks to https://github.com/vddCore/Starlight with some adjustments from me
|
||||
|
||||
using System.Text;
|
||||
using Starlight.Communication;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
namespace Starlight.AnimeMatrix
|
||||
{
|
||||
@@ -71,13 +72,41 @@ namespace Starlight.AnimeMatrix
|
||||
public int LedCount => 1450;
|
||||
public int Rows => 61;
|
||||
|
||||
private readonly byte[] _displayBuffer = new byte[UpdatePageLength * 3];
|
||||
private byte[] _displayBuffer = new byte[UpdatePageLength * 3];
|
||||
private List<byte[]> frames = new List<byte[]>();
|
||||
|
||||
private int frameIndex = 0;
|
||||
|
||||
public AnimeMatrixDevice()
|
||||
: base(0x0B05, 0x193B, 640)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public byte[] GetBuffer()
|
||||
{
|
||||
return _displayBuffer;
|
||||
}
|
||||
|
||||
public void PresentNextFrame()
|
||||
{
|
||||
//Debug.WriteLine(frameIndex);
|
||||
if (frameIndex >= frames.Count) frameIndex = 0;
|
||||
_displayBuffer = frames[frameIndex];
|
||||
Present();
|
||||
frameIndex++;
|
||||
}
|
||||
|
||||
public void ClearFrames()
|
||||
{
|
||||
frames.Clear();
|
||||
frameIndex = 0;
|
||||
}
|
||||
|
||||
public void AddFrame()
|
||||
{
|
||||
frames.Add(_displayBuffer.ToArray());
|
||||
}
|
||||
|
||||
public void SendRaw(params byte[] data)
|
||||
{
|
||||
Set(Packet<AnimeMatrixPacket>(data));
|
||||
@@ -90,7 +119,7 @@ namespace Starlight.AnimeMatrix
|
||||
}
|
||||
public int Columns(int row)
|
||||
{
|
||||
EnsureRowInRange(row);
|
||||
EnsureRowInRange(row);
|
||||
return 34 - EmptyColumns(row);
|
||||
}
|
||||
|
||||
@@ -202,13 +231,48 @@ namespace Starlight.AnimeMatrix
|
||||
var enabled = enable ? (byte)0x00 : (byte)0x80;
|
||||
Set(Packet<AnimeMatrixPacket>(0xC4, 0x01, enabled));
|
||||
}
|
||||
|
||||
|
||||
public void SetBuiltInAnimation(bool enable, BuiltInAnimation animation)
|
||||
{
|
||||
SetBuiltInAnimation(enable);
|
||||
Set(Packet<AnimeMatrixPacket>(0xC5, animation.AsByte));
|
||||
}
|
||||
|
||||
|
||||
public void GenerateFrame(Image image)
|
||||
{
|
||||
|
||||
int width = 34 * 3;
|
||||
int height = 61;
|
||||
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), ((int)height - scaleHeight) / 2, scaleWidth, scaleHeight);
|
||||
|
||||
Bitmap bmp = new Bitmap(canvas, 34, 61);
|
||||
|
||||
for (int y = 0; y < bmp.Height; y++)
|
||||
{
|
||||
for (int x = 0; x < bmp.Width; x++)
|
||||
{
|
||||
var pixel = bmp.GetPixel(x, y);
|
||||
byte color = (byte)(Math.Max((pixel.R + pixel.G + pixel.B) / 3 - 10, 0));
|
||||
SetLedPlanar(x, y, color);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void EnsureRowInRange(int row)
|
||||
{
|
||||
if (row < 0 || row >= Rows)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Text.Json;
|
||||
|
||||
public class AppConfig
|
||||
{
|
||||
|
||||
|
||||
4
Aura.cs
4
Aura.cs
@@ -3,8 +3,8 @@
|
||||
public class Aura
|
||||
{
|
||||
|
||||
static byte[] MESSAGE_SET = { 0x5d, 0xb5 };
|
||||
static byte[] MESSAGE_APPLY = { 0x5d, 0xb4 };
|
||||
static byte[] MESSAGE_SET = { 0x5d, 0xb5, 0,0,0 };
|
||||
static byte[] MESSAGE_APPLY = { 0x5d, 0xb4};
|
||||
|
||||
public const int Static = 0;
|
||||
public const int Breathe = 1;
|
||||
|
||||
6
Fans.Designer.cs
generated
6
Fans.Designer.cs
generated
@@ -247,8 +247,9 @@
|
||||
//
|
||||
// Fans
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
AutoScaleDimensions = new SizeF(96F, 96F);
|
||||
AutoScaleMode = AutoScaleMode.Dpi;
|
||||
AutoSize = true;
|
||||
ClientSize = new Size(621, 510);
|
||||
Controls.Add(checkAuto);
|
||||
Controls.Add(buttonApplyPower);
|
||||
@@ -257,7 +258,6 @@
|
||||
Controls.Add(buttonReset);
|
||||
Controls.Add(buttonApply);
|
||||
Controls.Add(chartCPU);
|
||||
FormBorderStyle = FormBorderStyle.FixedSingle;
|
||||
Margin = new Padding(2, 1, 2, 1);
|
||||
MaximizeBox = false;
|
||||
MdiChildrenMinimizedAnchorBottom = false;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<AssemblyName>GHelper</AssemblyName>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||
<AssemblyVersion>0.15.1</AssemblyVersion>
|
||||
<AssemblyVersion>0.16</AssemblyVersion>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
38
Keyboard.Designer.cs
generated
38
Keyboard.Designer.cs
generated
@@ -35,11 +35,17 @@
|
||||
labelM4 = new Label();
|
||||
comboM3 = new ComboBox();
|
||||
labelM3 = new Label();
|
||||
textFNF4 = new TextBox();
|
||||
comboFNF4 = new ComboBox();
|
||||
labelFNF4 = new Label();
|
||||
groupBox1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
groupBox1.Controls.Add(textFNF4);
|
||||
groupBox1.Controls.Add(comboFNF4);
|
||||
groupBox1.Controls.Add(labelFNF4);
|
||||
groupBox1.Controls.Add(textM4);
|
||||
groupBox1.Controls.Add(textM3);
|
||||
groupBox1.Controls.Add(comboM4);
|
||||
@@ -49,7 +55,7 @@
|
||||
groupBox1.Dock = DockStyle.Top;
|
||||
groupBox1.Location = new Point(10, 10);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(751, 196);
|
||||
groupBox1.Size = new Size(751, 242);
|
||||
groupBox1.TabIndex = 0;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "Key Bindings";
|
||||
@@ -58,7 +64,7 @@
|
||||
//
|
||||
textM4.Location = new Point(411, 113);
|
||||
textM4.Name = "textM4";
|
||||
textM4.PlaceholderText = "notepad /p \"file.txt\"";
|
||||
textM4.PlaceholderText = "action";
|
||||
textM4.Size = new Size(320, 39);
|
||||
textM4.TabIndex = 5;
|
||||
//
|
||||
@@ -106,6 +112,31 @@
|
||||
labelM3.TabIndex = 0;
|
||||
labelM3.Text = "M3:";
|
||||
//
|
||||
// textFNF4
|
||||
//
|
||||
textFNF4.Location = new Point(411, 176);
|
||||
textFNF4.Name = "textFNF4";
|
||||
textFNF4.PlaceholderText = "action";
|
||||
textFNF4.Size = new Size(320, 39);
|
||||
textFNF4.TabIndex = 8;
|
||||
//
|
||||
// comboFNF4
|
||||
//
|
||||
comboFNF4.FormattingEnabled = true;
|
||||
comboFNF4.Location = new Point(93, 175);
|
||||
comboFNF4.Name = "comboFNF4";
|
||||
comboFNF4.Size = new Size(312, 40);
|
||||
comboFNF4.TabIndex = 7;
|
||||
//
|
||||
// labelFNF4
|
||||
//
|
||||
labelFNF4.AutoSize = true;
|
||||
labelFNF4.Location = new Point(2, 178);
|
||||
labelFNF4.Name = "labelFNF4";
|
||||
labelFNF4.Size = new Size(90, 32);
|
||||
labelFNF4.TabIndex = 6;
|
||||
labelFNF4.Text = "FN+F4:";
|
||||
//
|
||||
// Keyboard
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||
@@ -135,5 +166,8 @@
|
||||
private Label labelM4;
|
||||
private TextBox textM4;
|
||||
private TextBox textM3;
|
||||
private TextBox textFNF4;
|
||||
private ComboBox comboFNF4;
|
||||
private Label labelFNF4;
|
||||
}
|
||||
}
|
||||
104
Keyboard.cs
104
Keyboard.cs
@@ -1,11 +1,8 @@
|
||||
using System.Diagnostics.Metrics;
|
||||
|
||||
namespace GHelper
|
||||
namespace GHelper
|
||||
{
|
||||
public partial class Keyboard : Form
|
||||
{
|
||||
|
||||
|
||||
Dictionary<string, string> customActions = new Dictionary<string, string>
|
||||
{
|
||||
{"","--------------" },
|
||||
@@ -13,85 +10,60 @@ namespace GHelper
|
||||
{"screenshot", "Screenshot"},
|
||||
{"play", "Play/Pause"},
|
||||
{"aura", "Aura"},
|
||||
{"ghelper", "Open GHelper"},
|
||||
{"custom", "Custom"}
|
||||
};
|
||||
|
||||
private void SetKeyCombo(ComboBox combo, TextBox txbox, string name)
|
||||
{
|
||||
if (name == "m4")
|
||||
customActions[""] = "Performance";
|
||||
|
||||
if (name == "fnf4")
|
||||
{
|
||||
customActions[""] = "Aura";
|
||||
customActions.Remove("aura");
|
||||
}
|
||||
|
||||
combo.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
combo.DataSource = new BindingSource(customActions, null);
|
||||
combo.DisplayMember = "Value";
|
||||
combo.ValueMember = "Key";
|
||||
|
||||
string action = Program.config.getConfigString(name);
|
||||
|
||||
combo.SelectedValue = (action is not null) ? action : "";
|
||||
if (combo.SelectedValue is null) combo.SelectedValue = "";
|
||||
|
||||
combo.SelectedValueChanged += delegate
|
||||
{
|
||||
if (combo.SelectedValue is not null)
|
||||
Program.config.setConfig(name, combo.SelectedValue.ToString());
|
||||
};
|
||||
|
||||
txbox.Text = Program.config.getConfigString(name + "_custom");
|
||||
txbox.TextChanged += delegate
|
||||
{
|
||||
Program.config.setConfig(name + "_custom", txbox.Text);
|
||||
};
|
||||
}
|
||||
|
||||
public Keyboard()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
comboM3.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboM3.DataSource = new BindingSource(customActions, null);
|
||||
comboM3.DisplayMember = "Value";
|
||||
comboM3.ValueMember = "Key";
|
||||
|
||||
customActions[""] = "Performance";
|
||||
comboM4.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboM4.DataSource = new BindingSource(customActions, null);
|
||||
comboM4.DisplayMember = "Value";
|
||||
comboM4.ValueMember = "Key";
|
||||
|
||||
comboM3.SelectedValueChanged += ComboM3_SelectedValueChanged;
|
||||
comboM4.SelectedValueChanged += ComboM4_SelectedValueChanged;
|
||||
|
||||
textM3.TextChanged += TextM3_TextChanged;
|
||||
textM4.TextChanged += TextM4_TextChanged;
|
||||
SetKeyCombo(comboM3, textM3, "m3");
|
||||
SetKeyCombo(comboM4, textM4, "m4");
|
||||
SetKeyCombo(comboFNF4, textFNF4, "fnf4");
|
||||
|
||||
Shown += Keyboard_Shown;
|
||||
}
|
||||
|
||||
private void TextM3_TextChanged(object? sender, EventArgs e)
|
||||
{
|
||||
if (sender is null) return;
|
||||
TextBox tb = (TextBox)sender;
|
||||
Program.config.setConfig("m3_custom", tb.Text);
|
||||
}
|
||||
|
||||
private void TextM4_TextChanged(object? sender, EventArgs e)
|
||||
{
|
||||
if (sender is null) return;
|
||||
TextBox tb = (TextBox)sender;
|
||||
Program.config.setConfig("m4_custom", tb.Text);
|
||||
}
|
||||
|
||||
private void ComboKeyChanged(object? sender, string name = "m3")
|
||||
{
|
||||
if (sender is null) return;
|
||||
ComboBox cmb = (ComboBox)sender;
|
||||
|
||||
if (cmb.SelectedValue is not null)
|
||||
Program.config.setConfig(name, cmb.SelectedValue.ToString());
|
||||
}
|
||||
|
||||
private void ComboM4_SelectedValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
ComboKeyChanged(sender, "m4");
|
||||
}
|
||||
|
||||
private void ComboM3_SelectedValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
ComboKeyChanged(sender, "m3");
|
||||
}
|
||||
|
||||
private void Keyboard_Shown(object? sender, EventArgs e)
|
||||
{
|
||||
|
||||
Top = Program.settingsForm.Top;
|
||||
Left = Program.settingsForm.Left - Width - 5;
|
||||
|
||||
string m3 = Program.config.getConfigString("m3");
|
||||
string m4 = Program.config.getConfigString("m4");
|
||||
|
||||
comboM3.SelectedValue = (m3 is not null) ? m3 : "";
|
||||
comboM4.SelectedValue = (m4 is not null) ? m4 : "";
|
||||
|
||||
if (comboM3.SelectedValue is null) comboM3.SelectedValue = "";
|
||||
if (comboM4.SelectedValue is null) comboM4.SelectedValue = "";
|
||||
|
||||
textM3.Text = Program.config.getConfigString("m3_custom");
|
||||
textM4.Text = Program.config.getConfigString("m4_custom");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
13
Program.cs
13
Program.cs
@@ -61,6 +61,7 @@ namespace GHelper
|
||||
settingsForm.InitGPUMode();
|
||||
settingsForm.InitBoost();
|
||||
settingsForm.InitAura();
|
||||
settingsForm.InitMatrix();
|
||||
|
||||
settingsForm.VisualiseGPUAuto(config.getConfig("gpu_auto"));
|
||||
settingsForm.VisualiseScreenAuto(config.getConfig("screen_auto"));
|
||||
@@ -82,6 +83,9 @@ namespace GHelper
|
||||
settingsForm.AutoGPUMode(isPlugged);
|
||||
settingsForm.AutoScreen(isPlugged);
|
||||
settingsForm.AutoPerformance(isPlugged);
|
||||
|
||||
settingsForm.SetAnimeMatrix();
|
||||
|
||||
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
||||
}
|
||||
|
||||
@@ -134,10 +138,12 @@ namespace GHelper
|
||||
{
|
||||
string action = config.getConfigString(name);
|
||||
|
||||
if (action.Length == 0)
|
||||
if (action is null || action.Length <= 1)
|
||||
{
|
||||
if (name == "m4")
|
||||
action = "performance";
|
||||
if (name == "fnf4")
|
||||
action = "aura";
|
||||
}
|
||||
|
||||
switch (action)
|
||||
@@ -157,6 +163,9 @@ namespace GHelper
|
||||
case "performance":
|
||||
settingsForm.BeginInvoke(settingsForm.CyclePerformanceMode);
|
||||
break;
|
||||
case "ghelper":
|
||||
settingsForm.BeginInvoke(SettingsToggle);
|
||||
break;
|
||||
case "custom":
|
||||
CustomKey(name);
|
||||
break;
|
||||
@@ -188,7 +197,7 @@ namespace GHelper
|
||||
settingsForm.BeginInvoke(settingsForm.CyclePerformanceMode);
|
||||
return;
|
||||
case 179: // FN+F4
|
||||
settingsForm.BeginInvoke(settingsForm.CycleAuraMode);
|
||||
KeyProcess("fnf4");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
56
Settings.Designer.cs
generated
56
Settings.Designer.cs
generated
@@ -106,7 +106,7 @@
|
||||
trackBattery.Maximum = 100;
|
||||
trackBattery.Minimum = 50;
|
||||
trackBattery.Name = "trackBattery";
|
||||
trackBattery.Size = new Size(341, 45);
|
||||
trackBattery.Size = new Size(337, 45);
|
||||
trackBattery.SmallChange = 10;
|
||||
trackBattery.TabIndex = 3;
|
||||
trackBattery.TickFrequency = 10;
|
||||
@@ -138,7 +138,7 @@
|
||||
// labelGPUFan
|
||||
//
|
||||
labelGPUFan.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
labelGPUFan.Location = new Point(172, 131);
|
||||
labelGPUFan.Location = new Point(168, 131);
|
||||
labelGPUFan.Margin = new Padding(2, 0, 2, 0);
|
||||
labelGPUFan.Name = "labelGPUFan";
|
||||
labelGPUFan.Size = new Size(174, 16);
|
||||
@@ -161,7 +161,7 @@
|
||||
tableGPU.Name = "tableGPU";
|
||||
tableGPU.RowCount = 1;
|
||||
tableGPU.RowStyles.Add(new RowStyle(SizeType.Absolute, 54F));
|
||||
tableGPU.Size = new Size(341, 54);
|
||||
tableGPU.Size = new Size(337, 54);
|
||||
tableGPU.TabIndex = 7;
|
||||
//
|
||||
// buttonUltimate
|
||||
@@ -170,10 +170,10 @@
|
||||
buttonUltimate.Dock = DockStyle.Fill;
|
||||
buttonUltimate.FlatAppearance.BorderSize = 0;
|
||||
buttonUltimate.FlatStyle = FlatStyle.Flat;
|
||||
buttonUltimate.Location = new Point(230, 6);
|
||||
buttonUltimate.Location = new Point(228, 6);
|
||||
buttonUltimate.Margin = new Padding(4, 6, 4, 6);
|
||||
buttonUltimate.Name = "buttonUltimate";
|
||||
buttonUltimate.Size = new Size(107, 42);
|
||||
buttonUltimate.Size = new Size(105, 42);
|
||||
buttonUltimate.TabIndex = 2;
|
||||
buttonUltimate.Text = "Ultimate";
|
||||
buttonUltimate.UseVisualStyleBackColor = false;
|
||||
@@ -184,10 +184,10 @@
|
||||
buttonStandard.Dock = DockStyle.Fill;
|
||||
buttonStandard.FlatAppearance.BorderSize = 0;
|
||||
buttonStandard.FlatStyle = FlatStyle.Flat;
|
||||
buttonStandard.Location = new Point(117, 6);
|
||||
buttonStandard.Location = new Point(116, 6);
|
||||
buttonStandard.Margin = new Padding(4, 6, 4, 6);
|
||||
buttonStandard.Name = "buttonStandard";
|
||||
buttonStandard.Size = new Size(105, 42);
|
||||
buttonStandard.Size = new Size(104, 42);
|
||||
buttonStandard.TabIndex = 1;
|
||||
buttonStandard.Text = "Standard";
|
||||
buttonStandard.UseVisualStyleBackColor = false;
|
||||
@@ -202,7 +202,7 @@
|
||||
buttonEco.Location = new Point(4, 6);
|
||||
buttonEco.Margin = new Padding(4, 6, 4, 6);
|
||||
buttonEco.Name = "buttonEco";
|
||||
buttonEco.Size = new Size(105, 42);
|
||||
buttonEco.Size = new Size(104, 42);
|
||||
buttonEco.TabIndex = 0;
|
||||
buttonEco.Text = "Eco";
|
||||
buttonEco.UseVisualStyleBackColor = false;
|
||||
@@ -232,7 +232,7 @@
|
||||
// labelCPUFan
|
||||
//
|
||||
labelCPUFan.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
labelCPUFan.Location = new Point(163, 19);
|
||||
labelCPUFan.Location = new Point(159, 19);
|
||||
labelCPUFan.Margin = new Padding(2, 0, 2, 0);
|
||||
labelCPUFan.Name = "labelCPUFan";
|
||||
labelCPUFan.Size = new Size(183, 16);
|
||||
@@ -255,7 +255,7 @@
|
||||
tablePerf.Name = "tablePerf";
|
||||
tablePerf.RowCount = 1;
|
||||
tablePerf.RowStyles.Add(new RowStyle(SizeType.Absolute, 54F));
|
||||
tablePerf.Size = new Size(341, 54);
|
||||
tablePerf.Size = new Size(337, 54);
|
||||
tablePerf.TabIndex = 11;
|
||||
//
|
||||
// buttonTurbo
|
||||
@@ -265,10 +265,10 @@
|
||||
buttonTurbo.FlatAppearance.BorderColor = Color.FromArgb(192, 0, 0);
|
||||
buttonTurbo.FlatAppearance.BorderSize = 0;
|
||||
buttonTurbo.FlatStyle = FlatStyle.Flat;
|
||||
buttonTurbo.Location = new Point(230, 6);
|
||||
buttonTurbo.Location = new Point(228, 6);
|
||||
buttonTurbo.Margin = new Padding(4, 6, 4, 6);
|
||||
buttonTurbo.Name = "buttonTurbo";
|
||||
buttonTurbo.Size = new Size(107, 42);
|
||||
buttonTurbo.Size = new Size(105, 42);
|
||||
buttonTurbo.TabIndex = 2;
|
||||
buttonTurbo.Text = "Turbo";
|
||||
buttonTurbo.UseVisualStyleBackColor = false;
|
||||
@@ -280,10 +280,10 @@
|
||||
buttonBalanced.FlatAppearance.BorderColor = Color.FromArgb(0, 0, 192);
|
||||
buttonBalanced.FlatAppearance.BorderSize = 0;
|
||||
buttonBalanced.FlatStyle = FlatStyle.Flat;
|
||||
buttonBalanced.Location = new Point(117, 6);
|
||||
buttonBalanced.Location = new Point(116, 6);
|
||||
buttonBalanced.Margin = new Padding(4, 6, 4, 6);
|
||||
buttonBalanced.Name = "buttonBalanced";
|
||||
buttonBalanced.Size = new Size(105, 42);
|
||||
buttonBalanced.Size = new Size(104, 42);
|
||||
buttonBalanced.TabIndex = 1;
|
||||
buttonBalanced.Text = "Balanced";
|
||||
buttonBalanced.UseVisualStyleBackColor = false;
|
||||
@@ -299,7 +299,7 @@
|
||||
buttonSilent.Location = new Point(4, 6);
|
||||
buttonSilent.Margin = new Padding(4, 6, 4, 6);
|
||||
buttonSilent.Name = "buttonSilent";
|
||||
buttonSilent.Size = new Size(105, 42);
|
||||
buttonSilent.Size = new Size(104, 42);
|
||||
buttonSilent.TabIndex = 0;
|
||||
buttonSilent.Text = "Silent";
|
||||
buttonSilent.UseVisualStyleBackColor = false;
|
||||
@@ -344,7 +344,7 @@
|
||||
//
|
||||
buttonQuit.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
buttonQuit.BackColor = SystemColors.ButtonFace;
|
||||
buttonQuit.Location = new Point(292, 565);
|
||||
buttonQuit.Location = new Point(288, 565);
|
||||
buttonQuit.Margin = new Padding(2, 1, 2, 1);
|
||||
buttonQuit.Name = "buttonQuit";
|
||||
buttonQuit.Size = new Size(60, 24);
|
||||
@@ -388,7 +388,7 @@
|
||||
tableScreen.Name = "tableScreen";
|
||||
tableScreen.RowCount = 1;
|
||||
tableScreen.RowStyles.Add(new RowStyle(SizeType.Absolute, 54F));
|
||||
tableScreen.Size = new Size(341, 54);
|
||||
tableScreen.Size = new Size(337, 54);
|
||||
tableScreen.TabIndex = 19;
|
||||
//
|
||||
// button120Hz
|
||||
@@ -398,10 +398,10 @@
|
||||
button120Hz.FlatAppearance.BorderColor = SystemColors.ActiveBorder;
|
||||
button120Hz.FlatAppearance.BorderSize = 0;
|
||||
button120Hz.FlatStyle = FlatStyle.Flat;
|
||||
button120Hz.Location = new Point(117, 6);
|
||||
button120Hz.Location = new Point(116, 6);
|
||||
button120Hz.Margin = new Padding(4, 6, 4, 6);
|
||||
button120Hz.Name = "button120Hz";
|
||||
button120Hz.Size = new Size(105, 42);
|
||||
button120Hz.Size = new Size(104, 42);
|
||||
button120Hz.TabIndex = 1;
|
||||
button120Hz.Text = "120Hz + OD";
|
||||
button120Hz.UseVisualStyleBackColor = false;
|
||||
@@ -418,7 +418,7 @@
|
||||
button60Hz.Location = new Point(4, 6);
|
||||
button60Hz.Margin = new Padding(4, 6, 4, 6);
|
||||
button60Hz.Name = "button60Hz";
|
||||
button60Hz.Size = new Size(105, 42);
|
||||
button60Hz.Size = new Size(104, 42);
|
||||
button60Hz.TabIndex = 0;
|
||||
button60Hz.Text = "60Hz";
|
||||
button60Hz.UseVisualStyleBackColor = false;
|
||||
@@ -500,7 +500,7 @@
|
||||
// labelBattery
|
||||
//
|
||||
labelBattery.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
labelBattery.Location = new Point(210, 496);
|
||||
labelBattery.Location = new Point(206, 496);
|
||||
labelBattery.Margin = new Padding(2, 0, 2, 0);
|
||||
labelBattery.Name = "labelBattery";
|
||||
labelBattery.Size = new Size(138, 16);
|
||||
@@ -513,7 +513,7 @@
|
||||
buttonFans.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
buttonFans.BackColor = SystemColors.ButtonFace;
|
||||
buttonFans.FlatAppearance.BorderSize = 0;
|
||||
buttonFans.Location = new Point(243, 93);
|
||||
buttonFans.Location = new Point(239, 93);
|
||||
buttonFans.Margin = new Padding(2, 1, 2, 1);
|
||||
buttonFans.Name = "buttonFans";
|
||||
buttonFans.Size = new Size(105, 24);
|
||||
@@ -526,7 +526,7 @@
|
||||
buttonKeyboard.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
buttonKeyboard.BackColor = SystemColors.ButtonFace;
|
||||
buttonKeyboard.FlatAppearance.BorderSize = 0;
|
||||
buttonKeyboard.Location = new Point(243, 382);
|
||||
buttonKeyboard.Location = new Point(238, 383);
|
||||
buttonKeyboard.Margin = new Padding(2, 1, 2, 1);
|
||||
buttonKeyboard.Name = "buttonKeyboard";
|
||||
buttonKeyboard.Size = new Size(104, 24);
|
||||
@@ -537,7 +537,7 @@
|
||||
// pictureColor
|
||||
//
|
||||
pictureColor.Location = new Point(216, 390);
|
||||
pictureColor.Margin = new Padding(2, 2, 2, 2);
|
||||
pictureColor.Margin = new Padding(2);
|
||||
pictureColor.Name = "pictureColor";
|
||||
pictureColor.Size = new Size(10, 10);
|
||||
pictureColor.TabIndex = 30;
|
||||
@@ -546,7 +546,7 @@
|
||||
// pictureColor2
|
||||
//
|
||||
pictureColor2.Location = new Point(202, 390);
|
||||
pictureColor2.Margin = new Padding(2, 2, 2, 2);
|
||||
pictureColor2.Margin = new Padding(2);
|
||||
pictureColor2.Name = "pictureColor2";
|
||||
pictureColor2.Size = new Size(10, 10);
|
||||
pictureColor2.TabIndex = 31;
|
||||
@@ -617,7 +617,7 @@
|
||||
buttonMatrix.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
buttonMatrix.BackColor = SystemColors.ButtonFace;
|
||||
buttonMatrix.FlatAppearance.BorderSize = 0;
|
||||
buttonMatrix.Location = new Point(243, 452);
|
||||
buttonMatrix.Location = new Point(238, 453);
|
||||
buttonMatrix.Margin = new Padding(2, 1, 2, 1);
|
||||
buttonMatrix.Name = "buttonMatrix";
|
||||
buttonMatrix.Size = new Size(104, 24);
|
||||
@@ -629,7 +629,8 @@
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(96F, 96F);
|
||||
AutoScaleMode = AutoScaleMode.Dpi;
|
||||
ClientSize = new Size(368, 602);
|
||||
AutoSize = true;
|
||||
ClientSize = new Size(364, 599);
|
||||
Controls.Add(buttonMatrix);
|
||||
Controls.Add(comboMatrixRunning);
|
||||
Controls.Add(comboMatrix);
|
||||
@@ -664,7 +665,6 @@
|
||||
Controls.Add(labelBatteryTitle);
|
||||
Controls.Add(trackBattery);
|
||||
Controls.Add(checkStartup);
|
||||
FormBorderStyle = FormBorderStyle.FixedSingle;
|
||||
Margin = new Padding(2, 1, 2, 1);
|
||||
MaximizeBox = false;
|
||||
MdiChildrenMinimizedAnchorBottom = false;
|
||||
|
||||
106
Settings.cs
106
Settings.cs
@@ -1,10 +1,8 @@
|
||||
using Starlight.AnimeMatrix;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Reflection;
|
||||
using System.Timers;
|
||||
using System.Drawing.Imaging;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Drawing;
|
||||
|
||||
namespace GHelper
|
||||
{
|
||||
@@ -20,12 +18,15 @@ namespace GHelper
|
||||
static int buttonActive = 5;
|
||||
|
||||
static System.Timers.Timer aTimer = default!;
|
||||
static System.Timers.Timer matrixTimer = new System.Timers.Timer();
|
||||
|
||||
public string perfName = "Balanced";
|
||||
|
||||
Fans fans;
|
||||
Keyboard keyb;
|
||||
|
||||
AnimeMatrixDevice mat = new AnimeMatrixDevice();
|
||||
|
||||
public SettingsForm()
|
||||
{
|
||||
|
||||
@@ -80,9 +81,6 @@ namespace GHelper
|
||||
labelCPUFan.Click += LabelCPUFan_Click;
|
||||
labelGPUFan.Click += LabelCPUFan_Click;
|
||||
|
||||
|
||||
InitMatrix();
|
||||
|
||||
comboMatrix.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboMatrixRunning.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboMatrix.SelectedValueChanged += ComboMatrix_SelectedValueChanged;
|
||||
@@ -90,62 +88,62 @@ namespace GHelper
|
||||
|
||||
buttonMatrix.Click += ButtonMatrix_Click;
|
||||
|
||||
matrixTimer.Enabled = false;
|
||||
matrixTimer.Interval = 100;
|
||||
matrixTimer.Elapsed += MatrixTimer_Elapsed;
|
||||
|
||||
SetTimer();
|
||||
|
||||
}
|
||||
|
||||
private void MatrixTimer_Elapsed(object? sender, ElapsedEventArgs e)
|
||||
{
|
||||
mat.PresentNextFrame();
|
||||
}
|
||||
|
||||
void SetMatrixPicture(string fileName)
|
||||
{
|
||||
|
||||
int width = 34 * 3;
|
||||
int height = 61;
|
||||
float scale;
|
||||
|
||||
Bitmap image;
|
||||
Image image;
|
||||
|
||||
try
|
||||
{
|
||||
using (var bmpTemp = (Bitmap)Image.FromFile(fileName))
|
||||
using (var fs = new FileStream(fileName, FileMode.Open))
|
||||
{
|
||||
image = new Bitmap(bmpTemp);
|
||||
|
||||
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), ((int)height - scaleHeight) / 2, scaleWidth, scaleHeight);
|
||||
|
||||
Bitmap bmp = new Bitmap(canvas, 34, 61);
|
||||
|
||||
var mat = new AnimeMatrixDevice();
|
||||
mat.SetBuiltInAnimation(false);
|
||||
|
||||
for (int y = 0; y < bmp.Height; y++)
|
||||
{
|
||||
for (int x = 0; x < bmp.Width; x++)
|
||||
{
|
||||
var pixel = bmp.GetPixel(x, y);
|
||||
byte color = (byte)((pixel.R + pixel.G + pixel.B) / 3);
|
||||
mat.SetLedPlanar(x, y, color);
|
||||
}
|
||||
}
|
||||
|
||||
mat.Present();
|
||||
mat.Dispose();
|
||||
var ms = new MemoryStream();
|
||||
fs.CopyTo(ms);
|
||||
ms.Position = 0;
|
||||
image = Image.FromStream(ms);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.WriteLine("Error loading picture");
|
||||
return;
|
||||
}
|
||||
|
||||
mat.SetBuiltInAnimation(false);
|
||||
mat.ClearFrames();
|
||||
|
||||
FrameDimension dimension = new FrameDimension(image.FrameDimensionsList[0]);
|
||||
int frameCount = image.GetFrameCount(dimension);
|
||||
|
||||
if (frameCount > 1)
|
||||
{
|
||||
for (int i = 0; i < frameCount; i++)
|
||||
{
|
||||
image.SelectActiveFrame(dimension, i);
|
||||
mat.GenerateFrame(image);
|
||||
mat.AddFrame();
|
||||
}
|
||||
matrixTimer.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
matrixTimer.Enabled = false;
|
||||
|
||||
mat.GenerateFrame(image);
|
||||
mat.Present();
|
||||
}
|
||||
|
||||
|
||||
@@ -157,7 +155,7 @@ namespace GHelper
|
||||
Thread t = new Thread((ThreadStart)(() =>
|
||||
{
|
||||
OpenFileDialog of = new OpenFileDialog();
|
||||
of.Filter = "Image Files (*.bmp;*.jpg;*.jpeg,*.png)|*.BMP;*.JPG;*.JPEG;*.PNG";
|
||||
of.Filter = "Image Files (*.bmp;*.jpg;*.jpeg,*.png,*.gif)|*.BMP;*.JPG;*.JPEG;*.PNG;*.GIF";
|
||||
if (of.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Program.config.setConfig("matrix_picture", of.FileName);
|
||||
@@ -177,22 +175,25 @@ namespace GHelper
|
||||
|
||||
private void ComboMatrixRunning_SelectedValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("matrix_running", comboMatrixRunning.SelectedIndex);
|
||||
SetAnimeMatrix();
|
||||
}
|
||||
|
||||
|
||||
private void ComboMatrix_SelectedValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("matrix_brightness", comboMatrix.SelectedIndex);
|
||||
SetAnimeMatrix();
|
||||
}
|
||||
|
||||
private void SetAnimeMatrix()
|
||||
public void SetAnimeMatrix()
|
||||
{
|
||||
|
||||
int brightness = comboMatrix.SelectedIndex;
|
||||
int running = comboMatrixRunning.SelectedIndex;
|
||||
int brightness = Program.config.getConfig("matrix_brightness");
|
||||
int running = Program.config.getConfig("matrix_running");
|
||||
|
||||
var mat = new AnimeMatrixDevice();
|
||||
if (brightness < 0) brightness = 0;
|
||||
if (running < 0) running = 0;
|
||||
|
||||
BuiltInAnimation animation = new BuiltInAnimation(
|
||||
(BuiltInAnimation.Running)running,
|
||||
@@ -201,6 +202,7 @@ namespace GHelper
|
||||
BuiltInAnimation.Startup.StaticEmergence
|
||||
);
|
||||
|
||||
matrixTimer.Enabled = false;
|
||||
|
||||
if (brightness == 0)
|
||||
{
|
||||
@@ -222,10 +224,6 @@ namespace GHelper
|
||||
}
|
||||
}
|
||||
|
||||
mat.Dispose();
|
||||
|
||||
Program.config.setConfig("matrix_brightness", comboMatrix.SelectedIndex);
|
||||
Program.config.setConfig("matrix_running", comboMatrixRunning.SelectedIndex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@
|
||||
<windowsSettings>
|
||||
<!--<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitor/dpiAwareness>-->
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor, System</dpiAwareness>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user