public GraphCodeWindowRegistrar(Lifetime lifetime, ToolWindowManager toolWindowManager,
                                     GraphCodeToolWindow descriptor, UIApplication environment)
 {
     _environment = environment;
     _lifetime = lifetime;
     
     _toolWindowClass = toolWindowManager.Classes[descriptor];
     //_toolWindowClass.RegisterEmptyContent(
     //  lifetime,
     //  lt =>
     //  {
     //      var graphs = (new GraphLoader()).Load();
     //      var tabControl = new System.Windows.Controls.TabControl();
     //      var zcontrols = new List<ZoomControl>();
     //      foreach (var graph in graphs)
     //      {
     //          var gArea = InitializeGraphArea.Initialize(graph);
     //          var zcontrol = new ZoomControl();
     //          zcontrol.Content = gArea;
     //          zcontrols.Add(zcontrol);
     //      }
     //      tabControl.ItemsSource = zcontrols;
     //      return (new EitherControl(tabControl)).BindToLifetime(lt);
     //  });
 }
示例#2
0
        public Tool(IPackageContext packageContext, IBuildInfo buildContext, IBuildDistributor buildDistributor, ControlViewModel viewModel)
        {
            _packageContext = packageContext;
            _dte            = packageContext.GetDTE();
            _dte2           = packageContext.GetDTE2();
            if (_dte == null)
            {
                throw new InvalidOperationException("Unable to get DTE instance.");
            }

            _dteStatusBar = packageContext.GetStatusBar();
            if (_dteStatusBar == null)
            {
                TraceManager.TraceError("Unable to get IVsStatusbar instance.");
            }

            _toolWindowManager = new ToolWindowManager(packageContext);

            _buildContext     = buildContext;
            _buildDistributor = buildDistributor;

            _viewModel      = viewModel;
            _solutionEvents = _dte.Events.SolutionEvents;

            Initialize();
        }
示例#3
0
        public TutorialRunner([NotNull] Lifetime lifetime, ISolution solution, IPsiFiles psiFiles,
                              [NotNull] ISolutionStateTracker solutionStateTracker,
                              [NotNull] GlobalSettings globalSettings, TextControlManager textControlManager, IShellLocks shellLocks,
                              IEditorManager editorManager, DocumentManager documentManager, IUIApplication environment,
                              IActionManager actionManager, ToolWindowManager toolWindowManager, TutorialWindowDescriptor tutorialWindowDescriptor,
                              IWindowsHookManager windowsHookManager, IPsiServices psiServices, IActionShortcuts shortcutManager,
                              IColorThemeManager colorThemeManager)
        {
            if (lifetime == null)
            {
                throw new ArgumentNullException("lifetime");
            }
            if (solutionStateTracker == null)
            {
                throw new ArgumentNullException("solutionStateTracker");
            }
            if (globalSettings == null)
            {
                throw new ArgumentNullException("globalSettings");
            }


            foreach (var tutorial in globalSettings.AvailableTutorials)
            {
                if (VsCommunication.GetCurrentSolutionPath() == tutorial.Value)
                {
                    solutionStateTracker.AfterPsiLoaded.Advise(lifetime,
                                                               sol => RunTutorial(globalSettings.GetPath(tutorial.Key, PathType.WorkCopyContentFile), lifetime, solution, psiFiles,
                                                                                  textControlManager, shellLocks, editorManager, documentManager, environment, actionManager, toolWindowManager,
                                                                                  tutorialWindowDescriptor, windowsHookManager, psiServices, shortcutManager, colorThemeManager));
                }
            }
        }
        public TypeInterfaceToolWindowRegistrar(Lifetime lifetime,
                                                ToolWindowManager toolWindowManager,
                                                IShellLocks locks,
                                                ISettingsStore settingsStore,
                                                IActionManager actionManager,
                                                IActionBarManager actionBarManager,
                                                IShortcutManager shortcutManager,
                                                TypeInterfaceToolWindowDescriptor toolWindowDescriptor,
                                                ITheming theming,
                                                IThemedIconManager themedIconManager, IColorThemeManager colorThemeManager)
        {
            myLifetime          = lifetime;
            myLocks             = locks;
            mySettingsStore     = settingsStore;
            myActionBarManager  = actionBarManager;
            myTheming           = theming;
            myThemedIconManager = themedIconManager;
            myColorThemeManager = colorThemeManager;

            myToolWindowClass = toolWindowManager.Classes[toolWindowDescriptor];
            myToolWindowClass.RegisterEmptyContent(
                lifetime,
                lt =>
            {
                var emptyLabel = new RichTextLabel {
                    BackColor = SystemColors.Control, Dock = DockStyle.Fill
                };
                emptyLabel.RichTextBlock.Add(new RichText("No hierarchies open", new TextStyle(FontStyle.Bold)));
                emptyLabel.RichTextBlock.Add(
                    new RichText("Use " + actionManager.GetHowToExecuteAction(shortcutManager, typeof(BrowseTypeHierarchyAction)), TextStyle.Default));
                emptyLabel.RichTextBlock.Add(new RichText("on a type to see hierarchy", TextStyle.Default));
                emptyLabel.RichTextBlock.Parameters = new RichTextBlockParameters(8, ContentAlignment.MiddleCenter);
                return(emptyLabel.BindToLifetime(lt));
            });
        }
示例#5
0
        public TypeInterfaceToolWindowRegistrar(Lifetime lifetime,
                                                ToolWindowManager toolWindowManager,
                                                IActionManager actionManager,
                                                IActionBarManager actionBarManager,
                                                IShortcutManager shortcutManager,
                                                TypeInterfaceToolWindowDescriptor toolWindowDescriptor,
                                                IUIApplication environment,
                                                IWindowsHookManager windowsHookManager)
        {
            _lifetime           = lifetime;
            _actionBarManager   = actionBarManager;
            _environment        = environment;
            _windowsHookManager = windowsHookManager;

            _toolWindowClass = toolWindowManager.Classes[toolWindowDescriptor];
            _toolWindowClass.RegisterEmptyContent(
                lifetime,
                lt =>
            {
                var emptyLabel = new RichTextLabel(environment)
                {
                    BackColor = SystemColors.Control, Dock = DockStyle.Fill
                };
                emptyLabel.RichTextBlock.Add(new RichText("No hierarchies open", new TextStyle(FontStyle.Bold)));
                emptyLabel.RichTextBlock.Add(
                    new RichText("Use " + actionManager.GetHowToExecuteAction(shortcutManager, typeof(BrowseTypeHierarchyAction)), TextStyle.Default));
                emptyLabel.RichTextBlock.Add(new RichText("on a type to see hierarchy", TextStyle.Default));
                emptyLabel.RichTextBlock.Parameters = new RichTextBlockParameters(8, ContentAlignment.MiddleCenter);
                return(emptyLabel.BindToLifetime(lt));
            });
        }
示例#6
0
        public GraphCodeWindowRegistrar(Lifetime lifetime, ToolWindowManager toolWindowManager,
                                        GraphCodeToolWindow descriptor, UIApplication environment)
        {
            _environment = environment;
            _lifetime    = lifetime;

            _toolWindowClass = toolWindowManager.Classes[descriptor];
            //_toolWindowClass.RegisterEmptyContent(
            //  lifetime,
            //  lt =>
            //  {
            //      var graphs = (new GraphLoader()).Load();
            //      var tabControl = new System.Windows.Controls.TabControl();
            //      var zcontrols = new List<ZoomControl>();
            //      foreach (var graph in graphs)
            //      {
            //          var gArea = InitializeGraphArea.Initialize(graph);
            //          var zcontrol = new ZoomControl();
            //          zcontrol.Content = gArea;
            //          zcontrols.Add(zcontrol);
            //      }
            //      tabControl.ItemsSource = zcontrols;
            //      return (new EitherControl(tabControl)).BindToLifetime(lt);
            //  });
        }
 public ActiveTaskWindowRegistrar(Lifetime lifetime, ToolWindowManager toolWindowManager,
                                  ActiveTaskWindowDescriptor descriptor, TaskViewModel viewModel)
 {
     _toolWindowClass = toolWindowManager.Classes[descriptor];
     _toolWindowClass.RegisterEmptyContent(lifetime,
                                           lt =>
     {
         var control = new ActiveTaskWindow(viewModel);
         var wrapper = new EitherControl(control);
         return(wrapper.BindToLifetime(lt));
     }
                                           );
 }
示例#8
0
 public MainNavigationRegistrar(Lifetime lifetime, ToolWindowManager toolWindowManager,
                                MainNavigationDescriptor descriptor, TaskViewModel viewModel, IconsSettingsRepository settingsRepository)
 {
     Directory.CreateDirectory(PersistenceConstants.AppFolder);
     _toolWindowClass = toolWindowManager.Classes[descriptor];
     _toolWindowClass.RegisterEmptyContent(
         lifetime,
         lt =>
     {
         var control = new MainNavigationControl(viewModel);
         var wrapper = new EitherControl(control);
         return(wrapper.BindToLifetime(lt));
     });
 }
示例#9
0
        private static void RunTutorial(string contentPath, Lifetime lifetime, ISolution solution, IPsiFiles psiFiles,
                                        TextControlManager textControlManager, IShellLocks shellLocks, IEditorManager editorManager,
                                        DocumentManager documentManager, IUIApplication environment, IActionManager actionManager,
                                        ToolWindowManager toolWindowManager, TutorialWindowDescriptor tutorialWindowDescriptor,
                                        IWindowsHookManager windowsHookManager, IPsiServices psiServices, IActionShortcuts shortcutManager,
                                        IColorThemeManager colorThemeManager)
        {
            var tutorialWindow = new TutorialWindow(contentPath, lifetime, solution, psiFiles, textControlManager, shellLocks, editorManager,
                                                    documentManager, environment, actionManager, toolWindowManager, tutorialWindowDescriptor, windowsHookManager,
                                                    psiServices, shortcutManager, colorThemeManager);

            lifetime.AddBracket(
                () => { tutorialWindow.Show(); },
                () => { tutorialWindow.Close(); });
        }
示例#10
0
        public TutorialWindowManager(Lifetime shellLifetime, SolutionStateTracker solutionStateTracker,
                                     GlobalSettings globalSettings,
                                     IShellLocks shellLocks, ToolWindowManager toolWindowManager, TutorialWindowDescriptor toolWindowDescriptor,
                                     IUIApplication environment, IActionManager actionManager, IWindowsHookManager windowsHookManager,
                                     IColorThemeManager colorThemeManager, IThreading threading)
        {
            _shellLifetime        = shellLifetime;
            _solutionStateTracker = solutionStateTracker;
            _globalSettings       = globalSettings;
            _shellLocks           = shellLocks;
            _environment          = environment;
            _actionManager        = actionManager;
            _windowsHookManager   = windowsHookManager;
            _colorThemeManager    = colorThemeManager;
            _threading            = threading;

            _runningTutorial = 0;

            _toolWindowClass = toolWindowManager.Classes[toolWindowDescriptor] as TabbedToolWindowClass;
            if (_toolWindowClass == null)
            {
                throw new ApplicationException("Expected tabbed tool window");
            }

            _toolWindowClass.QueryCloseInstances.Advise(shellLifetime, args =>
            {
                if (_runningTutorial == 0)
                {
                    return;
                }
                if (!_tutorialWindow.IsLastStep)
                {
                    args.Cancel = !MessageBox.ShowYesNo(
                        "This will close the tutorial solution as well. Tutorial progress will be lost. Close the tutorial?",
                        "ReSharper Tutorials");
                    if (args.Cancel)
                    {
                        return;
                    }
                }
                VsIntegration.CloseVsSolution(true);
            });
        }
示例#11
0
        public YouTrackExplorerWindowRegistrar(Lifetime lifetime, ToolWindowManager toolWindowManager,
                                               YouTrackExplorerWindowDescriptor descriptor, IUIApplication application)
        {
            this.lifetime    = lifetime;
            this.application = application;

            toolWindowClass = toolWindowManager.Classes[descriptor];
            toolWindowClass.RegisterEmptyContent(
                lifetime,
                lt =>
            {
                // initialize the default ('empty') content for the tool window
                var label = new RichTextLabel(application)
                {
                    BackColor = SystemColors.Control, Dock = DockStyle.Fill
                };
                label.RichTextBlock.Add(new RichText("Nothing Here", new TextStyle(FontStyle.Bold)));
                label.RichTextBlock.Parameters = new RichTextBlockParameters(8, ContentAlignment.MiddleCenter);
                return(label.BindToLifetime(lt));
            });
        }
示例#12
0
 public SessionManagerWindowRegistrar(Lifetime lifetime,
                                      ToolWindowManager toolWindowManager,
                                      SessionManagerWindowDescriptor descriptor,
                                      ActionExecutor actionExecutor,
                                      ILogManager logManager,
                                      IExporter exporter,
                                      ISettingsStore settingsStore)
 {
     // objects are kept in fields to prevent garbage collection
     _toolWindowClass = toolWindowManager.Classes[descriptor];
     _toolWindowClass.RegisterEmptyContent(
         lifetime,
         lt =>
     {
         var visibilitySignal = _toolWindowClass.Visible.Change;
         var control          = new SessionManagerControl(
             new FeedbackViewModel(logManager, exporter),
             actionExecutor,
             settingsStore);
         visibilitySignal.Advise(lt, control.OnVisibilityChanged);
         var wrapper = new EitherControl(control);
         return(wrapper.BindToLifetime(lt));
     });
 }
示例#13
0
        public TutorialWindow(string contentPath, Lifetime lifetime, ISolution solution, IPsiFiles psiFiles,
                              TextControlManager textControlManager, IShellLocks shellLocks, IEditorManager editorManager,
                              DocumentManager documentManager, IUIApplication environment, IActionManager actionManager,
                              ToolWindowManager toolWindowManager, TutorialWindowDescriptor toolWindowDescriptor,
                              IWindowsHookManager windowsHookManager, IPsiServices psiServices, IActionShortcuts shortcutManager,
                              IColorThemeManager colorThemeManager)
        {
            _lifetime          = lifetime;
            _solution          = solution;
            _actionManager     = actionManager;
            _shellLocks        = shellLocks;
            _psiServices       = psiServices;
            _shortcutManager   = shortcutManager;
            _colorThemeManager = colorThemeManager;
            _toolWindowClass   = toolWindowManager.Classes[toolWindowDescriptor];

            if (solution.GetComponent <ISolutionOwner>().IsRealSolutionOwner)
            {
                var toolWindowInstance = _toolWindowClass.RegisterInstance(
                    lifetime, null, null,
                    (lt, twi) =>
                {
                    var containerControl = new TutorialPanel(environment).BindToLifetime(lt);

                    var viewControl = new HtmlViewControl(windowsHookManager, actionManager)
                    {
                        Dock = DockStyle.Fill,
                    }.BindToLifetime(lt);

                    var buttonNext = new Button
                    {
                        Text           = "Next",
                        Anchor         = AnchorStyles.Bottom | AnchorStyles.Right,
                        FlatStyle      = FlatStyle.Flat,
                        FlatAppearance = { BorderColor = Color.Gray, BorderSize = 1 }
                    };

                    lt.AddBracket(
                        () => _buttonNext = buttonNext,
                        () => _buttonNext = null);

                    _buttonNext.Top  = containerControl.Height - _buttonNext.Height - 10;
                    _buttonNext.Left = containerControl.Width - _buttonNext.Width - 25;

                    lt.AddBracket(
                        () => _containerControl = containerControl,
                        () => _containerControl = null);

                    lt.AddBracket(
                        () => _viewControl = viewControl,
                        () => _viewControl = null);

                    lt.AddBracket(
                        () => { _buttonNext.Click += NextStep; },
                        () => { _buttonNext.Click -= NextStep; });

                    lt.AddBracket(
                        () => _containerControl.Controls.Add(_buttonNext),
                        () => _containerControl.Controls.Remove(_buttonNext));

                    lt.AddBracket(
                        () => _containerControl.Controls.Add(_viewControl),
                        () => _containerControl.Controls.Remove(_viewControl));

                    _colorThemeManager.ColorThemeChanged.Advise(lifetime, RefreshKeepContent);

                    SetColors();

                    return(new EitherControl(lt, containerControl));
                });

                _toolWindowClass.QueryCloseInstances.Advise(_lifetime, args => { Close(); });    // not working

                _stepPresenter = new TutorialStepPresenter(this, contentPath, lifetime, solution, psiFiles, textControlManager,
                                                           shellLocks, editorManager, documentManager, environment, actionManager, psiServices, shortcutManager);
            }
        }
示例#14
0
 private static void ShowReport(object o)
 {
     ReportViewModel.ActiveReport = o as IAnalysisReport;
     ToolWindowManager.ShowToolPane().Result?.ShowView <IAnalyzerDetailViewModel>();
 }
示例#15
0
        public SampleToolWindow(Lifetime lifetime, ToolWindowManager toolWindowManager,
                                SampleToolWindowDescriptor sampleToolWindowDescriptor, ISettingsStore settingsStore,
                                IColorThemeManager colorThemeManager)
        {
            _toolWindowClass = toolWindowManager.Classes[sampleToolWindowDescriptor] as TabbedToolWindowClass;
            if (_toolWindowClass == null)
            {
                throw new ApplicationException("ToolWindowClass");
            }

            _toolWindowInstance = _toolWindowClass.RegisterInstance(lifetime, "Sample Tool Window", null,
                                                                    (lt, twi) =>
            {
                twi.QueryClose.Value = true;

                var toolPanel = new ToolPanel();

                // Tool Window
                var toolwndView    = new ToolWindowView();
                var toolwndViewTab = new TabItem
                {
                    Content = toolwndView,
                    Header  = toolwndView.Name
                };
                toolPanel.tabControl.Items.Add(toolwndViewTab);

                // Options
                var optionsPageViewModel = new OptionsPageViewModel(lt, settingsStore);
                var optionsPageView      = new OptionsPageView {
                    DataContext = optionsPageViewModel
                };
                var optionsPageViewTab = new TabItem
                {
                    Content = optionsPageView,
                    Header  = optionsPageView.Name
                };
                toolPanel.tabControl.Items.Add(optionsPageViewTab);

                // Actions
                var actionsViewModel = new ActionsViewModel(lt);
                var actionsView      = new ActionsView {
                    DataContext = actionsViewModel
                };
                var actionsViewTab = new TabItem
                {
                    Content = actionsView,
                    Header  = actionsView.Name
                };
                toolPanel.tabControl.Items.Add(actionsViewTab);

                // PSI Navigation
                var psiNavigationViewModel = new PsiNavigationViewModel(lt);
                var psiNavigationView      = new PsiNavigationView {
                    DataContext = psiNavigationViewModel
                };
                var psiNavigationViewTab = new TabItem
                {
                    Content = psiNavigationView,
                    Header  = psiNavigationView.Name
                };
                toolPanel.tabControl.Items.Add(psiNavigationViewTab);

                // Context Action
                var contextActionView    = new ToLowerCaseContextActionView();
                var contextActionViewTab = new TabItem
                {
                    Content = contextActionView,
                    Header  = contextActionView.Name
                };
                toolPanel.tabControl.Items.Add(contextActionViewTab);

                // Quick Fix
                var quickFixView    = new CorrectBadWordQuickFixView();
                var quickFixViewTab = new TabItem
                {
                    Content = quickFixView,
                    Header  = quickFixView.Name
                };
                toolPanel.tabControl.Items.Add(quickFixViewTab);

                // Element Problem Analyzer and Code Highlighting
                var problemAnalyzerView    = new BadWordNamingView();
                var problemAnalyzerViewTab = new TabItem
                {
                    Content = problemAnalyzerView,
                    Header  = problemAnalyzerView.Name
                };
                toolPanel.tabControl.Items.Add(problemAnalyzerViewTab);

                // Solution Component
                var solcompView    = new SolutionComponentView();
                var solcompViewTab = new TabItem
                {
                    Content = solcompView,
                    Header  = solcompView.Name
                };
                toolPanel.tabControl.Items.Add(solcompViewTab);

                // Signals
                var sigViewModel = new SignalsViewModel(lt);
                var sigView      = new SignalsView {
                    DataContext = sigViewModel
                };
                var sigViewTab = new TabItem
                {
                    Content = sigView,
                    Header  = sigView.Name
                };
                toolPanel.tabControl.Items.Add(sigViewTab);

                // IProperty
                var propViewModel = new PropertyViewModel(lt);
                var propView      = new PropertyView {
                    DataContext = propViewModel
                };
                var propViewTab = new TabItem
                {
                    Content = propView,
                    Header  = propView.Name
                };
                toolPanel.tabControl.Items.Add(propViewTab);

                // UI Themes
                var uithemeViewModel = new UiThemeViewModel(lt, colorThemeManager);
                var uithemeView      = new UiThemeView {
                    DataContext = uithemeViewModel
                };
                var uithemeViewTab = new TabItem
                {
                    Content = uithemeView,
                    Header  = uithemeView.Name
                };
                toolPanel.tabControl.Items.Add(uithemeViewTab);

                return(new EitherControl(lt, toolPanel));
            });
        }