void IView.SetViewModel(IViewModel viewModel) { var updateDialog = Updaters.Create( () => viewModel.DialogData, dd => { if ((dd != null) != (dialog != null)) { if (dialog != null) { dialog.Close(); dialog = null; } else { synchronizationContext.Post(() => { if (viewModel.DialogData != null) { FilesSelectionDialogController.Execute(viewModel, reactive, out dialog); } }); } } else if (dialog != null && dd != null) { dialog.Update(dd); } } ); viewModel.ChangeNotification.CreateSubscription(updateDialog); }
void Presenters.PreprocessingUserInteractions.IView.SetViewModel(Presenters.PreprocessingUserInteractions.IViewModel viewModel) { var updateDialog = Updaters.Create( () => viewModel.DialogData, dd => { if ((dd != null) != (dialog != null)) { if (dialog != null) { dialog.Close(); dialog = null; } else { synchronizationContext.Post(() => { if (viewModel.DialogData != null) { appWindow.BringToFront(); FilesSelectionDialog.Open(viewModel, reactive, out dialog); } }); } } else if (dialog != null && dd != null) { dialog.Update(dd); } } ); viewModel.ChangeNotification.CreateSubscription(updateDialog); }
void IChangeNotification.Post() { if (Interlocked.CompareExchange(ref changePosted, 1, 0) == 0) { invoke.Post(() => { changePosted = 0; OnChange?.Invoke(this, EventArgs.Empty); }); } }
/// <summary> /// Calls the asynchronous function <paramref name="asyncFunc"/> in the /// synchronization context and returns the Task that is complete when passed /// function has completed. /// </summary> public static Task <T> InvokeAndAwait <T>(this ISynchronizationContext sync, Func <Task <T> > asyncFunc) { var completionSource = new TaskCompletionSource <T>(); sync.Post(async() => { try { completionSource.SetResult(await asyncFunc()); } catch (Exception e) { completionSource.SetException(e); } }); return(completionSource.Task); }
public void ContinueOn(ISynchronizationContext context) { context.Post(AdvanceCoroutine, this, context); }
void FireChangedEvent() { eventInvoker.Post(() => Changed?.Invoke(this, EventArgs.Empty)); }
void FireChangedEvent() { changeNotification.Post(); eventInvoker.Post(() => Changed?.Invoke(this, EventArgs.Empty)); }
public Presenter( ISearchManager searchManager, IBookmarks bookmarks, IFiltersList hlFilters, IView view, IPresentersFacade navHandler, LoadedMessages.IPresenter loadedMessagesPresenter, IHeartBeatTimer heartbeat, ISynchronizationContext uiThreadSynchronization, StatusReports.IPresenter statusReports, LogViewer.IPresenterFactory logViewerPresenterFactory, IColorTheme theme, IChangeNotification changeNotification ) { this.searchManager = searchManager; this.bookmarks = bookmarks; this.hlFilters = hlFilters; this.view = view; this.loadedMessagesPresenter = loadedMessagesPresenter; this.statusReports = statusReports; this.theme = theme; this.changeNotification = changeNotification; var(messagesPresenter, messagesModel) = logViewerPresenterFactory.CreateSearchResultsPresenter( view.MessagesView, loadedMessagesPresenter.LogViewerPresenter); this.messagesPresenter = messagesPresenter; this.messagesPresenter.FocusedMessageDisplayMode = LogViewer.FocusedMessageDisplayModes.Slave; this.messagesPresenter.DblClickAction = Presenters.LogViewer.PreferredDblClickAction.DoDefaultAction; this.messagesPresenter.DefaultFocusedMessageActionCaption = "Go to message"; this.messagesPresenter.DisabledUserInteractions = LogViewer.UserInteraction.RawViewSwitching; this.messagesPresenter.DefaultFocusedMessageAction += async(s, e) => { if (messagesPresenter.FocusedMessage != null) { if (await navHandler.ShowMessage(messagesPresenter.FocusedMessageBookmark, BookmarkNavigationOptions.EnablePopups | BookmarkNavigationOptions.SearchResultStringsSet ).IgnoreCancellation()) { loadedMessagesPresenter.LogViewerPresenter.ReceiveInputFocus(); } } }; this.hlFilters.OnPropertiesChanged += (sender, args) => { if (args.ChangeAffectsFilterResult) { lazyUpdateFlag.Invalidate(); } }; this.hlFilters.OnFiltersListChanged += (sender, args) => { lazyUpdateFlag.Invalidate(); }; this.hlFilters.OnFilteringEnabledChanged += (sender, args) => { lazyUpdateFlag.Invalidate(); }; this.searchManager.SearchResultChanged += (sender, e) => { if ((e.Flags & SearchResultChangeFlag.HitCountChanged) != 0 || (e.Flags & SearchResultChangeFlag.ProgressChanged) != 0 || (e.Flags & SearchResultChangeFlag.PinnedChanged) != 0 || (e.Flags & SearchResultChangeFlag.VisibleChanged) != 0) { lazyUpdateFlag.Invalidate(); } if ((e.Flags & SearchResultChangeFlag.StatusChanged) != 0) { lazyUpdateFlag.Invalidate(); uiThreadSynchronization.Post(ValidateView); uiThreadSynchronization.Post(PostSearchActions); } }; this.searchManager.CombinedSearchResultChanged += (sender, e) => { uiThreadSynchronization.Post(() => messagesModel.RaiseSourcesChanged()); }; this.searchManager.SearchResultsChanged += (sender, e) => { lazyUpdateFlag.Invalidate(); messagesModel.RaiseSourcesChanged(); uiThreadSynchronization.Post(ValidateView); uiThreadSynchronization.Post(PreSearchActions); }; heartbeat.OnTimer += (sender, args) => { if (args.IsNormalUpdate) { ValidateView(); } }; view.SetViewModel(this); UpdateExpandedState(); }