public DatabasesExplorerViewModel( IDatabaseInteractions databaseInteractions, IApplicationInteraction applicationInteraction, IRecentFilesProvider recentFilesProvider) { _databaseInteractions = databaseInteractions; _applicationInteraction = applicationInteraction; PathDefinitions = recentFilesProvider; OpenRecentItemCommand = new RelayCommand <RecentFileInfo>(async info => await OpenRecentItem(info)); ItemDoubleClickCommand = new RelayCommand <CollectionReference>(async reference => await NodeDoubleClick(reference)); SaveDatabaseCopyAsCommand = new RelayCommand(async _ => await SaveDatabaseCopyAs(), o => CanSaveDatabaseCopyAs()); CloseDatabaseCommand = new RelayCommand(async _ => await CloseDatabase(), o => CanCloseDatabase()); AddFileCommand = new RelayCommand(async _ => await AddFile(), _ => CanAddFile()); AddCollectionCommand = new RelayCommand(async _ => await AddCollection(), _ => CanAddCollection()); RefreshDatabaseCommand = new RelayCommand(_ => RefreshDatabase(), _ => CanRefreshDatabase()); RevealInExplorerCommand = new RelayCommand(async _ => await RevealInExplorer(), _ => CanRevealInExplorer()); RenameCollectionCommand = new RelayCommand(async _ => await RenameCollection(), _ => CanRenameCollection()); DropCollectionCommand = new RelayCommand(async _ => await DropCollection(), _ => CanDropCollection()); ExportCollectionCommand = new RelayCommand(async _ => await ExportCollection(), _ => CanExportCollection()); EditDbPropertiesCommand = new RelayCommand(_ => EditDbProperties(), _ => CanEditDbProperties()); ImportDataCommand = new RelayCommand(_ => ImportData(), _ => CanImportData()); Store.Current.Databases.CollectionChanged += (sender, args) => { Commands.ShowNavigationPanel.MainExecute(true); }; }
public DatabasesExplorerViewModel( IDatabaseInteractions databaseInteractions, IApplicationInteraction applicationInteraction, IRecentFilesProvider recentFilesProvider) { _databaseInteractions = databaseInteractions; _applicationInteraction = applicationInteraction; PathDefinitions = recentFilesProvider; CloseDatabaseCommand = new AsyncCommand <DatabaseReference>(CloseDatabase, CanCloseDatabase, this); EditDbPropertiesCommand = new AsyncCommand <DatabaseReference>(EditDbProperties, CanEditDbProperties, this); SaveDatabaseCopyAsCommand = new AsyncCommand <DatabaseReference>(SaveDatabaseCopyAs, CanSaveDatabaseCopyAs, this); AddFileCommand = new AsyncCommand <DatabaseReference>(AddFile, CanAddFile, this); AddCollectionCommand = new AsyncCommand <DatabaseReference>(AddCollection, CanAddCollection, this); RefreshDatabaseCommand = new AsyncCommand <DatabaseReference>(RefreshDatabase, CanRefreshDatabase, this); RevealInExplorerCommand = new AsyncCommand <DatabaseReference>(RevealInExplorer, CanRevealInExplorer, this); RenameCollectionCommand = new AsyncCommand <CollectionReference>(RenameCollection, CanRenameCollection, this); DropCollectionCommand = new AsyncCommand <CollectionReference>(DropCollection, CanDropCollection, this); ExportCollectionCommand = new AsyncCommand <CollectionReference>(ExportCollection, CanExportCollection, this); ImportDataCommand = new RelayCommand(_ => ImportData(), _ => CanImportData()); OpenRecentItemCommand = new AsyncCommand <RecentFileInfo>(OpenRecentItem); NodeDefaulActionCommand = new AsyncCommand <object>(NodeDefaultAction); Store.Current.Databases.CollectionChanged += OnDatabasesCollectionChanged; }
public DefaultCommandsHandler( IDatabaseInteractions databaseInteractions, IViewInteractionResolver viewInteractionResolver, IEventAggregator eventAggregator) { _databaseInteractions = databaseInteractions; _viewInteractionResolver = viewInteractionResolver; _eventAggregator = eventAggregator; Add(Commands.Exit, (sender, args) => { Store.Current.CloseDatabases(); if (Application.Current.MainWindow != null) { Application.Current.MainWindow.Close(); } }); Add(ApplicationCommands.Open, (sender, args) => { _databaseInteractions.OpenDatabase(); }); Add(ApplicationCommands.New, (sender, args) => { _databaseInteractions.CreateAndOpenDatabase(); }); }
public DatabaseCommandsHandler(IDatabaseInteractions databaseInteractions) { _databaseInteractions = databaseInteractions; Add(ApplicationCommands.Open, (sender, args) => { _databaseInteractions.OpenDatabase(); }); Add(ApplicationCommands.New, (sender, args) => { _databaseInteractions.CreateAndOpenDatabase(); }); Add(ApplicationCommands.Close, (sender, args) => { Store.Current.CloseSelectedDatabase(); }, (sender, e) => { e.CanExecute = Store.Current.HasSelectedDatabase; }); Add(ApplicationCommands.Copy, (sender, args) => { _databaseInteractions.CopySelectedDocuments(); }, (sender, e) => { e.CanExecute = Store.Current.SelectedDocumentsCount > 0 && Store.Current.SelectedCollection != null && Store.Current.SelectedCollection.Name != "_files"; }); }
public StartPageViewModel( IDatabaseInteractions databaseInteractions, IApplicationInteraction applicationInteraction, IRecentDatabaseFilesProvider recentDatabaseFilesProvider) { _databaseInteractions = databaseInteractions; _applicationInteraction = applicationInteraction; PathDefinitions = recentDatabaseFilesProvider; ShowStartPageOnOpen = Properties.Settings.Default.ShowStartPageOnOpen; var recentFilesTermFilter = this.WhenValueChanged(vm => vm.SearchTerm) .Throttle(TimeSpan.FromMilliseconds(150)) .Select(CreatePredicate); _cleanUp = PathDefinitions.RecentFiles .ToObservableChangeSet() .Filter(recentFilesTermFilter) .Sort( SortExpressionComparer <RecentDatabaseFileInfo> .Descending(p => p.FixedAt.HasValue) .ThenByDescending(p => p.FixedAt ?? p.LastOpenedAt) ) .ObserveOnDispatcher() .Bind(out _recentFilesFiltered) .Do(p => { NotifyOfPropertyChange(nameof(RecentFilesListIsEmpty)); NotifyOfPropertyChange(nameof(RecentFilesListEmptyMessage)); }) .Subscribe(); }
public QueryResultViewModel(IDatabaseInteractions databaseInteractions) { _databaseInteractions = databaseInteractions; _stopwatch = new Stopwatch(); }
public DatabasePropertiesViewModel(IApplicationInteraction applicationInteraction, IDatabaseInteractions databaseInteractions) { _applicationInteraction = applicationInteraction; _databaseInteractions = databaseInteractions; DisplayName = "Database Properties"; }
public CollectionExplorerViewModel( IEventAggregator eventAggregator, IApplicationInteraction applicationInteraction, IDatabaseInteractions databaseInteractions) { _eventAggregator = eventAggregator; _applicationInteraction = applicationInteraction; _databaseInteractions = databaseInteractions; SplitOrientation = Properties.Settings.Default.CollectionExplorer_SplitOrientation; ShowDocumentPreview = Properties.Settings.Default.CollectionExplorer_ShowPreview; ContentMaxLength = Properties.Settings.Default.CollectionExplorer_ContentMaxLength; DoubleClickAction = Properties.Settings.Default.CollectionExplorer_DoubleClickAction; FindTextModel = new FindTextModel(); ItemDoubleClickCommand = new RelayCommand <DocumentReference>(async doc => await OnItemDoubleClick(doc)); AddDocumentCommand = new AsyncCommand(AddDocument, CanAddDocument, this); EditDocumentCommand = new AsyncCommand <DocumentReference>(EditDocument, CanEditDocument, this); RemoveDocumentCommand = new AsyncCommand(RemoveDocument, CanRemoveDocument, this); ExportDocumentCommand = new AsyncCommand(ExportDocument, CanExportDocument, this); CopyDocumentCommand = new AsyncCommand(CopyDocument, CanCopyDocument, this); PasteDocumentCommand = new AsyncCommand(PasteDocument, CanPasteDocument, this); RefreshCollectionCommand = new RelayCommand(_ => RefreshCollection(), o => CanRefreshCollection()); EditDbPropertiesCommand = new RelayCommand(_ => EditDbProperties(), o => CanEditDbProperties()); FindCommand = new RelayCommand(_ => OpenFind(), o => CanOpenFind()); FindNextCommand = new RelayCommand(_ => Find(), o => CanFind()); FindPreviousCommand = new RelayCommand(_ => FindPrevious(), o => CanFind()); FileDroppedCommand = new AsyncCommand <IDataObject>(OnFileDropped); }
public DatabasesExplorerViewModel(IDatabaseInteractions databaseInteractions) { _databaseInteractions = databaseInteractions; PathDefinitions = databaseInteractions.PathDefinitions; OpenRecentItemCommand = new RelayCommand <string>(OpenRecentItem); }
public ShellMenuViewModel( IDatabaseInteractions databaseInteractions, IWindowManager windowManager) { _databaseInteractions = databaseInteractions; _windowManager = windowManager; PathDefinitions = databaseInteractions.PathDefinitions; }
public DefaultCommandsHandler( IDatabaseInteractions databaseInteractions, IApplicationInteraction applicationInteraction) { _databaseInteractions = databaseInteractions; _applicationInteraction = applicationInteraction; Add(Commands.Exit, (sender, args) => { Store.Current.CloseDatabases(); if (Application.Current.MainWindow != null) { Application.Current.MainWindow.Close(); } }); Add(ApplicationCommands.Open, async(sender, args) => { await _databaseInteractions.OpenDatabase(); }); Add(ApplicationCommands.New, async(sender, args) => { await _databaseInteractions.CreateAndOpenDatabase(); }); Add(Commands.FileDropped, async(sender, args) => { if (!(args.Parameter is IDataObject dataObject)) { return; } try { if (dataObject.GetDataPresent(DataFormats.FileDrop) && dataObject.GetData(DataFormats.FileDrop, false) is string[] paths) { await _databaseInteractions.OpenDatabases(paths); } } catch (Exception exc) { _applicationInteraction.ShowError("Failed to open database: " + exc.Message, "Database Error"); } }); Add(Commands.Import, (sender, args) => { _applicationInteraction.ShowImportWizard(); }, (sender, args) => { var hasDatabaseOpen = Store.Current.Databases.Any(); args.CanExecute = hasDatabaseOpen; }); }
public DatabasesExplorerViewModel(IDatabaseInteractions databaseInteractions) { _databaseInteractions = databaseInteractions; PathDefinitions = databaseInteractions.PathDefinitions; OpenRecentItemCommand = new RelayCommand <string>(OpenRecentItem); ItemDoubleClickCommand = new RelayCommand <CollectionReference>(NodeDoubleClick); }
public CollectionExplorerViewModel( IEventAggregator eventAggregator, IViewInteractionResolver viewInteractionResolver, IDatabaseInteractions databaseInteractions) { _eventAggregator = eventAggregator; _viewInteractionResolver = viewInteractionResolver; _databaseInteractions = databaseInteractions; DocumentPreview = IoC.Get <IDocumentPreview>(); }
public ShellMenuViewModel( IDatabaseInteractions databaseInteractions, IWindowManager windowManager, IApplicationInteraction applicationInteraction) { _databaseInteractions = databaseInteractions; _windowManager = windowManager; _applicationInteraction = applicationInteraction; PathDefinitions = databaseInteractions.PathDefinitions; }
public StartPageViewModel(IDatabaseInteractions databaseInteractions, IViewInteractionResolver viewInteractionResolver) { _databaseInteractions = databaseInteractions; _viewInteractionResolver = viewInteractionResolver; PathDefinitions = databaseInteractions.PathDefinitions; PathDefinitions.RecentFiles.CollectionChanged += (sender, args) => { NotifyOfPropertyChange(nameof(RecentFilesIsEmpty)); }; }
public DatabasesExplorerViewModel( IDatabaseInteractions databaseInteractions, IViewInteractionResolver viewInteractionResolver) { _databaseInteractions = databaseInteractions; _viewInteractionResolver = viewInteractionResolver; PathDefinitions = databaseInteractions.PathDefinitions; OpenRecentItemCommand = new RelayCommand <RecentFileInfo>(OpenRecentItem); ItemDoubleClickCommand = new RelayCommand <CollectionReference>(NodeDoubleClick); }
public StartPageViewModel(IDatabaseInteractions databaseInteractions, IApplicationInteraction applicationInteraction) { _databaseInteractions = databaseInteractions; _applicationInteraction = applicationInteraction; PathDefinitions = databaseInteractions.PathDefinitions; ShowStartPageOnOpen = Properties.Settings.Default.ShowStartPageOnOpen; PathDefinitions.RecentFiles.CollectionChanged += (sender, args) => { NotifyOfPropertyChange(nameof(RecentFilesIsEmpty)); }; }
public ShellMenuViewModel( IDatabaseInteractions databaseInteractions, IWindowManager windowManager, IApplicationInteraction applicationInteraction, IEventAggregator eventAggregator, IRecentFilesProvider recentFilesProvider) { _databaseInteractions = databaseInteractions; _windowManager = windowManager; _applicationInteraction = applicationInteraction; _eventAggregator = eventAggregator; PathDefinitions = recentFilesProvider; }
public CollectionExplorerViewModel( IEventAggregator eventAggregator, IViewInteractionResolver viewInteractionResolver, IDatabaseInteractions databaseInteractions, IDocumentPreview documentPreview) { _eventAggregator = eventAggregator; _viewInteractionResolver = viewInteractionResolver; _databaseInteractions = databaseInteractions; DocumentPreview = documentPreview; SplitOrientation = Properties.Settings.Default.CollectionExplorer_SplitOrientation; ShowDocumentPreview = Properties.Settings.Default.CollectionExplorer_ShowPreview; ContentMaxLength = Properties.Settings.Default.CollectionExplorer_ContentMaxLength; DoubleClickAction = Properties.Settings.Default.CollectionExplorer_DoubleClickAction; ItemDoubleClickCommand = new RelayCommand <DocumentReference>(OnItemDoubleClick); }
public DatabasesExplorerViewModel( IDatabaseInteractions databaseInteractions, IApplicationInteraction applicationInteraction) { _databaseInteractions = databaseInteractions; _applicationInteraction = applicationInteraction; PathDefinitions = databaseInteractions.PathDefinitions; OpenRecentItemCommand = new RelayCommand <RecentFileInfo>(async info => await OpenRecentItem(info)); ItemDoubleClickCommand = new RelayCommand <CollectionReference>(NodeDoubleClick); SaveDatabaseCopyAsCommand = new RelayCommand(async _ => await SaveDatabaseCopyAs(), o => CanSaveDatabaseCopyAs()); CloseDatabaseCommand = new RelayCommand(async _ => await CloseDatabase(), o => CanCloseDatabase()); AddFileCommand = new RelayCommand(async _ => await AddFile(), _ => CanAddFile()); AddCollectionCommand = new RelayCommand(async _ => await AddCollection(), _ => CanAddCollection()); RefreshDatabaseCommand = new RelayCommand(_ => RefreshDatabase(), _ => CanRefreshDatabase()); RevealInExplorerCommand = new RelayCommand(async _ => await RevealInExplorer(), _ => CanRevealInExplorer()); RenameCollectionCommand = new RelayCommand(async _ => await RenameCollection(), _ => CanRenameCollection()); DropCollectionCommand = new RelayCommand(async _ => await DropCollection(), _ => CanDropCollection()); ExportCollectionCommand = new RelayCommand(async _ => await ExportCollection(), _ => CanExportCollection()); EditDbPropertiesCommand = new RelayCommand(_ => EditDbProperties(), _ => CanEditDbProperties()); }
public PipeServiceBootstrapper(IDatabaseInteractions databaseInteractions) { _databaseInteractions = databaseInteractions; }
public ShellMenuViewModel(IDatabaseInteractions databaseInteractions) { _databaseInteractions = databaseInteractions; PathDefinitions = databaseInteractions.PathDefinitions; }
public DefaultCommandsHandler( IDatabaseInteractions databaseInteractions, IViewInteractionResolver viewInteractionResolver, IEventAggregator eventAggregator) { _databaseInteractions = databaseInteractions; _viewInteractionResolver = viewInteractionResolver; _eventAggregator = eventAggregator; Add(Commands.Exit, (sender, args) => { Store.Current.CloseDatabases(); if (Application.Current.MainWindow != null) { Application.Current.MainWindow.Close(); } }); Add(ApplicationCommands.Open, (sender, args) => { _databaseInteractions.OpenDatabase(); }); Add(ApplicationCommands.New, (sender, args) => { _databaseInteractions.CreateAndOpenDatabase(); }); Add(ApplicationCommands.Close, (sender, args) => { GetDatabaseReference(sender, args) .OnSuccess(reference => { _databaseInteractions.CloseDatabase(reference); _eventAggregator.PublishOnUIThread(new InteractionEvents.DatabaseClosed(reference)); }); }, (sender, args) => { args.CanExecute = HasDatabaseReference(sender, args); }); Add(ApplicationCommands.Copy, (sender, args) => { GetManyDocumentsReference(sender, args) .OnSuccess(references => _databaseInteractions.CopyDocuments(references)); }, (sender, e) => { e.CanExecute = HasAnyDocumentsReference(sender, e, DocumentTypeFilter.BsonDocument); }); Add(ApplicationCommands.Paste, (sender, args) => { try { GetCollectionReference(sender, args) .OnSuccess(reference => { var textData = Clipboard.GetText(); return(_databaseInteractions.ImportDataFromText(reference, textData)); }) .OnSuccess(update => _eventAggregator.PublishOnUIThread(update)); } catch (Exception exc) { Logger.Warn(exc, "Cannot process clipboard data."); MessageBox.Show("Failed to paste document from clipboard: " + exc.Message, "Import Error", MessageBoxButton.OK, MessageBoxImage.Error); } }, (sender, e) => { e.CanExecute = NotIsFilesCollection(sender, e) && Clipboard.ContainsText(); }); Add(Commands.EditDbProperties, (sender, args) => { GetDatabaseReference(sender, args) .OnSuccess(reference => _viewInteractionResolver.OpenDatabaseProperties(reference.LiteDatabase)); }, (sender, args) => { args.CanExecute = HasDatabaseReference(sender, args); }); Add(Commands.Add, (sender, args) => { GetCollectionReference(sender, args) .OnSuccess(reference => _databaseInteractions.CreateItem(reference)) .OnSuccess(reference => { _viewInteractionResolver.ActivateCollection(reference.CollectionReference, reference.NewDocuments); _eventAggregator.PublishOnUIThread(reference); }); }, (sender, args) => { args.CanExecute = HasCollectionReference(sender, args); }); Add(Commands.AddFile, (sender, args) => { GetDatabaseReference(sender, args) .OnSuccess(reference => _databaseInteractions.AddFileToDatabase(reference)) .OnSuccess(reference => { _viewInteractionResolver.ActivateCollection(reference.CollectionReference, reference.NewDocuments); _eventAggregator.PublishOnUIThread(reference); }); }, (sender, args) => { args.CanExecute = HasDatabaseReference(sender, args); }); Add(Commands.Edit, (sender, args) => { GetDocumentReference(sender, args) .OnSuccess(reference => _databaseInteractions.OpenEditDocument(reference)) .OnSuccess(maybe => { maybe.Execute(value => _eventAggregator.PublishOnUIThread(new InteractionEvents.DocumentUpdated(value))); }); }, (sender, args) => { args.CanExecute = HasDocumentReference(sender, args); }); Add(Commands.AddCollection, (sender, args) => { GetDatabaseReference(sender, args) .OnSuccess(reference => { var addCollection = _databaseInteractions.AddCollection(reference); if (addCollection.IsSuccess) { _viewInteractionResolver.ActivateCollection(addCollection.Value); } }); }, (sender, args) => { args.CanExecute = HasDatabaseReference(sender, args); }); Add(Commands.Remove, (sender, args) => { GetManyDocumentsReference(sender, args) .OnSuccess(references => _databaseInteractions.RemoveDocuments(references)); }, (sender, args) => { args.CanExecute = HasAnyDocumentsReference(sender, args); }); Add(Commands.Export, (sender, args) => { GetManyDocumentsReference(sender, args) .OnSuccess(references => _databaseInteractions.ExportDocuments(references.ToList())); }, (sender, args) => { args.CanExecute = HasAnyDocumentsReference(sender, args); }); Add(Commands.RefreshCollection, (sender, args) => { GetCollectionReference(sender, args) .OnSuccess(reference => reference.Refresh()); }, (sender, e) => { e.CanExecute = HasCollectionReference(sender, e); }); Add(Commands.RenameCollection, (sender, args) => { GetCollectionReference(sender, args) .OnSuccess(reference => _databaseInteractions.RenameCollection(reference)); }, (sender, args) => { args.CanExecute = NotIsFilesCollection(sender, args); }); Add(Commands.DropCollection, (sender, args) => { GetCollectionReference(sender, args) .OnSuccess(reference => { var dropCollection = _databaseInteractions.DropCollection(reference); if (dropCollection.IsSuccess) { _eventAggregator.PublishOnUIThread(new InteractionEvents.CollectionRemoved(reference)); } }); }, (sender, args) => { args.CanExecute = HasCollectionReference(sender, args); }); Add(Commands.ExportCollection, (sender, args) => { GetCollectionReference(sender, args) .OnSuccess(reference => _databaseInteractions.ExportCollection(reference)); }, (sender, args) => { args.CanExecute = HasCollectionReference(sender, args); }); Add(Commands.RefreshDatabase, (sender, args) => { GetDatabaseReference(sender, args) .OnSuccess(reference => reference.Refresh()); }, (sender, args) => { args.CanExecute = HasDatabaseReference(sender, args); }); Add(Commands.RevealInExplorer, (sender, args) => { GetDatabaseReference(sender, args) .OnSuccess(reference => _databaseInteractions.RevealInExplorer(reference)); }, (sender, args) => { args.CanExecute = HasDatabaseReference(sender, args); }); }
public QueryResultViewModel(IDatabaseInteractions databaseInteractions) { _databaseInteractions = databaseInteractions; }
public DefaultCommandsHandler( IDatabaseInteractions databaseInteractions) { _databaseInteractions = databaseInteractions; Add(ApplicationCommands.Open, (sender, args) => { _databaseInteractions.OpenDatabase(); }); Add(ApplicationCommands.New, (sender, args) => { _databaseInteractions.CreateAndOpenDatabase(); }); Add(ApplicationCommands.Close, (sender, args) => { Store.Current.CloseSelectedDatabase(); }, (sender, e) => { e.CanExecute = Store.Current.HasSelectedDatabase; }); Add(ApplicationCommands.Copy, (sender, args) => { _databaseInteractions.CopyDocuments(Store.Current.SelectedDocuments); }, (sender, e) => { e.CanExecute = Store.Current.SelectedDocumentsCount > 0 && Store.Current.SelectedCollection != null && Store.Current.SelectedCollection.Name != "_files"; }); Add(ApplicationCommands.Paste, (sender, args) => { try { var textData = Clipboard.GetText(); _databaseInteractions.ImportDataFromText(Store.Current.SelectedCollection, textData); } catch (Exception exc) { Logger.Warn(exc, "Cannot process clipboard data."); MessageBox.Show("Failed to paste document from clipboard: " + exc.Message, "Import Error", MessageBoxButton.OK, MessageBoxImage.Error); } }, (sender, e) => { e.CanExecute = Store.Current.SelectedCollection != null && Store.Current.SelectedCollection.Name != "_files" && Clipboard.ContainsText(); }); Add(Commands.EditDbProperties, (sender, args) => { _databaseInteractions.OpenDatabaseProperties(Store.Current.SelectedDatabase.LiteDatabase); }, (sender, e) => { e.CanExecute = Store.Current.HasSelectedDatabase; }); Add(Commands.Exit, (sender, args) => { Store.Current.CloseDatabases(); if (Application.Current.MainWindow != null) { Application.Current.MainWindow.Close(); } }); Add(Commands.Add, (sender, args) => { var result = _databaseInteractions.CreateItem(Store.Current.SelectedCollection); if (result.IsSuccess) { var reference = result.Value; if (reference.Type == DocumentType.File) { Store.Current.SelectCollection(Store.Current.SelectedCollection.Database.Collections.First(a => a.Name == "_files")); Store.Current.SelectDocument(reference.DocumentReference); } else { Store.Current.SelectDocument(reference.DocumentReference); // UpdateGridColumns(reference.DocumentReference.LiteDocument); } // CollectionListView.ScrollIntoSelectedItem(); // UpdateDocumentPreview(); } }, (sender, e) => { e.CanExecute = Store.Current.HasSelectedDatabase; }); Add(Commands.AddFile, (sender, args) => { var database = Store.Current.SelectedDatabase; var result = _databaseInteractions.AddFileToDatabase(database); if (result.IsSuccess) { Store.Current.SelectCollection(database.Collections.First(a => a.Name == "_files")); Store.Current.SelectDocument(result.Value.DocumentReference); // CollectionListView.ScrollIntoSelectedItem(); } }, (sender, e) => { e.CanExecute = Store.Current.HasSelectedDatabase; }); Add(Commands.Edit, (sender, args) => { var item = Store.Current.SelectedDocument; var document = _databaseInteractions.OpenEditDocument(item); if (document.HasValue) { // UpdateGridColumns(document.Value.LiteDocument); // UpdateDocumentPreview(); } }, (sender, e) => { e.CanExecute = Store.Current.SelectedDocumentsCount == 1; }); Add(Commands.Remove, (sender, args) => { var currentSelectedDocuments = Store.Current.SelectedDocuments.ToList(); _databaseInteractions.RemoveDocuments(currentSelectedDocuments); }, (sender, e) => { e.CanExecute = Store.Current.SelectedDocumentsCount > 0; }); Add(Commands.Export, (sender, args) => { _databaseInteractions.ExportDocuments(Store.Current.SelectedDocuments); }, (sender, e) => { e.CanExecute = Store.Current.SelectedDocumentsCount > 0; }); Add(Commands.RefreshCollection, (sender, args) => { Store.Current.SelectedCollection?.Refresh(); }, (sender, e) => { e.CanExecute = Store.Current.HasSelectedCollection; }); Add(Commands.AddCollection, (sender, args) => { _databaseInteractions.AddCollection(Store.Current.SelectedDatabase); }, (sender, e) => { e.CanExecute = Store.Current.HasSelectedDatabase; }); Add(Commands.RenameCollection, (sender, args) => { _databaseInteractions.RenameCollection(Store.Current.SelectedCollection); }, (sender, e) => { e.CanExecute = Store.Current.SelectedCollection != null && Store.Current.SelectedCollection.Name != "_files" && Store.Current.SelectedCollection.Name != "_chunks"; }); Add(Commands.DropCollection, (sender, args) => { var result = _databaseInteractions.DropCollection(Store.Current.SelectedCollection); if (result.IsSuccess && result.Value) { Store.Current.ResetSelectedCollection(); } }, (sender, e) => { e.CanExecute = Store.Current.SelectedCollection != null && Store.Current.SelectedCollection.Name != "_files" && Store.Current.SelectedCollection.Name != "_chunks"; }); Add(Commands.ExportCollection, (sender, args) => { _databaseInteractions.ExportCollection(Store.Current.SelectedCollection); }, (sender, e) => { e.CanExecute = Store.Current.SelectedCollection != null && Store.Current.SelectedCollection.Name != "_files" && Store.Current.SelectedCollection.Name != "_chunks"; }); Add(Commands.RefreshDatabase, (sender, args) => { Store.Current.ResetSelectedCollection(); Store.Current.SelectedDatabase.Refresh(); }, (sender, e) => { e.CanExecute = Store.Current.HasSelectedDatabase; }); }
public StartPageViewModel(IDatabaseInteractions databaseInteractions) { _databaseInteractions = databaseInteractions; PathDefinitions = databaseInteractions.PathDefinitions; }