Example #1
0
        public GridLayoutModel(GridLayoutModel other)
            : base(other)
        {
            _rows        = other._rows;
            _cols        = other._cols;
            _showSpacing = other._showSpacing;
            _spacing     = other._spacing;

            CellChildMap = new int[_rows, _cols];
            for (int row = 0; row < _rows; row++)
            {
                for (int col = 0; col < _cols; col++)
                {
                    CellChildMap[row, col] = other.CellChildMap[row, col];
                }
            }

            for (int row = 0; row < _rows; row++)
            {
                RowPercents.Add(other.RowPercents[row]);
            }

            for (int col = 0; col < _cols; col++)
            {
                ColumnPercents.Add(other.ColumnPercents[col]);
            }
        }
Example #2
0
        public GridLayoutModel(GridLayoutModel other, bool enableQuickKeysPropertyChangedSubscribe = true)
            : base(other, enableQuickKeysPropertyChangedSubscribe)
        {
            _rows        = other._rows;
            _cols        = other._cols;
            _showSpacing = other._showSpacing;
            _spacing     = other._spacing;

            CellChildMap = new int[_rows, _cols];
            for (int row = 0; row < _rows; row++)
            {
                for (int col = 0; col < _cols; col++)
                {
                    CellChildMap[row, col] = other.CellChildMap[row, col];
                }
            }

            for (int row = 0; row < _rows; row++)
            {
                RowPercents.Add(other.RowPercents[row]);
            }

            for (int col = 0; col < _cols; col++)
            {
                ColumnPercents.Add(other.ColumnPercents[col]);
            }
        }
Example #3
0
        public bool IsModelValid()
        {
            // Check if rows and columns are valid
            if (Rows <= 0 || Columns <= 0)
            {
                return(false);
            }

            // Check if percentage is valid.
            if (RowPercents.Count != Rows || ColumnPercents.Count != Columns || RowPercents.Exists((x) => (x < 1)) || ColumnPercents.Exists((x) => (x < 1)))
            {
                return(false);
            }

            // Check if cells map is valid
            if (CellChildMap.Length != Rows * Columns)
            {
                return(false);
            }

            int zoneCount = 0;

            for (int row = 0; row < Rows; row++)
            {
                for (int col = 0; col < Columns; col++)
                {
                    zoneCount = Math.Max(zoneCount, CellChildMap[row, col]);
                }
            }

            zoneCount++;

            if (zoneCount > Rows * Columns)
            {
                return(false);
            }

            var rowPrefixSum = GridData.PrefixSum(RowPercents);
            var colPrefixSum = GridData.PrefixSum(ColumnPercents);

            if (rowPrefixSum[Rows] != GridData.Multiplier || colPrefixSum[Columns] != GridData.Multiplier)
            {
                return(false);
            }

            return(true);
        }