Compare commits

...

3 Commits

Author SHA1 Message Date
seerge
24014dd20f Fix 2023-03-05 23:26:39 +01:00
seerge
321bc2623d Added support for animated GIF in animatrix 2023-03-05 23:14:48 +01:00
seerge
52b07843a2 UI Fixes 2023-03-05 19:59:07 +01:00
10 changed files with 225 additions and 152 deletions

View File

@@ -1,5 +1,6 @@
// Source thanks to https://github.com/vddCore/Starlight :) // Source thanks to https://github.com/vddCore/Starlight :)
using System.Diagnostics;
using System.Text; using System.Text;
using Starlight.Communication; using Starlight.Communication;
@@ -71,13 +72,40 @@ namespace Starlight.AnimeMatrix
public int LedCount => 1450; public int LedCount => 1450;
public int Rows => 61; 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() public AnimeMatrixDevice()
: base(0x0B05, 0x193B, 640) : base(0x0B05, 0x193B, 640)
{ {
} }
public byte[] GetBuffer()
{
return _displayBuffer;
}
public void PresentNextFrame()
{
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) public void SendRaw(params byte[] data)
{ {
Set(Packet<AnimeMatrixPacket>(data)); Set(Packet<AnimeMatrixPacket>(data));
@@ -208,6 +236,41 @@ namespace Starlight.AnimeMatrix
SetBuiltInAnimation(enable); SetBuiltInAnimation(enable);
Set(Packet<AnimeMatrixPacket>(0xC5, animation.AsByte)); 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)((pixel.R + pixel.G + pixel.B) / 3);
SetLedPlanar(x, y, color);
}
}
}
private void EnsureRowInRange(int row) private void EnsureRowInRange(int row)
{ {

View File

@@ -3,8 +3,8 @@
public class Aura public class Aura
{ {
static byte[] MESSAGE_SET = { 0x5d, 0xb5 }; static byte[] MESSAGE_SET = { 0x5d, 0xb5, 0,0,0 };
static byte[] MESSAGE_APPLY = { 0x5d, 0xb4 }; static byte[] MESSAGE_APPLY = { 0x5d, 0xb4};
public const int Static = 0; public const int Static = 0;
public const int Breathe = 1; public const int Breathe = 1;

6
Fans.Designer.cs generated
View File

@@ -247,8 +247,9 @@
// //
// Fans // Fans
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(96F, 96F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Dpi;
AutoSize = true;
ClientSize = new Size(621, 510); ClientSize = new Size(621, 510);
Controls.Add(checkAuto); Controls.Add(checkAuto);
Controls.Add(buttonApplyPower); Controls.Add(buttonApplyPower);
@@ -257,7 +258,6 @@
Controls.Add(buttonReset); Controls.Add(buttonReset);
Controls.Add(buttonApply); Controls.Add(buttonApply);
Controls.Add(chartCPU); Controls.Add(chartCPU);
FormBorderStyle = FormBorderStyle.FixedSingle;
Margin = new Padding(2, 1, 2, 1); Margin = new Padding(2, 1, 2, 1);
MaximizeBox = false; MaximizeBox = false;
MdiChildrenMinimizedAnchorBottom = false; MdiChildrenMinimizedAnchorBottom = false;

View File

@@ -15,7 +15,7 @@
<AssemblyName>GHelper</AssemblyName> <AssemblyName>GHelper</AssemblyName>
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly> <ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AssemblyVersion>0.15.1</AssemblyVersion> <AssemblyVersion>0.16</AssemblyVersion>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>

38
Keyboard.Designer.cs generated
View File

@@ -35,11 +35,17 @@
labelM4 = new Label(); labelM4 = new Label();
comboM3 = new ComboBox(); comboM3 = new ComboBox();
labelM3 = new Label(); labelM3 = new Label();
textFNF4 = new TextBox();
comboFNF4 = new ComboBox();
labelFNF4 = new Label();
groupBox1.SuspendLayout(); groupBox1.SuspendLayout();
SuspendLayout(); SuspendLayout();
// //
// groupBox1 // groupBox1
// //
groupBox1.Controls.Add(textFNF4);
groupBox1.Controls.Add(comboFNF4);
groupBox1.Controls.Add(labelFNF4);
groupBox1.Controls.Add(textM4); groupBox1.Controls.Add(textM4);
groupBox1.Controls.Add(textM3); groupBox1.Controls.Add(textM3);
groupBox1.Controls.Add(comboM4); groupBox1.Controls.Add(comboM4);
@@ -49,7 +55,7 @@
groupBox1.Dock = DockStyle.Top; groupBox1.Dock = DockStyle.Top;
groupBox1.Location = new Point(10, 10); groupBox1.Location = new Point(10, 10);
groupBox1.Name = "groupBox1"; groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(751, 196); groupBox1.Size = new Size(751, 242);
groupBox1.TabIndex = 0; groupBox1.TabIndex = 0;
groupBox1.TabStop = false; groupBox1.TabStop = false;
groupBox1.Text = "Key Bindings"; groupBox1.Text = "Key Bindings";
@@ -58,7 +64,7 @@
// //
textM4.Location = new Point(411, 113); textM4.Location = new Point(411, 113);
textM4.Name = "textM4"; textM4.Name = "textM4";
textM4.PlaceholderText = "notepad /p \"file.txt\""; textM4.PlaceholderText = "action";
textM4.Size = new Size(320, 39); textM4.Size = new Size(320, 39);
textM4.TabIndex = 5; textM4.TabIndex = 5;
// //
@@ -106,6 +112,31 @@
labelM3.TabIndex = 0; labelM3.TabIndex = 0;
labelM3.Text = "M3:"; 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 // Keyboard
// //
AutoScaleDimensions = new SizeF(13F, 32F); AutoScaleDimensions = new SizeF(13F, 32F);
@@ -135,5 +166,8 @@
private Label labelM4; private Label labelM4;
private TextBox textM4; private TextBox textM4;
private TextBox textM3; private TextBox textM3;
private TextBox textFNF4;
private ComboBox comboFNF4;
private Label labelFNF4;
} }
} }

View File

@@ -1,11 +1,8 @@
using System.Diagnostics.Metrics; namespace GHelper
namespace GHelper
{ {
public partial class Keyboard : Form public partial class Keyboard : Form
{ {
Dictionary<string, string> customActions = new Dictionary<string, string> Dictionary<string, string> customActions = new Dictionary<string, string>
{ {
{"","--------------" }, {"","--------------" },
@@ -13,85 +10,60 @@ namespace GHelper
{"screenshot", "Screenshot"}, {"screenshot", "Screenshot"},
{"play", "Play/Pause"}, {"play", "Play/Pause"},
{"aura", "Aura"}, {"aura", "Aura"},
{"ghelper", "Open GHelper"},
{"custom", "Custom"} {"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() public Keyboard()
{ {
InitializeComponent(); InitializeComponent();
comboM3.DropDownStyle = ComboBoxStyle.DropDownList; SetKeyCombo(comboM3, textM3, "m3");
comboM3.DataSource = new BindingSource(customActions, null); SetKeyCombo(comboM4, textM4, "m4");
comboM3.DisplayMember = "Value"; SetKeyCombo(comboFNF4, textFNF4, "fnf4");
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;
Shown += Keyboard_Shown; 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) private void Keyboard_Shown(object? sender, EventArgs e)
{ {
Top = Program.settingsForm.Top; Top = Program.settingsForm.Top;
Left = Program.settingsForm.Left - Width - 5; 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");
} }
} }
} }

View File

@@ -134,10 +134,12 @@ namespace GHelper
{ {
string action = config.getConfigString(name); string action = config.getConfigString(name);
if (action.Length == 0) if (action is null || action.Length <= 1)
{ {
if (name == "m4") if (name == "m4")
action = "performance"; action = "performance";
if (name == "fnf4")
action = "aura";
} }
switch (action) switch (action)
@@ -157,6 +159,9 @@ namespace GHelper
case "performance": case "performance":
settingsForm.BeginInvoke(settingsForm.CyclePerformanceMode); settingsForm.BeginInvoke(settingsForm.CyclePerformanceMode);
break; break;
case "ghelper":
settingsForm.BeginInvoke(SettingsToggle);
break;
case "custom": case "custom":
CustomKey(name); CustomKey(name);
break; break;
@@ -188,7 +193,7 @@ namespace GHelper
settingsForm.BeginInvoke(settingsForm.CyclePerformanceMode); settingsForm.BeginInvoke(settingsForm.CyclePerformanceMode);
return; return;
case 179: // FN+F4 case 179: // FN+F4
settingsForm.BeginInvoke(settingsForm.CycleAuraMode); KeyProcess("fnf4");
return; return;
} }

56
Settings.Designer.cs generated
View File

@@ -106,7 +106,7 @@
trackBattery.Maximum = 100; trackBattery.Maximum = 100;
trackBattery.Minimum = 50; trackBattery.Minimum = 50;
trackBattery.Name = "trackBattery"; trackBattery.Name = "trackBattery";
trackBattery.Size = new Size(341, 45); trackBattery.Size = new Size(337, 45);
trackBattery.SmallChange = 10; trackBattery.SmallChange = 10;
trackBattery.TabIndex = 3; trackBattery.TabIndex = 3;
trackBattery.TickFrequency = 10; trackBattery.TickFrequency = 10;
@@ -138,7 +138,7 @@
// labelGPUFan // labelGPUFan
// //
labelGPUFan.Anchor = AnchorStyles.Top | AnchorStyles.Right; 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.Margin = new Padding(2, 0, 2, 0);
labelGPUFan.Name = "labelGPUFan"; labelGPUFan.Name = "labelGPUFan";
labelGPUFan.Size = new Size(174, 16); labelGPUFan.Size = new Size(174, 16);
@@ -161,7 +161,7 @@
tableGPU.Name = "tableGPU"; tableGPU.Name = "tableGPU";
tableGPU.RowCount = 1; tableGPU.RowCount = 1;
tableGPU.RowStyles.Add(new RowStyle(SizeType.Absolute, 54F)); tableGPU.RowStyles.Add(new RowStyle(SizeType.Absolute, 54F));
tableGPU.Size = new Size(341, 54); tableGPU.Size = new Size(337, 54);
tableGPU.TabIndex = 7; tableGPU.TabIndex = 7;
// //
// buttonUltimate // buttonUltimate
@@ -170,10 +170,10 @@
buttonUltimate.Dock = DockStyle.Fill; buttonUltimate.Dock = DockStyle.Fill;
buttonUltimate.FlatAppearance.BorderSize = 0; buttonUltimate.FlatAppearance.BorderSize = 0;
buttonUltimate.FlatStyle = FlatStyle.Flat; 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.Margin = new Padding(4, 6, 4, 6);
buttonUltimate.Name = "buttonUltimate"; buttonUltimate.Name = "buttonUltimate";
buttonUltimate.Size = new Size(107, 42); buttonUltimate.Size = new Size(105, 42);
buttonUltimate.TabIndex = 2; buttonUltimate.TabIndex = 2;
buttonUltimate.Text = "Ultimate"; buttonUltimate.Text = "Ultimate";
buttonUltimate.UseVisualStyleBackColor = false; buttonUltimate.UseVisualStyleBackColor = false;
@@ -184,10 +184,10 @@
buttonStandard.Dock = DockStyle.Fill; buttonStandard.Dock = DockStyle.Fill;
buttonStandard.FlatAppearance.BorderSize = 0; buttonStandard.FlatAppearance.BorderSize = 0;
buttonStandard.FlatStyle = FlatStyle.Flat; 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.Margin = new Padding(4, 6, 4, 6);
buttonStandard.Name = "buttonStandard"; buttonStandard.Name = "buttonStandard";
buttonStandard.Size = new Size(105, 42); buttonStandard.Size = new Size(104, 42);
buttonStandard.TabIndex = 1; buttonStandard.TabIndex = 1;
buttonStandard.Text = "Standard"; buttonStandard.Text = "Standard";
buttonStandard.UseVisualStyleBackColor = false; buttonStandard.UseVisualStyleBackColor = false;
@@ -202,7 +202,7 @@
buttonEco.Location = new Point(4, 6); buttonEco.Location = new Point(4, 6);
buttonEco.Margin = new Padding(4, 6, 4, 6); buttonEco.Margin = new Padding(4, 6, 4, 6);
buttonEco.Name = "buttonEco"; buttonEco.Name = "buttonEco";
buttonEco.Size = new Size(105, 42); buttonEco.Size = new Size(104, 42);
buttonEco.TabIndex = 0; buttonEco.TabIndex = 0;
buttonEco.Text = "Eco"; buttonEco.Text = "Eco";
buttonEco.UseVisualStyleBackColor = false; buttonEco.UseVisualStyleBackColor = false;
@@ -232,7 +232,7 @@
// labelCPUFan // labelCPUFan
// //
labelCPUFan.Anchor = AnchorStyles.Top | AnchorStyles.Right; 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.Margin = new Padding(2, 0, 2, 0);
labelCPUFan.Name = "labelCPUFan"; labelCPUFan.Name = "labelCPUFan";
labelCPUFan.Size = new Size(183, 16); labelCPUFan.Size = new Size(183, 16);
@@ -255,7 +255,7 @@
tablePerf.Name = "tablePerf"; tablePerf.Name = "tablePerf";
tablePerf.RowCount = 1; tablePerf.RowCount = 1;
tablePerf.RowStyles.Add(new RowStyle(SizeType.Absolute, 54F)); tablePerf.RowStyles.Add(new RowStyle(SizeType.Absolute, 54F));
tablePerf.Size = new Size(341, 54); tablePerf.Size = new Size(337, 54);
tablePerf.TabIndex = 11; tablePerf.TabIndex = 11;
// //
// buttonTurbo // buttonTurbo
@@ -265,10 +265,10 @@
buttonTurbo.FlatAppearance.BorderColor = Color.FromArgb(192, 0, 0); buttonTurbo.FlatAppearance.BorderColor = Color.FromArgb(192, 0, 0);
buttonTurbo.FlatAppearance.BorderSize = 0; buttonTurbo.FlatAppearance.BorderSize = 0;
buttonTurbo.FlatStyle = FlatStyle.Flat; 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.Margin = new Padding(4, 6, 4, 6);
buttonTurbo.Name = "buttonTurbo"; buttonTurbo.Name = "buttonTurbo";
buttonTurbo.Size = new Size(107, 42); buttonTurbo.Size = new Size(105, 42);
buttonTurbo.TabIndex = 2; buttonTurbo.TabIndex = 2;
buttonTurbo.Text = "Turbo"; buttonTurbo.Text = "Turbo";
buttonTurbo.UseVisualStyleBackColor = false; buttonTurbo.UseVisualStyleBackColor = false;
@@ -280,10 +280,10 @@
buttonBalanced.FlatAppearance.BorderColor = Color.FromArgb(0, 0, 192); buttonBalanced.FlatAppearance.BorderColor = Color.FromArgb(0, 0, 192);
buttonBalanced.FlatAppearance.BorderSize = 0; buttonBalanced.FlatAppearance.BorderSize = 0;
buttonBalanced.FlatStyle = FlatStyle.Flat; 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.Margin = new Padding(4, 6, 4, 6);
buttonBalanced.Name = "buttonBalanced"; buttonBalanced.Name = "buttonBalanced";
buttonBalanced.Size = new Size(105, 42); buttonBalanced.Size = new Size(104, 42);
buttonBalanced.TabIndex = 1; buttonBalanced.TabIndex = 1;
buttonBalanced.Text = "Balanced"; buttonBalanced.Text = "Balanced";
buttonBalanced.UseVisualStyleBackColor = false; buttonBalanced.UseVisualStyleBackColor = false;
@@ -299,7 +299,7 @@
buttonSilent.Location = new Point(4, 6); buttonSilent.Location = new Point(4, 6);
buttonSilent.Margin = new Padding(4, 6, 4, 6); buttonSilent.Margin = new Padding(4, 6, 4, 6);
buttonSilent.Name = "buttonSilent"; buttonSilent.Name = "buttonSilent";
buttonSilent.Size = new Size(105, 42); buttonSilent.Size = new Size(104, 42);
buttonSilent.TabIndex = 0; buttonSilent.TabIndex = 0;
buttonSilent.Text = "Silent"; buttonSilent.Text = "Silent";
buttonSilent.UseVisualStyleBackColor = false; buttonSilent.UseVisualStyleBackColor = false;
@@ -344,7 +344,7 @@
// //
buttonQuit.Anchor = AnchorStyles.Top | AnchorStyles.Right; buttonQuit.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonQuit.BackColor = SystemColors.ButtonFace; 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.Margin = new Padding(2, 1, 2, 1);
buttonQuit.Name = "buttonQuit"; buttonQuit.Name = "buttonQuit";
buttonQuit.Size = new Size(60, 24); buttonQuit.Size = new Size(60, 24);
@@ -388,7 +388,7 @@
tableScreen.Name = "tableScreen"; tableScreen.Name = "tableScreen";
tableScreen.RowCount = 1; tableScreen.RowCount = 1;
tableScreen.RowStyles.Add(new RowStyle(SizeType.Absolute, 54F)); tableScreen.RowStyles.Add(new RowStyle(SizeType.Absolute, 54F));
tableScreen.Size = new Size(341, 54); tableScreen.Size = new Size(337, 54);
tableScreen.TabIndex = 19; tableScreen.TabIndex = 19;
// //
// button120Hz // button120Hz
@@ -398,10 +398,10 @@
button120Hz.FlatAppearance.BorderColor = SystemColors.ActiveBorder; button120Hz.FlatAppearance.BorderColor = SystemColors.ActiveBorder;
button120Hz.FlatAppearance.BorderSize = 0; button120Hz.FlatAppearance.BorderSize = 0;
button120Hz.FlatStyle = FlatStyle.Flat; 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.Margin = new Padding(4, 6, 4, 6);
button120Hz.Name = "button120Hz"; button120Hz.Name = "button120Hz";
button120Hz.Size = new Size(105, 42); button120Hz.Size = new Size(104, 42);
button120Hz.TabIndex = 1; button120Hz.TabIndex = 1;
button120Hz.Text = "120Hz + OD"; button120Hz.Text = "120Hz + OD";
button120Hz.UseVisualStyleBackColor = false; button120Hz.UseVisualStyleBackColor = false;
@@ -418,7 +418,7 @@
button60Hz.Location = new Point(4, 6); button60Hz.Location = new Point(4, 6);
button60Hz.Margin = new Padding(4, 6, 4, 6); button60Hz.Margin = new Padding(4, 6, 4, 6);
button60Hz.Name = "button60Hz"; button60Hz.Name = "button60Hz";
button60Hz.Size = new Size(105, 42); button60Hz.Size = new Size(104, 42);
button60Hz.TabIndex = 0; button60Hz.TabIndex = 0;
button60Hz.Text = "60Hz"; button60Hz.Text = "60Hz";
button60Hz.UseVisualStyleBackColor = false; button60Hz.UseVisualStyleBackColor = false;
@@ -500,7 +500,7 @@
// labelBattery // labelBattery
// //
labelBattery.Anchor = AnchorStyles.Top | AnchorStyles.Right; 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.Margin = new Padding(2, 0, 2, 0);
labelBattery.Name = "labelBattery"; labelBattery.Name = "labelBattery";
labelBattery.Size = new Size(138, 16); labelBattery.Size = new Size(138, 16);
@@ -513,7 +513,7 @@
buttonFans.Anchor = AnchorStyles.Top | AnchorStyles.Right; buttonFans.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonFans.BackColor = SystemColors.ButtonFace; buttonFans.BackColor = SystemColors.ButtonFace;
buttonFans.FlatAppearance.BorderSize = 0; 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.Margin = new Padding(2, 1, 2, 1);
buttonFans.Name = "buttonFans"; buttonFans.Name = "buttonFans";
buttonFans.Size = new Size(105, 24); buttonFans.Size = new Size(105, 24);
@@ -526,7 +526,7 @@
buttonKeyboard.Anchor = AnchorStyles.Top | AnchorStyles.Right; buttonKeyboard.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonKeyboard.BackColor = SystemColors.ButtonFace; buttonKeyboard.BackColor = SystemColors.ButtonFace;
buttonKeyboard.FlatAppearance.BorderSize = 0; 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.Margin = new Padding(2, 1, 2, 1);
buttonKeyboard.Name = "buttonKeyboard"; buttonKeyboard.Name = "buttonKeyboard";
buttonKeyboard.Size = new Size(104, 24); buttonKeyboard.Size = new Size(104, 24);
@@ -537,7 +537,7 @@
// pictureColor // pictureColor
// //
pictureColor.Location = new Point(216, 390); pictureColor.Location = new Point(216, 390);
pictureColor.Margin = new Padding(2, 2, 2, 2); pictureColor.Margin = new Padding(2);
pictureColor.Name = "pictureColor"; pictureColor.Name = "pictureColor";
pictureColor.Size = new Size(10, 10); pictureColor.Size = new Size(10, 10);
pictureColor.TabIndex = 30; pictureColor.TabIndex = 30;
@@ -546,7 +546,7 @@
// pictureColor2 // pictureColor2
// //
pictureColor2.Location = new Point(202, 390); pictureColor2.Location = new Point(202, 390);
pictureColor2.Margin = new Padding(2, 2, 2, 2); pictureColor2.Margin = new Padding(2);
pictureColor2.Name = "pictureColor2"; pictureColor2.Name = "pictureColor2";
pictureColor2.Size = new Size(10, 10); pictureColor2.Size = new Size(10, 10);
pictureColor2.TabIndex = 31; pictureColor2.TabIndex = 31;
@@ -617,7 +617,7 @@
buttonMatrix.Anchor = AnchorStyles.Top | AnchorStyles.Right; buttonMatrix.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonMatrix.BackColor = SystemColors.ButtonFace; buttonMatrix.BackColor = SystemColors.ButtonFace;
buttonMatrix.FlatAppearance.BorderSize = 0; 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.Margin = new Padding(2, 1, 2, 1);
buttonMatrix.Name = "buttonMatrix"; buttonMatrix.Name = "buttonMatrix";
buttonMatrix.Size = new Size(104, 24); buttonMatrix.Size = new Size(104, 24);
@@ -629,7 +629,8 @@
// //
AutoScaleDimensions = new SizeF(96F, 96F); AutoScaleDimensions = new SizeF(96F, 96F);
AutoScaleMode = AutoScaleMode.Dpi; AutoScaleMode = AutoScaleMode.Dpi;
ClientSize = new Size(368, 602); AutoSize = true;
ClientSize = new Size(364, 599);
Controls.Add(buttonMatrix); Controls.Add(buttonMatrix);
Controls.Add(comboMatrixRunning); Controls.Add(comboMatrixRunning);
Controls.Add(comboMatrix); Controls.Add(comboMatrix);
@@ -664,7 +665,6 @@
Controls.Add(labelBatteryTitle); Controls.Add(labelBatteryTitle);
Controls.Add(trackBattery); Controls.Add(trackBattery);
Controls.Add(checkStartup); Controls.Add(checkStartup);
FormBorderStyle = FormBorderStyle.FixedSingle;
Margin = new Padding(2, 1, 2, 1); Margin = new Padding(2, 1, 2, 1);
MaximizeBox = false; MaximizeBox = false;
MdiChildrenMinimizedAnchorBottom = false; MdiChildrenMinimizedAnchorBottom = false;

View File

@@ -1,10 +1,8 @@
using Starlight.AnimeMatrix; using Starlight.AnimeMatrix;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing.Imaging;
using System.Reflection; using System.Reflection;
using System.Timers; using System.Timers;
using System.Drawing.Imaging;
using System.CodeDom.Compiler;
using System.Drawing;
namespace GHelper namespace GHelper
{ {
@@ -20,12 +18,15 @@ namespace GHelper
static int buttonActive = 5; static int buttonActive = 5;
static System.Timers.Timer aTimer = default!; static System.Timers.Timer aTimer = default!;
static System.Timers.Timer matrixTimer = new System.Timers.Timer(100);
public string perfName = "Balanced"; public string perfName = "Balanced";
Fans fans; Fans fans;
Keyboard keyb; Keyboard keyb;
AnimeMatrixDevice mat = new AnimeMatrixDevice();
public SettingsForm() public SettingsForm()
{ {
@@ -90,62 +91,61 @@ namespace GHelper
buttonMatrix.Click += ButtonMatrix_Click; buttonMatrix.Click += ButtonMatrix_Click;
matrixTimer.Enabled = false;
matrixTimer.Elapsed += MatrixTimer_Elapsed;
SetTimer(); SetTimer();
} }
private void MatrixTimer_Elapsed(object? sender, ElapsedEventArgs e)
{
mat.PresentNextFrame();
}
void SetMatrixPicture(string fileName) void SetMatrixPicture(string fileName)
{ {
int width = 34 * 3; Image image;
int height = 61;
float scale;
Bitmap image;
try try
{ {
using (var bmpTemp = (Bitmap)Image.FromFile(fileName)) using (var fs = new FileStream(fileName, FileMode.Open))
{ {
image = new Bitmap(bmpTemp); var ms = new MemoryStream();
fs.CopyTo(ms);
Bitmap canvas = new Bitmap(width, height); ms.Position = 0;
image = Image.FromStream(ms);
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();
} }
} }
catch catch
{ {
Debug.WriteLine("Error loading picture"); 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 +157,7 @@ namespace GHelper
Thread t = new Thread((ThreadStart)(() => Thread t = new Thread((ThreadStart)(() =>
{ {
OpenFileDialog of = new OpenFileDialog(); 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) if (of.ShowDialog() == DialogResult.OK)
{ {
Program.config.setConfig("matrix_picture", of.FileName); Program.config.setConfig("matrix_picture", of.FileName);
@@ -192,7 +192,7 @@ namespace GHelper
int brightness = comboMatrix.SelectedIndex; int brightness = comboMatrix.SelectedIndex;
int running = comboMatrixRunning.SelectedIndex; int running = comboMatrixRunning.SelectedIndex;
var mat = new AnimeMatrixDevice(); //var mat = new AnimeMatrixDevice();
BuiltInAnimation animation = new BuiltInAnimation( BuiltInAnimation animation = new BuiltInAnimation(
(BuiltInAnimation.Running)running, (BuiltInAnimation.Running)running,
@@ -222,7 +222,7 @@ namespace GHelper
} }
} }
mat.Dispose(); //mat.Dispose();
Program.config.setConfig("matrix_brightness", comboMatrix.SelectedIndex); Program.config.setConfig("matrix_brightness", comboMatrix.SelectedIndex);
Program.config.setConfig("matrix_running", comboMatrixRunning.SelectedIndex); Program.config.setConfig("matrix_running", comboMatrixRunning.SelectedIndex);

View File

@@ -55,7 +55,6 @@
<windowsSettings> <windowsSettings>
<!--<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitor/dpiAwareness>--> <!--<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitor/dpiAwareness>-->
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor, System</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> </windowsSettings>
</application> </application>