protected void OnPaintDisplayRect(Graphics g)
{
// are we animating a fade
if (this.animatingFade && this.AnimationImage != null)
{
// calculate the transparency value for the animation image
float alpha = (((float) (this.Height - this.HeaderHeight)) / ((float) (this.ExpandedHeight - this.HeaderHeight)));
float[][] ptsArray = {new float[] {1, 0, 0, 0, 0},
new float[] {0, 1, 0, 0, 0},
new float[] {0, 0, 1, 0, 0},
new float[] {0, 0, 0, alpha, 0},
new float[] {0, 0, 0, 0, 1}};
ColorMatrix colorMatrix = new ColorMatrix(ptsArray);
ImageAttributes imageAttributes = new ImageAttributes();
imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
// work out how far up the animation image we need to start
int y = this.AnimationImage.Height - this.PseudoClientHeight - this.Border.Bottom;
// draw the image
g.DrawImage(this.AnimationImage,
new Rectangle(0, this.HeaderHeight, this.Width, this.Height - this.HeaderHeight),
0,
y,
this.AnimationImage.Width,
this.AnimationImage.Height - y,
GraphicsUnit.Pixel,
imageAttributes);
}
// are we animating a slide
else if (this.animatingSlide)
{
// check if we have a background image
if (this.BackImage != null)
{
// tile the backImage
using (TextureBrush brush = new TextureBrush(this.BackImage, WrapMode.Tile))
{
g.FillRectangle(brush, this.DisplayRectangle);
}
}
else
{
// just paint the area with a solid brush
using (SolidBrush brush = new SolidBrush(this.BackColor))
{
g.FillRectangle(brush,
this.Border.Left,
this.HeaderHeight + this.Border.Top,
this.Width - this.Border.Left - this.Border.Right,
this.Height - this.HeaderHeight - this.Border.Top - this.Border.Bottom);
}
}
}
else
{
// check if we have a background image
if (this.BackImage != null)
{
// tile the backImage
using (TextureBrush brush = new TextureBrush(this.BackImage, WrapMode.Tile))
{
g.FillRectangle(brush, this.DisplayRectangle);
}
}
else
{
// just paint the area with a solid brush
using (SolidBrush brush = new SolidBrush(this.BackColor))
{
g.FillRectangle(brush, this.DisplayRectangle);
}
}
if (this.Watermark != null)
{
// work out a rough location of where the watermark should go
Rectangle rect = new Rectangle(0, 0, this.Watermark.Width, this.Watermark.Height);
rect.X = this.PseudoClientRect.Right - this.Watermark.Width;
rect.Y = this.DisplayRectangle.Bottom - this.Watermark.Height;
// shrink the destination rect if necesary so that we
// can see all of the image
if (rect.X < 0)
{
rect.X = 0;
}
if (rect.Width > this.ClientRectangle.Width)
{
rect.Width = this.ClientRectangle.Width;
}
if (rect.Y < this.DisplayRectangle.Top)
{
rect.Y = this.DisplayRectangle.Top;
}
if (rect.Height > this.DisplayRectangle.Height)
{
rect.Height = this.DisplayRectangle.Height;
}
// draw the watermark
g.DrawImage(this.Watermark, rect);
}
}
}