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


C# ITextRunConstructionContext类代码示例

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


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


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