示例#1
0
        private void CreateToolbarButtons(IEnumerable <dynamic> items, BarSubItem parentItem)
        {
            var beginGroup = false;

            Bar.BeginUpdate();

            foreach (var item in items)
            {
                if (!DesignerExtensions.IsEmpty(item.ToolBarButton))
                {
                    AddBarButton(item.ToolBarButton, parentItem, beginGroup);
                    beginGroup = false;
                }
                else if (!DesignerExtensions.IsEmpty(item.ToolBarPopupButton))
                {
                    var barSubItem = AddBarPopupButton(item.ToolBarPopupButton, parentItem, beginGroup);
                    IEnumerable <dynamic> innerItems =
                        DesignerExtensions.GetCollection(item.ToolBarPopupButton, "Items").ToList();
                    CreateToolbarButtons(innerItems, barSubItem);
                    beginGroup = false;
                }
                else if (!DesignerExtensions.IsEmpty(item.ToolBarSeparator))
                {
                    beginGroup = true;
                }
            }
            Bar.EndUpdate();
        }
示例#2
0
        private void ProcessRows(dynamic[] rows)
        {
            var cells    = new List <GridPanelCellMap>();
            var rowIndex = 0;

            for (rowIndex = 0; rowIndex < rows.Count(); rowIndex++)
            {
                dynamic[] rowCells = DesignerExtensions.GetCollection(rows[rowIndex], "Cells").ToArray();
                for (var columnIndex = 0; columnIndex < rowCells.Count(); columnIndex++)
                {
                    cells.Add(new GridPanelCellMap(rowIndex, columnIndex, rowCells[columnIndex],
                                                   Convert.ToInt32(rowCells[columnIndex].ColumnSpan)));
                }
            }


            rowIndex = 0;
            if (rows.Any())
            {
                while (true)
                {
                    var colSpanSum = 0;
                    var rowCells   = cells.TakeWhile(s =>
                    {
                        colSpanSum += Convert.ToInt32(s.ColumnSpan);
                        return(colSpanSum <= 12);
                    }).ToArray();

                    for (var columnIndex = 0; columnIndex < rowCells.Count(); columnIndex++)
                    {
                        var cellMap = rowCells[columnIndex];
                        cellMap.InnerRowIndex    = rowIndex;
                        cellMap.InnerColumnIndex = columnIndex;
                    }

                    _rows.Add(rowCells);

                    cells = cells.Except(rowCells).ToList();
                    if (!cells.Any())
                    {
                        break;
                    }
                    rowIndex++;
                }
            }
        }
示例#3
0
        public dynamic GetLayout()
        {
            var instanceLayout = new DynamicWrapper();

            this.SetSimplePropertiesToInstance(instanceLayout);

            var rowIndex = 0;

            var rows          = _collectionProperties["Rows"].Items.ToArray();
            var rowsContainer = new GridPanelRowConstructor(rows);

            foreach (var row in _collectionProperties["Rows"].Items)
            {
                row.Cells = DesignerExtensions.GetCollection(row, "Cells");

                var cellsList = new List <dynamic>();
                for (var i = 0; i < row.Cells.Count(); i++)
                {
                    var gridCellMap = rowsContainer.GetCellMap(rowIndex, i);

                    var controlName =
                        Panels[gridCellMap.InnerRowIndex].GetCell(gridCellMap.InnerColumnIndex).GetPropertyName();
                    var controlLayout =
                        Panels[gridCellMap.InnerRowIndex].GetCell(gridCellMap.InnerColumnIndex).GetLayout();

                    if (!String.IsNullOrEmpty(controlName) && controlLayout != null)
                    {
                        var cell = row.Cells[i];
                        cell.ColumnSpan   = Convert.ToInt32(cell.ColumnSpan);
                        cell[controlName] = controlLayout;
                        cellsList.Add(cell);
                    }
                }
                row.Cells = cellsList;
                rowIndex++;
            }

            instanceLayout["Rows"] = _collectionProperties["Rows"].Items;

            return(instanceLayout);
        }