From 52d68d4b7f403e6be6eb02649067fc31851f9021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Sat, 12 Nov 2022 13:56:15 +0100 Subject: [PATCH] Clickable help and other changes --- FanControl/FanControl.csproj | 2 +- FanControl/FanControlForm.Designer.cs | 33 +++++------ FanControl/FanControlForm.cs | 7 ++- FanControl/FanSensor.cs | 5 -- FanControl/Program.cs | 80 +-------------------------- FanControl/app.manifest | 2 +- 6 files changed, 24 insertions(+), 105 deletions(-) diff --git a/FanControl/FanControl.csproj b/FanControl/FanControl.csproj index 3497e99..51cc293 100644 --- a/FanControl/FanControl.csproj +++ b/FanControl/FanControl.csproj @@ -8,7 +8,7 @@ True FanControl.Program app.manifest - 0.1.0 + 0.1.0 diff --git a/FanControl/FanControlForm.Designer.cs b/FanControl/FanControlForm.Designer.cs index 4d606a0..abed8ef 100644 --- a/FanControl/FanControlForm.Designer.cs +++ b/FanControl/FanControlForm.Designer.cs @@ -46,7 +46,7 @@ this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.sensorWarningLabel = new System.Windows.Forms.Label(); this.propertyGrid1 = new System.Windows.Forms.PropertyGrid(); - this.label1 = new System.Windows.Forms.Label(); + this.helpLabel = new System.Windows.Forms.Label(); this.contextMenu.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); @@ -160,7 +160,7 @@ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel1.Controls.Add(this.sensorWarningLabel, 0, 1); this.tableLayoutPanel1.Controls.Add(this.propertyGrid1, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.label1, 0, 2); + this.tableLayoutPanel1.Controls.Add(this.helpLabel, 0, 2); this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 44); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; @@ -198,20 +198,21 @@ this.propertyGrid1.TabIndex = 1; this.propertyGrid1.ToolbarVisible = false; // - // label1 + // helpLabel // - this.label1.AutoSize = true; - this.label1.Dock = System.Windows.Forms.DockStyle.Fill; - this.label1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.label1.Font = new System.Drawing.Font("Segoe UI", 9F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))), System.Drawing.GraphicsUnit.Point); - this.label1.ForeColor = System.Drawing.SystemColors.HotTrack; - this.label1.Location = new System.Drawing.Point(3, 853); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(706, 32); - this.label1.TabIndex = 7; - this.label1.Text = "https://github.com/ayufan-research/SteamDeckTools"; - this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.label1.DoubleClick += new System.EventHandler(this.label1_DoubleClick); + this.helpLabel.AutoSize = true; + this.helpLabel.Cursor = System.Windows.Forms.Cursors.Hand; + this.helpLabel.Dock = System.Windows.Forms.DockStyle.Fill; + this.helpLabel.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.helpLabel.Font = new System.Drawing.Font("Segoe UI", 9F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))), System.Drawing.GraphicsUnit.Point); + this.helpLabel.ForeColor = System.Drawing.SystemColors.HotTrack; + this.helpLabel.Location = new System.Drawing.Point(3, 853); + this.helpLabel.Name = "helpLabel"; + this.helpLabel.Size = new System.Drawing.Size(706, 32); + this.helpLabel.TabIndex = 7; + this.helpLabel.Text = "https://github.com/ayufan-research/SteamDeckTools"; + this.helpLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.helpLabel.DoubleClick += new System.EventHandler(this.help_DoubleClick); // // FanControlForm // @@ -258,6 +259,6 @@ private PropertyGrid propertyGrid1; private ToolStripMenuItem toolStripMenuItemStartupOnBoot; private ToolStripSeparator toolStripSeparator2; - private Label label1; + private Label helpLabel; } } \ No newline at end of file diff --git a/FanControl/FanControlForm.cs b/FanControl/FanControlForm.cs index 1fcb4a9..541acf5 100644 --- a/FanControl/FanControlForm.cs +++ b/FanControl/FanControlForm.cs @@ -72,13 +72,14 @@ namespace FanControl if (e.CloseReason == CloseReason.UserClosing && Visible) { e.Cancel = true; - WindowState = FormWindowState.Minimized; + Hide(); } } private void formShow_Event(object sender, EventArgs e) { WindowState = FormWindowState.Normal; + Show(); propertyGrid1.Refresh(); } @@ -117,9 +118,9 @@ namespace FanControl toolStripMenuItemStartupOnBoot.Checked = startupManager.Startup; } - private void label1_DoubleClick(object sender, EventArgs e) + private void help_DoubleClick(object sender, EventArgs e) { - System.Diagnostics.Process.Start("http://github.com/ayufan-research/SteamDeckTools"); + System.Diagnostics.Process.Start("explorer.exe", "http://github.com/ayufan-research/SteamDeckTools"); } } } diff --git a/FanControl/FanSensor.cs b/FanControl/FanSensor.cs index 69e2e02..0d8ea8d 100644 --- a/FanControl/FanSensor.cs +++ b/FanControl/FanSensor.cs @@ -206,11 +206,6 @@ namespace FanControl return value; } - public override string ToString() - { - return Name; - } - public ushort? CalculateRPM(FanController.FanMode mode) { if (!Profiles.ContainsKey(mode) || !Value.HasValue) diff --git a/FanControl/Program.cs b/FanControl/Program.cs index 4a124da..14af7ba 100644 --- a/FanControl/Program.cs +++ b/FanControl/Program.cs @@ -9,87 +9,9 @@ namespace FanControl { internal class Program { - public class UpdateVisitor : IVisitor - { - public void VisitComputer(IComputer computer) - { - computer.Traverse(this); - } - public void VisitHardware(IHardware hardware) - { - hardware.Update(); - foreach (IHardware subHardware in hardware.SubHardware) subHardware.Accept(this); - } - public void VisitSensor(ISensor sensor) { } - public void VisitParameter(IParameter parameter) { } - } - - public static void Monitor() - { - Computer computer = new Computer - { - IsCpuEnabled = true, - IsGpuEnabled = true, - IsMemoryEnabled = true, - IsMotherboardEnabled = true, - IsControllerEnabled = true, - IsNetworkEnabled = true, - IsStorageEnabled = true, - IsPsuEnabled = true, - IsBatteryEnabled = true - }; - - computer.Open(); - //computer.Accept(new UpdateVisitor()); - - foreach (IHardware hardware in computer.Hardware) - { - Console.WriteLine("Hardware: {0}. Type: {1}", hardware.Name, hardware.HardwareType); - - foreach (IHardware subhardware in hardware.SubHardware) - { - Console.WriteLine("\tSubhardware: {0}", subhardware.Name); - - foreach (ISensor sensor in subhardware.Sensors) - { - Console.WriteLine("\t\tSensor: {0}, value: {1}, type: {2}", sensor.Name, sensor.Value, sensor.SensorType); - } - } - - foreach (ISensor sensor in hardware.Sensors) - { - Console.WriteLine("\tSensor: {0}, value: {1}, type: {2}", sensor.Name, sensor.Value, sensor.SensorType); - } - } - - computer.Close(); - } - static void ConsoleMain(string[] args) - { - Monitor(); - - while (true) - { - Thread.Sleep(300); - - Vlv0100.SetFanControl(false); - Vlv0100.SetFanDesiredRPM(6000); - - Console.WriteLine("Fan RPM: {0}", Vlv0100.GetFanRPM()); - Console.WriteLine("Fan Desired RPM: {0}", Vlv0100.GetFanDesiredRPM()); - } - } - static void Main(string[] args) { - if (Environment.UserInteractive && !Console.IsInputRedirected) - { - ConsoleMain(args); - } - else - { - Application.Run(new FanControlForm()); - } + Application.Run(new FanControlForm()); } } } diff --git a/FanControl/app.manifest b/FanControl/app.manifest index 9eddb63..1c97d89 100644 --- a/FanControl/app.manifest +++ b/FanControl/app.manifest @@ -1,6 +1,6 @@  - +