private void gradientToolStripMenuItem_Click(object sender, EventArgs e) { lastSelected = "gradient"; OnPaintAction = cr => { Gradient pat = new LinearGradient(0.0, 0.0, 0.0, 256.0); pat.AddColorStopRgba(1, 0, 0, 0, 1); pat.AddColorStopRgba(0, 1, 1, 1, 1); cr.Rectangle(0, 0, 256, 256); cr.SetSource(pat); cr.Fill(); pat.Dispose(); pat = new RadialGradient(115.2, 102.4, 25.6, 102.4, 102.4, 128.0); pat.AddColorStopRgba(0, 1, 1, 1, 1); pat.AddColorStopRgba(1, 0, 0, 0, 1); cr.SetSource(pat); cr.Arc(128.0, 128.0, 76.8, 0, 2 * Math.PI); cr.Fill(); pat.Dispose(); }; Invalidate(); }