AddArc() public method

public AddArc ( CGAffineTransform m, float x, float y, float radius, float startAngle, float endAngle, bool clockwise ) : void
m CGAffineTransform
x float
y float
radius float
startAngle float
endAngle float
clockwise bool
return void
コード例 #1
0
        public override void DrawRect(System.Drawing.RectangleF dirtyRect)
        {
            base.DrawRect(dirtyRect);

            if(!IsPlaying)
                return;           

            // Save context state
            CGContext context = NSGraphicsContext.CurrentContext.GraphicsPort;
            context.SaveState();

            // Calculate size
            float size = (Bounds.Width > Bounds.Height) ? Bounds.Height : Bounds.Width;
            float circleRadius = (size - 4) / 2;
            RectangleF rect = new RectangleF(padding / 2, padding / 2, size - padding, size - padding);

            CGColor color1 = GlobalTheme.PanelBackgroundColor1;
            CGColor color2 = GlobalTheme.PanelBackgroundColor2;
            CGGradient gradientBackground;
            CGColorSpace colorSpace = CGColorSpace.CreateDeviceRGB();            
            float[] locationListBackground = new float[] { 1.0f, 0.0f };
            List<float> colorListBackground = new List<float>();
            colorListBackground.AddRange(color1.Components);
            colorListBackground.AddRange(color2.Components);
            gradientBackground = new CGGradient(colorSpace, colorListBackground.ToArray(), locationListBackground);

            // Create path
            CGPath path = new CGPath();
            float x = Bounds.Width / 2;
            float y = Bounds.Height / 2;
            path.AddArc(x, y, circleRadius, 0, 2 * (float)Math.PI, false);
            path.AddArc(x, y, circleRadius / 3, 0, 2 * (float)Math.PI, false);
            context.AddPath(path);

            // Draw outline
            context.SetLineWidth(1.5f);
            context.SetStrokeColor(GlobalTheme.PanelBorderColor);
            context.StrokePath();

            // Clip path and draw gradient inside
            context.AddPath(path);
            context.EOClip();
            context.DrawLinearGradient(gradientBackground, new PointF(0, 0), new PointF(0, Bounds.Height), CGGradientDrawingOptions.DrawsAfterEndLocation);

            context.RestoreState();
        }