示例#1
0
        /// <summary>
        /// Draws the content of the control.
        /// </summary>
        /// <param name="canvas">The canvas to draw on.</param>
        protected override void OnDraw(Canvas canvas)
        {
            base.OnDraw(canvas);
            var actualModel = this.ActualModel;

            if (actualModel == null)
            {
                return;
            }

            if (!actualModel.Background.IsUndefined())
            {
                canvas.DrawColor(actualModel.Background.ToColor());
            }
            else
            {
                // Use white as default background color
                canvas.DrawColor(Color.White);
            }

            lock (this.invalidateLock)
            {
                if (this.isModelInvalidated)
                {
                    ((IPlotModel)actualModel).Update(this.updateDataFlag);
                    this.updateDataFlag     = false;
                    this.isModelInvalidated = false;
                }
            }

            lock (this.renderingLock)
            {
                if (this.rc == null)
                {
                    this.rc = new CanvasRenderContext(Scale);
                }

                this.rc.SetTarget(canvas);
                using (var bounds = new Rect())
                {
                    canvas.GetClipBounds(bounds);
                    var width  = bounds.Right - bounds.Left;
                    var height = bounds.Bottom - bounds.Top;
                    ((IPlotModel)actualModel).Render(this.rc, width / Scale, height / Scale);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Draws the content of the control.
        /// </summary>
        /// <param name="canvas">The canvas to draw on.</param>
        protected override void OnDraw(Canvas canvas)
        {
            base.OnDraw(canvas);
            var actualModel = this.ActualModel;
            if (actualModel == null)
            {
                return;
            }

            if (!actualModel.Background.IsUndefined())
            {
                canvas.DrawColor(actualModel.Background.ToColor());
            }
            else
            {
                // Use white as default background color
                canvas.DrawColor(Color.White);
            }

            lock (this.invalidateLock)
            {
                if (this.isModelInvalidated)
                {
                    ((IPlotModel)actualModel).Update(this.updateDataFlag);
                    this.updateDataFlag = false;
                    this.isModelInvalidated = false;
                }
            }

            lock (this.renderingLock)
            {
                if (this.rc == null)
                {
                    this.rc = new CanvasRenderContext(Scale);
                }

                this.rc.SetTarget(canvas);
                using (var bounds = new Rect())
                {
                    canvas.GetClipBounds(bounds);
                    var width = bounds.Right - bounds.Left;
                    var height = bounds.Bottom - bounds.Top;
                    ((IPlotModel)actualModel).Render(this.rc, width / Scale, height / Scale);
                }
            }
        }