예제 #1
0
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            RegisterExceptionHandler();

            await base.InitializeAsync(cancellationToken, progress);

            var hostWorkspaceGateway = new HostWorkspaceGateway(this);
            var hostUiGateway        = new HostUiGateway(this);

            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            _diagramToolApplication = new DiagramToolApplication(hostWorkspaceGateway, hostUiGateway);

            RegisterShellCommands(GetMenuCommandService(), _diagramToolApplication);
        }
예제 #2
0
        protected override void Initialize()
        {
            base.Initialize();

            // This is needed otherwise VS catches the exception and shows no stack trace.
            Dispatcher.CurrentDispatcher.UnhandledException += (sender, args) =>
            {
#if DEBUG
                System.Diagnostics.Debugger.Break();
#else
                Trace.WriteLine($"[{PackageInfo.ToolName}] unhandled exception: {args.Exception}");
#endif
            };

            _visualStudioServiceProvider = GetGlobalService(typeof(IVisualStudioServiceProvider)) as IVisualStudioServiceProvider;
            if (_visualStudioServiceProvider == null)
            {
                throw new Exception("Unable to get IVisualStudioServiceProvider.");
            }

            _componentModel = GetGlobalService(typeof(SComponentModel)) as IComponentModel;
            if (_componentModel == null)
            {
                throw new Exception("Unable to get IComponentModel.");
            }

            var hostWorkspaceGateway = new HostWorkspaceGateway(this);
            var hostUiGateway        = new HostUiGateway(this);

            _visualizationService = CreateVisualizationService(hostWorkspaceGateway, hostUiGateway);
            var diagramId = _visualizationService.CreateDiagram(minZoom: .1, maxZoom: 10, initialZoom: 1);

            _diagramToolApplication = new DiagramToolApplication(
                _visualizationService.GetRoslynModelService(),
                _visualizationService.GetRoslynDiagramService(diagramId),
                _visualizationService.GetRoslynUiService(diagramId));

            RegisterShellCommands(GetMenuCommandService(), _diagramToolApplication);
        }
예제 #3
0
        protected override void Initialize()
        {
            base.Initialize();

            // This is needed otherwise VS catches the exception and shows no stack trace.
            Dispatcher.CurrentDispatcher.UnhandledException += (sender, args) =>
            {
#if DEBUG
                System.Diagnostics.Debugger.Break();
#else
                return;
#endif
            };

            _visualStudioServiceProvider = GetGlobalService(typeof(IVisualStudioServiceProvider)) as IVisualStudioServiceProvider;
            if (_visualStudioServiceProvider == null)
            {
                throw new Exception("Unable to get IVisualStudioServiceProvider.");
            }

            _componentModel = GetGlobalService(typeof(SComponentModel)) as IComponentModel;
            if (_componentModel == null)
            {
                throw new Exception("Unable to get IComponentModel.");
            }

            var hostWorkspaceGateway = new HostWorkspaceGateway(this);
            var hostUiGateway        = new HostUiGateway(this);

            var modelServices   = new RoslynBasedModelBuilder(hostWorkspaceGateway);
            var diagramServices = new RoslynBasedDiagram(modelServices);
            var uiServices      = new DiagramUi(hostUiGateway, diagramServices);

            _diagramToolApplication = new DiagramToolApplication(modelServices, diagramServices, uiServices);

            RegisterShellCommands(GetMenuCommandService(), _diagramToolApplication);
        }