コード例 #1
0
        public PresenterFactory(
            IHeartBeatTimer heartbeat,
            IPresentersFacade presentationFacade,
            IClipboardAccess clipboard,
            IBookmarksFactory bookmarksFactory,
            Telemetry.ITelemetryCollector telemetry,
            ILogSourcesManager logSources,
            IInvokeSynchronization modelInvoke,
            IModelThreads modelThreads,
            IFiltersList hlFilters,
            IBookmarks bookmarks,
            Settings.IGlobalSettingsAccessor settings,
            ISearchManager searchManager,
            IFiltersFactory filtersFactory
            )
        {
            this.heartbeat          = heartbeat;
            this.presentationFacade = presentationFacade;
            this.clipboard          = clipboard;
            this.bookmarksFactory   = bookmarksFactory;
            this.telemetry          = telemetry;

            this.logSources     = logSources;
            this.modelInvoke    = modelInvoke;
            this.modelThreads   = modelThreads;
            this.hlFilters      = hlFilters;
            this.bookmarks      = bookmarks;
            this.settings       = settings;
            this.searchManager  = searchManager;
            this.filtersFactory = filtersFactory;
        }
コード例 #2
0
        public Presenter(
            IView view,
            ILogSourcesManager logSources,
            Preprocessing.ILogSourcesPreprocessingManager preprocessings,
            IPresentersFacade navHandler,
            IAlertPopup alerts,
            IClipboardAccess clipboard,
            IShellOpen shellOpen
            )
        {
            this.view             = view;
            this.presentersFacade = navHandler;
            this.alerts           = alerts;
            this.preprocessings   = preprocessings;
            this.clipboard        = clipboard;
            this.shellOpen        = shellOpen;
            this.logSources       = logSources;

            view.SetEventsHandler(this);

            logSources.OnLogSourceColorChanged += (s, e) =>
            {
                if (object.ReferenceEquals(s, source) && currentWindow != null)
                {
                    UpdateColorPanel();
                }
            };
        }
コード例 #3
0
        public Presenter(
            IBookmarks bookmarks,
            ILogSourcesManager sourcesManager,
            IView view,
            IHeartBeatTimer heartbeat,
            LoadedMessages.IPresenter loadedMessagesPresenter,
            IClipboardAccess clipboardAccess,
            IColorTheme colorTheme,
            IChangeNotification changeNotification,
            ITraceSourceFactory traceSourceFactory
            )
        {
            this.bookmarks = bookmarks;
            this.view      = view;
            this.loadedMessagesPresenter = loadedMessagesPresenter;
            this.clipboardAccess         = clipboardAccess;
            this.colorTheme         = colorTheme;
            this.changeNotification = changeNotification;
            this.trace = traceSourceFactory.CreateTraceSource("UI", "bmks");

            itemsSelector = Selectors.Create(
                () => bookmarks.Items,
                () => selectedBookmarks,
                () => colorTheme.ThreadColors,
                () => loadedMessagesPresenter.LogViewerPresenter.Coloring,
                CreateViewItems
                );
            focusedMessagePositionSelector = Selectors.Create(
                () => loadedMessagesPresenter.LogViewerPresenter.FocusedMessageBookmark,
                () => bookmarks.Items,
                FindFocusedMessagePosition
                );

            view.SetViewModel(this);
        }
コード例 #4
0
        public Presenter(
            ILogSourcesManager logSources,
            IView view,
            ILogSourcesPreprocessingManager logSourcesPreprocessings,
            SourcePropertiesWindow.IPresenter propertiesWindowPresenter,
            LogViewer.IPresenter logViewerPresenter,
            IPresentersFacade navHandler,
            IAlertPopup alerts,
            IFileDialogs fileDialogs,
            IClipboardAccess clipboard,
            IShellOpen shellOpen,
            SaveJointLogInteractionPresenter.IPresenter saveJointLogInteractionPresenter
            )
        {
            this.logSources = logSources;
            this.view       = view;
            this.propertiesWindowPresenter = propertiesWindowPresenter;
            this.logViewerPresenter        = logViewerPresenter;
            this.logSourcesPreprocessings  = logSourcesPreprocessings;
            this.alerts      = alerts;
            this.fileDialogs = fileDialogs;
            this.clipboard   = clipboard;
            this.shellOpen   = shellOpen;
            this.saveJointLogInteractionPresenter = saveJointLogInteractionPresenter;

            logViewerPresenter.FocusedMessageChanged += (sender, args) =>
            {
                view.InvalidateFocusedMessageArea();
            };

            view.SetPresenter(this);
        }
コード例 #5
0
        public Presenter(
            IBookmarks bookmarks,
            ILogSourcesManager sourcesManager,
            IView view,
            IHeartBeatTimer heartbeat,
            LoadedMessages.IPresenter loadedMessagesPresenter,
            IClipboardAccess clipboardAccess)
        {
            this.bookmarks = bookmarks;
            this.view      = view;
            this.loadedMessagesPresenter = loadedMessagesPresenter;
            this.clipboardAccess         = clipboardAccess;
            this.trace = new LJTraceSource("UI", "bmks");

            bookmarks.OnBookmarksChanged += (sender, evt) => updateTracker.Invalidate();
            heartbeat.OnTimer            += (sender, evt) =>
            {
                if (evt.IsNormalUpdate && updateTracker.Validate())
                {
                    UpdateViewInternal(null, ViewUpdateFlags.None);
                }
            };
            sourcesManager.OnLogSourceVisiblityChanged += (sender, evt) => updateTracker.Invalidate();
            loadedMessagesPresenter.LogViewerPresenter.ColoringModeChanged += (sender, evt) => view.Invalidate();

            view.SetPresenter(this);
        }
コード例 #6
0
 public Extension(
     IPostprocessorsRegistry postprocessorsRegistry,
     Func <IView> viewFactory,
     IClipboardAccess clipboardAccess
     )
 {
     this.postprocessorsRegistry = postprocessorsRegistry;
     this.viewFactory            = viewFactory;
     this.clipboardAccess        = clipboardAccess;
 }
コード例 #7
0
        public StateInspectorPresenter(
            IView view,
            IStateInspectorVisualizerModel model,
            IUserNamesProvider shortNames,
            ILogSourcesManager logSources,
            LoadedMessages.IPresenter loadedMessagesPresenter,
            IBookmarks bookmarks,
            IModelThreads threads,
            IPresentersFacade presentersFacade,
            IClipboardAccess clipboardAccess,
            SourcesManager.IPresenter sourcesManagerPresenter,
            IColorTheme theme
            )
        {
            this.view                    = view;
            this.model                   = model;
            this.shortNames              = shortNames;
            this.threads                 = threads;
            this.presentersFacade        = presentersFacade;
            this.bookmarks               = bookmarks;
            this.clipboardAccess         = clipboardAccess;
            this.sourcesManagerPresenter = sourcesManagerPresenter;
            this.loadedMessagesPresenter = loadedMessagesPresenter;
            this.theme                   = theme;

            view.SetEventsHandler(this);

            logSources.OnLogSourceAnnotationChanged += (sender, e) =>
            {
                InvalidateTree();
            };

            loadedMessagesPresenter.LogViewerPresenter.FocusedMessageChanged += (sender, args) =>
            {
                HandleFocusedMessageChange();
            };

            bookmarks.OnBookmarksChanged += (sender, args) =>
            {
                view.BeginUpdateStateHistoryList(false, false);
                view.EndUpdateStateHistoryList(null, false, redrawFocusedMessageMark: true);
            };

            model.Changed += (sender, args) =>
            {
                InvalidateTree();
                HandleFocusedMessageChange();
                RemoveMissingGroupsFromCache();
            };

            InvalidateTree();
            HandleFocusedMessageChange();
        }
コード例 #8
0
        public Presenter(
            ILogSourcesManager logSourcesManager,
            Workspaces.IWorkspacesManager workspacesManager,
            Preprocessing.IManager preprocessingsManager,
            IAlertPopup alertPopup,
            IClipboardAccess clipboard,
            IView view,
            IChangeNotification changeNotification
            )
        {
            this.logSourcesManager = logSourcesManager;
            this.workspacesManager = workspacesManager;
            this.view = view;
            this.preprocessingsManager = preprocessingsManager;
            this.alertPopup            = alertPopup;
            this.clipboard             = clipboard;
            this.changeNotification    = changeNotification;

            view.SetEventsHandler(this);

            logSourcesManager.OnLogSourceAdded += (sender, args) =>
            {
                UpdateAvaialibility();
            };

            logSourcesManager.OnLogSourceRemoved += (sender, args) =>
            {
                UpdateAvaialibility();
            };

            workspacesManager.CurrentWorkspaceChanged += (sender, args) =>
            {
                UpdateWorkspaceUrlEditBox();
                UpdateWorkspaceEditCotrols();
            };

            workspacesManager.StatusChanged += (sender, args) =>
            {
                UpdateWorkspaceUrlEditBox();
                UpdateDescription();
                UpdateDialogButtons();
                UpdateProgressIndicator();
                UpdateWorkspaceEditCotrols(triggeredByStatusChange: true);
                UpdateIsBusy();
            };

            UpdateAvaialibility();
            UpdateDescription();
            UpdateWorkspaceUrlEditBox();
            UpdateDialogButtons();
            UpdateWorkspaceEditCotrols();
        }
コード例 #9
0
ファイル: Factory.cs プロジェクト: sabrogden/logjoint
 public static PresentationObjects Create(
     ModelObjects model,
     IClipboardAccess clipboardAccess,
     IShellOpen shellOpen,
     IAlertPopup alertPopup,
     IFileDialogs fileDialogs,
     IPromptDialog promptDialog,
     About.IAboutConfig aboutConfig,
     MainForm.IDragDropHandler dragDropHandler,
     ISystemThemeDetector systemThemeDetector,
     IViewsFactory views
     )
 {
     T callOptionalFactory <T>(Func <T> factory) where T : class
コード例 #10
0
        public Presenter(
            IView view,
            ILogSourcesManager logSources,
            Preprocessing.IManager preprocessings,
            IModelThreads threads,
            IPresentersFacade navHandler,
            IAlertPopup alerts,
            IClipboardAccess clipboard,
            IShellOpen shellOpen,
            IColorTheme theme,
            IHeartBeatTimer heartBeat,
            IChangeNotification changeNotification
            )
        {
            this.view               = view;
            this.presentersFacade   = navHandler;
            this.alerts             = alerts;
            this.preprocessings     = preprocessings;
            this.clipboard          = clipboard;
            this.shellOpen          = shellOpen;
            this.theme              = theme;
            this.changeNotification = changeNotification.CreateChainedChangeNotification(initiallyActive: false);

            logSources.OnLogSourceStatsChanged += (s, e) =>
            {
                if (s == logSources)
                {
                    pendingUpdateFlag.Invalidate();
                }
            };

            threads.OnThreadListChanged       += (s, e) => pendingUpdateFlag.Invalidate();
            threads.OnThreadPropertiesChanged += (s, e) => pendingUpdateFlag.Invalidate();

            heartBeat.OnTimer += (s, e) =>
            {
                if (pendingUpdateFlag.Validate())
                {
                    ++forceUpdateRevision;
                    changeNotification.Post();
                }
            };

            this.getViewState = () => emptyViewState;

            view.SetViewModel(this);
        }
コード例 #11
0
 public SelectionManager(
     IView view,
     IScreenBuffer screenBuffer,
     LJTraceSource tracer,
     IPresentationDataAccess presentationDataAccess,
     IClipboardAccess clipboard,
     IScreenBufferFactory screenBufferFactory,
     IBookmarksFactory bookmarksFactory
     )
 {
     this.view                   = view;
     this.screenBuffer           = screenBuffer;
     this.clipboard              = clipboard;
     this.presentationDataAccess = presentationDataAccess;
     this.tracer                 = tracer;
     this.screenBufferFactory    = screenBufferFactory;
     this.bookmarksFactory       = bookmarksFactory;
 }
コード例 #12
0
        public Presenter(
            IView view,
            IAboutConfig config,
            IClipboardAccess clipboardAccess,
            AutoUpdate.IAutoUpdater autoUpdater
            )
        {
            this.view            = view;
            this.config          = config;
            this.clipboardAccess = clipboardAccess;
            this.autoUpdater     = autoUpdater;

            view.SetEventsHandler(this);

            autoUpdater.Changed += (s, e) =>
            {
                UpdateAutoUpdateControls();
            };
        }
コード例 #13
0
 public PresenterFactory(
     IChangeNotification changeNotification,
     IHeartBeatTimer heartbeat,
     IPresentersFacade presentationFacade,
     IClipboardAccess clipboard,
     IBookmarksFactory bookmarksFactory,
     Telemetry.ITelemetryCollector telemetry,
     ILogSourcesManager logSources,
     ISynchronizationContext modelInvoke,
     IModelThreads modelThreads,
     IFiltersList hlFilters,
     IBookmarks bookmarks,
     Settings.IGlobalSettingsAccessor settings,
     ISearchManager searchManager,
     IFiltersFactory filtersFactory,
     IColorTheme theme,
     ITraceSourceFactory traceSourceFactory,
     RegularExpressions.IRegexFactory regexFactory
     )
 {
     this.changeNotification = changeNotification;
     this.heartbeat          = heartbeat;
     this.presentationFacade = presentationFacade;
     this.clipboard          = clipboard;
     this.bookmarksFactory   = bookmarksFactory;
     this.telemetry          = telemetry;
     this.logSources         = logSources;
     this.modelInvoke        = modelInvoke;
     this.modelThreads       = modelThreads;
     this.hlFilters          = hlFilters;
     this.bookmarks          = bookmarks;
     this.settings           = settings;
     this.searchManager      = searchManager;
     this.filtersFactory     = filtersFactory;
     this.theme = theme;
     this.traceSourceFactory = traceSourceFactory;
     this.regexFactory       = regexFactory;
 }
コード例 #14
0
        public SelectionManager(
            IView view,
            ISearchResultModel searchResultModel,             // todo: try get rid of this dependency
            IScreenBuffer screenBuffer,
            LJTraceSource tracer,
            IPresentationDataAccess presentationDataAccess,
            IClipboardAccess clipboard,
            IScreenBufferFactory screenBufferFactory,
            IBookmarksFactory bookmarksFactory
            )
        {
            this.view = view;
            this.searchResultModel      = searchResultModel;
            this.screenBuffer           = screenBuffer;
            this.clipboard              = clipboard;
            this.presentationDataAccess = presentationDataAccess;
            this.tracer              = tracer;
            this.searchResultModel   = searchResultModel;
            this.screenBufferFactory = screenBufferFactory;
            this.bookmarksFactory    = bookmarksFactory;

            this.searchResultInplaceHightlightHandler = SearchResultInplaceHightlightHandler;
        }
コード例 #15
0
 public Factory(
     IViewsFactory postprocessingViewsFactory,
     IManager postprocessorsManager,
     ILogSourcesManager logSourcesManager,
     ISynchronizationContext synchronizationContext,
     IChangeNotification changeNotification,
     IBookmarks bookmarks,
     IModelThreads threads,
     Persistence.IStorageManager storageManager,
     ILogSourceNamesProvider logSourceNamesProvider,
     IUserNamesProvider shortNames,
     SourcesManager.IPresenter sourcesManagerPresenter,
     LoadedMessages.IPresenter loadedMessagesPresenter,
     IClipboardAccess clipboardAccess,
     IPresentersFacade presentersFacade,
     IAlertPopup alerts,
     IColorTheme colorTheme
     )
 {
     this.postprocessingViewsFactory = postprocessingViewsFactory;
     this.postprocessorsManager      = postprocessorsManager;
     this.logSourcesManager          = logSourcesManager;
     this.synchronizationContext     = synchronizationContext;
     this.changeNotification         = changeNotification;
     this.bookmarks               = bookmarks;
     this.threads                 = threads;
     this.storageManager          = storageManager;
     this.logSourceNamesProvider  = logSourceNamesProvider;
     this.shortNames              = shortNames;
     this.sourcesManagerPresenter = sourcesManagerPresenter;
     this.loadedMessagesPresenter = loadedMessagesPresenter;
     this.clipboardAccess         = clipboardAccess;
     this.presentersFacade        = presentersFacade;
     this.alerts     = alerts;
     this.colorTheme = colorTheme;
 }
コード例 #16
0
        public Factory(
            IViewsFactory postprocessingViewsFactory,
            IManagerInternal postprocessorsManager,
            ILogSourcesManager logSourcesManager,
            ISynchronizationContext synchronizationContext,
            IChangeNotification changeNotification,
            IBookmarks bookmarks,
            IModelThreads threads,
            Persistence.IStorageManager storageManager,
            ILogSourceNamesProvider logSourceNamesProvider,
            IUserNamesProvider shortNames,
            SourcesManager.IPresenter sourcesManagerPresenter,
            LoadedMessages.IPresenter loadedMessagesPresenter,
            IClipboardAccess clipboardAccess,
            IPresentersFacade presentersFacade,
            IAlertPopup alerts,
            IColorTheme colorTheme,
            Drawing.IMatrixFactory matrixFactory,
            ICorrelationManager correlationManager
            )
        {
            stateInspectorVisualizer = new Lazy <StateInspectorVisualizer.IPresenterInternal>(() =>
            {
                var view  = postprocessingViewsFactory.CreateStateInspectorView();
                var model = new LogJoint.Postprocessing.StateInspector.StateInspectorVisualizerModel(
                    postprocessorsManager,
                    logSourcesManager,
                    synchronizationContext,
                    shortNames
                    );
                return(new StateInspectorVisualizer.StateInspectorPresenter(
                           view,
                           model,
                           shortNames,
                           logSourcesManager,
                           loadedMessagesPresenter,
                           bookmarks,
                           threads,
                           presentersFacade,
                           clipboardAccess,
                           sourcesManagerPresenter,
                           colorTheme
                           ));
            });

            timelineVisualizer = new Lazy <TimelineVisualizer.IPresenter>(() =>
            {
                var view  = postprocessingViewsFactory.CreateTimelineView();
                var model = new LogJoint.Postprocessing.Timeline.TimelineVisualizerModel(
                    postprocessorsManager,
                    logSourcesManager,
                    shortNames,
                    logSourceNamesProvider
                    );
                return(new TimelineVisualizer.TimelineVisualizerPresenter(
                           model,
                           view,
                           stateInspectorVisualizer.Value,
                           new Common.PresentationObjectsFactory(postprocessorsManager, logSourcesManager, changeNotification, alerts, correlationManager),
                           loadedMessagesPresenter,
                           bookmarks,
                           storageManager,
                           presentersFacade,
                           shortNames,
                           changeNotification,
                           colorTheme
                           ));
            });

            sequenceDiagramVisualizer = new Lazy <SequenceDiagramVisualizer.IPresenter>(() =>
            {
                var view  = postprocessingViewsFactory.CreateSequenceDiagramView();
                var model = new LogJoint.Postprocessing.SequenceDiagram.SequenceDiagramVisualizerModel(
                    postprocessorsManager,
                    logSourcesManager,
                    shortNames,
                    logSourceNamesProvider,
                    changeNotification
                    );
                return(new SequenceDiagramVisualizer.SequenceDiagramVisualizerPresenter(
                           model,
                           view,
                           stateInspectorVisualizer.Value,
                           new Common.PresentationObjectsFactory(postprocessorsManager, logSourcesManager, changeNotification, alerts, correlationManager),
                           loadedMessagesPresenter,
                           bookmarks,
                           storageManager,
                           presentersFacade,
                           shortNames,
                           changeNotification,
                           colorTheme,
                           matrixFactory
                           ));
            });

            timeSeriesVisualizer = new Lazy <TimeSeriesVisualizer.IPresenter>(() =>
            {
                var view  = postprocessingViewsFactory.CreateTimeSeriesView();
                var model = new LogJoint.Postprocessing.TimeSeries.TimelineVisualizerModel(
                    postprocessorsManager,
                    logSourcesManager,
                    shortNames,
                    logSourceNamesProvider
                    );
                return(new TimeSeriesVisualizer.TimeSeriesVisualizerPresenter(
                           model,
                           view,
                           new Common.PresentationObjectsFactory(postprocessorsManager, logSourcesManager, changeNotification, alerts, correlationManager),
                           loadedMessagesPresenter.LogViewerPresenter,
                           bookmarks,
                           presentersFacade,
                           changeNotification
                           ));
            });
        }
コード例 #17
0
        public StateInspectorPresenter(
            IView view,
            IStateInspectorVisualizerModel model,
            IUserNamesProvider shortNames,
            ILogSourcesManager logSources,
            LoadedMessages.IPresenter loadedMessagesPresenter,
            IBookmarks bookmarks,
            IModelThreads threads,
            IPresentersFacade presentersFacade,
            IClipboardAccess clipboardAccess,
            SourcesManager.IPresenter sourcesManagerPresenter,
            IColorTheme theme,
            IChangeNotification changeNotification
            )
        {
            this.view                    = view;
            this.model                   = model;
            this.shortNames              = shortNames;
            this.threads                 = threads;
            this.presentersFacade        = presentersFacade;
            this.bookmarks               = bookmarks;
            this.clipboardAccess         = clipboardAccess;
            this.sourcesManagerPresenter = sourcesManagerPresenter;
            this.loadedMessagesPresenter = loadedMessagesPresenter;
            this.theme                   = theme;
            this.changeNotification      = changeNotification.CreateChainedChangeNotification(initiallyActive: false);

            var annotationsVersion = 0;

            logSources.OnLogSourceAnnotationChanged += (sender, e) =>
            {
                annotationsVersion++;
                changeNotification.Post();
            };

            var getAnnotationsMap = Selectors.Create(
                () => logSources.Items,
                () => annotationsVersion,
                (sources, _) =>
                sources
                .Where(s => !s.IsDisposed && !string.IsNullOrEmpty(s.Annotation))
                .ToImmutableDictionary(s => s, s => s.Annotation)
                );

            VisualizerNode rootNode   = new VisualizerNode(null, ImmutableList <VisualizerNode> .Empty, true, false, 0, ImmutableDictionary <ILogSource, string> .Empty);
            var            updateRoot = Updaters.Create(
                () => model.Groups,
                getAnnotationsMap,
                (groups, annotationsMap) => rootNode = MakeRootNode(groups, OnNodeCreated, annotationsMap, rootNode)
                );

            this.getRootNode = () =>
            {
                updateRoot();
                return(rootNode);
            };
            this.updateRootNode = reducer =>
            {
                var oldRoot = getRootNode();
                var newRoot = reducer(oldRoot);
                if (oldRoot != newRoot)
                {
                    rootNode = newRoot;
                    changeNotification.Post();
                }
            };

            this.getSelectedNodes = Selectors.Create(
                getRootNode,
                (root) =>
            {
                var result = ImmutableArray.CreateBuilder <VisualizerNode>();

                void traverse(VisualizerNode n)
                {
                    if (!n.HasSelectedNodes)
                    {
                        return;
                    }
                    if (n.IsSelected)
                    {
                        result.Add(n);
                    }
                    foreach (var c in n.Children)
                    {
                        traverse(c);
                    }
                }

                traverse(root);

                return(result.ToImmutable());
            }
                );

            this.getSelectedInspectedObjects = Selectors.Create(
                getSelectedNodes,
                nodes => ImmutableArray.CreateRange(nodes.Select(n => n.InspectedObject))
                );

            this.getStateHistoryItems = Selectors.Create(
                getSelectedInspectedObjects,
                () => selectedHistoryEvents,
                MakeSelectedObjectHistory
                );

            this.getIsHistoryItemBookmarked = Selectors.Create(
                () => bookmarks.Items,
                boormarksItems =>
            {
                Predicate <IStateHistoryItem> result = (item) =>
                {
                    var change = (item as StateHistoryItem)?.Event;
                    if (change == null || change.Output.LogSource.IsDisposed)
                    {
                        return(false);
                    }
                    var bmk = bookmarks.Factory.CreateBookmark(
                        change.Trigger.Timestamp.Adjust(change.Output.LogSource.TimeOffsets),
                        change.Output.LogSource.GetSafeConnectionId(), change.Trigger.StreamPosition, 0);
                    var pos = boormarksItems.FindBookmark(bmk);
                    return(pos.Item2 > pos.Item1);
                };
                return(result);
            }
                );

            this.getFocusedMessageInfo = () => loadedMessagesPresenter.LogViewerPresenter.FocusedMessage;

            this.getFocusedMessageEqualRange = Selectors.Create(
                getFocusedMessageInfo,
                focusedMessageInfo =>
            {
                var cache = new Dictionary <IStateInspectorOutputsGroup, FocusedMessageEventsRange>();
                Func <IStateInspectorOutputsGroup, FocusedMessageEventsRange> result = forGroup =>
                {
                    if (!cache.TryGetValue(forGroup, out FocusedMessageEventsRange eventsRange))
                    {
                        eventsRange = new FocusedMessageEventsRange(focusedMessageInfo,
                                                                    forGroup.Events.CalcFocusedMessageEqualRange(focusedMessageInfo));
                        cache.Add(forGroup, eventsRange);
                    }
                    return(eventsRange);
                };
                return(result);
            }
                );

            this.getPaintNode = Selectors.Create(
                getFocusedMessageEqualRange,
                MakePaintNodeDelegate
                );

            this.getFocusedMessagePositionInHistory = Selectors.Create(
                getStateHistoryItems,
                getFocusedMessageInfo,
                (changes, focusedMessage) =>
            {
                return
                (focusedMessage == null ? null :
                 new ListUtils.VirtualList <StateInspectorEvent>(changes.Length,
                                                                 i => changes[i].Event).CalcFocusedMessageEqualRange(focusedMessage));
            }
                );

            this.getCurrentTimeLabelText = Selectors.Create(
                getFocusedMessageInfo,
                focusedMsg => focusedMsg != null ? $"at {focusedMsg.Time}" : ""
                );

            this.getCurrentProperties = Selectors.Create(
                getSelectedInspectedObjects,
                getFocusedMessageEqualRange,
                () => selectedProperty,
                MakeCurrentProperties
                );

            this.getPropertyItems = Selectors.Create(
                getCurrentProperties,
                props => (IReadOnlyList <IPropertyListItem>)props.Cast <IPropertyListItem>().ToImmutableArray()
                );

            this.getObjectsProperties = Selectors.Create(
                getCurrentProperties,
                props => (IReadOnlyList <KeyValuePair <string, object> >)props.Select(p => p.ToDataSourceItem()).ToImmutableArray()
                );

            view.SetViewModel(this);
        }
コード例 #18
0
        public Presenter(
            ILogSourcesManager logSources,
            IView view,
            IManager logSourcesPreprocessings,
            SourcePropertiesWindow.IPresenter propertiesWindowPresenter,
            LogViewer.IPresenterInternal logViewerPresenter,
            IAlertPopup alerts,
            IFileDialogs fileDialogs,
            IClipboardAccess clipboard,
            IShellOpen shellOpen,
            SaveJointLogInteractionPresenter.IPresenter saveJointLogInteractionPresenter,
            IColorTheme theme,
            IChangeNotification changeNotification,
            IHeartBeatTimer heartbeat
            )
        {
            this.logSources = logSources;
            this.view       = view;
            this.propertiesWindowPresenter = propertiesWindowPresenter;
            this.logSourcesPreprocessings  = logSourcesPreprocessings;
            this.alerts      = alerts;
            this.fileDialogs = fileDialogs;
            this.clipboard   = clipboard;
            this.shellOpen   = shellOpen;
            this.saveJointLogInteractionPresenter = saveJointLogInteractionPresenter;
            this.changeNotification = changeNotification;

            void updateItems()
            {
                itemsRevision++;
                changeNotification.Post();
            }

            logSources.OnLogSourceVisiblityChanged  += (s, e) => updateItems();
            logSources.OnLogSourceAnnotationChanged += (s, e) => updateItems();
            logSources.OnLogSourceColorChanged      += (s, e) => updateItems();

            logSourcesPreprocessings.PreprocessingChangedAsync += (s, e) => pendingUpdateFlag.Invalidate();
            logSources.OnLogSourceStatsChanged += (s, e) =>
            {
                if ((e.Flags & (LogProviderStatsFlag.Error | LogProviderStatsFlag.CachedMessagesCount | LogProviderStatsFlag.State | LogProviderStatsFlag.BytesCount | LogProviderStatsFlag.BackgroundAcivityStatus)) != 0)
                {
                    pendingUpdateFlag.Invalidate();
                }
            };

            heartbeat.OnTimer += (s, e) =>
            {
                if (pendingUpdateFlag.Validate())
                {
                    updateItems();
                }
            };

            this.getRoot = Selectors.Create(
                () => logSources.Items,
                () => logSourcesPreprocessings.Items,
                () => theme.ThreadColors,
                () => expandedKeys,
                () => selectedKeys,
                () => itemsRevision,
                (sources, preprocessings, themeColors, expanded, selected, rev) => new RootViewItem
            {
                Items = ImmutableArray.CreateRange(
                    EnumItemsData(sources, preprocessings, themeColors, expanded, selected, logSourcesPreprocessings))
            }
                );

            this.getSelectedSources = Selectors.Create(
                getRoot,
                root => ImmutableArray.CreateRange(
                    ViewItem.Flatten(root).Where(i => i.IsSelected).SelectMany(i =>
            {
                if (i is LogSourceViewItem singleSource)
                {
                    return new[] { singleSource.LogSource }
                }
                ;
                if (i is SourcesContainerViewItem container)
                {
                    return(container.LogSources.Select(x => x.LogSource));
                }
                return(Enumerable.Empty <ILogSource>());
            })
                    .Distinct()
                    )
                );

            this.getSelectedPreprocessings = Selectors.Create(
                getRoot,
                root => ImmutableArray.CreateRange(
                    ViewItem.Flatten(root).OfType <PreprocessingViewItem>().Select(p => p.Preprocessing)
                    )
                );

            this.getFocusedMessageItem = Selectors.Create(
                () => logViewerPresenter.FocusedMessage,
                getRoot,
                (msg, root) =>
            {
                var ls = msg?.GetLogSource();
                return((IViewItem)ViewItem.Flatten(root).FirstOrDefault(
                           i => (i as LogSourceViewItem)?.LogSource == ls
                           ));
            }
                );

            view.SetViewModel(this);
        }
コード例 #19
0
        public Presenter(
            IView view,
            IChangeNotification changeNotification,
            IClipboardAccess clipboardAccess
            )
        {
            this.view = view;
            this.changeNotification = changeNotification;
            this.clipboardAccess    = clipboardAccess;

            this.getRoot = Selectors.Create(
                () => message,
                () => lastSetExpanded,
                () => lastSetSelected,
                (msg, setExpanded, setSelected) =>
            {
                XElement packetElement = null;
                try
                {
                    if (msg != null)
                    {
                        packetElement = XElement.Parse(msg.RawText.Value);
                    }
                }
                catch (XmlException)
                {
                }
                packetElement = packetElement ?? new XElement("packet");

                Node toNode(XElement element, string parentId, bool isHidden, HashSet <string> usedKeys)
                {
                    // todo: handle "response in" by doing binary search inside the file
                    var show =
                        element.Attribute("showname")?.Value ?? element.Attribute("show")?.Value;
                    var name = element.Attribute("name")?.Value;
                    var hide = element.Attribute("hide")?.Value;
                    if (show == null || name == null || hide == "yes")
                    {
                        return(null);
                    }
                    var key = name;
                    while (!usedKeys.Add(key))
                    {
                        key += "+";
                    }
                    var id         = $"{parentId}/{key}";
                    var isExpanded = setExpanded.Contains(id);
                    return(new Node
                    {
                        Text = show,
                        Key = key,
                        Id = id,
                        Children = toNodes(element.Elements(), id, isHidden || !isExpanded),
                        IsExpanded = isExpanded,
                        IsSelected = !isHidden && id == setSelected
                    });
                }

                ImmutableArray <Node> toNodes(IEnumerable <XElement> elements,
                                              string parentId, bool isHidden)
                {
                    var usedKeys = new HashSet <string>();
                    return(ImmutableArray.CreateRange(elements.Select(
                                                          e => toNode(e, parentId, isHidden, usedKeys)).Where(n => n != null)));
                }

                return(new Node
                {
                    Text = "",
                    Id = "",
                    Key = "",
                    IsExpanded = true,
                    Children = toNodes(
                        packetElement.Elements("proto")
                        .Where(p => p.Attribute("name")?.Value != "geninfo"),
                        "",
                        false
                        ),
                });
            }
                );

            view.SetViewModel(this);
        }