Example #1
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 #2
0
        public void OpenOrRestart(IDataContext context, TutorialId id)
        {
            var globalOptions = context.GetComponent <GlobalSettings>();
            var titleString   = TutorialXmlReader.ReadIntro(globalOptions.GetPath(id, PathType.WorkCopyContentFile));
            var step          = TutorialXmlReader.ReadCurrentStep(globalOptions.GetPath(id, PathType.WorkCopyContentFile));
            var firstTime     = step == 1;

            var titleWnd = new TitleWindow(titleString, firstTime);

            if (titleWnd.ShowDialog() != true)
            {
                return;
            }
            if (titleWnd.Restart)
            {
                SolutionCopyHelper.CopySolution(globalOptions.GetPath(id, PathType.BaseSolutionFolder),
                                                globalOptions.GetPath(id, PathType.WorkCopySolutionFolder));

                GC.Collect();
                TutorialXmlReader.WriteCurrentStep(globalOptions.GetPath(id, PathType.WorkCopyContentFile), "1");

                VsCommunication.OpenVsSolution(globalOptions.GetPath(id, PathType.WorkCopySolutionFile));
            }
            else
            {
                VsCommunication.OpenVsSolution(globalOptions.GetPath(id, PathType.WorkCopySolutionFile));
            }
        }
Example #3
0
        public void Close()
        {
            foreach (var toolWindowInstance in _toolWindowClass.Instances)
            {
                toolWindowInstance.Close();
            }

            _toolWindowClass.Close();
            VsCommunication.CloseVsSolution(true);
        }
Example #4
0
        public StepActionChecker(Lifetime lifetime, IShellLocks shellLocks, IPsiFiles psiFiles, IActionManager actionManager)
        {
            _shellLocks = shellLocks;
            _psiFiles   = psiFiles;
            _vsInstance = VsCommunication.GetCurrentVsInstance();
            var events2 = _vsInstance?.Events as Events2;

            if (events2 == null)
            {
                return;
            }

            _commandEvents = events2.CommandEvents;

            lifetime.AddBracket(
                () => _commandEvents.AfterExecute += CommandEventsOnAfterExecute,
                () => _commandEvents.AfterExecute -= CommandEventsOnAfterExecute);

            AfterActionApplied = new Signal <bool>(lifetime, "StepActionChecker.AfterActionApplied");
        }
Example #5
0
        public static void NavigateToText(ICSharpFile file, string typeName, string methodName, string text, int textOcc, IShellLocks shellLocks, Lifetime lifetime)
        {
            var treeNodeList = file.EnumerateTo(file.LastChild);

            var methods = (from treeNode in treeNodeList
                           let element = GetDeclaredElement(treeNode)
                                         let typeElement = element as ITypeElement
                                                           where typeElement != null
                                                           where typeElement.GetFullClrName() == typeName
                                                           select typeElement.GetAllMethods()).FirstOrDefault();

            if (methods == null)
            {
                return;
            }

            var targetMethod = methods.FirstOrDefault(method => method.ShortName == methodName);

            shellLocks.ReentrancyGuard.ExecuteOrQueue("Navigate", () => { targetMethod.Navigate(true); });
            shellLocks.ReentrancyGuard.ExecuteOrQueue("FindText", () =>
            {
                VsCommunication.NavigateToTextInCurrentDocument(text, textOcc);
            });
        }
Example #6
0
 public void Close(object sender, RoutedEventArgs args)
 {
     VsCommunication.CloseVsSolution(true);
 }