diff --git a/CHANGELIST.md b/CHANGELIST.md
index 7c61c769..7c22fd7e 100644
--- a/CHANGELIST.md
+++ b/CHANGELIST.md
@@ -6,6 +6,7 @@
- Update to Aaru v5.3.0-rc1
- Update to BurnOutSharp 1.8.0
- Update support packages
+- Add on-startup "check for updates" option
### 2.1 (2021-07-22)
- Enum, no more
diff --git a/MPF.Library/Data/Options.cs b/MPF.Library/Data/Options.cs
index 7358f67f..ec3faded 100644
--- a/MPF.Library/Data/Options.cs
+++ b/MPF.Library/Data/Options.cs
@@ -2,7 +2,6 @@
using System.Collections;
using System.Collections.Generic;
using MPF.Converters;
-using MPF.Utilities;
using RedumpLib.Data;
namespace MPF.Data
@@ -70,6 +69,15 @@ namespace MPF.Data
set { _settings["EnableDarkMode"] = value.ToString(); }
}
+ ///
+ /// Check for updates on startup
+ ///
+ public bool CheckForUpdatesOnStartup
+ {
+ get { return GetBooleanSetting(_settings, "CheckForUpdatesOnStartup", true); }
+ set { _settings["CheckForUpdatesOnStartup"] = value.ToString(); }
+ }
+
///
/// Default output path for dumps
///
diff --git a/MPF/ViewModels/MainViewModel.cs b/MPF/ViewModels/MainViewModel.cs
index 46ec9881..e64df4e5 100644
--- a/MPF/ViewModels/MainViewModel.cs
+++ b/MPF/ViewModels/MainViewModel.cs
@@ -83,6 +83,10 @@ namespace MPF.GUI.ViewModels
// Finish initializing the rest of the values
InitializeUIValues(removeEventHandlers: false, rescanDrives: true);
+
+ // Check for updates, if necessary
+ if (App.Options.CheckForUpdatesOnStartup)
+ CheckForUpdates();
}
#region Population
@@ -353,15 +357,15 @@ namespace MPF.GUI.ViewModels
if (rescanDrives)
{
App.Instance.StatusLabel.Content = "Creating drive list, please wait!";
- await App.Instance.Dispatcher.InvokeAsync(() => PopulateDrives());
+ await App.Instance.Dispatcher.InvokeAsync(PopulateDrives);
}
else
{
- await App.Instance.Dispatcher.InvokeAsync(() => DetermineSystemType());
+ await App.Instance.Dispatcher.InvokeAsync(DetermineSystemType);
}
// Determine current media type, if possible
- await App.Instance.Dispatcher.InvokeAsync(() => PopulateMediaType());
+ await App.Instance.Dispatcher.InvokeAsync(PopulateMediaType);
CacheCurrentDiscType();
SetCurrentDiscType();
diff --git a/MPF/ViewModels/OptionsViewModel.cs b/MPF/ViewModels/OptionsViewModel.cs
index 878a0076..b0fa2956 100644
--- a/MPF/ViewModels/OptionsViewModel.cs
+++ b/MPF/ViewModels/OptionsViewModel.cs
@@ -199,25 +199,20 @@ namespace MPF.GUI.ViewModels
///
/// Create an open folder dialog box
///
- private FolderBrowserDialog CreateFolderBrowserDialog()
- {
- FolderBrowserDialog dialog = new FolderBrowserDialog();
- return dialog;
- }
+ private static FolderBrowserDialog CreateFolderBrowserDialog() => new FolderBrowserDialog();
///
/// Create an open file dialog box
///
- private OpenFileDialog CreateOpenFileDialog()
+ private static OpenFileDialog CreateOpenFileDialog()
{
- OpenFileDialog dialog = new OpenFileDialog();
-
- dialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;
- dialog.Filter = "Executables (*.exe)|*.exe";
- dialog.FilterIndex = 0;
- dialog.RestoreDirectory = true;
-
- return dialog;
+ return new OpenFileDialog()
+ {
+ InitialDirectory = AppDomain.CurrentDomain.BaseDirectory,
+ Filter = "Executables (*.exe)|*.exe",
+ FilterIndex = 0,
+ RestoreDirectory = true,
+ };
}
///
@@ -225,10 +220,7 @@ namespace MPF.GUI.ViewModels
///
/// Setting name to find
/// TextBox for that setting
- private TextBox TextBoxForPathSetting(string name)
- {
- return Parent.FindName(name + "TextBox") as TextBox;
- }
+ private TextBox TextBoxForPathSetting(string name) => Parent.FindName(name + "TextBox") as TextBox;
#endregion
diff --git a/MPF/Windows/OptionsWindow.xaml b/MPF/Windows/OptionsWindow.xaml
index ccd1e881..cddc0fc2 100644
--- a/MPF/Windows/OptionsWindow.xaml
+++ b/MPF/Windows/OptionsWindow.xaml
@@ -71,6 +71,11 @@
IsChecked="{Binding Options.EnableDarkMode}"
ToolTip="(Experimental) Enable dark mode across the entire application" Margin="0,4"
/>
+
+