Example #1
0
        public GridView()
        {
            __rows = new List<GridViewRow>();
            __columns = new List<GridViewColumn>();
            __measures = new Dictionary<UIView, GridSubViewMeasure>();

            GridViewColumn defaultColumn = new GridViewColumn(){ MeasureType = MeasureType.Percentage, Width = 1F };
            GridViewRow defaultRow = new GridViewRow(){ MeasureType = MeasureType.Percentage, Height = 1F };
            __rows.Add(defaultRow);
            __columns.Add(defaultColumn);
        }
Example #2
0
        public void AddColumn(float width, MeasureType measureType)
        {
            if (__usingDefaultColumn)
            {
                __usingDefaultColumn = false;
                __columns.Clear();
            }

            GridViewColumn newColumn = new GridViewColumn(){ Width = width, MeasureType = measureType };
            __columns.Add(newColumn);
            this.RecalculateColumns();
        }
Example #3
0
        private List<GridViewColumn> ParseColumnMeasures(string columns)
        {
            List<GridViewColumn> inputColumns = new List<GridViewColumn>();

            if (columns == null)
                return inputColumns;

            columns = columns.Trim();

            if (columns.Length == 0)
                return inputColumns;

            string[] inputColumnsStr = columns.Split(new []{ INPUT_SEPARATOR }, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < inputColumnsStr.Length; i++)
            {
                string singleInputColumn = inputColumnsStr[i];
                singleInputColumn = singleInputColumn.Trim();

                int percentageIndex = singleInputColumn.IndexOf(PERCENTAGE_SYMBOL);
                MeasureType inputColumnMeasure = MeasureType.Total;
                string inputColumnWidthStr = singleInputColumn;

                if (percentageIndex != -1)
                {
                    inputColumnMeasure = MeasureType.Percentage;
                    inputColumnWidthStr = singleInputColumn.Substring(0, percentageIndex);
                }

                float inputColumnWidth;
                bool parseSucceded = float.TryParse(inputColumnWidthStr, out inputColumnWidth);

                if (!parseSucceded)
                    throw new ArgumentException(string.Format("Row value: {0} is not valid", inputColumnWidthStr));

                if (inputColumnWidth < 0)
                    throw new ArgumentException(string.Format("Row value: {0} can't be negative", inputColumnWidthStr));

                GridViewColumn newColumn = new GridViewColumn(){ Width = inputColumnWidth, MeasureType = inputColumnMeasure };
                inputColumns.Add(newColumn);
            }

            return inputColumns;
        }