Position: CSST软件>> Tag : .net compact framework                          

基于.Net Compact Framework的窗体GUI设计 ( Archived on 2008-12-12 10:12:10 328 Views )

整理一些平时工作中用到的winodws mobile界面开发规范及常用方法:
1.菜单的设计
ppc主窗体MaximizeBox = true,显示为"x",其它窗体MaximizeBox=false显示为"ok";
菜单mainMenu,左菜单不建议有弹出子菜单,为最常用的一个操作,右菜单可设置有弹出子菜单,集合其它操作,菜单级数不要超过3级,合理使用分隔线。

2.程序退出。主窗体this.Close()时应用程序退出,其它时间可调用Application.Exit()退出程序,不建议这样做,因为Application.Exit()时没有执行closing方法仅终止消息循环中的windows消息。

3.窗体全屏最大化:this.WindowState=FormWindowState.Maximized;

4.合理使用进度条或光标动画提醒用户有操作正在进行。
Cursor.Current = Cursors.WaitCursor;
  //todo
Cursor.Current = Cursors.Default;
 
5.ppc中控制输入面板的显示与关闭,6.0中提供inputPanel控件(Microsoft.WindowsCE.Forms)
inputPanel1.Enabled = true;
inputPanel1.Enabled = false;

SIP弹出时,可能要调整界面显示,以不让SIP遮住Form上的显示区域。

6.屏幕旋转,有些设备支持屏幕旋转,程序中可以检测屏幕分辨率
using Microsoft.WindowsCE.Forms;
PrimaryScreen.Bounds.Width;  Screen.PrimaryScreen.Bounds.Height //获取屏幕宽,高
SystemSettings.ScreenOrientation = ScreenOrientation.Angle270 //旋转支持横竖屏

7.合理使用Anchor定位和Dock停靠等属性来布局界面

8.确保一个应用程序在任务管理器中只出现一个Form
Form2 f2 = new Form2();
f2.Owner = this;
f2.ShowDialog();
-----
使用单件模式
private static frmMain _instance;

public static frmMain Instance()
{
    if (_instance == null)
    {
        _instance = new frmMain();
    }

    return _instance;
}

9.重绘界面,在窗体的Paint事件或重写OnPaint方法
protected override void OnPaint(PaintEventArgs e)
{
//重绘界面
   //e.Graphics.DrawString();
   //e.Graphics.DrawImage();
   base.OnPaint(e);
}

重绘背景
protected override void OnPaintBackground(PaintEventArgs e)
{
    e.Graphics.Clear(Color.DarkGreen);
}

10.做个启动画面加载,提高程序启动时的用户体验
static void Main()
{
    loadForm lf = new loadForm(); //这是启动画面,可以是全屏显示一个加载图片的窗体
    lf.Show();
    lf.Refresh();

    Form1 frm1 = new Form1(lf); //这是主窗体,在构造函数中接受参数保存,并在Paint事件中释放
    Application.Run(frm1);
}


Page 1 In 1 |   1  
Remark:无边落日萧萧下 不尽长江滚滚来
Contact Us For: CSST软件 | About Us:关于我们
Powered By CSST Soft Studio CopyRight 2008 - 2010