Example #1
0
        /// <summary>
        /// Raises the draw event.
        /// </summary>
        /// <param name="canvas">Canvas.</param>
        protected override void OnDraw(global::Android.Graphics.Canvas canvas)
        {
            try
            {
                base.OnDraw(canvas);

                if (_renderingSuspended)
                { // do nothing when rendering is suspended.
                    return;
                }

                // set the height/width.
                if (_surfaceHeight != canvas.Height ||
                    _surfaceWidth != canvas.Width)
                {
                    _surfaceHeight = canvas.Height;
                    _surfaceWidth = canvas.Width;

                    // make sure markers are in the correct position too.
                    _mapView.NotifyMapChange(this.SurfaceWidth, this.SurfaceHeight, this.CreateView(), this.Map.Projection);

                    // trigger rendering.
                    this.TriggerRendering();

                    // raise map initialized.
                    _mapView.RaiseMapInitialized();
                }

                if (_onScreenBuffer != null)
                { // there is a buffer.
                    // render only the cached scene.
                    canvas.DrawColor(new global::Android.Graphics.Color(_backgroundColor));
                    View2D view = this.CreateView();
                    float zoomFactor = (float)this.Map.Projection.ToZoomFactor(this.MapZoom);
                    _renderer.SceneRenderer.Render(
                        canvas,
                        view,
                        zoomFactor,
                        new Primitive2D[] { _onScreenBuffer });
                }
            }
            catch (Exception ex)
            {
                OsmSharp.Logging.Log.TraceEvent("MapViewSurface", TraceEventType.Critical,
                    string.Format("An unhandled exception occured:{0}", ex.ToString()));
            }
        }
Example #2
0
        /// <summary>
        /// Raises the draw event.
        /// </summary>
        /// <param name="canvas">Canvas.</param>
        protected override void OnDraw(global::Android.Graphics.Canvas canvas)
        {
            base.OnDraw(canvas);

            // set the height/width.
            if (_surfaceHeight != canvas.Height ||
                _surfaceWidth != canvas.Width)
            {
                _surfaceHeight = canvas.Height;
                _surfaceWidth = canvas.Width;

                // trigger rendering.
                this.TriggerRendering();
            }

            // render only the cached scene.
            canvas.DrawColor(new global::Android.Graphics.Color(_backgroundColor));
            View2D view = this.CreateView();
            float zoomFactor = (float)this.Map.Projection.ToZoomFactor(this.MapZoom);
            _renderer.SceneRenderer.Render(
                canvas,
                view,
                zoomFactor,
                new Primitive2D[] { _onScreenBuffer });
        }
Example #3
0
        /// <summary>
        /// Raises the draw event.
        /// </summary>
        /// <param name="canvas">Canvas.</param>
        protected override void OnDraw(global::Android.Graphics.Canvas canvas)
        {
            base.OnDraw (canvas);

            // render only the cached scene.
            lock(_scene)
            {
                canvas.DrawColor (new global::Android.Graphics.Color(_scene.BackColor));
                _renderer.SceneRenderer.Render (
                    canvas,
                    _scene,
                    this.CreateView());
            }
        }
Example #4
0
        /// <summary>
        /// Raises the draw event.
        /// </summary>
        /// <param name="canvas">Canvas.</param>
        protected override void OnDraw(global::Android.Graphics.Canvas canvas)
        {
            base.OnDraw (canvas);

            // set the height/width.
            if (_surfaceHeight != canvas.Height ||
                _surfaceWidth != canvas.Width)
            {
                _surfaceHeight = canvas.Height;
                _surfaceWidth = canvas.Width;

                // notify change.
                this.Change();
            }

            // render only the cached scene.
            lock(_scene)
            {
                canvas.DrawColor (new global::Android.Graphics.Color(_scene.BackColor));
                _renderer.SceneRenderer.Render (
                    canvas,
                    _scene,
                    this.CreateView());
            }
        }