From 2aa346ec64cfc5d6a3b3236268da2c528d4ec410 Mon Sep 17 00:00:00 2001 From: DucDangAnh Date: Sat, 20 Jun 2020 19:27:07 +0700 Subject: [PATCH] Check Radio Button Checked --- BITable/BiTable.cs | 226 ++++++++++++++++++++++++++------------------- 1 file changed, 133 insertions(+), 93 deletions(-) diff --git a/BITable/BiTable.cs b/BITable/BiTable.cs index 09ab955..31b08bb 100644 --- a/BITable/BiTable.cs +++ b/BITable/BiTable.cs @@ -231,22 +231,29 @@ namespace BITable private void btnFaceAndPaper_Click(object sender, EventArgs e) { - if (radioButtonBluetooth.Checked && !string.IsNullOrEmpty(currentBluetoothDeviceName) && client.Connected) + if (radioButtonBluetooth.Checked) { - DoRequest(1, true, true); - } - else - { - MessageBox.Show("Chưa kết nối tới thiết bị BI Table qua Bluetooth!"); + if (!string.IsNullOrEmpty(currentBluetoothDeviceName)) + { + DoRequest(1, true, true); + } + else + { + MessageBox.Show("Chưa kết nối tới thiết bị BI Table qua Bluetooth!"); + } } - if (radioButtonIpApi.Checked & !string.IsNullOrEmpty(txtIPAddress.Text) && !string.IsNullOrEmpty(deviceUrl)) + if (radioButtonIpApi.Checked) { - DoRequestAPI(1, true, true); - } - else - { - MessageBox.Show("Chưa kết nối tới thiết bị BI Table!"); + if (!string.IsNullOrEmpty(txtIPAddress.Text) && !string.IsNullOrEmpty(deviceUrl)) + { + + DoRequestAPI(1, true, true); + } + else + { + MessageBox.Show("Chưa kết nối tới thiết bị BI Table!"); + } } } @@ -260,126 +267,143 @@ namespace BITable } } - public class Base64Image - { - [JsonProperty("base64")] - public string Base64 { get; set; } - - [JsonProperty("type")] - public string Type { get; set; } - } - - public class RequestResult - { - [JsonProperty("data")] - public Base64Image[] Data { get; set; } - - [JsonProperty("code")] - public int Code { get; set; } - } - private void btnFace_Click(object sender, EventArgs e) { - if (radioButtonBluetooth.Checked && !string.IsNullOrEmpty(currentBluetoothDeviceName) && client.Connected) + if (radioButtonBluetooth.Checked) { - DoRequest(2, true, false); - } - else - { - MessageBox.Show("Chưa kết nối tới thiết bị BI Table qua Bluetooth!"); + if (!string.IsNullOrEmpty(currentBluetoothDeviceName)) + { + DoRequest(2, true, false); + } + else + { + MessageBox.Show("Chưa kết nối tới thiết bị BI Table qua Bluetooth!"); + } } - if (radioButtonIpApi.Checked & !string.IsNullOrEmpty(txtIPAddress.Text) && !string.IsNullOrEmpty(deviceUrl)) + if (radioButtonIpApi.Checked) { - DoRequestAPI(2, true, false); - } - else - { - MessageBox.Show("Chưa kết nối tới thiết bị BI Table!"); + if (!string.IsNullOrEmpty(txtIPAddress.Text) && !string.IsNullOrEmpty(deviceUrl)) + { + + DoRequestAPI(2, true, false); + } + else + { + MessageBox.Show("Chưa kết nối tới thiết bị BI Table!"); + } } } private void btnFontPaper_Click(object sender, EventArgs e) { - if (radioButtonBluetooth.Checked && !string.IsNullOrEmpty(currentBluetoothDeviceName) && client.Connected) + if (radioButtonBluetooth.Checked) { - DoRequest(3, false, true); - } - else - { - MessageBox.Show("Chưa kết nối tới thiết bị BI Table qua Bluetooth!"); + if (!string.IsNullOrEmpty(currentBluetoothDeviceName)) + { + DoRequest(3, false, true); + } + else + { + MessageBox.Show("Chưa kết nối tới thiết bị BI Table qua Bluetooth!"); + } } - if (radioButtonIpApi.Checked && !string.IsNullOrEmpty(txtIPAddress.Text) && !string.IsNullOrEmpty(deviceUrl)) + if (radioButtonIpApi.Checked) { - DoRequestAPI(3, false, true); - } - else - { - MessageBox.Show("Chưa kết nối tới thiết bị BI Table!"); + if (!string.IsNullOrEmpty(txtIPAddress.Text) && !string.IsNullOrEmpty(deviceUrl)) + { + + DoRequestAPI(3, false, true); + } + else + { + MessageBox.Show("Chưa kết nối tới thiết bị BI Table!"); + } } } private void btnBehindPaper_Click(object sender, EventArgs e) { - if (radioButtonBluetooth.Checked && !string.IsNullOrEmpty(currentBluetoothDeviceName) && client.Connected) + if (radioButtonBluetooth.Checked) { - DoRequest(4, false, true); - } - else - { - MessageBox.Show("Chưa kết nối tới thiết bị BI Table qua Bluetooth!"); + if (!string.IsNullOrEmpty(currentBluetoothDeviceName)) + { + DoRequest(4, false, true); + } + else + { + MessageBox.Show("Chưa kết nối tới thiết bị BI Table qua Bluetooth!"); + } } - if (radioButtonIpApi.Checked & !string.IsNullOrEmpty(txtIPAddress.Text) && !string.IsNullOrEmpty(deviceUrl)) + if (radioButtonIpApi.Checked) { - DoRequestAPI(4, false, true); - } - else - { - MessageBox.Show("Chưa kết nối tới thiết bị BI Table!"); + if (!string.IsNullOrEmpty(txtIPAddress.Text) && !string.IsNullOrEmpty(deviceUrl)) + { + + DoRequestAPI(4, false, true); + } + else + { + MessageBox.Show("Chưa kết nối tới thiết bị BI Table!"); + } } } private void btnFaceCamera_Click(object sender, EventArgs e) { - if (radioButtonBluetooth.Checked && !string.IsNullOrEmpty(currentBluetoothDeviceName) && client.Connected) + if (radioButtonBluetooth.Checked) { - DoRequest(5, true, false); - } - else - { - MessageBox.Show("Chưa kết nối tới thiết bị BI Table qua Bluetooth!"); + if (!string.IsNullOrEmpty(currentBluetoothDeviceName)) + { + DoRequest(5, true, false); + } + else + { + MessageBox.Show("Chưa kết nối tới thiết bị BI Table qua Bluetooth!"); + } } - if (radioButtonIpApi.Checked & !string.IsNullOrEmpty(txtIPAddress.Text) && !string.IsNullOrEmpty(deviceUrl)) + if (radioButtonIpApi.Checked) { - DoRequestAPI(5, true, false); - } - else - { - MessageBox.Show("Chưa kết nối tới thiết bị BI Table!"); + if (!string.IsNullOrEmpty(txtIPAddress.Text) && !string.IsNullOrEmpty(deviceUrl)) + { + + DoRequestAPI(5, true, false); + } + else + { + MessageBox.Show("Chưa kết nối tới thiết bị BI Table!"); + } } } private void btnPaperCamera_Click(object sender, EventArgs e) { - if (radioButtonBluetooth.Checked && !string.IsNullOrEmpty(currentBluetoothDeviceName) && client.Connected) + if (radioButtonBluetooth.Checked) { - DoRequest(6, false, true); - } - else - { - MessageBox.Show("Chưa kết nối tới thiết bị BI Table qua Bluetooth!"); + if (!string.IsNullOrEmpty(currentBluetoothDeviceName)) + { + DoRequest(6, false, true); + } + else + { + MessageBox.Show("Chưa kết nối tới thiết bị BI Table qua Bluetooth!"); + } } - if (radioButtonIpApi.Checked & !string.IsNullOrEmpty(txtIPAddress.Text) && !string.IsNullOrEmpty(deviceUrl)) + if (radioButtonIpApi.Checked) { - DoRequestAPI(6, false, true); - } - else - { - MessageBox.Show("Chưa kết nối tới thiết bị BI Table!"); + if (!string.IsNullOrEmpty(txtIPAddress.Text) && !string.IsNullOrEmpty(deviceUrl)) + { + + DoRequestAPI(6, false, true); + } + else + { + MessageBox.Show("Chưa kết nối tới thiết bị BI Table!"); + } } } @@ -452,7 +476,7 @@ namespace BITable { lblStatusSign.Invoke(new Action(() => { - lblStatusSign.BackColor = Color.Green; + lblStatusSign.BackColor = Color.Blue; })); } } @@ -482,10 +506,9 @@ namespace BITable } } } - catch (Exception ex) + catch (Exception) { MessageBox.Show("Không có kết nối internet!"); - Console.WriteLine($"SendEngineRequest : {ex.Message}"); } })); } @@ -497,6 +520,23 @@ namespace BITable [JsonProperty("error")] public string Error { get; set; } } + public class Base64Image + { + [JsonProperty("base64")] + public string Base64 { get; set; } + + [JsonProperty("type")] + public string Type { get; set; } + } + + public class RequestResult + { + [JsonProperty("data")] + public Base64Image[] Data { get; set; } + + [JsonProperty("code")] + public int Code { get; set; } + } } }