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

C# Rendering.VisualLine类代码示例

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

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



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

示例1: VisualLineText

 /// <summary>
 /// Creates a visual line text element with the specified length.
 /// It uses the <see cref="ITextRunConstructionContext.VisualLine"/> and its
 /// <see cref="VisualLineElement.RelativeTextOffset"/> to find the actual text string.
 /// </summary>
 public VisualLineText(VisualLine parentVisualLine, int length)
     : base(length, length)
 {
     if (parentVisualLine == null)
         throw new ArgumentNullException("parentVisualLine");
     this.parentVisualLine = parentVisualLine;
 }
开发者ID:richardschneider,项目名称:ILSpy,代码行数:12,代码来源:VisualLineText.cs


示例2: Render

        public void Render(DrawingContext drawingContext, VisualLine line, Size pixelSize)
        {
            var lineMiddle = line.GetTextLineVisualYPosition(line.TextLines[0], VisualYPosition.TextMiddle) -
                                 _textView.VerticalOffset;

            // Draw the error line
            drawingContext.DrawLine(new Pen(Brushes.DarkGoldenrod, 4), new Point(0, lineMiddle), new Point(20, lineMiddle));
        }
开发者ID:peterschen,项目名称:SMAStudio,代码行数:8,代码来源:AnalyzerWarningRenderer.cs


示例3: RemoveInlineObjects

		internal void RemoveInlineObjects(VisualLine visualLine)
		{
			// Delay removing inline objects:
			// A document change immediately invalidates affected visual lines, but it does not
			// cause an immediate redraw.
			// To prevent inline objects from flickering when they are recreated, we delay removing
			// inline objects until the next redraw.
			visualLinesWithOutstandingInlineObjects.Add(visualLine);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:9,代码来源:TextLayer.cs


示例4: GetEndOfLineCaretPosition

		static TextViewPosition GetEndOfLineCaretPosition(VisualLine visualLine, TextLine textLine)
		{
			int newVC = visualLine.GetTextLineVisualStartColumn(textLine) + textLine.Length - textLine.TrailingWhitespaceLength;
			TextViewPosition pos = visualLine.GetTextViewPosition(newVC);
			pos.IsAtEndOfLine = true;
			return pos;
		}
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:7,代码来源:CaretNavigationCommandHandler.cs


示例5: GetRectsFromVisualSegment

		/// <summary>
		/// Calculates the rectangles for the visual column segment.
		/// This returns one rectangle for each line inside the segment.
		/// </summary>
		public static IEnumerable<Rect> GetRectsFromVisualSegment(TextView textView, VisualLine line, int startVC, int endVC)
		{
			if (textView == null)
				throw new ArgumentNullException("textView");
			if (line == null)
				throw new ArgumentNullException("line");
			return ProcessTextLines(textView, line, startVC, endVC);
		}
开发者ID:AkshayVats,项目名称:SuperShell,代码行数:12,代码来源:BackgroundGeometryBuilder.cs


示例6: RevalidateVisualColumn

        /// <summary>
        /// Validates the visual column of the caret using the specified visual line.
        /// The visual line must contain the caret offset.
        /// </summary>
        void RevalidateVisualColumn(VisualLine visualLine)
        {
            if (visualLine == null)
                throw new ArgumentNullException("visualLine");

            // mark column as validated
            visualColumnValid = true;

            int caretOffset = textView.Document.GetOffset(position.Location);
            int firstDocumentLineOffset = visualLine.FirstDocumentLine.Offset;
            position.VisualColumn = visualLine.ValidateVisualColumn(position, textArea.Selection.EnableVirtualSpace);

            // search possible caret positions
            int newVisualColumnForwards = visualLine.GetNextCaretPosition(position.VisualColumn - 1, LogicalDirection.Forward, CaretPositioningMode.Normal, textArea.Selection.EnableVirtualSpace);
            // If position.VisualColumn was valid, we're done with validation.
            if (newVisualColumnForwards != position.VisualColumn) {
                // also search backwards so that we can pick the better match
                int newVisualColumnBackwards = visualLine.GetNextCaretPosition(position.VisualColumn + 1, LogicalDirection.Backward, CaretPositioningMode.Normal, textArea.Selection.EnableVirtualSpace);

                if (newVisualColumnForwards < 0 && newVisualColumnBackwards < 0)
                    throw ThrowUtil.NoValidCaretPosition();

                // determine offsets for new visual column positions
                int newOffsetForwards;
                if (newVisualColumnForwards >= 0)
                    newOffsetForwards = visualLine.GetRelativeOffset(newVisualColumnForwards) + firstDocumentLineOffset;
                else
                    newOffsetForwards = -1;
                int newOffsetBackwards;
                if (newVisualColumnBackwards >= 0)
                    newOffsetBackwards = visualLine.GetRelativeOffset(newVisualColumnBackwards) + firstDocumentLineOffset;
                else
                    newOffsetBackwards = -1;

                int newVisualColumn, newOffset;
                // if there's only one valid position, use it
                if (newVisualColumnForwards < 0) {
                    newVisualColumn = newVisualColumnBackwards;
                    newOffset = newOffsetBackwards;
                } else if (newVisualColumnBackwards < 0) {
                    newVisualColumn = newVisualColumnForwards;
                    newOffset = newOffsetForwards;
                } else {
                    // two valid positions: find the better match
                    if (Math.Abs(newOffsetBackwards - caretOffset) < Math.Abs(newOffsetForwards - caretOffset)) {
                        // backwards is better
                        newVisualColumn = newVisualColumnBackwards;
                        newOffset = newOffsetBackwards;
                    } else {
                        // forwards is better
                        newVisualColumn = newVisualColumnForwards;
                        newOffset = newOffsetForwards;
                    }
                }
                this.Position = new TextViewPosition(textView.Document.GetLocation(newOffset), newVisualColumn);
            }
        }
开发者ID:hardliner66,项目名称:ATMELGitSCC,代码行数:61,代码来源:Caret.cs


示例7: GetVisualPos

 double GetVisualPos(VisualLine vl, TextLine tl)
 {
     double pos = vl.GetTextLineVisualYPosition(tl, VisualYPosition.LineTop) + tl.Height / 2 - TextView.VerticalOffset;
     return Math.Round(pos) + 0.5;
 }
开发者ID:kjk,项目名称:kjkpub,代码行数:5,代码来源:FoldingMargin.cs


示例8: VisualLineLinkText

		/// <summary>
		/// Creates a visual line text element with the specified length.
		/// It uses the <see cref="ITextRunConstructionContext.VisualLine"/> and its
		/// <see cref="VisualLineElement.RelativeTextOffset"/> to find the actual text string.
		/// </summary>
		public VisualLineLinkText(VisualLine parentVisualLine, int length) : base(parentVisualLine, length)
		{
			this.RequireControlModifierForClick = true;
		}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:9,代码来源:VisualLineLinkText.cs


示例9: CalcCaretOverstrikeRectangle

		Rect CalcCaretOverstrikeRectangle(VisualLine visualLine)
		{
			if (!visualColumnValid) {
				RevalidateVisualColumn(visualLine);
			}
			
			int currentPos = position.VisualColumn;
			// The text being overwritten in overstrike mode is everything up to the next normal caret stop
			int nextPos = visualLine.GetNextCaretPosition(currentPos, LogicalDirection.Forward, CaretPositioningMode.Normal, true);
			TextLine textLine = visualLine.GetTextLine(currentPos);
			
			Rect r;
			if (currentPos < visualLine.VisualLength) {
				// If the caret is within the text, use GetTextBounds() for the text being overwritten.
				// This is necessary to ensure the rectangle is calculated correctly in bidirectional text.
				var textBounds = textLine.GetTextBounds(currentPos, nextPos - currentPos)[0];
				r = textBounds.Rectangle;
				r.Y += visualLine.GetTextLineVisualYPosition(textLine, VisualYPosition.LineTop);
			} else {
				// If the caret is at the end of the line (or in virtual space),
				// use the visual X position of currentPos and nextPos (one or more of which will be in virtual space)
				double xPos = visualLine.GetTextLineVisualXPosition(textLine, currentPos);
				double xPos2 = visualLine.GetTextLineVisualXPosition(textLine, nextPos);
				double lineTop = visualLine.GetTextLineVisualYPosition(textLine, VisualYPosition.TextTop);
				double lineBottom = visualLine.GetTextLineVisualYPosition(textLine, VisualYPosition.TextBottom);
				r = new Rect(xPos, lineTop, xPos2 - xPos, lineBottom - lineTop);
			}
			// If the caret is too small (e.g. in front of zero-width character), ensure it's still visible
			if (r.Width < SystemParameters.CaretWidth)
				r.Width = SystemParameters.CaretWidth;
			return r;
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:32,代码来源:Caret.cs


示例10: SetCaretPosition

 private static void SetCaretPosition(TextArea textArea, VisualLine targetVisualLine, TextLine targetLine, int newVisualColumn, bool allowWrapToNextLine)
 {
     int targetLineStartCol = targetVisualLine.GetTextLineVisualStartColumn(targetLine);
     if (!allowWrapToNextLine && newVisualColumn >= targetLineStartCol + targetLine.Length)
     {
         if (newVisualColumn <= targetVisualLine.VisualLength)
             newVisualColumn = targetLineStartCol + targetLine.Length - 1;
     }
     int newOffset = targetVisualLine.GetRelativeOffset(newVisualColumn) + targetVisualLine.FirstDocumentLine.Offset;
     SetCaretPosition(textArea, newVisualColumn, newOffset);
 }
开发者ID:arkanoid1,项目名称:FakePacketSender,代码行数:11,代码来源:CaretNavigationCommandHandler.cs


示例11: GetLineNumberString

 protected virtual string GetLineNumberString(VisualLine line)
 {
     return line.FirstDocumentLine.LineNumber.ToString(CultureInfo.CurrentCulture);
 }
开发者ID:adimitrov93,项目名称:AvalonEdit,代码行数:4,代码来源:LineNumberMargin.cs


示例12: DocumentLines

 private static IEnumerable<DocumentLine> DocumentLines(VisualLine visLine)
 {
   var line = visLine.FirstDocumentLine;
   while (line != visLine.LastDocumentLine)
   {
     yield return line;
     line = line.NextLine;
   }
   yield return line;
 }
开发者ID:cornelius90,项目名称:InnovatorAdmin,代码行数:10,代码来源:DiffViewer.xaml.cs


示例13: GetUpDownCaretPosition

		static TextViewPosition GetUpDownCaretPosition(TextView textView, TextViewPosition caretPosition, CaretMovementType direction, VisualLine visualLine, TextLine textLine, bool enableVirtualSpace, ref double xPos)
		{
			// moving up/down happens using the desired visual X position
			if (double.IsNaN(xPos))
				xPos = visualLine.GetTextLineVisualXPosition(textLine, caretPosition.VisualColumn);
			// now find the TextLine+VisualLine where the caret will end up in
			VisualLine targetVisualLine = visualLine;
			TextLine targetLine;
			int textLineIndex = visualLine.TextLines.IndexOf(textLine);
			switch (direction) {
				case CaretMovementType.LineUp:
					{
						// Move up: move to the previous TextLine in the same visual line
						// or move to the last TextLine of the previous visual line
						int prevLineNumber = visualLine.FirstDocumentLine.LineNumber - 1;
						if (textLineIndex > 0) {
							targetLine = visualLine.TextLines[textLineIndex - 1];
						} else if (prevLineNumber >= 1) {
							DocumentLine prevLine = textView.Document.GetLineByNumber(prevLineNumber);
							targetVisualLine = textView.GetOrConstructVisualLine(prevLine);
							targetLine = targetVisualLine.TextLines[targetVisualLine.TextLines.Count - 1];
						} else {
							targetLine = null;
						}
						break;
					}
				case CaretMovementType.LineDown:
					{
						// Move down: move to the next TextLine in the same visual line
						// or move to the first TextLine of the next visual line
						int nextLineNumber = visualLine.LastDocumentLine.LineNumber + 1;
						if (textLineIndex < visualLine.TextLines.Count - 1) {
							targetLine = visualLine.TextLines[textLineIndex + 1];
						} else if (nextLineNumber <= textView.Document.LineCount) {
							DocumentLine nextLine = textView.Document.GetLineByNumber(nextLineNumber);
							targetVisualLine = textView.GetOrConstructVisualLine(nextLine);
							targetLine = targetVisualLine.TextLines[0];
						} else {
							targetLine = null;
						}
						break;
					}
				case CaretMovementType.PageUp:
				case CaretMovementType.PageDown:
					{
						// Page up/down: find the target line using its visual position
						double yPos = visualLine.GetTextLineVisualYPosition(textLine, VisualYPosition.LineMiddle);
						if (direction == CaretMovementType.PageUp)
							yPos -= textView.RenderSize.Height;
						else
							yPos += textView.RenderSize.Height;
						DocumentLine newLine = textView.GetDocumentLineByVisualTop(yPos);
						targetVisualLine = textView.GetOrConstructVisualLine(newLine);
						targetLine = targetVisualLine.GetTextLineByVisualYPosition(yPos);
						break;
					}
				default:
					throw new NotSupportedException(direction.ToString());
			}
			if (targetLine != null) {
				double yPos = targetVisualLine.GetTextLineVisualYPosition(targetLine, VisualYPosition.LineMiddle);
				int newVisualColumn = targetVisualLine.GetVisualColumn(new Point(xPos, yPos), enableVirtualSpace);
				
				// prevent wrapping to the next line; TODO: could 'IsAtEnd' help here?
				int targetLineStartCol = targetVisualLine.GetTextLineVisualStartColumn(targetLine);
				if (newVisualColumn >= targetLineStartCol + targetLine.Length) {
					if (newVisualColumn <= targetVisualLine.VisualLength)
						newVisualColumn = targetLineStartCol + targetLine.Length - 1;
				}
				return targetVisualLine.GetTextViewPosition(newVisualColumn);
			} else {
				return caretPosition;
			}
		}
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:74,代码来源:CaretNavigationCommandHandler.cs


示例14: GetPrevCaretPosition

		static TextViewPosition GetPrevCaretPosition(TextView textView, TextViewPosition caretPosition, VisualLine visualLine, CaretPositioningMode mode, bool enableVirtualSpace)
		{
			int pos = visualLine.GetNextCaretPosition(caretPosition.VisualColumn, LogicalDirection.Backward, mode, enableVirtualSpace);
			if (pos >= 0) {
				return visualLine.GetTextViewPosition(pos);
			} else {
				// move to end of previous line
				DocumentLine previousDocumentLine = visualLine.FirstDocumentLine.PreviousLine;
				if (previousDocumentLine != null) {
					VisualLine previousLine = textView.GetOrConstructVisualLine(previousDocumentLine);
					pos = previousLine.GetNextCaretPosition(previousLine.VisualLength + 1, LogicalDirection.Backward, mode, enableVirtualSpace);
					if (pos < 0)
						throw ThrowUtil.NoValidCaretPosition();
					return previousLine.GetTextViewPosition(pos);
				} else {
					// at start of document
					Debug.Assert(visualLine.FirstDocumentLine.Offset == 0);
					return new TextViewPosition(0, 0);
				}
			}
		}
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:21,代码来源:CaretNavigationCommandHandler.cs


示例15: GetNextCaretPosition

		static TextViewPosition GetNextCaretPosition(TextView textView, TextViewPosition caretPosition, VisualLine visualLine, CaretPositioningMode mode, bool enableVirtualSpace)
		{
			int pos = visualLine.GetNextCaretPosition(caretPosition.VisualColumn, LogicalDirection.Forward, mode, enableVirtualSpace);
			if (pos >= 0) {
				return visualLine.GetTextViewPosition(pos);
			} else {
				// move to start of next line
				DocumentLine nextDocumentLine = visualLine.LastDocumentLine.NextLine;
				if (nextDocumentLine != null) {
					VisualLine nextLine = textView.GetOrConstructVisualLine(nextDocumentLine);
					pos = nextLine.GetNextCaretPosition(-1, LogicalDirection.Forward, mode, enableVirtualSpace);
					if (pos < 0)
						throw ThrowUtil.NoValidCaretPosition();
					return nextLine.GetTextViewPosition(pos);
				} else {
					// at end of document
					Debug.Assert(visualLine.LastDocumentLine.Offset + visualLine.LastDocumentLine.TotalLength == textView.Document.TextLength);
					return new TextViewPosition(textView.Document.GetLocation(textView.Document.TextLength));
				}
			}
		}
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:21,代码来源:CaretNavigationCommandHandler.cs


示例16: GetVisualPos

		double GetVisualPos(VisualLine vl, TextLine tl, double pixelHeight)
		{
			double pos = vl.GetTextLineVisualYPosition(tl, VisualYPosition.TextMiddle) - TextView.VerticalOffset;
			return PixelSnapHelpers.PixelAlign(pos, pixelHeight);
		}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:5,代码来源:FoldingMargin.cs


示例17: VisualLineReferenceText

 /// <summary>
 /// Creates a visual line text element with the specified length.
 /// It uses the <see cref="ITextRunConstructionContext.VisualLine"/> and its
 /// <see cref="VisualLineElement.RelativeTextOffset"/> to find the actual text string.
 /// </summary>
 public VisualLineReferenceText(VisualLine parentVisualLine, int length, ReferenceElementGenerator parent, ReferenceSegment referenceSegment)
     : base(parentVisualLine, length)
 {
     this.parent = parent;
     this.referenceSegment = referenceSegment;
 }
开发者ID:BahNahNah,项目名称:dnSpy,代码行数:11,代码来源:ReferenceElementGenerator.cs


示例18: MoveCaretLeft

 static void MoveCaretLeft(TextArea textArea, TextViewPosition caretPosition, VisualLine visualLine, CaretPositioningMode mode)
 {
     int pos = visualLine.GetNextCaretPosition(caretPosition.VisualColumn, LogicalDirection.Backward, mode);
     if (pos >= 0) {
         SetCaretPosition(textArea, pos, visualLine.GetRelativeOffset(pos) + visualLine.FirstDocumentLine.Offset);
     } else {
         // move to end of previous line
         DocumentLine previousDocumentLine = visualLine.FirstDocumentLine.PreviousLine;
         if (previousDocumentLine != null) {
             VisualLine previousLine = textArea.TextView.GetOrConstructVisualLine(previousDocumentLine);
             pos = previousLine.GetNextCaretPosition(previousLine.VisualLength + 1, LogicalDirection.Backward, mode);
             if (pos < 0)
                 throw ThrowUtil.NoValidCaretPosition();
             SetCaretPosition(textArea, pos, previousLine.GetRelativeOffset(pos) + previousLine.FirstDocumentLine.Offset);
         } else {
             // at start of document
             Debug.Assert(visualLine.FirstDocumentLine.Offset == 0);
             SetCaretPosition(textArea, 0, 0);
         }
     }
 }
开发者ID:Amichai,项目名称:PhysicsPad,代码行数:21,代码来源:CaretNavigationCommandHandler.cs


示例19: GetPrevCaretPosition

		static TextViewPosition GetPrevCaretPosition(TextView textView, TextViewPosition caretPosition, VisualLine visualLine, CaretPositioningMode mode, bool enableVirtualSpace) {
			int pos = visualLine.GetNextCaretPosition(caretPosition.VisualColumn, LogicalDirection.Backward, mode, enableVirtualSpace);
			if (pos >= 0)
				return visualLine.GetTextViewPosition(pos);
			var previousDocumentLine = visualLine.FirstDocumentLine.PreviousLine;
			if (previousDocumentLine != null) {
				var previousLine = textView.GetOrConstructVisualLine(previousDocumentLine);
				pos = previousLine.GetNextCaretPosition(previousLine.VisualLength + 1, LogicalDirection.Backward, mode, enableVirtualSpace);
				return previousLine.GetTextViewPosition(pos);
			}
			return new TextViewPosition(0, 0);
		}
开发者ID:GreenDamTan,项目名称:dnSpy,代码行数:12,代码来源:ReplEditorUI.cs


示例20: MoveCaretRight

 static void MoveCaretRight(TextArea textArea, TextViewPosition caretPosition, VisualLine visualLine, CaretPositioningMode mode)
 {
     int pos = visualLine.GetNextCaretPosition(caretPosition.VisualColumn, LogicalDirection.Forward, mode);
     if (pos >= 0) {
         SetCaretPosition(textArea, pos, visualLine.GetRelativeOffset(pos) + visualLine.FirstDocumentLine.Offset);
     } else {
         // move to start of next line
         DocumentLine nextDocumentLine = visualLine.LastDocumentLine.NextLine;
         if (nextDocumentLine != null) {
             VisualLine nextLine = textArea.TextView.GetOrConstructVisualLine(nextDocumentLine);
             pos = nextLine.GetNextCaretPosition(-1, LogicalDirection.Forward, mode);
             if (pos < 0)
                 throw ThrowUtil.NoValidCaretPosition();
             SetCaretPosition(textArea, pos, nextLine.GetRelativeOffset(pos) + nextLine.FirstDocumentLine.Offset);
         } else {
             // at end of document
             Debug.Assert(visualLine.LastDocumentLine.Offset + visualLine.LastDocumentLine.TotalLength == textArea.Document.TextLength);
             SetCaretPosition(textArea, -1, textArea.Document.TextLength);
         }
     }
 }
开发者ID:Amichai,项目名称:PhysicsPad,代码行数:21,代码来源:CaretNavigationCommandHandler.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Snippets.InsertionContext类代码示例发布时间:2022-05-26
下一篇:
C# Rendering.HeightTreeNode类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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