AddRectangle() public method

Adds a rectangle to the geometry.
public AddRectangle ( double left, double top, double right, double bottom ) : void
left double
top double
right double
bottom double
return void
        public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (!this.textView.Options.HighlightCurrentLine)
            {
                return;
            }

            BackgroundGeometryBuilder builder = new BackgroundGeometryBuilder();

            var visualLine = this.textView.GetVisualLine(line);

            if (visualLine == null)
            {
                return;
            }

            var linePosY = visualLine.VisualTop - this.textView.ScrollOffset.Y;

            builder.AddRectangle(textView, new Rect(0, linePosY, textView.ActualWidth, visualLine.Height));

            Geometry geometry = builder.CreateGeometry();

            if (geometry != null)
            {
                drawingContext.DrawGeometry(this.BackgroundBrush, this.BorderPen, geometry);
            }
        }
		public void Draw(TextView textView, DrawingContext drawingContext)
		{
			if(!this.textView.Options.HighlightCurrentLine)
				return;
			
			BackgroundGeometryBuilder builder = new BackgroundGeometryBuilder();
			
			var visualLine = this.textView.GetVisualLine(line);
			if (visualLine == null) return;
			
			var linePosY = visualLine.VisualTop - this.textView.ScrollOffset.Y;
			
			builder.AddRectangle(textView, new Rect(0, linePosY, textView.ActualWidth, visualLine.Height));
			
			Geometry geometry = builder.CreateGeometry();
			if (geometry != null) {
				drawingContext.DrawGeometry(this.BackgroundBrush, this.BorderPen, geometry);
			}
		}
Example #3
0
            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);
                }
                  }
                }
            }
      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);
            }
          }
        }
      }