Administrator [Syncfusion]
Replied On December 13, 2002 05:07 PM UTC
Ramesh,
Thanks for the help. I got it to work.
I had to extend XPTaskBar and override OnPaint event.
Here is the resultant code... You may want to add this to the samples in future tools release. It looks pretty cool !!
cheers,
- Reddy
------------------------------
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
Rectangle rc = this.ClientRectangle;
int gradientWidth = 18;
LinearGradientBrush linGrBrush = new System.Drawing.Drawing2D.LinearGradientBrush(
new Point(0, 10),
new Point(gradientWidth, 10),
Color.FromArgb(255, 237, 241, 242), // Opaque
Color.FromArgb(255, 42, 78, 129)); // Opaque
float[] factors = {0.0f, 0.3f, 0.4f, 0.8f, 1.0f};
float[] positions = {0.0f, 0.1f, 0.2f, 0.4f, 1.0f};
//Create a Blend object and assign it to linGrBrush.
Blend blend = new Blend();
blend.Factors = factors;
blend.Positions = positions;
linGrBrush.Blend = blend;
// draw the gradient on the left edge
e.Graphics.FillRectangle(linGrBrush, 0, 0, gradientWidth+5, rc.Height);
// draw a filled rectangle rest of the area
using (Brush brush = new SolidBrush(Color.FromArgb(42, 78, 129)))
{
e.Graphics.FillRectangle(brush, gradientWidth, 0, rc.Width-gradientWidth, rc.Height);
}
linGrBrush.Dispose();
// get the image from a resource file
System.Resources.ResourceManager rm = new System.Resources.ResourceManager(
"ControlsLibrary.Images",
System.Reflection.Assembly.GetExecutingAssembly());
Image gearsImage = (Image)rm.GetObject("transparent_gears.gif");
ImageAttributes ia = new ImageAttributes();
ColorMatrix cm = new ColorMatrix();
cm.Matrix00 = 1;
cm.Matrix11 = 1;
cm.Matrix22 = 1;
float transparancy = .14f;
cm.Matrix33 = transparancy;
ia.SetColorMatrix(cm);
int imgWidth = gearsImage.Width;
int imgHeight = gearsImage.Height;
Rectangle destRect = new Rectangle(rc.Width-imgWidth, rc.Height-imgHeight, imgWidth, imgHeight);
e.Graphics.DrawImage(gearsImage, destRect, 0, 0, imgWidth, imgHeight,
GraphicsUnit.Pixel, ia);
}