/// <summary>Determines the final size and placement of the cell content.</summary>
        /// <param name="arrangeSize">The maximum size that the cell can occupy.</param>
        /// <returns>The final size of the control.</returns>
        // Token: 0x0600470A RID: 18186 RVA: 0x001421D4 File Offset: 0x001403D4
        protected override Size ArrangeOverride(Size arrangeSize)
        {
            DataGrid dataGridOwner = this.DataGridOwner;
            bool     flag          = DataGridHelper.IsGridLineVisible(dataGridOwner, true);
            bool     flag2         = DataGridHelper.IsGridLineVisible(dataGridOwner, false);
            double   num           = 0.0;
            double   num2          = 0.0;

            if (flag)
            {
                num         = dataGridOwner.HorizontalGridLineThickness;
                arrangeSize = DataGridHelper.SubtractFromSize(arrangeSize, num, true);
            }
            if (flag2)
            {
                num2        = dataGridOwner.VerticalGridLineThickness;
                arrangeSize = DataGridHelper.SubtractFromSize(arrangeSize, num2, false);
            }
            Size result = base.ArrangeOverride(arrangeSize);

            if (flag)
            {
                result.Height += num;
            }
            if (flag2)
            {
                result.Width += num2;
            }
            return(result);
        }
Пример #2
0
        /// <summary>
        ///     Arrange.  This is overriden so that the cell can position its content to account for a grid line on the right.
        /// </summary>
        /// <param name="arrangeSize">Arrange size</param>
        protected override Size ArrangeOverride(Size arrangeSize)
        {
            // We don't need to adjust the Arrange position of the content.  By default it is arranged at 0,0 and we're
            // adding a line to the right and bottom.  All we have to do is compress and extend the size, just like Measure.
            DataGrid dataGridOwner           = DataGridOwner;
            bool     horizontalLinesVisible  = DataGridHelper.IsGridLineVisible(dataGridOwner, /*isHorizontal = */ true);
            bool     verticalLinesVisible    = DataGridHelper.IsGridLineVisible(dataGridOwner, /*isHorizontal = */ false);
            double   horizontalLineThickness = 0;
            double   verticalLineThickness   = 0;

            if (horizontalLinesVisible)
            {
                horizontalLineThickness = dataGridOwner.HorizontalGridLineThickness;
                arrangeSize             = DataGridHelper.SubtractFromSize(arrangeSize, horizontalLineThickness, /*height = */ true);
            }
            if (verticalLinesVisible)
            {
                verticalLineThickness = dataGridOwner.VerticalGridLineThickness;
                arrangeSize           = DataGridHelper.SubtractFromSize(arrangeSize, verticalLineThickness, /*height = */ false);
            }
            Size returnSize = base.ArrangeOverride(arrangeSize);

            if (horizontalLinesVisible)
            {
                returnSize.Height += horizontalLineThickness;
            }
            if (verticalLinesVisible)
            {
                returnSize.Width += verticalLineThickness;
            }
            return(returnSize);
        }
Пример #3
0
        // Different parts of the DataGrid draw different pieces of the GridLines.
        // Cells draw a single line on their right side.

        /// <summary>
        ///     Measure.  This is overridden so that the cell can extend its size to account for a grid line on the right.
        /// </summary>
        protected override Size MeasureOverride(Size constraint)
        {
            // Make space for the GridLine on the right and bottom:
            // Remove space from the constraint (since it implicitly includes the GridLine's thickness),
            // call the base implementation, and add the thickness back for the returned size.
            DataGrid dataGridOwner           = DataGridOwner;
            bool     horizontalLinesVisible  = DataGridHelper.IsGridLineVisible(dataGridOwner, /*isHorizontal = */ true);
            bool     verticalLinesVisible    = DataGridHelper.IsGridLineVisible(dataGridOwner, /*isHorizontal = */ false);
            double   horizontalLineThickness = 0;
            double   verticalLineThickness   = 0;

            if (horizontalLinesVisible)
            {
                horizontalLineThickness = dataGridOwner.HorizontalGridLineThickness;
                constraint = DataGridHelper.SubtractFromSize(constraint, horizontalLineThickness, /*height = */ true);
            }
            if (verticalLinesVisible)
            {
                verticalLineThickness = dataGridOwner.VerticalGridLineThickness;
                constraint            = DataGridHelper.SubtractFromSize(constraint, verticalLineThickness, /*height = */ false);
            }
            Size desiredSize = base.MeasureOverride(constraint);

            if (horizontalLinesVisible)
            {
                desiredSize.Height += horizontalLineThickness;
            }
            if (verticalLinesVisible)
            {
                desiredSize.Width += verticalLineThickness;
            }
            return(desiredSize);
        }
        /// <summary>Draws the cell and the right side gridline.</summary>
        /// <param name="drawingContext">The drawing instructions for the cell.</param>
        // Token: 0x0600470B RID: 18187 RVA: 0x00142268 File Offset: 0x00140468
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);
            DataGrid dataGridOwner = this.DataGridOwner;

            if (DataGridHelper.IsGridLineVisible(dataGridOwner, false))
            {
                double verticalGridLineThickness = this.DataGridOwner.VerticalGridLineThickness;
                Rect   rectangle = new Rect(new Size(verticalGridLineThickness, base.RenderSize.Height));
                rectangle.X = base.RenderSize.Width - verticalGridLineThickness;
                drawingContext.DrawRectangle(this.DataGridOwner.VerticalGridLinesBrush, null, rectangle);
            }
            if (DataGridHelper.IsGridLineVisible(dataGridOwner, true))
            {
                double horizontalGridLineThickness = dataGridOwner.HorizontalGridLineThickness;
                Rect   rectangle2 = new Rect(new Size(base.RenderSize.Width, horizontalGridLineThickness));
                rectangle2.Y = base.RenderSize.Height - horizontalGridLineThickness;
                drawingContext.DrawRectangle(dataGridOwner.HorizontalGridLinesBrush, null, rectangle2);
            }
        }
Пример #5
0
        /// <summary>
        ///     OnRender.  Overriden to draw a vertical line on the right.
        /// </summary>
        /// <param name="drawingContext"></param>
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);
            DataGrid dataGrid = DataGridOwner;

            if (DataGridHelper.IsGridLineVisible(dataGrid, /*isHorizontal = */ false))
            {
                double thickness = DataGridOwner.VerticalGridLineThickness;
                Rect   rect      = new Rect(new Size(thickness, RenderSize.Height));
                rect.X = RenderSize.Width - thickness;

                drawingContext.DrawRectangle(DataGridOwner.VerticalGridLinesBrush, null, rect);
            }

            if (DataGridHelper.IsGridLineVisible(dataGrid, /*isHorizontal = */ true))
            {
                double thickness = dataGrid.HorizontalGridLineThickness;
                Rect   rect      = new Rect(new Size(RenderSize.Width, thickness));
                rect.Y = RenderSize.Height - thickness;

                drawingContext.DrawRectangle(dataGrid.HorizontalGridLinesBrush, null, rect);
            }
        }