protected override bool DrawChild(Canvas canvas, View child, long drawingTime)
        {
            var lp = (LayoutParams) child.LayoutParameters;
            var save = canvas.Save(SaveFlags.Clip);

            var drawScrim = false;

            if (_canSlide && !lp.Slideable && _slideableView != null)
            {
                if (!OverlayContent)
                {
                    canvas.GetClipBounds(_tmpRect);
                    if (_isSlidingUp)
                        _tmpRect.Bottom = Math.Min(_tmpRect.Bottom, _slideableView.Top);
                    else
                        _tmpRect.Top = Math.Max(_tmpRect.Top, _slideableView.Bottom);

                    canvas.ClipRect(_tmpRect);
                }

                if (_slideOffset < 1)
                    drawScrim = true;
            }

            var result = base.DrawChild(canvas, child, drawingTime);
            canvas.RestoreToCount(save);

            if (drawScrim)
            {
                var baseAlpha = (_coveredFadeColor.ToArgb() & 0xff000000) >> 24;
                var imag = (int) (baseAlpha * (1 - _slideOffset));
                var color = imag << 24 | (_coveredFadeColor.ToArgb() & 0xffffff);
                _coveredFadePaint.Color = new Color(color);
                canvas.DrawRect(_tmpRect, _coveredFadePaint);
            }

            return result;
        }
Пример #2
0
 protected override void OnDraw(Canvas canvas)
 {
     base.OnDraw(canvas);
     canvas.DrawColor(Color.White);
     this.rootCanvas.SetTarget(canvas);
     using (var bounds = new Rect())
     {
         canvas.GetClipBounds(bounds);
         rootCanvas.DrawRectangle(new RectF(bounds.Left, bounds.Top, bounds.Width(), bounds.Height()), Color.Red, Color.Transparent, 0);
     }
 }
Пример #3
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);
                }
            }
        }
Пример #4
0
        protected override void OnDraw(Canvas canvas)
        {
            base.OnDraw(canvas);
            canvas.DrawColor(Color.White);

            lock (this.invalidateLock)
            {
                if (this.isModelInvalidated)
                {
                    if (this.model != null)
                    {
                        this.model.Update(this.updateDataFlag);
                        this.updateDataFlag = false;
                    }

                    this.isModelInvalidated = false;
                }
            }

            lock (this.renderingLock)
            {
                if (this.model != null)
                {
                    this.rc.SetTarget(canvas);
                    using (var bounds = new Rect())
                    {
                        canvas.GetClipBounds(bounds);

                        // Render the background
                        if (this.model.Background != null)
                        {
                            // TODO: can we set this.Background instead?
                            rc.DrawRectangle(new OxyRect(bounds.Left, bounds.Top, bounds.Width(), bounds.Height()), this.model.Background, null, 0);
                        }
                        
                        this.model.Render(rc, bounds.Right - bounds.Left, bounds.Bottom - bounds.Top);
                    }
                }
            }

            /*
            canvas.DrawColor(Color.White);

            using (var paint = new Paint())
            {
                paint.AntiAlias = true;
                paint.Color = new Color(0, 0, 0, 220);
                paint.StrokeWidth = 2;
                canvas.DrawLine(10f, 10f, canvas.Width - 10, h - 10, paint);
                canvas.DrawLine(canvas.Width - 10, 10f, 10, h - 10, paint);
                paint.TextSize = 24;
                paint.TextAlign = Paint.Align.Left;
                var textbounds = new Rect();
                paint.GetTextBounds("ABC", 0, 1, textbounds);
                var tw = paint.MeasureText("ABC");
                // canvas.DrawText(this.Text, 40, 200, paint);
                canvas.Translate(40, 40);
                canvas.DrawText("ABC=" + tw + "/" + textbounds, 0, 0, paint);
                canvas.Rotate(20);
                canvas.DrawText("ABC=" + tw, 0, 0, paint);
            }*/
        }