private void OnSinglePickerButtonClicked(object sender, EventArgs e) { var doneButton = new Forms9Patch.Button { BackgroundColor = Color.Blue, TextColor = Color.White, OutlineColor = Color.White, OutlineRadius = 4, OutlineWidth = 1, Text = "Done", HorizontalOptions = LayoutOptions.End, }; var cancelButton = new Forms9Patch.Button { BackgroundColor = Color.Black, TextColor = Color.White, OutlineColor = Color.White, OutlineRadius = 4, OutlineWidth = 1, Text = "Cancel", HorizontalOptions = LayoutOptions.EndAndExpand, }; var buttonBar = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { cancelButton, doneButton } }; var bubbleContent = new StackLayout { WidthRequest = 300, HeightRequest = 300, Children = { buttonBar, _singlePicker } }; var bubblePopup = new Forms9Patch.BubblePopup(_singlePickerButton) { PointerDirection = Forms9Patch.PointerDirection.Vertical, Content = bubbleContent, BackgroundColor = Color.Black, }; var selectedItemAtStart = _singlePicker.SelectedItem; doneButton.Clicked += async(s, args) => await bubblePopup.CancelAsync(); cancelButton.Clicked += async(s, args) => { _singlePicker.SelectedItem = selectedItemAtStart; await bubblePopup.CancelAsync(); }; bubblePopup.IsVisible = true; }
public ToolTipController(View v, string text) { bubble = new Forms9Patch.BubblePopup(v, true); bubble.Content = new Label { Text = text }; bubble.PointerDirection = Forms9Patch.PointerDirection.Down; bubble.PageOverlayColor = Color.Transparent; }
private void _singlePickerButton_Clicked(object sender, System.EventArgs e) { var bubbleContent = new StackLayout { WidthRequest = 300, HeightRequest = 300, Children = { _singlePicker } }; var bubblePopup = new Forms9Patch.BubblePopup(_singlePickerButton) { PointerDirection = Forms9Patch.PointerDirection.Vertical, Content = bubbleContent, BackgroundColor = Color.WhiteSmoke, }; bubblePopup.IsVisible = true; }
public EntryWithPopup() { InitializeComponent(); var content = new Frame { Padding = 0, Margin = 0, Content = new Label { Text = "Popup!" } }; popup = new BubblePopup(MainEntry) { PointerLength = 0, TargetBias = 0, PageOverlayColor = Color.Transparent, Content = content, CloseWhenBackgroundIsClicked = false, BackgroundInputTransparent = false // this doesn't work regardless of whether true or false }; }
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 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." }, } }; }