2) there is another solution : use a round rectangle as a Mask, draw a gradient rectangle and apply the mask on it to obtain the gradient-round-rectangle wanted ...
here is a function that do the job:
function FillGradientRoundRect(gr, x, y, w, h, arc_width, arc_height, gradient_angle, bg_colour1, bg_colour2, focus) {
// drawing the Mask
var Mask_img = gdi.CreateImage(w+1, h+1);
var gb = Mask_img.GetGraphics();
gb.FillSolidRect(0,0,w,h,0xffffffff);
gb.SetSmoothingMode(2);
gb.FillRoundRect(0, 0, w-2, h-2, arc_width, arc_height, 0xff000000);
Mask_img.ReleaseGraphics(gb);
// drawing the gradient rect
var GradientRect_img = gdi.CreateImage(w+1, h+1);
gb = GradientRect_img.GetGraphics();
gb.FillGradRect(0, 0, w-2, h-2, gradient_angle, bg_colour1, bg_colour2, focus);
GradientRect_img.ReleaseGraphics(gb);
// resizing and applying the mask
var Mask = Mask_img.Resize(w+1, h+1);
GradientRect_img.ApplyMask(Mask);
Mask.Dispose();
// drawing the resulting image
gr.DrawImage(GradientRect_img, x, y, w-1, h-1, 0, 0, w, h, 0, 255);
}
and this is an example of call to use in on_paint:
function on_paint(gr) {
FillGradientRoundRect(gr, 10, 10, 100, 60, 15, 15, 90, 0xffeeee22, 0xffff5533, 1.0);
}
... and the result is like this in a panel