当前位置: 首页>>代码示例>>C#>>正文


C# ITextDocumentFactoryService.TryGetTextDocument方法代码示例

本文整理汇总了C#中ITextDocumentFactoryService.TryGetTextDocument方法的典型用法代码示例。如果您正苦于以下问题:C# ITextDocumentFactoryService.TryGetTextDocument方法的具体用法?C# ITextDocumentFactoryService.TryGetTextDocument怎么用?C# ITextDocumentFactoryService.TryGetTextDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITextDocumentFactoryService的用法示例。


在下文中一共展示了ITextDocumentFactoryService.TryGetTextDocument方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BottomMargin

        public BottomMargin(IWpfTextView textView, IClassifierAggregatorService classifier, ITextDocumentFactoryService documentService)
        {
            _textView = textView;
            _classifier = classifier.GetClassifier(textView.TextBuffer);
            _foregroundBrush = new SolidColorBrush((Color)FindResource(VsColors.CaptionTextKey));
            _backgroundBrush = new SolidColorBrush((Color)FindResource(VsColors.ScrollBarBackgroundKey));

            this.Background = _backgroundBrush;
            this.ClipToBounds = true;

            _lblEncoding = new TextControl("Encoding");
            this.Children.Add(_lblEncoding);

            _lblContentType = new TextControl("Content type");
            this.Children.Add(_lblContentType);

            _lblClassification = new TextControl("Classification");
            this.Children.Add(_lblClassification);

            _lblSelection = new TextControl("Selection");
            this.Children.Add(_lblSelection);

            UpdateClassificationLabel();
            UpdateContentTypeLabel();
            UpdateContentSelectionLabel();

            if (documentService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out _doc))
            {
                _doc.FileActionOccurred += FileChangedOnDisk;
                UpdateEncodingLabel(_doc);
            }

            textView.Caret.PositionChanged += CaretPositionChanged;
        }
开发者ID:modulexcite,项目名称:ExtensibilityTools,代码行数:34,代码来源:BottomMargin.cs

示例2: InstantVisualStudio

		public InstantVisualStudio (IWpfTextView view, ITextDocumentFactoryService textDocumentFactoryService)
		{
			this.view = view;
			this.layer = view.GetAdornmentLayer("Instant.VisualStudio");

			//Listen to any event that changes the layout (text changes, scrolling, etc)
			this.view.LayoutChanged += OnLayoutChanged;

			this.dispatcher = Dispatcher.CurrentDispatcher;

			this.evaluator.EvaluationCompleted += OnEvaluationCompleted;
			this.evaluator.Start();

			this.dte.Events.BuildEvents.OnBuildProjConfigDone += OnBuildProjeConfigDone;
			this.dte.Events.BuildEvents.OnBuildDone += OnBuildDone;
			this.dte.Events.BuildEvents.OnBuildBegin += OnBuildBegin;

			this.statusbar = (IVsStatusbar)this.serviceProvider.GetService (typeof (IVsStatusbar));

			ITextDocument textDocument;
			if (!textDocumentFactoryService.TryGetTextDocument (view.TextBuffer, out textDocument))
				throw new InvalidOperationException();

			this.document = this.dte.Documents.OfType<EnvDTE.Document>().FirstOrDefault (d => d.FullName == textDocument.FilePath);

			InstantTagToggleAction.Toggled += OnInstantToggled;
		}
开发者ID:ermau,项目名称:Instant,代码行数:27,代码来源:InstantVisualStudio.cs

示例3: BottomMargin

        public BottomMargin(IWpfTextView textView, IClassifierAggregatorService classifier, ITextDocumentFactoryService documentService)
        {
            _textView = textView;
            _classifier = classifier.GetClassifier(textView.TextBuffer);

            SetResourceReference(BackgroundProperty, EnvironmentColors.ScrollBarBackgroundBrushKey);

            ClipToBounds = true;

            _lblEncoding = new TextControl("Encoding");
            Children.Add(_lblEncoding);

            _lblContentType = new TextControl("Content type");
            Children.Add(_lblContentType);

            _lblClassification = new TextControl("Classification");
            Children.Add(_lblClassification);

            _lblSelection = new TextControl("Selection");
            Children.Add(_lblSelection);

            UpdateClassificationLabel();
            UpdateContentTypeLabel();
            UpdateContentSelectionLabel();

            if (documentService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out _doc))
            {
                _doc.FileActionOccurred += FileChangedOnDisk;
                UpdateEncodingLabel(_doc);
            }

            textView.Caret.PositionChanged += CaretPositionChanged;
        }
开发者ID:japj,项目名称:ExtensibilityTools,代码行数:33,代码来源:BottomMargin.cs

示例4: MarkdownBackgroundParser

        public MarkdownBackgroundParser(ITextBuffer textBuffer, TaskScheduler taskScheduler, ITextDocumentFactoryService textDocumentFactoryService)
            : base(textBuffer, taskScheduler, textDocumentFactoryService)
        {
            ReparseDelay = TimeSpan.FromMilliseconds(300);

            ITextDocument document;
            if (textDocumentFactoryService.TryGetTextDocument(textBuffer, out document))
                this.LoadRuleset(document);
        }
开发者ID:JunyiYi,项目名称:MarkdownMode,代码行数:9,代码来源:MarkdownBackgroundParser.cs

示例5: PreviewWindowBackgroundParser

 public PreviewWindowBackgroundParser(ITextBuffer textBuffer, TaskScheduler taskScheduler, ITextDocumentFactoryService textDocumentFactoryService)
     : base(textBuffer, taskScheduler, textDocumentFactoryService)
 {
     ReparseDelay = TimeSpan.FromMilliseconds(1000);
     if (!textDocumentFactoryService.TryGetTextDocument(textBuffer, out document))
     {
         document = null;
     }
     markdownTransform.DocumentToTransformPath = document == null ? null : document.FilePath;
 }
开发者ID:JunyiYi,项目名称:MarkdownMode,代码行数:10,代码来源:PreviewWindowBackgroundParser.cs

示例6: PreviewWindowBackgroundParser

        public PreviewWindowBackgroundParser(ITextBuffer textBuffer, TaskScheduler taskScheduler, ITextDocumentFactoryService textDocumentFactoryService)
            : base(textBuffer, taskScheduler, textDocumentFactoryService)
        {
            ReparseDelay = TimeSpan.FromMilliseconds(1000);

            ITextDocument markdownDocument;
            if (textDocumentFactoryService.TryGetTextDocument(textBuffer, out markdownDocument))
            {
                markdownDocumentPath = markdownDocument.FilePath;
            }
        }
开发者ID:JackWangCUMT,项目名称:MarkdownMode,代码行数:11,代码来源:PreviewWindowBackgroundParser.cs

示例7: DartCodeWindowManager

        public DartCodeWindowManager(ITextDocumentFactoryService textDocumentFactory, IVsEditorAdaptersFactoryService editorAdapterFactory, IVsCodeWindow codeWindow, DartAnalysisServiceFactory analysisServiceFactory)
        {
            this.barManager = ((IVsDropdownBarManager)codeWindow);
            this.analysisServiceFactory = analysisServiceFactory;

            // Figure out the filename (seriously; this is the best way?!).
            IVsTextView textView;
            codeWindow.GetPrimaryView(out textView);
            wpfTextView = editorAdapterFactory.GetWpfTextView(textView);
            textDocumentFactory.TryGetTextDocument(wpfTextView.TextBuffer, out this.textDocument);
        }
开发者ID:modulexcite,项目名称:DartVS,代码行数:11,代码来源:DartCodeWindowManager.cs

示例8: TemplateErrorReporter

        private TemplateErrorReporter(ITextBuffer buffer, IServiceProvider serviceProvider, ITextDocumentFactoryService documentFactory)
        {
            Debug.Assert(buffer != null, "buffer");
            Debug.Assert(serviceProvider != null, "serviceProvider");
            Debug.Assert(documentFactory != null, "documentFactory");

            this.serviceProvider = serviceProvider;
            
            documentFactory.TryGetTextDocument(buffer, out this.document);
            WeakEventManager<ITextDocumentFactoryService, TextDocumentEventArgs>.AddHandler(documentFactory, "TextDocumentDisposed", this.DocumentDisposed);

            this.analyzer = TemplateAnalyzer.GetOrCreate(buffer);
            WeakEventManager<TemplateAnalyzer, TemplateAnalysis>.AddHandler(this.analyzer, "TemplateChanged", this.TemplateChanged);

            this.UpdateErrorTasks(this.analyzer.CurrentAnalysis);
        }
开发者ID:icool123,项目名称:T4Toolbox,代码行数:16,代码来源:TemplateErrorReporter.cs

示例9: ErrorManager

        protected ErrorManager(ITextView textView,
            IOptionsService optionsService, IServiceProvider serviceProvider,
            ITextDocumentFactoryService textDocumentFactoryService)
        {
            _textView = textView;
            _optionsService = optionsService;

            optionsService.OptionsChanged += OnOptionsChanged;

            ITextDocument document;
            if (textDocumentFactoryService.TryGetTextDocument(textView.TextBuffer, out document))
                ErrorListHelper = new ErrorListHelper(serviceProvider, document);

            textView.Closed += OnViewClosed;

            OnOptionsChanged(this, EventArgs.Empty);
        }
开发者ID:Samana,项目名称:HlslTools,代码行数:17,代码来源:ErrorManager.cs

示例10: PreviewWindowUpdateListener

        public PreviewWindowUpdateListener(IWpfTextView wpfTextView, MarkdownPackage package, ITextDocumentFactoryService textDocumentFactoryService)
        {
            this.textView = wpfTextView;
            this.package = package;
            this.backgroundParser = new PreviewWindowBackgroundParser(wpfTextView.TextBuffer, TaskScheduler.Default, textDocumentFactoryService);
            this.backgroundParser.ParseComplete += HandleBackgroundParseComplete;

            if (!textDocumentFactoryService.TryGetTextDocument(wpfTextView.TextDataModel.DocumentBuffer, out document))
                document = null;

            if (textView.HasAggregateFocus)
                UpdatePreviewWindow(string.Empty);

            backgroundParser.RequestParse(true);

            textView.Closed += HandleTextViewClosed;
            textView.GotAggregateFocus += HandleTextViewGotAggregateFocus;
        }
开发者ID:return,项目名称:MarkdownMode,代码行数:18,代码来源:PreviewWindowUpdateListener.cs

示例11: DocumentInsightsMargin

        public DocumentInsightsMargin(IWpfTextView textView, ITextDocumentFactoryService documentService)
        {
            Int32 sourceLineCount = 0;
            Int32 sourceCharCount = 0;

            // Instance initialization
            _textView = textView;

            if (documentService.TryGetTextDocument(textView.TextBuffer, out _textDocument)) {
                sourceLineCount = _textDocument.TextBuffer.CurrentSnapshot.LineCount;
                sourceCharCount = _textDocument.TextBuffer.CurrentSnapshot.Length;
                _textDocument.FileActionOccurred += TextDocument_FileActionOccurred;
            }

            Encoding encoding = _textDocument != null ? _textDocument.Encoding : null;

            _viewModel = new DocumentInsightsViewModel(sourceLineCount, sourceCharCount, encoding) {
                ShowCharInfo = DocumentInsightsOptions.Current.EnableCharInfo,
                ShowLineInfo = DocumentInsightsOptions.Current.EnableLineInfo,
                ShowEncodingInfo = DocumentInsightsOptions.Current.EnableEncodingInfo
            };

            _view = new DocumentInsightsView() {
                DataContext = _viewModel,
                Visibility = DocumentInsightsOptions.Current.ShowMargin ? Visibility.Visible : Visibility.Collapsed
            };

            // Add event handler
            if (textView != null) {
                textView.Closed += TextView_Closed;
                if (textView.TextBuffer != null) {
                    textView.TextBuffer.Changed += TextBuffer_Changed;
                }
            }

            // Subscribe options property changed notifications
            DocumentInsightsOptions.Current.PropertyChanged += Options_PropertyChanged;
        }
开发者ID:fschneidereit,项目名称:VSEssentials,代码行数:38,代码来源:DocumentInsightsMargin.cs

示例12: MarginCore

        /// <summary>
        /// Creates a <see cref="MarginCore"/> for a given <see cref="IWpfTextView"/>.
        /// </summary>
        /// <param name="textView">The <see cref="IWpfTextView"/> to attach the margin to.</param>
        /// <param name="textDocumentFactoryService">Service that creates, loads, and disposes text documents.</param>
        /// <param name="vsServiceProvider">Visual Studio service provider.</param>
        /// <param name="formatMapService">Service that provides the <see cref="IEditorFormatMap"/>.</param>
        /// <param name="scrollMapFactoryService">Factory that creates or reuses an <see cref="IScrollMap"/> for an <see cref="ITextView"/>.</param>
        public MarginCore(IWpfTextView textView, ITextDocumentFactoryService textDocumentFactoryService, SVsServiceProvider vsServiceProvider, IEditorFormatMapService formatMapService, IScrollMapFactoryService scrollMapFactoryService)
        {
            Debug.WriteLine("Entering constructor.", Properties.Resources.ProductName);

            _textView = textView;
            if (!textDocumentFactoryService.TryGetTextDocument(_textView.TextBuffer, out _textDoc))
            {
                Debug.WriteLine("Can not retrieve TextDocument. Margin is disabled.", Properties.Resources.ProductName);
                _isEnabled = false;
                return;
            }

            _formatMap = formatMapService.GetEditorFormatMap(textView);
            _marginSettings = new MarginSettings(_formatMap);

            _scrollMap = scrollMapFactoryService.Create(textView);

            var dte = (DTE2)vsServiceProvider.GetService(typeof(DTE));
            _tfExt = dte.GetObject(typeof(TeamFoundationServerExt).FullName);
            Debug.Assert(_tfExt != null, "_tfExt is null.");
            _tfExt.ProjectContextChanged += OnTfExtProjectContextChanged;

            UpdateMargin();
        }
开发者ID:gentoo90,项目名称:TfsPendingChangesMargin,代码行数:32,代码来源:MarginCore.cs


注:本文中的ITextDocumentFactoryService.TryGetTextDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。