From 52b07843a2cc40c09d07a95ba7ceeb577060f32a Mon Sep 17 00:00:00 2001 From: seerge Date: Sun, 5 Mar 2023 19:59:07 +0100 Subject: [PATCH] UI Fixes --- Fans.Designer.cs | 6 +-- Keyboard.Designer.cs | 38 +++++++++++++++- Keyboard.cs | 103 ++++++++++++++++--------------------------- Program.cs | 6 ++- Settings.Designer.cs | 56 +++++++++++------------ app.manifest | 1 - 6 files changed, 108 insertions(+), 102 deletions(-) diff --git a/Fans.Designer.cs b/Fans.Designer.cs index 44d0a7cf..6e7d4c39 100644 --- a/Fans.Designer.cs +++ b/Fans.Designer.cs @@ -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; diff --git a/Keyboard.Designer.cs b/Keyboard.Designer.cs index bbea83e8..f6c96e53 100644 --- a/Keyboard.Designer.cs +++ b/Keyboard.Designer.cs @@ -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; } } \ No newline at end of file diff --git a/Keyboard.cs b/Keyboard.cs index 5cf390eb..1b57bab3 100644 --- a/Keyboard.cs +++ b/Keyboard.cs @@ -1,11 +1,8 @@ -using System.Diagnostics.Metrics; - -namespace GHelper +namespace GHelper { public partial class Keyboard : Form { - Dictionary customActions = new Dictionary { {"","--------------" }, @@ -16,82 +13,56 @@ namespace 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"); - } } } diff --git a/Program.cs b/Program.cs index 31d3b13a..ca8bb67d 100644 --- a/Program.cs +++ b/Program.cs @@ -134,10 +134,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) @@ -188,7 +190,7 @@ namespace GHelper settingsForm.BeginInvoke(settingsForm.CyclePerformanceMode); return; case 179: // FN+F4 - settingsForm.BeginInvoke(settingsForm.CycleAuraMode); + KeyProcess("fnf4"); return; } diff --git a/Settings.Designer.cs b/Settings.Designer.cs index a0a14213..6a2da706 100644 --- a/Settings.Designer.cs +++ b/Settings.Designer.cs @@ -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; diff --git a/app.manifest b/app.manifest index 7cdc0357..1c128261 100644 --- a/app.manifest +++ b/app.manifest @@ -55,7 +55,6 @@ PerMonitorV2, PerMonitor, System - true