-1
我正在开发一个应用程序在Windows CE 5.0中使用C#.NET与Visual Studio 2008. 我想通过创建用户控件对象在主用户控件中显示一些用户控件。 在主用户控件中加载用户控件时,应用程序闪烁。如何避免在Windows CE应用程序中的UI闪烁?
例如我有1个用户控件,它有1个按钮图像,我想显示此用户控件的20个按钮。
`protected override void OnPaint(PaintEventArgs e) { //base.OnPaint(e); 图形gxOff = e.Graphics; 图形g;
//Paint the string
Font boldFont = new Font("Tahoma", 8.0F, FontStyle.Bold);
Color penColor = Color.FromArgb(48, 48, 48);
StringFormat drawFormat = new StringFormat();
drawFormat.Alignment = StringAlignment.Center;
if (m_bmpOffscreen == null) //Bitmap for doublebuffering
{
m_bmpOffscreen = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height);
}
g = Graphics.FromImage(m_bmpOffscreen);
g.Clear(this.BackColor);
if (!Disabled)
{
backgroundImage = unselected_img;
if (selected)
{
backgroundImage = selected_img;
g.DrawImage(backgroundImage, this.ClientRectangle, new Rectangle(0, 0, backgroundImage.Width, backgroundImage.Height), GraphicsUnit.Pixel);
}
else
g.DrawImage(backgroundImage, this.ClientRectangle, new Rectangle(0, 0, backgroundImage.Width, backgroundImage.Height), GraphicsUnit.Pixel);
}
else
{
backgroundImage = disabled_img;
g.DrawImage(backgroundImage, this.ClientRectangle, new Rectangle(0, 0, backgroundImage.Width, backgroundImage.Height), GraphicsUnit.Pixel);
}
g.DrawString(this.Content, boldFont, new SolidBrush(penColor), new RectangleF(0, 3, 20, 20), drawFormat);
gxOff.DrawImage(m_bmpOffscreen, 0, 0);
}`
请帮忙解决这个问题。
在此先感谢。
使用对接,面板,用户控件和用户控件中的控件的任何布局面板? – Reniuz 2012-02-02 10:49:23
我正在用户控件中的onpaint事件中绘制按钮图像,我试图在另一个用户控件中加载 – Shilpa 2012-02-02 11:04:35
因此请显示您的绘图代码。另外我认为添加20个用户控件绘制的东西不是好主意。 – Reniuz 2012-02-02 11:15:38