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


C# Path.AddRect方法代码示例

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


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

示例1: Draw

        public void Draw(Canvas canvas)
        {
            if (Hidden)
            {
                return;
            }

            canvas.Save();

            if (!Focused)
            {
                outlinePaint.Color = Color.White;
                canvas.DrawRect(DrawRect, outlinePaint);
            }
            else
            {
                Rect viewDrawingRect = new Rect();
                context.GetDrawingRect(viewDrawingRect);

                outlinePaint.Color = Color.White;// new Color(0XFF, 0xFF, 0x8A, 0x00);
                focusPaint.Color = new Color(50, 50, 50, 125);

                Path path = new Path();
                path.AddRect(new RectF(DrawRect), Path.Direction.Cw);

                canvas.ClipPath(path, Region.Op.Difference);
                canvas.DrawRect(viewDrawingRect, focusPaint);

                canvas.Restore();
                canvas.DrawPath(path, outlinePaint);

                if (mode == ModifyMode.Grow)
                {
                    int left = DrawRect.Left + 1;
                    int right = DrawRect.Right + 1;
                    int top = DrawRect.Top + 4;
                    int bottom = DrawRect.Bottom + 3;

                    int widthWidth = resizeDrawableWidth.IntrinsicWidth / 2;
                    int widthHeight = resizeDrawableWidth.IntrinsicHeight / 2;
                    int heightHeight = resizeDrawableHeight.IntrinsicHeight / 2;
                    int heightWidth = resizeDrawableHeight.IntrinsicWidth / 2;

                    int xMiddle = DrawRect.Left + ((DrawRect.Right - DrawRect.Left) / 2);
                    int yMiddle = DrawRect.Top + ((DrawRect.Bottom - DrawRect.Top) / 2);

                    resizeDrawableWidth.SetBounds(left - widthWidth,
                                                   yMiddle - widthHeight,
                                                   left + widthWidth,
                                                   yMiddle + widthHeight);
                    resizeDrawableWidth.Draw(canvas);

                    resizeDrawableWidth.SetBounds(right - widthWidth,
                                                   yMiddle - widthHeight,
                                                   right + widthWidth,
                                                   yMiddle + widthHeight);
                    resizeDrawableWidth.Draw(canvas);

                    resizeDrawableHeight.SetBounds(xMiddle - heightWidth,
                                                    top - heightHeight,
                                                    xMiddle + heightWidth,
                                                    top + heightHeight);
                    resizeDrawableHeight.Draw(canvas);

                    resizeDrawableHeight.SetBounds(xMiddle - heightWidth,
                                                    bottom - heightHeight,
                                                    xMiddle + heightWidth,
                                                    bottom + heightHeight);
                    resizeDrawableHeight.Draw(canvas);
                }
            }
        }
开发者ID:kevinrood,项目名称:cropimage-xamarin,代码行数:72,代码来源:HighlightView.cs

示例2: Draw

        internal void Draw(Canvas canvas, bool isRound)
        {
            if (Hidden)
            {
                return;
            }

            canvas.Save();
            var resizerPaint = new Paint { Color = new Color(255, 255, 255, 200) };

            //if (!Focused)
            //{
            //    outlinePaint.Color = Color.White;
            //    canvas.DrawRect(DrawRect, outlinePaint);
            //    //canvas.DrawCircle(DrawRect.CenterX(), DrawRect.CenterY(), DrawRect.Width(), resizerPaint);
            //}
            //else
            //{
            Rect viewDrawingRect = new Rect();
            context.GetDrawingRect(viewDrawingRect);

            outlinePaint.Color = Color.White;// new Color(0XFF, 0xFF, 0x8A, 0x00);
            focusPaint.Color = new Color(50, 50, 50, 125);

            Path path = new Path();

            if (isRound)
            {
                path.AddCircle(DrawRect.CenterX(), DrawRect.CenterY(), DrawRect.Width() / 2, Path.Direction.Cw);
                canvas.ClipPath(path, Region.Op.Difference);
                canvas.DrawCircle(viewDrawingRect.CenterX(), viewDrawingRect.CenterY(), viewDrawingRect.Width(), focusPaint);
            }
            else
            {
                path.AddRect(new RectF(DrawRect), Path.Direction.Cw);
                canvas.ClipPath(path, Region.Op.Difference);
                canvas.DrawRect(viewDrawingRect, focusPaint);

            }

            //canvas.ClipPath(path, Region.Op.Difference);

            //if (isRound)
            //    canvas.DrawCircle(viewDrawingRect.CenterX(), viewDrawingRect.CenterY(), viewDrawingRect.Width(), focusPaint);
            //else
            //    canvas.DrawRect(viewDrawingRect, focusPaint);

            canvas.Restore();
            canvas.DrawPath(path, outlinePaint);

            var resizerTriangle = new Path();
            var resizerOffset = 4;
            var triangleSize = resizerSize + resizerOffset;
            resizerTriangle.MoveTo(DrawRect.Right - resizerOffset, DrawRect.Bottom - triangleSize);
            resizerTriangle.LineTo(DrawRect.Right - resizerOffset, DrawRect.Bottom - resizerOffset);
            resizerTriangle.LineTo(DrawRect.Right - triangleSize, DrawRect.Bottom - resizerOffset);
            resizerPaint.SetStyle(Paint.Style.Fill);
            canvas.DrawPath(resizerTriangle, resizerPaint);

            if (isRound)
            {
                // Draw the rectangle around the round cropper                
                var roundCropperRectangle = new Path();
                roundCropperRectangle.MoveTo(DrawRect.Left, DrawRect.Top);
                roundCropperRectangle.LineTo(DrawRect.Right, DrawRect.Top);
                roundCropperRectangle.LineTo(DrawRect.Right, DrawRect.Bottom);
                roundCropperRectangle.LineTo(DrawRect.Left, DrawRect.Bottom);
                roundCropperRectangle.LineTo(DrawRect.Left, DrawRect.Top);

                resizerPaint.SetStyle(Paint.Style.Stroke);
                canvas.DrawPath(roundCropperRectangle, resizerPaint);
            }
        }
开发者ID:nielscup,项目名称:ImageCrop,代码行数:73,代码来源:HighlightView.cs


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