Beispiel #1
0
        private void BTForm_Load(object sender, EventArgs e)
        {
            object powerStatus = BTPowerManager.GetPowerStatus();

            if (powerStatus != null)
            {
                if (powerStatus.ToString() == "0")
                {
                    this.tbOut.AppendText("节电模式关闭\r\n");
                }
                else
                {
                    this.tbOut.AppendText("节电模式开启\r\n");
                    BTPowerManager.SetPowerState();
                    this.tbOut.AppendText("关闭节电模式,重启电脑生效!\r\n");
                }
            }
            else
            {
                BTPowerManager.SetPowerState();
                this.tbOut.AppendText("******关闭节电模式,重启生效!\r\n");
            }
            new Action(this.SetBthService).BeginInvoke(new AsyncCallback(this.QueryDevice), null);
            this.listView1.SelectedIndexChanged += new EventHandler(this.listView1_SelectedIndexChanged);
        }
Beispiel #2
0
        public BluetoothOper()
        {
            object powerStatus = BTPowerManager.GetPowerStatus();

            if (powerStatus != null)
            {
                if (powerStatus.ToString() == "0")
                {
                    LogHelper.LogInfo("节电模式关闭\r\n");
                }
                else
                {
                    LogHelper.LogInfo("节电模式开启\r\n");
                    BTPowerManager.SetPowerState();
                    LogHelper.LogInfo("关闭节电模式,重启电脑生效!\r\n");
                }
            }
            else
            {
                BTPowerManager.SetPowerState();
                LogHelper.LogInfo("******关闭节电模式,重启生效!\r\n");
            }
            Action action1 = new Action(this.SetBthService);

            if (Directory.Exists(Application.StartupPath + @"\authInfo"))
            {
                string[] files = Directory.GetFiles(Application.StartupPath + @"\authInfo");
                this.btfiles.AddRange((IEnumerable <string>)files);
                foreach (string str in files)
                {
                    Match match = new Regex(@"CHIT\D{2}|CHIT\D{3}").Match(str);
                    if (match != null)
                    {
                        string text1 = match.Value;
                    }
                    LogHelper.LogInfo("配对蓝牙设备:" + str);
                }
            }
            else
            {
                Directory.CreateDirectory(Application.StartupPath + @"\authInfo");
            }
            this.t_end_bt          = new System.Timers.Timer(60000.0);
            this.t_end_bt.Elapsed += new ElapsedEventHandler(this.t_end_bt_Elapsed);
            this.t_end_bt.Enabled  = false;
        }