Ejemplo n.º 1
0
        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
            }
        }
Ejemplo n.º 2
0
 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();
 }