Beispiel #1
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            txtReceive.UseWinFormControl();

            txtReceive.SetDefaultStyle(12);
            txtSend.SetDefaultStyle(12);
            numMutilSend.SetDefaultStyle(12);

            gbReceive.Tag = gbReceive.Text;
            gbSend.Tag    = gbSend.Text;

            _task.ContinueWith(t =>
            {
                var list = EnumHelper.GetDescriptions <WorkModes>().Select(kv => kv.Value).ToList();
                foreach (var item in t.Result)
                {
                    list.Add(item.Name);
                }
                this.Invoke(() =>
                {
                    cbMode.DataSource = list;
                    //cbMode.SelectedIndex = 0;
                });
            });

            cbAddr.DropDownStyle = ComboBoxStyle.DropDownList;
            cbAddr.DataSource    = GetIPs();

            var cfg = NetConfig.Current;

            if (cfg.Port > 0)
            {
                numPort.Value = cfg.Port;
            }

            // 加载保存的颜色
            UIConfig.Apply(txtReceive);

            LoadConfig();

            // 语音识别
            Task.Factory.StartNew(() =>
            {
                SpeechRecognition.Register("打开", () => this.Invoke(Connect));
                SpeechRecognition.Register("关闭", () => this.Invoke(Disconnect));
                SpeechRecognition.Register("退出", () => Application.Exit());
                SpeechRecognition.Register("发送", () => this.Invoke(() => btnSend_Click(null, null)));

                XTrace.WriteLine("有效的语音识别命令:{0}", SpeechRecognition.GetAllKeys().Join());
            });
        }
Beispiel #2
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            txtReceive.UseWinFormControl();

            txtReceive.SetDefaultStyle(12);
            txtSend.SetDefaultStyle(12);
            numMutilSend.SetDefaultStyle(12);

            gbReceive.Tag = gbReceive.Text;
            gbSend.Tag    = gbSend.Text;

            var cfg = MessageConfig.Current;

            cbMode.SelectedItem = cbMode.Items[0] + "";
            if (!cfg.Address.IsNullOrEmpty())
            {
                //cbAddr.DropDownStyle = ComboBoxStyle.DropDownList;
                cbAddr.DataSource = cfg.Address.Split(";");
            }

            // 加载封包协议
            foreach (var item in _packets.Result)
            {
                cbPacket.Items.Add(item.GetDisplayName() ?? item.Name);
            }
            cbPacket.SelectedIndex = 0;

            // 加载保存的颜色
            UIConfig.Apply(txtReceive);

            LoadConfig();

            // 语音识别
            Task.Factory.StartNew(() =>
            {
                SpeechRecognition.Register("打开", () => this.Invoke(Connect));
                SpeechRecognition.Register("关闭", () => this.Invoke(Disconnect));
                SpeechRecognition.Register("退出", () => Application.Exit());
                SpeechRecognition.Register("发送", () => this.Invoke(() => btnSend_Click(null, null)));

                XTrace.WriteLine("语音识别前缀:{0} 可用命令:{1}", SpeechRecognition.Name, SpeechRecognition.GetAllKeys().Join());
            });
        }