protected override void OnWindowLoaded(object sender, RoutedEventArgs e) { SettingsParser parser = new SettingsParser(); //if it's not launched from the main window, then the ModpackSettings object has not been parsed yet. do that now. if (!LaunchedFromMainWindow) { //TODO: use hook for functions that normally happen in the MainWindow? } //also load the feature window's custom settings file parser.LoadSettings(Settings); //load base classes method base.OnWindowLoaded(sender, e); //if not skipping update, and not launched from the main window, then run a stand-alone update check if (!LaunchedFromMainWindow && !CommandLineSettings.SkipUpdate && RunStandAloneUpdateCheck) { Task.Run(async() => { if (!await CommonUtils.IsManagerUptoDate(CommonUtils.GetApplicationVersion(), ModpackSettings.ApplicationDistroVersion)) { MessageBox.Show("Your application is out of date. Please launch the application normally to update"); } }); } }
public void Test01_LoadModpackSettingsTest() { Assert.IsTrue(File.Exists(ModpackSettings.SettingsFilename)); SettingsParser.LoadSettings(ModpackSettings); GlobalDependencies = new List <DatabasePackage>(); }
private void FinishApplicationInit() { Logging.WriteHeader(Logfiles.Application); Logging.Info(string.Format("| Relhax Modpack version {0}", CommonUtils.GetApplicationVersion())); Logging.Info(string.Format("| Build version {0}, from date {1}", ApplicationConstants.ApplicationVersion.ToString(), CommonUtils.GetCompileTime())); Logging.Info(string.Format("| Running on OS {0}", Environment.OSVersion.ToString())); //parse command line arguments given to the application Logging.Info("Parsing command line switches"); CommandLineSettings.ParseCommandLineSwitches(); //load the ModpackSettings from xml file SettingsParser settingsParser = new SettingsParser(); settingsParser.LoadSettings(modpackSettings); //set verbose logging option bool verboseSettingForLogfile = modpackSettings.VerboseLogging; if (ApplicationConstants.ApplicationVersion != ApplicationVersions.Stable) { verboseSettingForLogfile = true; } Logging.GetLogfile(Logfiles.Application).VerboseLogging = verboseSettingForLogfile; //run a check for a valid .net framework version, only if we're opening MainWindow, and the version //of the .net framework installed has not yet been detected to be 4.8 if ((!CommandLineSettings.ArgsOpenCustomWindow()) && (!modpackSettings.ValidFrameworkVersion)) { //https://github.com/Willster419/RelhaxModpack/issues/90 //try getting .net framework information //https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed //https://docs.microsoft.com/en-us/dotnet/api/system.environment.version?view=netcore-3.1 //https://stackoverflow.com/questions/19096841/how-to-get-the-version-of-the-net-framework-being-targeted Logging.Debug(".NET Framework version information"); int frameworkVersion = -1; try { RegistryKey key = RegistryUtils.GetRegistryKeys(new RegistrySearch() { Root = Registry.LocalMachine, Searchpath = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" }); Logging.Debug("Registry: {0}", key.Name); foreach (string subkey in key.GetValueNames()) { object value = key.GetValue(subkey); Logging.Debug("Registry: Subkey={0}, Value={1}", subkey, value.ToString()); if (subkey.ToLower().Equals("release")) { if (int.TryParse(value.ToString(), out int result)) { frameworkVersion = result; } else { Logging.Error("Unable to parse release value: {0}", value); } } } } catch (Exception ex) { Logging.Exception(ex.ToString()); } Logging.Info("Minimum required .NET Framework version: {0}, Installed: {1}", ApplicationConstants.MinimumDotNetFrameworkVersionRequired, frameworkVersion); if (frameworkVersion == -1) { Logging.Error("Failed to get .NET Framework version from the registry"); MessageBox.Show("failedToGetDotNetFrameworkVersion"); } else if (frameworkVersion < ApplicationConstants.MinimumDotNetFrameworkVersionRequired) { Logging.Error("Invalid .NET Framework version (less then 4.8)"); if (MessageBox.Show("invalidDotNetFrameworkVersion", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { CommonUtils.StartProcess(ApplicationConstants.DotNetFrameworkLatestDownloadURL); } } else { Logging.Info("Valid .NET Framework version"); modpackSettings.ValidFrameworkVersion = true; } } }