Exemplo n.º 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);
        }
Exemplo n.º 2
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
            });

            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);
        }
Exemplo n.º 3
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;

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

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

            Add(dateContainer);
            Add(dateSelectedContainer);
            Add(formatDateContainer);
            Add(minimumDateContainer);
            Add(maximumDateContainer);
            Add(textColorContainer);
            Add(fontAttributesContainer);
            Add(fontFamilyContainer);
            Add(fontSizeContainer);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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
                }),
                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);
            }
        }
Exemplo n.º 6
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,
#pragma warning disable 0618
                BorderRadius = 20,
#pragma warning restore
                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);
        }
Exemplo n.º 7
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/System.Maui/master/System.Maui.Controls/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);
        }
Exemplo n.º 8
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

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

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

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

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

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

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

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

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

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

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

            var textContainer = new ViewContainer <RadioButton>(Test.Button.Text,
                                                                new RadioButton
            {
                Text = "Text"
            }
                                                                );

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

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

            var isCheckedContainer = new ValueViewContainer <RadioButton>(Test.RadioButton.IsChecked, new RadioButton()
            {
                IsChecked = true, HorizontalOptions = LayoutOptions.Start
            }, "IsChecked", value => value.ToString());

            //var checkedVisualState = new VisualState { Name = "IsChecked" };
            //checkedVisualState.Setters.Add(new Setter { Property = RadioButton.ButtonSourceProperty, Value = "rb_checked" });

            //var group = new VisualStateGroup();
            //group.States.Add(checkedVisualState);

            //var normalVisualState = new VisualState{  Name = "Normal" };
            //normalVisualState.Setters.Add(new Setter { Property = RadioButton.ButtonSourceProperty, Value = "rb_unchecked" });
            //group.States.Add(normalVisualState);

            //var groupList = new VisualStateGroupList();
            //groupList.Add(group);

            //var rbStateManaged = new RadioButton() { HorizontalOptions = LayoutOptions.Start };
            //VisualStateManager.SetVisualStateGroups(rbStateManaged, groupList);

            //var stateManagedContainer = new ValueViewContainer<RadioButton>(Test.RadioButton.ButtonSource, rbStateManaged, "IsChecked", value => value.ToString());

            Add(borderButtonContainer);
            Add(borderRadiusContainer);
            Add(borderWidthContainer);
            Add(clickedContainer);
            Add(pressedContainer);
            Add(commandContainer);
            Add(fontContainer);
            Add(textContainer);
            Add(textColorContainer);
            Add(paddingContainer);
            Add(isCheckedContainer);
            //Add(stateManagedContainer);
        }
Exemplo n.º 9
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);
        }