Files
AIParkingApplication/AIParkingApplication/ExtensitionMethods.cs

77 lines
1.9 KiB
C#

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;
}));
}
}
}