C# PDA 数据采集器 判断wifi,gprs,activesync状态
2014-08-29 16:07
351 查看
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using Microsoft.WindowsMobile.Status;
namespace Gps_demo
{
public partial class Form3 : Form
{
private Timer SyncTimer = null;
public Form3()
{
InitializeComponent();
SetUpNotifications();
}
private void menuItem1_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
}
private ArrayList stateList = new ArrayList();
public void SetUpNotifications() {
SystemState s;
// Monitor for ActiveSync Connection
s = new SystemState(SystemProperty.CradlePresent);
s.Changed += new ChangeEventHandler(ChangeOccurred);
stateList.Add(s);
// Monitor for GPRS Connection
s = new SystemState(SystemProperty.PhoneGprsCoverage);
s.Changed += new ChangeEventHandler(ChangeOccurred);
stateList.Add(s);
//Monitor for Network Connection (eg. WIFI)
s = new SystemState(SystemProperty.ConnectionsNetworkCount);
s.Changed += new ChangeEventHandler(ChangeOccurred);
stateList.Add(s);
UpdateConnectionState();
}
public void ChangeOccurred(object sender, ChangeEventArgs args) {
SystemState state = (SystemState)sender;
UpdateConnectionState();
}
public void UpdateConnectionState() {
// Set the check boxes based on the current state of the networks
activesync.Checked = Convert.ToBoolean(SystemState.GetValue(SystemProperty.CradlePresent));
gprs.Checked = Convert.ToBoolean(SystemState.GetValue(SystemProperty.PhoneGprsCoverage));
wifi.Checked = Convert.ToBoolean(SystemState.GetValue(SystemProperty.ConnectionsNetworkCount));
}
private void btnSync_Click(object sender, EventArgs e)
{
Sync();
}
private void Sync() {
// Sync
MessageBox.Show("synchornization开始执行");
//////////////////////////////////////////////////////////
// //
// Insert Sync Code Here //
// //
//////////////////////////////////////////////////////////
label1.Text = "同步完成";
}
public void SyncTimerEvent(object unused, EventArgs notused) {
Sync();
}
private void button1_Click(object sender, EventArgs e)
{
this.SyncTimer = new Timer();
this.SyncTimer.Interval = 5000;
this.SyncTimer.Enabled = false;
this.SyncTimer.Tick += new EventHandler(SyncTimerEvent);
if (chkTimer.Checked)
this.SyncTimer.Enabled = true;
else
this.SyncTimer.Enabled = false;
}
private void chkTimer_CheckStateChanged(object sender, EventArgs e)
{
this.SyncTimer = new Timer();
this.SyncTimer.Interval = 5000;
this.SyncTimer.Enabled = false;
this.SyncTimer.Tick += new EventHandler(SyncTimerEvent);
if (chkTimer.Checked)
{ this.SyncTimer.Enabled = true; }
else
{ this.SyncTimer.Enabled = false; }
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using Microsoft.WindowsMobile.Status;
namespace Gps_demo
{
public partial class Form3 : Form
{
private Timer SyncTimer = null;
public Form3()
{
InitializeComponent();
SetUpNotifications();
}
private void menuItem1_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
}
private ArrayList stateList = new ArrayList();
public void SetUpNotifications() {
SystemState s;
// Monitor for ActiveSync Connection
s = new SystemState(SystemProperty.CradlePresent);
s.Changed += new ChangeEventHandler(ChangeOccurred);
stateList.Add(s);
// Monitor for GPRS Connection
s = new SystemState(SystemProperty.PhoneGprsCoverage);
s.Changed += new ChangeEventHandler(ChangeOccurred);
stateList.Add(s);
//Monitor for Network Connection (eg. WIFI)
s = new SystemState(SystemProperty.ConnectionsNetworkCount);
s.Changed += new ChangeEventHandler(ChangeOccurred);
stateList.Add(s);
UpdateConnectionState();
}
public void ChangeOccurred(object sender, ChangeEventArgs args) {
SystemState state = (SystemState)sender;
UpdateConnectionState();
}
public void UpdateConnectionState() {
// Set the check boxes based on the current state of the networks
activesync.Checked = Convert.ToBoolean(SystemState.GetValue(SystemProperty.CradlePresent));
gprs.Checked = Convert.ToBoolean(SystemState.GetValue(SystemProperty.PhoneGprsCoverage));
wifi.Checked = Convert.ToBoolean(SystemState.GetValue(SystemProperty.ConnectionsNetworkCount));
}
private void btnSync_Click(object sender, EventArgs e)
{
Sync();
}
private void Sync() {
// Sync
MessageBox.Show("synchornization开始执行");
//////////////////////////////////////////////////////////
// //
// Insert Sync Code Here //
// //
//////////////////////////////////////////////////////////
label1.Text = "同步完成";
}
public void SyncTimerEvent(object unused, EventArgs notused) {
Sync();
}
private void button1_Click(object sender, EventArgs e)
{
this.SyncTimer = new Timer();
this.SyncTimer.Interval = 5000;
this.SyncTimer.Enabled = false;
this.SyncTimer.Tick += new EventHandler(SyncTimerEvent);
if (chkTimer.Checked)
this.SyncTimer.Enabled = true;
else
this.SyncTimer.Enabled = false;
}
private void chkTimer_CheckStateChanged(object sender, EventArgs e)
{
this.SyncTimer = new Timer();
this.SyncTimer.Interval = 5000;
this.SyncTimer.Enabled = false;
this.SyncTimer.Tick += new EventHandler(SyncTimerEvent);
if (chkTimer.Checked)
{ this.SyncTimer.Enabled = true; }
else
{ this.SyncTimer.Enabled = false; }
}
}
}
相关文章推荐
- C#使用OpenNETCF.Desktop.Communication,实现对ActiveSync状态的判断,及对移动设备文件的操作!
- WINCE网络状态判断(WIFI OR USB OR GPRS)
- WINCE网络状态判断(WIFI OR USB OR GPRS)
- 判断网络状态 (在2G,3G,WIFI下测试均通过)
- Android(判断wifi是否开启,手机屏幕状态,sdcard是否被拔出,设置全屏)
- C#判断网络状态
- 网络判断网络连接有多种办法,通过C#程序也可以判断与远程主机的连接状态。具体实现方法
- 判断网络连接状态[C#]
- android 关闭wifi时判断GPRS是否连接
- 用c#判断网络连接状态的例子(判断Internet连接还是断开)
- C#中判断网络连接的状态
- c#中如何判断已知网络的连接状态?
- C# ListView 选中状态的判断方法
- C#使用Ping功能判断网络连接状态或者目标计算机是否开机等
- C#判断网络连接状态
- C#如何判断文件处于打开状态
- 判断当前的网络状态(C#)
- C#中判断系统的网络连接状态的方法
- HMT360工业PDA和工业PDA定制:wince+mobile+gprs+gsm+wifi+rfid+barcode+gps
- Android(判断wifi是否开启,手机屏幕状态,sdcard是否被拔出,设置全屏)