Ejemplo n.º 1
0
        public GridView(Context context, IAttributeSet attrs, int defStyle) :
            base(context, attrs, defStyle)
        {
            var a = context.ObtainStyledAttributes(attrs, Resource.Styleable.GridView, defStyle, 0);

            int markupId = a.GetResourceId(Resource.Styleable.GridView_grid_markup, DefaultGridMarkupValue);

            if (markupId != DefaultGridMarkupValue)
            {
                ParseMarkupXml(markupId);
            }
            else
            {
                _rowDefinitions.Add(new GridDefinition());
                _columnDefinitions.Add(new GridDefinition());
            }
            foreach (var row in _rowDefinitions)
            {
                var rowInfo = new GridDefinitionMeasureInfo(row);
                _rowsInfo.Add(row, rowInfo);
                if (row.Length.IsStar)
                {
                    _heightStarSum += row.Length.Value;
                }
            }
            foreach (var column in _columnDefinitions)
            {
                var columnInfo = new GridDefinitionMeasureInfo(column);
                _columnsInfo.Add(column, columnInfo);
                if (column.Length.IsStar)
                {
                    _widthStarSum += column.Length.Value;
                }
            }
        }
Ejemplo n.º 2
0
        public GridView(Context context, IAttributeSet attrs, int defStyle)
            : base(context, attrs, defStyle)
        {
            var a = context.ObtainStyledAttributes(attrs, Resource.Styleable.GridView, defStyle, 0);

            int markupId = a.GetResourceId(Resource.Styleable.GridView_grid_markup, DefaultGridMarkupValue);
            if(markupId != DefaultGridMarkupValue)
            {
                ParseMarkupXml(markupId);
            }
            else
            {
                _rowDefinitions.Add(new GridDefinition());
                _columnDefinitions.Add(new GridDefinition());
            }
            foreach(var row in _rowDefinitions)
            {
                var rowInfo = new GridDefinitionMeasureInfo(row);
                _rowsInfo.Add(row, rowInfo);
                if(row.Length.IsStar)
                {
                    _heightStarSum += row.Length.Value;
                }
            }
            foreach(var column in _columnDefinitions)
            {
                var columnInfo = new GridDefinitionMeasureInfo(column);
                _columnsInfo.Add(column, columnInfo);
                if(column.Length.IsStar)
                {
                    _widthStarSum += column.Length.Value;
                }
            }
        }
Ejemplo n.º 3
0
            public ViewMeasureInfo(View view, GridViewLayoutParams lp,
                                   List <GridDefinition> rows, List <GridDefinition> columns,
                                   Dictionary <GridDefinition, GridDefinitionMeasureInfo> rowsInfo, Dictionary <GridDefinition, GridDefinitionMeasureInfo> columnsInfo)
            {
                View = view;
                AssociatedColumns = new List <GridDefinitionMeasureInfo>();
                AssociatedRows    = new List <GridDefinitionMeasureInfo>();
                for (int j = lp.Row; j < lp.Row + lp.RowSpan && j < rows.Count; j++)
                {
                    AssociatedRows.Add(rowsInfo[rows[j]]);
                    rowsInfo[rows[j]].AttachedViews.Add(this);
                }
                for (int j = lp.Column; j < lp.Column + lp.ColumnSpan && j < columns.Count; j++)
                {
                    AssociatedColumns.Add(columnsInfo[columns[j]]);
                    columnsInfo[columns[j]].AttachedViews.Add(this);
                }

                foreach (var row in AssociatedRows)
                {
                    if (row.Definition.Length.IsStar)
                    {
                        _heightStarSum += row.Definition.Length.Value;
                    }
                    else if (row.Definition.Length.IsAuto)
                    {
                        if (_firstAutoRow == null)
                        {
                            _firstAutoRow = row;
                        }
                    }
                    else
                    {
                        _staticHeight += row.Definition.Length.Value;
                    }
                }

                foreach (var column in AssociatedColumns)
                {
                    if (column.Definition.Length.IsStar)
                    {
                        _widthStarSum += column.Definition.Length.Value;
                    }
                    else if (column.Definition.Length.IsAuto)
                    {
                        if (_firstAutoColumn == null)
                        {
                            _firstAutoColumn = column;
                        }
                    }
                    else
                    {
                        _staticWidth += column.Definition.Length.Value;
                    }
                }
            }
Ejemplo n.º 4
0
            public ViewMeasureInfo(View view, GridViewLayoutParams lp,
			                       List<GridDefinition> rows, List<GridDefinition> columns,
			                       Dictionary<GridDefinition, GridDefinitionMeasureInfo> rowsInfo, Dictionary<GridDefinition, GridDefinitionMeasureInfo> columnsInfo)
            {
                View = view;
                AssociatedColumns = new List<GridDefinitionMeasureInfo>();
                AssociatedRows = new List<GridDefinitionMeasureInfo>();
                for(int j = lp.Row; j < lp.Row + lp.RowSpan && j < rows.Count; j++)
                {
                    AssociatedRows.Add(rowsInfo[rows[j]]);
                    rowsInfo[rows[j]].AttachedViews.Add(this);
                }
                for(int j = lp.Column; j < lp.Column + lp.ColumnSpan && j < columns.Count; j++)
                {
                    AssociatedColumns.Add(columnsInfo[columns[j]]);
                    columnsInfo[columns[j]].AttachedViews.Add(this);
                }

                foreach(var row in AssociatedRows)
                {
                    if(row.Definition.Length.IsStar)
                    {
                        _heightStarSum += row.Definition.Length.Value;
                    }
                    else if(row.Definition.Length.IsAuto)
                    {
                        if(_firstAutoRow == null)
                        {
                            _firstAutoRow = row;
                        }
                    }
                    else
                    {
                        _staticHeight += row.Definition.Length.Value;
                    }
                }

                foreach(var column in AssociatedColumns)
                {
                    if(column.Definition.Length.IsStar)
                    {
                        _widthStarSum += column.Definition.Length.Value;
                    }
                    else if(column.Definition.Length.IsAuto)
                    {
                        if(_firstAutoColumn == null)
                        {
                            _firstAutoColumn = column;
                        }
                    }
                    else
                    {
                        _staticWidth += column.Definition.Length.Value;
                    }
                }
            }