示例#1
0
 public void Close()
 {
     if (DBController != null) {
         DBController.Close();
         DBController = null;
     }
 }
示例#2
0
        private void OpenDatabase(string journalFile)
        {
            try {
                var db = new DBController(journalFile, _factories);

                var tab = new TabItem();
                tab.Header = System.IO.Path.GetDirectoryName(journalFile).Split('\\').Last();

                var ctxMenu = new ContextMenu();
                var menuItem = new MenuItem();
                menuItem.Header = "Close " + tab.Header;
                menuItem.Click += new RoutedEventHandler((object sender, RoutedEventArgs e) => {
                    ((DataViewControl)tab.Content).Close();
                    tabControl.Items.Remove(tab);
                });
                ctxMenu.Items.Add(menuItem);
                tab.ContextMenu = ctxMenu;

                var control = new DataViewControl { DBController = db };
                tab.Content = control;
                tabControl.Items.Add(tab);
                tab.Focus();
            } catch (Exception ex) {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
        }