需求:页面有个任务中心,用户通过任务页面(wince的画面)。选择对应的任务记录跳转到对应的操作页面。比如,一个下架的任务(包含下架单号),选择该条任务跳转到对应的下架页面,并且初始化该页面的下架单号。
调用方法: NewTaskUcl(new PAAPAsnSelect(this), "asnNo_Tb", orderId);--第一个参数是页面的名称,第二个参数是页面文本框名,第三个参数是对应的初始化值。
方法明细
public void NewTaskUcl(BaseUcl baseUcl, string TaskOrderId, string defaultText)
{
baseUcl.Width = Global.mainForm.formPanel.Width;
baseUcl.Height = Global.mainForm.formPanel.Height;
Global.mainForm.formPanel.Controls.Remove(Global.currentUcl);
Global.currentUcl = baseUcl;
//主要是这段:其他可不看。
//baseUcl是页面的名称,取得它的FieldInfo
FieldInfo fieldInfo = baseUcl.GetType().GetField(TaskOrderId, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.CreateInstance);
//取得对应页面文本框的TEXT属性
if(fieldInfo!=null)
{
object objText = fieldInfo.GetValue(baseUcl);
PropertyInfo proPertyInfo=objText.GetType().GetProperty("Text", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.CreateInstance);
if (proPertyInfo != null)
{
proPertyInfo.SetValue(objText, defaultText, null);//把对应的值写入
}
}
Global.mainForm.formPanel.Controls.Add(baseUcl);
baseUcl.Resize += new EventHandler(Form_Resize);
baseUcl.BindLanguage();
Hide();
if (baseUcl.firstCtl != null)
{
baseUcl.firstCtl.Focus();
}
}
需求:既然是任务中心,肯定有消息提示功能。当有新的消息送达时候要有一个图片闪烁的提示功能。
private SinoPDAFrameWork.Component.PictureControl messageStatus_pc; //定义一个图片Control 用于存储图片
private System.Windows.Forms.Timer messageShowTimer;//定义一个定时器
this.messageShowTimer = new System.Windows.Forms.Timer(); //初始化定时器
this.messageShowTimer.Interval = 500;//定义定时器的时间,500是毫秒,也就是半秒
this.messageShowTimer.Tick += new System.EventHandler(this.messageShowPoint);//设置定时器的回调函数
//回调函数
private void messageShowPoint(object sender, EventArgs e) {
if (this.messageStatus_pc.BackgroundImage == null)
{
this.messageStatus_pc.BackgroundImage = Properties.Resources.message;//设置图片的值
this.messageStatus_pc.Refresh();
}
else
{
this.messageStatus_pc.BackgroundImage = null;
this.messageStatus_pc.Refresh();
}
}