由于工作的需要,开始学习C#的开发。在WINCE平台上将原有的代码从C++改用C#来实现,开发工具VS.net2005,看来漫漫自学旅途又要开始了。等我搞定后,会写些心得。有同样兴趣的朋友欢迎一起讨论。有这方面开发经验的朋友,希望也能不惜赐教。

20060321,使用VS2005的C#实现了移植到Windows CE 5.0下的九宫格菜单,对C#的编程心得收获不少,提出几点和大家一起分享.界面效果和C++相同,就不上传贴图了.

1.使用Off-Screen位图技术,避免导致显示设备资源不足
//Create off-screen
Bitmap bmpoff = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height);
Graphics gxoff = Graphics.FromImage(bmpoff);

//Draw to off-screen graphic
...

//Copy off-screen image onto on-screen
Graphics gxon = this.CreateGraphics();
gxon.DrawImage(bmpoff, 0, 0, this.ClientRectangle, GraphicsUnit.Pixel);

2.使用嵌入式资源
Assembly asm = Assembly.GetExecutingAssembly();
Bitmap background = new Bitmap(asm.GetManifestResourceStream("background.bmp"));

3.使用颜色键透明
ImageAttributes imgattr = new ImageAttributes();
imgattr.SetColorKey(Color.FromArgb(255, 0, 255), Color.FromArgb(255, 0, 255));