最近在windows mobile上做一个简单的GPS应用程序,想在form中画出当前从FAKEGPS中获得的点的坐标 每当监测到 gps_LocationChanged 时触发Form1_Paint1事件 但能够成功读取经纬度值 调用paint时一直出现异常
private PaintEventHandler mainformpaintHandler; //
private void Main_formpaint(object sender, PaintEventArgs e) {
mainformpaintHandler = new PaintEventHandler(Form1_Paint1);
} protected void gps_LocationChanged(object sender, LocationChangedEventArgs args)
{
position = args.Position; // call the UpdateData method via the updateDataHandler so that we
// update the UI on the UI thread
Invoke(updateDataHandler); //位置改变时调用数据更新委托
Invoke(mainformpaintHandler); // 在此处异常中断
}
void Form1_Paint1(object sender, PaintEventArgs e)
{
if (gps.Opened)
{
//
经纬度转化为x。y坐标
//
Graphics g = e.Graphics; //创建画板,这里的画板是由Form提供的.
Pen p = new Pen(Color.Blue, 2);//定义了一个蓝色,宽度为的画笔
g.DrawEllipse(p, x, y, 2, 2);//在画板上画椭圆,起始坐标为
} }求各位大侠帮忙 感激不尽
private PaintEventHandler mainformpaintHandler; //
private void Main_formpaint(object sender, PaintEventArgs e) {
mainformpaintHandler = new PaintEventHandler(Form1_Paint1);
} protected void gps_LocationChanged(object sender, LocationChangedEventArgs args)
{
position = args.Position; // call the UpdateData method via the updateDataHandler so that we
// update the UI on the UI thread
Invoke(updateDataHandler); //位置改变时调用数据更新委托
Invoke(mainformpaintHandler); // 在此处异常中断
}
void Form1_Paint1(object sender, PaintEventArgs e)
{
if (gps.Opened)
{
//
经纬度转化为x。y坐标
//
Graphics g = e.Graphics; //创建画板,这里的画板是由Form提供的.
Pen p = new Pen(Color.Blue, 2);//定义了一个蓝色,宽度为的画笔
g.DrawEllipse(p, x, y, 2, 2);//在画板上画椭圆,起始坐标为
} }求各位大侠帮忙 感激不尽
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货