C# PDA 数据采集器 判断wifi,gprs,activesync状态

  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; }
        }



      

    }
}
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值