Beispiel #1
0
        public static void MoveComponent(UXLayoutGrid from, UXLayoutGrid to, UXComponent component, bool moveAllCellContent)
        {
            IList <UXComponent> components = null;

            if (moveAllCellContent)
            {
                components = from.GetComponents(component);
            }
            else
            {
                components = new List <UXComponent> {
                    component
                };
            }

            if (components.Count > 0)
            {
                int newRow = to.RowCount;

                foreach (UXComponent comp in components)
                {
                    int span2 = from.GetColumnSpanForeComponent(comp);

                    // Remove component from the from grid
                    from.RemoveComponent(comp);

                    // Add the component to a new last row in the to-grid.
                    UXLayoutGridCell cellNew = to.AddComponent(0, newRow, comp);
                }
            }
        }
Beispiel #2
0
        public UXLayoutGridCell AddBlankCell(int column, int row, int colSpan)
        {
            string key = Key(column, row);

            if (cells.ContainsKey(key))
            {
            }
            else
            {
                UXLayoutGridCell cell = new UXLayoutGridCell()
                {
                    Row = row, Column = column, Component = null
                };
                cells[key]            = cell;
                cells[key].ColumnSpan = colSpan;
            }

            return(cells[key]);
        }
Beispiel #3
0
        public UXLayoutGridCell AddComponent(int column, int row, int columnSpan, UXComponent newComponent)
        {
            string key = Key(column, row);

            if (!componentDict.ContainsKey(newComponent))
            {
                if (cells.ContainsKey(key))
                {
                    componentDict.Add(newComponent, key);

                    if (cells[key].Component is UXContainer)
                    {
                        UXContainer cellContainer = cells[key].Component as UXContainer;
                        cellContainer.Children.Add(newComponent);
                        newComponent.Parent = cellContainer;
                        Children.Add(cellContainer);
                    }
                    else
                    {
                        // If more than one component in cell create stackpanel
                        UXComponent orgCellComponent = cells[key].Component;

                        UXStackPanel uxStackPanel = new UXStackPanel()
                        {
                            Parent = this, Orientation = UXPanelOrientation.Horizontal
                        };

                        cells[key].Component = uxStackPanel;


                        orgCellComponent.Parent = uxStackPanel;
                        uxStackPanel.Children.Add(orgCellComponent);

                        newComponent.Parent = uxStackPanel;
                        uxStackPanel.Children.Add(newComponent);

                        Children.Remove(orgCellComponent);
                        Children.Add(uxStackPanel);
                    }
                }
                else
                {
                    UXLayoutGridCell cell = new UXLayoutGridCell()
                    {
                        Row = row, Column = column, Component = newComponent, ColumnSpan = columnSpan
                    };
                    cells[key] = cell;

                    Children.Add(newComponent);

                    if (newComponent is UXContainer)
                    {
                        foreach (UXComponent comp in ((UXContainer)newComponent).Children)
                        {
                            componentDict.Add(comp, key);
                        }
                    }
                    else
                    {
                        componentDict.Add(newComponent, key);
                    }
                }
            }

            return(cells[key]);
        }