예제 #1
0
        // Returns a ContainerLayout that wraps a ScrollView whose content size will always match the ScrollView's size.
        // The reason someone might want this is if something may later temporarily show overtop of this view (like a keyboard) then
        // the ScrollView might scroll its content to still be visible.
        public static ContainerLayout SameSize_Scroller(ScrollView view, LayoutChoice_Set subLayout)
        {
            ContainerLayout containerLayout = new ContainerLayout();

            containerLayout.view      = view;
            containerLayout.SubLayout = subLayout;
            return(containerLayout);
        }
예제 #2
0
 public void CopyFrom(ContainerLayout original)
 {
     this.ChildFillsAvailableSpace = original.ChildFillsAvailableSpace;
     base.CopyFrom(original);
 }
예제 #3
0
        private void Initialize(Button button, double fontSize = -1, bool includeBevel = true, bool allowCropping = false, bool scoreIfEmpty = false, bool allowSplittingWords = false)
        {
            bool             isButtonColorSet = button.BackgroundColor.A > 0;
            LayoutChoice_Set sublayout;

            this.buttonBackground = new ContentView();
            ButtonConfigurer buttonConfigurer = new ButtonConfigurer(button, this.buttonBackground);

            if (fontSize > 0)
            {
                if (allowCropping)
                {
                    sublayout = TextLayout.New_Croppable(buttonConfigurer, fontSize, scoreIfEmpty);
                }
                else
                {
                    sublayout = new TextLayout(buttonConfigurer, fontSize, allowSplittingWords, scoreIfEmpty);
                }
            }
            else
            {
                List <LayoutChoice_Set> sublayoutOptions = new List <LayoutChoice_Set>(3);
                if (allowCropping)
                {
                    sublayoutOptions.Add(TextLayout.New_Croppable(buttonConfigurer, 30, scoreIfEmpty));
                    sublayoutOptions.Add(TextLayout.New_Croppable(buttonConfigurer, 16, scoreIfEmpty));
                    sublayoutOptions.Add(TextLayout.New_Croppable(buttonConfigurer, 12, scoreIfEmpty));
                }
                else
                {
                    sublayoutOptions.Add(new TextLayout(buttonConfigurer, 30, allowSplittingWords, scoreIfEmpty));
                    sublayoutOptions.Add(new TextLayout(buttonConfigurer, 16, allowSplittingWords, scoreIfEmpty));
                    sublayoutOptions.Add(new TextLayout(buttonConfigurer, 12, allowSplittingWords, scoreIfEmpty));
                }
                LayoutUnion layoutUnion = new LayoutUnion(sublayoutOptions);
                sublayout = layoutUnion;
            }

            // add a view behind the button to change its normal background color without changing its color when selected
            ContainerLayout backgroundLayout = new ContainerLayout(buttonBackground, sublayout, false);

            if (includeBevel)
            {
                buttonBackground.BackgroundColor = Color.Black;
                // add a small border, so that it's easy to see where the buttons end
                Thickness   innerBevelThickness = new Thickness(1);
                ContentView insideBevel         = new ContentView();
                insideBevel.Padding = innerBevelThickness;
                //insideBevel.BackgroundColor = Color.DarkGray;// Color.FromRgb(0.4, 0.4, 0.4);
                buttonConfigurer.InnerBevel = insideBevel;
                ContainerLayout middleLayout = new MustBorderLayout(insideBevel, backgroundLayout, innerBevelThickness, false);

                // add a bevel to the border
                Thickness   outerBevelThickness = new Thickness(1);
                ContentView outsideBevel        = new ContentView();
                outsideBevel.Padding = outerBevelThickness;
                //outsideBevel.BackgroundColor = Color.LightGray;// Color.FromRgb(0.63, 0.63, 0.63);
                buttonConfigurer.OuterBevel = outsideBevel;
                ContainerLayout outsideLayout = new MustBorderLayout(outsideBevel, middleLayout, outerBevelThickness, false);

                // add some extra space around it
                Thickness   spacingThickness = new Thickness(1);
                ContentView spacing          = new ContentView();
                spacing.Padding         = spacingThickness;
                spacing.BackgroundColor = Color.FromRgba(0, 0, 0, 0);
                ContainerLayout spacingLayout = new MustBorderLayout(spacing, outsideLayout, spacingThickness, false);

                this.Set_LayoutChoices(new List <LayoutChoice_Set>()
                {
                    spacingLayout, new ScoreShifted_Layout(null, LayoutScore.Get_CutOff_LayoutScore(1))
                });

                button.TextColor = Color.LightGray;
            }
            else
            {
                if (!isButtonColorSet)
                {
                    buttonBackground.BackgroundColor = Color.White;
                    button.TextColor = Color.Black;
                }
                this.Set_LayoutChoices(new List <LayoutChoice_Set>()
                {
                    backgroundLayout
                });
            }
            Effect effect = Effect.Resolve("VisiPlacement.ButtonEffect");

            button.Effects.Add(effect);

            this.buttonConfigurer = buttonConfigurer;
        }