public override void OnTouchMove(GPoint point)
 {
     if (_isThumbSelected)
     {
         UpdateValue(point);
     }
 }
 public override void OnTouchUp(GPoint point)
 {
     if (_isThumbSelected)
     {
         _isThumbSelected = false;
         AnimateMaterialThumbSize(false);
     }
 }
        public override void OnTouchDown(GPoint point)
        {
            PointF touchPoint = new PointF((float)point.X, (float)point.Y);

            if (_indicatorRect.Contains(touchPoint))
            {
                View.Text = string.Empty;
            }
        }
        public override void OnTouchDown(GPoint point)
        {
            _isThumbSelected = ThumbRect.Contains(new PointF((float)point.X, (float)point.Y));

            if (_isThumbSelected)
            {
                AnimateMaterialThumbSize(true);
            }
            UpdateValue(point);
        }
        public override void OnTouchDown(GPoint point)
        {
            _minusRippleEffect.ClipRectangle = _minusRect;
            _plusRippleEffect.ClipRectangle  = _plusRect;

            _plusRippleEffect.OnTouchDown(point);
            _minusRippleEffect.OnTouchDown(point);

            _pressed = true;
        }
        public override void OnTouchUp(GPoint point)
        {
            var touchDownPoint = new PointF((float)point.X, (float)point.Y);

            if (_minusRect.Contains(touchDownPoint) && _pressed)
            {
                View.Value -= View.Increment;
            }

            if (_plusRect.Contains(touchDownPoint) && _pressed)
            {
                View.Value += View.Increment;
            }

            _minusRippleEffect.OnTouchUp(point);
            _plusRippleEffect.OnTouchUp(point);
            _pressed = false;
        }
 public override void OnTouchDown(GPoint point)
 {
     var touchDownPoint = new PointF((float)point.X, (float)point.Y);
     TouchPoint = touchDownPoint;
 }
Esempio n. 8
0
        public static APath ToAPath(this Geometry geometry, Context context)
        {
            APath path = new APath();

            float density = context.Resources.DisplayMetrics.Density;

            if (geometry is LineGeometry)
            {
                LineGeometry lineGeometry = geometry as LineGeometry;

                path.MoveTo(
                    density * (float)lineGeometry.StartPoint.X,
                    density * (float)lineGeometry.StartPoint.Y);

                path.LineTo(
                    density * (float)lineGeometry.EndPoint.X,
                    density * (float)lineGeometry.EndPoint.Y);
            }
            else if (geometry is RectangleGeometry)
            {
                FormsRectangle rect = (geometry as RectangleGeometry).Rect;

                path.AddRect(
                    density * (float)rect.Left,
                    density * (float)rect.Top,
                    density * (float)rect.Right,
                    density * (float)rect.Bottom,
                    APath.Direction.Cw);
            }
            else if (geometry is EllipseGeometry)
            {
                EllipseGeometry ellipseGeometry = geometry as EllipseGeometry;

                path.AddOval(new RectF(
                                 density * (float)(ellipseGeometry.Center.X - ellipseGeometry.RadiusX),
                                 density * (float)(ellipseGeometry.Center.Y - ellipseGeometry.RadiusY),
                                 density * (float)(ellipseGeometry.Center.X + ellipseGeometry.RadiusX),
                                 density * (float)(ellipseGeometry.Center.Y + ellipseGeometry.RadiusY)),
                             APath.Direction.Cw);
            }
            else if (geometry is GeometryGroup)
            {
                GeometryGroup geometryGroup = geometry as GeometryGroup;

                path.SetFillType(geometryGroup.FillRule == FillRule.Nonzero ? APath.FillType.Winding : APath.FillType.EvenOdd);

                foreach (Geometry child in geometryGroup.Children)
                {
                    APath childPath = child.ToAPath(context);
                    path.AddPath(childPath);
                }
            }
            else if (geometry is PathGeometry)
            {
                PathGeometry pathGeometry = geometry as PathGeometry;

                path.SetFillType(pathGeometry.FillRule == FillRule.Nonzero ? APath.FillType.Winding : APath.FillType.EvenOdd);

                foreach (PathFigure pathFigure in pathGeometry.Figures)
                {
                    path.MoveTo(
                        density * (float)pathFigure.StartPoint.X,
                        density * (float)pathFigure.StartPoint.Y);

                    Point lastPoint = pathFigure.StartPoint;

                    foreach (PathSegment pathSegment in pathFigure.Segments)
                    {
                        // LineSegment
                        if (pathSegment is LineSegment)
                        {
                            LineSegment lineSegment = pathSegment as LineSegment;

                            path.LineTo(
                                density * (float)lineSegment.Point.X,
                                density * (float)lineSegment.Point.Y);
                            lastPoint = lineSegment.Point;
                        }
                        // PolylineSegment
                        else if (pathSegment is PolyLineSegment)
                        {
                            PolyLineSegment polylineSegment = pathSegment as PolyLineSegment;
                            PointCollection points          = polylineSegment.Points;

                            for (int i = 0; i < points.Count; i++)
                            {
                                path.LineTo(
                                    density * (float)points[i].X,
                                    density * (float)points[i].Y);
                            }
                            lastPoint = points[points.Count - 1];
                        }
                        // BezierSegment
                        else if (pathSegment is BezierSegment)
                        {
                            BezierSegment bezierSegment = pathSegment as BezierSegment;

                            path.CubicTo(
                                density * (float)bezierSegment.Point1.X, density * (float)bezierSegment.Point1.Y,
                                density * (float)bezierSegment.Point2.X, density * (float)bezierSegment.Point2.Y,
                                density * (float)bezierSegment.Point3.X, density * (float)bezierSegment.Point3.Y);

                            lastPoint = bezierSegment.Point3;
                        }
                        // PolyBezierSegment
                        else if (pathSegment is PolyBezierSegment)
                        {
                            PolyBezierSegment polyBezierSegment = pathSegment as PolyBezierSegment;
                            PointCollection   points            = polyBezierSegment.Points;

                            if (points.Count >= 3)
                            {
                                for (int i = 0; i < points.Count; i += 3)
                                {
                                    path.CubicTo(
                                        density * (float)points[i + 0].X, density * (float)points[i + 0].Y,
                                        density * (float)points[i + 1].X, density * (float)points[i + 1].Y,
                                        density * (float)points[i + 2].X, density * (float)points[i + 2].Y);
                                }
                            }

                            lastPoint = points[points.Count - 1];
                        }
                        // QuadraticBezierSegment
                        else if (pathSegment is QuadraticBezierSegment)
                        {
                            QuadraticBezierSegment bezierSegment = pathSegment as QuadraticBezierSegment;

                            path.QuadTo(
                                density * (float)bezierSegment.Point1.X, density * (float)bezierSegment.Point1.Y,
                                density * (float)bezierSegment.Point2.X, density * (float)bezierSegment.Point2.Y);

                            lastPoint = bezierSegment.Point2;
                        }
                        // PolyQuadraticBezierSegment
                        else if (pathSegment is PolyQuadraticBezierSegment)
                        {
                            PolyQuadraticBezierSegment polyBezierSegment = pathSegment as PolyQuadraticBezierSegment;
                            PointCollection            points            = polyBezierSegment.Points;

                            if (points.Count >= 2)
                            {
                                for (int i = 0; i < points.Count; i += 2)
                                {
                                    path.QuadTo(
                                        density * (float)points[i + 0].X, density * (float)points[i + 0].Y,
                                        density * (float)points[i + 1].X, density * (float)points[i + 1].Y);
                                }
                            }

                            lastPoint = points[points.Count - 1];
                        }
                        // ArcSegment
                        else if (pathSegment is ArcSegment)
                        {
                            ArcSegment arcSegment = pathSegment as ArcSegment;

                            List <Point> points = new List <Point>();

                            GeometryHelper.FlattenArc(
                                points,
                                lastPoint,
                                arcSegment.Point,
                                arcSegment.Size.Width,
                                arcSegment.Size.Height,
                                arcSegment.RotationAngle,
                                arcSegment.IsLargeArc,
                                arcSegment.SweepDirection == SweepDirection.CounterClockwise,
                                1);

                            for (int i = 0; i < points.Count; i++)
                            {
                                path.LineTo(
                                    density * (float)points[i].X,
                                    density * (float)points[i].Y);
                            }

                            if (points.Count > 0)
                            {
                                lastPoint = points[points.Count - 1];
                            }
                        }
                    }

                    if (pathFigure.IsClosed)
                    {
                        path.Close();
                    }
                }
            }

            return(path);
        }
Esempio n. 9
0
 public virtual void OnTouchMove(GPoint point)
 {
 }
Esempio n. 10
0
 public virtual void OnTouchUp(GPoint point)
 {
 }
Esempio n. 11
0
 public virtual void OnTouchDown(GPoint point)
 {
 }
Esempio n. 12
0
 void UpdateValue(GPoint point)
 {
     ValueRate = (point.X - TrackRect.X) / TrackRect.Width;
     SendInvalidated();
 }
Esempio n. 13
0
 public override void OnTouchDown(GPoint point)
 {
     _rippleEffect.ClipRectangle = _backgroundRect;
     _rippleEffect.OnTouchDown(point);
 }
 public override void OnTouchUp(GPoint point)
 {
     if (ClipRectangle == RectF.Zero || ClipRectangle.Contains(TouchPoint))
         AnimateDrawRipple();
 }
Esempio n. 15
0
 public override void OnTouchDown(GPoint point)
 {
     View.IsToggled = !View.IsToggled;
     AnimateMaterialSwitchThumb(View.IsToggled);
 }
 public override void OnTouchMove(GPoint point)
 {
     _pressed = false;
 }
Esempio n. 17
0
 public override void OnTouchUp(GPoint point)
 {
     _rippleEffect.OnTouchUp(point);
 }
Esempio n. 18
0
        async void OnScrollToRequested(object sender, ScrollToRequestedEventArgs e)
        {
            _checkedForRtlScroll = true;

            if (!_isAttached)
            {
                return;
            }

            // 99.99% of the time simply queuing to the end of the execution queue should handle this case.
            // However it is possible to end a layout cycle and STILL be layout requested. We want to
            // back off until all are done, even if they trigger layout storms over and over. So we back off
            // for 10ms tops then move on.
            var cycle = 0;

            while (IsLayoutRequested)
            {
                await Task.Delay(TimeSpan.FromMilliseconds(1));

                if (_disposed)
                {
                    return;
                }

                cycle++;

                if (cycle >= 10)
                {
                    break;
                }
            }

            var context  = Context;
            var x        = (int)context.ToPixels(e.ScrollX);
            var y        = (int)context.ToPixels(e.ScrollY);
            int currentX = _view.Orientation == ScrollOrientation.Horizontal || _view.Orientation == ScrollOrientation.Both ? _hScrollView.ScrollX : ScrollX;
            int currentY = _view.Orientation == ScrollOrientation.Vertical || _view.Orientation == ScrollOrientation.Both ? ScrollY : _hScrollView.ScrollY;

            if (e.Mode == ScrollToMode.Element)
            {
                Point itemPosition = Controller.GetScrollPositionForElement(e.Element as VisualElement, e.Position);

                x = (int)context.ToPixels(itemPosition.X);
                y = (int)context.ToPixels(itemPosition.Y);
            }
            if (e.ShouldAnimate)
            {
                ValueAnimator animator = ValueAnimator.OfFloat(0f, 1f);
                animator.SetDuration(1000);
                animator.Update += (o, animatorUpdateEventArgs) =>
                {
                    var v     = (double)animatorUpdateEventArgs.Animation.AnimatedValue;
                    int distX = GetDistance(currentX, x, v);
                    int distY = GetDistance(currentY, y, v);

                    if (_view == null)
                    {
                        // This is probably happening because the page with this Scroll View
                        // was popped off the stack during animation
                        animator.Cancel();
                        return;
                    }

                    switch (_view.Orientation)
                    {
                    case ScrollOrientation.Horizontal:
                        _hScrollView.ScrollTo(distX, distY);
                        break;

                    case ScrollOrientation.Vertical:
                        ScrollTo(distX, distY);
                        break;

                    default:
                        _hScrollView.ScrollTo(distX, distY);
                        ScrollTo(distX, distY);
                        break;
                    }
                };
                animator.AnimationEnd += delegate
                {
                    if (Controller == null)
                    {
                        return;
                    }
                    Controller.SendScrollFinished();
                };

                animator.Start();
            }
            else
            {
                switch (_view.Orientation)
                {
                case ScrollOrientation.Horizontal:
                    _hScrollView.ScrollTo(x, y);
                    break;

                case ScrollOrientation.Vertical:
                    ScrollTo(x, y);
                    break;

                default:
                    _hScrollView.ScrollTo(x, y);
                    ScrollTo(x, y);
                    break;
                }
                Controller.SendScrollFinished();
            }
        }
Esempio n. 19
0
 public override void OnTouchDown(GPoint point)
 {
     View.IsChecked = !View.IsChecked;
 }