Example #1
0
        async void imageAddWordByScan_TapGesture_Tapped(object sender, EventArgs e)
        {
            var page = new Common.ZXingBarcodeScanner
                       (
                title: "补补高 扫码新增",
                isScanContinuously: true,
                scanResultHandle: scanResultHandle
                       );

            await Navigation.PushAsync(page);
        }
Example #2
0
        async void scanResultHandle(ZXing.Result result, Common.ZXingBarcodeScanner page)
        {
            string msg = "{0}".FormatWith(Util.JsonUtils.SerializeObject(result));

            System.Diagnostics.Debug.WriteLine(msg);

            addWord(result.Text);


            bool r = await DisplayAlert("添加成功", "已成功添加[{0}]".FormatWith(result.Text), "确认", "取消");

            msg = "{0}".FormatWith(r);
            System.Diagnostics.Debug.WriteLine(msg);

            page.EndWith();
        }
Example #3
0
        async void BtnSend_Clicked(object sender, EventArgs e)
        {
            if (mTcpClient == null || mReceiveTask == null)
            {
                await DisplayAlert("Error", "请连接服务器", "确定");

                return;
            }

            var page = new Common.ZXingBarcodeScanner
                       (
                title: "模拟串口助手",
                isScanContinuously: true,
                scanResultHandle: scanResultHandle
                       );

            await Navigation.PushAsync(page);
        }
Example #4
0
        async void scanResultHandle(ZXing.Result result, Common.ZXingBarcodeScanner page)
        {
            try
            {
                string str = result.Text;
                mTcpClient.Send(result.Text);

                var toAdd = new FakeSerialPortModel()
                {
                    MsgType = "发送", Content = str, Foreground = "Silver"
                };
                this.ViewModel.Result.Add(toAdd);

                App.AudioPlayer.PlayBeep();
                Thread.Sleep(500);
                await DisplayAlert("成功发送", str, "确定");

                Device.BeginInvokeOnMainThread(() =>
                {
                    lv.ScrollTo(toAdd, ScrollToPosition.End, false);
                });
            }
            catch (Exception ex)
            {
                this.ViewModel.Result.Add(new FakeSerialPortModel()
                {
                    MsgType = "系统", Content = "发送信息到服务器失败。", Foreground = "Red"
                });

                App.AudioPlayer.PlayError();
                Thread.Sleep(500);
                await DisplayAlert("发送信息到服务器失败", ex.GetFullInfo(), "确定");
            }

            page.EndWith();
        }