Exemplo n.º 1
0
 public GestureViewRenderer()
 {
     _gestureListener = new DroidGestureViewTouchListener();
     _gestureDetector = new GestureDetector(_gestureListener);
     _scaleListener = new DroidGestureViewScaleListener();
     _scaleDetector = new ScaleGestureDetector(Context, _scaleListener);
 }
        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            // Add our touch handlers.
            PinchDetector = new ScaleGestureDetector(this, this);
            MoveDetector = new MoveGestureDetector(this, this);
            RotationDetector = new RotateGestureDetector(this, this);

            Detector = new GestureDetector(this, this);
            Detector.IsLongpressEnabled = false;

            MainLayout = (RelativeLayout)FindViewById (Resource.Id.main);
            MainLayout.Touch += HandleTouch;

            // Disable touch handling by the views themselves.
            for(var i = 0; i < MainLayout.ChildCount; i++) {
                var view = MainLayout.GetChildAt(i);
                Log("OnCreate", "View {0} disabled.", i);
                view.Focusable = true;
                view.FocusableInTouchMode = true;
                view.RequestFocus();
            }

            BootstrapDropbox ();
        }
		public GestureRecognizerView (Context context)
            : base(context, null, 0)
		{
			_icon = context.Resources.GetDrawable (Resource.Drawable.ic_launcher);
			_icon.SetBounds (0, 0, _icon.IntrinsicWidth, _icon.IntrinsicHeight);
			_scaleDetector = new ScaleGestureDetector (context, new MyScaleListener (this));
		}
Exemplo n.º 4
0
		public override bool OnScale(ScaleGestureDetector detector)
		{
			float cur = detector.CurrentSpan;
			float last = detector.PreviousSpan;

			if (Math.Abs(cur - last) < 10)
				return false;

			return _pinchDelegate(detector.ScaleFactor, new Point(Forms.Context.FromPixels(detector.FocusX), Forms.Context.FromPixels(detector.FocusY)));
		}
        public void OnLoaded(ImageView p0, Bitmap p1, string p2, bool p3)
        {
            _image = imageView.Drawable;
            _image.SetBounds(0, 0, _image.IntrinsicWidth, _image.IntrinsicHeight);
            _scaleDetector = new ScaleGestureDetector(_context, new MyScaleListener(this));

            var metrics = Resources.DisplayMetrics;
            _posX = GetCornerPosition(PixelConverter.PixelsToDp(metrics.WidthPixels), _image.Bounds.Width()) * (int)_scaleFactor;
            _posY = GetCornerPosition(PixelConverter.PixelsToDp(metrics.HeightPixels), _image.Bounds.Height());
        }
Exemplo n.º 6
0
        //float scale = 1;
                
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="context"></param>
        /// <param name="attrs"></param>
        public ImageCropView(Context context, IAttributeSet attrs) : base(context, attrs)
        {
            SetLayerType(Android.Views.LayerType.Software, null);
            this.context = context;
            _scaleDetector = new ScaleGestureDetector(context, new MyScaleListener(this));

            GetScreenResolution(context);

            // make this view available in the PCL
            ImageCropInstance.ImageCropView = this;
        }
            public bool OnScale(ScaleGestureDetector detector)
            {
                float scaleFactor = detector.ScaleFactor;

                if (Float.InvokeIsNaN(scaleFactor) || Float.InvokeIsInfinite(scaleFactor))
                    return false;

                froyoGestureDetector.mListener.OnScale (scaleFactor,
                    detector.FocusX, detector.FocusY);
                return true;
            }
			public override bool OnScale (ScaleGestureDetector detector)
			{
				_view._scaleFactor *= detector.ScaleFactor;

				// put a limit on how small or big the image can get.
				if (_view._scaleFactor > 5.0f) {
					_view._scaleFactor = 5.0f;
				}
				if (_view._scaleFactor < 0.1f) {
					_view._scaleFactor = 0.1f;
				}

				_view.Invalidate ();
				return true;
			}
Exemplo n.º 9
0
        /// <summary>
        /// Raises the scale begin event.
        /// </summary>
        /// <param name="detector">Detector.</param>
        public bool OnScaleBegin(ScaleGestureDetector detector)
        {
            _deltaScale = 1;
            _deltaDegrees = 0;
            _deltaX = 0;
            _deltaY = 0;

            return true;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Initialize implementation from IMapView.
        /// </summary>
        /// <param name="mapLayout"></param>
        void IMapViewSurface.Initialize(MapView mapLayout)
        {
            this.MapAllowPan = true;
            this.MapAllowTilt = true;
            this.MapAllowZoom = true;

            // register default invalidation trigger.
            (this as IInvalidatableMapSurface).RegisterListener(new DefaultTrigger(this));

            _mapView = mapLayout;
            this.SetWillNotDraw(false);
            // this.SetWillNotCacheDrawing(true);

            this.MapMinZoomLevel = 0;
            this.MapMaxZoomLevel = 20;

            // gets the system density.
            _density = global::Android.Content.Res.Resources.System.DisplayMetrics.Density;
            _bufferFactor = _density; // set default scale factor relative to density.

            // create the renderer.
            _renderer = new MapRenderer<global::Android.Graphics.Canvas>(
                new CanvasRenderer2D(1));

            // initialize the gesture detection.
            this.SetOnTouchListener(this);
            _scaleGestureDetector = new ScaleGestureDetector(
                this.Context, this);
            _rotateGestureDetector = new RotateGestureDetector(
                this.Context, this);
            _moveGestureDetector = new MoveGestureDetector(
                this.Context, this);
            _tagGestureDetector = new TapGestureDetector(
                this.Context, this);

            _makerLayer = new LayerPrimitives(
                new WebMercator());

            // initialize all the caching stuff.
            _backgroundColor = SimpleColor.FromKnownColor(KnownColor.White).Value;
            _cacheRenderer = new MapRenderer<global::Android.Graphics.Canvas>(
                new CanvasRenderer2D(1));
        }
Exemplo n.º 11
0
        public void OnScaleEnd(ScaleGestureDetector detector)
        {
            var args = new ScaleGestureDetector.ScaleEndEventArgs(detector);

            var handler = this.ScaleEnd;
            if (handler != null)
            {
                handler(this, args);
            }
        }
Exemplo n.º 12
0
 /// <summary>
 /// Raises the scale end event.
 /// </summary>
 /// <param name="detector">Detector.</param>
 public void OnScaleEnd(ScaleGestureDetector detector)
 {
 }
Exemplo n.º 13
0
 public override bool OnScale(ScaleGestureDetector detector)
 {
     var handler = Pinch;
     if (handler != null)
         handler(this, new PinchEventArgs
             {
                 ScaleFactor = detector.ScaleFactor, 
                 InProgress = detector.IsInProgress,
                 GestureTime = TimeSpan.FromMilliseconds(detector.TimeDelta)
             });
     return true;
 }
Exemplo n.º 14
0
        /// <summary>
        /// Initialize implementation from IMapView.
        /// </summary>
        /// <param name="mapLayout"></param>
        void IMapViewSurface.Initialize(MapView mapLayout)
        {
            // create the Open GL 2D target.
            _target = new OpenGLTarget2D();
            this.SetRenderer(_target);

            _mapView = mapLayout;
            this.SetWillNotDraw(false);

            this.MapMinZoomLevel = 10;
            this.MapMaxZoomLevel = 20;

            // create the renderer.
            _renderer = new MapRenderer<OpenGLTarget2D>(
                    new OpenGLRenderer2D());

            // initialize the gesture detection.
            this.SetOnTouchListener(this);
            _scaleGestureDetector = new ScaleGestureDetector(
                this.Context, this);
            _rotateGestureDetector = new RotateGestureDetector(
                this.Context, this);
            _moveGestureDetector = new MoveGestureDetector(
                this.Context, this);
            _tagGestureDetector = new TapGestureDetector(
                this.Context, this);

            _makerLayer = new LayerPrimitives(
                new WebMercator());

            _scene = new Scene2D(new WebMercator(), 16);
            _scene.BackColor = SimpleColor.FromKnownColor(KnownColor.White).Value;
        }
Exemplo n.º 15
0
		public override void OnScaleEnd(ScaleGestureDetector detector)
		{
			_pinchEndedDelegate();
		}
Exemplo n.º 16
0
		public override bool OnScaleBegin(ScaleGestureDetector detector)
		{
			return _pinchStartedDelegate(new Point(Forms.Context.FromPixels(detector.FocusX), Forms.Context.FromPixels(detector.FocusY)));
		}
Exemplo n.º 17
0
        /// <summary>
        /// Raises the scale event.
        /// </summary>
        /// <param name="detector">Detector.</param>
        public bool OnScale(ScaleGestureDetector detector)
        {
            this.ZoomFactor = (float)System.Math.Log((System.Math.Pow(2, this.ZoomFactor) * detector.ScaleFactor), 2.0);

            //			float factorX = this.View.Width / this.Width;
            //			float factorY = this.View.Height / this.Height;
            //			this.View = View2D.CreateFromCenterAndSize(this.View.Width / detector.ScaleFactor, this.View.Height / detector.ScaleFactor,
            //			                                           this.View.CenterX,
            //			                                           this.View.CenterY);
            _scaled = true;
            this.Invalidate();
            return true;
        }
Exemplo n.º 18
0
        /// <summary>
        /// Initialize implementation from IMapView.
        /// </summary>
        /// <param name="mapLayout"></param>
        void IMapViewSurface.Initialize(MapView mapLayout)
        {
            _mapView = mapLayout;
            this.SetWillNotDraw(false);

            this.MapMinZoomLevel = 10;
            this.MapMaxZoomLevel = 20;

            _renderer = new MapRenderer<global::Android.Graphics.Canvas>(
                new CanvasRenderer2D());

            // initialize the gesture detection.
            this.SetOnTouchListener(this);
            _scaleGestureDetector = new ScaleGestureDetector(
                this.Context, this);
            _rotateGestureDetector = new RotateGestureDetector(
                this.Context, this);
            _moveGestureDetector = new MoveGestureDetector(
                this.Context, this);
            _tagGestureDetector = new TapGestureDetector(
                this.Context, this);

            _makerLayer = new LayerPrimitives(
                new WebMercator());

            // initialize all the caching stuff.
            _cacheRenderer = new MapRenderer<global::Android.Graphics.Canvas>(
                new CanvasRenderer2D());
            _scene = new Scene2DSimple();
            _scene.BackColor = SimpleColor.FromKnownColor(KnownColor.White).Value;

            new Timer(InvalidateSimple, null, 0, 50);
        }
Exemplo n.º 19
0
 /// <summary>
 /// Raises the scale begin event.
 /// </summary>
 /// <param name="detector">Detector.</param>
 public bool OnScaleBegin(ScaleGestureDetector detector)
 {
     return true;
 }
Exemplo n.º 20
0
 private void OnScale(object sender, ScaleGestureDetector.ScaleEventArgs ev)
 {
     var zoom = ev.Detector.PreviousSpan / ev.Detector.CurrentSpan;
     var current = this.startFOV * zoom;
     if (current >= MinFOV && current <= MaxFOV)
     {
         this.renderer.FieldOfView = current;
     }
 }
Exemplo n.º 21
0
 /// <summary>
 /// Initialize this instance.
 /// </summary>
 void Initialize()
 {
     // initialize the gesture detection.
     _gestureDetector= new GestureDetector(
         this);
     _scaleGestureDetector = new ScaleGestureDetector(
         this.Context, this);
     this.SetOnTouchListener(this);
 }
Exemplo n.º 22
0
            public WaveFormLayout(WaveFormScrollView scrollView) : base(scrollView.Context)
            {
                _scrollView = scrollView;
                Orientation = Orientation.Vertical;
                //SetBackgroundColor(Color.DarkOrange);

                int height = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 22, Resources.DisplayMetrics);
                ScaleView = new WaveFormScaleView(Context);
                ScaleView.SetBackgroundColor(Color.Purple);
                AddView(ScaleView, new LinearLayout.LayoutParams(LayoutParams.WrapContent, height));

                WaveView = new WaveFormView(Context);
                //WaveView.SetBackgroundColor(Color.DarkRed);
                AddView(WaveView, new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.FillParent));

                _panGestureDetector = new GestureDetector(Context, new PanListener(_scrollView));
                _scaleGestureDetector = new ScaleGestureDetector(Context, new ScaleListener(_scrollView));
                _scroller = new OverScroller(Context);
            }
Exemplo n.º 23
0
        public bool OnScaleBegin(ScaleGestureDetector detector)
        {
            var args = new ScaleGestureDetector.ScaleBeginEventArgs(true, detector);

            var handler = this.ScaleBegin;
            if (handler != null)
            {
                handler(this, args);
            }

            return args.Handled;
        }
Exemplo n.º 24
0
            public override bool OnScaleBegin(ScaleGestureDetector detector)
            {
                //Console.WriteLine("ScaleListener - OnScaleBegin - scaleFactor: {0}", detector.ScaleFactor);
                if (_scrollView.WaveView.IsLoading)
                    return base.OnScaleBegin(detector);

                _startZoom = _scrollView.Zoom;
                _startContentOffsetX = _scrollView.WaveView.ContentOffset.X;
                SetScrollViewScale(detector.ScaleFactor, detector.FocusX);
                return base.OnScaleBegin(detector);
            }
Exemplo n.º 25
0
 public GestureListener(Context context)
 {
     this.numberOfPointers = 0;
     this.gestureScanner = new GestureDetector(this);
     this.scaleGestureScanner = new ScaleGestureDetector(context, this);
 }
Exemplo n.º 26
0
 public override bool OnScale(ScaleGestureDetector detector)
 {
     //Console.WriteLine("ScaleListener - OnScale - scaleFactor: {0}", detector.ScaleFactor);
     SetScrollViewScale(detector.ScaleFactor, detector.FocusX);                
     return base.OnScale(detector);
 }
Exemplo n.º 27
0
        /// <summary>
        /// Raises the scale event.
        /// </summary>
        /// <param name="detector">Detector.</param>
        public bool OnScale(ScaleGestureDetector detector)
        {
            _deltaScale = detector.ScaleFactor;

            return true;
        }
Exemplo n.º 28
0
 public override void OnScaleEnd(ScaleGestureDetector detector)
 {
     //Console.WriteLine("ScaleListener - OnScaleEnd - scaleFactor: {0}", detector.ScaleFactor);
     SetScrollViewScale(detector.ScaleFactor, detector.FocusX);
     base.OnScaleEnd(detector);
 }
Exemplo n.º 29
0
 /// <summary>
 /// Raises the scale end event.
 /// </summary>
 /// <param name="detector">Detector.</param>
 public void OnScaleEnd(ScaleGestureDetector detector)
 {
     _deltaScale = 1;
 }
Exemplo n.º 30
0
 public override bool OnScale(ScaleGestureDetector detector)
 {
     _view.ScaleCropper(detector.ScaleFactor);
     return true;
 }