Beispiel #1
0
        GenItemClass GetCancelEffectTemplete()
        {
            if (_cancelEffectTemplete != null)
            {
                return(_cancelEffectTemplete);
            }
            _cancelEffectTemplete = new GenItemClass("full_off")
            {
                GetContentHandler = (data, part) =>
                {
                    VisualElement element  = data as VisualElement;
                    var           renderer = Platform.GetOrCreateRenderer(element);

                    if (element.MinimumHeightRequest == -1)
                    {
                        SizeRequest request = element.Measure(double.PositiveInfinity, double.PositiveInfinity);
                        renderer.NativeView.MinimumHeight = XForms.ConvertToScaledPixel(request.Request.Height);
                    }
                    else
                    {
                        renderer.NativeView.MinimumHeight = XForms.ConvertToScaledPixel(element.MinimumHeightRequest);
                    }
                    (renderer as LayoutRenderer)?.RegisterOnLayoutUpdated();

                    return(renderer.NativeView);
                }
            };

            return(_cancelEffectTemplete);
        }
        void UpdateContentSize()
        {
            _scrollCanvas.MinimumWidth  = XForms.ConvertToScaledPixel(Element.ContentSize.Width + Element.Padding.HorizontalThickness);
            _scrollCanvas.MinimumHeight = XForms.ConvertToScaledPixel(Element.ContentSize.Height + Element.Padding.VerticalThickness);

            Device.BeginInvokeOnMainThread(() =>
            {
                if (Control != null)
                {
                    OnScrolled(Control, EventArgs.Empty);
                }
            });
        }
Beispiel #3
0
        void CreatePopup()
        {
            if (_popup != null)
            {
                return;
            }

            ElmSharp.EvasObject parent = null;
            if (Control?.Parent != null)
            {
                parent = Control.Parent;
            }
            if (parent == null)
            {
                parent = XForms.NativeParent;
            }

            _popup            = new SelectContextPopup(parent);
            _popup.Dismissed += (s, e) => _behavior.Visibility = false;

            _popup.Accepted += (s, e) => _behavior?.AcceptCommand?.Execute(_behavior?.AcceptCommandParameter);
            _popup.Canceled += (s, e) => _behavior?.CancelCommand?.Execute(_behavior?.CancelCommandParameter);

            string accept = _behavior.AcceptText ?? "";

            var acceptItem = _popup.Append(accept);

            string cancel = _behavior.CancelText;

            if (!string.IsNullOrEmpty(cancel))
            {
                var cancelItem = _popup.Append(cancel);

                acceptItem.Style     = "select_mode/top";
                cancelItem.Style     = "select_mode/bottom";
                cancelItem.Selected += (s, e) => _popup.Cancel();
            }
            acceptItem.Selected += (s, e) => _popup.Accept();

            var  option = _behavior.PositionOption;
            var  offset = _behavior.Offset;
            int  x, y;
            Rect rect;
            Rect ctxRect = _popup.Geometry;

            switch (option)
            {
            case PositionOption.Absolute:
                x = XForms.ConvertToPixel(offset.X);
                y = XForms.ConvertToPixel(offset.Y);
                break;

            case PositionOption.BottomOfView:
                rect = Control.Geometry;
                x    = rect.X + rect.Width / 2 + XForms.ConvertToPixel(offset.X);
                y    = rect.Y + rect.Height + XForms.ConvertToPixel(offset.Y);
                break;

            case PositionOption.CenterOfParent:
                rect = XForms.NativeParent.Geometry;

                x = rect.Width / 2 + XForms.ConvertToPixel(offset.X);
                y = rect.Height / 2 - ctxRect.Height / 2 + XForms.ConvertToPixel(offset.Y);
                break;

            case PositionOption.Relative:
                rect = XForms.NativeParent.Geometry;
                x    = (int)(rect.Width * offset.X);
                y    = (int)(rect.Height * offset.Y);
                break;

            default:
                x = 0;
                y = 0;
                break;
            }

            var window = XForms.NativeParent.Geometry;

            if (y + ctxRect.Height > window.Height)
            {
                y = window.Height - ctxRect.Height;
            }

            _popup.Move(x, y);
        }
Beispiel #4
0
 public FormsWatchface()
 {
     XForms.SetFlags("LightweightPlatform_Experimental");
     _isInitialStart = true;
 }