Exemple #1
0
 /// <summary>
 ///    Initializes a new instance of the <see cref="SelectionImageLabelButtonBase" /> class.
 /// </summary>
 protected SelectionImageLabelButtonBase()
 {
     ImageResourceClassType    = GetType();
     SelectionStyle            = ImageLabelButtonSelectionStyles.ToggleSelectionThroughAllStyles;
     ButtonLabel               = FormsUtils.GetSimpleLabel();
     UpdateButtonTextFromStyle = true;
 }
Exemple #2
0
 /// <summary>
 ///    Initializes a new instance of the <see cref="SimpleImageLabelButton" /> class.
 /// </summary>
 public SimpleImageLabelButton(double labelWidth, double labelHeight, string fontFamilyOverride = "")
 {
     CanSelect             = false;
     ButtonToggleSelection = false;
     ButtonLabel           = FormsUtils.GetSimpleLabel("", width: labelWidth, height: labelHeight,
                                                       fontFamilyOverride: fontFamilyOverride);
     SetAllStyles();
 }
        protected override View ConstructPageView()
        {
            var stackLayout = FormsUtils.GetExpandingStackLayout();

            stackLayout.VerticalOptions = LayoutOptions.Start;

            var whatLabel = new Label
            {
                Text   = "I Am A:",
                Margin = new Thickness(0, 10, 0, 0),
                HorizontalTextAlignment = TextAlignment.Center,
                FontSize  = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                TextColor = Color.Gray
            };

            stackLayout.Children.Add(whatLabel);
            var whatAmILabel = FormsUtils.GetSimpleLabel(labelBindingPropertyName: nameof(IAnimalViewModelBase.WhatAmI), fontNamedSize: NamedSize.Large, fontAttributes: FontAttributes.Bold);

            whatAmILabel.HorizontalOptions = LayoutOptions.Center;
            stackLayout.Children.Add(whatAmILabel);

            var eatLabel = new Label
            {
                Text   = "I Like To Eat:",
                Margin = new Thickness(0, 10, 0, 0),
                HorizontalTextAlignment = TextAlignment.Center,
                FontSize  = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                TextColor = Color.Gray
            };

            stackLayout.Children.Add(eatLabel);
            var likeToEatLabel = FormsUtils.GetSimpleLabel(labelBindingPropertyName: nameof(IAnimalViewModelBase.LikeToEat), fontNamedSize: NamedSize.Large, fontAttributes: FontAttributes.Bold);

            likeToEatLabel.HorizontalOptions = LayoutOptions.Center;
            stackLayout.Children.Add(likeToEatLabel);

            var bigLabel = new Label
            {
                Text              = "I Am Big:",
                Margin            = new Thickness(0, 10, 0, 0),
                HorizontalOptions = LayoutOptions.Center,
                FontSize          = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                TextColor         = Color.Gray
            };

            stackLayout.Children.Add(bigLabel);
            // var iAmBigSwitch = new Switch { HorizontalOptions = LayoutOptions.Center, WidthRequest = 75, HeightRequest = 30, InputTransparent = false };
            var iAmBigSwitch =
                new CustomToggleButton
            {
                HorizontalOptions = LayoutOptions.Center,
                WidthRequest      = 75,
                HeightRequest     = 30,
                CheckedImage      = ImageSource.FromFile("checked.png"),
                UnCheckedImage    = ImageSource.FromFile("unchecked.png")
            };

            iAmBigSwitch.SetUpBinding(CustomToggleButton.CheckedProperty, nameof(IAnimalViewModelBase.IAmBig), BindingMode.TwoWay);
            stackLayout.Children.Add(iAmBigSwitch);

            var imageLabel =
                new Label
            {
                Text              = "I Look Like This:",
                Margin            = new Thickness(0, 10, 0, 0),
                HorizontalOptions = LayoutOptions.Center,
                FontSize          = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                TextColor         = Color.Gray
            };

            stackLayout.Children.Add(imageLabel);
            var myImage = FormsUtils.GetImage("", 100, 100);

            myImage.SetUpBinding(Image.SourceProperty, nameof(IAnimalViewModelBase.MyImageSource));
            myImage.HorizontalOptions = LayoutOptions.Center;
            stackLayout.Children.Add(myImage);

            var moveButton = new Button {
                Text = "Move", HorizontalOptions = LayoutOptions.Center
            };

            moveButton.SetUpBinding(Button.CommandProperty, nameof(IAnimalViewModelBase.MoveCommand));
            stackLayout.Children.Add(moveButton);

            var makeNoiseButton = new Button {
                Text = "Make Noise", HorizontalOptions = LayoutOptions.Center
            };

            moveButton.SetUpBinding(Button.CommandProperty, nameof(IAnimalViewModelBase.MakeNoiseCommand));
            stackLayout.Children.Add(makeNoiseButton);

            return(stackLayout);
        }