コード例 #1
0
        private void RenderBorders(Cell cell, Rectangle innerRect)
        {
            XUnit   leftPos       = innerRect.X;
            XUnit   rightPos      = leftPos + innerRect.Width;
            XUnit   topPos        = innerRect.Y;
            XUnit   bottomPos     = innerRect.Y + innerRect.Height;
            Borders mergedBorders = _mergedCells.GetEffectiveBorders(cell);

            BordersRenderer bordersRenderer = new BordersRenderer(mergedBorders, _gfx);
            XUnit           bottomWidth     = bordersRenderer.GetWidth(BorderType.Bottom);
            XUnit           leftWidth       = bordersRenderer.GetWidth(BorderType.Left);
            XUnit           topWidth        = bordersRenderer.GetWidth(BorderType.Top);
            XUnit           rightWidth      = bordersRenderer.GetWidth(BorderType.Right);

            if (cell.RoundedCorner == RoundedCorner.TopLeft)
            {
                bordersRenderer.RenderRounded(cell.RoundedCorner, innerRect.X, innerRect.Y, innerRect.Width + rightWidth, innerRect.Height + bottomWidth);
            }
            else if (cell.RoundedCorner == RoundedCorner.TopRight)
            {
                bordersRenderer.RenderRounded(cell.RoundedCorner, innerRect.X - leftWidth, innerRect.Y, innerRect.Width + leftWidth, innerRect.Height + bottomWidth);
            }
            else if (cell.RoundedCorner == RoundedCorner.BottomLeft)
            {
                bordersRenderer.RenderRounded(cell.RoundedCorner, innerRect.X, innerRect.Y - topWidth, innerRect.Width + rightWidth, innerRect.Height + topWidth);
            }
            else if (cell.RoundedCorner == RoundedCorner.BottomRight)
            {
                bordersRenderer.RenderRounded(cell.RoundedCorner, innerRect.X - leftWidth, innerRect.Y - topWidth, innerRect.Width + leftWidth, innerRect.Height + topWidth);
            }

            // Render horizontal and vertical borders only if touching no rounded corner.
            if (cell.RoundedCorner != RoundedCorner.TopRight && cell.RoundedCorner != RoundedCorner.BottomRight)
            {
                bordersRenderer.RenderVertically(BorderType.Right, rightPos, topPos, bottomPos + bottomWidth - topPos);
            }

            if (cell.RoundedCorner != RoundedCorner.TopLeft && cell.RoundedCorner != RoundedCorner.BottomLeft)
            {
                bordersRenderer.RenderVertically(BorderType.Left, leftPos - leftWidth, topPos, bottomPos + bottomWidth - topPos);
            }

            if (cell.RoundedCorner != RoundedCorner.BottomLeft && cell.RoundedCorner != RoundedCorner.BottomRight)
            {
                bordersRenderer.RenderHorizontally(BorderType.Bottom, leftPos - leftWidth, bottomPos, rightPos + rightWidth + leftWidth - leftPos);
            }

            if (cell.RoundedCorner != RoundedCorner.TopLeft && cell.RoundedCorner != RoundedCorner.TopRight)
            {
                bordersRenderer.RenderHorizontally(BorderType.Top, leftPos - leftWidth, topPos - topWidth, rightPos + rightWidth + leftWidth - leftPos);
            }

            RenderDiagonalBorders(mergedBorders, innerRect);
        }
コード例 #2
0
        void RenderBorders(Cell cell, Rectangle innerRect)
        {
            XUnit   leftPos       = innerRect.X;
            XUnit   rightPos      = leftPos + innerRect.Width;
            XUnit   topPos        = innerRect.Y;
            XUnit   bottomPos     = innerRect.Y + innerRect.Height;
            Borders mergedBorders = this.mergedCells.GetEffectiveBorders(cell);

            BordersRenderer bordersRenderer = new BordersRenderer(mergedBorders, this.gfx);
            XUnit           bottomWidth     = bordersRenderer.GetWidth(BorderType.Bottom);
            XUnit           leftWidth       = bordersRenderer.GetWidth(BorderType.Left);
            XUnit           topWidth        = bordersRenderer.GetWidth(BorderType.Top);
            XUnit           rightWidth      = bordersRenderer.GetWidth(BorderType.Right);

            bordersRenderer.RenderVertically(BorderType.Right, rightPos, topPos, bottomPos + bottomWidth - topPos);
            bordersRenderer.RenderVertically(BorderType.Left, leftPos - leftWidth, topPos, bottomPos + bottomWidth - topPos);
            bordersRenderer.RenderHorizontally(BorderType.Bottom, leftPos - leftWidth, bottomPos, rightPos + rightWidth + leftWidth - leftPos);
            bordersRenderer.RenderHorizontally(BorderType.Top, leftPos - leftWidth, topPos - topWidth, rightPos + rightWidth + leftWidth - leftPos);

            RenderDiagonalBorders(mergedBorders, innerRect);
        }
コード例 #3
0
ファイル: ParagraphRenderer.cs プロジェクト: DavidS/MigraDoc
    void RenderBorders()
    {
      if (this.paragraph.Format.IsNull("Borders"))
        return;

      Area shadingArea = GetShadingArea();
      XUnit left = shadingArea.X;
      XUnit top = shadingArea.Y;
      XUnit bottom = shadingArea.Y + shadingArea.Height;
      XUnit right = shadingArea.X + shadingArea.Width;

      Borders borders = this.paragraph.Format.Borders;
      BordersRenderer bordersRenderer = new BordersRenderer(borders, this.gfx);
      XUnit borderWidth = bordersRenderer.GetWidth(BorderType.Left);
      if (borderWidth > 0)
      {
        left -= borderWidth;
        bordersRenderer.RenderVertically(BorderType.Left, left, top, bottom - top);
      }

      borderWidth = bordersRenderer.GetWidth(BorderType.Right);
      if (borderWidth > 0)
      {
        bordersRenderer.RenderVertically(BorderType.Right, right, top, bottom - top);
        right += borderWidth;
      }

      borderWidth = bordersRenderer.GetWidth(BorderType.Top);
      if (this.renderInfo.FormatInfo.IsStarting && borderWidth > 0)
      {
        top -= borderWidth;
        bordersRenderer.RenderHorizontally(BorderType.Top, left, top, right - left);
      }

      borderWidth = bordersRenderer.GetWidth(BorderType.Bottom);
      if (this.renderInfo.FormatInfo.IsEnding && borderWidth > 0)
      {
        bordersRenderer.RenderHorizontally(BorderType.Bottom, left, bottom, right - left);
      }
    }
コード例 #4
0
    void RenderBorders(Cell cell, Rectangle innerRect)
    {
      XUnit leftPos = innerRect.X;
      XUnit rightPos = leftPos + innerRect.Width;
      XUnit topPos = innerRect.Y;
      XUnit bottomPos = innerRect.Y + innerRect.Height;
      Borders mergedBorders = this.mergedCells.GetEffectiveBorders(cell);

      BordersRenderer bordersRenderer = new BordersRenderer(mergedBorders, this.gfx);
      XUnit bottomWidth = bordersRenderer.GetWidth(BorderType.Bottom);
      XUnit leftWidth = bordersRenderer.GetWidth(BorderType.Left);
      XUnit topWidth = bordersRenderer.GetWidth(BorderType.Top);
      XUnit rightWidth = bordersRenderer.GetWidth(BorderType.Right);

      bordersRenderer.RenderVertically(BorderType.Right, rightPos, topPos, bottomPos + bottomWidth - topPos);
      bordersRenderer.RenderVertically(BorderType.Left, leftPos - leftWidth, topPos, bottomPos + bottomWidth - topPos);
      bordersRenderer.RenderHorizontally(BorderType.Bottom, leftPos - leftWidth, bottomPos, rightPos + rightWidth + leftWidth - leftPos);
      bordersRenderer.RenderHorizontally(BorderType.Top, leftPos - leftWidth, topPos - topWidth, rightPos + rightWidth + leftWidth - leftPos);

      RenderDiagonalBorders(mergedBorders, innerRect);
    }
コード例 #5
0
ファイル: TableRenderer.cs プロジェクト: Sl0vi/MigraDoc
        private void RenderBorders(Cell cell, Rectangle innerRect)
        {
            XUnit leftPos = innerRect.X;
            XUnit rightPos = leftPos + innerRect.Width;
            XUnit topPos = innerRect.Y;
            XUnit bottomPos = innerRect.Y + innerRect.Height;
            Borders mergedBorders = _mergedCells.GetEffectiveBorders(cell);

            BordersRenderer bordersRenderer = new BordersRenderer(mergedBorders, _gfx);
            XUnit bottomWidth = bordersRenderer.GetWidth(BorderType.Bottom);
            XUnit leftWidth = bordersRenderer.GetWidth(BorderType.Left);
            XUnit topWidth = bordersRenderer.GetWidth(BorderType.Top);
            XUnit rightWidth = bordersRenderer.GetWidth(BorderType.Right);

            if (cell.RoundedCorner == RoundedCorner.TopLeft)
                bordersRenderer.RenderRounded(cell.RoundedCorner, innerRect.X, innerRect.Y, innerRect.Width + rightWidth, innerRect.Height + bottomWidth);
            else if (cell.RoundedCorner == RoundedCorner.TopRight)
                bordersRenderer.RenderRounded(cell.RoundedCorner, innerRect.X - leftWidth, innerRect.Y, innerRect.Width + leftWidth, innerRect.Height + bottomWidth);
            else if (cell.RoundedCorner == RoundedCorner.BottomLeft)
                bordersRenderer.RenderRounded(cell.RoundedCorner, innerRect.X, innerRect.Y - topWidth, innerRect.Width + rightWidth, innerRect.Height + topWidth);
            else if (cell.RoundedCorner == RoundedCorner.BottomRight)
                bordersRenderer.RenderRounded(cell.RoundedCorner, innerRect.X - leftWidth, innerRect.Y - topWidth, innerRect.Width + leftWidth, innerRect.Height + topWidth);

            // Render horizontal and vertical borders only if touching no rounded corner.
            if (cell.RoundedCorner != RoundedCorner.TopRight && cell.RoundedCorner != RoundedCorner.BottomRight)
                bordersRenderer.RenderVertically(BorderType.Right, rightPos, topPos, bottomPos + bottomWidth - topPos);
            
            if (cell.RoundedCorner != RoundedCorner.TopLeft && cell.RoundedCorner != RoundedCorner.BottomLeft)
                bordersRenderer.RenderVertically(BorderType.Left, leftPos - leftWidth, topPos, bottomPos + bottomWidth - topPos);

            if (cell.RoundedCorner != RoundedCorner.BottomLeft && cell.RoundedCorner != RoundedCorner.BottomRight)
                bordersRenderer.RenderHorizontally(BorderType.Bottom, leftPos - leftWidth, bottomPos, rightPos + rightWidth + leftWidth - leftPos);

            if (cell.RoundedCorner != RoundedCorner.TopLeft && cell.RoundedCorner != RoundedCorner.TopRight)
                bordersRenderer.RenderHorizontally(BorderType.Top, leftPos - leftWidth, topPos - topWidth, rightPos + rightWidth + leftWidth - leftPos);
            
            RenderDiagonalBorders(mergedBorders, innerRect);
        }