From d073ab0ff6deb9fa18d8087469eab2298ed18781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Fri, 11 Nov 2022 20:01:44 +0100 Subject: [PATCH] Better startup sequence --- FanControl/FanControlForm.Designer.cs | 34 ++++++++++++++------------- FanControl/FanControlForm.cs | 19 +++++++++++---- FanControl/FanControlForm.resx | 6 ++--- 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/FanControl/FanControlForm.Designer.cs b/FanControl/FanControlForm.Designer.cs index 6887a68..9148584 100644 --- a/FanControl/FanControlForm.Designer.cs +++ b/FanControl/FanControlForm.Designer.cs @@ -30,8 +30,8 @@ { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FanControlForm)); - this.timer1 = new System.Windows.Forms.Timer(this.components); - this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); + this.updateTimer = new System.Windows.Forms.Timer(this.components); + this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components); this.contextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); this.fanModeSelectNotifyMenu = new System.Windows.Forms.ToolStripComboBox(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); @@ -45,21 +45,21 @@ this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // - // timer1 + // updateTimer // - this.timer1.Enabled = true; - this.timer1.Interval = 200; - this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + this.updateTimer.Enabled = true; + this.updateTimer.Interval = 250; + this.updateTimer.Tick += new System.EventHandler(this.updateTimer_Tick); // - // notifyIcon1 + // notifyIcon // - this.notifyIcon1.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info; - this.notifyIcon1.BalloonTipText = "Test"; - this.notifyIcon1.ContextMenuStrip = this.contextMenu; - this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon"))); - this.notifyIcon1.Text = "notifyIcon1"; - this.notifyIcon1.Visible = true; - this.notifyIcon1.DoubleClick += new System.EventHandler(this.formShow_Event); + this.notifyIcon.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info; + this.notifyIcon.BalloonTipText = "Test"; + this.notifyIcon.ContextMenuStrip = this.contextMenu; + this.notifyIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon.Icon"))); + this.notifyIcon.Text = "Steam Deck Fan Control"; + this.notifyIcon.Visible = true; + this.notifyIcon.DoubleClick += new System.EventHandler(this.formShow_Event); // // contextMenu // @@ -148,7 +148,9 @@ this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MainMenuStrip = this.menuStrip1; this.Name = "FanControlForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Steam Deck Fan Control"; + this.WindowState = System.Windows.Forms.FormWindowState.Minimized; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FanControlForm_FormClosing); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FanControlForm_FormClosed); this.contextMenu.ResumeLayout(false); @@ -161,8 +163,8 @@ #endregion - private System.Windows.Forms.Timer timer1; - private NotifyIcon notifyIcon1; + private System.Windows.Forms.Timer updateTimer; + private NotifyIcon notifyIcon; private PropertyGrid propertyGrid1; private ContextMenuStrip contextMenu; private MenuStrip menuStrip1; diff --git a/FanControl/FanControlForm.cs b/FanControl/FanControlForm.cs index 769464f..80330e3 100644 --- a/FanControl/FanControlForm.cs +++ b/FanControl/FanControlForm.cs @@ -29,12 +29,9 @@ namespace FanControl } fanModeSelectMenu.SelectedIndex = 0; - } + fanModeSelectNotifyMenu.SelectedIndex = 0; - private void timer1_Tick(object sender, EventArgs e) - { - fanControl.Update(); - propertyGrid1.Refresh(); + notifyIcon.ShowBalloonTip(3000, "Steam Deck Fan Control", "Fan Control Started", ToolTipIcon.Info); } private void fanModeSelect_SelectedValueChanged(object sender, EventArgs e) @@ -71,5 +68,17 @@ namespace FanControl // Always revert to default on closing fanControl.SetMode(FanControl.FanMode.Default); } + + private void updateTimer_Tick(object sender, EventArgs e) + { + fanControl.Update(); + + if (Visible) + { + propertyGrid1.Refresh(); + } + + notifyIcon.Text = String.Format("Fan: {0} RPM Mode: {1}", fanControl.CurrentRPM, fanControl.Mode); + } } } diff --git a/FanControl/FanControlForm.resx b/FanControl/FanControlForm.resx index 0d0c339..d02e7fc 100644 --- a/FanControl/FanControlForm.resx +++ b/FanControl/FanControlForm.resx @@ -57,17 +57,17 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 - + 159, 17 353, 17 - + AAABAAEAAAAAAAEAIAB5CAAAFgAAAIlQTkcNChoKAAAADUlIRFIAAABAAAAAQAgGAAAAqmlx3gAAAAFz UkdCAK7OHOkAAAgzSURBVHhe5VtvbFPXFf+9Z2zlOQ8nIRG0E0RJGhQEW0kBW0QiJVoZAy2ZNiSDsvQD