예제 #1
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));
                }
            }
        }
예제 #2
0
 public T4TestsDeclaredAssembliesManager(
     Lifetime lifetime,
     [NotNull] IPsiFiles psiFiles,
     [NotNull] IShellLocks locks
     ) : base(lifetime, psiFiles, locks)
 {
 }
 public GotoRecentFilesAction(Lifetime lifetime, Agent agent, ISolution solution, IShellLocks shellLocks,
                              IPsiFiles psiFiles, RecentFilesTracker tracker,
                              OccurencePresentationManager presentationManager,
                              MainWindowPopupWindowContext popupWindowContext)
     : base(lifetime, agent, solution, shellLocks, psiFiles, tracker, presentationManager, popupWindowContext)
 {
 }
예제 #4
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();
        }
예제 #5
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));
                }
            }
        }
예제 #6
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);
                });
            });
        }
예제 #7
0
 public SourceCodeNavigator(Lifetime lifetime, ISolution solution, IPsiFiles psiFiles, IShellLocks shellLocks,
                            IEditorManager editorManager, DocumentManager documentManager)
 {
     _lifetime        = lifetime;
     _solution        = solution;
     _psiFiles        = psiFiles;
     _shellLocks      = shellLocks;
     _documentManager = documentManager;
     _editorManager   = editorManager;
 }
예제 #8
0
        public AttributedTypesCache(Lifetime lifetime, IDependencyStore dependencyStore, IShellLocks shellLocks, IPsiConfiguration psiConfiguration, IPersistentIndexManager persistentIndexManager, CommonIdentifierIntern identifierIntern, AttributedTypesCacheBuilder builder, ISolution solution, IShellLocks locks, IPsiFiles psiFiles)
        {
            myShellLocks             = shellLocks;
            myPersistentIndexManager = persistentIndexManager;
            Builder    = builder;
            myLocks    = locks;
            myPsiFiles = psiFiles;

            var solutionCacheFolder = psiConfiguration.SolutionCachesConfiguration.GetSolutionCacheFolder(solution);

            myCacheFile = solutionCacheFolder.Combine(IMAGE_FILE);
        }
예제 #9
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;
 }
 protected GotoRecentActionBase(Lifetime lifetime, Agent agent, ISolution solution,
                                IShellLocks shellLocks, IPsiFiles psiFiles, RecentFilesTracker tracker,
                                OccurencePresentationManager presentationManager, MainWindowPopupWindowContext popupWindowContext)
 {
     this.lifetime            = lifetime;
     this.agent               = agent;
     this.solution            = solution;
     this.shellLocks          = shellLocks;
     this.psiFiles            = psiFiles;
     this.tracker             = tracker;
     this.presentationManager = presentationManager;
     this.popupWindowContext  = popupWindowContext;
 }
예제 #11
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;
 }
 public T4OutputExtensionFrontendNotifier(
     Lifetime lifetime,
     [NotNull] IT4FileGraphNotifier notifier,
     [NotNull] DocumentManager documentManager,
     [NotNull] IT4FileDependencyGraph graph,
     [NotNull] IPsiServices services,
     [NotNull] IPsiCachesState state,
     [NotNull] IPsiFiles psiFiles
     ) : base(lifetime, notifier, services, state)
 {
     DocumentManager = documentManager;
     Graph           = graph;
     PsiFiles        = psiFiles;
 }
예제 #13
0
        public StepPsiChecker(Lifetime lifetime, ISolution solution, IPsiFiles psiFiles, IShellLocks shellLocks)
        {
            Solution    = solution;
            _psiFiles   = psiFiles;
            _shellLocks = shellLocks;

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

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

            OnCheckPass = new Signal <bool>(lifetime, "StepPsiChecker.AfterPsiChangesDone");
        }
예제 #14
0
        /// <inheritdoc/>
        public void Process(
            IPsiSourceFile sourceFile,
            IRangeMarker rangeMarker,
            CodeCleanupProfile profile,
            IProgressIndicator progressIndicator)
        {
            IPsiServices psiServices            = sourceFile.GetPsiServices();
            IPsiFiles    psiFiles               = psiServices.Files;
            IContextBoundSettingsStore settings = sourceFile.GetSettingsStore();
            var orderUsingSettings              =
                settings.GetKey <OrderUsingsSettings>(SettingsOptimization.DoMeSlowly);
            OrderUsingsConfiguration config = null;

            if (!string.IsNullOrWhiteSpace(orderUsingSettings.OrderSpecificationXml))
            {
                config = ConfigurationSerializer.FromXml(new StringReader(orderUsingSettings.OrderSpecificationXml));
            }

            if (config == null)
            {
                return;
            }

            var file = psiFiles.GetDominantPsiFile <CSharpLanguage>(sourceFile) as ICSharpFile;

            if (file == null)
            {
                return;
            }

            if (!profile.GetSetting(DescriptorInstance))
            {
                return;
            }

            file.GetPsiServices().Transactions.Execute(
                "Code cleanup",
                () =>
            {
                using (_shellLocks.UsingWriteLock())
                {
                    CleanUsings(file, config);
                    WalkNamespaceDeclarations(file.NamespaceDeclarations, config);
                }
            });
        }
 public T4DeclaredAssembliesManager(
     Lifetime lifetime,
     [NotNull] IPsiFiles psiFiles
     )
 {
     FileDataChanged = new Signal <Pair <IPsiSourceFile, T4DeclaredAssembliesDiff> >(
         lifetime,
         "T4DeclaredAssembliesCache.FileDataChanged"
         );
     lifetime.Bracket(
         () => psiFiles.PsiFileCreated += OnPsiFileChanged,
         () => psiFiles.PsiFileCreated -= OnPsiFileChanged
         );
     lifetime.Bracket(
         () => psiFiles.AfterPsiChanged += OnPsiChanged,
         () => psiFiles.AfterPsiChanged -= OnPsiChanged
         );
 }
예제 #16
0
 public T4RiderSyntaxHighlightingHost(
     Lifetime lifetime,
     [NotNull] ILogger logger,
     [NotNull] T4OutputExtensionFrontendNotifier notifier,
     [NotNull] ISolution solution,
     [NotNull] IPsiCachesState state,
     [NotNull] IPsiFiles files,
     [NotNull] RiderDocumentHost host
     )
 {
     Logger   = logger;
     Notifier = notifier;
     Solution = solution;
     State    = state;
     Files    = files;
     Host     = host;
     host.ViewHostDocuments(lifetime, CreateHandler);
 }
예제 #17
0
        public OverridingActionRegistrar(Lifetime lifetime, Agent agent, ISolution solution,
                                         IShellLocks shellLocks, IActionManager actionManager, IShortcutManager shortcutManager,
                                         IPsiFiles psiFiles, RecentFilesTracker tracker, OccurencePresentationManager presentationManager,
                                         MainWindowPopupWindowContext mainWindowPopupWindowContext)
        {
            RegisterHandler(actionManager, "RefactorThis", lifetime,
                            new RefactorThisAction(lifetime, agent, actionManager, shortcutManager));
            RegisterHandler(actionManager, "NavigateTo", lifetime,
                            new NavigateFromHereAction(lifetime, agent, actionManager, shortcutManager));
            RegisterHandler(actionManager, "Generate", lifetime,
                            new GenerateAction(lifetime, agent, actionManager, shortcutManager));
            RegisterHandler(actionManager, "GenerateFileBesides", lifetime,
                            new FileTemplatesGenerateAction(lifetime, agent, actionManager, shortcutManager));

            RegisterHandler(actionManager, "GotoRecentFiles", lifetime,
                            new GotoRecentFilesAction(lifetime, agent, solution, shellLocks, psiFiles, tracker, presentationManager, mainWindowPopupWindowContext));
            RegisterHandler(actionManager, "GotoRecentEdits", lifetime,
                            new GotoRecentEditsAction(lifetime, agent, solution, shellLocks, psiFiles, tracker, presentationManager, mainWindowPopupWindowContext));
        }
예제 #18
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);
        }
예제 #19
0
        public StepActionChecker(Lifetime lifetime, IShellLocks shellLocks, IPsiFiles psiFiles)
        {
            _shellLocks = shellLocks;
            _psiFiles   = psiFiles;
            _vsInstance = VsIntegration.GetCurrentVsInstance();
            var events2 = _vsInstance.Events as Events2;

            if (events2 == null)
            {
                return;
            }

            var commandEvents = events2.CommandEvents;

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

            OnCheckPass = new Signal <bool>(lifetime, "StepActionChecker.AfterActionApplied");
        }
예제 #20
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");
        }
예제 #21
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);
        }
예제 #22
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");
        }
        public DeferredCacheController(Lifetime lifetime, ISolution solution, SolutionCaches solutionCaches,
                                       ISolutionLoadTasksScheduler tasksScheduler, IPersistentIndexManager persistentIndexManager, IPsiFiles psiFiles,
                                       SolutionAnalysisConfiguration solutionAnalysisConfiguration, IShellLocks shellLocks,
                                       DeferredHelperCache deferredHelperCache, IEnumerable <IDeferredCache> deferredCaches,
                                       DeferredCacheProgressBar progressBar, ILogger logger)
        {
            myLifetime       = lifetime;
            mySolution       = solution;
            mySolutionCaches = solutionCaches;
            myPsiFiles       = psiFiles;
            mySolutionAnalysisConfiguration = solutionAnalysisConfiguration;
            myShellLocks          = shellLocks;
            myDeferredHelperCache = deferredHelperCache;
            myDeferredCaches      = deferredCaches;
            myProgressBar         = progressBar;
            myLogger = logger;
            var defaultValue = solutionCaches.PersistentProperties.TryGetValue("DeferredCachesCompletedOnce", out var result) && result.Equals("True");

            myCompletedOnce = new ViewableProperty <bool>(defaultValue);

            myGroupingEvent = solution.Locks.GroupingEvents.CreateEvent(lifetime, "DeferredCachesCoreActivity", TimeSpan.FromMilliseconds(500), Rgc.Guarded, RunBackgroundActivity);
        }
예제 #24
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();
        }
예제 #25
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");
        }
예제 #26
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;
        }
예제 #27
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);
            }
        }
예제 #28
0
        public ShaderContextHost(Lifetime lifetime, ISolution solution, IPsiFiles psiFiles,
                                 CppGlobalSymbolCache cppGlobalSymbolCache,
                                 ShaderContextCache shaderContextCache,
                                 ShaderContextDataPresentationCache shaderContextDataPresentationCache, ILogger logger,
                                 [CanBeNull] FrontendBackendHost frontendBackendHost = null,
                                 [CanBeNull] RiderDocumentHost documentHost          = null)
        {
            mySolution             = solution;
            myPsiFiles             = psiFiles;
            myCppGlobalSymbolCache = cppGlobalSymbolCache;
            myDocumentHost         = documentHost;
            myShaderContextCache   = shaderContextCache;
            myShaderContextDataPresentationCache = shaderContextDataPresentationCache;

            if (frontendBackendHost == null || documentHost == null)
            {
                return;
            }

            frontendBackendHost.Do(t =>
            {
                t.RequestShaderContexts.Set((lt, id) =>
                {
                    logger.Verbose("Requesting all shader context for file");
                    using (ReadLockCookie.Create())
                    {
                        var sourceFile = GetSourceFile(id);
                        if (sourceFile == null)
                        {
                            return(Rd.Tasks.RdTask <List <ShaderContextDataBase> > .Successful(
                                       new List <ShaderContextDataBase>()));
                        }
                        var task = new Rd.Tasks.RdTask <List <ShaderContextDataBase> >();
                        RequestShaderContexts(lt, sourceFile, task);

                        return(task);
                    }
                });

                t.ChangeContext.Advise(lifetime, c =>
                {
                    logger.Verbose("Setting new shader context for file");
                    using (ReadLockCookie.Create())
                    {
                        IPsiSourceFile sourceFile = GetSourceFile(c.Target);
                        if (sourceFile == null)
                        {
                            return;
                        }

                        var cppFileLocation = new CppFileLocation(
                            new FileSystemPathWithRange(FileSystemPath.Parse(c.Path), new TextRange(c.Start, c.End)));
                        shaderContextCache.SetContext(sourceFile, cppFileLocation);
                    }
                });

                t.SetAutoShaderContext.Advise(lifetime, id =>
                {
                    using (ReadLockCookie.Create())
                    {
                        IPsiSourceFile sourceFile = GetSourceFile(id);
                        if (sourceFile == null)
                        {
                            return;
                        }
                        shaderContextCache.SetContext(sourceFile, null);
                    }
                });

                t.RequestCurrentContext.Set((lt, id) =>
                {
                    logger.Verbose("Setting current context for file");
                    using (ReadLockCookie.Create())
                    {
                        var sourceFile = GetSourceFile(id);
                        if (sourceFile == null)
                        {
                            return(Rd.Tasks.RdTask <ShaderContextDataBase> .Successful(new AutoShaderContextData()));
                        }

                        var task = new Rd.Tasks.RdTask <ShaderContextDataBase>();
                        RequestCurrentContext(lt, sourceFile, task);
                        return(task);
                    }
                });
            });
        }
예제 #29
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(); });
        }
예제 #30
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);
        }