public UnconstrainedLabelAutoFitPage() { BackgroundColor = Color.Gray; Padding = 0; #region Editor var editor = new Editor { //Text = "Żorem ipsum dolor sit amet, consectetur adięiscing ełit", Text = text1, TextColor = Color.White, BackgroundColor = Color.Black, HeightRequest = 130, FontSize = 15, }; #endregion #region Xamarin Forms label var xfLabel = new Label { FontSize = 15, TextColor = Color.White, BackgroundColor = Color.Black, Text = editor.Text }; #endregion #region Forms9Patch Label var f9pLabel = new Forms9Patch.Label { //HeightRequest = 50, Lines = 3, FontSize = 15, TextColor = Color.White, AutoFit = Forms9Patch.AutoFit.None, BackgroundColor = Color.Black, Text = editor.Text }; #endregion #region Mode var modeSwitch = new Switch { IsToggled = false, HorizontalOptions = LayoutOptions.End, }; modeSwitch.Toggled += (sender, e) => { if (modeSwitch.IsToggled) { f9pLabel.HtmlText = editor.Text; } else { f9pLabel.Text = editor.Text; } }; #endregion #region Sync text between Editor and Labels editor.TextChanged += (sender, e) => { xfLabel.Text = editor.Text; f9pLabel.HtmlText = editor.Text; }; #endregion /* #region Frames for Labels * var frameForF9P = new Frame * { * HeightRequest = 100, * WidthRequest = 200, * Padding = 0, * Content = f9pLabel * }; * * var frameForXF = new Frame * { * HeightRequest = 100, * WidthRequest = 200, * Padding = 0, * Content = xfLabel * }; #endregion */ #region Font Size selection var fontSizeSlider = new Slider { Maximum = 104, Minimum = 4, Value = 15 }; var fontSizeLabel = new Label { Text = "Font Size: 15" }; fontSizeSlider.ValueChanged += (sender, e) => { fontSizeLabel.Text = "Font Size: " + fontSizeSlider.Value; f9pLabel.FontSize = fontSizeSlider.Value; if (!rendering) { rendering = true; xfLabel.FontSize = fontSizeSlider.Value; Device.StartTimer(TimeSpan.FromMilliseconds(50), () => { if (Math.Abs(xfLabel.FontSize - lastFontSize) > double.Epsilon * 5) { xfLabel.FontSize = lastFontSize; return(true); } rendering = false; return(false); }); } lastFontSize = fontSizeSlider.Value; }; var actualFontSizeLabel = new Label { Text = "Actual Font Size: 15" }; f9pLabel.PropertyChanged += (sender, e) => { if (e.PropertyName == Forms9Patch.Label.FittedFontSizeProperty.PropertyName) { actualFontSizeLabel.Text = "FittedFontSize: " + f9pLabel.FittedFontSize; } }; #endregion #region Lines selection var linesLabel = new Label { Text = "Lines: 3" }; var linesSlider = new Slider { Minimum = 0, Maximum = 8, Value = 3 }; linesSlider.ValueChanged += (sender, e) => { linesLabel.Text = "Lines: " + ((int)Math.Round(linesSlider.Value)); f9pLabel.Lines = ((int)Math.Round(linesSlider.Value)); }; #endregion #region AutoFit Selection var fitSelector = new Forms9Patch.SegmentedControl(); fitSelector.Segments.Add(new Forms9Patch.Segment { Text = "None", Command = new Command(x => { f9pLabel.AutoFit = Forms9Patch.AutoFit.None; }) }); var widthSegment = new Forms9Patch.Segment { Text = "Width", Command = new Command(x => { f9pLabel.AutoFit = Forms9Patch.AutoFit.Width; }), //IsEnabled = f9pLabel.HasImposedSize, BindingContext = f9pLabel, //IsEnabled = false }; //widthSegment.SetBinding(Forms9Patch.Segment.IsEnabledProperty, "HasImposedSize"); fitSelector.Segments.Add(widthSegment); var linesSegment = new Forms9Patch.Segment { Text = "Lines", Command = new Command(x => { f9pLabel.AutoFit = Forms9Patch.AutoFit.Lines; }), //IsEnabled = f9pLabel.HasImposedSize, BindingContext = f9pLabel }; //linesSegment.SetBinding(Forms9Patch.Segment.IsEnabledProperty, "HasImposedSize"); fitSelector.Segments.Add(linesSegment); fitSelector.SelectIndex(0); #endregion #region Alignment Selection var hzAlignmentSelector = new Forms9Patch.SegmentedControl(); var vtAlignmentSelector = new Forms9Patch.SegmentedControl(); hzAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "Start", Command = new Command(x => { f9pLabel.HorizontalTextAlignment = TextAlignment.Start; xfLabel.HorizontalTextAlignment = TextAlignment.Start; }) } ); hzAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "Center", Command = new Command(x => { f9pLabel.HorizontalTextAlignment = TextAlignment.Center; xfLabel.HorizontalTextAlignment = TextAlignment.Center; }) } ); hzAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "End", Command = new Command(x => { f9pLabel.HorizontalTextAlignment = TextAlignment.End; xfLabel.HorizontalTextAlignment = TextAlignment.End; }) } ); vtAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "Start", Command = new Command(x => { f9pLabel.VerticalTextAlignment = TextAlignment.Start; xfLabel.VerticalTextAlignment = TextAlignment.Start; }) } ); vtAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "Center", Command = new Command(x => { f9pLabel.VerticalTextAlignment = TextAlignment.Center; xfLabel.VerticalTextAlignment = TextAlignment.Center; }) } ); vtAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "End", Command = new Command(x => { f9pLabel.VerticalTextAlignment = TextAlignment.End; xfLabel.VerticalTextAlignment = TextAlignment.End; }) } ); hzAlignmentSelector.SelectIndex(0); vtAlignmentSelector.SelectIndex(0); #endregion #region BreakMode selection var breakModeSelector = new Forms9Patch.SegmentedControl(); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "NoWrap", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.NoWrap; xfLabel.LineBreakMode = LineBreakMode.NoWrap; }) } ); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "Char", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.CharacterWrap; xfLabel.LineBreakMode = LineBreakMode.CharacterWrap; }) } ); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "Word", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.WordWrap; xfLabel.LineBreakMode = LineBreakMode.WordWrap; }) } ); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "Head", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.HeadTruncation; xfLabel.LineBreakMode = LineBreakMode.HeadTruncation; }) } ); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "Mid", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.MiddleTruncation; xfLabel.LineBreakMode = LineBreakMode.MiddleTruncation; }) } ); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "Tail", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.TailTruncation; xfLabel.LineBreakMode = LineBreakMode.TailTruncation ; }) } ); breakModeSelector.SelectIndex(2); #endregion xfLabel.PropertyChanged += (sender, e) => { if (e.PropertyName == HeightProperty.PropertyName) { System.Diagnostics.Debug.WriteLine("xfLabel.Height=[" + xfLabel.Height + "]\n"); } }; #region FontSelection Picker fontPicker = new Picker { Title = "Default", //HeightRequest = 300, //VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.EndAndExpand, }; var fontFamilies = Forms9Patch.FontExtensions.LoadedFontFamilies(); foreach (var fontFamily in fontFamilies) { fontPicker.Items.Add(fontFamily); } fontPicker.SelectedIndexChanged += (sender, e) => { //string family = null; if (fontPicker.SelectedIndex > -1 && fontPicker.SelectedIndex < fontFamilies.Count) { f9pLabel.FontFamily = fontFamilies[fontPicker.SelectedIndex]; xfLabel.FontFamily = fontFamilies[fontPicker.SelectedIndex]; } }; #endregion Content = new ScrollView { Padding = 0, Content = new StackLayout { Padding = 20, Children = { new Label { Text = "Text:" }, editor, new StackLayout { Orientation = StackOrientation.Horizontal, Children = { new Label { Text = "HTML Formatted:", HorizontalOptions = LayoutOptions.StartAndExpand, }, modeSwitch }, }, new Label { Text = "Xamarin.Forms.Label:" }, xfLabel, new Label { Text = "Forms9Patch.Label:" }, f9pLabel, new StackLayout { Orientation = StackOrientation.Horizontal, Children = { new Label { Text = "Font Family:", HorizontalOptions = LayoutOptions.Start }, fontPicker } }, fontSizeLabel, fontSizeSlider, actualFontSizeLabel, new Label { Text = "AutoFit:" }, fitSelector, linesLabel, linesSlider, new Label { Text = "Horizontal Alignment:" }, hzAlignmentSelector, new Label { Text = "Vertical Alignment:" }, vtAlignmentSelector, new Label { Text = "Truncation Mode:" }, breakModeSelector, } } }; }
public ModalPopupTestPage() { BackgroundColor = Color.White; Padding = new Thickness(20, Device.OnPlatform(20, 0, 0), 20, 20); var shadowToggle = new Switch(); shadowToggle.SetBinding(Switch.IsToggledProperty, "HasShadow"); shadowToggle.BindingContext = this; var shadowInvertedToggle = new Switch(); shadowInvertedToggle.SetBinding(Switch.IsToggledProperty, "ShadowInverted"); shadowInvertedToggle.BindingContext = this; var cornerRadiusSlider = new Slider { Maximum = 40, Minimum = 0, HeightRequest = 20, }; cornerRadiusSlider.SetBinding(Slider.ValueProperty, "CornerRadius"); cornerRadiusSlider.BindingContext = this; var paddingSlider = new Slider { Maximum = 100, Minimum = 0, HeightRequest = 20, }; paddingSlider.SetBinding(Slider.ValueProperty, "PUDPadding"); paddingSlider.BindingContext = this; //var listener = new FormsOrientation.Listener (); var hidePopupButton = new Forms9Patch.MaterialButton { Text = "DONE", BackgroundColor = Color.Blue, DarkTheme = true, }; var showPopupButton = new Forms9Patch.MaterialButton { Text = "Show Modal popup", BackgroundColor = Color.Blue, DarkTheme = true, WidthRequest = 150, HorizontalOptions = LayoutOptions.Center, }; var cancelOnBackgroundTouchButton = new Forms9Patch.MaterialButton { Text = "Cancel on Background touch", ToggleBehavior = true, IsSelected = true }; cancelOnBackgroundTouchButton.SetBinding(Forms9Patch.MaterialButton.IsSelectedProperty, "CancelOnBackgroundTouch"); cancelOnBackgroundTouchButton.BindingContext = this; var blackSegment = new Forms9Patch.Segment { HtmlText = "<font color=\"#000000\">Black</font>" }; var redSegment = new Forms9Patch.Segment { HtmlText = "<font color=\"#FF0000\">Red</font>" }; var greenSegment = new Forms9Patch.Segment { HtmlText = "<font color=\"#00FF00\">Green</font>" }; var blueSegment = new Forms9Patch.Segment { HtmlText = "<font color=\"#0000FF\">Blue</font>" }; var overlayColorSelector = new Forms9Patch.MaterialSegmentedControl { Segments = { blackSegment, redSegment, greenSegment, blueSegment, }, BackgroundColor = Color.White }; var modal = new Forms9Patch.ModalPopup { Content = new StackLayout { Children = { new Label { Text = "Hello Modal popup!", TextColor = Color.Black, }, new Label { Text = "Padding:", FontSize = 10, }, paddingSlider, new Label { Text = "Corner Radius:", FontSize = 10, }, cornerRadiusSlider, hidePopupButton, new Label { Text = "PageOverlayColor:", FontSize = 10, }, overlayColorSelector }, //BackgroundColor = Color.FromRgb(100,100,100), //Padding = 20, }, OutlineRadius = 4, OutlineWidth = 1, OutlineColor = Color.Black, BackgroundColor = Color.Aqua, HasShadow = true, HeightRequest = 200, WidthRequest = 200, }; modal.SetBinding(Forms9Patch.ModalPopup.OutlineRadiusProperty, "CornerRadius"); modal.SetBinding(Forms9Patch.ModalPopup.OutlineWidthProperty, "OutlineWidth"); modal.SetBinding(Forms9Patch.ModalPopup.PaddingProperty, "PUPadding"); modal.SetBinding(Forms9Patch.ModalPopup.HasShadowProperty, "HasShadow"); modal.SetBinding(Forms9Patch.ModalPopup.ShadowInvertedProperty, "ShadowInverted"); modal.SetBinding(Forms9Patch.ModalPopup.CancelOnPageOverlayTouchProperty, "CancelOnBackgroundTouch"); modal.BindingContext = this; showPopupButton.Tapped += (sender, e) => { modal.IsVisible = true; }; hidePopupButton.Tapped += (sender, e) => { modal.IsVisible = false; System.Diagnostics.Debug.WriteLine("button " + showPopupButton.Text); }; blackSegment.Selected += (sender, e) => { modal.PageOverlayColor = Color.FromRgba(0, 0, 0, 128); }; redSegment.Selected += (sender, e) => { modal.PageOverlayColor = Color.FromRgba(255, 0, 0, 128); }; greenSegment.Selected += (sender, e) => { modal.PageOverlayColor = Color.FromRgba(0, 255, 0, 128); }; blueSegment.Selected += (sender, e) => { modal.PageOverlayColor = Color.FromRgba(0, 0, 255, 128); }; Detail = new ContentPage { BackgroundColor = Color.White, Title = "PopupTestPage - Detail", Content = new StackLayout { Children = { new Label { Text = "Hello ContentPage", TextColor = Color.Black, }, new StackLayout { Orientation = StackOrientation.Horizontal, Children = { new StackLayout { Children = { new Label { Text = "Has Shadow", FontSize = 10, }, shadowToggle, }, HorizontalOptions = LayoutOptions.StartAndExpand, }, new StackLayout { Children = { new Label { Text = "Inset Shadow", FontSize = 10, }, shadowInvertedToggle, }, HorizontalOptions = LayoutOptions.EndAndExpand, } } }, cancelOnBackgroundTouchButton, showPopupButton, }, Padding = 20, }, }; Master = new ContentPage { Title = "PopupTestPage - Master", Content = new Label { Text = "Master Page", }, BackgroundColor = Color.Gray, }; }
public ButtonCodePage() { _f9pButton.BackgroundImage = _f9pImage; Title = "StateButtonCodePage"; IsPresented = true; #region Local Elements hzOptionSegmentedControl.SelectIndex(3); hzOptionSegmentedControl.SegmentTapped += HzOptionSegmentedControl_SegmentTapped; vtOptionSegmentedControl.SelectIndex(3); vtOptionSegmentedControl.SegmentTapped += VtOptionSegmentedControl_SegmentTapped; var heightRequestSlider = new Slider(-1, 300, -1); heightRequestSlider.Effects.Add(new Forms9Patch.SliderStepSizeEffect(1)); heightRequestSlider.ValueChanged += HeightRequestSlider_ValueChanged; var fillSegmentedControl = new Forms9Patch.SegmentedControl { Segments = { //new Forms9Patch.Segment("NONE"), new Forms9Patch.Segment("TILE"), new Forms9Patch.Segment("ASPECTFILL"), new Forms9Patch.Segment("ASPECTFIT"), new Forms9Patch.Segment("FILL") } }; fillSegmentedControl.SelectIndex(3); fillSegmentedControl.SegmentTapped += FillSegmentedControl_SegmentTapped; Forms9Patch.SegmentedControl shapesSelector = new Forms9Patch.SegmentedControl { Segments = { new Forms9Patch.Segment { Text = Rectangle }, new Forms9Patch.Segment { Text = Square }, new Forms9Patch.Segment { Text = Circle }, new Forms9Patch.Segment { Text = Ellipse }, new Forms9Patch.Segment { Text = "OBROUND" } } }; shapesSelector.SelectIndex(0); shapesSelector.SegmentTapped += ShapesSelector_SegmentTapped; var outlineWidthSlider = new Xamarin.Forms.Slider { Minimum = 0, Maximum = 15, Value = 2 }; outlineWidthSlider.Effects.Add(new Forms9Patch.SliderStepSizeEffect(1.0 / Forms9Patch.Display.Scale)); outlineWidthSlider.ValueChanged += OutlineWidthSlider_ValueChanged; outlineRadiusSlider.Effects.Add(new Forms9Patch.SliderStepSizeEffect(1)); outlineRadiusSlider.ValueChanged += OutlineRadiusSlider_ValueChanged; var shapeAttributesSelector = new Forms9Patch.SegmentedControl { GroupToggleBehavior = Forms9Patch.GroupToggleBehavior.Multiselect, Segments = { new Forms9Patch.Segment("BACKGROUND"), new Forms9Patch.Segment("OUTLINE"), new Forms9Patch.Segment("SHADOW"), new Forms9Patch.Segment("INVERTED") } }; shapeAttributesSelector.SegmentTapped += ShapeAttributesSelector_SegmentTapped; var seg1 = new Forms9Patch.Segment(""); var seg2 = new Forms9Patch.Segment(null, "Forms9PatchDemo.Resources.redGridBox"); var seg3 = new Forms9Patch.Segment(null, "Forms9PatchDemo.Resources.button"); var seg4 = new Forms9Patch.Segment(null, new Forms9Patch.Image { Source = ImageSource.FromFile("cat.jpg"), Fill = Forms9Patch.Fill.AspectFit }); var seg5 = new Forms9Patch.Segment(null, new Forms9Patch.Image { Source = ImageSource.FromFile("balloons.jpg"), Fill = Forms9Patch.Fill.AspectFit }); var seg6 = new Forms9Patch.Segment(null, "Forms9PatchDemo.Resources.image"); var seg7 = new Forms9Patch.Segment(null, "Forms9PatchDemo.Resources.redribbon"); var seg8 = new Forms9Patch.Segment(null, "Forms9PatchDemo.Resources.bubble"); var seg9 = new Forms9Patch.Segment(null, "Forms9PatchDemo.Resources.bluebutton"); var backgroundImageSelector = new Forms9Patch.SegmentedControl { HeightRequest = 40, HasTightSpacing = true, HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center, TintIcon = false, Segments = { seg1, seg2, seg3, seg4, seg5, seg6, seg7, seg8, seg9 } }; /* * backgroundImageSelector.Segments.Add(seg1); * backgroundImageSelector.Segments.Add(seg2); * backgroundImageSelector.Segments.Add(seg3); * backgroundImageSelector.Segments.Add(seg4); * backgroundImageSelector.Segments.Add(seg5); * backgroundImageSelector.Segments.Add(seg6); * backgroundImageSelector.Segments.Add(seg7); * backgroundImageSelector.Segments.Add(seg8); * backgroundImageSelector.Segments.Add(seg9); */ backgroundImageSelector.SelectIndex(1); backgroundImageSelector.SegmentTapped += BackgroundImageSelector_SegmentTapped; capsInsetsTopSlider.Effects.Add(capsInsetsTStepSizeEffect); capsInsetsTopSlider.ValueChanged += CapsInsetsSlider_ValueChanged; capsInsetsLeftSlider.Effects.Add(capsInsetsLStepSizeEffect); capsInsetsLeftSlider.ValueChanged += CapsInsetsSlider_ValueChanged; capsInsetsRightSlider.Effects.Add(capsInsetsRStepSizeEffect); capsInsetsRightSlider.Rotation = 180; capsInsetsRightSlider.ValueChanged += CapsInsetsSlider_ValueChanged; capsInsetsBottomSlider.Effects.Add(capsInsetsBStepSizeEffect); capsInsetsBottomSlider.ValueChanged += CapsInsetsSlider_ValueChanged; capsInsetsBottomSlider.Rotation = 180; var outlineGrid = new Xamarin.Forms.Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }, }, ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }, }, }; outlineGrid.Children.Add(new Forms9Patch.Label("Forms9Patch.Image.OutlineWidth:"), 0, 0); outlineGrid.Children.Add(outlineWidthSlider, 0, 1); outlineGrid.Children.Add(new Forms9Patch.Label("Forms9Patch.Image.OutlineRadius:"), 1, 0); outlineGrid.Children.Add(outlineRadiusSlider, 1, 1); //pixelCapsSwitch.Toggled += PixelCapsSwitch_Toggled; var capsInsetsGrid = new Xamarin.Forms.Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }, }, ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }, }, }; capsInsetsGrid.Children.Add(new Forms9Patch.Label("CapsInsets.Top:"), 0, 0); capsInsetsGrid.Children.Add(capsInsetsTopSlider, 0, 1); capsInsetsGrid.Children.Add(new Forms9Patch.Label("CapsInsets.Bottom:"), 0, 2); capsInsetsGrid.Children.Add(capsInsetsBottomSlider, 0, 3); capsInsetsGrid.Children.Add(new Forms9Patch.Label("CapsInsets.Left:"), 1, 0); capsInsetsGrid.Children.Add(capsInsetsLeftSlider, 1, 1); capsInsetsGrid.Children.Add(new Forms9Patch.Label("CapsInsets.Right:"), 1, 2); capsInsetsGrid.Children.Add(capsInsetsRightSlider, 1, 3); capsUnitsSegmentedControl.SelectIndex(0); capsUnitsSegmentedControl.SegmentTapped += CapsUnitsSegmentedControl_SegmentTapped; antiAliasSwitch.Toggled += AntiAliasSwitch_Toggled; var capsInsetsAndAntiAliasGrid = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }, }, ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }, }, }; capsInsetsAndAntiAliasGrid.Children.Add(new Forms9Patch.Label("CapsInsets Units:"), 0, 0); capsInsetsAndAntiAliasGrid.Children.Add(capsUnitsSegmentedControl, 0, 1); capsInsetsAndAntiAliasGrid.Children.Add(new Forms9Patch.Label("AntiAlias:"), 1, 0); capsInsetsAndAntiAliasGrid.Children.Add(antiAliasSwitch, 1, 1); #endregion #region Content Master = new ContentPage { Title = "Controls", BackgroundColor = Color.LightGray, Content = new ScrollView { Content = new StackLayout { Padding = new Thickness(10, 10, 20, 10), Children = { new Forms9Patch.Label("HorizontalOptions:"), hzOptionSegmentedControl, new Forms9Patch.Label("VerticalOptions:"), vtOptionSegmentedControl, new Forms9Patch.Label("Fill / Aspect:"), fillSegmentedControl, new Forms9Patch.Label("ElementShape:"), shapesSelector, new Forms9Patch.Label("Shape attributes:"), shapeAttributesSelector, outlineGrid, new Forms9Patch.Label("ImageSource:"), backgroundImageSelector, capsInsetsAndAntiAliasGrid, capsInsetsGrid, new Forms9Patch.Label("HeightRequest:"), heightRequestSlider, new Xamarin.Forms.Label { Text = "Display.Scale=[" + Forms9Patch.Display.Scale + "]" } }, }, } }; Detail = new ContentPage { Title = "Images", Content = new ScrollView { Content = new StackLayout { Children = { new BoxView { Color = Color.Black, HeightRequest = 1 }, new Forms9Patch.Label("Forms9Patch.Button:"), new BoxView { Color = Color.Black, HeightRequest = 1 }, _f9pButton, new BoxView { Color = Color.Black, HeightRequest = 1 }, new BoxView { Color = Color.Black, HeightRequest = 1 }, new Forms9Patch.Label("Xamarin.Forms.Button:"), new BoxView { Color = Color.Black, HeightRequest = 1 }, _xfButton, new BoxView { Color = Color.Black, HeightRequest = 1 }, } } } }; #endregion }
public BubblePopupTestPage() { BackgroundColor = Color.White; var shadowToggle = new Switch(); shadowToggle.SetBinding(Switch.IsToggledProperty, "HasShadow"); shadowToggle.BindingContext = this; var shadowInvertedToggle = new Switch(); shadowInvertedToggle.SetBinding(Switch.IsToggledProperty, "ShadowInverted"); shadowInvertedToggle.BindingContext = this; var cornerRadiusSlider = new Slider { Maximum = 40, Minimum = 0, HeightRequest = 20, }; cornerRadiusSlider.SetBinding(Slider.ValueProperty, "CornerRadius"); cornerRadiusSlider.BindingContext = this; var pointerLengthSlider = new Slider { Maximum = 40, Minimum = 0, HeightRequest = 20, }; pointerLengthSlider.SetBinding(Slider.ValueProperty, "PointerLength"); pointerLengthSlider.BindingContext = this; var pointerTipRadiusSlider = new Slider { Maximum = 20, Minimum = 0, HeightRequest = 20, }; pointerTipRadiusSlider.SetBinding(Slider.ValueProperty, "PointerTipRadius"); pointerTipRadiusSlider.BindingContext = this; var paddingSlider = new Slider { Maximum = 100, Minimum = 0, HeightRequest = 20, }; paddingSlider.SetBinding(Slider.ValueProperty, "PUDPadding"); paddingSlider.BindingContext = this; var pointerCornerRadiusSlider = new Slider { Maximum = 20, Minimum = 0, HeightRequest = 20, }; pointerCornerRadiusSlider.SetBinding(Slider.ValueProperty, "PointerCornerRadius"); pointerCornerRadiusSlider.BindingContext = this; var leftSeg = new Forms9Patch.Segment { Text = "⬅︎", IsSelected = true, }; leftSeg.Tapped += (sender, e) => _lastChanged = leftSeg.VisualElement; var upSeg = new Forms9Patch.Segment { Text = "⬆︎", }; upSeg.Tapped += (sender, e) => _lastChanged = upSeg.VisualElement; var rightSeg = new Forms9Patch.Segment { Text = "➡︎", }; rightSeg.Tapped += (sender, e) => _lastChanged = rightSeg.VisualElement; var downSeg = new Forms9Patch.Segment { Text = "⬇︎", }; downSeg.Tapped += (sender, e) => _lastChanged = downSeg.VisualElement; PointerDirection = Forms9Patch.PointerDirection.Left; var directionSegmentControl = new Forms9Patch.SegmentedControl { Segments = { leftSeg, upSeg, rightSeg, downSeg, }, GroupToggleBehavior = Forms9Patch.GroupToggleBehavior.Multiselect, }; directionSegmentControl.SegmentTapped += (sender, e) => { var dir = Forms9Patch.PointerDirection.None; dir |= (leftSeg.IsSelected ? Forms9Patch.PointerDirection.Left : Forms9Patch.PointerDirection.None); dir |= (rightSeg.IsSelected ? Forms9Patch.PointerDirection.Right : Forms9Patch.PointerDirection.None); dir |= (upSeg.IsSelected ? Forms9Patch.PointerDirection.Up : Forms9Patch.PointerDirection.None); dir |= (downSeg.IsSelected ? Forms9Patch.PointerDirection.Down : Forms9Patch.PointerDirection.None); PointerDirection = dir; System.Diagnostics.Debug.WriteLine("Direction changed"); }; var bubbleLabel = new Label { Text = "Forms9Patch.BubblePopup", TextColor = Color.Black, //BackgroundColor = Color.Green, }; var bubbleButton = new Forms9Patch.Button { Text = "Close", //BackgroundColor = Color.Blue, OutlineColor = Color.Blue, TextColor = Color.Blue, }; //bubbleLabel.SetBinding (Label.TextProperty, "CornerRadius"); bubbleLabel.BindingContext = this; var addItemButton = new Forms9Patch.Button { Text = "Add Item", OutlineColor = Color.Black, OutlineWidth = 1, TextColor = Color.Red }; var removeItemButton = new Forms9Patch.Button { Text = "Remove Item", OutlineColor = Color.Black, OutlineWidth = 1, TextColor = Color.Red }; var enlargeItemsButton = new Forms9Patch.Button { Text = "Englarge Items", OutlineColor = Color.Black, OutlineWidth = 1, TextColor = Color.Black }; var shrinkItems = new Forms9Patch.Button { Text = "Shrink Items", OutlineColor = Color.Black, OutlineWidth = 1, TextColor = Color.Black }; var stackLayout = new Forms9Patch.StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.Start, }; //stackLayout.Children.Add(new Label { Text = "X,", TextColor = Color.Green }); var contentView = new Xamarin.Forms.ContentView { Content = stackLayout, HorizontalOptions = LayoutOptions.Start }; var bubble = new Forms9Patch.BubblePopup(this) { //BackgroundColor = Color.Green, //OutlineColor = Color.Black, //OutlineWidth = 1, PointerCornerRadius = 0, Content = new StackLayout { Children = { bubbleLabel, contentView, new Label { Text = "Padding:", FontSize = 10, TextColor = Color.Black }, paddingSlider, new Label { Text = "Pointer Length:",FontSize = 10, TextColor = Color.Black }, pointerLengthSlider, new Label { Text = "Pointer Tip Radius:",FontSize = 10, TextColor = Color.Black }, pointerTipRadiusSlider, new Label { Text = "Corner Radius:",FontSize = 10, TextColor = Color.Black }, cornerRadiusSlider, new Label { Text = "Pointer Corner Radius:",FontSize = 10, TextColor = Color.Black }, pointerCornerRadiusSlider, bubbleButton, addItemButton, removeItemButton, enlargeItemsButton, shrinkItems } }, }; bubble.SetBinding(Forms9Patch.BubblePopup.OutlineRadiusProperty, "CornerRadius"); bubble.SetBinding(Forms9Patch.BubblePopup.PointerLengthProperty, "PointerLength"); bubble.SetBinding(Forms9Patch.BubblePopup.PointerTipRadiusProperty, "PointerTipRadius"); bubble.SetBinding(Forms9Patch.BubblePopup.PaddingProperty, "PUPadding"); bubble.SetBinding(Forms9Patch.BubblePopup.HasShadowProperty, "HasShadow"); bubble.SetBinding(Forms9Patch.BubblePopup.ShadowInvertedProperty, "ShadowInverted"); bubble.SetBinding(Forms9Patch.BubblePopup.PointerDirectionProperty, "PointerDirection"); bubble.SetBinding(Forms9Patch.BubblePopup.PointerCornerRadiusProperty, "PointerCornerRadius"); bubble.BindingContext = this; //const bool Relayout = false; bubbleButton.Tapped += (sender, e) => bubble.IsVisible = false; addItemButton.Tapped += (sender, e) => { //var count = stackLayout.Children.Count(); //stackLayout.Children.Clear(); //for (int i = 0; i <= count; i++) stackLayout.Children.Add(new Label { Text = "X,", TextColor = Color.Green }); //bubble.WidthRequest = 1; stackLayout.WidthRequest = -1; var size = stackLayout.Measure(double.MaxValue, double.MinValue); System.Diagnostics.Debug.WriteLine("WIDTH=[" + stackLayout.Width + "] size.Request.Width=[" + size.Request.Width + "]"); //stackLayout.WidthRequest = size.Request.Width + 1; //this.CallMethod("InvalidateMeasure", new object[] {}); //contentView.WidthRequest = size.Request.Width; stackLayout.Children.Last().IsVisible = true; }; enlargeItemsButton.Tapped += (sender, e) => { var count = stackLayout.Children.Count(); var width = 1; if (count > 0) { width = ((Label)stackLayout.Children[0]).Text.Length; } string text = ""; for (int i = 0; i < width; i++) { text += "X"; } text += ","; stackLayout.Children.Clear(); for (int i = 0; i < count; i++) { stackLayout.Children.Add(new Label { Text = text, TextColor = Color.Green }); } //bubble.WidthRequest = 1; stackLayout.WidthRequest = -1; var size = stackLayout.Measure(double.MaxValue, double.MinValue); System.Diagnostics.Debug.WriteLine("WIDTH=[" + stackLayout.Width + "] size.Request.Width=[" + size.Request.Width + "]"); //stackLayout.WidthRequest = size.Request.Width + 1; //this.CallMethod("InvalidateMeasure", new object[] {}); //contentView.WidthRequest = size.Request.Width; }; shrinkItems.Tapped += (sender, e) => { var count = stackLayout.Children.Count(); var width = 1; if (count > 0) { width = ((Label)stackLayout.Children[0]).Text.Length; } string text = ""; for (int i = 0; i < width - 2; i++) { text += "X"; } text += ","; System.Diagnostics.Debug.WriteLine("Text=[" + text + "]"); stackLayout.Children.Clear(); for (int i = 0; i < count; i++) { stackLayout.Children.Add(new Label { Text = text, TextColor = Color.Green }); } //bubble.WidthRequest = 1; stackLayout.WidthRequest = -1; var size = stackLayout.Measure(double.MaxValue, double.MinValue); System.Diagnostics.Debug.WriteLine("WIDTH=[" + stackLayout.Width + "] size.Request.Width=[" + size.Request.Width + "]"); }; removeItemButton.Tapped += (sender, e) => { if (stackLayout.Children.Count > 0) { stackLayout.Children.Remove(stackLayout.Children.Last()); } }; var showButton = new Forms9Patch.Button { Text = "Show BubblePopup", OutlineColor = Color.Blue, TextColor = Color.Blue, }; showButton.Tapped += (object sender, EventArgs e) => { bubble.Target = _lastChanged; bubble.IsVisible = true; }; _lastChanged = leftSeg.VisualElement; Content = new StackLayout { Padding = 20, Children = { new StackLayout { Orientation = StackOrientation.Horizontal, Children = { new StackLayout { Children = { new Label { Text = "Has Shadow", FontSize = 10, TextColor = Color.Black }, shadowToggle, }, HorizontalOptions = LayoutOptions.StartAndExpand, }, new StackLayout { Children = { new Label { Text = "Inset Shadow", FontSize = 10, TextColor = Color.Black }, shadowInvertedToggle, }, HorizontalOptions = LayoutOptions.EndAndExpand, } } }, //new Label { Text = "Padding:", FontSize=10, TextColor=Color.Black }, //paddingSlider, new Label { Text = "Pointer Direction", FontSize = 10, TextColor = Color.Black }, directionSegmentControl, showButton, new Label { Text = "Arrows choose the BubblePopup's allowed pointer direction. Bubble's pointer will point at the last selected arrow-segment-button.", TextColor = Color.Black }, } }; }
public UnconstrainedLabelFitPage() { BackgroundColor = Color.Gray; Padding = 0; #region Editor var editor = new Editor { //Text = "Żorem ipsum dolor sit amet, consectetur adięiscing ełit", Text = text1, TextColor = Color.White, BackgroundColor = Color.Black, HeightRequest = 130, FontSize = 15, }; editor.Effects.Add(Effect.Resolve("Forms9Patch.CustomFontEffect")); #endregion #region Xamarin Forms label var xfLabel = new Label { FontSize = 15, TextColor = Color.White, BackgroundColor = Color.Black, Text = editor.Text }; #endregion #region Forms9Patch Label var f9pLabel = new Forms9Patch.Label { //HeightRequest = 50, Lines = 3, FontSize = 15, TextColor = Color.White, Fit = Forms9Patch.LabelFit.None, BackgroundColor = Color.Black, Text = editor.Text }; #endregion #region Mode var modeSwitch = new Switch { IsToggled = false, HorizontalOptions = LayoutOptions.End, }; modeSwitch.Toggled += (sender, e) => { if (modeSwitch.IsToggled) f9pLabel.HtmlText = editor.Text; else f9pLabel.Text = editor.Text; }; #endregion #region Sync text between Editor and Labels editor.TextChanged += (sender, e) => { xfLabel.Text = editor.Text; f9pLabel.HtmlText = editor.Text; }; #endregion #region Font Size selection var fontSizeSlider = new Slider { Maximum = 104, Minimum = 4, Value = 15 }; var fontSizeLabel = new Label { Text = "Font Size: 15" }; fontSizeSlider.ValueChanged += (sender, e) => { fontSizeLabel.Text = "Font Size: " + fontSizeSlider.Value; f9pLabel.FontSize = fontSizeSlider.Value; if (!rendering) { rendering = true; xfLabel.FontSize = fontSizeSlider.Value; Device.StartTimer(TimeSpan.FromMilliseconds(50), () => { if (Math.Abs(xfLabel.FontSize - lastFontSize) > double.Epsilon * 5) { xfLabel.FontSize = lastFontSize; return true; } rendering = false; return false; }); } lastFontSize = fontSizeSlider.Value; }; var actualFontSizeLabel = new Label { Text = "Actual Font Size: 15" }; f9pLabel.PropertyChanged += (sender, e) => { if (e.PropertyName == Forms9Patch.Label.ActualFontSizeProperty.PropertyName) actualFontSizeLabel.Text = "ActualFontSize: " + f9pLabel.ActualFontSize; }; #endregion #region Lines selection var linesLabel = new Label { Text = "Lines: 3" }; var linesSlider = new Slider { Minimum = 0, Maximum = 8, Value = 3 }; linesSlider.ValueChanged += (sender, e) => { linesLabel.Text = "Lines: " + ((int)Math.Round(linesSlider.Value)); f9pLabel.Lines = ((int)Math.Round(linesSlider.Value)); }; #endregion #region Fit Selection var fitSelector = new Forms9Patch.MaterialSegmentedControl(); fitSelector.Segments.Add(new Forms9Patch.Segment { Text = "None", Command = new Command(x => { f9pLabel.Fit = Forms9Patch.LabelFit.None; }) }); var widthSegment = new Forms9Patch.Segment { Text = "Width", Command = new Command(x => { f9pLabel.Fit = Forms9Patch.LabelFit.Width; }), //IsEnabled = f9pLabel.HasImposedSize, BindingContext = f9pLabel, //IsEnabled = false }; //widthSegment.SetBinding(Forms9Patch.Segment.IsEnabledProperty, "HasImposedSize"); fitSelector.Segments.Add(widthSegment); var linesSegment = new Forms9Patch.Segment { Text = "Lines", Command = new Command(x => { f9pLabel.Fit = Forms9Patch.LabelFit.Lines; }), //IsEnabled = f9pLabel.HasImposedSize, BindingContext = f9pLabel }; //linesSegment.SetBinding(Forms9Patch.Segment.IsEnabledProperty, "HasImposedSize"); fitSelector.Segments.Add(linesSegment); fitSelector.SelectIndex(0); #endregion #region Alignment Selection var hzAlignmentSelector = new Forms9Patch.MaterialSegmentedControl(); var vtAlignmentSelector = new Forms9Patch.MaterialSegmentedControl(); hzAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "Start", Command = new Command(x => { f9pLabel.HorizontalTextAlignment = TextAlignment.Start; xfLabel.HorizontalTextAlignment = TextAlignment.Start; }) } ); hzAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "Center", Command = new Command(x => { f9pLabel.HorizontalTextAlignment = TextAlignment.Center; xfLabel.HorizontalTextAlignment = TextAlignment.Center; }) } ); hzAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "End", Command = new Command(x => { f9pLabel.HorizontalTextAlignment = TextAlignment.End; xfLabel.HorizontalTextAlignment = TextAlignment.End; }) } ); vtAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "Start", Command = new Command(x => { f9pLabel.VerticalTextAlignment = TextAlignment.Start; xfLabel.VerticalTextAlignment = TextAlignment.Start; }) } ); vtAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "Center", Command = new Command(x => { f9pLabel.VerticalTextAlignment = TextAlignment.Center; xfLabel.VerticalTextAlignment = TextAlignment.Center; }) } ); vtAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "End", Command = new Command(x => { f9pLabel.VerticalTextAlignment = TextAlignment.End; xfLabel.VerticalTextAlignment = TextAlignment.End; }) } ); hzAlignmentSelector.SelectIndex(0); vtAlignmentSelector.SelectIndex(0); #endregion #region BreakMode selection var breakModeSelector = new Forms9Patch.MaterialSegmentedControl(); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "NoWrap", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.NoWrap; xfLabel.LineBreakMode = LineBreakMode.NoWrap; }) } ); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "Char", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.CharacterWrap; xfLabel.LineBreakMode = LineBreakMode.CharacterWrap; }) } ); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "Word", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.WordWrap; xfLabel.LineBreakMode = LineBreakMode.WordWrap; }) } ); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "Head", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.HeadTruncation; xfLabel.LineBreakMode = LineBreakMode.HeadTruncation; }) } ); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "Mid", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.MiddleTruncation; xfLabel.LineBreakMode = LineBreakMode.MiddleTruncation; }) } ); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "Tail", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.TailTruncation; xfLabel.LineBreakMode = LineBreakMode.TailTruncation ; }) } ); breakModeSelector.SelectIndex(2); #endregion #region FontSelection Picker fontPicker = new Picker { Title = "Default", //HeightRequest = 300, //VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.EndAndExpand, }; var fontFamilies = Forms9Patch.FontExtensions.LoadedFontFamilies(); foreach (var fontFamily in fontFamilies) fontPicker.Items.Add(fontFamily); fontPicker.SelectedIndexChanged += (sender, e) => { string family = null; if (fontPicker.SelectedIndex > -1 && fontPicker.SelectedIndex < fontFamilies.Count) { f9pLabel.FontFamily = fontFamilies[fontPicker.SelectedIndex]; xfLabel.FontFamily = fontFamilies[fontPicker.SelectedIndex]; editor.FontFamily = fontFamilies[fontPicker.SelectedIndex]; } }; #endregion Content = new ScrollView { Padding = 0, Content = new StackLayout { Padding = 20, Children = { new Label { Text = "Text:" }, editor, new StackLayout { Orientation = StackOrientation.Horizontal, Children = { new Label { Text = "HTML Formatted:", HorizontalOptions = LayoutOptions.StartAndExpand, }, modeSwitch }, }, new Label { Text = "Forms9Patch.Label:" }, f9pLabel, new Label { Text = "Font Family:", HorizontalOptions = LayoutOptions.Start }, fontPicker, fontSizeLabel, fontSizeSlider, actualFontSizeLabel, new Label { Text = "Fit:" }, fitSelector, linesLabel, linesSlider, new Label { Text = "Horizontal Alignment:" }, hzAlignmentSelector, new Label { Text = "Vertical Alignment:" }, vtAlignmentSelector, new Label { Text = "Truncation Mode:" }, breakModeSelector, } } }; }
public MaterialButtonsPage() { #region Material Buttons var grid = new Grid { RowDefinitions = { new RowDefinition { Height = GridLength.Auto }, }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, }, }; var mb1 = new Forms9Patch.Button { Text = "TI", IconImage = new Forms9Patch.Image { Source = _arrowIconSource }, TintIcon = false, }; mb1.Tapped += OnMaterialButtonTapped; mb1.Selected += OnMaterialButtonSelected; mb1.LongPressing += OnMaterialButtonLongPressing; mb1.LongPressed += OnMaterialButtonLongPressed; var mb2 = new Forms9Patch.Button { //Text = "toggle", ToggleBehavior = true, IconImage = new Forms9Patch.Image { Source = _infoIconSource }, }; mb2.Tapped += OnMaterialButtonTapped; mb2.Selected += OnMaterialButtonSelected; mb2.LongPressing += OnMaterialButtonLongPressing; mb2.LongPressed += OnMaterialButtonLongPressed; var mb3 = new Forms9Patch.Button { //Text = "disabled", ToggleBehavior = true, IsEnabled = false, IconImage = new Forms9Patch.Image { Source = _arrowIconSource }, }; mb3.Tapped += OnMaterialButtonTapped; mb3.Selected += OnMaterialButtonSelected; mb3.LongPressing += OnMaterialButtonLongPressing; mb3.LongPressed += OnMaterialButtonLongPressed; var mb4 = new Forms9Patch.Button { //Text = "selected disabled", IsEnabled = false, IsSelected = true, IconImage = new Forms9Patch.Image { Source = _infoIconSource }, }; mb4.Tapped += OnMaterialButtonTapped; mb4.Selected += OnMaterialButtonSelected; mb4.LongPressing += OnMaterialButtonLongPressing; mb4.LongPressed += OnMaterialButtonLongPressed; var label1 = new Label { Text = "Gesture Label", BackgroundColor = Color.Blue, HeightRequest = 50, }; var label1Listener = FormsGestures.Listener.For(label1); label1Listener.Tapped += (sender, e) => System.Diagnostics.Debug.WriteLine($"Tapped:{((Label)sender).Text}"); label1Listener.DoubleTapped += (sender, e) => System.Diagnostics.Debug.WriteLine($"DoubleTapped:{((Label)sender).Text}"); label1Listener.LongPressing += (sender, e) => System.Diagnostics.Debug.WriteLine($"LongPressing:{((Label)sender).Text}"); // How to remove a listener! label1Listener.LongPressed += (sender, e) => { label1Listener.Dispose(); System.Diagnostics.Debug.WriteLine("Removed FormsGestures.Listener"); }; grid.Children.Add(new StackLayout { BackgroundColor = Color.FromHex("#33FF33"), Padding = new Thickness(10), Children = { new Label { Text = "Default, Light", TextColor = Color.Black, }, mb1, mb2, mb3, mb4, new Label { Text = "Outline, Light", TextColor = Color.Black, }, new Forms9Patch.Button { Text = "", IconImage = new Forms9Patch.Image{ Source = _arrowIconSource }, OutlineWidth = 0, }, new Forms9Patch.Button { //Text = "toggle", ToggleBehavior = true, IconImage = new Forms9Patch.Image { Source = _infoIconSource }, OutlineWidth = 0, }, new Forms9Patch.Button { //Text = "disabled", ToggleBehavior = true, IsEnabled = false, IconImage = new Forms9Patch.Image { Source = _arrowIconSource }, OutlineWidth = 0, }, new Forms9Patch.Button { //Text = "selected disabled", IsEnabled = false, IsSelected = true, IconImage = new Forms9Patch.Image { Source = _infoIconSource }, OutlineWidth = 0, }, new Label { Text = "Background Color, Light Theme", TextColor = Color.Black, }, new Forms9Patch.Button { Text = "default", BackgroundColor = Color.FromHex("#E0E0E0"), IconImage = new Forms9Patch.Image { Source = _arrowIconSource }, Orientation = StackOrientation.Vertical, }, new Forms9Patch.Button { Text = "toggle", ToggleBehavior = true, BackgroundColor = Color.FromHex("#E0E0E0"), IconImage = new Forms9Patch.Image { Source = _infoIconSource }, }, new Forms9Patch.Button { Text = "disabled", ToggleBehavior = true, IsEnabled = false, BackgroundColor = Color.FromHex("#E0E0E0"), IconImage = new Forms9Patch.Image { Source = _arrowIconSource }, }, new Forms9Patch.Button { Text = "selected disabled", IsEnabled = false, IsSelected = true, BackgroundColor = Color.FromHex("#E0E0E0"), IconImage = new Forms9Patch.Image { Source = _infoIconSource }, }, new Label { Text = "Shadow, Light Theme", TextColor = Color.Black, }, new Forms9Patch.Button { Text = "default", HasShadow = true, IconImage = new Forms9Patch.Image{ Source = _infoIconSource }, }, new Forms9Patch.Button { Text = "toggle", ToggleBehavior = true, HasShadow = true, IconImage = new Forms9Patch.Image { Source = _arrowIconSource }, }, new Forms9Patch.Button { Text = "disabled", ToggleBehavior = true, IsEnabled = false, HasShadow = true, IconImage = new Forms9Patch.Image { Source = _infoIconSource }, }, new Forms9Patch.Button { Text = "selected disabled", IsEnabled = false, IsSelected = true, HasShadow = true, IconImage = new Forms9Patch.Image { Source = _arrowIconSource }, }, new Label { Text = "Shadow Background Color, Light Theme", TextColor = Color.Black, }, new Forms9Patch.Button { Text = "default", BackgroundColor = Color.FromHex("#E0E0E0"), HasShadow = true, IconImage = new Forms9Patch.Image { Source = _infoIconSource }, }, new Forms9Patch.Button { Text = "toggle", ToggleBehavior = true, BackgroundColor = Color.FromHex("#E0E0E0"), HasShadow = true, IconImage = new Forms9Patch.Image { Source = _arrowIconSource }, }, new Forms9Patch.Button { Text = "disabled", ToggleBehavior = true, IsEnabled = false, BackgroundColor = Color.FromHex("#E0E0E0"), HasShadow = true, IconImage = new Forms9Patch.Image { Source = _infoIconSource }, }, new Forms9Patch.Button { Text = "selected disabled", IsEnabled = false, IsSelected = true, BackgroundColor = Color.FromHex("#E0E0E0"), HasShadow = true, IconImage = new Forms9Patch.Image { Source = _arrowIconSource }, }, }, }, 0, 0); grid.Children.Add(new StackLayout { Padding = new Thickness(10), BackgroundColor = Color.FromHex("#003"), Children = { new Label { Text = "Default, Dark Theme", TextColor = Color.White, }, new Forms9Patch.Button { Text = "default", DarkTheme = true, }, new Forms9Patch.Button { Text = "toggle", ToggleBehavior = true, DarkTheme = true, }, new Forms9Patch.Button { Text = "disabled", ToggleBehavior = true, IsEnabled = false, DarkTheme = true, }, new Forms9Patch.Button { Text = "selected disabled", IsEnabled = false, IsSelected = true, DarkTheme = true, }, new Label { Text = "Outline, Dark Theme", TextColor = Color.White, }, new Forms9Patch.Button { Text = "default", DarkTheme = true, OutlineWidth = 0, }, new Forms9Patch.Button { Text = "toggle", ToggleBehavior = true, DarkTheme = true, OutlineWidth = 0, }, new Forms9Patch.Button { Text = "disabled", ToggleBehavior = true, IsEnabled = false, DarkTheme = true, OutlineWidth = 0, }, new Forms9Patch.Button { Text = "selected disabled", IsEnabled = false, IsSelected = true, DarkTheme = true, OutlineWidth = 0, }, new Label { Text = "Background Color, Dark Theme", TextColor = Color.White, }, new Forms9Patch.Button { Text = "default", BackgroundColor = Color.FromHex("#1194F6"), DarkTheme = true, IconImage = new Forms9Patch.Image { Source = _arrowIconSource }, Orientation = StackOrientation.Vertical, }, new Forms9Patch.Button { Text = "toggle", ToggleBehavior = true, BackgroundColor = Color.FromHex("#1194F6"), DarkTheme = true, }, new Forms9Patch.Button { Text = "disabled", ToggleBehavior = true, IsEnabled = false, BackgroundColor = Color.FromHex("#1194F6"), DarkTheme = true, }, new Forms9Patch.Button { Text = "selected disabled", IsEnabled = false, IsSelected = true, BackgroundColor = Color.FromHex("#1194F6"), DarkTheme = true, }, new Label { Text = "Shadow, Dark Theme", TextColor = Color.White, }, new Forms9Patch.Button { Text = "default", DarkTheme = true, HasShadow = true, }, new Forms9Patch.Button { Text = "toggle", ToggleBehavior = true, DarkTheme = true, HasShadow = true, }, new Forms9Patch.Button { Text = "disabled", ToggleBehavior = true, IsEnabled = false, DarkTheme = true, HasShadow = true, }, new Forms9Patch.Button { Text = "selected disabled", IsEnabled = false, IsSelected = true, DarkTheme = true, HasShadow = true, }, new Label { Text = "Shadow Background Color, Dark Theme", TextColor = Color.White, }, new Forms9Patch.Button { Text = "default", BackgroundColor = Color.FromHex("#1194F6"), DarkTheme = true, HasShadow = true, }, new Forms9Patch.Button { Text = "toggle", ToggleBehavior = true, BackgroundColor = Color.FromHex("#1194F6"), DarkTheme = true, HasShadow = true, }, new Forms9Patch.Button { Text = "disabled", ToggleBehavior = true, IsEnabled = false, BackgroundColor = Color.FromHex("#1194F6"), DarkTheme = true, HasShadow = true, }, new Forms9Patch.Button { Text = "selected disabled", IsEnabled = false, IsSelected = true, BackgroundColor = Color.FromHex("#1194F6"), DarkTheme = true, HasShadow = true, }, }, }, 1, 0); #endregion #region Light SegmentedControl var sc1 = new Forms9Patch.SegmentedControl { Padding = 3, Segments = { new Forms9Patch.Segment { Text = "A", IconImage = new Forms9Patch.Image{ Source = _arrowIconSource }, Command = _trueCommand, CommandParameter = "sc1 A", }, new Forms9Patch.Segment { //Text = "B", IsSelected = true, IconImage = new Forms9Patch.Image { Source = _arrowIconSource }, Command = _trueCommand, CommandParameter = "sc1 B", }, new Forms9Patch.Segment { Text = "C", Command = _trueCommand, CommandParameter = "sc1 C", }, new Forms9Patch.Segment { Text = "D", //IsEnabled = false, Command = _falseCommand, CommandParameter = "sc1 D", }, }, }; sc1.SegmentSelected += OnSegmentSelected; sc1.SegmentTapped += OnSegmentTapped; sc1.SegmentLongPressing += OnSegmentLongPressing; sc1.SegmentLongPressed += OnSegmentLongPressed; var seg1 = new Forms9Patch.Segment { //Text = "A", IconImage = new Forms9Patch.Image { Source = _arrowIconSource }, }; seg1.Tapped += OnMaterialButtonTapped; seg1.Selected += OnMaterialButtonTapped; seg1.LongPressing += OnMaterialButtonLongPressing; seg1.LongPressed += OnMaterialButtonLongPressed; var seg2 = new Forms9Patch.Segment { Text = "B", IsSelected = true, }; seg2.Tapped += OnMaterialButtonTapped; seg2.Selected += OnMaterialButtonTapped; seg2.LongPressing += OnMaterialButtonLongPressing; seg2.LongPressed += OnMaterialButtonLongPressed; var seg3 = new Forms9Patch.Segment { Text = "C", }; seg3.Tapped += OnMaterialButtonTapped; seg3.Selected += OnMaterialButtonTapped; seg3.LongPressing += OnMaterialButtonLongPressing; seg3.LongPressed += OnMaterialButtonLongPressed; var seg4 = new Forms9Patch.Segment { Text = "D", IsEnabled = false, }; seg4.Tapped += OnMaterialButtonTapped; seg4.Selected += OnMaterialButtonTapped; seg4.LongPressing += OnMaterialButtonLongPressing; seg4.LongPressed += OnMaterialButtonLongPressed; var sc2 = new Forms9Patch.SegmentedControl { OutlineWidth = 0, Padding = 3, Segments = { seg1, seg2, seg3, seg4, }, }; sc2.SegmentSelected += OnSegmentSelected; sc2.SegmentTapped += OnSegmentTapped; sc2.SegmentLongPressing += OnSegmentLongPressing; sc2.SegmentLongPressed += OnSegmentLongPressed; var sc3 = new Forms9Patch.SegmentedControl { //OutlineColor = Color.Transparent, BackgroundColor = Color.FromHex("#E0E0E0"), Padding = 3, Segments = { new Forms9Patch.Segment { Text = "A", }, new Forms9Patch.Segment { Text = "B", IsSelected = true, }, new Forms9Patch.Segment { Text = "C", }, new Forms9Patch.Segment { //Text = "D", IsEnabled = false, IconImage = new Forms9Patch.Image{ Source = _arrowIconSource }, }, }, }; sc3.SegmentSelected += OnSegmentSelected; sc3.SegmentTapped += OnSegmentTapped; sc3.SegmentLongPressing += OnSegmentLongPressing; sc3.SegmentLongPressed += OnSegmentLongPressed; var sc4 = new Forms9Patch.SegmentedControl { BackgroundColor = Color.FromHex("#E0E0E0"), OutlineWidth = 0, SeparatorWidth = 1, GroupToggleBehavior = Forms9Patch.GroupToggleBehavior.None, Padding = 3, Segments = { new Forms9Patch.Segment { Text = "A none", IconImage = new Forms9Patch.Image{ Source = _arrowIconSource }, Orientation = StackOrientation.Vertical, }, new Forms9Patch.Segment { Text = "B none", IsSelected = true, IconImage = new Forms9Patch.Image { Source = _infoIconSource }, Orientation = StackOrientation.Vertical, }, new Forms9Patch.Segment { Text = "C none", IconImage = new Forms9Patch.Image{ Source = _arrowIconSource }, }, new Forms9Patch.Segment { Text = "D none", IsEnabled = false, IconImage = new Forms9Patch.Image{ Source = _infoIconSource }, Orientation = StackOrientation.Vertical, }, }, }; sc4.SegmentSelected += OnSegmentSelected; sc4.SegmentTapped += OnSegmentTapped; sc4.SegmentLongPressing += OnSegmentLongPressing; sc4.SegmentLongPressed += OnSegmentLongPressed; var sc5 = new Forms9Patch.SegmentedControl { BackgroundColor = Color.FromHex("#E0E0E0"), HasShadow = true, //OutlineRadius = 0, //OutlineWidth = 0, Orientation = StackOrientation.Vertical, GroupToggleBehavior = Forms9Patch.GroupToggleBehavior.Multiselect, Padding = 3, Segments = { new Forms9Patch.Segment { Text = "A multi", IconImage = new Forms9Patch.Image{ Source = _arrowIconSource }, }, new Forms9Patch.Segment { Text = "B multi", IsSelected = true, }, new Forms9Patch.Segment { Text = "C multi", }, new Forms9Patch.Segment { Text = "D multi", IsEnabled = false, }, }, }; sc5.SegmentSelected += OnSegmentSelected; sc5.SegmentTapped += OnSegmentTapped; sc5.SegmentLongPressing += OnSegmentLongPressing; sc5.SegmentLongPressed += OnSegmentLongPressed; var sc6 = new Forms9Patch.SegmentedControl { BackgroundColor = Color.FromHex("#E0E0E0"), HasShadow = true, //OutlineRadius = 0, OutlineWidth = 0, SeparatorWidth = 1, Orientation = StackOrientation.Vertical, GroupToggleBehavior = Forms9Patch.GroupToggleBehavior.None, Padding = 3, Segments = { new Forms9Patch.Segment { Text = "A none", }, new Forms9Patch.Segment { Text = "B none", IsSelected = true, IconImage = new Forms9Patch.Image { Source = _arrowIconSource }, //Orientation = StackOrientation.Vertical, }, new Forms9Patch.Segment { Text = "C none", }, new Forms9Patch.Segment { Text = "D none", IsEnabled = false, }, }, }; sc6.SegmentSelected += OnSegmentSelected; sc6.SegmentTapped += OnSegmentTapped; sc6.SegmentLongPressing += OnSegmentLongPressing; sc6.SegmentLongPressed += OnSegmentLongPressed; #endregion Padding = 20; Content = new ScrollView { Content = new StackLayout { Children = { grid, #region MaterialSegmentControl #region Light new StackLayout { BackgroundColor = Color.Lime, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(10), Children = { new Label { Text = "Default, Light", TextColor = Color.Black, }, sc1,sc2, sc3, sc4, sc5, sc6, }, }, #endregion #region Dark new StackLayout { BackgroundColor = Color.FromHex("#003"), HorizontalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(10), Children = { new Label { Text = "Default, Dark", TextColor = Color.White, }, new Forms9Patch.SegmentedControl { //OutlineColor = Color.Transparent, DarkTheme = true, Padding = 3, Segments = { new Forms9Patch.Segment { Text = "A", }, new Forms9Patch.Segment { //Text = "B", IsSelected = true, IconImage = new Forms9Patch.Image { Source = _arrowIconSource }, }, new Forms9Patch.Segment { Text = "C", }, new Forms9Patch.Segment { Text = "D", IsEnabled = false, }, }, }, new Forms9Patch.SegmentedControl { DarkTheme = true, OutlineWidth = 0, Padding = 3, Segments = { new Forms9Patch.Segment { //Text = "A", IconImage = new Forms9Patch.Image{ Source = _arrowIconSource }, }, new Forms9Patch.Segment { Text = "B", IsSelected = true, }, new Forms9Patch.Segment { Text = "C", }, new Forms9Patch.Segment { Text = "D", IsEnabled = false, }, }, }, new Forms9Patch.SegmentedControl { DarkTheme = true, BackgroundColor = Color.FromHex("#1194F6"), Padding = 3, Segments = { new Forms9Patch.Segment { Text = "A", }, new Forms9Patch.Segment { Text = "B", IsSelected = true, }, new Forms9Patch.Segment { Text = "C", }, new Forms9Patch.Segment { //Text = "D", IsEnabled = false, IconImage = new Forms9Patch.Image{ Source = _arrowIconSource }, }, }, }, new Forms9Patch.SegmentedControl { DarkTheme = true, BackgroundColor = Color.FromHex("#1194F6"), OutlineWidth = 0, Padding = 3, Segments = { new Forms9Patch.Segment { Text = "A", IconImage = new Forms9Patch.Image{ Source = _arrowIconSource }, Orientation = StackOrientation.Vertical, }, new Forms9Patch.Segment { Text = "B", IsSelected = true, IconImage = new Forms9Patch.Image { Source = _infoIconSource }, Orientation = StackOrientation.Vertical, }, new Forms9Patch.Segment { Text = "C", IconImage = new Forms9Patch.Image{ Source = _arrowIconSource }, }, new Forms9Patch.Segment { Text = "D", IsEnabled = false, IconImage = new Forms9Patch.Image{ Source = _infoIconSource }, Orientation = StackOrientation.Vertical, }, }, }, new Forms9Patch.SegmentedControl { DarkTheme = true, BackgroundColor = Color.FromHex("#1194F6"), HasShadow = true, //OutlineRadius = 0, //OutlineWidth = 0, Orientation = StackOrientation.Vertical, GroupToggleBehavior = Forms9Patch.GroupToggleBehavior.Multiselect, Padding = 3, Segments = { new Forms9Patch.Segment { Text = "A", IconImage = new Forms9Patch.Image{ Source = _arrowIconSource }, }, new Forms9Patch.Segment { Text = "B", IsSelected = true, }, new Forms9Patch.Segment { Text = "C", }, new Forms9Patch.Segment { Text = "D", IsEnabled = false, }, }, }, new Forms9Patch.SegmentedControl { DarkTheme = true, BackgroundColor = Color.FromHex("#1194F6"), HasShadow = true, //OutlineRadius = 0, OutlineWidth = 0, SeparatorWidth = 1, Orientation = StackOrientation.Vertical, GroupToggleBehavior = Forms9Patch.GroupToggleBehavior.Multiselect, Padding = 3, Segments = { new Forms9Patch.Segment { Text = "A", }, new Forms9Patch.Segment { Text = "B", IsSelected = true, IconImage = new Forms9Patch.Image { Source = _arrowIconSource }, }, new Forms9Patch.Segment { Text = "C", }, new Forms9Patch.Segment { Text = "D", IsEnabled = false, }, }, }, }, }, #endregion #endregion }, }, }; }
public LabelAutoFitPage() { LinesSlider.Effects.Add(new Forms9Patch.SliderStepSizeEffect(1.0)); BackgroundColor = Color.LightGray; Padding = 10; #region Editor var editor = new Editor { Text = text1, TextColor = Color.Black, BackgroundColor = Color.White, HeightRequest = 130, FontSize = 15, }; #endregion #region Xamarin Forms label var effect = Effect.Resolve("Forms9Patch.EmbeddedResourceFontEffect"); //xfLabel.Effects.Add(effect); #endregion #region Forms9Patch Label var listener = FormsGestures.Listener.For(f9pLabel); listener.Tapped += (object sender, FormsGestures.TapEventArgs e) => { System.Diagnostics.Debug.WriteLine("Point=[" + e.ElementTouches[0] + "] Index=[" + f9pLabel.IndexAtPoint(e.ElementTouches[0]) + "]"); }; #endregion #region Mode var modeSwitch = new Switch { IsToggled = false, HorizontalOptions = LayoutOptions.End, }; modeSwitch.Toggled += (sender, e) => { if (modeSwitch.IsToggled) { f9pLabel.HtmlText = editor.Text; } else { f9pLabel.Text = editor.Text; } }; #endregion #region Sync text between Editor and Labels editor.TextChanged += (sender, e) => { xfLabel.Text = editor.Text; if (modeSwitch.IsToggled) { f9pLabel.HtmlText = editor.Text; } else { f9pLabel.Text = editor.Text; } }; #endregion #region Frames for Labels var frameForF9P = new Frame { HeightRequest = 100, //WidthRequest = 200, Padding = 0, Content = f9pLabel, CornerRadius = 0 }; var frameForXF = new Frame { HeightRequest = 100, //WidthRequest = 200, Padding = 0, Content = xfLabel, CornerRadius = 0 }; #endregion #region Impose Height var imposeHeightSwitch = new Switch { IsToggled = true }; var heightRequestSlider = new Slider(0, 800, 100); heightRequestSlider.Effects.Add(new Forms9Patch.SliderStepSizeEffect(0.5)); var imposedHeightGrid = new Grid { RowDefinitions = new RowDefinitionCollection { new RowDefinition { Height = GridLength.Star }, new RowDefinition { Height = GridLength.Star } }, ColumnDefinitions = new ColumnDefinitionCollection { new ColumnDefinition { Width = GridLength.Auto }, new ColumnDefinition { Width = GridLength.Star }, }, }; var heightRequestLabel = new Forms9Patch.Label("HeightRequest: " + 100); imposedHeightGrid.Children.Add(new Forms9Patch.Label("Impose Height?"), 0, 0); imposedHeightGrid.Children.Add(heightRequestLabel, 1, 0); imposedHeightGrid.Children.Add(imposeHeightSwitch, 0, 1); imposedHeightGrid.Children.Add(heightRequestSlider, 1, 1); imposeHeightSwitch.Toggled += (ihs, ihsArgs) => { double heightRequest = imposeHeightSwitch.IsToggled ? heightRequestSlider.Value : -1; frameForXF.HeightRequest = heightRequest; frameForF9P.HeightRequest = heightRequest; heightRequestSlider.IsVisible = imposeHeightSwitch.IsToggled; heightRequestLabel.IsVisible = imposeHeightSwitch.IsToggled; vtAlignmentSelector.IsVisible = imposeHeightSwitch.IsToggled; vtAlignmentSelectorLabel.IsVisible = imposeHeightSwitch.IsToggled; }; heightRequestSlider.ValueChanged += (hrs, hrsArgs) => { double heightRequest = imposeHeightSwitch.IsToggled ? heightRequestSlider.Value : -1; frameForXF.HeightRequest = heightRequest; frameForF9P.HeightRequest = heightRequest; heightRequestLabel.Text = "HeightRequest: " + heightRequestSlider.Value.ToString("####.###"); }; #endregion #region Font Size selection fontSizeSlider.ValueChanged += OnFontSizeSliderValueChanged; LineHeightSlider.ValueChanged += OnLineHeightSlider_ValueChanged; f9pLabel.FittedFontSizeChanged += (object sender, double e) => { fittedFontSizeLabel.Text = "FittedFontSize: " + e; }; #endregion #region Lines selection var linesLabel = new Label { Text = "Lines: 5" }; LinesSlider.ValueChanged += (sender, e) => { linesLabel.Text = "Lines: " + ((int)Math.Round(LinesSlider.Value)); f9pLabel.Lines = ((int)Math.Round(LinesSlider.Value)); }; #endregion #region AutoFit Selection var fitSelector = new Forms9Patch.SegmentedControl(); fitSelector.Segments.Add(new Forms9Patch.Segment { Text = "None", Command = new Command(x => { f9pLabel.AutoFit = Forms9Patch.AutoFit.None; }) }); var widthSegment = new Forms9Patch.Segment { Text = "Width", Command = new Command(x => { f9pLabel.AutoFit = Forms9Patch.AutoFit.Width; }), //IsEnabled = f9pLabel.HasImposedSize, //BindingContext = f9pLabel }; //widthSegment.SetBinding(Forms9Patch.Segment.IsEnabledProperty, "HasImposedSize"); fitSelector.Segments.Add(widthSegment); var linesSegment = new Forms9Patch.Segment { Text = "Lines", Command = new Command(x => { f9pLabel.AutoFit = Forms9Patch.AutoFit.Lines; }), //IsEnabled = f9pLabel.HasImposedSize, //BindingContext = f9pLabel }; //linesSegment.SetBinding(Forms9Patch.Segment.IsEnabledProperty, "HasImposedSize"); fitSelector.Segments.Add(linesSegment); fitSelector.SelectIndex(0); #endregion #region Alignment Selection hzAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "Start", Command = new Command(x => { f9pLabel.HorizontalTextAlignment = TextAlignment.Start; xfLabel.HorizontalTextAlignment = TextAlignment.Start; }) } ); hzAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "Center", Command = new Command(x => { f9pLabel.HorizontalTextAlignment = TextAlignment.Center; xfLabel.HorizontalTextAlignment = TextAlignment.Center; }) } ); hzAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "End", Command = new Command(x => { f9pLabel.HorizontalTextAlignment = TextAlignment.End; xfLabel.HorizontalTextAlignment = TextAlignment.End; }) } ); vtAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "Start", Command = new Command(x => { f9pLabel.VerticalTextAlignment = TextAlignment.Start; xfLabel.VerticalTextAlignment = TextAlignment.Start; }) } ); vtAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "Center", Command = new Command(x => { f9pLabel.VerticalTextAlignment = TextAlignment.Center; xfLabel.VerticalTextAlignment = TextAlignment.Center; }) } ); vtAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "End", Command = new Command(x => { f9pLabel.VerticalTextAlignment = TextAlignment.End; xfLabel.VerticalTextAlignment = TextAlignment.End; }) } ); hzAlignmentSelector.SelectIndex(0); vtAlignmentSelector.SelectIndex(0); #endregion #region BreakMode selection var breakModeSelector = new Forms9Patch.SegmentedControl(); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "NoWrap", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.NoWrap; xfLabel.LineBreakMode = LineBreakMode.NoWrap; }) } ); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "Char", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.CharacterWrap; xfLabel.LineBreakMode = LineBreakMode.CharacterWrap; }) } ); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "Word", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.WordWrap; xfLabel.LineBreakMode = LineBreakMode.WordWrap; }) } ); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "Head", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.HeadTruncation; xfLabel.LineBreakMode = LineBreakMode.HeadTruncation; }) } ); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "Mid", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.MiddleTruncation; xfLabel.LineBreakMode = LineBreakMode.MiddleTruncation; }) } ); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "Tail", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.TailTruncation; xfLabel.LineBreakMode = LineBreakMode.TailTruncation ; }) } ); breakModeSelector.SelectIndex(2); #endregion #region FontSelection Picker fontPicker = new Picker { Title = "Default", HorizontalOptions = LayoutOptions.EndAndExpand, }; var fontFamilies = Forms9Patch.FontExtensions.LoadedFontFamilies(); foreach (var fontFamily in fontFamilies) { fontPicker.Items.Add(fontFamily); } fontPicker.SelectedIndexChanged += (sender, e) => { if (fontPicker.SelectedIndex > -1 && fontPicker.SelectedIndex < fontFamilies.Count) { f9pLabel.FontFamily = fontFamilies[fontPicker.SelectedIndex]; xfLabel.FontFamily = fontFamilies[fontPicker.SelectedIndex]; } }; #endregion Content = new ScrollView { Padding = 0, Content = new StackLayout { Padding = 10, Children = { /* * new Label { Text = "Text:" }, * editor, */ new StackLayout { Orientation = StackOrientation.Horizontal, Children = { new Label { Text = "HTML Formatted:", HorizontalOptions = LayoutOptions.StartAndExpand, }, modeSwitch }, }, /* * new Label { Text = "Xamarin.Forms.Label:" }, * frameForXF, */ new Label { Text = "Forms9Patch.Label:" }, frameForF9P, LabelSizeLabel, new StackLayout { Orientation = StackOrientation.Horizontal, Children = { new Label { Text = "Font:", HorizontalOptions = LayoutOptions.Start }, fontPicker, } }, fontSizeLabel, fontSizeSlider, lineHeightLabel, LineHeightSlider, fittedFontSizeLabel, new Label { Text = "AutoFit:" }, fitSelector, linesLabel, LinesSlider, imposedHeightGrid, vtAlignmentSelectorLabel, vtAlignmentSelector, new Label { Text = "Horizontal Alignment:" }, hzAlignmentSelector, new Label { Text = "Truncation Mode:" }, breakModeSelector, } } }; SizeChanged += LabelAutoFitPage_SizeChanged; frameForF9P.SizeChanged += LabelAutoFitPage_SizeChanged; }
public NestedBubblePopupPage() { BackgroundColor = Color.White; //Padding = new Thickness(20, Device.RuntimePlatform == Device.iOS ? 20 : 0, 20, 20); var shadowToggle = new Switch(); var shadowInvertedToggle = new Switch(); var cornerRadiusSlider = new Slider { Maximum = 40, Minimum = 0, HeightRequest = 20, }; var pointerLengthSlider = new Slider { Maximum = 40, Minimum = 0, HeightRequest = 20, }; var pointerTipRadiusSlider = new Slider { Maximum = 20, Minimum = 0, HeightRequest = 20, }; var paddingSlider = new Slider { Maximum = 100, Minimum = 0, HeightRequest = 20, }; var pointerCornerRadiusSlider = new Slider { Maximum = 20, Minimum = 0, HeightRequest = 20, }; var leftSeg = new Forms9Patch.Segment { Text = "⬅︎", IsSelected = true, }; leftSeg.Tapped += (sender, e) => _lastChanged = leftSeg.VisualElement; var upSeg = new Forms9Patch.Segment { Text = "⬆︎", }; upSeg.Tapped += (sender, e) => _lastChanged = upSeg.VisualElement; var rightSeg = new Forms9Patch.Segment { Text = "➡︎", }; rightSeg.Tapped += (sender, e) => _lastChanged = rightSeg.VisualElement; var downSeg = new Forms9Patch.Segment { Text = "⬇︎", }; downSeg.Tapped += (sender, e) => _lastChanged = downSeg.VisualElement; var directionSegmentControl = new Forms9Patch.SegmentedControl { Segments = { leftSeg, upSeg, rightSeg, downSeg, }, GroupToggleBehavior = Forms9Patch.GroupToggleBehavior.Multiselect, }; var bubbleLabel = new Label { Text = "Forms9Patch.BubblePopup", TextColor = Color.Black, //BackgroundColor = Color.Green, }; var bubbleButton = new Forms9Patch.Button { Text = "Close", //BackgroundColor = Color.Blue, OutlineColor = Color.Blue, TextColor = Color.Blue, }; //bubbleLabel.SetBinding (Label.TextProperty, "CornerRadius"); bubbleLabel.BindingContext = this; var childBubbleButton = new Forms9Patch.Button("Show Child"); var bubble = new Forms9Patch.BubblePopup(this) { //BackgroundColor = Color.Green, //OutlineColor = Color.Black, //OutlineWidth = 1, Padding = 0, PointerCornerRadius = 0, Content = new StackLayout { Padding = 5, Children = { //bubbleLabel, childBubbleButton, bubbleButton, } }, }; cornerRadiusSlider.ValueChanged += (s, e) => bubble.OutlineRadius = (float)cornerRadiusSlider.Value; pointerLengthSlider.ValueChanged += (s, e) => bubble.PointerLength = (float)pointerLengthSlider.Value; pointerTipRadiusSlider.ValueChanged += (s, e) => bubble.PointerTipRadius = (float)pointerTipRadiusSlider.Value; shadowToggle.Toggled += (s, e) => bubble.HasShadow = shadowToggle.IsToggled; shadowInvertedToggle.Toggled += (s, e) => bubble.ShadowInverted = shadowInvertedToggle.IsToggled; pointerCornerRadiusSlider.ValueChanged += (s, e) => bubble.PointerCornerRadius = (float)pointerCornerRadiusSlider.Value; paddingSlider.ValueChanged += (s, e) => bubble.Padding = paddingSlider.Value; directionSegmentControl.SegmentTapped += (sender, e) => { var dir = Forms9Patch.PointerDirection.None; dir |= (leftSeg.IsSelected ? Forms9Patch.PointerDirection.Left : Forms9Patch.PointerDirection.None); dir |= (rightSeg.IsSelected ? Forms9Patch.PointerDirection.Right : Forms9Patch.PointerDirection.None); dir |= (upSeg.IsSelected ? Forms9Patch.PointerDirection.Up : Forms9Patch.PointerDirection.None); dir |= (downSeg.IsSelected ? Forms9Patch.PointerDirection.Down : Forms9Patch.PointerDirection.None); bubble.PointerDirection = dir; System.Diagnostics.Debug.WriteLine("Direction changed"); }; bubbleButton.Tapped += (sender, e) => bubble.IsVisible = false; childBubbleButton.Clicked += (sender, e) => { var newBubbleCancelButton = new Forms9Patch.Button { Text = "Close", OutlineColor = Color.Blue, TextColor = Color.Blue, }; var newbubble = new Forms9Patch.BubblePopup(bubble) { //BackgroundColor = Color.Green, //OutlineColor = Color.Black, //OutlineWidth = 1, //Target = childBubbleButton, //PointerCornerRadius = 0, PointerDirection = Forms9Patch.PointerDirection.Any, Content = new StackLayout { Children = { //bubbleLabel, new Label { Text = "Pointer Length:", FontSize = 10, }, pointerLengthSlider, new Label { Text = "Pointer Tip Radius:", FontSize = 10, }, pointerTipRadiusSlider, new Label { Text = "Corner Radius:", FontSize = 10, }, cornerRadiusSlider, new Label { Text = "Pointer Corner Radius:", FontSize = 10, }, pointerCornerRadiusSlider, newBubbleCancelButton, } }, }; newbubble.IsVisible = true; newBubbleCancelButton.Clicked += async(s1, e1) => { await newbubble.CancelAsync(); }; }; var showButton = new Forms9Patch.Button { Text = "Show BubblePopup", OutlineColor = Color.Blue, TextColor = Color.Blue, }; showButton.Tapped += (object sender, EventArgs e) => { bubble.Target = _lastChanged; bubble.IsVisible = true; }; _lastChanged = leftSeg.VisualElement; Content = new StackLayout { Children = { new StackLayout { Orientation = StackOrientation.Horizontal, Children = { new StackLayout { Children = { new Label { Text = "Has Shadow", FontSize = 10, }, shadowToggle, }, HorizontalOptions = LayoutOptions.StartAndExpand, }, new StackLayout { Children = { new Label { Text = "Inset Shadow", FontSize = 10, }, shadowInvertedToggle, }, HorizontalOptions = LayoutOptions.EndAndExpand, } } }, new Label { Text = "Padding:", FontSize = 10, }, paddingSlider, new Label { Text = "Pointer Direction", FontSize = 10, }, directionSegmentControl, showButton, new Label { Text = "Arrows choose the BubblePopup's allowed pointer direction. Bubble's pointer will point at the last selected arrow-segment-button." }, } }; }
public BubblePopupTestPage() { BackgroundColor = Color.White; Padding = new Thickness(20,Device.OnPlatform(20,0,0),20,20); var shadowToggle = new Switch (); shadowToggle.SetBinding (Switch.IsToggledProperty, "HasShadow"); shadowToggle.BindingContext = this; var shadowInvertedToggle = new Switch (); shadowInvertedToggle.SetBinding (Switch.IsToggledProperty, "ShadowInverted"); shadowInvertedToggle.BindingContext = this; var cornerRadiusSlider = new Slider { Maximum = 40, Minimum = 0, HeightRequest = 20, }; cornerRadiusSlider.SetBinding (Slider.ValueProperty, "CornerRadius"); cornerRadiusSlider.BindingContext = this; var pointerLengthSlider = new Slider { Maximum = 40, Minimum = 0, HeightRequest = 20, }; pointerLengthSlider.SetBinding (Slider.ValueProperty, "PointerLength"); pointerLengthSlider.BindingContext = this; var pointerTipRadiusSlider = new Slider { Maximum = 20, Minimum = 0, HeightRequest = 20, }; pointerTipRadiusSlider.SetBinding (Slider.ValueProperty, "PointerTipRadius"); pointerTipRadiusSlider.BindingContext = this; var paddingSlider = new Slider { Maximum = 100, Minimum = 0, HeightRequest = 20, }; paddingSlider.SetBinding (Slider.ValueProperty, "PUDPadding"); paddingSlider.BindingContext = this; var pointerCornerRadiusSlider = new Slider { Maximum = 20, Minimum = 0, HeightRequest = 20, }; pointerCornerRadiusSlider.SetBinding (Slider.ValueProperty, "PointerCornerRadius"); pointerCornerRadiusSlider.BindingContext = this; var leftSeg = new Forms9Patch.Segment { Text = "⬅︎", IsSelected = true, }; leftSeg.Tapped += (sender, e) => _lastChanged = leftSeg.VisualElement; var upSeg = new Forms9Patch.Segment { Text = "⬆︎", }; upSeg.Tapped += (sender, e) => _lastChanged = upSeg.VisualElement; var rightSeg = new Forms9Patch.Segment { Text = "➡︎", }; rightSeg.Tapped += (sender, e) => _lastChanged = rightSeg.VisualElement; var downSeg = new Forms9Patch.Segment { Text = "⬇︎", }; downSeg.Tapped += (sender, e) => _lastChanged = downSeg.VisualElement; PointerDirection = Forms9Patch.PointerDirection.Left; var directionSegmentControl = new Forms9Patch.MaterialSegmentedControl { Segments = { leftSeg, upSeg, rightSeg, downSeg, }, GroupToggleBehavior = Forms9Patch.GroupToggleBehavior.Multiselect, }; directionSegmentControl.SegmentTapped += (sender,e) => { var dir = Forms9Patch.PointerDirection.None; dir |= (leftSeg.IsSelected ? Forms9Patch.PointerDirection.Left : Forms9Patch.PointerDirection.None); dir |= (rightSeg.IsSelected ? Forms9Patch.PointerDirection.Right : Forms9Patch.PointerDirection.None); dir |= (upSeg.IsSelected ? Forms9Patch.PointerDirection.Up : Forms9Patch.PointerDirection.None); dir |= (downSeg.IsSelected ? Forms9Patch.PointerDirection.Down : Forms9Patch.PointerDirection.None); PointerDirection = dir; System.Diagnostics.Debug.WriteLine("Direction changed"); }; var bubbleLabel = new Label { Text = "Forms9Patch.BubblePopup", TextColor = Color.Black, //BackgroundColor = Color.Green, }; var bubbleButton = new Forms9Patch.MaterialButton { Text = "Close", //BackgroundColor = Color.Blue, OutlineColor = Color.Blue, FontColor = Color.Blue, }; //bubbleLabel.SetBinding (Label.TextProperty, "CornerRadius"); bubbleLabel.BindingContext = this; var bubble = new Forms9Patch.BubblePopup { //BackgroundColor = Color.Green, //OutlineColor = Color.Black, //OutlineWidth = 1, PointerCornerRadius = 0, Content = new StackLayout { Children = { //bubbleLabel, new Label { Text = "Pointer Length:", FontSize=10, }, pointerLengthSlider, new Label { Text = "Pointer Tip Radius:", FontSize=10, }, pointerTipRadiusSlider, new Label { Text = "Corner Radius:" , FontSize=10, }, cornerRadiusSlider, new Label { Text = "Pointer Corner Radius:" , FontSize=10, }, pointerCornerRadiusSlider, bubbleButton, } }, }; bubble.SetBinding (Forms9Patch.BubblePopup.OutlineRadiusProperty, "CornerRadius"); bubble.SetBinding (Forms9Patch.BubblePopup.PointerLengthProperty, "PointerLength"); bubble.SetBinding (Forms9Patch.BubblePopup.PointerTipRadiusProperty, "PointerTipRadius"); bubble.SetBinding (Forms9Patch.BubblePopup.PaddingProperty, "PUPadding"); bubble.SetBinding (Forms9Patch.BubblePopup.HasShadowProperty, "HasShadow"); bubble.SetBinding (Forms9Patch.BubblePopup.ShadowInvertedProperty, "ShadowInverted"); bubble.SetBinding (Forms9Patch.BubblePopup.PointerDirectionProperty, "PointerDirection"); bubble.SetBinding (Forms9Patch.BubblePopup.PointerCornerRadiusProperty, "PointerCornerRadius"); bubble.BindingContext = this; bubbleButton.Tapped += (sender, e) => bubble.IsVisible = false; var showButton = new Forms9Patch.MaterialButton { Text = "Show BubblePopup", OutlineColor = Color.Blue, FontColor = Color.Blue, }; showButton.Tapped += (object sender, EventArgs e) => { bubble.Target = _lastChanged; bubble.IsVisible = true; }; _lastChanged = leftSeg.VisualElement; Content = new StackLayout { Children = { new StackLayout { Orientation = StackOrientation.Horizontal, Children = { new StackLayout { Children = { new Label { Text = "Has Shadow", FontSize=10, }, shadowToggle, }, HorizontalOptions = LayoutOptions.StartAndExpand, }, new StackLayout { Children = { new Label { Text = "Inset Shadow", FontSize=10, }, shadowInvertedToggle, }, HorizontalOptions = LayoutOptions.EndAndExpand, } } }, new Label { Text = "Padding:", FontSize=10, }, paddingSlider, new Label { Text = "Pointer Direction", FontSize=10, }, directionSegmentControl, showButton, new Label { Text = "Arrows choose the BubblePopup's allowed pointer direction. Bubble's pointer will point at the last selected arrow-segment-button." }, } }; }
public BubblePopupTestPage() { BackgroundColor = Color.White; Padding = new Thickness(20, Device.OnPlatform(20, 0, 0), 20, 20); var shadowToggle = new Switch(); shadowToggle.SetBinding(Switch.IsToggledProperty, "HasShadow"); shadowToggle.BindingContext = this; var shadowInvertedToggle = new Switch(); shadowInvertedToggle.SetBinding(Switch.IsToggledProperty, "ShadowInverted"); shadowInvertedToggle.BindingContext = this; var cornerRadiusSlider = new Slider { Maximum = 40, Minimum = 0, HeightRequest = 20, }; cornerRadiusSlider.SetBinding(Slider.ValueProperty, "CornerRadius"); cornerRadiusSlider.BindingContext = this; var pointerLengthSlider = new Slider { Maximum = 40, Minimum = 0, HeightRequest = 20, }; pointerLengthSlider.SetBinding(Slider.ValueProperty, "PointerLength"); pointerLengthSlider.BindingContext = this; var pointerTipRadiusSlider = new Slider { Maximum = 20, Minimum = 0, HeightRequest = 20, }; pointerTipRadiusSlider.SetBinding(Slider.ValueProperty, "PointerTipRadius"); pointerTipRadiusSlider.BindingContext = this; var paddingSlider = new Slider { Maximum = 100, Minimum = 0, HeightRequest = 20, }; paddingSlider.SetBinding(Slider.ValueProperty, "PUDPadding"); paddingSlider.BindingContext = this; var pointerCornerRadiusSlider = new Slider { Maximum = 20, Minimum = 0, HeightRequest = 20, }; pointerCornerRadiusSlider.SetBinding(Slider.ValueProperty, "PointerCornerRadius"); pointerCornerRadiusSlider.BindingContext = this; var leftSeg = new Forms9Patch.Segment { Text = "⬅︎", IsSelected = true, }; leftSeg.Tapped += (sender, e) => _lastChanged = leftSeg.VisualElement; var upSeg = new Forms9Patch.Segment { Text = "⬆︎", }; upSeg.Tapped += (sender, e) => _lastChanged = upSeg.VisualElement; var rightSeg = new Forms9Patch.Segment { Text = "➡︎", }; rightSeg.Tapped += (sender, e) => _lastChanged = rightSeg.VisualElement; var downSeg = new Forms9Patch.Segment { Text = "⬇︎", }; downSeg.Tapped += (sender, e) => _lastChanged = downSeg.VisualElement; PointerDirection = Forms9Patch.PointerDirection.Left; var directionSegmentControl = new Forms9Patch.MaterialSegmentedControl { Segments = { leftSeg, upSeg, rightSeg, downSeg, }, StickyBehavior = Forms9Patch.SegmentControlStickyBehavior.Multiselect, }; directionSegmentControl.SegmentTapped += (sender, e) => { var dir = Forms9Patch.PointerDirection.None; dir |= (leftSeg.IsSelected ? Forms9Patch.PointerDirection.Left : Forms9Patch.PointerDirection.None); dir |= (rightSeg.IsSelected ? Forms9Patch.PointerDirection.Right : Forms9Patch.PointerDirection.None); dir |= (upSeg.IsSelected ? Forms9Patch.PointerDirection.Up : Forms9Patch.PointerDirection.None); dir |= (downSeg.IsSelected ? Forms9Patch.PointerDirection.Down : Forms9Patch.PointerDirection.None); PointerDirection = dir; System.Diagnostics.Debug.WriteLine("Direction changed"); }; var bubbleLabel = new Label { Text = "Forms9Patch.BubblePopup", TextColor = Color.Black, //BackgroundColor = Color.Green, }; var bubbleButton = new Forms9Patch.MaterialButton { Text = "Close", //BackgroundColor = Color.Blue, OutlineColor = Color.Blue, FontColor = Color.Blue, }; //bubbleLabel.SetBinding (Label.TextProperty, "CornerRadius"); bubbleLabel.BindingContext = this; var bubble = new Forms9Patch.BubblePopup { //BackgroundColor = Color.Green, //OutlineColor = Color.Black, //OutlineWidth = 1, PointerCornerRadius = 0, Content = new StackLayout { Children = { //bubbleLabel, new Label { Text = "Pointer Length:", FontSize = 10, }, pointerLengthSlider, new Label { Text = "Pointer Tip Radius:", FontSize = 10, }, pointerTipRadiusSlider, new Label { Text = "Corner Radius:", FontSize = 10, }, cornerRadiusSlider, new Label { Text = "Pointer Corner Radius:", FontSize = 10, }, pointerCornerRadiusSlider, bubbleButton, } }, }; bubble.SetBinding(Forms9Patch.BubblePopup.OutlineRadiusProperty, "CornerRadius"); bubble.SetBinding(Forms9Patch.BubblePopup.PointerLengthProperty, "PointerLength"); bubble.SetBinding(Forms9Patch.BubblePopup.PointerTipRadiusProperty, "PointerTipRadius"); bubble.SetBinding(Forms9Patch.BubblePopup.PaddingProperty, "PUPadding"); bubble.SetBinding(Forms9Patch.BubblePopup.HasShadowProperty, "HasShadow"); bubble.SetBinding(Forms9Patch.BubblePopup.ShadowInvertedProperty, "ShadowInverted"); bubble.SetBinding(Forms9Patch.BubblePopup.PointerDirectionProperty, "PointerDirection"); bubble.SetBinding(Forms9Patch.BubblePopup.PointerCornerRadiusProperty, "PointerCornerRadius"); bubble.BindingContext = this; bubbleButton.Tapped += (sender, e) => bubble.IsVisible = false; var showButton = new Forms9Patch.MaterialButton { Text = "Show BubblePopup", OutlineColor = Color.Blue, FontColor = Color.Blue, }; showButton.Tapped += (object sender, EventArgs e) => { bubble.Target = _lastChanged; bubble.IsVisible = true; }; _lastChanged = leftSeg.VisualElement; Content = new StackLayout { Children = { new StackLayout { Orientation = StackOrientation.Horizontal, Children = { new StackLayout { Children = { new Label { Text = "Has Shadow", FontSize = 10, }, shadowToggle, }, HorizontalOptions = LayoutOptions.StartAndExpand, }, new StackLayout { Children = { new Label { Text = "Inset Shadow", FontSize = 10, }, shadowInvertedToggle, }, HorizontalOptions = LayoutOptions.EndAndExpand, } } }, new Label { Text = "Padding:", FontSize = 10, }, paddingSlider, new Label { Text = "Pointer Direction", FontSize = 10, }, directionSegmentControl, showButton, new Label { Text = "Arrows choose the BubblePopup's allowed pointer direction. Bubble's pointer will point at the last selected arrow-segment-button." }, } }; }
public LabelFitPage() { BackgroundColor = Color.Gray; Padding = 0; #region Editor var editor = new Editor { //Text = "Żorem ipsum dolor sit amet, consectetur adięiscing ełit", Text = text1, TextColor = Color.White, BackgroundColor = Color.Black, HeightRequest = 130, FontSize = 15, }; editor.Effects.Add(Effect.Resolve("Forms9Patch.CustomFontEffect")); #endregion #region Xamarin Forms label var xfLabel = new Label { FontSize = 15, TextColor = Color.White, BackgroundColor = Color.Black, Text = editor.Text }; #endregion #region Forms9Patch Label var f9pLabel = new Forms9Patch.Label { //HeightRequest = 50, Lines = 5, FontSize = 15, TextColor = Color.White, Fit = Forms9Patch.LabelFit.None, BackgroundColor = Color.Black, Text = editor.Text }; #endregion #region Mode var modeSwitch = new Switch { IsToggled = false, HorizontalOptions = LayoutOptions.End, }; modeSwitch.Toggled += (sender, e) => { if (modeSwitch.IsToggled) { f9pLabel.HtmlText = editor.Text; } else { f9pLabel.Text = editor.Text; } }; #endregion #region Sync text between Editor and Labels editor.TextChanged += (sender, e) => { xfLabel.Text = editor.Text; f9pLabel.HtmlText = editor.Text; }; #endregion #region Frames for Labels var frameForF9P = new Frame { HeightRequest = 100, WidthRequest = 200, Padding = 0, Content = f9pLabel }; var frameForXF = new Frame { HeightRequest = 100, WidthRequest = 200, Padding = 0, Content = xfLabel }; #endregion #region Font Size selection var fontSizeSlider = new Slider { Maximum = 104, Minimum = 4, Value = 15 }; var fontSizeLabel = new Label { Text = "Font Size: 15" }; fontSizeSlider.ValueChanged += (sender, e) => { fontSizeLabel.Text = "Font Size: " + fontSizeSlider.Value; f9pLabel.FontSize = fontSizeSlider.Value; if (!rendering) { rendering = true; xfLabel.FontSize = fontSizeSlider.Value; Device.StartTimer(TimeSpan.FromMilliseconds(50), () => { if (Math.Abs(xfLabel.FontSize - lastFontSize) > double.Epsilon * 5) { xfLabel.FontSize = lastFontSize; return(true); } rendering = false; return(false); }); } lastFontSize = fontSizeSlider.Value; }; var actualFontSizeLabel = new Label { Text = "Actual Font Size: 15" }; f9pLabel.PropertyChanged += (sender, e) => { if (e.PropertyName == Forms9Patch.Label.ActualFontSizeProperty.PropertyName) { actualFontSizeLabel.Text = "ActualFontSize: " + f9pLabel.ActualFontSize; } }; #endregion #region Lines selection var linesLabel = new Label { Text = "Lines: 5" }; var linesSlider = new Slider { Minimum = 0, Maximum = 8, Value = 5 }; linesSlider.ValueChanged += (sender, e) => { linesLabel.Text = "Lines: " + ((int)Math.Round(linesSlider.Value)); f9pLabel.Lines = ((int)Math.Round(linesSlider.Value)); }; #endregion #region Fit Selection var fitSelector = new Forms9Patch.MaterialSegmentedControl(); fitSelector.Segments.Add(new Forms9Patch.Segment { Text = "None", Command = new Command(x => { f9pLabel.Fit = Forms9Patch.LabelFit.None; }) }); var widthSegment = new Forms9Patch.Segment { Text = "Width", Command = new Command(x => { f9pLabel.Fit = Forms9Patch.LabelFit.Width; }), //IsEnabled = f9pLabel.HasImposedSize, BindingContext = f9pLabel }; widthSegment.SetBinding(Forms9Patch.Segment.IsEnabledProperty, "HasImposedSize"); fitSelector.Segments.Add(widthSegment); var linesSegment = new Forms9Patch.Segment { Text = "Lines", Command = new Command(x => { f9pLabel.Fit = Forms9Patch.LabelFit.Lines; }), //IsEnabled = f9pLabel.HasImposedSize, BindingContext = f9pLabel }; linesSegment.SetBinding(Forms9Patch.Segment.IsEnabledProperty, "HasImposedSize"); fitSelector.Segments.Add(linesSegment); fitSelector.SelectIndex(0); #endregion #region Alignment Selection var hzAlignmentSelector = new Forms9Patch.MaterialSegmentedControl(); var vtAlignmentSelector = new Forms9Patch.MaterialSegmentedControl(); hzAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "Start", Command = new Command(x => { f9pLabel.HorizontalTextAlignment = TextAlignment.Start; xfLabel.HorizontalTextAlignment = TextAlignment.Start; }) } ); hzAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "Center", Command = new Command(x => { f9pLabel.HorizontalTextAlignment = TextAlignment.Center; xfLabel.HorizontalTextAlignment = TextAlignment.Center; }) } ); hzAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "End", Command = new Command(x => { f9pLabel.HorizontalTextAlignment = TextAlignment.End; xfLabel.HorizontalTextAlignment = TextAlignment.End; }) } ); vtAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "Start", Command = new Command(x => { f9pLabel.VerticalTextAlignment = TextAlignment.Start; xfLabel.VerticalTextAlignment = TextAlignment.Start; }) } ); vtAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "Center", Command = new Command(x => { f9pLabel.VerticalTextAlignment = TextAlignment.Center; xfLabel.VerticalTextAlignment = TextAlignment.Center; }) } ); vtAlignmentSelector.Segments.Add( new Forms9Patch.Segment { Text = "End", Command = new Command(x => { f9pLabel.VerticalTextAlignment = TextAlignment.End; xfLabel.VerticalTextAlignment = TextAlignment.End; }) } ); hzAlignmentSelector.SelectIndex(0); vtAlignmentSelector.SelectIndex(0); #endregion #region BreakMode selection var breakModeSelector = new Forms9Patch.MaterialSegmentedControl(); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "NoWrap", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.NoWrap; xfLabel.LineBreakMode = LineBreakMode.NoWrap; }) } ); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "Char", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.CharacterWrap; xfLabel.LineBreakMode = LineBreakMode.CharacterWrap; }) } ); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "Word", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.WordWrap; xfLabel.LineBreakMode = LineBreakMode.WordWrap; }) } ); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "Head", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.HeadTruncation; xfLabel.LineBreakMode = LineBreakMode.HeadTruncation; }) } ); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "Mid", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.MiddleTruncation; xfLabel.LineBreakMode = LineBreakMode.MiddleTruncation; }) } ); breakModeSelector.Segments.Add( new Forms9Patch.Segment { Text = "Tail", Command = new Command(x => { f9pLabel.LineBreakMode = LineBreakMode.TailTruncation; xfLabel.LineBreakMode = LineBreakMode.TailTruncation ; }) } ); breakModeSelector.SelectIndex(2); #endregion #region FontSelection /* * var fontSelector = new Forms9Patch.MaterialSegmentedControl(); * fontSelector.Segments.Add( * new Forms9Patch.Segment * { * Text = "System", * Command = new Command(x => * { * f9pLabel.FontFamily = null; * xfLabel.FontFamily = null; * }) * } * ); * fontSelector.Segments.Add( * new Forms9Patch.Segment * { * Text = Device.OnPlatform("Menlo","thin",""), * Command = new Command(x => * { * f9pLabel.FontFamily = Device.OnPlatform("Menlo", "sans-serif-thin", ""); * xfLabel.FontFamily = Device.OnPlatform("Menlo", "sans-serif-thin", ""); * }) * } * ); * fontSelector.Segments.Add( * new Forms9Patch.Segment * { * Text = Device.OnPlatform("Typewriter", "light", ""), * Command = new Command(x => * { * f9pLabel.FontFamily = Device.OnPlatform("American Typewriter","sans-serif-light",""); * xfLabel.FontFamily = Device.OnPlatform("American Typewriter", "sans-serif-light", ""); * }) * } * ); * fontSelector.Segments.Add( * new Forms9Patch.Segment * { * Text = Device.OnPlatform("Chalkboard","condensed",""), * Command = new Command(x => * { * f9pLabel.FontFamily = Device.OnPlatform("Chalkboard SE","sans-serif-condensed",""); * xfLabel.FontFamily = Device.OnPlatform("Chalkboard SE", "sans-serif-condensed", ""); * }) * } * ); * fontSelector.Segments.Add( * new Forms9Patch.Segment * { * Text = Device.OnPlatform("Zapfino", "medium", ""), * Command = new Command(x => * { * f9pLabel.FontFamily = Device.OnPlatform("Zapfino","sans-serif-medium",""); * xfLabel.FontFamily = Device.OnPlatform("Zapfino", "sans-serif-medium", ""); * }) * } * ); * fontSelector.SelectIndex(0); */ Picker fontPicker = new Picker { Title = "Default", //HeightRequest = 300, //VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.EndAndExpand, }; var fontFamilies = Forms9Patch.FontExtensions.LoadedFontFamilies(); foreach (var fontFamily in fontFamilies) { fontPicker.Items.Add(fontFamily); } fontPicker.SelectedIndexChanged += (sender, e) => { string family = null; if (fontPicker.SelectedIndex > -1 && fontPicker.SelectedIndex < fontFamilies.Count) { f9pLabel.FontFamily = fontFamilies[fontPicker.SelectedIndex]; xfLabel.FontFamily = fontFamilies[fontPicker.SelectedIndex]; editor.FontFamily = fontFamilies[fontPicker.SelectedIndex]; } }; #endregion Content = new ScrollView { Padding = 0, Content = new StackLayout { Padding = 20, Children = { new Label { Text = "Text:" }, editor, new StackLayout { Orientation = StackOrientation.Horizontal, Children = { new Label { Text = "HTML Formatted:", HorizontalOptions = LayoutOptions.StartAndExpand, }, modeSwitch }, }, //new Label { Text = "Xamarin.Forms.Label:" }, //frameForXF, new Label { Text = "Forms9Patch.Label:" }, //label, frameForF9P, new Label { Text = "Font Family:", HorizontalOptions = LayoutOptions.Start }, fontPicker, fontSizeLabel, fontSizeSlider, actualFontSizeLabel, new Label { Text = "Fit:" }, fitSelector, linesLabel, linesSlider, new Label { Text = "Horizontal Alignment:" }, hzAlignmentSelector, new Label { Text = "Vertical Alignment:" }, vtAlignmentSelector, new Label { Text = "Truncation Mode:" }, breakModeSelector, } } }; }
public MaterialButtonsPage() { var infoIcon = Forms9Patch.ImageSource.FromMultiResource("Forms9PatchDemo.Resources.Info"); var arrowIcon = Forms9Patch.ImageSource.FromMultiResource("Forms9PatchDemo.Resources.ArrowR"); #region Material Buttons var grid = new Grid { RowDefinitions = { new RowDefinition { Height = GridLength.Auto }, }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, }, }; var mb1 = new Forms9Patch.MaterialButton { Text = "", ImageSource = arrowIcon, }; mb1.Tapped += OnMaterialButtonTapped; mb1.Selected += OnMaterialButtonSelected; mb1.LongPressing += OnMaterialButtonLongPressing; mb1.LongPressed += OnMaterialButtonLongPressed; var mb2 = new Forms9Patch.MaterialButton { //Text = "toggle", ToggleBehavior = true, ImageSource = infoIcon, }; mb2.Tapped += OnMaterialButtonTapped; mb2.Selected += OnMaterialButtonSelected; mb2.LongPressing += OnMaterialButtonLongPressing; mb2.LongPressed += OnMaterialButtonLongPressed; var mb3 = new Forms9Patch.MaterialButton { //Text = "disabled", ToggleBehavior = true, IsEnabled = false, ImageSource = arrowIcon, }; mb3.Tapped += OnMaterialButtonTapped; mb3.Selected += OnMaterialButtonSelected; mb3.LongPressing += OnMaterialButtonLongPressing; mb3.LongPressed += OnMaterialButtonLongPressed; var mb4 = new Forms9Patch.MaterialButton { //Text = "selected disabled", IsEnabled = false, IsSelected = true, ImageSource = infoIcon, }; mb4.Tapped += OnMaterialButtonTapped; mb4.Selected += OnMaterialButtonSelected; mb4.LongPressing += OnMaterialButtonLongPressing; mb4.LongPressed += OnMaterialButtonLongPressed; var label1 = new Label { Text = "Gesture Label", BackgroundColor = Color.Blue, HeightRequest = 50, }; var label1Listener = new FormsGestures.Listener (label1); label1Listener.Tapped += (sender, e) => System.Diagnostics.Debug.WriteLine($"Tapped:{((Label)sender).Text}"); label1Listener.DoubleTapped += (sender, e) => System.Diagnostics.Debug.WriteLine($"DoubleTapped:{((Label)sender).Text}"); label1Listener.LongPressing += (sender, e) => System.Diagnostics.Debug.WriteLine($"LongPressing:{((Label)sender).Text}"); // How to remove a listener! label1Listener.LongPressed += (sender, e) => { label1Listener.Dispose(); System.Diagnostics.Debug.WriteLine("Removed FormsGestures.Listener"); }; grid.Children.Add (new StackLayout { BackgroundColor = Color.FromHex("#33FF33"), Padding = new Thickness(10), Children = { new Label { Text = "Default, Light", TextColor = Color.Black, }, mb1,mb2, mb3, mb4, new Label { Text = "Outline, Light", TextColor = Color.Black, }, new Forms9Patch.MaterialButton { Text = "", ImageSource = arrowIcon, OutlineWidth = 0, }, new Forms9Patch.MaterialButton { //Text = "toggle", ToggleBehavior = true, ImageSource = infoIcon, OutlineWidth = 0, }, new Forms9Patch.MaterialButton { //Text = "disabled", ToggleBehavior = true, IsEnabled = false, ImageSource = arrowIcon, OutlineWidth = 0, }, new Forms9Patch.MaterialButton { //Text = "selected disabled", IsEnabled = false, IsSelected = true, ImageSource = infoIcon, OutlineWidth = 0, }, new Label { Text = "Background Color, Light Theme", TextColor = Color.Black, }, new Forms9Patch.MaterialButton { Text = "default", BackgroundColor = Color.FromHex("#E0E0E0"), ImageSource = arrowIcon, Orientation = StackOrientation.Vertical, }, new Forms9Patch.MaterialButton { Text = "toggle", ToggleBehavior = true, BackgroundColor = Color.FromHex("#E0E0E0"), ImageSource = infoIcon, }, new Forms9Patch.MaterialButton { Text = "disabled", ToggleBehavior = true, IsEnabled = false, BackgroundColor = Color.FromHex("#E0E0E0"), ImageSource = arrowIcon, }, new Forms9Patch.MaterialButton { Text = "selected disabled", IsEnabled = false, IsSelected = true, BackgroundColor = Color.FromHex("#E0E0E0"), ImageSource = infoIcon, }, new Label { Text = "Shadow, Light Theme", TextColor = Color.Black, }, new Forms9Patch.MaterialButton { Text = "default", HasShadow = true, ImageSource = infoIcon, }, new Forms9Patch.MaterialButton { Text = "toggle", ToggleBehavior = true, HasShadow = true, ImageSource = arrowIcon, }, new Forms9Patch.MaterialButton { Text = "disabled", ToggleBehavior = true, IsEnabled = false, HasShadow = true, ImageSource = infoIcon, }, new Forms9Patch.MaterialButton { Text = "selected disabled", IsEnabled = false, IsSelected = true, HasShadow = true, ImageSource = arrowIcon, }, new Label { Text = "Shadow Background Color, Light Theme", TextColor = Color.Black, }, new Forms9Patch.MaterialButton { Text = "default", BackgroundColor = Color.FromHex("#E0E0E0"), HasShadow = true, ImageSource = infoIcon, }, new Forms9Patch.MaterialButton { Text = "toggle", ToggleBehavior = true, BackgroundColor = Color.FromHex("#E0E0E0"), HasShadow = true, ImageSource = arrowIcon, }, new Forms9Patch.MaterialButton { Text = "disabled", ToggleBehavior = true, IsEnabled = false, BackgroundColor = Color.FromHex("#E0E0E0"), HasShadow = true, ImageSource = infoIcon, }, new Forms9Patch.MaterialButton { Text = "selected disabled", IsEnabled = false, IsSelected = true, BackgroundColor = Color.FromHex("#E0E0E0"), HasShadow = true, ImageSource = arrowIcon, }, }, }, 0, 0); grid.Children.Add(new StackLayout { Padding = new Thickness(10), BackgroundColor = Color.FromHex("#003"), Children = { new Label { Text = "Default, Dark Theme", TextColor = Color.White, }, new Forms9Patch.MaterialButton { Text = "default", DarkTheme = true, }, new Forms9Patch.MaterialButton { Text = "toggle", ToggleBehavior = true, DarkTheme = true, }, new Forms9Patch.MaterialButton { Text = "disabled", ToggleBehavior = true, IsEnabled = false, DarkTheme = true, }, new Forms9Patch.MaterialButton { Text = "selected disabled", IsEnabled = false, IsSelected = true, DarkTheme = true, }, new Label { Text = "Outline, Dark Theme", TextColor = Color.White, }, new Forms9Patch.MaterialButton { Text = "default", DarkTheme = true, OutlineWidth = 0, }, new Forms9Patch.MaterialButton { Text = "toggle", ToggleBehavior = true, DarkTheme = true, OutlineWidth = 0, }, new Forms9Patch.MaterialButton { Text = "disabled", ToggleBehavior = true, IsEnabled = false, DarkTheme = true, OutlineWidth = 0, }, new Forms9Patch.MaterialButton { Text = "selected disabled", IsEnabled = false, IsSelected = true, DarkTheme = true, OutlineWidth = 0, }, new Label { Text = "Background Color, Dark Theme", TextColor = Color.White, }, new Forms9Patch.MaterialButton { Text = "default", BackgroundColor = Color.FromHex("#1194F6"), DarkTheme = true, ImageSource = arrowIcon, Orientation = StackOrientation.Vertical, }, new Forms9Patch.MaterialButton { Text = "toggle", ToggleBehavior = true, BackgroundColor = Color.FromHex("#1194F6"), DarkTheme = true, }, new Forms9Patch.MaterialButton { Text = "disabled", ToggleBehavior = true, IsEnabled = false, BackgroundColor = Color.FromHex("#1194F6"), DarkTheme = true, }, new Forms9Patch.MaterialButton { Text = "selected disabled", IsEnabled = false, IsSelected = true, BackgroundColor = Color.FromHex("#1194F6"), DarkTheme = true, }, new Label { Text = "Shadow, Dark Theme", TextColor = Color.White, }, new Forms9Patch.MaterialButton { Text = "default", DarkTheme = true, HasShadow = true, }, new Forms9Patch.MaterialButton { Text = "toggle", ToggleBehavior = true, DarkTheme = true, HasShadow = true, }, new Forms9Patch.MaterialButton { Text = "disabled", ToggleBehavior = true, IsEnabled = false, DarkTheme = true, HasShadow = true, }, new Forms9Patch.MaterialButton { Text = "selected disabled", IsEnabled = false, IsSelected = true, DarkTheme = true, HasShadow = true, }, new Label { Text = "Shadow Background Color, Dark Theme", TextColor = Color.White, }, new Forms9Patch.MaterialButton { Text = "default", BackgroundColor = Color.FromHex("#1194F6"), DarkTheme = true, HasShadow = true, }, new Forms9Patch.MaterialButton { Text = "toggle", ToggleBehavior = true, BackgroundColor = Color.FromHex("#1194F6"), DarkTheme = true, HasShadow = true, }, new Forms9Patch.MaterialButton { Text = "disabled", ToggleBehavior = true, IsEnabled = false, BackgroundColor = Color.FromHex("#1194F6"), DarkTheme = true, HasShadow = true, }, new Forms9Patch.MaterialButton { Text = "selected disabled", IsEnabled = false, IsSelected = true, BackgroundColor = Color.FromHex("#1194F6"), DarkTheme = true, HasShadow = true, }, }, },1,0); #endregion #region Light SegmentedControl var sc1 = new Forms9Patch.MaterialSegmentedControl { Segments = { new Forms9Patch.Segment { Text = "A", ImageSource = arrowIcon, Command = _trueCommand, CommandParameter = "sc1 A", }, new Forms9Patch.Segment { //Text = "B", IsSelected = true, ImageSource = arrowIcon, Command = _trueCommand, CommandParameter = "sc1 B", }, new Forms9Patch.Segment { Text = "C", Command = _trueCommand, CommandParameter = "sc1 C", }, new Forms9Patch.Segment { Text = "D", //IsEnabled = false, Command = _falseCommand, CommandParameter = "sc1 D", }, }, }; sc1.SegmentSelected += OnSegmentSelected; sc1.SegmentTapped += OnSegmentTapped; sc1.SegmentLongPressing += OnSegmentLongPressing; sc1.SegmentLongPressed += OnSegmentLongPressed; var seg1 = new Forms9Patch.Segment { //Text = "A", ImageSource = arrowIcon, }; seg1.Tapped += OnMaterialButtonTapped; seg1.Selected += OnMaterialButtonTapped; seg1.LongPressing += OnMaterialButtonLongPressing; seg1.LongPressed += OnMaterialButtonLongPressed; var seg2 = new Forms9Patch.Segment { Text = "B", IsSelected = true, }; seg2.Tapped += OnMaterialButtonTapped; seg2.Selected += OnMaterialButtonTapped; seg2.LongPressing += OnMaterialButtonLongPressing; seg2.LongPressed += OnMaterialButtonLongPressed; var seg3 = new Forms9Patch.Segment { Text = "C", }; seg3.Tapped += OnMaterialButtonTapped; seg3.Selected += OnMaterialButtonTapped; seg3.LongPressing += OnMaterialButtonLongPressing; seg3.LongPressed += OnMaterialButtonLongPressed; var seg4 = new Forms9Patch.Segment { Text = "D", IsEnabled = false, }; seg4.Tapped += OnMaterialButtonTapped; seg4.Selected += OnMaterialButtonTapped; seg4.LongPressing += OnMaterialButtonLongPressing; seg4.LongPressed += OnMaterialButtonLongPressed; var sc2 = new Forms9Patch.MaterialSegmentedControl { OutlineWidth = 0, Segments = { seg1, seg2, seg3, seg4, }, }; sc2.SegmentSelected += OnSegmentSelected; sc2.SegmentTapped += OnSegmentTapped; sc2.SegmentLongPressing += OnSegmentLongPressing; sc2.SegmentLongPressed += OnSegmentLongPressed; var sc3 = new Forms9Patch.MaterialSegmentedControl { //OutlineColor = Color.Transparent, BackgroundColor = Color.FromHex("#E0E0E0"), Segments = { new Forms9Patch.Segment { Text = "A", }, new Forms9Patch.Segment { Text = "B", IsSelected = true, }, new Forms9Patch.Segment { Text = "C", }, new Forms9Patch.Segment { //Text = "D", IsEnabled = false, ImageSource = arrowIcon, }, }, }; sc3.SegmentSelected += OnSegmentSelected; sc3.SegmentTapped += OnSegmentTapped; sc3.SegmentLongPressing += OnSegmentLongPressing; sc3.SegmentLongPressed += OnSegmentLongPressed; var sc4 = new Forms9Patch.MaterialSegmentedControl { BackgroundColor = Color.FromHex("#E0E0E0"), OutlineWidth = 0, SeparatorWidth = 1, GroupToggleBehavior = Forms9Patch.GroupToggleBehavior.None, Segments = { new Forms9Patch.Segment { Text = "A", ImageSource = arrowIcon, Orientation = StackOrientation.Vertical, }, new Forms9Patch.Segment { Text = "B", IsSelected = true, ImageSource = infoIcon, Orientation = StackOrientation.Vertical, }, new Forms9Patch.Segment { Text = "C", ImageSource = arrowIcon, }, new Forms9Patch.Segment { Text = "D", IsEnabled = false, ImageSource = infoIcon, Orientation = StackOrientation.Vertical, }, }, }; sc4.SegmentSelected += OnSegmentSelected; sc4.SegmentTapped += OnSegmentTapped; sc4.SegmentLongPressing += OnSegmentLongPressing; sc4.SegmentLongPressed += OnSegmentLongPressed; var sc5 = new Forms9Patch.MaterialSegmentedControl { BackgroundColor = Color.FromHex("#E0E0E0"), HasShadow = true, //OutlineRadius = 0, //OutlineWidth = 0, Orientation = StackOrientation.Vertical, GroupToggleBehavior = Forms9Patch.GroupToggleBehavior.Multiselect, Segments = { new Forms9Patch.Segment { Text = "A", ImageSource = arrowIcon, }, new Forms9Patch.Segment { Text = "B", IsSelected = true, }, new Forms9Patch.Segment { Text = "C", }, new Forms9Patch.Segment { Text = "D", IsEnabled = false, }, }, }; sc5.SegmentSelected += OnSegmentSelected; sc5.SegmentTapped += OnSegmentTapped; sc5.SegmentLongPressing += OnSegmentLongPressing; sc5.SegmentLongPressed += OnSegmentLongPressed; var sc6 = new Forms9Patch.MaterialSegmentedControl { BackgroundColor = Color.FromHex("#E0E0E0"), HasShadow = true, //OutlineRadius = 0, OutlineWidth = 0, SeparatorWidth = 1, Orientation = StackOrientation.Vertical, GroupToggleBehavior = Forms9Patch.GroupToggleBehavior.Multiselect, Segments = { new Forms9Patch.Segment { Text = "A", }, new Forms9Patch.Segment { Text = "B", IsSelected = true, ImageSource = arrowIcon, //Orientation = StackOrientation.Vertical, }, new Forms9Patch.Segment { Text = "C", }, new Forms9Patch.Segment { Text = "D", IsEnabled = false, }, }, }; sc6.SegmentSelected += OnSegmentSelected; sc6.SegmentTapped += OnSegmentTapped; sc6.SegmentLongPressing += OnSegmentLongPressing; sc6.SegmentLongPressed += OnSegmentLongPressed; #endregion Padding = 20; Content = new ScrollView { Content = new StackLayout{ Children = { grid, #region MaterialSegmentControl //new StackLayout { // Orientation = StackOrientation.Horizontal, // Children = { #region Light new StackLayout { BackgroundColor = Color.Lime, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(10), Children = { new Label { Text = "Default, Light", TextColor = Color.Black, }, sc1, sc2, sc3, sc4, sc5, sc6, }, }, #endregion #region Dark new StackLayout { BackgroundColor = Color.FromHex("#003"), HorizontalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(10), Children = { new Label { Text = "Default, Dark", TextColor = Color.White, }, new Forms9Patch.MaterialSegmentedControl { //OutlineColor = Color.Transparent, DarkTheme = true, Segments = { new Forms9Patch.Segment { Text = "A", }, new Forms9Patch.Segment { //Text = "B", IsSelected = true, ImageSource = arrowIcon, }, new Forms9Patch.Segment { Text = "C", }, new Forms9Patch.Segment { Text = "D", IsEnabled = false, }, }, }, new Forms9Patch.MaterialSegmentedControl { DarkTheme = true, OutlineWidth = 0, Segments = { new Forms9Patch.Segment { //Text = "A", ImageSource = arrowIcon, }, new Forms9Patch.Segment { Text = "B", IsSelected = true, }, new Forms9Patch.Segment { Text = "C", }, new Forms9Patch.Segment { Text = "D", IsEnabled = false, }, }, }, new Forms9Patch.MaterialSegmentedControl { DarkTheme = true, BackgroundColor = Color.FromHex("#1194F6"), Segments = { new Forms9Patch.Segment { Text = "A", }, new Forms9Patch.Segment { Text = "B", IsSelected = true, }, new Forms9Patch.Segment { Text = "C", }, new Forms9Patch.Segment { //Text = "D", IsEnabled = false, ImageSource = arrowIcon, }, }, }, new Forms9Patch.MaterialSegmentedControl { DarkTheme = true, BackgroundColor = Color.FromHex("#1194F6"), OutlineWidth = 0, Segments = { new Forms9Patch.Segment { Text = "A", ImageSource = arrowIcon, Orientation = StackOrientation.Vertical, }, new Forms9Patch.Segment { Text = "B", IsSelected = true, ImageSource = infoIcon, Orientation = StackOrientation.Vertical, }, new Forms9Patch.Segment { Text = "C", ImageSource = arrowIcon, }, new Forms9Patch.Segment { Text = "D", IsEnabled = false, ImageSource = infoIcon, Orientation = StackOrientation.Vertical, }, }, }, new Forms9Patch.MaterialSegmentedControl { DarkTheme = true, BackgroundColor = Color.FromHex("#1194F6"), HasShadow = true, //OutlineRadius = 0, //OutlineWidth = 0, Orientation = StackOrientation.Vertical, GroupToggleBehavior = Forms9Patch.GroupToggleBehavior.Multiselect, Segments = { new Forms9Patch.Segment { Text = "A", ImageSource = arrowIcon, }, new Forms9Patch.Segment { Text = "B", IsSelected = true, }, new Forms9Patch.Segment { Text = "C", }, new Forms9Patch.Segment { Text = "D", IsEnabled = false, }, }, }, new Forms9Patch.MaterialSegmentedControl { DarkTheme = true, BackgroundColor = Color.FromHex("#1194F6"), HasShadow = true, //OutlineRadius = 0, OutlineWidth = 0, SeparatorWidth = 1, Orientation = StackOrientation.Vertical, GroupToggleBehavior = Forms9Patch.GroupToggleBehavior.Multiselect, Segments = { new Forms9Patch.Segment { Text = "A", }, new Forms9Patch.Segment { Text = "B", IsSelected = true, ImageSource = arrowIcon, }, new Forms9Patch.Segment { Text = "C", }, new Forms9Patch.Segment { Text = "D", IsEnabled = false, }, }, }, }, }, #endregion // }, //}, #endregion }, }, }; }