Esempio n. 1
0
            public GridWalker(Grid grid, Segment[,] rowMatrix, Segment[,] colMatrix)
            {
                foreach (UIElement child in VisualTreeHelper.GetChildren(grid))
                {
                    bool starCol = false;
                    bool starRow = false;
                    bool autoCol = false;
                    bool autoRow = false;

                    int col = Math.Min(Grid.GetColumn(child), colMatrix.GetUpperBound(0));
                    int row = Math.Min(Grid.GetRow(child), rowMatrix.GetUpperBound(0));
                    int colspan = Math.Min(Grid.GetColumnSpan(child), colMatrix.GetUpperBound(0));
                    int rowspan = Math.Min(Grid.GetRowSpan(child), rowMatrix.GetUpperBound(0));

                    for (int r = row; r < row + rowspan; r++) 
                    {
                        starRow |= rowMatrix[r, r].Type == GridUnitType.Star;
                        autoRow |= rowMatrix[r, r].Type == GridUnitType.Auto;
                    }

                    for (int c = col; c < col + colspan; c++) 
                    {
                        starCol |= colMatrix[c, c].Type == GridUnitType.Star;
                        autoCol |= colMatrix[c, c].Type == GridUnitType.Auto;
                    }

                    this.HasAutoAuto |= autoRow && autoCol && !starRow && !starCol;
                    this.HasStarAuto |= starRow && autoCol;
                    this.HasAutoStar |= autoRow && starCol;
                }
            }