Exemple #1
0
        private LayoutChoice_Set MakeSublayout(AppContribution contribution)
        {
            // get some properties
            AppContributor who         = contribution.Contributor;
            string         name        = who.Name;
            string         when        = contribution.DateTime.ToString("yyyy-MM-dd");
            string         description = contribution.Description;
            double         fontSize    = 16;
            double         nameSize    = 30;

            // build the name button layout
            LayoutChoice_Set nameLayout;

            if (who.Email != null || who.Website != null)
            {
                // If this contributor provided details, then make a button to show those details
                Vertical_GridLayout_Builder detailBuilder = new Vertical_GridLayout_Builder();
                detailBuilder.AddLayout(new TextblockLayout("Contributor Name: " + name, fontSize));
                if (who.Email != null)
                {
                    detailBuilder.AddLayout(new TextblockLayout("Email: " + who.Email, fontSize));
                }
                if (who.Website != null)
                {
                    detailBuilder.AddLayout(new TextblockLayout("Website: " + who.Website, fontSize));
                }
                nameLayout = new HelpButtonLayout(name, detailBuilder.Build(), layoutStack, nameSize);
            }
            else
            {
                // If this contributor didn't provide details, then just display their name
                TextblockLayout l = new TextblockLayout(name, nameSize);
                l.AlignHorizontally(TextAlignment.Center);
                nameLayout = l;
            }

            // build the rest of the layout
            Vertical_GridLayout_Builder fullBuilder = new Vertical_GridLayout_Builder();

            fullBuilder.AddLayout(nameLayout);
            fullBuilder.AddLayout(new TextblockLayout("On " + when + ": " + description, fontSize));
            fullBuilder.AddLayout(new TextblockLayout("Thanks!", fontSize));
            return(fullBuilder.Build());
        }
        private LayoutChoice_Set build()
        {
            GridLayout_Builder mainBuilder = new Vertical_GridLayout_Builder().Uniform();

            this.buttons            = new List <Button>();
            this.subtitles          = new List <TextblockLayout>();
            this.buttonDestinations = new Dictionary <Button, ValueProvider <StackEntry> >();
            for (int i = 0; i < this.buttonNameProviders.Count; i++)
            {
                Button button = new Button();
                button.Clicked += Button_Clicked;
                this.buttons.Add(button);

                ButtonLayout    buttonLayout   = new ButtonLayout(button);
                TextblockLayout subtitleLayout = new TextblockLayout();
                subtitleLayout.AlignHorizontally(TextAlignment.Center);
                subtitleLayout.AlignVertically(TextAlignment.Center);
                subtitleLayout.ScoreIfEmpty = false;
                this.subtitles.Add(subtitleLayout);

                BoundProperty_List columnWidths = new BoundProperty_List(2);
                columnWidths.SetPropertyScale(0, 2);
                columnWidths.SetPropertyScale(1, 1);
                columnWidths.BindIndices(0, 1);
                GridLayout entryGrid = GridLayout.New(new BoundProperty_List(1), columnWidths, LayoutScore.Get_UnCentered_LayoutScore(1));
                entryGrid.AddLayout(buttonLayout);
                entryGrid.AddLayout(subtitleLayout);

                LayoutUnion content = new LayoutUnion(entryGrid, buttonLayout);
                mainBuilder.AddLayout(content);

                ValueProvider <StackEntry> destinationProvider = destinationProviders[i];
                this.buttonDestinations[button] = destinationProvider;
            }
            return(LayoutCache.For(mainBuilder.BuildAnyLayout()));
        }