private void AddFeedFlyoutOpened(object sender, object e) { ViewModel.LoadErrorMessage = null; feedBox.Select(feedBox.Text.Length, 0); feedBox.Focus(FocusState.Programmatic); pasteCommand.RaiseCanExecuteChanged(); // Manual update necessary because of the CanPasteUri workaround. }
private void AddEditFeedViewModelPropertyChanged(object sender, PropertyChangedEventArgs e) { if (new[] { nameof(AddEditFeedViewModel.LoadErrorMessage), nameof(AddEditFeedViewModel.Feed) }.Contains(e.PropertyName)) { addUpdateFeedCommand.RaiseCanExecuteChanged(); } }
private void Stop() { if (resumeCommand.CanExecute(null)) { resumeCommand.Execute(null); } crawlerCancellationTokenSource.Cancel(); crawlerService.IsCrawl = false; crawlCommand.RaiseCanExecuteChanged(); pauseCommand.RaiseCanExecuteChanged(); resumeCommand.RaiseCanExecuteChanged(); stopCommand.RaiseCanExecuteChanged(); }
private void CrawlerServicePropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(crawlerService.NewBlogUrl)) { addBlogCommand.RaiseCanExecuteChanged(); } }
private void FeedItemViewModelPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(FeedItemViewModel.FeedItem)) { launchBrowserCommand.RaiseCanExecuteChanged(); } }
public MainViewModel(IDependencyService serviceLocator) { this.serviceLocator = serviceLocator; SearchCriteria = new ObservableCollection <SearchCriteriaViewModel>() { new SearchCriteriaViewModel { Field = "Year", Operator = ComparisonOperation.GreaterEqual, Value = "2000" } }; Search = new AsyncDelegateCommand(OnSearch, () => SearchCriteria.Count > 0); EditSearchCriteria = new AsyncDelegateCommand <SearchCriteriaViewModel>(OnEditSearchCriteria); CancelSearch = new DelegateCommand(OnCancelSearch, () => cancellationTokenSource != null); AddSearchCriteria = new AsyncDelegateCommand(OnAddSearchCriteria); MessagingCenter.Subscribe <SearchCriteriaViewModel>(this, "Delete", async scvm => { SearchCriteria.Remove(scvm); if (SearchCriteria.Count == 0) { Search.RaiseCanExecuteChanged(); } await serviceLocator.Get <INavigationService>().GoBackAsync(); }); }
private void CompareAssembliesDataModelPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(CompareAssembliesDataModel.HasErrors)) { compareCommand.RaiseCanExecuteChanged(); } }
public async Task InitializeAsync() { _crawlerService.ImportBlogsCommand = _importBlogsCommand; _crawlerService.AddBlogCommand = _addBlogCommand; _crawlerService.RemoveBlogCommand = _removeBlogCommand; _crawlerService.ShowFilesCommand = _showFilesCommand; _crawlerService.EnqueueSelectedCommand = _enqueueSelectedCommand; _crawlerService.LoadLibraryCommand = _loadLibraryCommand; _crawlerService.LoadAllDatabasesCommand = _loadAllDatabasesCommand; _crawlerService.LoadArchiveCommand = _loadArchiveCommand; _crawlerService.CheckIfDatabasesCompleteCommand = _checkIfDatabasesCompleteCommand; _crawlerService.AutoDownloadCommand = _autoDownloadCommand; _crawlerService.ListenClipboardCommand = _listenClipboardCommand; _crawlerService.PropertyChanged += CrawlerServicePropertyChanged; ManagerViewModel.ShowFilesCommand = _showFilesCommand; ManagerViewModel.VisitBlogCommand = _visitBlogCommand; ManagerViewModel.VisitBlogOnTumbexCommand = _visitBlogOnTumbexCommand; ManagerViewModel.ShowDetailsCommand = _showDetailsCommand; ManagerViewModel.CopyUrlCommand = _copyUrlCommand; ManagerViewModel.CheckStatusCommand = _checkStatusCommand; ManagerViewModel.PropertyChanged += ManagerViewModelPropertyChanged; ManagerViewModel.QueueItems = QueueManager.Items; QueueManager.Items.CollectionChanged += QueueItemsCollectionChanged; ManagerViewModel.QueueItems.CollectionChanged += ManagerViewModel.QueueItemsCollectionChanged; BlogManagerFinishedLoadingLibrary += OnBlogManagerFinishedLoadingLibrary; BlogManagerFinishedLoadingDatabases += OnBlogManagerFinishedLoadingDatabases; BlogManagerFinishedLoadingArchive += OnBlogManagerFinishedLoadingArchive; _shellService.ContentView = ManagerViewModel.View; // Refresh command availability on selection change. ManagerViewModel.PropertyChanged += (sender, e) => { if (e.PropertyName != nameof(ManagerViewModel.SelectedBlogFile)) { return; } _showFilesCommand.RaiseCanExecuteChanged(); _visitBlogCommand.RaiseCanExecuteChanged(); _visitBlogOnTumbexCommand.RaiseCanExecuteChanged(); _showDetailsCommand.RaiseCanExecuteChanged(); _copyUrlCommand.RaiseCanExecuteChanged(); _checkStatusCommand.RaiseCanExecuteChanged(); }; if (_shellService.Settings.CheckClipboard) { _shellService.ClipboardMonitor.OnClipboardContentChanged += OnClipboardContentChanged; } using (_shellService.SetApplicationBusy()) { await LoadDataBasesAsync(); } }
private void SelectionServicePropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(selectionService.SelectedFeedItem)) { readUnreadCommand.RaiseCanExecuteChanged(); launchWebBrowserCommand.RaiseCanExecuteChanged(); } }
public void AsyncDelegateCommand_RaiseCanExecuteChanged_Should_Invoke_Listeners() { bool invoked = false; var c = new AsyncDelegateCommand(_ => Task.CompletedTask); c.CanExecuteChanged += (s, e) => invoked = true; c.RaiseCanExecuteChanged(); invoked.Should().BeTrue(); }
private void Stop() { if (_resumeCommand.CanExecute(null)) { _resumeCommand.Execute(null); } try { _crawlerCancellationTokenSource.Cancel(); } catch { // sometimes it fails to cancel the crawlers, because they are already cancelled/disposed } _crawlerService.IsCrawl = false; _crawlCommand.RaiseCanExecuteChanged(); _pauseCommand.RaiseCanExecuteChanged(); _resumeCommand.RaiseCanExecuteChanged(); _stopCommand.RaiseCanExecuteChanged(); }
public async Task InitializeAsync() { crawlerService.ImportBlogsCommand = importBlogsCommand; crawlerService.AddBlogCommand = addBlogCommand; crawlerService.RemoveBlogCommand = removeBlogCommand; crawlerService.ShowFilesCommand = showFilesCommand; crawlerService.EnqueueSelectedCommand = enqueueSelectedCommand; crawlerService.LoadLibraryCommand = loadLibraryCommand; crawlerService.LoadAllDatabasesCommand = loadAllDatabasesCommand; crawlerService.CheckIfDatabasesCompleteCommand = checkIfDatabasesCompleteCommand; crawlerService.AutoDownloadCommand = autoDownloadCommand; crawlerService.ListenClipboardCommand = listenClipboardCommand; crawlerService.PropertyChanged += CrawlerServicePropertyChanged; ManagerViewModel.ShowFilesCommand = showFilesCommand; ManagerViewModel.VisitBlogCommand = visitBlogCommand; ManagerViewModel.ShowDetailsCommand = showDetailsCommand; ManagerViewModel.CopyUrlCommand = copyUrlCommand; ManagerViewModel.CheckStatusCommand = checkStatusCommand; ManagerViewModel.PropertyChanged += ManagerViewModelPropertyChanged; ManagerViewModel.QueueItems = QueueManager.Items; QueueManager.Items.CollectionChanged += QueueItemsCollectionChanged; ManagerViewModel.QueueItems.CollectionChanged += ManagerViewModel.QueueItemsCollectionChanged; BlogManagerFinishedLoadingLibrary += OnBlogManagerFinishedLoadingLibrary; BlogManagerFinishedLoadingDatabases += OnBlogManagerFinishedLoadingDatabases; shellService.ContentView = ManagerViewModel.View; // Refresh command availability on selection change. ManagerViewModel.PropertyChanged += (sender, e) => { if (e.PropertyName != nameof(ManagerViewModel.SelectedBlogFile)) { return; } showFilesCommand.RaiseCanExecuteChanged(); visitBlogCommand.RaiseCanExecuteChanged(); showDetailsCommand.RaiseCanExecuteChanged(); copyUrlCommand.RaiseCanExecuteChanged(); checkStatusCommand.RaiseCanExecuteChanged(); }; if (shellService.Settings.CheckClipboard) { shellService.ClipboardMonitor.OnClipboardContentChanged += OnClipboardContentChanged; } await LoadDataBasesAsync(); }
public void RaiseCanExecuteChangedTest() { var executed = false; var canExecute = false; var command = new AsyncDelegateCommand(() => { executed = true; return(Task.FromResult((object)null)); }, () => canExecute); Assert.IsFalse(command.CanExecute(null)); canExecute = true; Assert.IsTrue(command.CanExecute(null)); AssertHelper.CanExecuteChangedEvent(command, () => command.RaiseCanExecuteChanged()); AssertHelper.CanExecuteChangedEvent(command, () => command.Execute(null), 2, ExpectedChangedCountMode.Exact); // Because during execution CanExecute returns false Assert.IsTrue(executed); }
private void SelectedFeedsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { removeFeedCommand.RaiseCanExecuteChanged(); }