Exemplo n.º 1
0
        /// <summary>
        /// [email protected] : for FreezePanes enhancement, draw method is extended by adding a parameter to specify which border should be drawn.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="area"></param>
        /// <param name="partType"></param>
        public override void Draw(GraphicsCache graphics, RectangleF area, BorderPartType partType)
        {
            Border3DSide sides = Border3DSide.All;

            if (partType == BorderPartType.All)
            {
                sides = Border3DSide.All;
            }

            if (BorderStyle == BorderStyle.System)
            {
                ControlPaint.DrawBorder3D(graphics.Graphics, Rectangle.Round(area), Border3DStyle.Flat, sides);
            }
        }
Exemplo n.º 2
0
 public override void Draw(GraphicsCache graphics, RectangleF area, BorderPartType partType)
 {
     if (Application.RenderWithVisualStyles && VisualStyleRenderer.IsElementDefined(GetBackgroundElement()))
     {
         if (BorderStyle == BorderStyle.System)
         {
             GetRenderer(GetBackgroundElement()).DrawBackground(graphics.Graphics, Rectangle.Round(area));
         }
     }
     else
     {
         //[email protected]: for FreezePanes enhancement, draw method is extended by adding a parameter to specify which border should be drawn.
         mStandard.Draw(graphics, area, partType);
     }
 }
Exemplo n.º 3
0
        public BorderPartType GetBorderType(Range rng)
        {
            BorderPartType partType = BorderPartType.All;

            if (m_Grid.IsRowHiddenUnderFixedRows(rng.End.Row))
            {
                partType &= ~(BorderPartType.BottomBorder | BorderPartType.DragRectangle);
            }
            if (m_Grid.IsColumnHiddenUnderFixedColumn(rng.End.Column))
            {
                partType &= ~(BorderPartType.RightBorder | BorderPartType.DragRectangle);
            }
            if (m_Grid.IsRowHiddenUnderFixedRows(rng.Start.Row, true))
            {
                partType &= ~(BorderPartType.TopBorder);
            }
            if (m_Grid.IsColumnHiddenUnderFixedColumn(rng.Start.Column, true))
            {
                partType &= ~(BorderPartType.LeftBorder);
            }
            return(partType);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Draw the current VisualElement in the specified Graphics object.
 /// [email protected] : for FreezePanes enhancement, draw method is extended by adding a parameter to specify which border should be drawn.
 /// </summary>
 /// <param name="graphics"></param>
 /// <param name="area"></param>
 /// <param name="partType"></param>
 public abstract void Draw(GraphicsCache graphics, System.Drawing.RectangleF area, BorderPartType partType);
Exemplo n.º 5
0
        public BorderPartType GetBorderType(Range rng)
        {
            BorderPartType partType = BorderPartType.All;

            int lastFixedColumn = m_Grid.ActualFixedColumns - 1;
            int lastFixedRow    = m_Grid.ActualFixedRows - 1;

            int?firstVisibleScrollableColumn = FirstVisibleScrollableColumn;
            int?firstVisibleScrollableRow    = FirstVisibleScrollableRow;

            if (!firstVisibleScrollableColumn.HasValue || !firstVisibleScrollableRow.HasValue)
            {
                return(partType);
            }

            #region firstColumn check

            int firstColumn = rng.Start.Column;

            if (firstColumn > lastFixedColumn && firstColumn < firstVisibleScrollableColumn)
            {
                partType &= ~(BorderPartType.LeftBorder);
            }
            else if (firstColumn == firstVisibleScrollableColumn)
            {
                if (IsColumnHiddenUnderFixedColumn(firstColumn, true))
                {
                    partType &= ~(BorderPartType.LeftBorder);
                }
            }
            #endregion firstColumn check

            #region lastColumn check
            int lastColumn = rng.End.Column;
            if (lastColumn != firstColumn && lastColumn > lastFixedColumn)
            {
                if (lastColumn < firstVisibleScrollableColumn)
                {
                    partType &= ~(BorderPartType.RightBorder | BorderPartType.DragRectangle);
                }
                else if (lastColumn == firstVisibleScrollableColumn)
                {
                    if (IsColumnHiddenUnderFixedColumn(lastColumn, false))
                    {
                        partType &= ~(BorderPartType.RightBorder | BorderPartType.DragRectangle);
                    }
                }
            }

            #endregion lastColumn check


            #region firstRow check
            int firstRow = rng.Start.Row;
            if (firstRow > lastFixedRow && firstRow < firstVisibleScrollableRow)
            {
                partType &= ~(BorderPartType.TopBorder);
            }
            else if (firstRow == firstVisibleScrollableRow)
            {
                if (IsRowHiddenUnderFixedRows(firstRow, true))
                {
                    partType &= ~(BorderPartType.TopBorder);
                }
            }

            #endregion firstRow check

            #region lastRow check
            int lastRow = rng.End.Row;
            if (lastRow != firstRow && lastRow > lastFixedRow)
            {
                if (lastRow < firstVisibleScrollableRow)
                {
                    partType &= ~(BorderPartType.BottomBorder | BorderPartType.DragRectangle);
                }
                else if (lastRow == firstVisibleScrollableRow)
                {
                    if (IsRowHiddenUnderFixedRows(lastRow, false))
                    {
                        partType &= ~(BorderPartType.BottomBorder | BorderPartType.DragRectangle);
                    }
                }
            }
            #endregion lastRow check

            return(partType);
        }
Exemplo n.º 6
0
        //public void Draw(GraphicsCache graphics, RectangleF rectangle)
        //{
        //    RectangleBorder border = this;

        //    //Calculate the padding
        //    rectangle = new RectangleF(rectangle.X + Left.Padding, rectangle.Y + Top.Padding, rectangle.Width - (Left.Padding + Right.Padding), rectangle.Height - (Top.Padding + Bottom.Padding));

        //    if (rectangle.Width <= 0 || rectangle.Height <= 0)
        //        return;

        //    PensCache pens = graphics.PensCache;
        //    if (border.Left.Width > 0)
        //    {
        //        Pen leftPen = pens.GetPen(border.Left.Color, 1, border.Left.DashStyle);
        //        for (int i = 0; i < border.Left.Width; i++)
        //            graphics.Graphics.DrawLine(leftPen, rectangle.X + i, rectangle.Y, rectangle.X + i, rectangle.Bottom - 1);
        //    }

        //    if (border.Bottom.Width > 0)
        //    {
        //        Pen bottomPen = pens.GetPen(border.Bottom.Color, 1, border.Bottom.DashStyle);
        //        for (int i = 1; i <= border.Bottom.Width; i++)
        //            graphics.Graphics.DrawLine(bottomPen, rectangle.X, rectangle.Bottom - i, rectangle.Right - 1, rectangle.Bottom - i);
        //    }

        //    if (border.Right.Width > 0)
        //    {
        //        Pen rightPen = pens.GetPen(border.Right.Color, 1, border.Right.DashStyle);
        //        for (int i = 1; i <= border.Right.Width; i++)
        //            graphics.Graphics.DrawLine(rightPen, rectangle.Right - i, rectangle.Y, rectangle.Right - i, rectangle.Bottom - 1);
        //    }

        //    if (border.Top.Width > 0)
        //    {
        //        Pen topPen = pens.GetPen(border.Top.Color, 1, border.Top.DashStyle);
        //        for (int i = 0; i < border.Top.Width; i++)
        //            graphics.Graphics.DrawLine(topPen, rectangle.X, rectangle.Y + i, rectangle.Right - 1, rectangle.Y + i);
        //    }
        //}

        /// <summary>
        /// [email protected]: draws part by part of rectangle.
        /// conditions are added so that only specified border is drawn.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="rectangle"></param>
        /// <param name="partType"></param>
        public void Draw(GraphicsCache graphics, RectangleF rectangle, BorderPartType partType)
        {
            RectangleBorder border = this;

            //Calculate the padding
            rectangle = new RectangleF(rectangle.X + Left.Padding, rectangle.Y + Top.Padding, rectangle.Width - (Left.Padding + Right.Padding), rectangle.Height - (Top.Padding + Bottom.Padding));

            if (rectangle.Width <= 0 || rectangle.Height <= 0)
            {
                return;
            }

            PensCache pens = graphics.PensCache;

            if (border.Left.Width > 0 && (partType & BorderPartType.LeftBorder) == BorderPartType.LeftBorder)
            {
                Pen   leftPen = pens.GetPen(border.Left.Color, border.Left.Width, border.Left.DashStyle);
                float x;
                float bottom;
                if (border.Left.Width > 1)
                {
                    x      = rectangle.X + ((float)border.Left.Width) / 2;
                    bottom = rectangle.Bottom;
                }
                else
                {
                    x      = rectangle.X;
                    bottom = rectangle.Bottom - 1;
                }
                graphics.Graphics.DrawLine(leftPen, new PointF(x, rectangle.Y),
                                           new PointF(x, bottom));
            }

            if (border.Right.Width > 0 && (partType & BorderPartType.RightBorder) == BorderPartType.RightBorder)
            {
                Pen   rightPen = pens.GetPen(border.Right.Color, border.Right.Width, border.Right.DashStyle);
                float x;
                float bottom;
                if (border.Right.Width > 1)
                {
                    x      = rectangle.Right - border.Right.Width / 2;
                    bottom = rectangle.Bottom;
                }
                else
                {
                    x      = rectangle.Right - 1;
                    bottom = rectangle.Bottom - 1;
                }
                graphics.Graphics.DrawLine(rightPen, new PointF(x, rectangle.Y),
                                           new PointF(x, bottom));
            }

            if (border.Top.Width > 0 && (partType & BorderPartType.TopBorder) == BorderPartType.TopBorder)
            {
                Pen   topPen = pens.GetPen(border.Top.Color, border.Top.Width, border.Top.DashStyle);
                float y;
                float right;
                if (border.Top.Width > 1)
                {
                    y     = rectangle.Y + border.Top.Width / 2;
                    right = rectangle.Right;
                }
                else
                {
                    y     = rectangle.Y;
                    right = rectangle.Right - 1;
                }
                graphics.Graphics.DrawLine(topPen, new PointF(rectangle.X, y),
                                           new PointF(right, y));
            }

            if (border.Bottom.Width > 0 && (partType & BorderPartType.BottomBorder) == BorderPartType.BottomBorder)
            {
                Pen   bottomPen = pens.GetPen(border.Bottom.Color, border.Bottom.Width, border.Bottom.DashStyle);
                float y;
                float right;
                if (border.Bottom.Width > 1)
                {
                    y     = rectangle.Bottom - border.Bottom.Width / 2;
                    right = rectangle.Right;
                }
                else
                {
                    y     = rectangle.Bottom - 1;
                    right = rectangle.Right - 1;
                }
                graphics.Graphics.DrawLine(bottomPen, new PointF(rectangle.X, y),
                                           new PointF(right, y));
            }
        }