public SettingsViewModel(BaseViewModel parentViewModel, SettingsModel dataModel, IDialogService dialogService, Func<IOpenFileDialog> openFileDialogFactory, Func<IFolderBrowserDialog> folderDialogFactory) : base(parentViewModel) { Contract.Requires(dialogService != null); Contract.Requires(openFileDialogFactory != null); _dialogService = dialogService; _openFileDialogFactory = openFileDialogFactory; _folderDialogFactory = folderDialogFactory; _dataModel = dataModel; // Will bubble property change events from the Model to the ViewModel. _dataModel.PropertyChanged += (sender, e) => OnPropertyChanged(e.PropertyName); }
public void OpenSettingsExecuted() { var model = new SettingsModel(); model.Load(GlobalSettings.Default.SEBinPath, GlobalSettings.Default.CustomVoxelPath, GlobalSettings.Default.AlwaysCheckForUpdates); var loadVm = new SettingsViewModel(this, model); if (_dialogService.ShowDialog<WindowSettings>(this, loadVm) == true) { var reloadMods = GlobalSettings.Default.SEBinPath != model.SEBinPath; GlobalSettings.Default.SEBinPath = model.SEBinPath; GlobalSettings.Default.CustomVoxelPath = model.CustomVoxelPath; GlobalSettings.Default.AlwaysCheckForUpdates = model.AlwaysCheckForUpdates; GlobalSettings.Default.Save(); if (reloadMods) { IsBusy = true; if (ActiveWorld == null) { SpaceEngineersCore.Resources.LoadDefinitions(); } else { // Reload the Mods. ActiveWorld.LoadDefinitionsAndMods(); } IsBusy = false; } } }
public SettingsViewModel(BaseViewModel parentViewModel, SettingsModel dataModel) : this(parentViewModel, dataModel, ServiceLocator.Resolve<IDialogService>(), ServiceLocator.Resolve<IOpenFileDialog>, ServiceLocator.Resolve<IFolderBrowserDialog>) { }