Beispiel #1
0
        private void SetPadding(Thickness padding, Editor editor)
        {
            int left   = (int)ContextExtensions.ToPixels(Control.Context, (int)editor.Padding.Left);
            int top    = (int)ContextExtensions.ToPixels(Control.Context, (int)editor.Padding.Top);
            int right  = (int)ContextExtensions.ToPixels(Control.Context, (int)editor.Padding.Right);
            int bottom = (int)ContextExtensions.ToPixels(Control.Context, (int)editor.Padding.Bottom);

            Control.SetPadding(left, top, right, bottom);
        }
        protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)
        {
            MeasureSpecMode widthMode      = MeasureSpec.GetMode(widthMeasureSpec);
            MeasureSpecMode heightMode     = MeasureSpec.GetMode(heightMeasureSpec);
            int             widthSize      = MeasureSpec.GetSize(widthMeasureSpec);
            int             heightSize     = MeasureSpec.GetSize(heightMeasureSpec);
            int             pxHeight       = (int)ContextExtensions.ToPixels(Context, Renderer.Element.HeightRequest);
            int             pxWidth        = (int)ContextExtensions.ToPixels(Context, Renderer.Element.WidthRequest);
            var             measuredWidth  = widthMode != MeasureSpecMode.Exactly ? (widthMode != MeasureSpecMode.AtMost ? pxHeight : Math.Min(pxHeight, widthSize)) : widthSize;
            var             measuredHeight = heightMode != MeasureSpecMode.Exactly ? (heightMode != MeasureSpecMode.AtMost ? pxWidth : Math.Min(pxWidth, heightSize)) : heightSize;

            SetMeasuredDimension(measuredWidth, measuredHeight);
        }
Beispiel #3
0
        public override bool DispatchTouchEvent(MotionEvent e)
        {
            if (e.Action == MotionEventActions.Down)
            {
                downTime     = DateTime.UtcNow;
                downPosition = new Xamarin.Forms.Point((double)e.RawX, (double)e.RawY);
            }
            if (e.Action != MotionEventActions.Up)
            {
                return(base.DispatchTouchEvent(e));
            }
            Android.Views.View currentFocus1 = ((Activity)Context).CurrentFocus;
            bool flag = base.DispatchTouchEvent(e);

            if (currentFocus1 is EditText)
            {
                Android.Views.View currentFocus2 = ((Activity)Context).CurrentFocus;
                if (currentFocus1 == currentFocus2 && this.downPosition.Distance(new Xamarin.Forms.Point((double)e.RawX, (double)e.RawY)) <= ContextExtensions.ToPixels(Context, 20.0) && !(DateTime.UtcNow - downTime > TimeSpan.FromMilliseconds(200.0)))
                {
                    int[] location = new int[2];
                    currentFocus1.GetLocationOnScreen(location);
                    float num1 = e.RawX + currentFocus1.Left - location[0];
                    float num2 = e.RawY + currentFocus1.Top - location[1];
                    if (!new Rectangle((double)currentFocus1.Left, (double)currentFocus1.Top, (double)currentFocus1.Width, (double)currentFocus1.Height).Contains((double)num1, (double)num2))
                    {
                        ContextExtensions.HideKeyboard(Context, currentFocus1);
                        RequestFocus();
                        currentFocus1.ClearFocus();
                    }
                }
            }
            return(flag);
        }
Beispiel #4
0
 public override SizeRequest GetDesiredSize(int widthConstraint, int heightConstraint)
 {
     return(new SizeRequest(new Size(ContextExtensions.ToPixels(Context, 40.0), ContextExtensions.ToPixels(Context, 40.0))));
 }