diff --git a/YAMDCC.ConfigEditor/MainWindow.Designer.cs b/YAMDCC.ConfigEditor/MainWindow.Designer.cs index be0c062..a5d4801 100644 --- a/YAMDCC.ConfigEditor/MainWindow.Designer.cs +++ b/YAMDCC.ConfigEditor/MainWindow.Designer.cs @@ -83,9 +83,6 @@ private void InitializeComponent() this.tsiSource = new System.Windows.Forms.ToolStripMenuItem(); this.tblFanControl = new System.Windows.Forms.TableLayoutPanel(); this.tblCurve = new System.Windows.Forms.TableLayoutPanel(); - this.lblSpeed = new System.Windows.Forms.Label(); - this.lblUpT = new System.Windows.Forms.Label(); - this.lblDownT = new System.Windows.Forms.Label(); this.lblFanSel = new System.Windows.Forms.Label(); this.cboFanSel = new System.Windows.Forms.ComboBox(); this.lblProfSel = new System.Windows.Forms.Label(); @@ -128,7 +125,6 @@ private void InitializeComponent() tcMain.SuspendLayout(); tabFanControl.SuspendLayout(); this.tblFanControl.SuspendLayout(); - this.tblCurve.SuspendLayout(); flwFanSelect.SuspendLayout(); tabExtra.SuspendLayout(); tblExtra.SuspendLayout(); @@ -256,27 +252,27 @@ private void InitializeComponent() // tsiProfRename // this.tsiProfRename.Name = "tsiProfRename"; - this.tsiProfRename.Size = new System.Drawing.Size(180, 22); + this.tsiProfRename.Size = new System.Drawing.Size(178, 22); this.tsiProfRename.Text = "Change Name"; this.tsiProfRename.Click += new System.EventHandler(this.tsiProfRename_Click); // // tsiProfChangeDesc // this.tsiProfChangeDesc.Name = "tsiProfChangeDesc"; - this.tsiProfChangeDesc.Size = new System.Drawing.Size(180, 22); + this.tsiProfChangeDesc.Size = new System.Drawing.Size(178, 22); this.tsiProfChangeDesc.Text = "Change Description"; this.tsiProfChangeDesc.Click += new System.EventHandler(this.tsiProfChangeDesc_Click); // // sep3 // sep3.Name = "sep3"; - sep3.Size = new System.Drawing.Size(177, 6); + sep3.Size = new System.Drawing.Size(175, 6); // // tsiProfDel // this.tsiProfDel.Name = "tsiProfDel"; this.tsiProfDel.ShortcutKeys = System.Windows.Forms.Keys.Delete; - this.tsiProfDel.Size = new System.Drawing.Size(180, 22); + this.tsiProfDel.Size = new System.Drawing.Size(178, 22); this.tsiProfDel.Text = "Delete"; this.tsiProfDel.Click += new System.EventHandler(this.tsiProfDel_Click); // @@ -334,14 +330,14 @@ private void InitializeComponent() // tsiAbout // this.tsiAbout.Name = "tsiAbout"; - this.tsiAbout.Size = new System.Drawing.Size(180, 22); + this.tsiAbout.Size = new System.Drawing.Size(141, 22); this.tsiAbout.Text = "&About"; this.tsiAbout.Click += new System.EventHandler(this.tsiAbout_Click); // // tsiSource // this.tsiSource.Name = "tsiSource"; - this.tsiSource.Size = new System.Drawing.Size(180, 22); + this.tsiSource.Size = new System.Drawing.Size(141, 22); this.tsiSource.Text = "Source &Code"; this.tsiSource.Click += new System.EventHandler(this.tsiSrc_Click); // @@ -377,29 +373,18 @@ private void InitializeComponent() this.tblFanControl.Location = new System.Drawing.Point(0, 0); this.tblFanControl.Margin = new System.Windows.Forms.Padding(0); this.tblFanControl.Name = "tblFanControl"; - this.tblFanControl.RowCount = 3; + this.tblFanControl.RowCount = 2; this.tblFanControl.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tblFanControl.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tblFanControl.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tblFanControl.Size = new System.Drawing.Size(526, 336); this.tblFanControl.TabIndex = 0; // // tblCurve // this.tblCurve.AutoSize = true; - this.tblCurve.ColumnCount = 2; - this.tblCurve.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tblCurve.ColumnCount = 1; this.tblCurve.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tblCurve.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tblCurve.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tblCurve.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tblCurve.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tblCurve.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tblCurve.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tblCurve.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tblCurve.Controls.Add(this.lblSpeed, 0, 0); - this.tblCurve.Controls.Add(this.lblUpT, 0, 2); - this.tblCurve.Controls.Add(this.lblDownT, 0, 3); this.tblCurve.Dock = System.Windows.Forms.DockStyle.Fill; this.tblCurve.Location = new System.Drawing.Point(0, 29); this.tblCurve.Margin = new System.Windows.Forms.Padding(0); @@ -412,42 +397,6 @@ private void InitializeComponent() this.tblCurve.Size = new System.Drawing.Size(526, 307); this.tblCurve.TabIndex = 2; // - // lblSpeed - // - this.lblSpeed.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.lblSpeed.AutoSize = true; - this.lblSpeed.Location = new System.Drawing.Point(4, 2); - this.lblSpeed.Margin = new System.Windows.Forms.Padding(2, 2, 0, 2); - this.lblSpeed.Name = "lblSpeed"; - this.lblSpeed.Padding = new System.Windows.Forms.Padding(0, 0, 0, 3); - this.lblSpeed.Size = new System.Drawing.Size(60, 18); - this.lblSpeed.TabIndex = 0; - this.lblSpeed.Text = "Speed (%)"; - // - // lblUpT - // - this.lblUpT.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.lblUpT.AutoSize = true; - this.lblUpT.Location = new System.Drawing.Point(18, 265); - this.lblUpT.Margin = new System.Windows.Forms.Padding(2, 2, 0, 2); - this.lblUpT.Name = "lblUpT"; - this.lblUpT.Padding = new System.Windows.Forms.Padding(0, 0, 0, 3); - this.lblUpT.Size = new System.Drawing.Size(46, 18); - this.lblUpT.TabIndex = 1; - this.lblUpT.Text = "Up (°C)"; - // - // lblDownT - // - this.lblDownT.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.lblDownT.AutoSize = true; - this.lblDownT.Location = new System.Drawing.Point(2, 287); - this.lblDownT.Margin = new System.Windows.Forms.Padding(2, 2, 0, 2); - this.lblDownT.Name = "lblDownT"; - this.lblDownT.Padding = new System.Windows.Forms.Padding(0, 0, 0, 3); - this.lblDownT.Size = new System.Drawing.Size(62, 18); - this.lblDownT.TabIndex = 2; - this.lblDownT.Text = "Down (°C)"; - // // flwFanSelect // flwFanSelect.AutoSize = true; @@ -839,8 +788,6 @@ private void InitializeComponent() tabFanControl.ResumeLayout(false); this.tblFanControl.ResumeLayout(false); this.tblFanControl.PerformLayout(); - this.tblCurve.ResumeLayout(false); - this.tblCurve.PerformLayout(); flwFanSelect.ResumeLayout(false); flwFanSelect.PerformLayout(); tabExtra.ResumeLayout(false); @@ -884,9 +831,6 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem tsiSource; private System.Windows.Forms.TableLayoutPanel tblFanControl; private System.Windows.Forms.TableLayoutPanel tblCurve; - private System.Windows.Forms.Label lblSpeed; - private System.Windows.Forms.Label lblUpT; - private System.Windows.Forms.Label lblDownT; private System.Windows.Forms.Label lblFanSel; private System.Windows.Forms.ComboBox cboFanSel; private System.Windows.Forms.Label lblProfSel; diff --git a/YAMDCC.ConfigEditor/MainWindow.cs b/YAMDCC.ConfigEditor/MainWindow.cs index bd325c8..691698a 100644 --- a/YAMDCC.ConfigEditor/MainWindow.cs +++ b/YAMDCC.ConfigEditor/MainWindow.cs @@ -44,10 +44,8 @@ internal sealed partial class MainWindow : Form private readonly NamedPipeClient IPCClient = new("YAMDCC-Server"); - private readonly NumericUpDown[] numUpTs = new NumericUpDown[6]; - private readonly NumericUpDown[] numDownTs = new NumericUpDown[6]; - private readonly NumericUpDown[] numFanSpds = new NumericUpDown[7]; - private readonly TrackBar[] tbFanSpds = new TrackBar[7]; + private NumericUpDown[] numUpTs, numDownTs, numFanSpds; + private TrackBar[] tbFanSpds; private readonly ToolTip ttMain = new(); @@ -88,91 +86,6 @@ public MainWindow() ttMain.SetToolTip(btnApply, Strings.GetString("ttApply")); ttMain.SetToolTip(btnRevert, Strings.GetString("ttRevert")); - float scale = CurrentAutoScaleDimensions.Height / 72; - - tblCurve.ColumnStyles.Clear(); - tblCurve.ColumnCount = numFanSpds.Length + 2; - tblCurve.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); - - for (int i = 0; i < numFanSpds.Length; i++) - { - tblCurve.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F / numFanSpds.Length)); - numFanSpds[i] = new NumericUpDown() - { - Dock = DockStyle.Fill, - Margin = new Padding((int)(2 * scale)), - Tag = i, - }; - ttMain.SetToolTip(numFanSpds[i], Strings.GetString("ttFanSpd")); - numFanSpds[i].ValueChanged += numFanSpd_Changed; - tblCurve.Controls.Add(numFanSpds[i], i + 1, 0); - - tbFanSpds[i] = new TrackBar() - { - Dock = DockStyle.Fill, - Margin = new Padding((int)(10 * scale), 0, (int)(10 * scale), 0), - Orientation = Orientation.Vertical, - Tag = i, - TickFrequency = 5, - TickStyle = TickStyle.Both, - }; - ttMain.SetToolTip(tbFanSpds[i], Strings.GetString("ttFanSpd")); - tbFanSpds[i].ValueChanged += tbFanSpd_Scroll; - tblCurve.Controls.Add(tbFanSpds[i], i + 1, 1); - - if (i != 0) - { - numUpTs[i - 1] = new NumericUpDown() - { - Dock = DockStyle.Fill, - Height = (int)(23 * scale), - Margin = new Padding(2), - Tag = i - 1, - }; - ttMain.SetToolTip(numUpTs[i - 1], Strings.GetString("ttUpT")); - numUpTs[i - 1].ValueChanged += numUpT_Changed; - tblCurve.Controls.Add(numUpTs[i - 1], i + 1, 2); - } - else - { - tblCurve.Controls.Add(new Label - { - Dock = DockStyle.Fill, - Margin = new Padding((int)(2 * scale)), - Padding = new Padding(0, 0, 0, (int)(3 * scale)), - Text = "Default", - TextAlign = ContentAlignment.MiddleCenter, - }, - i + 1, 2); - } - - if (i != numFanSpds.Length - 1) - { - numDownTs[i] = new NumericUpDown() - { - Dock = DockStyle.Fill, - Height = (int)(23 * scale), - Margin = new Padding((int)(2 * scale)), - Tag = i, - }; - ttMain.SetToolTip(numDownTs[i], Strings.GetString("ttDownT")); - numDownTs[i].ValueChanged += numDownT_Changed; - tblCurve.Controls.Add(numDownTs[i], i + 1, 3); - } - else - { - tblCurve.Controls.Add(new Label - { - Dock = DockStyle.Fill, - Margin = new Padding((int)(2 * scale)), - Padding = new Padding(0, 0, 0, (int)(3 * scale)), - Text = "Max", - TextAlign = ContentAlignment.MiddleCenter, - }, - i + 1, 3); - } - } - tmrPoll = new() { Interval = 1000, @@ -790,7 +703,7 @@ private void tmrSvcTimeout_Tick(object sender, EventArgs e) tmrSvcTimeout.Stop(); } - #endregion + #endregion // Events #region Private methods private void UpdateFanMon(int value, int i) @@ -1057,6 +970,76 @@ private void UpdateFanCurveDisplay() cboProfSel.Items.Add(curve.Name); } + if (numUpTs is null || numDownTs is null || numFanSpds is null || tbFanSpds is null || + numUpTs.Length != config.UpThresholdRegs.Length || + numDownTs.Length != config.DownThresholdRegs.Length || + numFanSpds.Length != config.FanCurveRegs.Length || + tbFanSpds.Length != config.FanCurveRegs.Length) + { + float scale = CurrentAutoScaleDimensions.Height / 72; + + tblCurve.Controls.Clear(); + numUpTs = new NumericUpDown[config.UpThresholdRegs.Length]; + numDownTs = new NumericUpDown[config.DownThresholdRegs.Length]; + numFanSpds = new NumericUpDown[config.FanCurveRegs.Length]; + tbFanSpds = new TrackBar[config.FanCurveRegs.Length]; + + tblCurve.ColumnStyles.Clear(); + tblCurve.ColumnCount = numFanSpds.Length + 2; + + // labels on left side + tblCurve.ColumnStyles.Add(new ColumnStyle()); + tblCurve.Controls.Add(FanCurveLabel("Speed (%)", scale, ContentAlignment.MiddleRight), 0, 0); + tblCurve.Controls.Add(FanCurveLabel("Up (°C)", scale, ContentAlignment.MiddleRight), 0, 2); + tblCurve.Controls.Add(FanCurveLabel("Down (°C)", scale, ContentAlignment.MiddleRight), 0, 3); + + for (int i = 0; i < numFanSpds.Length; i++) + { + tblCurve.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F / numFanSpds.Length)); + numFanSpds[i] = FanCurveNUD(i, scale); + ttMain.SetToolTip(numFanSpds[i], Strings.GetString("ttFanSpd")); + numFanSpds[i].ValueChanged += numFanSpd_Changed; + tblCurve.Controls.Add(numFanSpds[i], i + 1, 0); + + tbFanSpds[i] = new TrackBar() + { + Dock = DockStyle.Fill, + Margin = new Padding((int)(10 * scale), 0, (int)(10 * scale), 0), + Orientation = Orientation.Vertical, + Tag = i, + TickFrequency = 5, + TickStyle = TickStyle.Both, + }; + ttMain.SetToolTip(tbFanSpds[i], Strings.GetString("ttFanSpd")); + tbFanSpds[i].ValueChanged += tbFanSpd_Scroll; + tblCurve.Controls.Add(tbFanSpds[i], i + 1, 1); + + if (i != 0) + { + numUpTs[i - 1] = FanCurveNUD(i - 1, scale); + ttMain.SetToolTip(numUpTs[i - 1], Strings.GetString("ttUpT")); + numUpTs[i - 1].ValueChanged += numUpT_Changed; + tblCurve.Controls.Add(numUpTs[i - 1], i + 1, 2); + } + else + { + tblCurve.Controls.Add(FanCurveLabel("Default", scale), i + 1, 2); + } + + if (i != numFanSpds.Length - 1) + { + numDownTs[i] = FanCurveNUD(i, scale); + ttMain.SetToolTip(numDownTs[i], Strings.GetString("ttDownT")); + numDownTs[i].ValueChanged += numDownT_Changed; + tblCurve.Controls.Add(numDownTs[i], i + 1, 3); + } + else + { + tblCurve.Controls.Add(FanCurveLabel("Max", scale), i + 1, 3); + } + } + } + for (int i = 0; i < numFanSpds.Length; i++) { if (config.FanCurveRegs.Length >= i) @@ -1080,7 +1063,30 @@ private void UpdateFanCurveDisplay() tmrPoll.Start(); } } - #endregion + + private static Label FanCurveLabel(string text, float scale, ContentAlignment textAlign = ContentAlignment.MiddleCenter) + { + return new Label + { + AutoSize = true, + Dock = DockStyle.Fill, + Margin = new Padding((int)(2 * scale)), + Padding = new Padding(0, 0, 0, (int)(3 * scale)), + Text = text, + TextAlign = textAlign, + }; + } + + private static NumericUpDown FanCurveNUD(int tag, float scale) + { + return new NumericUpDown() + { + Dock = DockStyle.Fill, + Height = (int)(23 * scale), + Margin = new Padding((int)(2 * scale)), + Tag = tag, + }; + } private void DisableAll() { @@ -1107,14 +1113,17 @@ private void DisableAll() tsiECtoConf.Enabled = false; tsiECMon.Enabled = false; - for (int i = 0; i < tbFanSpds.Length; i++) + if (tbFanSpds is not null) { - tbFanSpds[i].Enabled = false; - numFanSpds[i].Enabled = false; - if (i != 0) + for (int i = 0; i < tbFanSpds.Length; i++) { - numUpTs[i - 1].Enabled = false; - numDownTs[i - 1].Enabled = false; + tbFanSpds[i].Enabled = false; + numFanSpds[i].Enabled = false; + if (i != 0) + { + numUpTs[i - 1].Enabled = false; + numDownTs[i - 1].Enabled = false; + } } } } @@ -1185,5 +1194,6 @@ private void SendServiceMessage(ServiceCommand command) IPCClient.PushMessage(command); tmrSvcTimeout.Start(); } + #endregion // Private methods } } diff --git a/YAMDCC.ConfigEditor/MainWindow.resx b/YAMDCC.ConfigEditor/MainWindow.resx index 76092b1..9e76e27 100644 --- a/YAMDCC.ConfigEditor/MainWindow.resx +++ b/YAMDCC.ConfigEditor/MainWindow.resx @@ -129,6 +129,21 @@ False + + False + + + False + + + False + + + False + + + False + False @@ -153,6 +168,24 @@ False + + False + + + False + + + False + + + False + + + False + + + False + False