Exemplo n.º 1
0
        /// <summary>
        /// Diposes of all resources associated with this object.
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            if (disposing == true)
            {
                //someone wants the deterministic release of all resources
                //Let us release all the managed resources
            }
            else
            {
                // Do nothing, no one asked a dispose, the object went out of
                // scope and finalized is called so lets next round of GC
                // release these resources
            }

            // Release the unmanaged resource in any case as they will not be
            // released by GC
            this._cacheRenderer = null;
            if (this._offScreenBuffer != null)
            { // dispose of the map view surface.
                this._offScreenBuffer.Dispose();
                this._offScreenBuffer = null;
            }
            if (this._onScreenBuffer != null)
            { // dispose of the map view surface.
                this._onScreenBuffer.Dispose();
                this._onScreenBuffer = null;
            }
            if (this._mapViewAnimator != null)
            {
                _mapViewAnimator.Stop();
                _mapViewAnimator = null;
            }
            if (this._map != null)
            {
                this._map = null;
            }

            this._scaleGestureDetector  = null;
            this._tagGestureDetector    = null;
            this._moveGestureDetector   = null;
            this._rotateGestureDetector = null;
        }
Exemplo n.º 2
0
        private void init()
        {
            base.SetScaleType(ScaleType.Matrix);
            if (mScaleType == null)
            {
                mScaleType = ScaleType.CenterInside;
            }
            mRotateDetector = new RotateGestureDetector(mRotateListener);
            mDetector       = new GestureDetector(Context, mGestureListener);
            mScaleDetector  = new ScaleGestureDetector(Context, mScaleListener);
            float density = Resources.DisplayMetrics.Density;

            MAX_OVER_SCROLL       = (int)(density * 30);
            MAX_FLING_OVER_SCROLL = (int)(density * 30);
            MAX_OVER_RESISTANCE   = (int)(density * 140);

            mMinRotate   = MIN_ROTATE;
            mAnimaDuring = ANIMA_DURING;
            mMaxScale    = MAX_SCALE;
        }
Exemplo n.º 3
0
        public override bool OnScale(ScaleGestureDetector detector)
        {
            float newScale = _scale * detector.ScaleFactor;            //Math.Min(Math.Max(_scale * detector.ScaleFactor, ZoomMin), ZoomMax);

            if (/*newScale < 1 ||*/ newScale > _zoomMax)
            {
                return(false);
            }

            _scale = Math.Min(Math.Max(newScale, 1), ZoomMax);

            if (_zoomEnabled)
            {
                return(base.OnScale(detector));
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initialize this instance.
        /// </summary>
        void Initialize()
        {
            // create the Open GL 2D target.
            _target = new OpenGLTarget2D();
            this.SetRenderer(_target);

            // initialize the gesture detection.
            _gestureDetector = new GestureDetector(
                this);
            _scaleGestureDetector = new ScaleGestureDetector(
                this.Context, this);
            this.SetOnTouchListener(this);

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

            // initialize the scene.
            _scene           = new Scene2DSimple();
            _scene.BackColor = SimpleColor.FromKnownColor(KnownColor.White).Value;
        }
Exemplo n.º 5
0
        private void Initialize(Context c)
        {
            // Set the background color the white. This is actually redundant, whilst the map can't be zoomed out more than the size of the view. So this background color won't show. We've kept it in as a safeguard.
            this.SetBackgroundColor(Color.White);

            BitmapFactory.Options MapOptions = new BitmapFactory.Options();
            // Disable scaling due to memory limitations
            MapOptions.InScaled = false;
            // Load the bitmap of the map
            this.Map = BitmapFactory.DecodeResource(this.Resources, Resource.Drawable.Map, MapOptions);

            // Initialize the scale and pinch gestures
            this.ScaleDetector = new ScaleGestureDetector(c, this);
            this.Touch        += this.RegisterTouchEvent;

            // Initialize the location listener. Use Fine Accuarcy and receive updates as often as possible.
            LocationManager lm   = (LocationManager)c.GetSystemService(Context.LocationService);
            Criteria        crit = new Criteria();

            crit.Accuracy = Android.Locations.Accuracy.Fine;
            string lp = lm.GetBestProvider(crit, true);

            lm.RequestLocationUpdates(lp, 0, 0.5f, this);

            // Initialize the sensor manager for the orientation
            SensorManager sm = (SensorManager)c.GetSystemService(Context.SensorService);

            sm.RegisterListener(this, sm.GetDefaultSensor(SensorType.Orientation), SensorDelay.Ui);

            // Set the default map offset to the center of the map
            this.SetLocation(new PointF((MapView.MapEastRD + MapView.MapWestRD) / 2, (MapView.MapNorthRD + MapView.MapSouthRD) / 2));

            // Set the current Location to the last know location
            try
            {
                this.CurrentRDLocation = Projectie.Geo2RD(lm.GetLastKnownLocation(lp));
                this.CenterMapToCurrentLocation();
            }
            catch (Exception) { }
        }
Exemplo n.º 6
0
            public override bool OnScale(ScaleGestureDetector detector)
            {
                spanX = detector.CurrentSpanX;
                spanY = detector.CurrentSpanY;

                double angle = (Math.Atan2(spanY, spanX));

                angle = angle * (180.0 / Math.PI);
                if (angle < 45)
                {
                    _view.ScalingTime = true;
                    if (firstSpanX > spanX + scaleTreshold)
                    {
                        _view.Service.Execute(new NextTimeBaseCommand());
                        firstSpanX = spanX;
                    }
                    else if (firstSpanX < spanX - scaleTreshold)
                    {
                        _view.Service.Execute(new PreviousTimeBaseCommand());
                        firstSpanX = spanX;
                    }
                }
                else
                {
                    _view.ScalingTime = false;
                    if (firstSpanY > spanY + scaleTreshold)
                    {
                        firstSpanY = spanY;
                        _view.Service.Execute(new PreviousVoltsPerDivisionCommand(_view.SelectedChannel));
                    }
                    else if (firstSpanY < spanY - scaleTreshold)
                    {
                        firstSpanY = spanY;
                        _view.Service.Execute(new NextVoltsPerDivisionCommand(_view.SelectedChannel));
                    }
                }
                _view.Invalidate();
                return(true);
            }
Exemplo n.º 7
0
        private void Initialize()
        {
            SetEGLContextClientVersion(2); // GLES 2
                                           //			SetZOrderOnTop(true);
                                           //			SetEGLConfigChooser(8, 8, 8, 8, 16, 0);
                                           //			Holder.SetFormat(Format.Rgba8888);
                                           //			//		setEGLConfigChooser(8, 8, 8, 8, 16, 0);
                                           //			//		setDebugFlags(DEBUG_CHECK_GL_ERROR | DEBUG_LOG_GL_CALLS);

            // TODO: find better way to handle shaders. Static dont work when restarting context
            AmbientShader.Reset();
            ThresholdShader.Reset();
            TextureShader.Reset();


            renderer = new CountViewRenderer(Context);
            SetRenderer(renderer);

            gestureDetector = new GestureDetector(this);
            gestureDetector.IsLongpressEnabled = true;
            scaleGestureDetector = new ScaleGestureDetector(Context, this);
        }
Exemplo n.º 8
0
        public bool OnScale(ScaleGestureDetector detector)
        {
            float scale       = getScale();
            float scaleFactor = detector.ScaleFactor;

            if (Drawable == null)
            {
                return(true);
            }

            /**
             * 缩放的范围控制
             */
            if ((scale < SCALE_MAX && scaleFactor > 1.0f) ||
                (scale > initScale && scaleFactor < 1.0f))
            {
                /**
                 * 最大值最小值判断
                 */
                if (scaleFactor * scale < initScale)
                {
                    scaleFactor = initScale / scale;
                }
                if (scaleFactor * scale > SCALE_MAX)
                {
                    scaleFactor = SCALE_MAX / scale;
                }

                /**
                 * 设置缩放比例
                 */
                mScaleMatrix.PostScale(scaleFactor, scaleFactor,
                                       detector.FocusX, detector.FocusY);
                checkBorderAndCenterWhenScale();
                ImageMatrix = mScaleMatrix;
            }
            return(true);
        }
Exemplo n.º 9
0
            public override void OnScaleEnd(ScaleGestureDetector detector)
            {
                base.OnScaleEnd(detector);
                _view.SetState(TouchState.None);
                var animateToZoomBoundary = false;
                var targetZoom            = _view._normalizedScale;

                if (_view._normalizedScale > _view._maxScale)
                {
                    targetZoom            = _view._maxScale;
                    animateToZoomBoundary = true;
                }
                else if (_view._normalizedScale < _view._minScale)
                {
                    targetZoom            = _view._minScale;
                    animateToZoomBoundary = true;
                }
                if (animateToZoomBoundary)
                {
                    var doubleTap = new DoubleTapZoom(_view, targetZoom, _view.ViewWidth / 2f, _view.ViewHeight / 2f, true);
                    _view.CompatPostOnAnimation(doubleTap);
                }
            }
Exemplo n.º 10
0
        public bool OnScale(ScaleGestureDetector detector)
        {
            float previousScale = mScale;

            mScale = Math.Min(Math.Max(mScale * detector.ScaleFactor, MinScale), MaxScale);
            {
                var factor = mScale / previousScale;
                var v      = GetChildAt(0);
                if (v != null)
                {
                    mListTopOffset  = (int)(mListTopOffset * factor);
                    mListTop        = (int)(mListTop * factor);
                    mListLeftOffset = (int)(mListLeftOffset * factor);
                    mListLeft       = (int)(mListLeft * factor);
                    var viewFocusX = (int)(detector.FocusX * factor - detector.FocusX);
                    var viewFocusY = (int)(detector.FocusY * factor - detector.FocusY);
                    mListTop  -= viewFocusY;
                    mListLeft -= viewFocusX;
                    RequestLayout();
                }
            }
            return(true);
        }
Exemplo n.º 11
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View rootView = inflater.Inflate(Resource.Layout.fragment_scale, container, false);

            View rect = rootView.FindViewById(Resource.Id.rect);

            SpringSystem springSystem = SpringSystem.Create();
            Spring       spring       = springSystem.CreateSpring();

            spring.AddListener(new Performer(rect, View.ScaleXs));
            spring.AddListener(new Performer(rect, View.ScaleYs));

            spring.SetCurrentValue(1.0f);

            ScaleGestureDetector scaleGestureDetector = new ScaleGestureDetector(this.Activity, new OnScaleGestureListener(spring));

            rootView.Touch += (sender, e) =>
            {
                e.Handled = scaleGestureDetector.OnTouchEvent(e.Event);
            };

            return(rootView);
        }
Exemplo n.º 12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here

            // Activityテーマを設定
            base.SetTheme(Resource.Style.ARActivityTheme);

            // 説明文を表示
            SetContentView(Resource.Layout.OverlayView);
            var textView = FindViewById <TextView>(Resource.Id.textView1);
            var label    = GetString(Resource.String.marker_description);

            textView.SetText(label, TextView.BufferType.Normal);

            // フェードアウト処理
            Animation.FadeOut(textView);

            GestureDetect         = new GestureDetectorCompat(this, this);
            ScaleGestureDetect    = new ScaleGestureDetector(this, this);
            RotationGestureDetect = new RotationGestureDetector(this);
        }
Exemplo n.º 13
0
 public void SharedConstructing(Context context)
 {
     this.Clickable   = true;
     this.context     = context;
     mScaleDetector   = new ScaleGestureDetector(context, new ScaleListener(this));
     mGestureDetector = new GestureDetector(context, new GestureListener(this));
     matrix           = new Matrix();
     prevMatrix       = new Matrix();
     m = new float[9];
     normalizedScale = 1;
     if (mScaleType == null)
     {
         mScaleType = ScaleType.FitCenter;
     }
     minScale         = 1;
     maxScale         = 3;
     superMinScale    = SUPER_MIN_MULTIPLIER * minScale;
     superMaxScale    = SUPER_MAX_MULTIPLIER * maxScale;
     this.ImageMatrix = matrix;
     SetScaleType(ScaleType.Matrix);
     SetState(TouchState.NONE);
     base.SetOnTouchListener(new TouchImageViewListener(this));
 }
Exemplo n.º 14
0
        public bool OnScale(ScaleGestureDetector detector)
        {
            float scale = 1 - detector.ScaleFactor;

            float prevScale = mScale;

            mScale += scale;

            if (mScale < 0.5f) // Minimum scale condition:
            {
                mScale = 0.5f;
            }

            if (mScale > 1f) // Maximum scale condition:
            {
                mScale = 1f;
            }
            ScaleAnimation scaleAnimation = new ScaleAnimation(1f / prevScale, 1f / mScale, 1f / prevScale, 1f / mScale, detector.FocusX, detector.FocusY);

            scaleAnimation.Duration  = 0;
            scaleAnimation.FillAfter = true;
            StartAnimation(scaleAnimation);
            return(true);
        }
Exemplo n.º 15
0
            public override void OnScaleEnd(ScaleGestureDetector detector)
            {
                base.OnScaleEnd(detector);
                view.SetState(TouchState.NONE);
                bool  animateToZoomBoundary = false;
                float targetZoom            = view.normalizedScale;

                if (view.normalizedScale > view.maxScale)
                {
                    targetZoom            = view.maxScale;
                    animateToZoomBoundary = true;
                }
                else if (view.normalizedScale < view.minScale)
                {
                    targetZoom            = view.minScale;
                    animateToZoomBoundary = true;
                }

                if (animateToZoomBoundary)
                {
                    DoubleTapZoom doubleTap = new DoubleTapZoom(view, targetZoom, view.viewWidth / 2, view.viewHeight / 2, true);
                    view.CompatPostOnAnimation(doubleTap);
                }
            }
Exemplo n.º 16
0
        //initialiseer de eigen view
        public RunningView(Context c) : base(c)
        {
            BitmapFactory.Options options;
            options          = new BitmapFactory.Options();
            options.InScaled = false;

            //voor het aanraken van het scherm
            det         = new ScaleGestureDetector(c, this);
            det2        = new GestureDetector(c, this);
            this.Touch += raakAan;

            //laad de plaatjes
            p  = BitmapFactory.DecodeResource(c.Resources, Resource.Drawable.Utrecht, options);
            p1 = BitmapFactory.DecodeResource(c.Resources, Resource.Drawable.character2, options);

            //laad de sensor voor kompas
            SensorManager sm = (SensorManager)c.GetSystemService(Context.SensorService);

            sm.RegisterListener(this, sm.GetDefaultSensor(SensorType.Orientation), SensorDelay.Ui);

            //voor de locatie
            LocationManager lm   = (LocationManager)c.GetSystemService(Context.LocationService);
            Criteria        crit = new Criteria();

            crit.Accuracy = Accuracy.Fine;
            string lp = lm.GetBestProvider(crit, true);

            //positie wordt geupdate elke 500 ms en bij een verandering
            lm.RequestLocationUpdates(lp, 1000, 0, this);

            //beginwaardes declareren
            centrum = new PointF(139000, 455500);
            plek    = new PointF(138300, 454300);
            rad     = Math.Min(p1.Height / 4, p1.Width / 4);
            Schaal  = 1.25f;
        }
Exemplo n.º 17
0
 public void OnScaleEnd(ScaleGestureDetector detector)
 {
 }
Exemplo n.º 18
0
 public bool OnScale(ScaleGestureDetector detector)
 {
     scene.ScaleCamera(1.0f / detector.ScaleFactor);
     return(true);
 }
Exemplo n.º 19
0
 public bool OnScaleBegin(ScaleGestureDetector detector)
 {
     return(true);
 }
Exemplo n.º 20
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            viewportHeight = Height; viewportWidth = Width;

            string vertexShaderCode   = null;
            string fragmentShaderCode = null;

            try {
                vertexShaderCode   = FileTools.getContentByStream(Context.Assets.Open("Shaders/Spot/vs.glsl"));
                fragmentShaderCode = FileTools.getContentByStream(Context.Assets.Open("Shaders/Spot/fs.glsl"));
                spotShader         = new Shader(vertexShaderCode, fragmentShaderCode);

                vertexShaderCode   = FileTools.getContentByStream(Context.Assets.Open("Shaders/Depth/vs.glsl"));
                fragmentShaderCode = FileTools.getContentByStream(Context.Assets.Open("Shaders/Depth/fs.glsl"));
                depthShader        = new Shader(vertexShaderCode, fragmentShaderCode);
            }
            catch (Exception ex) {
                throw new Exception("Can't load shaders from file: {0}", ex);
            }

            //////////////////////////////////////////////////////////////////////

            ObjMesh sphere = new ObjMesh(Context, "triad_sphere.obj");

            scene     = new Scene.Scene(spotShader);
            scene.Cam = new Scene.Camera(new Vector3(0.0f, 0.0f, 10.0f));
            Vector3 lightAtt = new Vector3(1.0f, 0.00f, 0.02f);

            Light light;

            light = new Light();
            Objects.InitSpotLight(ref light);
            light.direction   = new Vector3(1.0f, 0.0f, 0.0f);
            light.color       = new Vector4(0.0f, 0.5f, 1.0f, 1.0f);
            light.attenuation = lightAtt;
            scene.appendLight(light);

            light = new Light();
            Objects.InitSpotLight(ref light);
            light.direction   = new Vector3(-1.0f, 0.0f, 0.0f);
            light.color       = new Vector4(1.0f, 0.0f, 0.0f, 1.0f);
            light.attenuation = lightAtt;
            scene.appendLight(light);

            light = new Light();
            Objects.InitSpotLight(ref light);
            light.direction   = new Vector3(0.0f, 0.0f, 1.0f);
            light.color       = new Vector4(1.0f, 0.5f, 0.0f, 1.0f);
            light.attenuation = lightAtt;
            scene.appendLight(light);

            light = new Light();
            Objects.InitPointLight(ref light);
            light.pos         = new Vector3(0.0f, 6.0f, 6.0f);
            light.color       = new Vector4(0.0f, 0.75f, 0.0f, 1.0f);
            light.attenuation = lightAtt;
            scene.appendLight(light);

            float d  = 2.0f;
            int   id = 0;

            for (int i = -1; i < 2; ++i)
            {
                for (int j = -1; j < 2; ++j)
                {
                    for (int k = -1; k < 2; ++k)
                    {
                        if (i == 0 && j == 0 && k == 0)
                        {
                            continue;
                        }
                        Scene.Object obj = new Scene.Object()
                        {
                            Position = new Transformation()
                            {
                                TranslateVector = new Vector3(d * i, d * j, d * k),
                                ScaleFactor     = 0.8f
                            },
                            Mesh = sphere,
                            Id   = id++,
                        };
                        scene.appendObject(obj);
                    }
                }
            }

            mScaleDetector = new ScaleGestureDetector(Context, this);

            //UpdateFrame += delegate(object sender, FrameEventArgs args)
            //{
            //};

            RenderFrame += delegate
            {
                Render();
            };

            scene.setViewport(Width, Height);
            scene.init();

            Run(30);
        }
Exemplo n.º 21
0
 public ZoomableLayout(Android.Content.Context context, IAttributeSet attrs) : base(context, attrs)
 {
     _scaleDetector = new ScaleGestureDetector(context, new ScaleListener(this));
     _moveDetector  = new GestureDetector(context, new GestureListener(this));
 }
Exemplo n.º 22
0
 public override bool OnScaleBegin(ScaleGestureDetector detector)
 {
     _view.SetState(TouchState.Zoom);
     return(true);
 }
Exemplo n.º 23
0
 public override bool OnScale(ScaleGestureDetector detector)
 {
     _view.ScaleImage(detector.ScaleFactor, detector.FocusX, detector.FocusY, true);
     return(true);
 }
Exemplo n.º 24
0
        public PanZoomImageRenderer(Context context) : base(context)
        {
            _scaleDetector = new ScaleGestureDetector(context, new ScaleListener(this));

            SetWillNotDraw(false);
        }
Exemplo n.º 25
0
 public override bool OnScale(ScaleGestureDetector detector)
 {
     _parent.OnScale(detector);
     return(true);
 }
Exemplo n.º 26
0
 public void OnScale(ScaleGestureDetector detector)
 {
     Scale(detector.ScaleFactor, detector.FocusX, detector.FocusY);
 }
 public bool OnScaleBegin(ScaleGestureDetector detector) => true;
        public FroyoGestureDetector(Context context) : base(context)
        {
            OnScaleGestureListener mScaleListener = new OnScaleGestureListener(this);

            Detector = new ScaleGestureDetector(context, mScaleListener);
        }
Exemplo n.º 29
0
 public SubLayout(Context context) : base(context)
 {
     this.scaleDetector = new ScaleGestureDetector(context, new ScaleListener(this));
     this.SetWillNotDraw(false);
     base.Clickable = true;
 }
Exemplo n.º 30
0
 public override void OnScaleEnd(ScaleGestureDetector detector)
 {
     _pinchEndedDelegate();
 }