From d6d87b2ec830ff22b3ce0d8490a9caf7fb3662f2 Mon Sep 17 00:00:00 2001 From: DucDangAnh Date: Tue, 14 Jul 2020 11:14:25 +0700 Subject: [PATCH] AIParkingApplication.csproj - add class ExtensitionMethods. Util - Remove extensition methods. --- .../AIParkingApplication.csproj | 1 + AIParkingApplication/ExtensitionMethods.cs | 76 +++++++++++++++++++ AIParkingApplication/Util.cs | 69 ----------------- 3 files changed, 77 insertions(+), 69 deletions(-) create mode 100644 AIParkingApplication/ExtensitionMethods.cs diff --git a/AIParkingApplication/AIParkingApplication.csproj b/AIParkingApplication/AIParkingApplication.csproj index 790f037..ba4315b 100644 --- a/AIParkingApplication/AIParkingApplication.csproj +++ b/AIParkingApplication/AIParkingApplication.csproj @@ -120,6 +120,7 @@ + diff --git a/AIParkingApplication/ExtensitionMethods.cs b/AIParkingApplication/ExtensitionMethods.cs new file mode 100644 index 0000000..4290e17 --- /dev/null +++ b/AIParkingApplication/ExtensitionMethods.cs @@ -0,0 +1,76 @@ +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace AIParkingApplication +{ + public static class ExtensitionMethods + { + public static void DisableSelected(this ToolStripMenuItem toolStripMenuItem) + { + toolStripMenuItem.Checked = true; + toolStripMenuItem.Enabled = false; + } + + public static string GetTimeFormatted(this DateTime dateTime) + { + return dateTime.ToString(AppConstant.DATETIME_FORMAT); + } + + public static void UpdateImage(this PictureBox pictureBox, Bitmap image) + { + if (pictureBox.IsDisposed) + { + return; + } + + pictureBox.Invoke(new Action(() => + { + pictureBox.Image?.Dispose(); + pictureBox.Image = image; + })); + } + + public static void UpdateLabel(this Label label, string text, Color backColor, Color foreColor) + { + if (label.IsDisposed) + { + return; + } + + label.Invoke(new Action(() => + { + label.Text = text; + label.BackColor = backColor; + label.ForeColor = foreColor; + })); + } + + public static void UpdateLabel(this Label label, string text, Color backColor) + { + if (label.IsDisposed) + { + return; + } + + label.Invoke(new Action(() => + { + label.Text = text; + label.BackColor = backColor; + })); + } + + public static void UpdateLabel(this Label label, string text) + { + if (label.IsDisposed) + { + return; + } + + label.Invoke(new Action(() => + { + label.Text = text; + })); + } + } +} diff --git a/AIParkingApplication/Util.cs b/AIParkingApplication/Util.cs index 8cd808a..d38286d 100644 --- a/AIParkingApplication/Util.cs +++ b/AIParkingApplication/Util.cs @@ -6,9 +6,7 @@ using System.Drawing; using System.IO; using System.Net; using System.Net.NetworkInformation; -using System.Text.RegularExpressions; using System.Threading.Tasks; -using System.Windows.Forms; namespace AIParkingApplication { @@ -54,62 +52,6 @@ namespace AIParkingApplication return sf.GetMethod().Name; } - public static void UpdateImage(this PictureBox pictureBox, Bitmap image) - { - if (pictureBox.IsDisposed) - { - return; - } - - pictureBox.Invoke(new Action(() => - { - pictureBox.Image?.Dispose(); - pictureBox.Image = image; - })); - } - - public static void UpdateLabel(this Label label, string text, Color backColor, Color foreColor) - { - if (label.IsDisposed) - { - return; - } - - label.Invoke(new Action(() => - { - label.Text = text; - label.BackColor = backColor; - label.ForeColor = foreColor; - })); - } - - public static void UpdateLabel(this Label label, string text, Color backColor) - { - if (label.IsDisposed) - { - return; - } - - label.Invoke(new Action(() => - { - label.Text = text; - label.BackColor = backColor; - })); - } - - public static void UpdateLabel(this Label label, string text) - { - if (label.IsDisposed) - { - return; - } - - label.Invoke(new Action(() => - { - label.Text = text; - })); - } - public static Bitmap ConvertFromBase64Image(string base64ImageString) { byte[] imageData = Convert.FromBase64String(base64ImageString); @@ -120,11 +62,6 @@ namespace AIParkingApplication } } - public static string GetTimeFormatted(this DateTime dateTime) - { - return dateTime.ToString(AppConstant.DATETIME_FORMAT); - } - public static void ExecuteCommand(string command) { var processInfo = new ProcessStartInfo("cmd.exe", "/c " + command); @@ -198,12 +135,6 @@ namespace AIParkingApplication Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tAddOrUpdateAppSettings\t{ex.Message}"); } } - - public static void DisableSelected(this ToolStripMenuItem toolStripMenuItem) - { - toolStripMenuItem.Checked = true; - toolStripMenuItem.Enabled = false; - } } public class PlateRequestEngineModel