Exemple #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);
        }
Exemple #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;
        }
Exemple #3
0
        public void Start()
        {
            this.p_bt = new Process();
            bool flag = false;

            if (BTPowerManager.GetOs() == "WIN7")
            {
                if (File.Exists(Application.StartupPath + @"\BlueAuthTool7.exe"))
                {
                    this.p_bt.StartInfo.FileName = Application.StartupPath + @"\BlueAuthTool7.exe";
                    flag = true;
                }
            }
            else if (File.Exists(Application.StartupPath + @"\BlueAuthTool.exe"))
            {
                this.p_bt.StartInfo.FileName = Application.StartupPath + @"\BlueAuthTool.exe";
                flag = true;
            }
            if (flag)
            {
                if (this.p_bt.Start())
                {
                    this.currentStatus = BluePeiduiStatus.Open;
                    this.n_minute      = 60;
                    this.t_end_bt.Start();
                    LogHelper.LogInfo("开启配对!\r\n");
                    LogHelper.LogInfo("蓝牙配对.....");
                }
                else
                {
                    this.currentStatus = BluePeiduiStatus.Error;
                }
            }
            else
            {
                this.currentStatus = BluePeiduiStatus.Error;
                LogHelper.LogInfo("未找到蓝牙配对程式!\r\n");
                LogHelper.LogInfo("未找到蓝牙配对程式.....");
            }
        }