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


C# TextView.EnsureVisualLines方法代码示例

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


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

示例1: Draw

        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            textView.EnsureVisualLines();

            #region Highlight Error Tokens

            var errorsToVisualize = _solution.ErrorService.GetErrorsFromDocument(_codeitem);

            foreach(var err in errorsToVisualize) {
                if(err.Range != null) {
                    foreach(Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, err.Range)) {
                        //drawingContext.DrawRectangle(null, _errorPen, r);
                        drawingContext.DrawLine(_errorPen, r.BottomLeft, r.BottomRight);
                    }
                } else {

                    var line = _editor.Document.GetLineByNumber(err.StartLine);
                    if(line != null) {
                        var segment = new TextSegment { StartOffset = line.Offset, EndOffset = line.EndOffset };

                        foreach(Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment)) {
                            drawingContext.DrawRectangle(_errorBrush, _errorPen, r);
                        }
                    }
                }
            }

            #endregion
        }
开发者ID:RaptorOne,项目名称:SmartDevelop,代码行数:29,代码来源:ErrorBackgroundRenderer.cs

示例2: Draw

        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (_editor.Document == null)
                return;

            textView.EnsureVisualLines();
            var currentLine = _editor.Document.GetLineByOffset(_editor.CaretOffset);
            foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, currentLine))
            {
                drawingContext.DrawRectangle(
                    new SolidColorBrush(Color.FromArgb(0x40, 0, 0, 0xFF)), null,
                    new Rect(rect.Location, new Size(textView.ActualWidth - 32, rect.Height)));
            }
        }
开发者ID:tpetrina,项目名称:FastSharp,代码行数:14,代码来源:LineBackgroundRenderer.cs

示例3: Draw

        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            textView.EnsureVisualLines();

            foreach (var lineToHighlight in HighlightedLines.Where(i => textView.Document.LineCount >= i))
            {
                if (lineToHighlight <= 0)
                    continue;

                foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, textView.Document.GetLineByNumber(lineToHighlight), true))
                {
                    drawingContext.DrawRectangle(new SolidColorBrush(Color.FromArgb(100, 255, 184, 0)), null, new Rect(rect.Location, new Size(textView.ActualWidth, rect.Height)));
                }
            }
        }
开发者ID:Abc-Arbitrage,项目名称:Abc.NCrafts.Quiz,代码行数:15,代码来源:LineHighlighterBackgroundRenderer.cs

示例4: Draw

        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (m_textEditor.Document == null || m_textBlocks == null)
            return;

              textView.EnsureVisualLines();

              foreach (TextBlock textBlock in m_textBlocks)
              {
            foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, textBlock))
            {
              drawingContext.DrawRectangle(
            new SolidColorBrush(textBlock.Color), new Pen(new SolidColorBrush(textBlock.BorderColor), 1),
            rect);
            }
              }
        }
开发者ID:grarup,项目名称:SharpE,代码行数:17,代码来源:TextMarkingBackGroundRender.cs

示例5: Draw

 public void Draw(TextView textView, DrawingContext drawingContext)
 {
     textView.EnsureVisualLines();
     if (_line.IsDeleted) return;
     var segment = new TextSegment
     {
         StartOffset = _line.Offset,
         EndOffset = _line.EndOffset
     };
     // ReSharper disable once RedundantArgumentDefaultValue
     foreach (var current in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment, false))
     {
         drawingContext.DrawRoundedRectangle(new SolidColorBrush(EditorOptions.Instance.HighlightedLineColor),
             new Pen(Brushes.Red, 0.0),
             new Rect(current.Location, new Size(textView.ActualWidth, current.Height)), 3.0, 3.0);
     }
 }
开发者ID:mookiejones,项目名称:miEditor,代码行数:17,代码来源:BackgroundRenderer.cs

示例6: Draw

        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            textView.EnsureVisualLines();

            #region Highlight Current Line

            if(lastLine != _editor.TextArea.Caret.Line) {
                var line = _editor.Document.GetLineByOffset(_editor.CaretOffset);
                var segment = new TextSegment { StartOffset = line.Offset, EndOffset = line.EndOffset };
                foreach(Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment)) {
                    drawingContext.DrawRoundedRectangle(_lineSelection, _borderPen, new Rect(r.Location, new Size(textView.ActualWidth, r.Height)), 3, 3);
                }
            }

            #endregion

            #region Highlight Brackets

            if(_editor.TextArea.Caret.Offset > 1 && TokenHelper.BRAKETS.ContainsKey(_editor.TextArea.Document.GetCharAt(_editor.TextArea.Caret.Offset - 1))) {
                var offset = _editor.TextArea.Caret.Offset;
                var seg = _projectitem.SegmentService.QueryCodeSegmentAt(offset);
                if(seg != null && TokenHelper.BRAKETS.ContainsValue(seg.Token)) {
                    var other = seg.FindOtherBracked(true);

                    var col = other != null ? _braketMatch : _braketMatchFail;
                    var braketsegment = new TextSegment { StartOffset = seg.Range.Offset, EndOffset = seg.Range.EndOffset };
                    foreach(Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, braketsegment)) {
                        drawingContext.DrawRectangle(col, _borderPen, r);
                    }

                    if(other != null) {
                        braketsegment = new TextSegment { StartOffset = other.Range.Offset, EndOffset = other.Range.EndOffset };
                        foreach(Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, braketsegment)) {
                            drawingContext.DrawRectangle(_braketMatch, _borderPen, r);
                        }
                    }
                }
            }

            #endregion
        }
开发者ID:RaptorOne,项目名称:SmartDevelop,代码行数:41,代码来源:CurrentLineHighlightRenderer.cs

示例7: Draw

        public void Draw(TextView textView, DrawingContext drawingContext)
        {

            textView.EnsureVisualLines();
            bool odd = true;
            if (!G.AppSettings.isFixedBackgroundLines)
            if (textView.VisualLines[0].FirstDocumentLine.LineNumber % 2 == 0)
               odd = false;            
            for (int i = 0; i < textView.VisualLines.Count; i++)
            {
                //textView.LineTransformers.Add(IVisualLineTransformer)
                //textView.Options
                var segment = new TextSegment
                {
                    StartOffset = textView.VisualLines[i].FirstDocumentLine.Offset,
                    EndOffset = textView.VisualLines[i].LastDocumentLine.EndOffset
                };
                foreach (Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment))
                {

                    if (!odd)
                    //if (textView.VisualLines[i].FirstDocumentLine.LineNumber % 2 == 0)
                        drawingContext.DrawRectangle(scbEven,
                                                        border,
                                                        new Rect(r.Location, new Size(textView.ActualWidth, r.Height))
                                                        );
                    else
                        
                        drawingContext.DrawRectangle(scbOdd,
                                                            border,
                                                            new Rect(r.Location, new Size(textView.ActualWidth, r.Height))
                                                            );
                    if (odd) odd = false; else odd = true;
                }
            }    //foreach
        }
开发者ID:NightmareX1337,项目名称:lfs,代码行数:36,代码来源:LinesBackgroundRenderer.cs

示例8: Draw

        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (m_textEditor.Document == null)
            return;

              textView.EnsureVisualLines();

              var currentLine = m_textEditor.Document.GetLineByOffset(m_textEditor.CaretOffset);
              foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, currentLine))
              {
            drawingContext.DrawRectangle(
              new SolidColorBrush(Color.FromArgb(0xFF, 0x10, 0x10, 0x10)), null,
              new Rect(rect.Location, new Size(textView.ActualWidth, rect.Height)));
            Brush edgeBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x60, 0x60, 0x60));
            drawingContext.DrawRectangle(
              edgeBrush, null,
              new Rect(rect.Location, new Size(textView.ActualWidth, 1)));
            Point point = rect.Location;
            point.Offset(0, rect.Height);
            drawingContext.DrawRectangle(
              edgeBrush, null,
              new Rect(point, new Size(textView.ActualWidth, 1)));
              }
        }
开发者ID:grarup,项目名称:SharpE,代码行数:24,代码来源:CaretLineBackGroundRender.cs

示例9: Draw

        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (_editor.Document == null)
                return;

            for (int i=start_line; i<start_line+no_lines; i++)
            {
                if (!(i > 0)) return;
                textView.EnsureVisualLines();
                var currentLine = _editor.Document.GetLineByNumber(i);
                foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, currentLine))
                {
                    drawingContext.DrawRectangle(
                        new SolidColorBrush(Color.FromArgb(0x20, 0, 0xFF, 0)), null,
                        new Rect(rect.Location, new Size(textView.ActualWidth, rect.Height)));
                }
            }
        }
开发者ID:nccgroup,项目名称:tybocer,代码行数:18,代码来源:CodeHighlighters.cs

示例10: Draw

            public void Draw(TextView textView, DrawingContext drawingContext)
            {
                if (textView.Document == null) return;

                textView.EnsureVisualLines();

                var firstLine = textView.VisualLines.First().FirstDocumentLine.LineNumber;
                int nextBlockLine = int.MaxValue;
                int blockIndex;
                Color backColor;
                MergeAlternate alt;
                MergeLocation colorLocation;

                for (blockIndex = 1; blockIndex < _view._starts.Count; blockIndex++)
                {
                  if (_view._starts[blockIndex].LineNumber > firstLine)
                  {
                nextBlockLine = _view._starts[blockIndex].LineNumber;
                blockIndex--;
                break;
                  }
                }
                if (blockIndex >= _view._starts.Count) blockIndex = _view._starts.Count - 1;

                foreach (var visLine in textView.VisualLines)
                {
                  if (visLine.FirstDocumentLine.LineNumber >= nextBlockLine)
                  {
                blockIndex++;
                nextBlockLine = (blockIndex < (_view._starts.Count - 1) ? _view._starts[blockIndex + 1].LineNumber : int.MaxValue);
                  }

                  alt = _view._starts[blockIndex].Alternate;
                  if (_view._starts[blockIndex].Alternate.Parent.Alternates.Count > 1
                && (_view.Location == MergeLocation.Output
                  || _view.Location == MergeLocation.Parent
                  || (alt.Location & MergeLocation.Parent) == 0))
                  {

                colorLocation = alt.Location & ~MergeLocation.Output;
                if (_view.Location == MergeLocation.Output)
                {
                  if ((colorLocation & MergeLocation.Right) != 0)
                  {
                backColor = GetColor(MergeLocation.Right);
                  }
                  else if ((colorLocation & MergeLocation.Parent) != 0)
                  {
                backColor = GetColor(MergeLocation.Parent);
                  }
                  else
                  {
                backColor = GetColor(MergeLocation.Left);
                  }
                }
                else
                {
                  backColor = GetColor(_view.Location);
                  if (colorLocation == (MergeLocation.Left | MergeLocation.Right)) backColor = GetColor(MergeLocation.Right);
                }

                var backgroundGeometryBuilder = new BackgroundGeometryBuilder();
                var y = visLine.VisualTop - textView.ScrollOffset.Y;
                backgroundGeometryBuilder.AddRectangle(textView, new Rect(0.0, y, textView.ActualWidth, visLine.Height));
                var geometry = backgroundGeometryBuilder.CreateGeometry();
                if (geometry != null)
                {
                  drawingContext.DrawGeometry(new SolidColorBrush(backColor), null, geometry);
                }
                  }
                }
            }
开发者ID:Barnickle,项目名称:InnovatorAdmin,代码行数:72,代码来源:MergeView.cs

示例11: Draw

      public void Draw(TextView textView, DrawingContext drawingContext)
      {
        if (textView.Document == null) return;

        textView.EnsureVisualLines();

        Color backColor;
        foreach (var visLine in textView.VisualLines)
        {
          backColor = default(Color);
          switch (GetDiffType(visLine.FirstDocumentLine.LineNumber))
          {
            case DiffType.Add:
              backColor = this.AddColor;
              break;
            case DiffType.Change:
              backColor = Color.FromRgb(0xcc, 0xcc, 0xff);
              break;
          }

          if (backColor != default(Color))
          {
            var backgroundGeometryBuilder = new BackgroundGeometryBuilder();
            var y = visLine.VisualTop - textView.ScrollOffset.Y;
            backgroundGeometryBuilder.AddRectangle(textView, new Rect(0.0, y, textView.ActualWidth, visLine.Height));
            var geometry = backgroundGeometryBuilder.CreateGeometry();
            if (geometry != null)
            {
              drawingContext.DrawGeometry(new SolidColorBrush(backColor), null, geometry);
            }
          }
        }
      }
开发者ID:cornelius90,项目名称:InnovatorAdmin,代码行数:33,代码来源:DiffViewer.xaml.cs

示例12: Draw

        public void Draw(TextView textView, DrawingContext drawingContext)
        {
          
            try
            {
                textView.EnsureVisualLines();
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                bool odd = true;
                if (!G.AppSettings.isFixedBackgroundLines)
                    if (textView.VisualLines.Count>0)
                    if (textView.VisualLines[0].FirstDocumentLine.LineNumber % 2 == 0)
                        odd = false;
                for (int i = 0; i < textView.VisualLines.Count; i++)
                {
                    var segment2 = new TextSegment
                    {
                        StartOffset = textView.VisualLines[i].FirstDocumentLine.Offset,
                        EndOffset = textView.VisualLines[i].LastDocumentLine.EndOffset
                    };
                    foreach (Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment2))
                    {
                        if (!odd)
                            drawingContext.DrawRectangle(scbEven, border,
                                                           new Rect(r.Location, new Size(textView.ActualWidth, r.Height)));//draw even line
                        else drawingContext.DrawRectangle(scbOdd, border,
                                                                new Rect(r.Location, new Size(textView.ActualWidth, r.Height)));//draw odd line
                        if (G.AppSettings.isShowUnderline)
                        {
                            string str = editor.Document.GetText(textView.VisualLines[i].FirstDocumentLine.Offset, textView.VisualLines[i].FirstDocumentLine.Length);
                            //if (str.Contains("<frame_end>") || str.Contains("<bmp_end>"))
                            if (Contains(str, G.AppSettings.underlineThisWords))
                            {
                                double halfPenWidth = lpen.Thickness / 2;
                                GuidelineSet guidelines = new GuidelineSet();
                                guidelines.GuidelinesX.Add(r.Left + halfPenWidth);
                                guidelines.GuidelinesX.Add(r.Right + halfPenWidth);
                                guidelines.GuidelinesY.Add(r.Top + halfPenWidth);
                                guidelines.GuidelinesY.Add(r.Bottom + halfPenWidth);
                                drawingContext.PushGuidelineSet(guidelines);
                                drawingContext.DrawLine(lpen, new Point(r.Left, r.Bottom), new Point(textView.ActualWidth, r.Bottom)); //draw underline                            
                            }
                        }
                        if (odd) odd = false; else odd = true;
                    }     //foreach
                }    //for
                ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                var line = editor.Document.GetLineByOffset(editor.CaretOffset);
                var segment = new TextSegment { StartOffset = line.Offset, EndOffset = line.EndOffset };
                foreach (Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment))
                {
                    drawingContext.DrawRectangle(lgbLine, border,
                                                 new Rect(r.Location, new Size(textView.ActualWidth, r.Height))); //Draw current cursor line
                    if (G.AppSettings.isShowUnderline)
                    {
                        string str2 = editor.Document.GetText(segment);

                        if (Contains(str2, G.AppSettings.underlineThisWords))
                        {
                            double halfPenWidth = lpen.Thickness / 2;
                            GuidelineSet guidelines = new GuidelineSet();
                            guidelines.GuidelinesX.Add(r.Left + halfPenWidth);
                            guidelines.GuidelinesX.Add(r.Right + halfPenWidth);
                            guidelines.GuidelinesY.Add(r.Top + halfPenWidth);
                            guidelines.GuidelinesY.Add(r.Bottom + halfPenWidth);
                            drawingContext.PushGuidelineSet(guidelines);
                            drawingContext.DrawLine(lpen, new Point(r.Left, r.Bottom), new Point(textView.ActualWidth, r.Bottom)); //correct underline
                        }
                    }
                }
            }
            catch (Exception ex) { new wException(ex).ShowDialog(); }
        }//Draw end
开发者ID:NightmareX1337,项目名称:lfs,代码行数:72,代码来源:XBackgroundRenderer.cs

示例13: Draw

        public void Draw(TextView textView, DrawingContext ctx)
        {
            textView.EnsureVisualLines();

            // update first and last line
            viewportFirstLine = editor.TextArea.TextView.GetDocumentLineByVisualTop(editor.TextArea.TextView.ScrollOffset.Y);
            viewportLastLine = editor.TextArea.TextView.GetDocumentLineByVisualTop(editor.TextArea.TextView.ScrollOffset.Y + editor.ActualHeight);

            #region Draw tabs

            if (Settings.Instance.ShowTabsInEditor)
            {
                foreach (Match match in Regex.Matches(editor.Text, "\t"))
                {
                    if (!IsOffsetInsideViewport(match.Index, match.Index + 1))
                        continue;

                    var rects = BackgroundGeometryBuilder.GetRectsForSegment(editor.TextArea.TextView, new TextSegment {
                        StartOffset = match.Index,
                        Length = 1,
                    });

                    if (rects.Count() == 0)
                        continue;

                    var rect = rects.First();
                    var x1 = rect.X + 3;
                    var y1 = rect.Y + rect.Height / 2;

                    var x2 = rect.X + rect.Width - 3;
                    var y2 = y1;

                    if (x1 < 0 || y1 < 0 || x2 < 0 || y2 < 0 || x1 == x2)
                        continue;

                    var pen = new Pen
                    {
                        Brush = tabsColor,
                        Thickness = 0.3
                    };

                    ctx.DrawLine(pen, new Point(x1, y1), new Point(x2, y2));
                }
            }

            #endregion

            #region Draw spaces

            if (Settings.Instance.ShowSpacesInEditor)
            {
                foreach (Match match in Regex.Matches(editor.Text, " "))
                {
                    if (!IsOffsetInsideViewport(match.Index, match.Index + 1))
                        continue;

                    var point = GetPositionFromOffset(editor, VisualYPosition.LineMiddle, match.Index);

                    var x1 = point.X - editor.TextArea.TextView.ScrollOffset.X + 2;
                    var y1 = point.Y - editor.TextArea.TextView.ScrollOffset.Y;

                    var x2 = point.X - editor.TextArea.TextView.ScrollOffset.X + 4;
                    var y2 = point.Y - editor.TextArea.TextView.ScrollOffset.Y;

                    if (x1 < 0 || y1 < 0 || x2 < 0 || y2 < 0 || x1 == x2)
                        continue;

                    var pen = new Pen
                    {
                        Brush = spacesColor,
                        Thickness = 1
                    };

                    ctx.DrawLine(pen, new Point(x1, y1), new Point(x2, y2));
                }
            }

            #endregion

            #region Draw highlighted line

            if (Theme.Instance.HighlightLineOfCaret && editor.TextArea.IsFocused)
            {
                var line = editor.Document.GetLineByOffset(editor.CaretOffset);
                var start = GetPositionFromOffset(editor, VisualYPosition.LineTop, line.Offset);
                var end = GetPositionFromOffset(editor, VisualYPosition.LineBottom, line.Offset);

                ctx.DrawRoundedRectangle(lineOfCaret, new Pen(), new Rect(start.X, start.Y - editor.TextArea.TextView.ScrollOffset.Y, textView.ActualWidth, end.Y - start.Y), 3, 3);
            }

            #endregion

            #region Draw blocks

            foreach (var block in blocks)
            {
                if (!IsOffsetInsideViewport(block.Offset, block.Offset + block.Length))
                    continue;

                var startPosition = GetPositionFromOffset(editor, VisualYPosition.LineTop, block.Offset);
//.........这里部分代码省略.........
开发者ID:anaimi,项目名称:farawla,代码行数:101,代码来源:BlockHighlighter.cs


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