Example #1
0
        void OnTap(object sender, EventArgs e)
        {
            var control = Control ?? Container;

            var text = ToolTipEffect.GetText(Element);

            if (!string.IsNullOrEmpty(text))
            {
                tooltip.BubbleColor     = ToolTipEffect.GetBackgroundColor(Element).ToUIColor();
                tooltip.ForegroundColor = ToolTipEffect.GetTextColor(Element).ToUIColor();
                tooltip.Text            = new Foundation.NSString(text);
                var heightArrow = ToolTipEffect.GetArrowHeight(Element);
                if (heightArrow > 0.0)
                {
                    tooltip.ArrowHeight = Convert.ToSingle(heightArrow);
                }
                var widthArrow = ToolTipEffect.GetArrowWidth(Element);
                if (widthArrow > 0.0)
                {
                    tooltip.ArrowWidth = Convert.ToSingle(widthArrow);
                }
                UpdatePosition();

                var window = UIApplication.SharedApplication.KeyWindow;
                var vc     = window.RootViewController;
                while (vc.PresentedViewController != null)
                {
                    vc = vc.PresentedViewController;
                }


                tooltip?.Show(control, vc.View, true);
            }
        }
Example #2
0
        protected override void OnElementPropertyChanged(PropertyChangedEventArgs args)
        {
            base.OnElementPropertyChanged(args);

            if (args.PropertyName == ToolTipEffect.BackgroundColorProperty.PropertyName)
            {
                tooltip.BubbleColor = ToolTipEffect.GetBackgroundColor(Element).ToUIColor();
            }
            else if (args.PropertyName == ToolTipEffect.TextColorProperty.PropertyName)
            {
                tooltip.ForegroundColor = ToolTipEffect.GetTextColor(Element).ToUIColor();
            }
            else if (args.PropertyName == ToolTipEffect.TextProperty.PropertyName)
            {
                tooltip.Text = new Foundation.NSString(ToolTipEffect.GetText(Element));
            }
            else if (args.PropertyName == ToolTipEffect.ArrowWidthProperty.PropertyName)
            {
                var widthArrow = ToolTipEffect.GetArrowWidth(Element);
                tooltip.ArrowWidth = Convert.ToSingle(widthArrow);
            }
            else if (args.PropertyName == ToolTipEffect.ArrowHeightProperty.PropertyName)
            {
                var heightArrow = ToolTipEffect.GetArrowHeight(Element);
                tooltip.ArrowWidth = Convert.ToSingle(heightArrow);
            }

            else if (args.PropertyName == ToolTipEffect.PositionProperty.PropertyName)
            {
                UpdatePosition();
            }
        }
Example #3
0
        protected override void OnElementPropertyChanged(PropertyChangedEventArgs args)
        {
            base.OnElementPropertyChanged(args);


            if (args.PropertyName == "Text")
            {
                if (toolTip != null)
                {
                    toolTip.Content = ToolTipEffect.GetText(Element);
                }
            }
        }
Example #4
0
        void UpdatePosition()
        {
            var position = ToolTipEffect.GetPosition(Element);

            switch (position)
            {
            case ToolTipPosition.Top:
                tooltip.ArrowPosition = EasyTipView.ArrowPosition.Bottom;
                break;

            case ToolTipPosition.Left:
                tooltip.ArrowPosition = EasyTipView.ArrowPosition.Right;
                break;

            case ToolTipPosition.Right:
                tooltip.ArrowPosition = EasyTipView.ArrowPosition.Left;
                break;

            default:
                tooltip.ArrowPosition = EasyTipView.ArrowPosition.Top;
                break;
            }
        }
        private void GetToolTip()
        {
            var control = Control ?? Container;

            var text = ToolTipEffect.GetText(Element);

            if (!string.IsNullOrEmpty(text))
            {
                var position = ToolTipEffect.GetPosition(Element);
                builder = new Tooltip.Builder(control);
                switch (position)
                {
                case ToolTipPosition.Top:
                    builder.SetGravity((int)GravityFlags.Top);
                    break;

                case ToolTipPosition.Left:
                    builder.SetGravity((int)GravityFlags.Left);
                    break;

                case ToolTipPosition.Right:
                    builder.SetGravity((int)GravityFlags.Right);
                    break;

                case ToolTipPosition.Bottom:
                    builder.SetGravity((int)GravityFlags.Bottom);
                    break;

                default:
                    builder.SetGravity((int)GravityFlags.NoGravity);
                    break;
                }

                builder.SetText(text);
                builder.SetCornerRadius(Convert.ToSingle(ToolTipEffect.GetCornerRadius(Element)));

                builder.SetDismissOnClick(true);
                builder.SetBackgroundColor(ToolTipEffect.GetBackgroundColor(Element).ToAndroid());
                builder.SetTextColor(ToolTipEffect.GetTextColor(Element).ToAndroid());
                var heightArrow = ToolTipEffect.GetArrowHeight(Element);
                if (heightArrow > 0.0)
                {
                    builder.SetArrowHeight(Convert.ToSingle(heightArrow));
                }
                var widthArrow = ToolTipEffect.GetArrowWidth(Element);
                if (widthArrow > 0.0)
                {
                    builder.SetArrowWidth(Convert.ToSingle(widthArrow));
                }

                var textSize = ToolTipEffect.GetTextSize(Element);
                if (textSize > 0)
                {
                    builder.SetTextSize(Convert.ToSingle(textSize));
                }

                builder.SetMargin(Convert.ToSingle(ToolTipEffect.GetMargin(Element)));
                builder.SetPadding(ToolTipEffect.GetPadding(Element));
                builder.SetCancelable(true);

                builder.Build().Show();

                //  _toolTipsManager?.Show(toolTipView);
            }
        }
Example #6
0
        private void ShowToolTip()
        {
            var control = Control ?? Container;

            if (control is DependencyObject)
            {
                object toolTipContent;
                var    content = ToolTipEffect.GetContent(Element);

                if (content != null)
                {
                    var viewToRendererConverter = new ViewToRendererConverter();
                    var frameworkElement        = viewToRendererConverter.Convert(content, null, null, null);
                    toolTipContent = frameworkElement;
                }
                else
                {
                    toolTipContent = ToolTipEffect.GetText(Element);
                }
                toolTip = new ToolTip
                {
                    Background = XamarinColorToNative(ToolTipEffect.GetBackgroundColor(Element)),
                    Content    = toolTipContent ?? "n/a",
                    Placement  = GetPlacementMode()
                };

                var height = ToolTipEffect.GetHeight(Element);
                if (height > 0.0)
                {
                    toolTip.Height = height;
                }

                var width = ToolTipEffect.GetWidth(Element);
                if (width > 0.0)
                {
                    toolTip.Width = width;
                }

                ToolTipService.SetToolTip(control, toolTip);

                PlacementMode GetPlacementMode()
                {
                    switch (ToolTipEffect.GetPosition(Element))
                    {
                    case ToolTipPosition.Bottom:
                        return(Windows.UI.Xaml.Controls.Primitives.PlacementMode.Bottom);

                    case ToolTipPosition.Top:
                        return(Windows.UI.Xaml.Controls.Primitives.PlacementMode.Top);

                    case ToolTipPosition.Left:
                        return(Windows.UI.Xaml.Controls.Primitives.PlacementMode.Left);

                    case ToolTipPosition.Right:
                        return(Windows.UI.Xaml.Controls.Primitives.PlacementMode.Right);

                    default:
                        return(Windows.UI.Xaml.Controls.Primitives.PlacementMode.Mouse);
                    }
                }
            }
        }