Пример #1
0
            public override void Draw(global::Android.Graphics.Canvas canvas)
            {
                base.Draw (canvas);

                var g = new AndroidGraphics (canvas);

                _clock.Width = Width;
                _clock.Height = Height;

                _clock.Draw (g);
            }
        public override void Draw(global::Android.Graphics.Canvas canvas)
        {
            //
            // Start drawing
            //
            var del = Content;
            if (del == null) return;

            var startT = DateTime.Now;

            var _graphics = new AndroidGraphics (canvas);
            _graphics.SaveState ();
            _graphics.Scale (Zoom, Zoom);

            //
            // Draw
            //
            del.Frame = new RectangleF (0, 0, Width / Zoom, Height / Zoom);
            try {
                del.Draw (_graphics);
            }
            catch (Exception) {
            }

            _graphics.RestoreState ();

            var endT = DateTime.Now;

            _drawTime += (endT - startT).TotalSeconds;
            _drawCount++;

            //
            // Throttle
            //
            if (_running && _drawCount > 2 && (DateTime.Now - _lastThrottleTime) >= ThrottleInterval) {

                _lastThrottleTime = DateTime.Now;

                var maxfps = 1.0 / (_drawTime / _drawCount);
                _drawTime = 0;
                _drawCount = 0;

                var fps = ClampUpdateFreq((int)(maxfps * CpuUtilization));

                if (Math.Abs(fps - _fps) > 1) {
                    _fps = fps;
                    Start();
                }
            }

            //
            // Notify
            //
            var df = DrewFrame;
            if (df != null) {
                df(this, EventArgs.Empty);
            }

            if (_running) {
                _handler.PostDelayed (HandleDrawTimerElapsed, 1000 / _fps);
            }
        }
        public override void Draw(global::Android.Graphics.Canvas canvas)
        {
            //
            // Start drawing
            //
            var del = Content;

            if (del == null)
            {
                return;
            }

            var startT = DateTime.Now;

            var _graphics = new AndroidGraphics(canvas);

            _graphics.SaveState();
            _graphics.Scale(Zoom, Zoom);


            //
            // Draw
            //
            del.Frame = new RectangleF(0, 0, Width / Zoom, Height / Zoom);
            try {
                del.Draw(_graphics);
            }
            catch (Exception) {
            }

            _graphics.RestoreState();

            var endT = DateTime.Now;

            _drawTime += (endT - startT).TotalSeconds;
            _drawCount++;

            //
            // Throttle
            //
            if (_running && _drawCount > 2 && (DateTime.Now - _lastThrottleTime) >= ThrottleInterval)
            {
                _lastThrottleTime = DateTime.Now;

                var maxfps = 1.0 / (_drawTime / _drawCount);
                _drawTime  = 0;
                _drawCount = 0;

                var fps = ClampUpdateFreq((int)(maxfps * CpuUtilization));

                if (Math.Abs(fps - _fps) > 1)
                {
                    _fps = fps;
                    Start();
                }
            }

            //
            // Notify
            //
            var df = DrewFrame;

            if (df != null)
            {
                df(this, EventArgs.Empty);
            }

            if (_running)
            {
                _handler.PostDelayed(HandleDrawTimerElapsed, 1000 / _fps);
            }
        }