Skip to content

Commit 991b535

Browse files
committed
add autoUpdate (enabled by default)
1 parent 13d480e commit 991b535

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

OpenHardwareMonitor/UI/MainForm.Designer.cs

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OpenHardwareMonitor/UI/MainForm.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ public sealed partial class MainForm : Form
4646
private readonly UnitManager _unitManager;
4747
private readonly UpdateVisitor _updateVisitor = new();
4848
private readonly WmiProvider _wmiProvider;
49-
#if DEBUG
5049
private readonly Timer _checkUpdatesTimer;
51-
#endif
5250

5351
private int _delayCount;
5452
private bool _selectionDragging;
@@ -68,12 +66,12 @@ public MainForm()
6866
this.MinimumSize = new Size(400, 200);
6967
Text = $"Open Hardware Monitor {(Environment.Is64BitProcess ? "x64" : "x32")} - {Updater.CurrentVersion}";
7068
Icon = Icon.ExtractAssociatedIcon(Updater.CurrentFileLocation);
71-
#if DEBUG
7269
//start check updates timer (silent for errors)
70+
var autoUpdate = _settings.GetValue("autoUpdate", true);
7371
_checkUpdatesTimer = new Timer { Interval = 60 * 60 * 1000 };
7472
_checkUpdatesTimer.Tick += (_, _) => Updater.CheckForUpdates(true);
75-
_checkUpdatesTimer.Start();
76-
#endif
73+
_checkUpdatesTimer.Enabled = autoUpdate;
74+
menuItemAutoUpdates.Checked = autoUpdate;
7775
portableModeMenuItem.Checked = _settings.IsPortable;
7876

7977
_unitManager = new UnitManager(_settings);
@@ -712,6 +710,14 @@ private void menuItemCheckUpdates_Click(object sender, EventArgs e)
712710
Updater.CheckForUpdates(false);
713711
}
714712

713+
private void menuItemAutoUpdate_Click(object sender, EventArgs e)
714+
{
715+
var autoUpdate = !menuItemAutoUpdates.Checked;
716+
this.menuItemAutoUpdates.Checked = autoUpdate;
717+
_checkUpdatesTimer.Enabled = autoUpdate;
718+
_settings.SetValue("autoUpdate", autoUpdate);
719+
}
720+
715721
private void AboutMenuItem_Click(object sender, EventArgs e)
716722
{
717723
_ = new AboutBox().ShowDialog();

0 commit comments

Comments
 (0)