Exemplo n.º 1
0
        private Grid RenderGrid(ComponentContainer decisionsGrid, StandAloneFormSessionInfo info)
        {
            Grid grid = new Grid
            {
                Margin        = decisionsGrid.MarginTop,
                RowSpacing    = decisionsGrid.RowGap,
                ColumnSpacing = decisionsGrid.ColumnGap
            };

            foreach (GridLayoutPart row in decisionsGrid.Rows)
            {
                grid.RowDefinitions.Add(new RowDefinition
                {
                    Height = new GridLength(row.RequestedSize, FormUtils.GetGridUnitType(row.LayoutType))
                });
            }

            foreach (GridLayoutPart col in decisionsGrid.Columns)
            {
                grid.ColumnDefinitions.Add(new ColumnDefinition
                {
                    Width = new GridLength(col.RequestedSize, FormUtils.GetGridUnitType(col.LayoutType))
                });
            }

            foreach (ChildElement element in decisionsGrid.Children)
            {
                View view = null;
                if (element.Child.ServerType.Contains("GridLayout") || element.Child.ServerType.Contains("SilverVerticalStack") || element.Child.ServerType.Contains("SilverHorizontalStack"))
                {
                    view = RenderLayout(element.Child, info);
                }
                else
                {
                    FormControlWrapper control = FormUtils.GetComponentView(element, info);

                    view = control.View;

                    // track elements by id:
                    controls.Add(element.Child.ComponentId, control);

                    // add any button handlers also during this iteration:
                    if (control.GetType().Equals(typeof(ButtonControl)))
                    {
                        AddButtonHandler((ButtonControl)control);
                    }
                    else if (control.GetType().Equals(typeof(ImageButtonControl)))
                    {
                        AddImageButtonHandler((ImageButtonControl)control);
                    }
                }

                grid.Children.Add(view, element.Column, element.Row);
                Grid.SetColumnSpan(view, element.ColumnSpan);
                Grid.SetRowSpan(view, element.RowSpan);
            }

            return(grid);
        }
Exemplo n.º 2
0
        private StackLayout RenderStackLayout(ComponentContainer decisionsLayout, StandAloneFormSessionInfo info, StackOrientation orientation)
        {
            StackLayout layout = new StackLayout
            {
                Orientation = orientation,
            };

            foreach (var element in decisionsLayout.Children)
            {
                View view = null;

                if (element.Child.ServerType.Contains("GridLayout") || element.Child.ServerType.Contains("SilverVerticalStack") || element.Child.ServerType.Contains("SilverHorizontalStack"))
                {
                    view = RenderLayout(element.Child, info);
                }
                else
                {
                    FormControlWrapper control = FormUtils.GetComponentView(element, info);
                    view = control.View;

                    // track elements by id:
                    controls.Add(element.Child.ComponentId, control);

                    // add any button handlers also during this iteration:
                    if (control.GetType().Equals(typeof(ButtonControl)))
                    {
                        AddButtonHandler((ButtonControl)control);
                    }
                    else if (control.GetType().Equals(typeof(ImageButtonControl)))
                    {
                        AddImageButtonHandler((ImageButtonControl)control);
                    }
                }

                if (orientation == StackOrientation.Horizontal)
                {
                    view.VerticalOptions = LayoutOptions.Start;
                }
                layout.Children.Add(view);
            }

            return(layout);
        }