Пример #1
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);
            var maximumContainer = new ValueViewContainer <Slider>(Test.Slider.Maximum, new Slider {
                Maximum = 10, Minimum = 5
            }, "Value", value => value.ToString());
            var minimumContainer = new ValueViewContainer <Slider>(Test.Slider.Minimum, new Slider {
                Maximum = 10
            }, "Value", value => value.ToString());
            var valueContainer = new ValueViewContainer <Slider>(Test.Slider.Value, new Slider {
                Value = 0.5
            }, "Value", value => value.ToString());

            var minTrackColorContainer = new ValueViewContainer <Slider>(Test.Slider.MinimumTrackColor, new Slider {
                MinimumTrackColor = Color.Red, Value = 0.5
            }, "Value", value => value.ToString());
            var maxTrackColorContainer = new ValueViewContainer <Slider>(Test.Slider.MaximumTrackColor, new Slider {
                MaximumTrackColor = Color.Red, Value = 0.5
            }, "Value", value => value.ToString());
            var thumbColorContainer = new ValueViewContainer <Slider>(Test.Slider.ThumbColor, new Slider {
                ThumbColor = Color.Red, Value = 0.5
            }, "Value", value => value.ToString());
            var thumbImageContainer = new ValueViewContainer <Slider>(Test.Slider.ThumbImage, new Slider {
                ThumbImageSource = "coffee.png", Value = 0.5
            }, "Value", value => value.ToString());

            var dragStartedContainer = new EventViewContainer <Slider>(Test.Slider.DragStarted, new Slider {
                Value = 0.5
            });

            dragStartedContainer.View.DragStarted += (sender, args) => dragStartedContainer.EventFired();
            var dragCompletedContainer = new EventViewContainer <Slider>(Test.Slider.DragCompleted, new Slider {
                Value = 0.5
            });

            dragCompletedContainer.View.DragCompleted += (sender, args) => dragCompletedContainer.EventFired();

            Add(maximumContainer);
            Add(minimumContainer);
            Add(valueContainer);
            Add(minTrackColorContainer);
            Add(maxTrackColorContainer);
            Add(thumbColorContainer);
            Add(thumbImageContainer);
            Add(dragStartedContainer);
            Add(dragCompletedContainer);
        }
Пример #2
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);


            IsEnabledStateViewContainer.View.Clicked += (sender, args) =>
            {
                IsEnabledStateViewContainer.TitleLabel.Text += " (Tapped)";
            };

            var aspectFillContainer = new ViewContainer <ImageButton>(Test.ImageButton.AspectFill, new ImageButton {
                Aspect = Aspect.AspectFill
            });
            var aspectFitContainer = new ViewContainer <ImageButton>(Test.ImageButton.AspectFit, new ImageButton {
                Aspect = Aspect.AspectFit
            });
            var fillContainer = new ViewContainer <ImageButton>(Test.ImageButton.Fill, new ImageButton {
                Aspect = Aspect.Fill
            });
            var isLoadingContainer = new StateViewContainer <ImageButton>(Test.ImageButton.IsLoading, new ImageButton());
            var isOpaqueContainer  = new StateViewContainer <ImageButton>(Test.ImageButton.IsOpaque, new ImageButton());


            var borderButtonContainer = new ViewContainer <ImageButton>(Test.ImageButton.BorderColor,
                                                                        new ImageButton
            {
                BackgroundColor = Color.Transparent,
                BorderColor     = Color.Red,
                BorderWidth     = 1,
                Source          = "oasissmall.jpg"
            }
                                                                        );

            var corderRadiusContainer = new ViewContainer <ImageButton>(Test.ImageButton.CornerRadius,
                                                                        new ImageButton
            {
                Source          = "oasissmall.jpg",
                BackgroundColor = Color.Transparent,
                BorderColor     = Color.Red,
                CornerRadius    = 20,
                BorderWidth     = 1,
            }
                                                                        );

            var borderWidthContainer = new ViewContainer <ImageButton>(Test.ImageButton.BorderWidth,
                                                                       new ImageButton
            {
                Source          = "oasissmall.jpg",
                BackgroundColor = Color.Transparent,
                BorderColor     = Color.Red,
                BorderWidth     = 15,
            }
                                                                       );

            var clickedContainer = new EventViewContainer <ImageButton>(Test.ImageButton.Clicked,
                                                                        new ImageButton
            {
                Source = "oasissmall.jpg"
            }
                                                                        );

            clickedContainer.View.Clicked += (sender, args) => clickedContainer.EventFired();

            var pressedContainer = new EventViewContainer <ImageButton>(Test.ImageButton.Pressed,
                                                                        new ImageButton
            {
                Source = "oasissmall.jpg"
            }
                                                                        );

            pressedContainer.View.Pressed += (sender, args) => pressedContainer.EventFired();

            var commandContainer = new ViewContainer <ImageButton>(Test.ImageButton.Command,
                                                                   new ImageButton
            {
                Command = new Command(() => DisplayActionSheet("Hello Command", "Cancel", "Destroy")),
                Source  = "oasissmall.jpg"
            }
                                                                   );

            var imageContainer = new ViewContainer <ImageButton>(Test.ImageButton.Image,
                                                                 new ImageButton
            {
                Source = new FileImageSource {
                    File = "bank.png"
                }
            }
                                                                 );

            var paddingContainer = new ViewContainer <ImageButton>(Test.ImageButton.Padding,
                                                                   new ImageButton
            {
                Source          = "oasissmall.jpg",
                BackgroundColor = Color.Red,
                Padding         = new Thickness(20, 30, 60, 15)
            }
                                                                   );


            InitializeElement(aspectFillContainer.View);
            InitializeElement(aspectFitContainer.View);
            InitializeElement(fillContainer.View);
            InitializeElement(isLoadingContainer.View);
            InitializeElement(isOpaqueContainer.View);

            var sourceContainer = new ViewContainer <ImageButton>(Test.ImageButton.Source, new ImageButton {
                Source = "https://raw.githubusercontent.com/xamarin/Xamarin.Forms/main/Microsoft.Maui.Controls.ControlGallery/coffee.png"
            });

            var gifContainer = new ViewContainer <ImageButton>(Test.ImageButton.Source, new ImageButton {
                Source = "GifTwo.gif"
            });

            Add(aspectFillContainer);
            Add(aspectFitContainer);
            Add(fillContainer);
            Add(isLoadingContainer);
            Add(isOpaqueContainer);
            Add(sourceContainer);
            Add(gifContainer);

            Add(borderButtonContainer);
            Add(borderWidthContainer);
            Add(clickedContainer);
            Add(commandContainer);
            Add(corderRadiusContainer);
            Add(imageContainer);
            Add(pressedContainer);
            Add(paddingContainer);
        }
Пример #3
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var completedContainer = new EventViewContainer <Entry>(Test.Entry.Completed, new Entry {
                Placeholder = "Completed"
            });

            completedContainer.View.Completed += (sender, args) => completedContainer.EventFired();

            var placeholderContainer = new ViewContainer <Entry>(Test.Entry.Placeholder, new Entry {
                Placeholder = "Placeholder"
            });
            var keyboardContainer = new ViewContainer <Entry>(Test.InputView.Keyboard, new Entry {
                Keyboard = Keyboard.Numeric
            });
            var isPasswordContainer = new ViewContainer <Entry>(Test.Entry.IsPassword, new Entry {
                IsPassword = true
            });
            var textContainer = new ViewContainer <Entry>(Test.Entry.Text, new Entry {
                Text = "Hi, I am Text"
            });

            var textChangedContainer = new EventViewContainer <Entry>(Test.Entry.TextChanged, new Entry());

            textChangedContainer.View.TextChanged += (sender, args) => textChangedContainer.EventFired();

            var textFontAttributesContainer = new ViewContainer <Entry>(Test.Entry.FontAttributes, new Entry {
                Text = "I have italic text", FontAttributes = FontAttributes.Italic
            });
            var textFamilyContainer1 = new ViewContainer <Entry>(Test.Entry.FontFamily, new Entry {
                Text = "I have Comic Sans text in Win & Android", FontFamily = "Comic Sans MS"
            });
            var textFamilyContainer2 = new ViewContainer <Entry>(Test.Entry.FontFamily, new Entry {
                Text = "I have bold Chalkboard text in iOS", FontFamily = "ChalkboardSE-Regular", FontAttributes = FontAttributes.Bold
            });
            var textFontSizeContainer = new ViewContainer <Entry>(Test.Entry.FontSize, new Entry {
                Text = "I have default size text"
            });
            var textFontSizeDefaultContainer = new ViewContainer <Entry>(Test.Entry.FontSize, new Entry {
                Text = "I also have default size text"
            });

            textFontSizeDefaultContainer.View.FontSize = Device.GetNamedSize(NamedSize.Default, textFontSizeDefaultContainer.View);
            var textFontSizeLargeContainer = new ViewContainer <Entry>(Test.Entry.FontSize, new Entry {
                Text = "I have size 48 (huge) text", FontSize = 48
            });

            var textColorContainer = new ViewContainer <Entry>(Test.Entry.TextColor, new Entry {
                Text = "Hi, I should be red", TextColor = Color.Red
            });

            var xAlignCenterContainer = new ViewContainer <Entry>(Test.Entry.HorizontalTextAlignmentCenter,
                                                                  new Entry {
                Text = "Should be centered", HorizontalTextAlignment = TextAlignment.Center
            });
            var xAlignEndContainer = new ViewContainer <Entry>(Test.Entry.HorizontalTextAlignmentEnd,
                                                               new Entry {
                Text = "Should be aligned end", HorizontalTextAlignment = TextAlignment.End
            });
            var xAlignStartContainer = new ViewContainer <Entry>(Test.Entry.HorizontalTextAlignmentStart,
                                                                 new Entry {
                Text = "Should be aligned start", HorizontalTextAlignment = TextAlignment.Start
            });

            var xAlignPlaceholderCenter = new ViewContainer <Entry>(Test.Entry.HorizontalTextAlignmentPlaceholderCenter,
                                                                    new Entry {
                Placeholder = "Should be centered", HorizontalTextAlignment = TextAlignment.Center
            });
            var xAlignPlaceholderEnd = new ViewContainer <Entry>(Test.Entry.HorizontalTextAlignmentPlaceholderEnd,
                                                                 new Entry {
                Placeholder = "Should be aligned end", HorizontalTextAlignment = TextAlignment.End
            });
            var xAlignPlaceholderStart = new ViewContainer <Entry>(Test.Entry.HorizontalTextAlignmentPlaceholderStart,
                                                                   new Entry {
                Placeholder = "Should be aligned start", HorizontalTextAlignment = TextAlignment.Start
            });

            var yAlignCenterContainer = new ViewContainer <Entry>(Test.Entry.VerticalTextAlignmentCenter,
                                                                  new Entry {
                Text = "Should be centered!", VerticalTextAlignment = TextAlignment.Center, BackgroundColor = Color.Pink, HeightRequest = 100
            });
            var yAlignEndContainer = new ViewContainer <Entry>(Test.Entry.VerticalTextAlignmentEnd,
                                                               new Entry {
                Text = "Should be aligned end!", VerticalTextAlignment = TextAlignment.End, BackgroundColor = Color.Pink, HeightRequest = 100
            });
            var yAlignStartContainer = new ViewContainer <Entry>(Test.Entry.VerticalTextAlignmentStart,
                                                                 new Entry {
                Text = "Should be aligned start!", VerticalTextAlignment = TextAlignment.Start, BackgroundColor = Color.Pink, HeightRequest = 100
            });

            var yAlignPlaceholderCenter = new ViewContainer <Entry>(Test.Entry.VerticalTextAlignmentPlaceholderCenter,
                                                                    new Entry {
                Placeholder = "Should be centered!", VerticalTextAlignment = TextAlignment.Center, BackgroundColor = Color.Pink, HeightRequest = 100
            });
            var yAlignPlaceholderEnd = new ViewContainer <Entry>(Test.Entry.VerticalTextAlignmentPlaceholderEnd,
                                                                 new Entry {
                Placeholder = "Should be aligned end!", VerticalTextAlignment = TextAlignment.End, BackgroundColor = Color.Pink, HeightRequest = 100
            });
            var yAlignPlaceholderStart = new ViewContainer <Entry>(Test.Entry.VerticalTextAlignmentPlaceholderStart,
                                                                   new Entry {
                Placeholder = "Should be aligned start!", VerticalTextAlignment = TextAlignment.Start, BackgroundColor = Color.Pink, HeightRequest = 100
            });

            var placeholderColorContainer = new ViewContainer <Entry>(Test.Entry.PlaceholderColor,
                                                                      new Entry {
                Placeholder = "Hi, I should be red", PlaceholderColor = Color.Red
            });

            var textColorDisabledContainer = new ViewContainer <Entry>(Test.Entry.TextDisabledColor,
                                                                       new Entry {
                IsEnabled = false, Text = "I should be the default disabled color", TextColor = Color.Red
            });

            var placeholderColorDisabledContainer = new ViewContainer <Entry>(Test.Entry.PlaceholderDisabledColor,
                                                                              new Entry
            {
                IsEnabled        = false,
                Placeholder      = "I should be the default placeholder disabled color",
                PlaceholderColor = Color.Red
            });

            var passwordColorContainer = new ViewContainer <Entry>(Test.Entry.PasswordColor,
                                                                   new Entry {
                IsPassword = true, Text = "12345", TextColor = Color.Red
            });

            var maxLengthContainer = new ViewContainer <Entry>(Test.InputView.MaxLength, new Entry {
                MaxLength = 3
            });

            var readOnlyContainer = new ViewContainer <Entry>(Test.Entry.IsReadOnly, new Entry {
                Text = "This is read-only Entry", IsReadOnly = true
            });
            var isPasswordInputScopeContainer = new ViewContainer <Entry>(Test.Entry.IsPasswordNumeric, new Entry {
                Keyboard = Keyboard.Numeric
            });
            var switchPasswordButton = new Button
            {
                Text = "Toggle IsPassword"
            };
            var switchNumericButton = new Button
            {
                Text = "Toggle numeric"
            };

            switchPasswordButton.Clicked += (o, a) =>
            {
                isPasswordInputScopeContainer.View.IsPassword = !isPasswordInputScopeContainer.View.IsPassword;
            };
            switchNumericButton.Clicked += (o, a) =>
            {
                isPasswordInputScopeContainer.View.Keyboard = isPasswordInputScopeContainer.View.Keyboard == Keyboard.Numeric ? Keyboard.Default : Keyboard.Numeric;
            };
            isPasswordInputScopeContainer.ContainerLayout.Children.Add(switchPasswordButton);
            isPasswordInputScopeContainer.ContainerLayout.Children.Add(switchNumericButton);

            var switchClearBtnVisibilityBtn = new Button {
                Text = "Toggle ClearButtonVisibility"
            };
            var clearBtnModelContainer = new ViewContainer <Entry>(Test.Entry.ClearButtonVisibility,
                                                                   new Entry {
                Text = "I should have clear button visible", ClearButtonVisibility = ClearButtonVisibility.WhileEditing
            });

            switchClearBtnVisibilityBtn.Clicked += (o, a) =>
                                                   clearBtnModelContainer.View.ClearButtonVisibility = clearBtnModelContainer.View.ClearButtonVisibility == ClearButtonVisibility.Never ? ClearButtonVisibility.WhileEditing : ClearButtonVisibility.Never;
            clearBtnModelContainer.ContainerLayout.Children.Add(switchClearBtnVisibilityBtn);

            Add(isPasswordContainer);
            Add(completedContainer);
            Add(placeholderContainer);
            Add(keyboardContainer);
            Add(textContainer);
            Add(textChangedContainer);
            Add(textColorContainer);
            Add(xAlignPlaceholderCenter);
            Add(xAlignCenterContainer);
            Add(xAlignPlaceholderEnd);
            Add(xAlignEndContainer);
            Add(xAlignPlaceholderStart);
            Add(xAlignStartContainer);
            Add(yAlignPlaceholderCenter);
            Add(yAlignCenterContainer);
            Add(yAlignPlaceholderEnd);
            Add(yAlignEndContainer);
            Add(yAlignPlaceholderStart);
            Add(yAlignStartContainer);
            Add(textFontAttributesContainer);
            Add(textFamilyContainer1);
            Add(textFamilyContainer2);
            Add(textFontSizeContainer);
            Add(textFontSizeDefaultContainer);
            Add(textFontSizeLargeContainer);
            Add(placeholderColorContainer);
            Add(textColorDisabledContainer);
            Add(placeholderColorDisabledContainer);
            Add(passwordColorContainer);
            Add(maxLengthContainer);
            Add(readOnlyContainer);
            Add(isPasswordInputScopeContainer);
            Add(clearBtnModelContainer);
        }
Пример #4
0
        protected virtual void Build(StackLayout stackLayout)
        {
            var isFocusedView = new T();

            isFocusedView.SetValueCore(IsFocusedPropertyKey, true);

            IsEnabledStateViewContainer = new StateViewContainer <T>(Test.VisualElement.IsEnabled, new T {
                IsEnabled = true
            });
            IsEnabledStateViewContainer.StateChangeButton.Command = new Command(() =>
            {
                IsEnabledStateViewContainer.View.IsEnabled = !IsEnabledStateViewContainer.View.IsEnabled;
            });

            var isVisibleStateViewContainer = new StateViewContainer <T>(Test.VisualElement.IsVisible, new T {
                IsVisible = true
            });

            isVisibleStateViewContainer.StateChangeButton.Command = new Command(() =>
            {
                isVisibleStateViewContainer.View.IsVisible = !isVisibleStateViewContainer.View.IsVisible;
            });

            var isFocusedStateViewContainer = new StateViewContainer <T>(Test.VisualElement.IsFocused, isFocusedView);

            isFocusedStateViewContainer.StateChangeButton.Command = new Command(() =>
            {
                if ((bool)isFocusedView.GetValue(VisualElement.IsFocusedProperty))
                {
                    isFocusedView.SetValueCore(IsFocusedPropertyKey, false);
                }
                else
                {
                    isFocusedView.SetValueCore(IsFocusedPropertyKey, true);
                }
            });

            var focusStateViewContainer = new StateViewContainer <T>(Test.VisualElement.Focus, new T());

            focusStateViewContainer.StateChangeButton.Command = new Command(() =>
            {
                if (focusStateViewContainer.View.IsFocused)
                {
                    focusStateViewContainer.View.Unfocus();
                }
                else
                {
                    focusStateViewContainer.View.Focus();
                }
            });

            var focusedEventViewContainer = new EventViewContainer <T>(Test.VisualElement.Focused, new T());

            focusedEventViewContainer.View.Focused += (sender, args) => focusedEventViewContainer.EventFired();

            var unfocusedEventViewContainer = new EventViewContainer <T>(Test.VisualElement.Unfocused, new T());

            unfocusedEventViewContainer.View.Unfocused += (sender, args) => unfocusedEventViewContainer.EventFired();

            var gestureRecognizerEventViewContainer = new EventViewContainer <T>(Test.View.GestureRecognizers, new T());

            gestureRecognizerEventViewContainer.View.GestureRecognizers.Add(
                new TapGestureRecognizer
            {
                Command = new Command(() => gestureRecognizerEventViewContainer.EventFired())
            }
                );

            _viewContainers = new List <ViewContainer <T> > {
                isFocusedStateViewContainer,
                new ViewContainer <T> (Test.VisualElement.BackgroundColor, new T {
                    BackgroundColor = Color.Blue
                }),
                new ViewContainer <T>(Test.VisualElement.Background, new T {
                    Background = new LinearGradientBrush
                    {
                        StartPoint    = new Point(0, 0),
                        EndPoint      = new Point(1, 0),
                        GradientStops = new GradientStopCollection
                        {
                            new GradientStop(Color.Yellow, 0.0f),
                            new GradientStop(Color.Orange, 0.5f),
                            new GradientStop(Color.Red, 1.0f)
                        }
                    }
                }),
                focusStateViewContainer,
                gestureRecognizerEventViewContainer,
                new LayeredViewContainer <T> (Test.VisualElement.InputTransparent, new T {
                    InputTransparent = true
                }),
                IsEnabledStateViewContainer,
                focusedEventViewContainer,
                unfocusedEventViewContainer,
                isVisibleStateViewContainer,
                new ViewContainer <T> (Test.VisualElement.Opacity, new T {
                    Opacity = 0.5
                }),
                new ViewContainer <T> (Test.VisualElement.Rotation, new T {
                    Rotation = 10
                }),
                new ViewContainer <T> (Test.VisualElement.RotationX, new T {
                    RotationX = 33
                }),
                new ViewContainer <T> (Test.VisualElement.RotationY, new T {
                    RotationY = 10
                }),
                new ViewContainer <T> (Test.VisualElement.Scale, new T {
                    Scale = 0.5
                }),
                new ViewContainer <T> (Test.VisualElement.TranslationX, new T {
                    TranslationX = 30
                }),
                new ViewContainer <T> (Test.VisualElement.TranslationY, new T {
                    TranslationY = 30
                }),
            };

            _layout = new StackLayout();

            _targetEntry = new Entry {
                AutomationId = "TargetViewContainer", Placeholder = "Jump To ViewContainer"
            };

            var goButton = new Button
            {
                Text         = "Go",
                AutomationId = "GoButton"
            };

            goButton.Clicked += GoClicked;

            _picker = new Picker();
            foreach (var container in _viewContainers)
            {
                _picker.Items.Add(container.TitleLabel.Text);
            }

            _picker.SelectedIndex = _currentIndex;

            _picker.SelectedIndexChanged += PickerSelectedIndexChanged;

            _layout.Children.Add(_picker);
            _layout.Children.Add(_targetEntry);
            _layout.Children.Add(goButton);
            _layout.Children.Add(_viewContainers[_currentIndex].ContainerLayout);

            stackLayout.Children.Add(_layout);

            if (!SupportsFocus)
            {
                stackLayout.Children.Remove(focusStateViewContainer.ContainerLayout);
                stackLayout.Children.Remove(isFocusedStateViewContainer.ContainerLayout);
            }

            if (!SupportsTapGestureRecognizer)
            {
                stackLayout.Children.Remove(gestureRecognizerEventViewContainer.ContainerLayout);
            }

            foreach (var element in _viewContainers)
            {
                InitializeElement(element.View);
            }
        }
Пример #5
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            IsEnabledStateViewContainer.View.Clicked += (sender, args) => IsEnabledStateViewContainer.TitleLabel.Text += " (Tapped)";

            var borderButtonContainer = new ViewContainer <Button>(Test.Button.BorderColor,
                                                                   new Button
            {
                Text            = "BorderColor",
                BackgroundColor = Color.Transparent,
                BorderColor     = Color.Red,
                BorderWidth     = 1,
            }
                                                                   );

            var borderRadiusContainer = new ViewContainer <Button>(Test.Button.BorderRadius,
                                                                   new Button
            {
                Text            = "BorderRadius",
                BackgroundColor = Color.Transparent,
                BorderColor     = Color.Red,
                CornerRadius    = 20,
                BorderWidth     = 1,
            }
                                                                   );

            var borderWidthContainer = new ViewContainer <Button>(Test.Button.BorderWidth,
                                                                  new Button
            {
                Text            = "BorderWidth",
                BackgroundColor = Color.Transparent,
                BorderColor     = Color.Red,
                BorderWidth     = 15,
            }
                                                                  );

            var clickedContainer = new EventViewContainer <Button>(Test.Button.Clicked,
                                                                   new Button
            {
                Text = "Clicked"
            }
                                                                   );

            clickedContainer.View.Clicked += (sender, args) => clickedContainer.EventFired();

            var pressedContainer = new EventViewContainer <Button>(Test.Button.Pressed,
                                                                   new Button
            {
                Text = "Pressed"
            }
                                                                   );

            pressedContainer.View.Pressed += (sender, args) => pressedContainer.EventFired();

            var commandContainer = new ViewContainer <Button>(Test.Button.Command,
                                                              new Button
            {
                Text    = "Command",
                Command = new Command(() => DisplayActionSheet("Hello Command", "Cancel", "Destroy"))
            }
                                                              );

            var fontContainer = new ViewContainer <Button>(Test.Button.Font,
                                                           new Button
            {
                Text = "Font",
                Font = Font.SystemFontOfSize(NamedSize.Large, FontAttributes.Bold)
            }
                                                           );

            var imageContainer = new ViewContainer <Button>(Test.Button.Image,
                                                            new Button
            {
                Text        = "Image",
                ImageSource = new FileImageSource {
                    File = "bank.png"
                }
            }
                                                            )
            ;
            var textContainer = new ViewContainer <Button>(Test.Button.Text,
                                                           new Button
            {
                Text = "Text"
            }
                                                           );

            var textColorContainer = new ViewContainer <Button>(Test.Button.TextColor,
                                                                new Button
            {
                Text      = "TextColor",
                TextColor = Color.Pink
            }
                                                                );

            var paddingContainer = new ViewContainer <Button>(Test.Button.Padding,
                                                              new Button
            {
                Text            = "Padding",
                BackgroundColor = Color.Red,
                Padding         = new Thickness(20, 30, 60, 15)
            }
                                                              );

            Add(borderButtonContainer);
            Add(borderRadiusContainer);
            Add(borderWidthContainer);
            Add(clickedContainer);
            Add(pressedContainer);
            Add(commandContainer);
            Add(fontContainer);
            Add(imageContainer);
            Add(textContainer);
            Add(textColorContainer);
            Add(paddingContainer);
            //stackLayout.Children.Add (textColorContainer);
        }
Пример #6
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);
            var placeholderContainer = new ViewContainer <SearchBar>(Test.SearchBar.PlaceHolder, new SearchBar {
                Placeholder = "Placeholder"
            });

            var searchButtonPressedContainer = new EventViewContainer <SearchBar>(Test.SearchBar.SearchButtonPressed, new SearchBar {
            });

            searchButtonPressedContainer.View.SearchButtonPressed += (sender, args) => searchButtonPressedContainer.EventFired();

            var searchCommandContainer = new ViewContainer <SearchBar>(Test.SearchBar.SearchCommand,
                                                                       new SearchBar
            {
                SearchCommand = new Command(async() => await DisplayAlert("Search command", "Fired", "Ok"))
            }
                                                                       );

            var textContainer = new ViewContainer <SearchBar>(Test.SearchBar.Text, new SearchBar {
                Text = "I am text"
            });

            var textChangedContainer = new EventViewContainer <SearchBar>(Test.SearchBar.TextChanged, new SearchBar {
                Placeholder = "I am text changed"
            });

            textChangedContainer.View.TextChanged += (sender, args) => textChangedContainer.EventFired();

            var cancelButtonColor = new ViewContainer <SearchBar>(
                Test.SearchBar.CancelButtonColor,
                new SearchBar
            {
                Placeholder       = "Should have a red cancel button",
                CancelButtonColor = Color.Red
            }
                );

            var textFontAttributesContainer = new ViewContainer <SearchBar>(Test.SearchBar.FontAttributes, new SearchBar {
                Text = "I have italic text", FontAttributes = FontAttributes.Italic
            });
            var textFamilyContainer1 = new ViewContainer <SearchBar>(Test.SearchBar.FontFamily, new SearchBar {
                Text = "I have Comic Sans text in Win & Android", FontFamily = "Comic Sans MS"
            });
            var textFamilyContainer2 = new ViewContainer <SearchBar>(Test.SearchBar.FontFamily, new SearchBar {
                Text = "I have bold Chalkboard text in iOS", FontFamily = "ChalkboardSE-Regular", FontAttributes = FontAttributes.Bold
            });
            var textFontSizeContainer = new ViewContainer <SearchBar>(Test.SearchBar.FontSize, new SearchBar {
                Text = "I have default size text"
            });
            var textFontSizeDefaultContainer = new ViewContainer <SearchBar>(Test.SearchBar.FontSize, new SearchBar {
                Text = "I also have default size text"
            });

            textFontSizeDefaultContainer.View.FontSize = Device.GetNamedSize(NamedSize.Default, textFontSizeDefaultContainer.View);
            var textFontSizeLargeContainer = new ViewContainer <SearchBar>(Test.SearchBar.FontSize, new SearchBar {
                Text = "I have size 48 (huge) text", FontSize = 48
            });

            var textAlignmentStartContainer = new ViewContainer <SearchBar>(Test.SearchBar.TextAlignmentStart,
                                                                            new SearchBar {
                Text = "I should be at the start", HorizontalTextAlignment = TextAlignment.Start
            });
            var textAlignmentCenterContainer = new ViewContainer <SearchBar>(Test.SearchBar.TextAlignmentCenter,
                                                                             new SearchBar {
                Text = "I should be centered", HorizontalTextAlignment = TextAlignment.Center
            });
            var textAlignmentEndContainer = new ViewContainer <SearchBar>(Test.SearchBar.TextAlignmentEnd,
                                                                          new SearchBar {
                Text = "I should be at the end", HorizontalTextAlignment = TextAlignment.End
            });

            var textVerticalAlignmentStartContainer = new ViewContainer <SearchBar>(Test.SearchBar.TextVerticalAlignmentStart,
                                                                                    new SearchBar {
                Text = "I should be at the start", VerticalTextAlignment = TextAlignment.Start
            });
            var textVerticalAlignmentCenterContainer = new ViewContainer <SearchBar>(Test.SearchBar.TextVerticalAlignmentCenter,
                                                                                     new SearchBar {
                Text = "I should be centered", VerticalTextAlignment = TextAlignment.Center
            });
            var textVerticalAlignmentEndContainer = new ViewContainer <SearchBar>(Test.SearchBar.TextVerticalAlignmentEnd,
                                                                                  new SearchBar {
                Text = "I should be at the end", VerticalTextAlignment = TextAlignment.End
            });

            var placeholderAlignmentStartContainer = new ViewContainer <SearchBar>(Test.SearchBar.PlaceholderAlignmentStart,
                                                                                   new SearchBar {
                Placeholder = "I should be at the start", HorizontalTextAlignment = TextAlignment.Start
            });
            var placeholderAlignmentCenterContainer = new ViewContainer <SearchBar>(Test.SearchBar.PlaceholderAlignmentCenter,
                                                                                    new SearchBar {
                Placeholder = "I should be centered", HorizontalTextAlignment = TextAlignment.Center
            });
            var placeholderAlignmentEndContainer = new ViewContainer <SearchBar>(Test.SearchBar.PlaceholderAlignmentEnd,
                                                                                 new SearchBar {
                Placeholder = "I should be at the end", HorizontalTextAlignment = TextAlignment.End
            });

            var placeholderVerticalAlignmentStartContainer = new ViewContainer <SearchBar>(Test.SearchBar.PlaceholderVerticalAlignmentStart,
                                                                                           new SearchBar {
                Placeholder = "I should be at the start", VerticalTextAlignment = TextAlignment.Start
            });
            var placeholderVerticalAlignmentCenterContainer = new ViewContainer <SearchBar>(Test.SearchBar.PlaceholderVerticalAlignmentCenter,
                                                                                            new SearchBar {
                Placeholder = "I should be centered", VerticalTextAlignment = TextAlignment.Center
            });
            var placeholderVerticalAlignmentEndContainer = new ViewContainer <SearchBar>(Test.SearchBar.PlaceholderVerticalAlignmentEnd,
                                                                                         new SearchBar {
                Placeholder = "I should be at the end", VerticalTextAlignment = TextAlignment.End
            });

            var textColorContainer = new ViewContainer <SearchBar>(Test.SearchBar.TextColor,
                                                                   new SearchBar {
                Text = "I should be red", TextColor = Color.Red
            });

            var placeholderColorContainer = new ViewContainer <SearchBar>(Test.SearchBar.PlaceholderColor,
                                                                          new SearchBar {
                Placeholder = "I should be red", PlaceholderColor = Color.Red
            });

            var keyboardContainer = new ViewContainer <SearchBar>(Test.InputView.Keyboard,
                                                                  new SearchBar {
                Keyboard = Keyboard.Numeric
            });

            var maxLengthContainer = new ViewContainer <SearchBar>(Test.InputView.MaxLength,
                                                                   new SearchBar {
                MaxLength = 3
            });

            Add(placeholderContainer);
            Add(searchButtonPressedContainer);
            Add(searchCommandContainer);
            Add(textContainer);
            Add(textChangedContainer);
            Add(textFontAttributesContainer);
            Add(textFamilyContainer1);
            Add(textFamilyContainer2);
            Add(textFontSizeContainer);
            Add(textFontSizeDefaultContainer);
            Add(textFontSizeLargeContainer);
            Add(cancelButtonColor);
            Add(textAlignmentStartContainer);
            Add(textAlignmentCenterContainer);
            Add(textAlignmentEndContainer);
            Add(placeholderAlignmentStartContainer);
            Add(placeholderAlignmentCenterContainer);
            Add(placeholderAlignmentEndContainer);
            Add(textVerticalAlignmentStartContainer);
            Add(textVerticalAlignmentCenterContainer);
            Add(textVerticalAlignmentEndContainer);
            Add(placeholderVerticalAlignmentStartContainer);
            Add(placeholderVerticalAlignmentCenterContainer);
            Add(placeholderVerticalAlignmentEndContainer);
            Add(textColorContainer);
            Add(placeholderColorContainer);
            Add(keyboardContainer);
            Add(maxLengthContainer);
        }
Пример #7
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var viewModel = new ListViewViewModel();

            var groupDisplayBindingContainer = new ViewContainer <ListView>(Test.ListView.GroupDisplayBinding, new ListView());

            InitializeElementListView(groupDisplayBindingContainer.View, 0);
            groupDisplayBindingContainer.View.ItemsSource         = viewModel.CategorizedEmployees;
            groupDisplayBindingContainer.View.IsGroupingEnabled   = true;
            groupDisplayBindingContainer.View.GroupDisplayBinding = new Binding("Key");


            var groupHeaderTemplateContainer = new ViewContainer <ListView>(Test.ListView.GroupHeaderTemplate, new ListView());

            InitializeElementListView(groupHeaderTemplateContainer.View, 0);
            groupHeaderTemplateContainer.View.ItemsSource         = viewModel.CategorizedEmployees;
            groupHeaderTemplateContainer.View.IsGroupingEnabled   = true;
            groupHeaderTemplateContainer.View.GroupHeaderTemplate = new DataTemplate(typeof(HeaderCell));

            var groupShortNameContainer = new ViewContainer <ListView>(Test.ListView.GroupShortNameBinding, new ListView());

            InitializeElementListView(groupShortNameContainer.View, 0);
            groupShortNameContainer.View.ItemsSource           = viewModel.CategorizedEmployees;
            groupShortNameContainer.View.IsGroupingEnabled     = true;
            groupShortNameContainer.View.GroupShortNameBinding = new Binding("Key");

            // TODO - not sure how to do this
            var hasUnevenRowsContainer = new ViewContainer <ListView>(Test.ListView.HasUnevenRows, new ListView());

            InitializeElement(hasUnevenRowsContainer.View);
            hasUnevenRowsContainer.View.HasUnevenRows = true;
            hasUnevenRowsContainer.View.ItemTemplate  = new DataTemplate(typeof(UnevenCell));

            var isGroupingEnabledContainer = new StateViewContainer <ListView>(Test.ListView.IsGroupingEnabled, new ListView());

            InitializeElement(isGroupingEnabledContainer.View);
            isGroupingEnabledContainer.View.ItemsSource           = viewModel.CategorizedEmployees;
            isGroupingEnabledContainer.View.IsGroupingEnabled     = true;
            isGroupingEnabledContainer.StateChangeButton.Clicked += (sender, args) => isGroupingEnabledContainer.View.IsGroupingEnabled = !isGroupingEnabledContainer.View.IsGroupingEnabled;


            var itemAppearingContainer = new EventViewContainer <ListView>(Test.ListView.ItemAppearing, new ListView());

            InitializeElement(itemAppearingContainer.View);
            itemAppearingContainer.View.ItemAppearing += (sender, args) => itemAppearingContainer.EventFired();

            var itemDisappearingContainer = new EventViewContainer <ListView>(Test.ListView.ItemDisappearing, new ListView());

            InitializeElement(itemDisappearingContainer.View);
            itemDisappearingContainer.View.ItemDisappearing += (sender, args) => itemDisappearingContainer.EventFired();

            var itemSelectedContainer = new EventViewContainer <ListView>(Test.ListView.ItemSelected, new ListView());

            InitializeElement(itemSelectedContainer.View);
            itemSelectedContainer.View.ItemSelected += (sender, args) => itemSelectedContainer.EventFired();

            var itemTappedContainer = new EventViewContainer <ListView>(Test.ListView.ItemTapped, new ListView());

            InitializeElement(itemTappedContainer.View);
            itemTappedContainer.View.ItemTapped += (sender, args) => itemTappedContainer.EventFired();

            // TODO
            var rowHeightContainer = new ViewContainer <ListView>(Test.ListView.RowHeight, new ListView());

            InitializeElement(rowHeightContainer.View);

            var selectedItemContainer = new ViewContainer <ListView>(Test.ListView.SelectedItem, new ListView());

            InitializeElement(selectedItemContainer.View);
            selectedItemContainer.View.SelectedItem = viewModel.Employees[2];

            var fastScrollItemContainer = new ViewContainer <ListView>(Test.ListView.FastScroll, new ListView());

            InitializeElement(fastScrollItemContainer.View);
            fastScrollItemContainer.View.On <Android>().SetIsFastScrollEnabled(true);
            fastScrollItemContainer.View.ItemsSource = viewModel.CategorizedEmployees;

            var scrolledItemContainer = new ViewContainer <ListView>(Test.ListView.Scrolled, new ListView());

            InitializeElement(scrolledItemContainer.View);
            scrolledItemContainer.View.ItemsSource = viewModel.Employees;
            var scrollTitle = scrolledItemContainer.TitleLabel.Text;

            scrolledItemContainer.View.Scrolled += (sender, args) =>
            {
                scrolledItemContainer.TitleLabel.Text = $"{scrollTitle}; X={args.ScrollX};Y={args.ScrollY}";
            };

            var refreshControlColorContainer = new ViewContainer <ListView>(Test.ListView.RefreshControlColor, new ListView());

            InitializeElement(refreshControlColorContainer.View);
            refreshControlColorContainer.View.RefreshControlColor    = Color.Red;
            refreshControlColorContainer.View.IsPullToRefreshEnabled = true;
            refreshControlColorContainer.View.Refreshing            += async(object sender, EventArgs e) =>
            {
                await Task.Delay(2000);

                refreshControlColorContainer.View.IsRefreshing = false;
            };
            refreshControlColorContainer.View.ItemsSource = viewModel.Employees;

            var scrollbarVisibilityContainer = new ViewContainer <ListView>(Test.ListView.ScrollBarVisibility, new ListView());

            InitializeElement(scrollbarVisibilityContainer.View);
            scrollbarVisibilityContainer.View.HorizontalScrollBarVisibility = ScrollBarVisibility.Never;
            scrollbarVisibilityContainer.View.VerticalScrollBarVisibility   = ScrollBarVisibility.Never;
            scrollbarVisibilityContainer.View.ItemsSource         = viewModel.CategorizedEmployees;
            scrollbarVisibilityContainer.View.IsGroupingEnabled   = true;
            scrollbarVisibilityContainer.View.GroupDisplayBinding = new Binding("Key");

            Add(groupDisplayBindingContainer);
            Add(groupHeaderTemplateContainer);
            Add(groupShortNameContainer);
            Add(hasUnevenRowsContainer);
            Add(isGroupingEnabledContainer);
            Add(itemAppearingContainer);
            Add(itemDisappearingContainer);
            Add(itemSelectedContainer);
            Add(itemTappedContainer);
            Add(rowHeightContainer);
            Add(selectedItemContainer);
            Add(fastScrollItemContainer);
            Add(scrolledItemContainer);
            Add(refreshControlColorContainer);
            Add(scrollbarVisibilityContainer);
        }
Пример #8
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var dateContainer = new ViewContainer <DatePicker>(Test.DatePicker.Date,
                                                               new DatePicker {
                Date = new DateTime(1987, 9, 13)
            });

            var dateSelectedContainer = new EventViewContainer <DatePicker>(Test.DatePicker.DateSelected, new DatePicker());

            dateSelectedContainer.View.DateSelected += (sender, args) => dateSelectedContainer.EventFired();

            var formatDateContainer = new ViewContainer <DatePicker>(Test.DatePicker.Format, new DatePicker {
                Format = "ddd"
            });
            var minimumDateContainer = new ViewContainer <DatePicker>(Test.DatePicker.MinimumDate,
                                                                      new DatePicker {
                MinimumDate = new DateTime(1987, 9, 13)
            });
            var maximumDateContainer = new ViewContainer <DatePicker>(Test.DatePicker.MaximumDate,
                                                                      new DatePicker {
                MaximumDate = new DateTime(2087, 9, 13)
            });
            var textColorContainer = new ViewContainer <DatePicker>(Test.DatePicker.TextColor,
                                                                    new DatePicker {
                Date = new DateTime(1978, 12, 24), TextColor = Color.Lime
            });
            var fontAttributesContainer = new ViewContainer <DatePicker>(Test.DatePicker.FontAttributes,
                                                                         new DatePicker {
                FontAttributes = FontAttributes.Bold
            });

            var fontFamilyContainer = new ViewContainer <DatePicker>(Test.DatePicker.FontFamily,
                                                                     new DatePicker());

            // Set font family based on available fonts per platform
            switch (Device.RuntimePlatform)
            {
            case Device.Android:
                fontFamilyContainer.View.FontFamily = "sans-serif-thin";
                break;

            case Device.iOS:
                fontFamilyContainer.View.FontFamily = "Courier";
                break;

            case Device.WPF:
                fontFamilyContainer.View.FontFamily = "Comic Sans MS";
                break;

            default:
                fontFamilyContainer.View.FontFamily = "Garamond";
                break;
            }

            var fontSizeContainer = new ViewContainer <DatePicker>(Test.DatePicker.FontSize,
                                                                   new DatePicker {
                FontSize = 32
            });

            Add(dateContainer);
            Add(dateSelectedContainer);
            Add(formatDateContainer);
            Add(minimumDateContainer);
            Add(maximumDateContainer);
            Add(textColorContainer);
            Add(fontAttributesContainer);
            Add(fontFamilyContainer);
            Add(fontSizeContainer);
        }
Пример #9
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var completedContainer = new EventViewContainer <Editor>(Test.Editor.Completed, new Editor());

            completedContainer.View.Completed += (sender, args) => completedContainer.EventFired();

            var textContainer = new ViewContainer <Editor>(Test.Editor.Text, new Editor {
                Text = "I have text"
            });

            var textChangedContainer = new EventViewContainer <Editor>(Test.Editor.TextChanged, new Editor());

            textChangedContainer.View.TextChanged += (sender, args) => textChangedContainer.EventFired();
            var placeholderContainer = new ViewContainer <Editor>(Test.Editor.Placeholder, new Editor {
                Placeholder = "Placeholder"
            });

            var placeholderColorContainer = new ViewContainer <Editor>(Test.Editor.PlaceholderColor, new Editor {
                Placeholder = "I should have red placeholder", PlaceholderColor = Color.Red
            });
            var textFontAttributesContainer = new ViewContainer <Editor>(Test.Editor.FontAttributes, new Editor {
                Text = "I have italic text", FontAttributes = FontAttributes.Italic
            });
            var textFamilyContainer1 = new ViewContainer <Editor>(Test.Editor.FontFamily, new Editor {
                Text = "I have Comic Sans text in Win & Android", FontFamily = "Comic Sans MS"
            });
            var textFamilyContainer2 = new ViewContainer <Editor>(Test.Editor.FontFamily, new Editor {
                Text = "I have bold Chalkboard text in iOS", FontFamily = "ChalkboardSE-Regular", FontAttributes = FontAttributes.Bold
            });
            var textFontSizeContainer = new ViewContainer <Editor>(Test.Editor.FontSize, new Editor {
                Text = "I have default size text"
            });
            var textFontSizeDefaultContainer = new ViewContainer <Editor>(Test.Editor.FontSize, new Editor {
                Text = "I also have default size text"
            });

            textFontSizeDefaultContainer.View.FontSize = Device.GetNamedSize(NamedSize.Default, textFontSizeDefaultContainer.View);
            var textFontSizeLargeContainer = new ViewContainer <Editor>(Test.Editor.FontSize, new Editor {
                Text = "I have size 48 (huge) text", FontSize = 48, Placeholder = "This is a placeholder"
            });

            var textColorContainer = new ViewContainer <Editor>(Test.Editor.TextColor,
                                                                new Editor {
                Text = "I should have red text", TextColor = Color.Red
            });

            var textColorDisabledContainer = new ViewContainer <Editor>(Test.Editor.TextColor,
                                                                        new Editor {
                Text = "I should have the default disabled text color", TextColor = Color.Red, IsEnabled = false
            });

            var keyboardContainer = new ViewContainer <Editor>(Test.InputView.Keyboard,
                                                               new Editor {
                Keyboard = Keyboard.Numeric
            });

            var maxLengthContainer = new ViewContainer <Editor>(Test.InputView.MaxLength, new Editor {
                MaxLength = 3
            });

            var readOnlyContainer = new ViewContainer <Editor>(Test.Editor.IsReadOnly, new Editor {
                Text = "This is read-only Editor", IsReadOnly = true
            });

            Add(completedContainer);
            Add(textContainer);
            Add(textChangedContainer);
            Add(placeholderContainer);
            Add(placeholderColorContainer);
            Add(textFontAttributesContainer);
            Add(textFamilyContainer1);
            Add(textFamilyContainer2);
            Add(textFontSizeContainer);
            Add(textFontSizeDefaultContainer);
            Add(textFontSizeLargeContainer);
            Add(textColorContainer);
            Add(textColorDisabledContainer);
            Add(keyboardContainer);
            Add(maxLengthContainer);
            Add(readOnlyContainer);
        }