Пример #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);
        }
Пример #2
0
        public void AddRow(float height, MeasureType measureType)
        {
            if (__usingDefaultRow)
            {
                __usingDefaultRow = false;
                __rows.Clear();
            }

            GridViewRow newRow = new GridViewRow(){ Height = height, MeasureType = measureType };
            __rows.Add(newRow);
            this.RecalculateRows();
        }
Пример #3
0
        private List<GridViewRow> ParseRowMeasures(string rows)
        {
            List<GridViewRow> inputRows = new List<GridViewRow>();

            if (rows == null)
                return inputRows;

            rows = rows.Trim();

            if (rows.Length == 0)
                return inputRows;

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

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

                int percentageIndex = singleInputRow.IndexOf(PERCENTAGE_SYMBOL);
                MeasureType inputRowMeasure = MeasureType.Total;
                string inputRowHeightStr = singleInputRow;

                if (percentageIndex != -1)
                {
                    inputRowMeasure = MeasureType.Percentage;
                    inputRowHeightStr = singleInputRow.Substring(0, percentageIndex);
                }

                float inputRowHeight;
                bool parseSucceded = float.TryParse(inputRowHeightStr, out inputRowHeight);

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

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

                GridViewRow newRow = new GridViewRow(){ Height = inputRowHeight, MeasureType = inputRowMeasure };
                inputRows.Add(newRow);
            }

            return inputRows;
        }