Example #1
0
        public TutorialStepPresenter(IStepView view, string contentPath, Lifetime lifetime, ISolution solution, IPsiFiles psiFiles,
                                     TextControlManager textControlManager, IShellLocks shellLocks, IEditorManager editorManager,
                                     DocumentManager documentManager, IUIApplication environment, IActionManager actionManager,
                                     IPsiServices psiServices, IActionShortcuts shortcutManager)
        {
            _stepView          = view;
            Lifetime           = lifetime;
            Solution           = solution;
            PsiFiles           = psiFiles;
            TextControlManager = textControlManager;
            ShellLocks         = shellLocks;
            EditorManager      = editorManager;
            DocumentManager    = documentManager;
            Environment        = environment;
            ActionManager      = actionManager;
            _contentPath       = contentPath;
            _codeNavigator     = new SourceCodeNavigator(lifetime, solution, psiFiles, textControlManager, shellLocks, editorManager,
                                                         documentManager, environment);
            _steps = new Dictionary <int, TutorialStep>();
            _steps = TutorialXmlReader.ReadTutorialSteps(contentPath);

            _currentStepId = TutorialXmlReader.ReadCurrentStep(contentPath);
            CurrentStep    = _steps[_currentStepId];

            lifetime.AddBracket(
                () => { _stepView.NextStep += GoNext; },
                () => { _stepView.NextStep -= GoNext; });

            ProcessStep();
        }
Example #2
0
        public MainChecker(Lifetime lifetime, TutStep.TutorialStep step, ISolution solution, IPsiFiles psiFiles,
                           TextControlManager textControlManager, IShellLocks shellLocks,
                           IEditorManager editorManager, DocumentManager documentManager)
        {
            _lifetime           = lifetime;
            _currentStep        = step;
            _solution           = solution;
            _textControlManager = textControlManager;
            _documentManager    = documentManager;
            _editorManager      = editorManager;

            if (step.Check.Actions != null)
            {
                _stepActionChecker = new StepActionChecker(lifetime, shellLocks, psiFiles);
            }

            if (step.Check.Method == null)
            {
                return;
            }
            _stepPsiChecker = new StepPsiChecker(lifetime, solution, psiFiles,
                                                 shellLocks);
            _stepNavigationChecker = new StepNavigationChecker(lifetime, solution, psiFiles, textControlManager,
                                                               shellLocks);
        }
Example #3
0
        public TutorialWindowRunner([NotNull] Lifetime lifetime, ISolution solution, IPsiFiles psiFiles,
                                    ChangeManager changeManager, [NotNull] ISolutionStateTracker solutionStateTracker,
                                    [NotNull] GlobalSettings globalSettings, TextControlManager textControlManager, IShellLocks shellLocks,
                                    IEditorManager editorManager, DocumentManager documentManager, IUIApplication environment,
                                    IActionManager actionManager,
                                    WindowsHookManager windowsHookManager, IPsiServices psiServices, IActionShortcuts shortcutManager,
                                    IColorThemeManager colorThemeManager, IThreading threading)
        {
            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 (VsIntegration.GetCurrentSolutionPath() == tutorial.Value)
                {
                    solutionStateTracker.AfterSolutionOpened.Advise(lifetime,
                                                                    () =>
                                                                    RunTutorial(globalSettings, tutorial.Key, lifetime, solution, psiFiles, changeManager,
                                                                                textControlManager, shellLocks, editorManager, documentManager, environment,
                                                                                actionManager, windowsHookManager, psiServices, shortcutManager, colorThemeManager,
                                                                                threading));
                }
            }
        }
Example #4
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));
                }
            }
        }
Example #5
0
 public ContextGenerator(TextControlManager textControlManager,
                         IntellisenseManager intellisenseManager,
                         ILogger logger)
 {
     _textControlManager = textControlManager;
     _logger             = logger;
     _solution           = intellisenseManager.Solution;
 }
Example #6
0
        public ContextGenerator(TextControlManager textControlManager,
                                IntellisenseManager intellisenseManager,
                                ILogger logger)
        {
            _textControlManager = textControlManager;
            _documentManager    = intellisenseManager.DocumentManager;
            _logger             = logger;
            _solution           = intellisenseManager.Solution;

            ContextGeneratorCreated(this);
        }
Example #7
0
 public SourceCodeNavigator(Lifetime lifetime, ISolution solution, IPsiFiles psiFiles,
                            TextControlManager textControlManager, IShellLocks shellLocks,
                            IEditorManager editorManager, DocumentManager documentManager, IUIApplication environment)
 {
     _lifetime           = lifetime;
     _solution           = solution;
     _psiFiles           = psiFiles;
     _textControlManager = textControlManager;
     _shellLocks         = shellLocks;
     _documentManager    = documentManager;
     _environment        = environment;
     _editorManager      = editorManager;
 }
Example #8
0
 public UnityCodeInsightFieldUsageProvider(Lifetime lifetime, UnitySolutionTracker unitySolutionTracker, ConnectionTracker connectionTracker,
                                           UnityApi unityApi, UnityHost host, BulbMenuComponent bulbMenu, IPsiFiles files, UnityHost unityHost, UnitySceneDataLocalCache sceneDataCache,
                                           ITooltipManager tooltipManager, TextControlManager textControlManager)
     : base(unitySolutionTracker, host, bulbMenu)
 {
     myLifetime                 = lifetime;
     myConnectionTracker        = connectionTracker;
     myUnityApi                 = unityApi;
     myFiles                    = files;
     myUnityHost                = unityHost;
     myUnitySceneDataLocalCache = sceneDataCache;
     myTooltipManager           = tooltipManager;
     myTextControlManager       = textControlManager;
 }
Example #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(); });
        }
Example #10
0
        public StepNavigationChecker(Lifetime lifetime, ISolution solution, IPsiFiles psiFiles,
                                     TextControlManager textControlManager, IShellLocks shellLocks)
        {
            var lifetime1 = lifetime;

            Solution  = solution;
            _psiFiles = psiFiles;

            EventHandler caretMoved =
                (sender, args) =>
            {
                shellLocks.QueueReadLock(lifetime1, "StepNavigationChecker.CheckOnCaretChange", CheckCode);
            };

            lifetime1.AddBracket(
                () => textControlManager.Legacy.CaretMoved += caretMoved,
                () => textControlManager.Legacy.CaretMoved -= caretMoved);

            OnCheckPass = new Signal <bool>(lifetime, "StepNavigationChecker.AfterNavigationDone");
        }
Example #11
0
        public Checker(Lifetime lifetime, TutorialStep step, ISolution solution, IPsiFiles psiFiles,
                       TextControlManager textControlManager, IShellLocks shellLocks,
                       IEditorManager editorManager, DocumentManager documentManager, IActionManager actionManager,
                       IUIApplication environment)
        {
            _lifetime           = lifetime;
            _currentStep        = step;
            _solution           = solution;
            _psiFiles           = psiFiles;
            _textControlManager = textControlManager;
            _shellLocks         = shellLocks;
            _documentManager    = documentManager;
            _environment        = environment;
            _editorManager      = editorManager;
            _actionManager      = actionManager;

            _stepActionChecker = new StepActionChecker(lifetime, shellLocks, psiFiles, actionManager);
            _stepPsiChecker    = new StepPsiChecker(lifetime, solution, psiFiles, textControlManager, shellLocks, editorManager,
                                                    documentManager, environment);
            _stepNavigationChecker = new StepNavigationChecker(lifetime, solution, psiFiles, textControlManager, shellLocks, editorManager, documentManager, environment);
        }
Example #12
0
        public TutorialStepPresenter(IStepView view, string contentPath, Lifetime lifetime, ISolution solution,
                                     IPsiFiles psiFiles,
                                     ChangeManager changeManager, TextControlManager textControlManager, IShellLocks shellLocks,
                                     IEditorManager editorManager,
                                     DocumentManager documentManager, IUIApplication environment, IActionManager actionManager)
        {
            _stepView          = view;
            _lifetime          = lifetime;
            Solution           = solution;
            PsiFiles           = psiFiles;
            ChangeManager      = changeManager;
            TextControlManager = textControlManager;
            ShellLocks         = shellLocks;
            EditorManager      = editorManager;
            DocumentManager    = documentManager;
            Environment        = environment;
            ActionManager      = actionManager;
            _codeNavigator     = new SourceCodeNavigator(lifetime, solution, psiFiles, shellLocks,
                                                         editorManager,
                                                         documentManager);
            _steps = new Dictionary <int, TutorialStep>();

            var tutorialXmlReader = new TutorialXmlReader(actionManager);

            _steps = tutorialXmlReader.ReadTutorialSteps(contentPath);

            Title = TutorialXmlReader.ReadTitle(contentPath);

            //TODO: get rid of _currentStepId
            _currentStepId      = 1;
            CurrentStep         = _steps[_currentStepId];
            _stepView.StepCount = _steps.Count;

            lifetime.AddBracket(
                () => { _stepView.NextStep += StepOnStepIsDone; },
                () => { _stepView.NextStep -= StepOnStepIsDone; });

            ProcessCurrentStep();
        }
Example #13
0
        public StepPsiChecker(Lifetime lifetime, ISolution solution, IPsiFiles psiFiles,
                              TextControlManager textControlManager, IShellLocks shellLocks,
                              IEditorManager editorManager, DocumentManager documentManager, IUIApplication environment)
        {
            _lifetime           = lifetime;
            _solution           = solution;
            _psiFiles           = psiFiles;
            _textControlManager = textControlManager;
            _shellLocks         = shellLocks;
            _documentManager    = documentManager;
            _environment        = environment;
            _editorManager      = editorManager;

            Action <ITreeNode, PsiChangedElementType> psiChanged =
                (_, __) => OnPsiChanged();

            _lifetime.AddBracket(
                () => psiFiles.AfterPsiChanged += psiChanged,
                () => psiFiles.AfterPsiChanged -= psiChanged);

            AfterPsiChangesDone = new Signal <bool>(lifetime, "StepPsiChecker.AfterPsiChangesDone");
        }
Example #14
0
        public StepNavigationChecker(Lifetime lifetime, ISolution solution, IPsiFiles psiFiles,
                                     TextControlManager textControlManager, IShellLocks shellLocks,
                                     IEditorManager editorManager, DocumentManager documentManager, IUIApplication environment)
        {
            _lifetime           = lifetime;
            _solution           = solution;
            _psiFiles           = psiFiles;
            _textControlManager = textControlManager;
            _shellLocks         = shellLocks;
            _documentManager    = documentManager;
            _environment        = environment;
            _editorManager      = editorManager;

            EventHandler caretMoved = (sender, args) =>
            {
                _shellLocks.QueueReadLock(_lifetime, "StepNavigationChecker.CheckOnCaretChange", CheckCode);
            };

            _lifetime.AddBracket(
                () => textControlManager.Legacy.CaretMoved += caretMoved,
                () => textControlManager.Legacy.CaretMoved -= caretMoved);

            AfterNavigationDone = new Signal <bool>(lifetime, "StepNavigationChecker.AfterNavigationDone");
        }
Example #15
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);
            }
        }
Example #16
0
        private static void RunTutorial(GlobalSettings globalSettings, int tutorialId, Lifetime lifetime,
                                        ISolution solution,
                                        IPsiFiles psiFiles, ChangeManager changeManager, TextControlManager textControlManager,
                                        IShellLocks shellLocks,
                                        IEditorManager editorManager, DocumentManager documentManager, IUIApplication environment,
                                        IActionManager actionManager,
                                        WindowsHookManager windowsHookManager, IPsiServices psiServices, IActionShortcuts shortcutManager,
                                        IColorThemeManager colorThemeManager, IThreading threading)
        {
            if (globalSettings.TutorialWindowManager == null)
            {
                throw new ApplicationException("Expected globalSettings.TutorialWindowManager");
            }

            globalSettings.TutorialWindowManager.ShowTutorialWindow(tutorialId, lifetime, solution, psiFiles,
                                                                    changeManager,
                                                                    textControlManager, shellLocks, editorManager, documentManager, environment, actionManager,
                                                                    windowsHookManager, psiServices, shortcutManager, colorThemeManager, threading);
        }
Example #17
0
        public TutorialWindow(string contentPath, Lifetime tutorialLifetime, TutorialWindowManager windowManager,
                              ISolution solution, IPsiFiles psiFiles,
                              ChangeManager changeManager, TextControlManager textControlManager, IShellLocks shellLocks,
                              IEditorManager editorManager,
                              DocumentManager documentManager, IUIApplication environment, IActionManager actionManager,
                              TabbedToolWindowClass toolWindowClass,
                              WindowsHookManager windowsHookManager,
                              IColorThemeManager colorThemeManager)
        {
            _windowManager     = windowManager;
            _htmlGenerator     = new HtmlGenerator(tutorialLifetime, colorThemeManager);
            _tutorialLifetime  = tutorialLifetime;
            _shellLocks        = shellLocks;
            _colorThemeManager = colorThemeManager;

            if (!solution.GetComponent <ISolutionOwner>().IsRealSolutionOwner)
            {
                return;
            }

            _toolWindowInstance = toolWindowClass.RegisterInstance(
                tutorialLifetime, null, null,
                (lt, twi) =>
            {
                twi.QueryClose.Value = true;

                var containerControl = new TutorialPanel(environment).BindToLifetime(lt);

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

                var webControlHandler = new WebBrowserHostUiHandler(viewControl)
                {
                    Flags = HostUIFlags.DPI_AWARE,
                    IsWebBrowserContextMenuEnabled = false
                };

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

                lt.AddAction(() => _progressBar = null);

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

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

                _colorThemeManager.ColorThemeChanged.Advise(tutorialLifetime, RefreshKeepContent);

                SetColors();

                _htmlMediator = new HtmlMediator(tutorialLifetime, this);
                _htmlMediator.OnNextStepButtonClick.Advise(tutorialLifetime,
                                                           () => NextStep?.Invoke(null, EventArgs.Empty));
                _htmlMediator.OnRunStepNavigationLinkClick.Advise(tutorialLifetime, NavigateToCodeByLink);

                var focusTracker = new WindowFocusTracker(tutorialLifetime);
                focusTracker.IsFocusOnEditor.Change.Advise(tutorialLifetime,
                                                           () => _htmlMediator.ChangeNextStepButtonText(focusTracker.IsFocusOnEditor.Value));

                _htmlMediator.OnPageHasFullyLoaded.Advise(tutorialLifetime,
                                                          () => { _htmlMediator.ChangeNextStepButtonText(focusTracker.IsFocusOnEditor.Value); });

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

            _stepPresenter = new TutorialStepPresenter(this, contentPath, tutorialLifetime, solution, psiFiles,
                                                       changeManager,
                                                       textControlManager, shellLocks, editorManager, documentManager, environment, actionManager);

            _toolWindowInstance.Title.Value = _stepPresenter.Title;
        }
Example #18
0
        public void ShowTutorialWindow(int tutorialId, Lifetime lifetime,
                                       ISolution solution, IPsiFiles psiFiles, ChangeManager changeManager, TextControlManager textControlManager,
                                       IShellLocks shellLocks, IEditorManager editorManager, DocumentManager documentManager,
                                       IUIApplication environment,
                                       IActionManager actionManager, WindowsHookManager windowsHookManager, IPsiServices psiServices,
                                       IActionShortcuts shortcutManager, IColorThemeManager colorThemeManager, IThreading threading)
        {
            var contentPath = _globalSettings.GetPath(tutorialId, PathType.WorkCopyContentFile);

            _runningTutorial = tutorialId;

            threading.ExecuteOrQueue("RunTutorialWindow", () =>
            {
                _tutorialWindow = new TutorialWindow(contentPath, lifetime, this, solution, psiFiles, changeManager,
                                                     textControlManager,
                                                     shellLocks, editorManager, documentManager, environment, actionManager, _toolWindowClass,
                                                     windowsHookManager, colorThemeManager);

                lifetime.AddBracket(
                    () =>
                {
                    _tutorialWindow.Show();
                    _homeWindow.HideLoadingImages();
                },
                    () =>
                {
                    _tutorialWindow.Close();
                    _tutorialWindow  = null;
                    _runningTutorial = 0;
                    _homeWindow.EnableButtons(true);
                });
            });
        }