Ejemplo n.º 1
0
        /// <summary>
        /// Measures the element contained by the specified virtual cell.
        /// </summary>
        /// <param name="cell">The virtual cell to measure.</param>
        /// <param name="options">The measurement options for this cell.</param>
        private void MeasureVirtualCell(VirtualCellMetadata cell, GridMeasurementOptions options)
        {
            var cellWidth  = 0.0;
            var cellHeight = 0.0;

            if ((options & GridMeasurementOptions.AssumeInfiniteWidth) == GridMeasurementOptions.AssumeInfiniteWidth)
            {
                cellWidth = Double.PositiveInfinity;
            }
            else
            {
                // If we contain auto columns, then the content determines our width (so assume no constraint)
                if (cell.ContainsAutoColumns && !cell.ContainsStarColumns)
                {
                    cellWidth = Double.PositiveInfinity;
                }
                else
                {
                    cellWidth = CalculateSpanDimension(ColumnDefinitions, cell.ColumnIndex, cell.ColumnSpan);
                }
            }

            if ((options & GridMeasurementOptions.AssumeInfiniteHeight) == GridMeasurementOptions.AssumeInfiniteHeight)
            {
                cellHeight = Double.PositiveInfinity;
            }
            else
            {
                // If we contain auto rows, then the content determines our height (so assume no constraint)
                if (cell.ContainsAutoRows && !cell.ContainsStarRows)
                {
                    cellHeight = Double.PositiveInfinity;
                }
                else
                {
                    cellHeight = CalculateSpanDimension(RowDefinitions, cell.RowIndex, cell.RowSpan);
                }
            }

            var cellSize = new Size2D(cellWidth, cellHeight);

            cell.Element.Measure(cellSize);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Measures the cells in the specified priority group.
        /// </summary>
        /// <param name="priority">The measurement priority group to measure.</param>
        /// <param name="options">The measurement options for this priority group.</param>
        private void MeasureVirtualCells(Int32 priority, GridMeasurementOptions options = GridMeasurementOptions.None)
        {
            if (!hasCellsOfPriority[priority])
            {
                return;
            }

            var discardDesiredWidth  = ((options & GridMeasurementOptions.DiscardDesiredWidth) == GridMeasurementOptions.DiscardDesiredWidth);
            var discardDesiredHeight = ((options & GridMeasurementOptions.DiscardDesiredHeight) == GridMeasurementOptions.DiscardDesiredHeight);

            foreach (var cell in virtualCells)
            {
                if (cell.MeasurementPriority != priority)
                {
                    continue;
                }

                MeasureVirtualCell(cell, options);

                if (!discardDesiredWidth && cell.ColumnSpan == 1)
                {
                    ColumnDefinitions[cell.ColumnIndex].ExpandContentDimension(cell.Element.DesiredSize.Width);
                }

                if (!discardDesiredHeight && cell.RowSpan == 1)
                {
                    RowDefinitions[cell.RowIndex].ExpandContentDimension(cell.Element.DesiredSize.Height);
                }
            }

            foreach (var cell in virtualCells)
            {
                if (!discardDesiredWidth && cell.ColumnSpan > 1)
                {
                    DistributeSpanDimension(ColumnDefinitions, cell.ColumnIndex, cell.ColumnSpan, cell.Element.DesiredSize.Width);
                }

                if (!discardDesiredHeight && cell.RowSpan > 1)
                {
                    DistributeSpanDimension(RowDefinitions, cell.RowIndex, cell.RowSpan, cell.Element.DesiredSize.Height);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Measures the cells in the specified priority group.
        /// </summary>
        /// <param name="priority">The measurement priority group to measure.</param>
        /// <param name="options">The measurement options for this priority group.</param>
        private void MeasureVirtualCells(Int32 priority, GridMeasurementOptions options = GridMeasurementOptions.None)
        {
            if (!hasCellsOfPriority[priority])
                return;

            var discardDesiredWidth  = ((options & GridMeasurementOptions.DiscardDesiredWidth) == GridMeasurementOptions.DiscardDesiredWidth);
            var discardDesiredHeight = ((options & GridMeasurementOptions.DiscardDesiredHeight) == GridMeasurementOptions.DiscardDesiredHeight);

            foreach (var cell in virtualCells)
            {
                if (cell.MeasurementPriority != priority)
                    continue;

                MeasureVirtualCell(cell, options);

                if (!discardDesiredWidth && cell.ColumnSpan == 1)
                    ColumnDefinitions[cell.ColumnIndex].ExpandContentDimension(cell.Element.DesiredSize.Width);

                if (!discardDesiredHeight && cell.RowSpan == 1)
                    RowDefinitions[cell.RowIndex].ExpandContentDimension(cell.Element.DesiredSize.Height);
            }

            foreach (var cell in virtualCells)
            {
                if (!discardDesiredWidth && cell.ColumnSpan > 1)
                    DistributeSpanDimension(ColumnDefinitions, cell.ColumnIndex, cell.ColumnSpan, cell.Element.DesiredSize.Width);

                if (!discardDesiredHeight && cell.RowSpan > 1)
                    DistributeSpanDimension(RowDefinitions, cell.RowIndex, cell.RowSpan, cell.Element.DesiredSize.Height);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Measures the element contained by the specified virtual cell.
        /// </summary>
        /// <param name="cell">The virtual cell to measure.</param>
        /// <param name="options">The measurement options for this cell.</param>
        private void MeasureVirtualCell(VirtualCellMetadata cell, GridMeasurementOptions options)
        {
            var cellWidth  = 0.0;
            var cellHeight = 0.0;

            if ((options & GridMeasurementOptions.AssumeInfiniteWidth) == GridMeasurementOptions.AssumeInfiniteWidth)
            {
                cellWidth = Double.PositiveInfinity;
            }
            else
            {
                // If we contain auto columns, then the content determines our width (so assume no constraint)
                if (cell.ContainsAutoColumns && !cell.ContainsStarColumns)
                {
                    cellWidth = Double.PositiveInfinity;
                }
                else
                {
                    cellWidth = CalculateSpanDimension(ColumnDefinitions, cell.ColumnIndex, cell.ColumnSpan);
                }
            }

            if ((options & GridMeasurementOptions.AssumeInfiniteHeight) == GridMeasurementOptions.AssumeInfiniteHeight)
            {
                cellHeight = Double.PositiveInfinity;
            }
            else
            {
                // If we contain auto rows, then the content determines our height (so assume no constraint)
                if (cell.ContainsAutoRows && !cell.ContainsStarRows)
                {
                    cellHeight = Double.PositiveInfinity;
                }
                else
                {
                    cellHeight = CalculateSpanDimension(RowDefinitions, cell.RowIndex, cell.RowSpan);
                }
            }

            var cellSize = new Size2D(cellWidth, cellHeight);
            cell.Element.Measure(cellSize);
        }