/// <summary>
        /// Adds the button.
        /// </summary>
        /// <param name="text">The text.</param>
        public void AddButton(string text)
        {
            string font = String.Format("{0}{1}", Device.OnPlatform("Assets/Fonts/", "", "Assets/Fonts/"), "Roboto-Condensed.ttf");

            var button = new ExtendedButton
            {
                HorizontalOptions          = LayoutOptions.FillAndExpand,
                HorizontalContentAlignment = IsNumber ? TextAlignment.Center : TextAlignment.Start,
                BackgroundColor            = BackgroundColor,
                BorderColor = BorderColor,
                TextColor   = TextColor,
                //BorderWidth = BUTTON_BORDER_WIDTH,
                //BorderRadius =
                //    Rounded
                //        ? Device.OnPlatform(ButtonHeight/2, ButtonHeight/2, ButtonHeight/2)
                //        : BUTTON_BORDER_RADIUS,
                HeightRequest        = Device.OnPlatform(ButtonHeight, ButtonHeight, ButtonHeight),
                MinimumHeightRequest = Device.OnPlatform(ButtonHeight, ButtonHeight, ButtonHeight),
                WidthRequest         = Device.OnPlatform(ButtonWidth, ButtonWidth, ButtonWidth),
                MinimumWidthRequest  = Device.OnPlatform(ButtonWidth, ButtonWidth, ButtonWidth),
                //Font = Font,

                //Font = Font.OfSize(Device.OnPlatform(font, font, font+"#Roboto"), 16),
                Command          = _clickedCommand,
                CommandParameter = _buttonLayout.Children.Count,
            };

            if (IsNumber)
            {
                button.Text = string.Format("{0}", text);
                //button.WidthRequest = Device.OnPlatform(44, 44, 60);
                //button.MinimumWidthRequest = Device.OnPlatform(44, 44, 60);
            }
            else
            {
                button.Text = string.Format(" {0}", text);
            }

            var frame = new Frame
            {
                BackgroundColor = ViewBackgroundColor,
                Padding         = FRAME_PADDING,
                OutlineColor    = OutlineColor,
                HasShadow       = false,
                Content         = button,
            };

            _buttonLayout.Children.Add(frame);

            //SetSelectedState(_buttonLayout.Children.Count - 1, _buttonLayout.Children.Count - 1 == SelectedIndex);
        }
Beispiel #2
0
        private void ExtendedButton_SizeChanged(object sender, EventArgs e)
        {
            //Debug.WriteLine("ExtendedButton_SizeChanged");

            var w = Objects.Orientation.Width;
            var h = Objects.Orientation.Height;

            ExtendedButton button = ((ExtendedButton)sender);

            if (Device.RuntimePlatform == Device.Windows)
            {
                // HANDLE TEXT
                if (w < App.GetRealSize(442))
                {
                    button.SetBinding(Button.TextProperty, "OfficialBookAbbreviation");
                }
                else if (w <= App.GetRealSize(720) && w > App.GetRealSize(442))
                {
                    button.SetBinding(Button.TextProperty, "StandardBookAbbreviation");
                }
                else if (w >= App.GetRealSize(720))
                {
                    button.SetBinding(Button.TextProperty, "StandardBookName");
                }

                // HANDLE WIDTH AND HEIGHT
                if (w < App.GetRealSize(442))
                {
                    button.WidthRequest         = 60;
                    button.MinimumWidthRequest  = 60;
                    button.HeightRequest        = 60;
                    button.MinimumHeightRequest = 60;
                }
                else
                {
                    button.WidthRequest         = 50;
                    button.MinimumWidthRequest  = 50;
                    button.HeightRequest        = 50;
                    button.MinimumHeightRequest = 50;
                }
            }
            else if (Device.RuntimePlatform == Device.iOS)
            {
                // HANDLE TEXT
                if (Device.Idiom == TargetIdiom.Phone)
                {
                    button.SetBinding(Button.TextProperty, "OfficialBookAbbreviation");
                    //button.WidthRequest = h;
                    //button.MinimumWidthRequest = h;
                    //button.HeightRequest = h;
                    //button.MinimumHeightRequest = h;
                }
                else
                {
                    button.SetBinding(Button.TextProperty, "StandardBookName");
                    //button.WidthRequest = w;
                    //button.MinimumWidthRequest = w;
                    //button.HeightRequest = h;
                    //button.MinimumHeightRequest = h;
                }
            }
            else
            {
                //button.HeightRequest = 0;
                //button.WidthRequest = 0;

                //button.IsVisible = false;

                //// HANDLE TEXT
                //if (button.Width < 60)
                //{
                //    button.SetBinding(Button.TextProperty, "OfficialBookAbbreviation");
                //}
                //else if (button.Width < 100)
                //{
                //    button.SetBinding(Button.TextProperty, "StandardBookAbbreviation");
                //}
                //else if (button.Width >= 100)
                //{
                //    button.SetBinding(Button.TextProperty, "StandardBookName");
                //}
            }
        }