当前位置: 首页>>代码示例>>C#>>正文


C# Canvas.GetClipBounds方法代码示例

本文整理汇总了C#中Android.Graphics.Canvas.GetClipBounds方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.GetClipBounds方法的具体用法?C# Canvas.GetClipBounds怎么用?C# Canvas.GetClipBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android.Graphics.Canvas的用法示例。


在下文中一共展示了Canvas.GetClipBounds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawChild

        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;
        }
开发者ID:maxgrig,项目名称:SlidingUpPanel,代码行数:38,代码来源:SlidingUpPanelLayout.cs

示例2: OnDraw

 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);
     }
 }
开发者ID:jcw-,项目名称:sparrowtoolkit,代码行数:11,代码来源:SparrowChartView.cs

示例3: OnDraw

        /// <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);
                }
            }
        }
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:50,代码来源:PlotView.cs

示例4: OnDraw

        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);
            }*/
        }
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:62,代码来源:PlotView.cs


注:本文中的Android.Graphics.Canvas.GetClipBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。