예제 #1
0
        public Presenter(
            IView view,
            IManager postprocessorsManager,
            IPostprocessorOutputFormFactory outputFormsFactory,
            ILogSourcesManager logSourcesManager,
            ITempFilesManager tempFiles,
            IShellOpen shellOpen,
            NewLogSourceDialog.IPresenter newLogSourceDialog,
            Telemetry.ITelemetryCollector telemetry,
            IChangeNotification changeNotification,
            MainForm.IPresenter mainFormPresenter
            )
        {
            this.view = view;
            this.postprocessorsManager = postprocessorsManager;
            this.outputFormsFactory    = outputFormsFactory;
            this.tempFiles             = tempFiles;
            this.shellOpen             = shellOpen;
            this.newLogSourceDialog    = newLogSourceDialog;
            this.telemetry             = telemetry;
            this.changeNotification    = changeNotification.CreateChainedChangeNotification(false);

            this.view.SetViewModel(this);

            logSourcesManager.OnLogSourceAnnotationChanged += (sender, e) =>
            {
                RefreshView();
            };

            // todo: create when there a least one postprocessor exists. Postprocessors may come from plugins or it can be internal trace.

            mainFormPresenter.AddCustomTab(view.UIControl, TabCaption, this);
            mainFormPresenter.TabChanging += (sender, e) => OnTabPageSelected(e.CustomTabTag == this);
        }
        public Presenter(
            IView view,
            IManagerInternal postprocessorsManager,
            ICorrelationManager correlationManager,
            IFactory presentersFactory,
            ITempFilesManager tempFiles,
            IShellOpen shellOpen,
            NewLogSourceDialog.IPresenter newLogSourceDialog,
            IChangeNotification changeNotification,
            MainForm.IPresenter mainFormPresenter
            )
        {
            this.view = view;
            this.postprocessorsManager = postprocessorsManager;
            this.correlationManager    = correlationManager;
            this.presentersFactory     = presentersFactory;
            this.tempFiles             = tempFiles;
            this.shellOpen             = shellOpen;
            this.changeNotification    = changeNotification.CreateChainedChangeNotification(false);


            InitAndAddProstprocessorHandler(ViewControlId.StateInspector, PostprocessorKind.StateInspector);
            InitAndAddProstprocessorHandler(ViewControlId.Timeline, PostprocessorKind.Timeline);
            InitAndAddProstprocessorHandler(ViewControlId.Sequence, PostprocessorKind.SequenceDiagram);
            InitAndAddProstprocessorHandler(ViewControlId.Correlate, PostprocessorKind.Correlator);
            InitAndAddProstprocessorHandler(ViewControlId.TimeSeries, PostprocessorKind.TimeSeries);
            viewControlHandlers.Add(ViewControlId.LogsCollectionControl1, new GenericLogsOpenerControlHandler(newLogSourceDialog));
            viewControlHandlers.Add(ViewControlId.AllPostprocessors, new AllPostprocessorsControlHandler(postprocessorsManager, correlationManager));

            this.getControlsData = Selectors.Create(
                () => (
                    viewControlHandlers[ViewControlId.StateInspector].GetCurrentData(),
                    viewControlHandlers[ViewControlId.Timeline].GetCurrentData(),
                    viewControlHandlers[ViewControlId.Sequence].GetCurrentData(),
                    viewControlHandlers[ViewControlId.Correlate].GetCurrentData(),
                    viewControlHandlers[ViewControlId.TimeSeries].GetCurrentData(),
                    viewControlHandlers[ViewControlId.LogsCollectionControl1].GetCurrentData(),
                    viewControlHandlers[ViewControlId.AllPostprocessors].GetCurrentData()
                    ), _ => {
                return(ImmutableDictionary.CreateRange(
                           viewControlHandlers.Select(h => new KeyValuePair <ViewControlId, ControlData>(h.Key, h.Value.GetCurrentData()))
                           ));
            }
                );

            this.getActionStates = Selectors.Create(
                getControlsData,
                ctrlData => ImmutableDictionary.CreateRange(
                    ctrlData.Select(h => {
                Action makeAction(string id) =>
                h.Value.Content.Contains($"*{id}")
                                                        ? () => viewControlHandlers[h.Key].ExecuteAction(id, ClickFlags.None)
                                                        : (Action)null;
                return(new KeyValuePair <ViewControlId, ActionState>(
                           h.Key,
                           new ActionState
                {
                    Enabled = !h.Value.Disabled,
                    Run = makeAction(Constants.RunActionId),
                    Show = makeAction(Constants.ShowVisualizerActionId)
                }
                           ));
            })
                    )
                );

            this.view.SetViewModel(this);

            // todo: create when there a least one postprocessor exists. Postprocessors may come from plugins or it can be internal trace.
            mainFormPresenter.AddCustomTab(view.UIControl, TabCaption, this);
            mainFormPresenter.TabChanging += (sender, e) => this.changeNotification.Active = e.CustomTabTag == this;
        }