CairoSamples.Form1.roundedRectangleToolStripMenuItem_Click C# (CSharp) Метод

roundedRectangleToolStripMenuItem_Click() приватный Метод

private roundedRectangleToolStripMenuItem_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
Результат void
        private void roundedRectangleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            lastSelected = "roundedRectangle";
            OnPaintAction = cr =>
            {
                /* a custom shape that could be wrapped in a function */
                double x = 25.6,        /* parameters like cairo_rectangle */
                       y = 25.6,
                       width = 204.8,
                       height = 204.8,
                       aspect = 1.0,     /* aspect ratio */
                       corner_radius = height / 10.0;   /* and corner curvature radius */

                double radius = corner_radius / aspect;
                double degrees = Math.PI / 180.0;

                cr.NewSubPath();
                cr.Arc(x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees);
                cr.Arc(x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees);
                cr.Arc(x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees);
                cr.Arc(x + radius, y + radius, radius, 180 * degrees, 270 * degrees);
                cr.ClosePath();

                cr.SetSourceRGB(0.5, 0.5, 1);
                cr.FillPreserve();
                cr.SetSourceRGBA(0.5, 0, 0, 0.5);
                cr.LineWidth = 10.0;
                cr.Stroke();
            };

            Invalidate();
        }