From 092f96a9ab9f3be122f5e61e64f0d1e7d5fd040d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Wed, 16 Nov 2022 12:32:09 +0100 Subject: [PATCH] Improve handling of SharedData --- FanControl/FanControlForm.cs | 1 + PerformanceOverlay/Controller.cs | 3 ++- PowerControl/Menu.cs | 6 ++---- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/FanControl/FanControlForm.cs b/FanControl/FanControlForm.cs index cfd789c..147d2cb 100644 --- a/FanControl/FanControlForm.cs +++ b/FanControl/FanControlForm.cs @@ -29,6 +29,7 @@ namespace FanControl public FanControlForm() { InitializeComponent(); + SharedData_Update(); Text += " v" + Application.ProductVersion.ToString(); Instance.Open(Text, "Global\\FanControlOnce"); diff --git a/PerformanceOverlay/Controller.cs b/PerformanceOverlay/Controller.cs index 728920c..7779200 100644 --- a/PerformanceOverlay/Controller.cs +++ b/PerformanceOverlay/Controller.cs @@ -37,7 +37,8 @@ namespace PerformanceOverlay public Controller() { contextMenu = new System.Windows.Forms.ContextMenuStrip(components); - + + SharedData_Update(); Instance.Open(TitleWithVersion, "Global\\PerformanceOverlay"); showItem = new ToolStripMenuItem("&Show OSD"); diff --git a/PowerControl/Menu.cs b/PowerControl/Menu.cs index 1992f8f..bc54787 100644 --- a/PowerControl/Menu.cs +++ b/PowerControl/Menu.cs @@ -126,8 +126,6 @@ namespace PowerControl if (ActiveOption == null) ActiveOption = Options.First(); - if (SelectedOption == null) - SelectedOption = ActiveOption; onUpdateToolStrip(); } @@ -171,7 +169,7 @@ namespace PowerControl return; foreach (ToolStripMenuItem item in toolStripItem.DropDownItems) - item.Checked = (item.Tag.ToString() == SelectedOption.ToString()); + item.Checked = Object.Equals(item.Tag, SelectedOption ?? ActiveOption); toolStripItem.Visible = Visible && Options.Count > 0; } @@ -254,7 +252,7 @@ namespace PowerControl else output += Color(Name + ":", Colors.Blue).PadRight(30); - output += optionText(SelectedOption); + output += optionText(SelectedOption ?? ActiveOption); if (!Object.Equals(ActiveOption, SelectedOption)) output += " (active: " + optionText(ActiveOption) + ")";