D
DaveL
when painting the background of a mdi app window
how can i resolve the flicker when it paints
from darker to lighter colors
below is the code i wrote
private void ShellWindow_Gradient(object sender, PaintEventArgs e)
{
Graphics oGraphics = (Graphics)e.Graphics;
//enum i Defined
if (this.StyleType == NetToolsUI.WindowStyle.Solid)
{
this.oMdi.BackColor = this.SolidColor; //.RoyalBlue;
//.FromArgb(35,7,143); //.Brushes.AliceBlue;
}
else if (this.StyleType == NetToolsUI.WindowStyle.Gradient)
{
Rectangle rect = oMdi.ClientRectangle;
rect.Inflate(2, 2);// to completely fill the client area
LinearGradientBrush filler = new LinearGradientBrush(
rect,
this.SolidColor,
this.LightColor,
90,true); //this._angle);
oGraphics.FillRectangle(filler, rect);
filler.Dispose();
}
//Draw Some Text On the Window
// Create string to draw.
//e.MeasureString(drawString, this.Font);
// Create font and brush.
System.Drawing.SizeF TxtSize = oGraphics.MeasureString(Header,
this.HeaderFont);
SolidBrush GreyBrush = new SolidBrush(this.ShadowColor);
SolidBrush BlackBrush = new SolidBrush(this.HeaderColor);
// Create point for upper-left corner of drawing.
//x=widht
//y=height
//centers
//float x = (this.ClientSize.Width / 2) - (TxtSize.Width / 2);
//float y = (this.ClientSize.Height / 2) - (TxtSize.Height / 2);
float x = (oMdi.ClientSize.Width / 2) - (TxtSize.Width / 2);
float y = ((float)(oMdi.ClientSize.Height
/this.HeaderLocation)) - (float)(TxtSize.Height/HeaderLocation );
// Set format of string.
StringFormat drawFormat = new StringFormat();
drawFormat.FormatFlags =
StringFormatFlags.MeasureTrailingSpaces;
//draw Shadow
oGraphics.DrawString(Header, this.HeaderFont, GreyBrush, x + 3,
y + 3, drawFormat);
// Draw string to screen.
oGraphics.DrawString(Header, this.HeaderFont, BlackBrush, x, y,
drawFormat);
//draw Owner Notice bottom Right
BlackBrush = new SolidBrush(this.FooterColor);
TxtSize = oGraphics.MeasureString(Footer, this.FooterFont);
//text
oGraphics.DrawString(Footer, this.FooterFont, BlackBrush,
oMdi.ClientSize.Width - (TxtSize.Width+10),
oMdi.ClientSize.Height
- (TxtSize.Height+10), drawFormat);
}
Thanks DaveL
how can i resolve the flicker when it paints
from darker to lighter colors
below is the code i wrote
private void ShellWindow_Gradient(object sender, PaintEventArgs e)
{
Graphics oGraphics = (Graphics)e.Graphics;
//enum i Defined
if (this.StyleType == NetToolsUI.WindowStyle.Solid)
{
this.oMdi.BackColor = this.SolidColor; //.RoyalBlue;
//.FromArgb(35,7,143); //.Brushes.AliceBlue;
}
else if (this.StyleType == NetToolsUI.WindowStyle.Gradient)
{
Rectangle rect = oMdi.ClientRectangle;
rect.Inflate(2, 2);// to completely fill the client area
LinearGradientBrush filler = new LinearGradientBrush(
rect,
this.SolidColor,
this.LightColor,
90,true); //this._angle);
oGraphics.FillRectangle(filler, rect);
filler.Dispose();
}
//Draw Some Text On the Window
// Create string to draw.
//e.MeasureString(drawString, this.Font);
// Create font and brush.
System.Drawing.SizeF TxtSize = oGraphics.MeasureString(Header,
this.HeaderFont);
SolidBrush GreyBrush = new SolidBrush(this.ShadowColor);
SolidBrush BlackBrush = new SolidBrush(this.HeaderColor);
// Create point for upper-left corner of drawing.
//x=widht
//y=height
//centers
//float x = (this.ClientSize.Width / 2) - (TxtSize.Width / 2);
//float y = (this.ClientSize.Height / 2) - (TxtSize.Height / 2);
float x = (oMdi.ClientSize.Width / 2) - (TxtSize.Width / 2);
float y = ((float)(oMdi.ClientSize.Height
/this.HeaderLocation)) - (float)(TxtSize.Height/HeaderLocation );
// Set format of string.
StringFormat drawFormat = new StringFormat();
drawFormat.FormatFlags =
StringFormatFlags.MeasureTrailingSpaces;
//draw Shadow
oGraphics.DrawString(Header, this.HeaderFont, GreyBrush, x + 3,
y + 3, drawFormat);
// Draw string to screen.
oGraphics.DrawString(Header, this.HeaderFont, BlackBrush, x, y,
drawFormat);
//draw Owner Notice bottom Right
BlackBrush = new SolidBrush(this.FooterColor);
TxtSize = oGraphics.MeasureString(Footer, this.FooterFont);
//text
oGraphics.DrawString(Footer, this.FooterFont, BlackBrush,
oMdi.ClientSize.Width - (TxtSize.Width+10),
oMdi.ClientSize.Height
- (TxtSize.Height+10), drawFormat);
}
Thanks DaveL