diff --git a/AIParkingApplication/LaneIn.cs b/AIParkingApplication/LaneIn.cs index 108938d..d58c7b1 100644 --- a/AIParkingApplication/LaneIn.cs +++ b/AIParkingApplication/LaneIn.cs @@ -85,29 +85,17 @@ namespace AIParkingApplication } else { - lblStatusInfo.Invoke(new Action(() => - { - lblStatusInfo.BackColor = Color.Red; - lblStatusInfo.Text = "KHÔNG THỂ KẾT NỐI ĐẾN MÁY CHỦ"; - })); + lblStatusInfo.UpdateLabel("KHÔNG THỂ KẾT NỐI ĐẾN MÁY CHỦ", Color.Red); } } else { - lblStatusInfo.Invoke(new Action(() => - { - lblStatusInfo.BackColor = Color.Red; - lblStatusInfo.Text = "THẺ ĐÃ ĐƯỢC SỬ DỤNG"; - })); + lblStatusInfo.UpdateLabel("THẺ ĐÃ ĐƯỢC SỬ DỤNG", Color.Red); } } else { - lblStatusInfo.Invoke(new Action(() => - { - lblStatusInfo.BackColor = Color.Purple; - lblStatusInfo.Text = "THẺ KHÔNG HỢP LỆ"; - })); + lblStatusInfo.UpdateLabel("THẺ KHÔNG HỢP LỆ", Color.Purple); } } @@ -131,11 +119,7 @@ namespace AIParkingApplication { if (c3Device.OpenDoor(doorId).HasError) { - lblStatusInfo.Invoke(new Action(() => - { - lblStatusInfo.BackColor = Color.Red; - lblStatusInfo.Text = "KHÔNG THỂ MỞ CỬA"; - })); + lblStatusInfo.UpdateLabel("KHÔNG THỂ MỞ CỬA", Color.Red); } } @@ -181,31 +165,11 @@ namespace AIParkingApplication private void ShowCardInfoOnUI(string cardNumber, string plateString, string cardType, string cardTime) { - lblCardNumber.Invoke(new Action(() => - { - lblCardNumber.Text = $"Số thẻ: {cardNumber}"; - })); - - lblPlateString.Invoke(new Action(() => - { - lblPlateString.Text = $"Biển số: {plateString}"; - })); - - lblCardType.Invoke(new Action(() => - { - lblCardType.Text = $"Loại thẻ: {cardType}"; - })); - - lblCardTime.Invoke(new Action(() => - { - lblCardTime.Text = $"Thời gian: {cardTime}"; - })); - - lblStatusInfo.Invoke(new Action(() => - { - lblStatusInfo.Text = string.IsNullOrEmpty(plateString) ? "KHÔNG NHẬN DIỆN ĐƯỢC BIỂN SỐ" : $"MỜI XE {plateString} VÀO"; - lblStatusInfo.BackColor = string.IsNullOrEmpty(plateString) ? System.Drawing.Color.Red : System.Drawing.Color.Green; - })); + lblCardNumber.UpdateLabel($"Số thẻ: {cardNumber}", lblCardNumber.BackColor); + lblPlateString.UpdateLabel($"Biển số: {plateString}", lblPlateString.BackColor); + lblCardType.UpdateLabel($"Loại thẻ: {cardType}", lblCardType.BackColor); + lblCardTime.UpdateLabel($"Thời gian: {cardTime}", lblCardTime.BackColor); + lblStatusInfo.UpdateLabel(string.IsNullOrEmpty(plateString) ? "KHÔNG NHẬN DIỆN ĐƯỢC BIỂN SỐ" : $"MỜI XE {plateString} VÀO", string.IsNullOrEmpty(plateString) ? Color.Red : Color.Green); } private void OverviewCameraOnVideoFrameReceived(Mat videoFrame) @@ -240,11 +204,7 @@ namespace AIParkingApplication } else { - lblStatusInfo.Invoke(new Action(() => - { - lblStatusInfo.BackColor = Color.Purple; - lblStatusInfo.Text = "KHÔNG THỂ KẾT NỐI TỚI C3200"; - })); + lblStatusInfo.UpdateLabel("KHÔNG THỂ KẾT NỐI TỚI C3200", Color.Purple); } } @@ -253,4 +213,4 @@ namespace AIParkingApplication ConnectToDoorAccessControl(); } } -} +} \ No newline at end of file