Esempio n. 1
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

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

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

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

            Add(aspectFillContainer);
            Add(aspectFitContainer);
            Add(fillContainer);
            Add(isLoadingContainer);
            Add(isOpaqueContainer);
            Add(sourceContainer);
        }
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);
            var itemsContainer = new ViewContainer <Picker>(Test.Picker.Items, new Picker());

            itemsContainer.View.Items.Add("Item 1");
            itemsContainer.View.Items.Add("Item 2");
            itemsContainer.View.Items.Add("Item 3");

            var selectedIndexContainer = new ViewContainer <Picker>(Test.Picker.SelectedIndex, new Picker());

            selectedIndexContainer.View.Items.Add("Item 1");
            selectedIndexContainer.View.Items.Add("Item 2");
            selectedIndexContainer.View.Items.Add("Item 3");
            selectedIndexContainer.View.SelectedIndex = 2;

            var titleContainer = new ViewContainer <Picker>(Test.Picker.Title, new Picker());

            titleContainer.View.Title = "Title";

            var textColorContainer = new ViewContainer <Picker>(Test.Picker.TextColor, new Picker());

            textColorContainer.View.Items.Add("Item 1");
            textColorContainer.View.Items.Add("Item 2");
            textColorContainer.View.Items.Add("Item 3");

            Add(itemsContainer);
            Add(selectedIndexContainer);
            Add(titleContainer);
            Add(textColorContainer);
        }
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

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

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

            var sourceContainer = new ViewContainer <Image> (Test.Image.Source, new Image {
                Source = "http://sethrosetter.com/images/projects/bezierdraw/bezierdraw_5.jpg"
            });

            Add(aspectFillContainer);
            Add(aspectFitContainer);
            Add(fillContainer);
            Add(isLoadingContainer);
            Add(isOpaqueContainer);
            Add(sourceContainer);
        }
Esempio n. 4
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 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
            });

            Add(completedContainer);
            Add(textContainer);
            Add(textChangedContainer);
            Add(textFontAttributesContainer);
            Add(textFamilyContainer1);
            Add(textFamilyContainer2);
            Add(textFontSizeContainer);
            Add(textFontSizeDefaultContainer);
            Add(textFontSizeLargeContainer);
            Add(textColorContainer);
            Add(textColorDisabledContainer);
        }
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var colorContainer = new ViewContainer <BoxView> (Test.BoxView.Color, new BoxView {
                Color = Color.Pink
            });

            Add(colorContainer);
        }
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var progressContainer = new ViewContainer <ProgressBar> (Test.ProgressBar.Progress, new ProgressBar {
                Progress = 0.5
            });

            Add(progressContainer);
        }
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);
            var formatContainer = new ViewContainer <TimePicker>(Test.TimePicker.Format, new TimePicker {
                Format = "HH-mm-ss"
            });
            var timeContainer = new ViewContainer <TimePicker>(Test.TimePicker.Time,
                                                               new TimePicker {
                Time = new TimeSpan(14, 45, 50)
            });
            var textColorContainer = new ViewContainer <TimePicker>(Test.TimePicker.TextColor,
                                                                    new TimePicker {
                Time = new TimeSpan(14, 45, 50), TextColor = Color.Lime
            });
            var fontAttributesContainer = new ViewContainer <TimePicker>(Test.TimePicker.FontAttributes,
                                                                         new TimePicker {
                FontAttributes = FontAttributes.Bold
            });

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

            // 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 <TimePicker>(Test.TimePicker.FontSize,
                                                                   new TimePicker {
                FontSize = 24
            });

            Add(formatContainer);
            Add(timeContainer);
            Add(textColorContainer);
            Add(fontAttributesContainer);
            Add(fontFamilyContainer);
            Add(fontSizeContainer);
        }
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var refreshColorContainer = new ViewContainer <RefreshView>(Test.RefreshView.RefreshColor, new RefreshView
            {
                Content      = CreateContent(),
                RefreshColor = Color.Red
            });

            refreshColorContainer.View.SetBinding(RefreshView.CommandProperty, "RefreshCommand");
            refreshColorContainer.View.SetBinding(RefreshView.IsRefreshingProperty, "IsRefreshing");

            Add(refreshColorContainer);
        }
Esempio n. 9
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var colorContainer = new ViewContainer <BoxView> (Test.BoxView.Color, new BoxView {
                Color = Color.Pink
            });

            Add(colorContainer);

            var cornerRadiusContainer = new ViewContainer <BoxView>(Test.BoxView.CornerRadius, new BoxView {
                Color = Color.Red, CornerRadius = new CornerRadius(0, 12, 12, 0)
            });

            Add(cornerRadiusContainer);
        }
Esempio n. 10
0
        public KeyboardCoreGallery()
        {
            var keyboardTypes = new[] {
                Keyboard.Chat,
                Keyboard.Default,
                Keyboard.Email,
                Keyboard.Numeric,
                Keyboard.Plain,
                Keyboard.Telephone,
                Keyboard.Text,
                Keyboard.Url
            };

            var layout = new StackLayout();

            foreach (var keyboardType in keyboardTypes)
            {
                var viewContainer = new ViewContainer <Entry> (Test.InputView.Keyboard, new Entry {
                    Placeholder = keyboardType.ToString(), Keyboard = keyboardType
                });
                layout.Children.Add(viewContainer.ContainerLayout);
            }

            var customKeyboards = new [] {
                Tuple.Create("None", Keyboard.Create(KeyboardFlags.None)),
                Tuple.Create("Suggestions", Keyboard.Create(KeyboardFlags.Suggestions)),
                Tuple.Create("Spellcheck", Keyboard.Create(KeyboardFlags.Spellcheck)),
                Tuple.Create("SpellcheckSuggestions", Keyboard.Create(KeyboardFlags.Spellcheck | KeyboardFlags.Suggestions)),
                Tuple.Create("Capitalize", Keyboard.Create(KeyboardFlags.CapitalizeSentence)),
                Tuple.Create("CapitalizeSuggestions", Keyboard.Create(KeyboardFlags.CapitalizeSentence | KeyboardFlags.Suggestions)),
                Tuple.Create("CapitalizeSpellcheck", Keyboard.Create(KeyboardFlags.CapitalizeSentence | KeyboardFlags.Spellcheck)),
                Tuple.Create("CapitalizeSpellcheckSuggestions", Keyboard.Create(KeyboardFlags.CapitalizeSentence | KeyboardFlags.Spellcheck | KeyboardFlags.Suggestions)),
                Tuple.Create("All", Keyboard.Create(KeyboardFlags.All)),
            };

            foreach (var customKeyboard in customKeyboards)
            {
                var viewContainer = new ViewContainer <Entry> (Test.InputView.Keyboard, new Entry {
                    Placeholder = customKeyboard.Item1, Keyboard = customKeyboard.Item2
                });
                layout.Children.Add(viewContainer.ContainerLayout);
            }

            Content = new ScrollView {
                Content = layout
            };
        }
Esempio n. 11
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var urlWebViewSourceContainer = new ViewContainer <WebView> (Test.WebView.UrlWebViewSource,
                                                                         new WebView {
                Source = new UrlWebViewSource {
                    Url = "https://www.google.com/"
                },
                HeightRequest = 200
            }
                                                                         );

            const string html = "<html><div class=\"test\"><h2>I am raw html</h2></div></html>";
            var          htmlWebViewSourceContainer = new ViewContainer <WebView> (Test.WebView.HtmlWebViewSource,
                                                                                   new WebView {
                Source = new HtmlWebViewSource {
                    Html = html
                },
                HeightRequest = 200
            }
                                                                                   );

            var htmlFileWebSourceContainer = new ViewContainer <WebView> (Test.WebView.LoadHtml,
                                                                          new WebView {
                Source = new HtmlWebViewSource {
                    Html = @"<html>
<head>
<link rel=""stylesheet"" href=""default.css"">
</head>
<body>
<h1>Xamarin.Forms</h1>
<p>The CSS and image are loaded from local files!</p>
<img src='WebImages/XamarinLogo.png'/>
<p><a href=""local.html"">next page</a></p>
</body>
</html>"
                },
                HeightRequest = 200
            }
                                                                          );

            Add(urlWebViewSourceContainer);
            Add(htmlWebViewSourceContainer);
            Add(htmlFileWebSourceContainer);
        }
Esempio n. 12
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);
            var formatContainer = new ViewContainer <TimePicker>(Test.TimePicker.Format, new TimePicker {
                Format = "HH-mm-ss"
            });
            var timeContainer = new ViewContainer <TimePicker>(Test.TimePicker.Time,
                                                               new TimePicker {
                Time = new TimeSpan(14, 45, 50)
            });
            var textColorContainer = new ViewContainer <TimePicker>(Test.TimePicker.TextColor,
                                                                    new TimePicker {
                Time = new TimeSpan(14, 45, 50), TextColor = Color.Lime
            });

            Add(formatContainer);
            Add(timeContainer);
            Add(textColorContainer);
        }
Esempio n. 13
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var colorContainer = new ViewContainer <ActivityIndicator> (Test.ActivityIndicator.Color, new ActivityIndicator {
                Color     = Color.Lime,
                IsRunning = true
            });

            var isRunningContainer = new StateViewContainer <ActivityIndicator> (Test.ActivityIndicator.IsRunning, new ActivityIndicator {
                IsRunning = true
            });

            isRunningContainer.StateChangeButton.Clicked += (sender, args) => {
                isRunningContainer.View.IsRunning = !isRunningContainer.View.IsRunning;
            };

            Add(colorContainer);
            Add(isRunningContainer);
        }
Esempio n. 14
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var tableSectionContainer = new ViewContainer <TableView>(Test.TableView.TableSection, new TableView());
            var section = new TableSection("Test")
            {
                TextColor = Color.Red
            };

            section.Add(new TextCell {
                Text = "Worked!"
            });

            var section1 = new TableSection("Testing")
            {
                TextColor = Color.Green
            };

            section1.Add(new TextCell {
                Text = "Workeding!"
            });

            var section2 = new TableSection("Test old")
            {
                new TextCell {
                    Text = "Worked old!"
                }
            };

            tableSectionContainer.View.Root.Add(section);
            tableSectionContainer.View.Root.Add(section1);
            tableSectionContainer.View.Root.Add(section2);

            Add(tableSectionContainer);
        }
Esempio n. 15
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
            });

            Add(dateContainer);
            Add(dateSelectedContainer);
            Add(formatDateContainer);
            Add(minimumDateContainer);
            Add(maximumDateContainer);
            Add(textColorContainer);
        }
Esempio n. 16
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var urlWebViewSourceContainer = new ViewContainer <WebView> (Test.WebView.UrlWebViewSource,
                                                                         new WebView {
                Source = new UrlWebViewSource {
                    Url = "https://www.google.com/"
                },
                HeightRequest = 200
            }
                                                                         );

            const string html = "<html><div class=\"test\"><h2>I am raw html</h2></div></html>";
            var          htmlWebViewSourceContainer = new ViewContainer <WebView> (Test.WebView.HtmlWebViewSource,
                                                                                   new WebView {
                Source = new HtmlWebViewSource {
                    Html = html
                },
                HeightRequest = 200
            }
                                                                                   );

            var htmlFileWebSourceContainer = new ViewContainer <WebView> (Test.WebView.LoadHtml,
                                                                          new WebView {
                Source = new HtmlWebViewSource {
                    Html = @"<html>
<head>
<link rel=""stylesheet"" href=""default.css"">
</head>
<body>
<h1>Xamarin.Forms</h1>
<p>The CSS and image are loaded from local files!</p>
<img src='WebImages/XamarinLogo.png'/>
<p><a href=""local.html"">next page</a></p>
</body>
</html>"
                },
                HeightRequest = 200
            }
                                                                          );

            // NOTE: Currently the ability to programmatically enable/disable mixed content only exists on Android
            if (Device.RuntimePlatform == Device.Android)
            {
                var mixedContentTestPage = "https://mixed-content-test.appspot.com/";

                var mixedContentDisallowedWebView = new WebView()
                {
                    HeightRequest = 1000
                };
                mixedContentDisallowedWebView.On <Android>().SetMixedContentMode(MixedContentHandling.NeverAllow);
                mixedContentDisallowedWebView.Source = new UrlWebViewSource
                {
                    Url = mixedContentTestPage
                };

                var mixedContentAllowedWebView = new WebView()
                {
                    HeightRequest = 1000
                };
                mixedContentAllowedWebView.On <Android>().SetMixedContentMode(MixedContentHandling.AlwaysAllow);
                mixedContentAllowedWebView.Source = new UrlWebViewSource
                {
                    Url = mixedContentTestPage
                };

                var mixedContentDisallowedContainer = new ViewContainer <WebView>(Test.WebView.MixedContentDisallowed,
                                                                                  mixedContentDisallowedWebView);
                var mixedContentAllowedContainer = new ViewContainer <WebView>(Test.WebView.MixedContentAllowed,
                                                                               mixedContentAllowedWebView);

                Add(mixedContentDisallowedContainer);
                Add(mixedContentAllowedContainer);
            }


            var jsAlertWebView = new WebView
            {
                Source = new HtmlWebViewSource
                {
                    Html = @"<html>
<head>
<link rel=""stylesheet"" href=""default.css"">
</head>
<body>
<button onclick=""window.alert('foo');"">Click</button>
</body>
</html>"
                },
                HeightRequest = 200
            };

            jsAlertWebView.On <Windows>().SetIsJavaScriptAlertEnabled(true);

            var javascriptAlertWebSourceContainer = new ViewContainer <WebView>(Test.WebView.JavaScriptAlert,
                                                                                jsAlertWebView
                                                                                );

            var evaluateJsWebView = new WebView
            {
                Source = new UrlWebViewSource {
                    Url = "https://www.google.com/"
                },
                HeightRequest = 50
            };
            var evaluateJsWebViewSourceContainer = new ViewContainer <WebView>(Test.WebView.EvaluateJavaScript,
                                                                               evaluateJsWebView
                                                                               );

            var resultsLabel = new Label();
            var execButton   = new Button();

            execButton.Text    = "Evaluate Javascript";
            execButton.Command = new Command(async() => resultsLabel.Text = await evaluateJsWebView.EvaluateJavaScriptAsync(
                                                 "var test = function(){ return 'This string came from Javascript!'; }; test();"));

            evaluateJsWebViewSourceContainer.ContainerLayout.Children.Add(resultsLabel);
            evaluateJsWebViewSourceContainer.ContainerLayout.Children.Add(execButton);


            Add(urlWebViewSourceContainer);
            Add(htmlWebViewSourceContainer);
            Add(htmlFileWebSourceContainer);
            Add(javascriptAlertWebSourceContainer);
            Add(evaluateJsWebViewSourceContainer);
        }
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

#pragma warning disable 618
            var namedSizeMediumBoldContainer = new ViewContainer <Label> (Test.Label.FontAttibutesBold, new Label {
                Text = "Medium Bold Font", Font = Font.SystemFontOfSize(NamedSize.Medium, FontAttributes.Bold)
            });
#pragma warning restore 618

#pragma warning disable 618
            var namedSizeMediumItalicContainer = new ViewContainer <Label> (Test.Label.FontAttributesItalic, new Label {
                Text = "Medium Italic Font", Font = Font.SystemFontOfSize(NamedSize.Medium, FontAttributes.Italic)
            });
#pragma warning restore 618

#pragma warning disable 618
            var namedSizeLargeContainer = new ViewContainer <Label> (Test.Label.FontNamedSizeLarge, new Label {
                Text = "Large Font", Font = Font.SystemFontOfSize(NamedSize.Large)
            });
#pragma warning restore 618

#pragma warning disable 618
            var namedSizeMediumContainer = new ViewContainer <Label> (Test.Label.FontNamedSizeMedium, new Label {
                Text = "Medium Font", Font = Font.SystemFontOfSize(NamedSize.Medium)
            });
#pragma warning restore 618

#pragma warning disable 618
            var namedSizeMicroContainer = new ViewContainer <Label> (Test.Label.FontNamedSizeMicro, new Label {
                Text = "Micro Font", Font = Font.SystemFontOfSize(NamedSize.Micro)
            });
#pragma warning restore 618

#pragma warning disable 618
            var namedSizeSmallContainer = new ViewContainer <Label> (Test.Label.FontNamedSizeSmall, new Label {
                Text = "Small Font", Font = Font.SystemFontOfSize(NamedSize.Small)
            });
#pragma warning restore 618

            var formattedString = new FormattedString();
            formattedString.Spans.Add(new Span {
                BackgroundColor = Color.Red, ForegroundColor = Color.Olive, Text = "Span 1 "
            });
            formattedString.Spans.Add(new Span {
                BackgroundColor = Color.Black, ForegroundColor = Color.White, Text = "Span 2 "
            });
            formattedString.Spans.Add(new Span {
                BackgroundColor = Color.Pink, ForegroundColor = Color.Purple, Text = "Span 3"
            });

            var formattedTextContainer = new ViewContainer <Label> (Test.Label.FormattedText, new Label {
                FormattedText = formattedString
            });

            const string longText = "Lorem ipsum dolor sit amet, cu mei malis petentium, dolor tempor delicata no qui, eos ex vitae utinam vituperata. Utroque habemus philosophia ut mei, doctus placerat eam cu. An inermis scaevola pro, quo legimus deleniti ei, equidem docendi urbanitas ea eum. Saepe doctus ut pri. Nec ex wisi dolorem. Duo dolor vituperatoribus ea. Id purto instructior per. Nec partem accusamus ne. Qui ad saepe accumsan appellantur, duis omnesque has et, vim nihil nemore scaevola ne. Ei populo appetere recteque cum, meliore splendide appellantur vix id.";
            var          lineBreakModeCharacterWrapContainer = new ViewContainer <Label> (Test.Label.LineBreakModeCharacterWrap, new Label {
                Text = longText, LineBreakMode = LineBreakMode.CharacterWrap
            });
            var lineBreakModeHeadTruncationContainer = new ViewContainer <Label> (Test.Label.LineBreakModeHeadTruncation, new Label {
                Text = longText, LineBreakMode = LineBreakMode.HeadTruncation
            });
            var lineBreakModeMiddleTruncationContainer = new ViewContainer <Label> (Test.Label.LineBreakModeMiddleTruncation, new Label {
                Text = longText, LineBreakMode = LineBreakMode.MiddleTruncation
            });
            var lineBreakModeNoWrapContainer = new ViewContainer <Label> (Test.Label.LineBreakModeNoWrap, new Label {
                Text = longText, LineBreakMode = LineBreakMode.NoWrap
            });
            var lineBreakModeTailTruncationContainer = new ViewContainer <Label> (Test.Label.LineBreakModeTailTruncation, new Label {
                Text = longText, LineBreakMode = LineBreakMode.TailTruncation
            });
            var lineBreakModeWordWrapContainer = new ViewContainer <Label> (Test.Label.LineBreakModeWordWrap, new Label {
                Text = longText, LineBreakMode = LineBreakMode.WordWrap
            });

            var textContainer = new ViewContainer <Label> (Test.Label.Text, new Label {
                Text = "I should have text"
            });
            var textColorContainer = new ViewContainer <Label> (Test.Label.TextColor, new Label {
                Text = "I should have lime text", TextColor = Color.Lime
            });

            const int alignmentTestsHeightRequest = 100;
            const int alignmentTestsWidthRequest  = 100;

            var xAlignCenterContainer = new ViewContainer <Label> (Test.Label.HorizontalTextAlignmentCenter,
                                                                   new Label {
                Text = "HorizontalTextAlignment Center",
                HorizontalTextAlignment = TextAlignment.Center,
                HeightRequest           = alignmentTestsHeightRequest,
                WidthRequest            = alignmentTestsWidthRequest
            }
                                                                   );

            var xAlignEndContainer = new ViewContainer <Label> (Test.Label.HorizontalTextAlignmentEnd,
                                                                new Label {
                Text = "HorizontalTextAlignment End",
                HorizontalTextAlignment = TextAlignment.End,
                HeightRequest           = alignmentTestsHeightRequest,
                WidthRequest            = alignmentTestsWidthRequest
            }
                                                                );

            var xAlignStartContainer = new ViewContainer <Label> (Test.Label.HorizontalTextAlignmentStart,
                                                                  new Label {
                Text = "HorizontalTextAlignment Start",
                HorizontalTextAlignment = TextAlignment.Start,
                HeightRequest           = alignmentTestsHeightRequest,
                WidthRequest            = alignmentTestsWidthRequest
            }
                                                                  );

            var yAlignCenterContainer = new ViewContainer <Label> (Test.Label.VerticalTextAlignmentCenter,
                                                                   new Label {
                Text = "VerticalTextAlignment Start",
                VerticalTextAlignment = TextAlignment.Center,
                HeightRequest         = alignmentTestsHeightRequest,
                WidthRequest          = alignmentTestsWidthRequest
            }
                                                                   );

            var yAlignEndContainer = new ViewContainer <Label> (Test.Label.VerticalTextAlignmentEnd,
                                                                new Label {
                Text = "VerticalTextAlignment End",
                VerticalTextAlignment = TextAlignment.End,
                HeightRequest         = alignmentTestsHeightRequest,
                WidthRequest          = alignmentTestsWidthRequest
            }
                                                                );

            var yAlignStartContainer = new ViewContainer <Label> (Test.Label.VerticalTextAlignmentStart,
                                                                  new Label {
                Text = "VerticalTextAlignment Start",
                VerticalTextAlignment = TextAlignment.Start,
                HeightRequest         = alignmentTestsHeightRequest,
                WidthRequest          = alignmentTestsWidthRequest
            }
                                                                  );

            var styleTitleContainer = new ViewContainer <Label> (Test.Device.Styles,
                                                                 new Label {
                Text  = "Device.Styles.TitleStyle",
                Style = Device.Styles.TitleStyle
            }
                                                                 );

            var styleSubtitleContainer = new ViewContainer <Label> (Test.Device.Styles,
                                                                    new Label {
                Text  = "Device.Styles.SubtitleStyle",
                Style = Device.Styles.SubtitleStyle
            }
                                                                    );

            var styleBodyContainer = new ViewContainer <Label> (Test.Device.Styles,
                                                                new Label {
                Text  = "Device.Styles.BodyStyle",
                Style = Device.Styles.BodyStyle
            }
                                                                );

            var styleCaptionContainer = new ViewContainer <Label> (Test.Device.Styles,
                                                                   new Label {
                Text  = "Device.Styles.CaptionStyle",
                Style = Device.Styles.CaptionStyle,
            }
                                                                   );

            Add(namedSizeMediumBoldContainer);
            Add(namedSizeMediumItalicContainer);
            Add(namedSizeLargeContainer);
            Add(namedSizeMediumContainer);
            Add(namedSizeMicroContainer);
            Add(namedSizeSmallContainer);
            Add(formattedTextContainer);
            Add(lineBreakModeCharacterWrapContainer);
            Add(lineBreakModeHeadTruncationContainer);
            Add(lineBreakModeMiddleTruncationContainer);
            Add(lineBreakModeNoWrapContainer);
            Add(lineBreakModeTailTruncationContainer);
            Add(lineBreakModeWordWrapContainer);
            Add(textContainer);
            Add(textColorContainer);
            Add(xAlignCenterContainer);
            Add(xAlignEndContainer);
            Add(xAlignStartContainer);
            Add(yAlignCenterContainer);
            Add(yAlignEndContainer);
            Add(yAlignStartContainer);
            Add(styleTitleContainer);
            Add(styleSubtitleContainer);
            Add(styleBodyContainer);
            Add(styleCaptionContainer);
        }
Esempio n. 18
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);
        }
Esempio n. 19
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var viewModel = new ListViewViewModel();

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

            InitializeElement(groupDisplayBindingContainer.View);
            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());

            InitializeElement(groupHeaderTemplateContainer.View);
            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());

            InitializeElement(groupShortNameContainer.View);
            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;
        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 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",
                Image = 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
            }
                                                                 );

            Add(borderButtonContainer);
            Add(borderRadiusContainer);
            Add(borderWidthContainer);
            Add(clickedContainer);
            Add(commandContainer);
            Add(fontContainer);
            Add(imageContainer);
            Add(textContainer);
            Add(textColorContainer);
            //stackLayout.Children.Add (textColorContainer);
        }
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var viewModel = new ListViewViewModel();

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

            InitializeElement(groupDisplayBindingContainer.View);
            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());

            InitializeElement(groupHeaderTemplateContainer.View);
            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());

            InitializeElement(groupShortNameContainer.View);
            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);
        }
        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 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 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
            });

            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(textColorContainer);
            Add(placeholderColorContainer);
        }
        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);
        }
 protected void Add(ViewContainer <T> viewContainer)
 {
     _viewContainers.Add(viewContainer);
     _picker.Items.Add(viewContainer.TitleLabel.Text);
 }
        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 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.Entry.MaxLength, new Entry {
                MaxLength = 3
            });

            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);

            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(textFontAttributesContainer);
            Add(textFamilyContainer1);
            Add(textFamilyContainer2);
            Add(textFontSizeContainer);
            Add(textFontSizeDefaultContainer);
            Add(textFontSizeLargeContainer);
            Add(placeholderColorContainer);
            Add(textColorDisabledContainer);
            Add(placeholderColorDisabledContainer);
            Add(passwordColorContainer);
            Add(maxLengthContainer);
            Add(isPasswordInputScopeContainer);
        }
Esempio n. 26
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

#pragma warning disable 618
            var namedSizeMediumBoldContainer = new ViewContainer <Label>(Test.Label.FontAttibutesBold, new Label {
                Text = "Medium Bold Font", Font = Font.SystemFontOfSize(NamedSize.Medium, FontAttributes.Bold)
            });
#pragma warning restore 618

#pragma warning disable 618
            var namedSizeMediumItalicContainer = new ViewContainer <Label>(Test.Label.FontAttributesItalic, new Label {
                Text = "Medium Italic Font", Font = Font.SystemFontOfSize(NamedSize.Medium, FontAttributes.Italic)
            });
#pragma warning restore 618

#pragma warning disable 618
            var namedSizeMediumUnderlineContainer = new ViewContainer <Label>(Test.Label.TextDecorationUnderline, new Label {
                Text = "Medium Underlined Font", Font = Font.SystemFontOfSize(NamedSize.Medium), TextDecorations = TextDecorations.Underline
            });
#pragma warning restore 618

#pragma warning disable 618
            var namedSizeMediumStrikeContainer = new ViewContainer <Label>(Test.Label.TextDecorationStrike, new Label {
                Text = "Medium StrikeThrough Font", Font = Font.SystemFontOfSize(NamedSize.Medium), TextDecorations = TextDecorations.Strikethrough
            });
#pragma warning restore 618

#pragma warning disable 618
            var namedSizeLargeContainer = new ViewContainer <Label>(Test.Label.FontNamedSizeLarge, new Label {
                Text = "Large Font", Font = Font.SystemFontOfSize(NamedSize.Large)
            });
#pragma warning restore 618

#pragma warning disable 618
            var namedSizeMediumContainer = new ViewContainer <Label>(Test.Label.FontNamedSizeMedium, new Label {
                Text = "Medium Font", Font = Font.SystemFontOfSize(NamedSize.Medium)
            });
#pragma warning restore 618

#pragma warning disable 618
            var namedSizeMicroContainer = new ViewContainer <Label>(Test.Label.FontNamedSizeMicro, new Label {
                Text = "Micro Font", Font = Font.SystemFontOfSize(NamedSize.Micro)
            });
#pragma warning restore 618

#pragma warning disable 618
            var namedSizeSmallContainer = new ViewContainer <Label>(Test.Label.FontNamedSizeSmall, new Label {
                Text = "Small Font", Font = Font.SystemFontOfSize(NamedSize.Small)
            });
#pragma warning restore 618

            var formattedString = new FormattedString();
            formattedString.Spans.Add(new Span {
                BackgroundColor = Color.Red, TextColor = Color.Olive, Text = "Span 1 "
            });

            Span span = new Span {
                BackgroundColor = Color.Black, TextColor = Color.White, Text = "Span 2 (tap me) "
            };
            span.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => DisplayAlert("Congratulations!", "This is a tapped span", "ok"))
            });
            formattedString.Spans.Add(span);

            formattedString.Spans.Add(new Span {
                BackgroundColor = Color.Pink, TextColor = Color.Purple, Text = "Span 3"
            });

            var formattedTextContainer = new ViewContainer <Label>(Test.Label.FormattedText, new Label {
                FormattedText = formattedString
            });

            const string longText = "Lorem ipsum dolor sit amet, cu mei malis petentium, dolor tempor delicata no qui, eos ex vitae utinam vituperata. Utroque habemus philosophia ut mei, doctus placerat eam cu. An inermis scaevola pro, quo legimus deleniti ei, equidem docendi urbanitas ea eum. Saepe doctus ut pri. Nec ex wisi dolorem. Duo dolor vituperatoribus ea. Id purto instructior per. Nec partem accusamus ne. Qui ad saepe accumsan appellantur, duis omnesque has et, vim nihil nemore scaevola ne. Ei populo appetere recteque xum, meliore splendide appellantur vix id.";
            var          lineBreakModeCharacterWrapContainer = new ViewContainer <Label>(Test.Label.LineBreakModeCharacterWrap, new Label {
                Text = longText, LineBreakMode = LineBreakMode.CharacterWrap
            });
            var lineBreakModeHeadTruncationContainer = new ViewContainer <Label>(Test.Label.LineBreakModeHeadTruncation, new Label {
                Text = longText, LineBreakMode = LineBreakMode.HeadTruncation
            });
            var lineBreakModeMiddleTruncationContainer = new ViewContainer <Label>(Test.Label.LineBreakModeMiddleTruncation, new Label {
                Text = longText, LineBreakMode = LineBreakMode.MiddleTruncation
            });
            var lineBreakModeNoWrapContainer = new ViewContainer <Label>(Test.Label.LineBreakModeNoWrap, new Label {
                Text = longText, LineBreakMode = LineBreakMode.NoWrap
            });
            var lineBreakModeTailTruncationContainer = new ViewContainer <Label>(Test.Label.LineBreakModeTailTruncation, new Label {
                Text = longText, LineBreakMode = LineBreakMode.TailTruncation
            });
            var lineBreakModeWordWrapContainer = new ViewContainer <Label>(Test.Label.LineBreakModeWordWrap, new Label {
                Text = longText, LineBreakMode = LineBreakMode.WordWrap
            });

            var textContainer = new ViewContainer <Label>(Test.Label.Text, new Label {
                Text = "I should have text"
            });
            var textColorContainer = new ViewContainer <Label>(Test.Label.TextColor, new Label {
                Text = "I should have lime text", TextColor = Color.Lime
            });

            const int alignmentTestsHeightRequest = 100;
            const int alignmentTestsWidthRequest  = 100;

            var xAlignCenterContainer = new ViewContainer <Label>(Test.Label.HorizontalTextAlignmentCenter,
                                                                  new Label
            {
                Text = "HorizontalTextAlignment Center",
                HorizontalTextAlignment = TextAlignment.Center,
                HeightRequest           = alignmentTestsHeightRequest,
                WidthRequest            = alignmentTestsWidthRequest
            }
                                                                  );

            var xAlignEndContainer = new ViewContainer <Label>(Test.Label.HorizontalTextAlignmentEnd,
                                                               new Label
            {
                Text = "HorizontalTextAlignment End",
                HorizontalTextAlignment = TextAlignment.End,
                HeightRequest           = alignmentTestsHeightRequest,
                WidthRequest            = alignmentTestsWidthRequest
            }
                                                               );

            var xAlignStartContainer = new ViewContainer <Label>(Test.Label.HorizontalTextAlignmentStart,
                                                                 new Label
            {
                Text = "HorizontalTextAlignment Start",
                HorizontalTextAlignment = TextAlignment.Start,
                HeightRequest           = alignmentTestsHeightRequest,
                WidthRequest            = alignmentTestsWidthRequest
            }
                                                                 );

            var yAlignCenterContainer = new ViewContainer <Label>(Test.Label.VerticalTextAlignmentCenter,
                                                                  new Label
            {
                Text = "VerticalTextAlignment Start",
                VerticalTextAlignment = TextAlignment.Center,
                HeightRequest         = alignmentTestsHeightRequest,
                WidthRequest          = alignmentTestsWidthRequest,
                BackgroundColor       = Color.Pink
            }
                                                                  );

            var yAlignEndContainer = new ViewContainer <Label>(Test.Label.VerticalTextAlignmentEnd,
                                                               new Label
            {
                Text = "VerticalTextAlignment End",
                VerticalTextAlignment = TextAlignment.End,
                HeightRequest         = alignmentTestsHeightRequest,
                WidthRequest          = alignmentTestsWidthRequest,
                BackgroundColor       = Color.Pink
            }
                                                               );

            var yAlignStartContainer = new ViewContainer <Label>(Test.Label.VerticalTextAlignmentStart,
                                                                 new Label
            {
                Text = "VerticalTextAlignment Start",
                VerticalTextAlignment = TextAlignment.Start,
                HeightRequest         = alignmentTestsHeightRequest,
                WidthRequest          = alignmentTestsWidthRequest,
                BackgroundColor       = Color.Pink
            }
                                                                 );

            var styleTitleContainer = new ViewContainer <Label>(Test.Device.Styles,
                                                                new Label
            {
                Text  = "Device.Styles.TitleStyle",
                Style = Device.Styles.TitleStyle
            }
                                                                );

            var styleSubtitleContainer = new ViewContainer <Label>(Test.Device.Styles,
                                                                   new Label
            {
                Text  = "Device.Styles.SubtitleStyle",
                Style = Device.Styles.SubtitleStyle
            }
                                                                   );

            var styleBodyContainer = new ViewContainer <Label>(Test.Device.Styles,
                                                               new Label
            {
                Text  = "Device.Styles.BodyStyle",
                Style = Device.Styles.BodyStyle
            }
                                                               );

            var styleCaptionContainer = new ViewContainer <Label>(Test.Device.Styles,
                                                                  new Label
            {
                Text  = "Device.Styles.CaptionStyle",
                Style = Device.Styles.CaptionStyle,
            }
                                                                  );

            var maxlinesContainer = new ViewContainer <Label>(Test.Label.MaxLines,
                                                              new Label
            {
                Text     = longText,
                MaxLines = 2
            }
                                                              );

            var maxlinesCharWrapContainer = new ViewContainer <Label>(Test.Label.MaxLines,
                                                                      new Label
            {
                Text          = longText,
                MaxLines      = 2,
                LineBreakMode = LineBreakMode.CharacterWrap
            }
                                                                      );

            var maxlinesHeadTruncContainer = new ViewContainer <Label>(Test.Label.MaxLines,
                                                                       new Label
            {
                Text          = longText,
                MaxLines      = 2,
                LineBreakMode = LineBreakMode.HeadTruncation
            }
                                                                       );

            var maxlinesMiddleTruncContainer = new ViewContainer <Label>(Test.Label.MaxLines,
                                                                         new Label
            {
                Text          = longText,
                MaxLines      = 2,
                LineBreakMode = LineBreakMode.MiddleTruncation
            }
                                                                         );

            var maxlinesNoWrapContainer = new ViewContainer <Label>(Test.Label.MaxLines,
                                                                    new Label
            {
                Text          = longText,
                MaxLines      = 2,
                LineBreakMode = LineBreakMode.NoWrap
            }
                                                                    );

            var maxlinesTailTruncContainer = new ViewContainer <Label>(Test.Label.MaxLines,
                                                                       new Label
            {
                Text          = longText,
                MaxLines      = 2,
                LineBreakMode = LineBreakMode.TailTruncation
            }
                                                                       );

            var maxlinesWordWrapContainer = new ViewContainer <Label>(Test.Label.MaxLines,
                                                                      new Label
            {
                Text          = longText,
                MaxLines      = 2,
                LineBreakMode = LineBreakMode.WordWrap
            }
                                                                      );

            var formattedString2 = new FormattedString();
            formattedString2.Spans.Add(new Span {
                BackgroundColor = Color.Red, TextColor = Color.Olive, Text = "Span 1 "
            });
            var span2 = new Span {
                BackgroundColor = Color.Black, TextColor = Color.White, Text = "Span 2 (tap me) "
            };
            span2.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => DisplayAlert("Congratulations!", "This is a tapped span", "ok"))
            });
            formattedString2.Spans.Add(span2);
            formattedString2.Spans.Add(new Span {
                BackgroundColor = Color.Pink, TextColor = Color.Purple, Text = "Span 3"
            });

            var paddingContainer = new ViewContainer <Label>(Test.Label.Padding,
                                                             new Label
            {
                FormattedText   = formattedString2,
                BackgroundColor = Color.Yellow,
                Padding         = new Thickness(40, 20)
            }
                                                             );

            var htmlLabelContainer = new ViewContainer <Label>(Test.Label.HtmlTextType,
                                                               new Label
            {
                Text     = "<h1>Hello world!</h1>",
                TextType = TextType.Html
            });

            var htmlLabelMultipleLinesContainer = new ViewContainer <Label>(Test.Label.HtmlTextTypeMultipleLines,
                                                                            new Label
            {
                Text     = "<h1>Hello world!</h1><p>Lorem <strong>ipsum</strong> bla di bla <i>blabla</i> blablabl&nbsp;ablabla & blablablablabl ablabl ablablabl ablablabla blablablablablablab lablablabla blablab lablablabla blablabl ablablablab lablabla blab lablablabla blablab lablabla blablablablab lablabla blablab lablablabl ablablabla blablablablablabla blablabla</p>",
                TextType = TextType.Html,
                MaxLines = 3
            });

            var toggleLabel = new Label
            {
                TextType = TextType.Html,
                Text     = "<h1 style=\"color: red;\">Hello world!</h1><p>Lorem <strong>ipsum</strong></p>"
            };

            var htmlLabelProperties = new ViewContainer <Label>(Test.Label.HtmlTextLabelProperties, new Label
            {
                Text     = "<h1>End aligned. Green. ä</h1>",
                TextType = TextType.Html,
                HorizontalTextAlignment = TextAlignment.Center,
                TextColor = Color.Green,
            });

            var gestureRecognizer = new TapGestureRecognizer();

            gestureRecognizer.Tapped += (s, a) =>
            {
                toggleLabel.TextType = toggleLabel.TextType == TextType.Html ? TextType.Text : TextType.Html;
            };

            toggleLabel.GestureRecognizers.Add(gestureRecognizer);

            var toggleHtmlPlainTextLabelContainer = new ViewContainer <Label>(Test.Label.TextTypeToggle,
                                                                              toggleLabel);

            Add(namedSizeMediumBoldContainer);
            Add(namedSizeMediumItalicContainer);
            Add(namedSizeMediumUnderlineContainer);
            Add(namedSizeMediumStrikeContainer);
            Add(namedSizeLargeContainer);
            Add(namedSizeMediumContainer);
            Add(namedSizeMicroContainer);
            Add(namedSizeSmallContainer);
            Add(formattedTextContainer);
            Add(lineBreakModeCharacterWrapContainer);
            Add(lineBreakModeHeadTruncationContainer);
            Add(lineBreakModeMiddleTruncationContainer);
            Add(lineBreakModeNoWrapContainer);
            Add(lineBreakModeTailTruncationContainer);
            Add(lineBreakModeWordWrapContainer);
            Add(textContainer);
            Add(textColorContainer);
            Add(xAlignCenterContainer);
            Add(xAlignEndContainer);
            Add(xAlignStartContainer);
            Add(yAlignCenterContainer);
            Add(yAlignEndContainer);
            Add(yAlignStartContainer);
            Add(styleTitleContainer);
            Add(styleSubtitleContainer);
            Add(styleBodyContainer);
            Add(styleCaptionContainer);
            Add(maxlinesContainer);
            Add(maxlinesCharWrapContainer);
            Add(maxlinesHeadTruncContainer);
            Add(maxlinesMiddleTruncContainer);
            Add(maxlinesNoWrapContainer);
            Add(maxlinesTailTruncContainer);
            Add(maxlinesWordWrapContainer);
            Add(paddingContainer);
            Add(htmlLabelContainer);
            Add(htmlLabelMultipleLinesContainer);
            Add(htmlLabelProperties);
            Add(toggleHtmlPlainTextLabelContainer);
        }
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);

            var urlWebViewSourceContainer = new ViewContainer <WebView> (Test.WebView.UrlWebViewSource,
                                                                         new WebView {
                Source = new UrlWebViewSource {
                    Url = "https://www.google.com/"
                },
                HeightRequest = 200
            }
                                                                         );

            const string html = "<html><div class=\"test\"><h2>I am raw html</h2></div></html>";
            var          htmlWebViewSourceContainer = new ViewContainer <WebView> (Test.WebView.HtmlWebViewSource,
                                                                                   new WebView {
                Source = new HtmlWebViewSource {
                    Html = html
                },
                HeightRequest = 200
            }
                                                                                   );

            var htmlFileWebSourceContainer = new ViewContainer <WebView> (Test.WebView.LoadHtml,
                                                                          new WebView {
                Source = new HtmlWebViewSource {
                    Html = @"<html>
<head>
<link rel=""stylesheet"" href=""default.css"">
</head>
<body>
<h1>Xamarin.Forms</h1>
<p>The CSS and image are loaded from local files!</p>
<img src='WebImages/XamarinLogo.png'/>
<p><a href=""local.html"">next page</a></p>
</body>
</html>"
                },
                HeightRequest = 200
            }
                                                                          );

            var jsAlertWebView = new WebView
            {
                Source = new HtmlWebViewSource
                {
                    Html = @"<html>
<head>
<link rel=""stylesheet"" href=""default.css"">
</head>
<body>
<button onclick=""window.alert('foo');"">Click</button>
</body>
</html>"
                },
                HeightRequest = 200
            };

            jsAlertWebView.On <Windows>().SetIsJavaScriptAlertEnabled(true);

            var javascriptAlertWebSourceContainer = new ViewContainer <WebView>(Test.WebView.JavaScriptAlert,
                                                                                jsAlertWebView
                                                                                );

            Add(urlWebViewSourceContainer);
            Add(htmlWebViewSourceContainer);
            Add(htmlFileWebSourceContainer);
            Add(javascriptAlertWebSourceContainer);
        }
Esempio n. 28
0
        protected override void Build(StackLayout stackLayout)
        {
            base.Build(stackLayout);
            var itemsContainer = new ViewContainer <Picker>(Test.Picker.Items, new Picker());

            itemsContainer.View.Items.Add("Item 1");
            itemsContainer.View.Items.Add("Item 2");
            itemsContainer.View.Items.Add("Item 3");

            var selectedIndexContainer = new ViewContainer <Picker>(Test.Picker.SelectedIndex, new Picker());

            selectedIndexContainer.View.Items.Add("Item 1");
            selectedIndexContainer.View.Items.Add("Item 2");
            selectedIndexContainer.View.Items.Add("Item 3");
            selectedIndexContainer.View.SelectedIndex = 2;

            var titleContainer = new ViewContainer <Picker>(Test.Picker.Title, new Picker());

            titleContainer.View.Title = "Title";

            var titleColorContainer = new ViewContainer <Picker>(Test.Picker.TitleColor, new Picker());

            titleColorContainer.View.Title      = "Title Color";
            titleColorContainer.View.TitleColor = Color.Red;

            var buttonReset = new Button()
            {
                Text = "Reset color to default"
            };
            var buttonChange = new Button()
            {
                Text = "Change color"
            };

            buttonReset.Clicked  += (o, a) => titleColorContainer.View.ClearValue(Picker.TitleColorProperty);
            buttonChange.Clicked += (o, a) => titleColorContainer.View.TitleColor = Color.Green;

            titleColorContainer.ContainerLayout.Children.Add(buttonReset);
            titleColorContainer.ContainerLayout.Children.Add(buttonChange);

            var textColorContainer = new ViewContainer <Picker>(Test.Picker.TextColor, new Picker());

            textColorContainer.View.Items.Add("Item 1");
            textColorContainer.View.Items.Add("Item 2");
            textColorContainer.View.Items.Add("Item 3");

            var fontAttributesContainer = new ViewContainer <Picker>(Test.Picker.FontAttributes,
                                                                     new Picker {
                FontAttributes = FontAttributes.Bold
            });

            fontAttributesContainer.View.Items.Add("Item 1");
            fontAttributesContainer.View.Items.Add("Item 2");
            fontAttributesContainer.View.Items.Add("Item 3");

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

            // 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;
            }
            fontFamilyContainer.View.Items.Add("Item 1");
            fontFamilyContainer.View.Items.Add("Item 2");
            fontFamilyContainer.View.Items.Add("Item 3");

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

            fontSizeContainer.View.Items.Add("Item 1");
            fontSizeContainer.View.Items.Add("Item 2");
            fontSizeContainer.View.Items.Add("Item 3");

            Add(itemsContainer);
            Add(selectedIndexContainer);
            Add(titleContainer);
            Add(titleColorContainer);
            Add(textColorContainer);
            Add(fontAttributesContainer);
            Add(fontFamilyContainer);
            Add(fontSizeContainer);
        }
Esempio n. 29
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/master/Xamarin.Forms.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);
        }
        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);
        }