public MainWindow(string pathToConfigFile) { Instance = this; FMConfiguration config = null; if (!string.IsNullOrEmpty(pathToConfigFile)) { config = FMConfiguration.Load(pathToConfigFile); } else { config = FMConfiguration.Load(); } LoadPreferences(config.Preferences); InitializeComponent(); var dialogService = new DialogService(this); Root = new RootViewModel(dialogService, config); Task.Run(() => Root.InitializeAsync()); DataContext = Root; Closing += (s, e) => Root.SaveConfiguration(); }
public RootViewModel(IDialogService dialogService, FMConfiguration configuration) { DialogService = dialogService; ActiveEntity = new Binding <BaseViewModel>(new DefaultViewModel()); Output = new Binding <string>(); AddCategoryCommand = new RelayCommand(param => AddCategory()); AddProjectCommand = new RelayCommand(param => AddProject()); EditPreferencesCommand = new RelayCommand(param => EditPreferences()); FullUpdateCommand = new RelayCommand(async param => await FullUpdateAsync()); SaveConfigurationCommand = new RelayCommand(param => SaveConfiguration()); SelectActiveEntityCommand = new RelayCommand(param => SelectActiveEntity(param)); UpdateApplicationCommand = new RelayCommand(param => UpdateApplication()); Configuration = configuration; OutputVM = new OutputViewModel(); OutputVM.Write("Loaded local FluentMigrator assembly version " + Lib.Utility.References.GetFluentMigratorAssemblyVersion()); UpdateVM = new UpdateViewModel(this); Task.Run(async() => await UpdateVM.CheckForUpdates()); Configuration.Categories.ForEach(c => Add(new CategoryViewModel(OutputVM, this, c))); Configuration.Projects.ForEach(p => Add(new ProjectViewModel(OutputVM, this, p))); }