• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ITextRunConstructionContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ITextRunConstructionContext的典型用法代码示例。如果您正苦于以下问题:C# ITextRunConstructionContext类的具体用法?C# ITextRunConstructionContext怎么用?C# ITextRunConstructionContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ITextRunConstructionContext类属于命名空间,在下文中一共展示了ITextRunConstructionContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Colorize

		protected override void Colorize(ITextRunConstructionContext context)
		{
			// if SelectionForeground is null, keep the existing foreground color
			if (textArea.SelectionForeground == null)
				return;
			
			int lineStartOffset = context.VisualLine.FirstDocumentLine.Offset;
			int lineEndOffset = context.VisualLine.LastDocumentLine.Offset + context.VisualLine.LastDocumentLine.TotalLength;
			
			foreach (SelectionSegment segment in textArea.Selection.Segments) {
				int segmentStart = segment.StartOffset;
				int segmentEnd = segment.EndOffset;
				if (segmentEnd <= lineStartOffset)
					continue;
				if (segmentStart >= lineEndOffset)
					continue;
				int startColumn;
				if (segmentStart < lineStartOffset)
					startColumn = 0;
				else
					startColumn = context.VisualLine.ValidateVisualColumn(segment.StartOffset, segment.StartVisualColumn, textArea.Selection.EnableVirtualSpace);
				
				int endColumn;
				if (segmentEnd > lineEndOffset)
					endColumn = textArea.Selection.EnableVirtualSpace ? int.MaxValue : context.VisualLine.VisualLengthWithEndOfLineMarker;
				else
					endColumn = context.VisualLine.ValidateVisualColumn(segment.EndOffset, segment.EndVisualColumn, textArea.Selection.EnableVirtualSpace);
				
				ChangeVisualElements(
					startColumn, endColumn,
					element => {
						element.TextRunProperties.SetForegroundBrush(textArea.SelectionForeground);
					});
			}
		}
开发者ID:AkshayVats,项目名称:SuperShell,代码行数:35,代码来源:SelectionColorizer.cs


示例2: Colorize

        protected override void Colorize(ITextRunConstructionContext context)
        {
            // if SelectionForeground is null, keep the existing foreground color
            if (textArea.SelectionForeground == null)
                return;

            int lineStartOffset = context.VisualLine.FirstDocumentLine.Offset;
            int lineEndOffset = context.VisualLine.LastDocumentLine.Offset + context.VisualLine.LastDocumentLine.TotalLength;

            foreach (ISegment segment in textArea.Selection.Segments) {
                int segmentStart = segment.Offset;
                int segmentEnd = segment.Offset + segment.Length;
                if (segmentEnd <= lineStartOffset)
                    continue;
                if (segmentStart >= lineEndOffset)
                    continue;
                int startColumn = context.VisualLine.GetVisualColumn(Math.Max(0, segmentStart - lineStartOffset));
                int endColumn = context.VisualLine.GetVisualColumn(segmentEnd - lineStartOffset);
                ChangeVisualElements(
                    startColumn, endColumn,
                    element => {
                        element.TextRunProperties.SetForegroundBrush(textArea.SelectionForeground);
                    });
            }
        }
开发者ID:Amichai,项目名称:PhysicsPad,代码行数:25,代码来源:SelectionColorizer.cs


示例3: CreateTextRun

        /// <inheritdoc/>
        public override TextRun CreateTextRun(int startVisualColumn, ITextRunConstructionContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            return new InlineObjectRun(1, this.TextRunProperties, this.Element);
        }
开发者ID:arkanoid1,项目名称:FakePacketSender,代码行数:8,代码来源:InlineObjectRun.cs


示例4: CreateTextRun

 public override TextRun CreateTextRun(int startVisualColumn, ITextRunConstructionContext context)
 {
     this.TextRunProperties.SetTextDecorations(TextDecorations.Underline);
     if (this._options.ErrorDecoration != null && !this._options.ErrorDecoration.Equals(String.Empty))
     {
         switch (this._options.ErrorDecoration)
         {
             case "Baseline":
                 this.TextRunProperties.SetTextDecorations(TextDecorations.Baseline);
                 break;
             case "OverLine":
                 this.TextRunProperties.SetTextDecorations(TextDecorations.OverLine);
                 break;
             case "Strikethrough":
                 this.TextRunProperties.SetTextDecorations(TextDecorations.Strikethrough);
                 break;
             case "Underline":
                 this.TextRunProperties.SetTextDecorations(TextDecorations.Underline);
                 break;
         }
         
     }
     this.TextRunProperties.SetBackgroundBrush(new SolidColorBrush(this._options.ErrorBackground));
     this.TextRunProperties.SetForegroundBrush(new SolidColorBrush(this._options.ErrorForeground));
     if (this._options.ErrorFontFace != null)
     {
         this.TextRunProperties.SetTypeface(new Typeface(this._options.ErrorFontFace, new FontStyle(), new FontWeight(), new FontStretch()));
     }
     return base.CreateTextRun(startVisualColumn, context);
 }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:30,代码来源:ValidationErrorLineText.cs


示例5: CreateTextRun

 /// <inheritdoc/>
 public override TextRun CreateTextRun(int startVisualColumn, ITextRunConstructionContext context)
 {
     this.TextRunProperties.SetForegroundBrush(context.TextView.LinkTextForegroundBrush);
     this.TextRunProperties.SetBackgroundBrush(context.TextView.LinkTextBackgroundBrush);
     this.TextRunProperties.SetTextDecorations(TextDecorations.Underline);
     return base.CreateTextRun(startVisualColumn, context);
 }
开发者ID:eolandezhang,项目名称:Diagram,代码行数:8,代码来源:VisualLineLinkText.cs


示例6: Colorize

        /// <inheritdoc/>
        protected override void Colorize(ITextRunConstructionContext context)
        {
            if (context == null)
                throw new ArgumentNullException(nameof(context));
            CurrentContext = context;

            currentDocumentLine = context.VisualLine.FirstDocumentLine;
            firstLineStart = currentDocumentLineStartOffset = currentDocumentLine.Offset;
            currentDocumentLineEndOffset = currentDocumentLineStartOffset + currentDocumentLine.Length;

            if (context.VisualLine.FirstDocumentLine == context.VisualLine.LastDocumentLine)
            {
                ColorizeLine(currentDocumentLine);
            }
            else
            {
                ColorizeLine(currentDocumentLine);
                // ColorizeLine modifies the visual line elements, loop through a copy of the line elements
                foreach (VisualLineElement e in context.VisualLine.Elements.ToArray())
                {
                    int elementOffset = firstLineStart + e.RelativeTextOffset;
                    if (elementOffset >= currentDocumentLineEndOffset)
                    {
                        currentDocumentLine = context.Document.GetLineByOffset(elementOffset);
                        currentDocumentLineStartOffset = currentDocumentLine.Offset;
                        currentDocumentLineEndOffset = currentDocumentLineStartOffset + currentDocumentLine.Length;
                        ColorizeLine(currentDocumentLine);
                    }
                }
            }
            currentDocumentLine = null;
            CurrentContext = null;
        }
开发者ID:arkanoid1,项目名称:Yanitta,代码行数:34,代码来源:DocumentColorizingTransformer.cs


示例7: GetColor

		/// <summary>
		/// Gets the color of the brush.
		/// </summary>
		/// <param name="context">The construction context. context can be null!</param>
		public virtual Color? GetColor(ITextRunConstructionContext context)
		{
			SolidColorBrush scb = GetBrush(context) as SolidColorBrush;
			if (scb != null)
				return scb.Color;
			else
				return null;
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:12,代码来源:HighlightingBrush.cs


示例8: CreateTextRun

        /// <inheritdoc/>
        public override TextRun CreateTextRun(int startVisualColumn, ITextRunConstructionContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            int relativeOffset = startVisualColumn - VisualColumn;
            string text = context.Document.GetText(context.VisualLine.FirstDocumentLine.Offset + RelativeTextOffset + relativeOffset, DocumentLength - relativeOffset);
            return new TextCharacters(text, 0, text.Length, this.TextRunProperties);
        }
开发者ID:richardschneider,项目名称:ILSpy,代码行数:10,代码来源:VisualLineText.cs


示例9: CreateTextRun

		/// <inheritdoc/>
		public override TextRun CreateTextRun(int startVisualColumn, ITextRunConstructionContext context)
		{
			if (textLine == null) {
				var formatter = TextFormatterFactory.Create(context.TextView);
				textLine = PrepareText(formatter, this.text, this.TextRunProperties);
				this.text = null;
			}
			return new FormattedTextRun(this, this.TextRunProperties);
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:10,代码来源:FormattedTextElement.cs


示例10: GetPrecedingText

        /// <inheritdoc/>
        public override TextSpan<CultureSpecificCharacterBufferRange> GetPrecedingText(int visualColumnLimit, ITextRunConstructionContext context)
        {
            if (context == null)
                throw new ArgumentNullException(nameof(context));

            int relativeOffset = visualColumnLimit - VisualColumn;
            StringSegment text = context.GetText(context.VisualLine.FirstDocumentLine.Offset + RelativeTextOffset, relativeOffset);
            CharacterBufferRange range = new CharacterBufferRange(text.Text, text.Offset, text.Count);
            return new TextSpan<CultureSpecificCharacterBufferRange>(range.Length, new CultureSpecificCharacterBufferRange(TextRunProperties.CultureInfo, range));
        }
开发者ID:arkanoid1,项目名称:Yanitta,代码行数:11,代码来源:VisualLineText.cs


示例11: StartGeneration

		/// <inheritdoc/>
		public override void StartGeneration(ITextRunConstructionContext context)
		{
			base.StartGeneration(context);
			if (foldingManager != null) {
				if (!foldingManager.textViews.Contains(context.TextView))
					throw new ArgumentException("Invalid TextView");
				if (context.Document != foldingManager.document)
					throw new ArgumentException("Invalid document");
			}
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:11,代码来源:FoldingElementGenerator.cs


示例12: LineIsCode

        private bool LineIsCode(ITextRunConstructionContext context, SortedList<int, object> content)
        {
            if (content.IsNull())
                return false;

            var codeLines = content.Where(x => !(x.Value is string)).Select(x => x.Key);
            var line = context.VisualLine.LastDocumentLine.LineNumber;
            if (codeLines.Contains(line))
                return true;
            
            return false;
        }
开发者ID:jcteague,项目名称:dtt,代码行数:12,代码来源:MixedHighlightingColorizer.cs


示例13: CreateTextRun

		/// <inheritdoc/>
		public override TextRun CreateTextRun(int startVisualColumn, ITextRunConstructionContext context)
		{
			if (context == null)
				throw new ArgumentNullException("context");
			
			// remove inline object if its already added, can happen e.g. when recreating textrun for word-wrapping
			// TODO: certainly the text view should handle this internally? external code might want to use InlineObjectRun,
			// but doesn't have access to textLayer.RemoveInlineObject
			context.TextView.textLayer.RemoveInlineObject(this.Element);
			
			return new InlineObjectRun(1, this.TextRunProperties, this.Element);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:13,代码来源:InlineObjectRun.cs


示例14: Transform

		/// <summary>
		/// <see cref="IVisualLineTransformer.Transform"/> implementation.
		/// Sets <see cref="CurrentElements"/> and calls <see cref="Colorize"/>.
		/// </summary>
		public void Transform(ITextRunConstructionContext context, IList<VisualLineElement> elements)
		{
			if (elements == null)
				throw new ArgumentNullException("elements");
			if (this.CurrentElements != null)
				throw new InvalidOperationException("Recursive Transform() call");
			this.CurrentElements = elements;
			try {
				Colorize(context);
			} finally {
				this.CurrentElements = null;
			}
		}
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:17,代码来源:ColorizingTransformer.cs


示例15: Transform

 public void Transform(ITextRunConstructionContext context, IList<VisualLineElement> elements)
 {
     foreach (VisualLineElement element in elements)
     {
         //if (element is EscapeSequenceElement)
         //{
         //    currentEscapeSequence = (EscapeSequenceElement)element;
         //}
         //else if (currentEscapeSequence != null)
         //{
         //    element.TextRunProperties.SetForegroundBrush(currentEscapeSequence.ForegroundBrush);
         //}
     }
 }
开发者ID:nccgroup,项目名称:tybocer,代码行数:14,代码来源:CodeHighlighters.cs


示例16: ConstructVisualElements

		internal void ConstructVisualElements(ITextRunConstructionContext context, VisualLineElementGenerator[] generators)
		{
			foreach (VisualLineElementGenerator g in generators) {
				g.StartGeneration(context);
			}
			elements = new List<VisualLineElement>();
			PerformVisualElementConstruction(generators);
			foreach (VisualLineElementGenerator g in generators) {
				g.FinishGeneration();
			}
			
			this.Elements = elements.AsReadOnly();
			CalculateOffsets(context.GlobalTextRunProperties);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:14,代码来源:VisualLine.cs


示例17: GetTextForNonPrintableCharacter

		public TextLine GetTextForNonPrintableCharacter(string text, ITextRunConstructionContext context)
		{
			if (nonPrintableCharacterTexts == null)
				nonPrintableCharacterTexts = new Dictionary<string, TextLine>();
			TextLine textLine;
			if (!nonPrintableCharacterTexts.TryGetValue(text, out textLine)) {
				var p = new VisualLineElementTextRunProperties(context.GlobalTextRunProperties);
				p.SetForegroundBrush(context.TextView.NonPrintableCharacterBrush);
				if (formatter == null)
					formatter = TextFormatterFactory.Create(context.TextView);
				textLine = FormattedTextElement.PrepareText(formatter, text, p);
				nonPrintableCharacterTexts[text] = textLine;
			}
			return textLine;
		}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:15,代码来源:TextViewCachedElements.cs


示例18: GetSimpleLightGrayText

		public TextLine GetSimpleLightGrayText(string text, ITextRunConstructionContext context)
		{
			if (simpleLightGrayTexts == null)
				simpleLightGrayTexts = new Dictionary<string, TextLine>();
			TextLine textLine;
			if (!simpleLightGrayTexts.TryGetValue(text, out textLine)) {
				var p = new VisualLineElementTextRunProperties(context.GlobalTextRunProperties);
				p.SetForegroundBrush(Brushes.LightGray);
				if (formatter == null)
					formatter = TextFormatterFactory.Create(context.TextView);
				textLine = FormattedTextElement.PrepareText(formatter, text, p);
				simpleLightGrayTexts[text] = textLine;
			}
			return textLine;
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:15,代码来源:TextViewCachedElements.cs


示例19: ConstructVisualElements

		internal void ConstructVisualElements(ITextRunConstructionContext context, VisualLineElementGenerator[] generators)
		{
			foreach (VisualLineElementGenerator g in generators) {
				g.StartGeneration(context);
			}
			elements = new List<VisualLineElement>();
			PerformVisualElementConstruction(generators);
			foreach (VisualLineElementGenerator g in generators) {
				g.FinishGeneration();
			}
			
//			if (FirstDocumentLine.Length != 0)
//				elements.Add(new VisualLineText(FirstDocumentLine.Text, FirstDocumentLine.Length));
//			//elements.Add(new VisualNewLine(VisualNewLine.NewLineType.Lf));
			this.Elements = elements.AsReadOnly();
			CalculateOffsets(context.GlobalTextRunProperties);
		}
开发者ID:tiwariritesh7,项目名称:devdefined-tools,代码行数:17,代码来源:VisualLine.cs


示例20: Colorize

 /// <inheritdoc/>
 protected override void Colorize(ITextRunConstructionContext context)
 {
     this.lastColorizedLine = null;
     base.Colorize(context);
     if (this.lastColorizedLine != context.VisualLine.LastDocumentLine) {
         IHighlighter highlighter = context.TextView.Services.GetService(typeof(IHighlighter)) as IHighlighter;
         if (highlighter != null) {
             // In some cases, it is possible that we didn't highlight the last document line within the visual line
             // (e.g. when the line ends with a fold marker).
             // But even if we didn't highlight it, we'll have to update the highlighting state for it so that the
             // proof inside TextViewDocumentHighlighter.OnHighlightStateChanged holds.
             lineNumberBeingColorized = context.VisualLine.LastDocumentLine.LineNumber;
             highlighter.GetSpanStack(lineNumberBeingColorized);
             lineNumberBeingColorized = 0;
         }
     }
     this.lastColorizedLine = null;
 }
开发者ID:richardschneider,项目名称:ILSpy,代码行数:19,代码来源:HighlightingColorizer.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ITextSnapshot类代码示例发布时间:2022-05-24
下一篇:
C# ITextRange类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap