Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 void IChangeNotification.Post()
 {
     if (Interlocked.CompareExchange(ref changePosted, 1, 0) == 0)
     {
         invoke.Post(() =>
         {
             changePosted = 0;
             OnChange?.Invoke(this, EventArgs.Empty);
         });
     }
 }
Esempio n. 4
0
        /// <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);
        }
Esempio n. 5
0
 public void ContinueOn(ISynchronizationContext context)
 {
     context.Post(AdvanceCoroutine, this, context);
 }
Esempio n. 6
0
 void FireChangedEvent()
 {
     eventInvoker.Post(() => Changed?.Invoke(this, EventArgs.Empty));
 }
Esempio n. 7
0
 void FireChangedEvent()
 {
     changeNotification.Post();
     eventInvoker.Post(() => Changed?.Invoke(this, EventArgs.Empty));
 }
Esempio n. 8
0
        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();
        }