private void OpenDatabase() { try { DateTime startTime = DateTime.Now; // count the time used to open DatabaseHandler handler = new DatabaseHandler(_recentItem.File.FullName, Password); RecentFiles.AddNewFile(_recentItem.File.FullName); handler.Open(); Registry.View.MainWindow mw = new Registry.View.MainWindow(); MainWindowViewModel viewModel = new MainWindowViewModel(handler.Database, mw.Dispatcher, startTime); mw.DataContext = viewModel; mw.Show(); OnRequestClose(); } catch (ArgumentException ex) { #if DEBUG MessageBox.Show(ex.ToString(), Properties.Resources.DatabaseCannotBeOpenedInvalidPassword); #else MessageBox.Show(Properties.Resources.DatabaseCannotBeOpenedInvalidPassword, Properties.Resources.DatabaseCannotBeOpenedInvalidPassword); #endif } }
private static void OpenCreatedDatabase(DatabaseHandler handler) { Registry.View.MainWindow mw = new Registry.View.MainWindow(); MainWindowViewModel viewModel = new MainWindowViewModel(handler.Database, mw.Dispatcher, DateTime.Now); mw.DataContext = viewModel; mw.Show(); }