/// <summary> /// Loads the launcher config. /// </summary> /// <returns></returns> private LauncherConfig LoadConfig() { ILauncherConfig launcherConfig = null; try { if (File.Exists(this.configPath)) { launcherConfig = LauncherConfig.LoadConfig(this.configPath); } } catch (Exception ex) { Debug.Write(ex); // ToDo add logging here. } finally { if (launcherConfig == null) { launcherConfig = new LauncherConfig(); } } return(launcherConfig as LauncherConfig); }
/// <summary> /// Initializes a new instance of the <see cref="MainWindowViewModel" /> class. /// </summary> /// <param name="config">The current launcher config,</param> /// <param name="registry">The registry config object.</param> /// <param name="updater">The instance of the <see cref="Updater" /> class that is used to check for and execute updates.</param> /// <param name="resourceManager"> /// The instance of the resource manager that should be used to provide resource strings for /// the view. /// </param> public MainWindowViewModel( ILauncherConfig config, RegistryConfig registry, Updater updater, ResourceManager resourceManager) : base(resourceManager) { if (config == null) { throw new ArgumentNullException(nameof(config)); } if (registry == null) { throw new ArgumentNullException(nameof(registry)); } if (updater == null) { throw new ArgumentNullException(nameof(updater)); } this.config = config; this.registry = registry; this.UpdateVersionText(); this.SelectedTabIndex = config.SelectedTabIndex > 0 ? config.SelectedTabIndex : 0; updater.AvailableUpdateDetected += (obj, args) => updater.Update(); updater.ErrorOccured += this.UpdaterErrorOccured; updater.DownloadStarted += (obj, args) => this.UpdateRunning = true; updater.UpdateCompleted += (obj, args) => { this.UpdateRunning = false; this.UpdateVersionText(); updater.Check(); }; updater.DownloadProgress += this.UpdaterDownloadProgress; updater.Check(); this.updater = updater; }
public CommonSettings(ILauncherConfig config) { this.config = config; }