public MaterialButtonAndSegmentAlignments() { BackgroundColor = Color.White; _grid1.Children.Add(new Xamarin.Forms.Label { Text = "HZ", VerticalTextAlignment = TextAlignment.Center, FontSize = 9, TextColor = Color.Black }, 0, 0); _grid1.Children.Add(_hzAlignmentElement, 1, 0); _grid1.Children.Add(new Xamarin.Forms.Label { Text = "VT", VerticalTextAlignment = TextAlignment.Center, FontSize = 9, TextColor = Color.Black }, 0, 1); _grid1.Children.Add(_vtAlignmentElement, 1, 1); _grid1.Children.Add(new Xamarin.Forms.Label { Text = "Opt", VerticalTextAlignment = TextAlignment.Center, FontSize = 9, TextColor = Color.Black }, 0, 2); _grid1.Children.Add(_optionsElement, 1, 2); _grid1.Children.Add(new Xamarin.Forms.Label { Text = "Icon", VerticalTextAlignment = TextAlignment.Center, FontSize = 9, TextColor = Color.Black }, 0, 3); _grid1.Children.Add(_iconElement, 1, 3); _grid2.Children.Add(new Xamarin.Forms.Label { Text = "Spacing:", TextColor = Color.Black }, 0, 0); _grid2.Children.Add(_spacingSlider, 0, 1); _grid2.Children.Add(new Xamarin.Forms.Label { Text = "Imposed Ht:", TextColor = Color.Black }, 1, 0); _grid2.Children.Add(_imposedHeightSwitch, 1, 1); Padding = new Thickness(40, 20, 20, 20); Content = new Xamarin.Forms.ScrollView { Content = new Xamarin.Forms.StackLayout { Children = { _grid1, _grid2, new BoxView { HeightRequest = 1, Color = Color.Black }, _iconTextAndTextButton, _hzSegmentsElement, _vtSegmentsElement } } }; _hzAlignmentElement.SegmentTapped += (sender, e) => { TextAlignment alignment; var buttonText = string.Concat(e.Segment.Text.ToUpper().Substring(0, 1), e.Segment.Text.ToLower().Substring(1)); if (!Enum.TryParse <TextAlignment>(buttonText, out alignment)) { throw new Exception("doh"); } _labelElement.HorizontalTextAlignment = alignment; _iconTextAndTextButton.HorizontalTextAlignment = alignment; _hzSegmentsElement.HorizontalTextAlignment = alignment; _vtSegmentsElement.HorizontalTextAlignment = alignment; }; _vtAlignmentElement.SegmentTapped += (sender, e) => { TextAlignment alignment; var buttonText = string.Concat(e.Segment.Text.ToUpper().Substring(0, 1), e.Segment.Text.ToLower().Substring(1)); if (!Enum.TryParse <TextAlignment>(buttonText, out alignment)) { throw new Exception("doh"); } _labelElement.VerticalTextAlignment = alignment; _iconTextAndTextButton.VerticalTextAlignment = alignment; _hzSegmentsElement.VerticalTextAlignment = alignment; _vtSegmentsElement.VerticalTextAlignment = alignment; }; _optionsElement.SegmentTapped += (sender, e) => { var options = new List <string>(); foreach (var segment in _optionsElement.SelectedSegments) { options.Add(segment.Text.ToUpper()); } var hasTightSpacing = options.Contains("TIGHT"); var trailingImage = options.Contains("TRAILING"); var orientation = options.Contains("VERTICAL") ? StackOrientation.Vertical : StackOrientation.Horizontal; _iconTextAndTextButton.HasTightSpacing = hasTightSpacing; _iconTextAndTextButton.TrailingIcon = trailingImage; _iconTextAndTextButton.Orientation = orientation; _hzSegmentsElement.HasTightSpacing = hasTightSpacing; _hzSegmentsElement.TrailingIcon = trailingImage; _hzSegmentsElement.IntraSegmentOrientation = orientation; _vtSegmentsElement.HasTightSpacing = hasTightSpacing; _vtSegmentsElement.TrailingIcon = trailingImage; _vtSegmentsElement.IntraSegmentOrientation = orientation; }; _iconElement.SegmentTapped += (sender, e) => { if (e.Segment.IconImage != null) { _iconTextAndTextButton.IconImage = new Forms9Patch.Image("Forms9PatchDemo.Resources.Info"); foreach (var segment in _hzSegmentsElement.Segments) { segment.IconImage = new Forms9Patch.Image("Forms9PatchDemo.Resources.Info"); } foreach (var segment in _vtSegmentsElement.Segments) { segment.IconImage = new Forms9Patch.Image("Forms9PatchDemo.Resources.Info"); } } else { SetIconText(e.Segment.HtmlText); } }; _spacingSlider.ValueChanged += (sender, e) => { _iconTextAndTextButton.Spacing = _spacingSlider.Value; _hzSegmentsElement.IntraSegmentSpacing = _spacingSlider.Value; _vtSegmentsElement.IntraSegmentSpacing = _spacingSlider.Value; }; _imposedHeightSwitch.Toggled += (sender, e) => { _iconTextAndTextButton.HeightRequest = _imposedHeightSwitch.IsToggled ? 60 : -1; _hzSegmentsElement.HeightRequest = _imposedHeightSwitch.IsToggled ? 60 : -1; _vtSegmentsElement.HeightRequest = _imposedHeightSwitch.IsToggled ? 180 : -1; _vtAlignmentElement.IsEnabled = _imposedHeightSwitch.IsToggled; if (!_vtAlignmentElement.IsEnabled) { _vtAlignmentElement.DeselectAll(); } }; var defaultHzAlignment = _iconTextAndTextButton.HorizontalTextAlignment; if (defaultHzAlignment == TextAlignment.Start) { _hzAlignmentElement.SelectIndex(0); } else if (defaultHzAlignment == TextAlignment.Center) { _hzAlignmentElement.SelectIndex(1); } else { _hzAlignmentElement.SelectIndex(2); } _iconElement.SelectIndex(0); _vtAlignmentElement.IsEnabled = false; }
public EmbeddedResourceFontEffectPage() { Forms9Patch.EmbeddedResourceFontEffect.ApplyTo(_label); _editor.Effects.Add(new Forms9Patch.EmbeddedResourceFontEffect()); _entry.Effects.Add(new Forms9Patch.EmbeddedResourceFontEffect()); Forms9Patch.SegmentedControl segmentedControl = new SegmentedControl { Margin = new Thickness(10, 0), FontFamily = "Forms9PatchDemo.Resources.Fonts.Pacifico.ttf", Segments = { new Forms9Patch.Segment("label"), new Forms9Patch.Segment("editor"), new Forms9Patch.Segment("entry"), } }; Content = new Xamarin.Forms.StackLayout { Children = { _label, _editor, _entry, new Xamarin.Forms.Label { Text = "Focus:" }, segmentedControl } }; segmentedControl.SegmentTapped += (sender, e) => { switch (e.Segment.Text) { case "label": _label.HardwareKeyFocus(); break; case "editor": _editor.HardwareKeyFocus(); break; case "entry": _entry.HardwareKeyFocus(); break; } }; HardwareKeyPage.FocusedElementChanged += (sender, e) => { if (sender == _label) { segmentedControl.SelectIndex(0); } else if (sender == _editor) { segmentedControl.SelectIndex(1); } else if (sender == _entry) { segmentedControl.SelectIndex(2); } else { segmentedControl.DeselectAll(); } }; _label.Focused += (sender, e) => System.Diagnostics.Debug.WriteLine("label.Focused " + e.IsFocused); _editor.Focused += (sender, e) => System.Diagnostics.Debug.WriteLine("editor.Focused " + e.IsFocused); _entry.Focused += (sender, e) => System.Diagnostics.Debug.WriteLine("entry.Focused " + e.IsFocused); _label.Unfocused += (sender, e) => System.Diagnostics.Debug.WriteLine("label.Unfocused " + e.IsFocused); _editor.Unfocused += (sender, e) => System.Diagnostics.Debug.WriteLine("editor.Unfocused " + e.IsFocused); _entry.Unfocused += (sender, e) => System.Diagnostics.Debug.WriteLine("entry.Unfocused " + e.IsFocused); _label.FocusChangeRequested += (object sender, FocusRequestArgs e) => System.Diagnostics.Debug.WriteLine("label.FocusChangeRequested "); _editor.FocusChangeRequested += (object sender, FocusRequestArgs e) => System.Diagnostics.Debug.WriteLine("editor.FocusChangeRequested "); _entry.FocusChangeRequested += (object sender, FocusRequestArgs e) => System.Diagnostics.Debug.WriteLine("entry.FocusChangeRequested "); this.AddHardwareKeyListener("ç", OnHardwareKeyPressed); this.AddHardwareKeyListener("é", OnHardwareKeyPressed); this.AddHardwareKeyListener("ф", OnHardwareKeyPressed); this.AddHardwareKeyListener("A", OnHardwareKeyPressed); this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.PlatformKey, OnHardwareKeyPressed); this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.Control, OnHardwareKeyPressed); this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.Alternate, OnHardwareKeyPressed); this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.CapsLock, OnHardwareKeyPressed); this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.FunctionKey, OnHardwareKeyPressed); this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.Shift, OnHardwareKeyPressed); this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.Shift | HardwareKeyModifierKeys.Alternate, OnHardwareKeyPressed); this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.Shift | HardwareKeyModifierKeys.Control, OnHardwareKeyPressed); this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.Shift | HardwareKeyModifierKeys.PlatformKey, OnHardwareKeyPressed); this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.Control | HardwareKeyModifierKeys.Alternate, OnHardwareKeyPressed); this.AddHardwareKeyListener("a", HardwareKeyModifierKeys.Control | HardwareKeyModifierKeys.PlatformKey, OnHardwareKeyPressed); this.AddHardwareKeyListener("5", OnHardwareKeyPressed); this.AddHardwareKeyListener("5", HardwareKeyModifierKeys.NumericPadKey, OnHardwareKeyPressed); this.AddHardwareKeyListener("5", HardwareKeyModifierKeys.PlatformKey, OnHardwareKeyPressed); this.AddHardwareKeyListener("5", HardwareKeyModifierKeys.Control, OnHardwareKeyPressed); this.AddHardwareKeyListener("5", HardwareKeyModifierKeys.Alternate, OnHardwareKeyPressed); this.AddHardwareKeyListener("5", HardwareKeyModifierKeys.CapsLock, OnHardwareKeyPressed); this.AddHardwareKeyListener("5", HardwareKeyModifierKeys.FunctionKey, OnHardwareKeyPressed); this.AddHardwareKeyListener("5", HardwareKeyModifierKeys.Shift, OnHardwareKeyPressed); this.AddHardwareKeyListener("/", OnHardwareKeyPressed); this.AddHardwareKeyListener("/", HardwareKeyModifierKeys.Alternate, OnHardwareKeyPressed); this.AddHardwareKeyListener(HardwareKey.UpArrowKeyInput, OnHardwareKeyPressed); this.AddHardwareKeyListener(HardwareKey.DownArrowKeyInput, OnHardwareKeyPressed); this.AddHardwareKeyListener(HardwareKey.LeftArrowKeyInput, OnHardwareKeyPressed); this.AddHardwareKeyListener(HardwareKey.RightArrowKeyInput, OnHardwareKeyPressed); this.AddHardwareKeyListener(HardwareKey.EscapeKeyInput, OnHardwareKeyPressed); this.AddHardwareKeyListener(HardwareKey.BackspaceDeleteKeyInput, OnHardwareKeyPressed); this.AddHardwareKeyListener(HardwareKey.ForwardDeleteKeyInput, OnHardwareKeyPressed); this.AddHardwareKeyListener(HardwareKey.InsertKeyInput, OnHardwareKeyPressed); this.AddHardwareKeyListener(HardwareKey.TabKeyInput, OnHardwareKeyPressed); this.AddHardwareKeyListener(HardwareKey.EnterReturnKeyInput, OnHardwareKeyPressed); this.AddHardwareKeyListener(HardwareKey.PageUpKeyInput, OnHardwareKeyPressed); this.AddHardwareKeyListener(HardwareKey.PageDownKeyInput, OnHardwareKeyPressed); this.AddHardwareKeyListener(HardwareKey.HomeKeyInput, OnHardwareKeyPressed); this.AddHardwareKeyListener(HardwareKey.EndKeyInput, OnHardwareKeyPressed); _entry.AddHardwareKeyListener(HardwareKey.UpArrowKeyInput, OnHardwareKeyPressed); _entry.AddHardwareKeyListener(HardwareKey.DownArrowKeyInput, OnHardwareKeyPressed); _entry.AddHardwareKeyListener(HardwareKey.LeftArrowKeyInput, OnHardwareKeyPressed); _entry.AddHardwareKeyListener(HardwareKey.RightArrowKeyInput, OnHardwareKeyPressed); _entry.AddHardwareKeyListener(HardwareKey.EscapeKeyInput, OnHardwareKeyPressed); _editor.AddHardwareKeyListener(HardwareKey.UpArrowKeyInput, OnHardwareKeyPressed); _editor.AddHardwareKeyListener(HardwareKey.DownArrowKeyInput, OnHardwareKeyPressed); _editor.AddHardwareKeyListener(HardwareKey.LeftArrowKeyInput, OnHardwareKeyPressed); _editor.AddHardwareKeyListener(HardwareKey.RightArrowKeyInput, OnHardwareKeyPressed); _editor.AddHardwareKeyListener(HardwareKey.EscapeKeyInput, OnHardwareKeyPressed); _label.AddHardwareKeyListener(HardwareKey.UpArrowKeyInput, OnHardwareKeyPressed); _label.AddHardwareKeyListener(HardwareKey.DownArrowKeyInput, OnHardwareKeyPressed); _label.AddHardwareKeyListener(HardwareKey.LeftArrowKeyInput, OnHardwareKeyPressed); _label.AddHardwareKeyListener(HardwareKey.RightArrowKeyInput, OnHardwareKeyPressed); _label.AddHardwareKeyListener(HardwareKey.EscapeKeyInput, OnHardwareKeyPressed); }
public ButtonAndSegmentAlignments() { _grid1.Children.Add(new Xamarin.Forms.Label { Text = "HZ", VerticalTextAlignment = TextAlignment.Center, FontSize = 9 }, 0, 0); _grid1.Children.Add(_hzAlignmentElement, 1, 0); _grid1.Children.Add(new Xamarin.Forms.Label { Text = "VT", VerticalTextAlignment = TextAlignment.Center, FontSize = 9 }, 0, 1); _grid1.Children.Add(_vtAlignmentElement, 1, 1); _grid1.Children.Add(new Xamarin.Forms.Label { Text = "Opt", VerticalTextAlignment = TextAlignment.Center, FontSize = 9 }, 0, 2); _grid1.Children.Add(_optionsElement, 1, 2); _grid1.Children.Add(new Xamarin.Forms.Label { Text = "Icon", VerticalTextAlignment = TextAlignment.Center, FontSize = 9 }, 0, 3); _grid1.Children.Add(_iconElement, 1, 3); _grid2.Children.Add(new Xamarin.Forms.Label { Text = "Spacing:" }, 0, 0); _grid2.Children.Add(_spacingSlider, 0, 1); _grid2.Children.Add(new Xamarin.Forms.Label { Text = "Imposed Ht:" }, 1, 0); _grid2.Children.Add(_imposedHeightSwitch, 1, 1); _grid2.Children.Add(_outlineWidthLabel, 2, 0); _grid2.Children.Add(_outlineWidthSlider, 2, 1); _grid2.Children.Add(_outlineRadiusLabel, 3, 0); _grid2.Children.Add(_outlineRadiusSlider, 3, 1); _grid3.Children.Add(new Xamarin.Forms.Label { Text = "HasShadow:" }, 0, 0); _grid3.Children.Add(_hasShadowSwitch, 0, 1); Padding = new Thickness(40, 20, 20, 20); Content = new Xamarin.Forms.ScrollView { Content = new Xamarin.Forms.StackLayout { Children = { new Xamarin.Forms.Label { Text = "version 0.9.15.1" }, new BoxView { HeightRequest = 1, Color = Color.Gray }, _grid1, new BoxView { HeightRequest = 1, Color = Color.Gray }, _grid2, new BoxView { HeightRequest = 1, Color = Color.Gray }, _grid3, new BoxView { HeightRequest = 1, Color = Color.Black }, _stateButton, new BoxView { HeightRequest = 1, Color = Color.Gray }, _button, new BoxView { HeightRequest = 1, Color = Color.Gray }, _hzSegmentsElement, new BoxView { HeightRequest = 1, Color = Color.Gray }, _vtSegmentsElement, new BoxView { HeightRequest = 1, Color = Color.Gray }, new Xamarin.Forms.Label { Text = "Display.Scale=[" + Display.Scale + "]" } } } }; _hasShadowSwitch.Toggled += (sender, e) => { _hzAlignmentElement.HasShadow = _hasShadowSwitch.IsToggled; _vtAlignmentElement.HasShadow = _hasShadowSwitch.IsToggled; _optionsElement.HasShadow = _hasShadowSwitch.IsToggled; _iconElement.HasShadow = _hasShadowSwitch.IsToggled; _button.HasShadow = _hasShadowSwitch.IsToggled; _stateButton.DefaultState.HasShadow = _hasShadowSwitch.IsToggled; _hzSegmentsElement.HasShadow = _hasShadowSwitch.IsToggled; _vtSegmentsElement.HasShadow = _hasShadowSwitch.IsToggled; }; _hzAlignmentElement.SegmentTapped += (sender, e) => { var buttonText = string.Concat(e.Segment.Text.ToUpper().Substring(0, 1), e.Segment.Text.ToLower().Substring(1)); if (!Enum.TryParse <TextAlignment>(buttonText, out TextAlignment alignment)) { throw new Exception("doh"); } _labelElement.HorizontalTextAlignment = alignment; _button.HorizontalTextAlignment = alignment; _stateButton.DefaultState.HorizontalTextAlignment = alignment; _hzSegmentsElement.HorizontalTextAlignment = alignment; _vtSegmentsElement.HorizontalTextAlignment = alignment; }; _vtAlignmentElement.SegmentTapped += (sender, e) => { var buttonText = string.Concat(e.Segment.Text.ToUpper().Substring(0, 1), e.Segment.Text.ToLower().Substring(1)); if (!Enum.TryParse <TextAlignment>(buttonText, out TextAlignment alignment)) { throw new Exception("doh"); } _labelElement.VerticalTextAlignment = alignment; _button.VerticalTextAlignment = alignment; _stateButton.DefaultState.VerticalTextAlignment = alignment; _hzSegmentsElement.VerticalTextAlignment = alignment; _vtSegmentsElement.VerticalTextAlignment = alignment; }; _optionsElement.SegmentTapped += (sender, e) => { var options = new List <string>(); foreach (var segment in _optionsElement.SelectedSegments) { options.Add(segment.Text.ToUpper()); } var hasTightSpacing = options.Contains("TIGHT"); var trailingIcon = options.Contains("TRAILING"); var orientation = options.Contains("VERTICAL") ? StackOrientation.Vertical : StackOrientation.Horizontal; _button.HasTightSpacing = hasTightSpacing; _button.TrailingIcon = trailingIcon; _button.Orientation = orientation; _stateButton.DefaultState.HasTightSpacing = hasTightSpacing; _stateButton.DefaultState.TrailingIcon = trailingIcon; _stateButton.DefaultState.Orientation = orientation; _hzSegmentsElement.HasTightSpacing = hasTightSpacing; _hzSegmentsElement.TrailingIcon = trailingIcon; _hzSegmentsElement.IntraSegmentOrientation = orientation; _vtSegmentsElement.HasTightSpacing = hasTightSpacing; _vtSegmentsElement.TrailingIcon = trailingIcon; _vtSegmentsElement.IntraSegmentOrientation = orientation; }; _iconElement.SegmentTapped += (sender, e) => { //if (e.Segment.IconImage != null) //{ /* * _iconTextAndTextButton.IconImage = new Forms9Patch.Image { Source = Forms9Patch.ImageSource.FromMultiResource("Forms9PatchDemo.Resources.Info") }; * foreach (var segment in _hzSegmentsElement.Segments) * segment.IconImage = new Forms9Patch.Image { Source = Forms9Patch.ImageSource.FromMultiResource("Forms9PatchDemo.Resources.Info") }; * foreach (var segment in _vtSegmentsElement.Segments) * segment.IconImage = new Forms9Patch.Image { Source = Forms9Patch.ImageSource.FromMultiResource("Forms9PatchDemo.Resources.Info") }; */ SetIconImage(e.Segment.IconImage); //} //else SetIconText(e.Segment.HtmlText ?? e.Segment.Text); }; _spacingSlider.ValueChanged += (sender, e) => { _button.Spacing = _spacingSlider.Value; //_stateButton.Spacing = _spacingSlider.Value; _stateButton.DefaultState.Spacing = _spacingSlider.Value; _hzSegmentsElement.IntraSegmentSpacing = _spacingSlider.Value; _vtSegmentsElement.IntraSegmentSpacing = _spacingSlider.Value; }; _imposedHeightSwitch.Toggled += (sender, e) => { _button.HeightRequest = _imposedHeightSwitch.IsToggled ? 60 : -1; _stateButton.HeightRequest = _imposedHeightSwitch.IsToggled ? 60 : -1; _hzSegmentsElement.HeightRequest = _imposedHeightSwitch.IsToggled ? 60 : -1; _vtSegmentsElement.HeightRequest = _imposedHeightSwitch.IsToggled ? 180 : -1; _vtAlignmentElement.IsEnabled = _imposedHeightSwitch.IsToggled; if (!_vtAlignmentElement.IsEnabled) { _vtAlignmentElement.DeselectAll(); } }; _outlineRadiusSlider.ValueChanged += (sender, e) => { int value = (int)_outlineRadiusSlider.Value; _hzAlignmentElement.OutlineRadius = value; _vtAlignmentElement.OutlineRadius = value; _button.OutlineRadius = value; _stateButton.DefaultState.OutlineRadius = value; _optionsElement.OutlineRadius = value; _iconElement.OutlineRadius = value; _hzSegmentsElement.OutlineRadius = value; _vtSegmentsElement.OutlineRadius = value; _outlineRadiusLabel.Text = "line R: " + value; }; _outlineWidthSlider.Effects.Add(new Forms9Patch.SliderStepSizeEffect(0.5)); _outlineWidthSlider.ValueChanged += (sender, e) => { float value = (float)_outlineWidthSlider.Value; // (float)(Math.Round(_outlineWidthSlider.Value*2.0)/2.0); _hzAlignmentElement.OutlineWidth = value; _vtAlignmentElement.OutlineWidth = value; _button.OutlineWidth = value; _stateButton.DefaultState.OutlineWidth = value; _optionsElement.OutlineWidth = value; _iconElement.OutlineWidth = value; _hzSegmentsElement.OutlineWidth = value; _vtSegmentsElement.OutlineWidth = value; _outlineWidthLabel.Text = "line W: " + _outlineWidthSlider.Value;// + value; }; var defaultHzAlignment = _button.HorizontalTextAlignment; if (defaultHzAlignment == TextAlignment.Start) { _hzAlignmentElement.SelectIndex(0); } else if (defaultHzAlignment == TextAlignment.Center) { _hzAlignmentElement.SelectIndex(1); } else { _hzAlignmentElement.SelectIndex(2); } _iconElement.SelectIndex(0); _vtAlignmentElement.IsEnabled = false; }
public ImageButtonAlignments() { _grid1.Children.Add(new Xamarin.Forms.Label { Text = "HZ", VerticalTextAlignment = TextAlignment.Center, FontSize = 9 }, 0, 0); _grid1.Children.Add(_hzAlignmentElement, 1, 0); _grid1.Children.Add(new Xamarin.Forms.Label { Text = "VT", VerticalTextAlignment = TextAlignment.Center, FontSize = 9 }, 0, 1); _grid1.Children.Add(_vtAlignmentElement, 1, 1); _grid1.Children.Add(new Xamarin.Forms.Label { Text = "Opt", VerticalTextAlignment = TextAlignment.Center, FontSize = 9 }, 0, 2); _grid1.Children.Add(_optionsElement, 1, 2); //_grid1.Children.Add(new Xamarin.Forms.Label { Text = "Icon", VerticalTextAlignment = TextAlignment.Center, FontSize = 9 }, 0, 3); //_grid1.Children.Add(_iconElement, 1, 3); _grid2.Children.Add(new Xamarin.Forms.Label { Text = "Spacing:" }, 0, 0); _grid2.Children.Add(_spacingSlider, 0, 1); _grid2.Children.Add(new Xamarin.Forms.Label { Text = "Imposed Ht:" }, 1, 0); _grid2.Children.Add(_imposedHeightSwitch, 1, 1); _iconTextAndTextButton.Tapped += (sender, e) => System.Diagnostics.Debug.WriteLine("Tapped"); _iconTextAndTextButton.LongPressed += (sender, e) => System.Diagnostics.Debug.WriteLine("LongPressed"); _iconTextAndTextButton.LongPressing += (sender, e) => System.Diagnostics.Debug.WriteLine("LongPressing"); Padding = new Thickness(40, 20, 20, 20); Content = new Xamarin.Forms.ScrollView { Content = new Xamarin.Forms.StackLayout { Children = { _grid1, _grid2, new BoxView { HeightRequest = 1, Color = Color.Black }, _iconTextAndTextButton, } } }; _hzAlignmentElement.SegmentTapped += (sender, e) => { TextAlignment alignment; var buttonText = string.Concat(e.Segment.Text.ToUpper().Substring(0, 1), e.Segment.Text.ToLower().Substring(1)); if (!Enum.TryParse <TextAlignment>(buttonText, out alignment)) { throw new Exception("doh"); } _labelElement.HorizontalTextAlignment = alignment; _iconTextAndTextButton.HorizontalTextAlignment = alignment; }; _vtAlignmentElement.SegmentTapped += (sender, e) => { TextAlignment alignment; var buttonText = string.Concat(e.Segment.Text.ToUpper().Substring(0, 1), e.Segment.Text.ToLower().Substring(1)); if (!Enum.TryParse <TextAlignment>(buttonText, out alignment)) { throw new Exception("doh"); } _labelElement.VerticalTextAlignment = alignment; _iconTextAndTextButton.VerticalTextAlignment = alignment; }; _optionsElement.SegmentTapped += (sender, e) => { _iconTextAndTextButton.HasTightSpacing = _optionsElement.IsIndexSelected(0); _iconTextAndTextButton.TrailingIcon = _optionsElement.IsIndexSelected(1); _iconTextAndTextButton.Orientation = _optionsElement.IsIndexSelected(2) ? StackOrientation.Vertical : StackOrientation.Horizontal; }; _iconElement.SegmentTapped += (sender, e) => { if (e.Segment.IconImage != null) { _iconTextAndTextButton.IconImage = new Forms9Patch.Image { Source = e.Segment.IconImage.Source } } ; // Forms9Patch.ImageSource.FromMultiResource("Forms9PatchDemo.Resources.Info"); else { SetIconText(e.Segment.HtmlText); } }; _spacingSlider.ValueChanged += (sender, e) => { _iconTextAndTextButton.Spacing = _spacingSlider.Value; }; _imposedHeightSwitch.Toggled += (sender, e) => { _iconTextAndTextButton.HeightRequest = _imposedHeightSwitch.IsToggled ? 60 : -1; _vtAlignmentElement.IsEnabled = _imposedHeightSwitch.IsToggled; if (!_vtAlignmentElement.IsEnabled) { _vtAlignmentElement.DeselectAll(); } }; var defaultHzAlignment = _iconTextAndTextButton.HorizontalTextAlignment; if (defaultHzAlignment == TextAlignment.Start) { _hzAlignmentElement.SelectIndex(0); } else if (defaultHzAlignment == TextAlignment.Center) { _hzAlignmentElement.SelectIndex(1); } else { _hzAlignmentElement.SelectIndex(2); } _iconElement.SelectIndex(0); _vtAlignmentElement.IsEnabled = false; }