Esempio n. 1
0
 private void OnNewDatabaseRequested(ObservableTreeItem item)
 {
     try
     {
         if (item != null && SelectedItem.Type == ItemTypeModel.Folder)
         {
             AddDatabaseDialog dialog = new AddDatabaseDialog();
             if (dialog.ShowDialog() ?? false)
             {
                 string databasePath = dialog.DatabaseName.EndsWith(".db") ? Path.Combine(SelectedItem.Path, dialog.DatabaseName) : Path.Combine(SelectedItem.Path, String.Concat(dialog.DatabaseName, ".db"));
                 _sqliteService.BuildDatabase(databasePath);
                 item.Items.Add(new ObservableTreeItem
                 {
                     Name = dialog.DatabaseName,
                     Path = databasePath,
                     Type = ItemTypeModel.Database
                 });
                 ItemsCollectionChanged(this, new ItemsCollectionChangedEventArgs(Items.SelectMany(i => i.Items)));
             }
         }
         else
         {
             WpfMessageBox.ShowDialog("Invalid Item Selected", "Please select a folder to add a database to.", MessageBoxButton.OK, MessageIcon.Error);
         }
     }
     catch (Exception ex)
     {
         WpfMessageBox.ShowDialog("Error Building Database", ex.Message, MessageBoxButton.OK, MessageIcon.Error);
     }
 }
Esempio n. 2
0
 private void OnNewQueryRequested(ObservableTreeItem item)
 {
     if (item.Type == ItemTypeModel.Database || item.Type == ItemTypeModel.Table)
     {
         DocumentRequested(this, new DocumentRequestedEventArgs(item.Path));
     }
 }
Esempio n. 3
0
 private void OnTreeItemExpanded(ObservableTreeItem item)
 {
     foreach (ObservableTreeItem subItem in item.Items)
     {
         if (subItem.Type != ItemTypeModel.DataType)
         {
             subItem.Items = new ObservableCollection <ObservableTreeItem>(_sqliteService.GetItems(subItem.Translate()).Select(i => i.Translate()));
         }
     }
 }
Esempio n. 4
0
 private void OnNewTableRequested(ObservableTreeItem item)
 {
     if (item != null && SelectedItem.Type == ItemTypeModel.Database)
     {
         CreateTableDialog dialog = new CreateTableDialog(SelectedItem.Path, _sqliteService);
         if (dialog.ShowDialog() ?? false)
         {
             ObservableTreeItem newItem = new ObservableTreeItem
             {
                 Name = dialog.TableName,
                 Path = dialog.DatabasePath,
                 Type = ItemTypeModel.Table
             };
             newItem.Items = new ObservableCollection <ObservableTreeItem>(_sqliteService.GetItems(newItem.Translate()).Select(i => i.Translate()));
             item.Items.Add(newItem);
         }
     }
     else
     {
         WpfMessageBox.ShowDialog("Invalid Operation", "Please select a database for this operation.", MessageBoxButton.OK, MessageIcon.Error);
     }
 }