92 lines
3.4 KiB
C#
92 lines
3.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace UWS
|
|
{
|
|
public partial class CustomMessageBox : Form
|
|
{
|
|
private Button btnOK;
|
|
private Label lblMessage;
|
|
|
|
public CustomMessageBox(string message, Color textColor)
|
|
{
|
|
InitializeComponent();
|
|
lblMessage.Text = message;
|
|
lblMessage.ForeColor = textColor;
|
|
lblMessage.Font = new Font(lblMessage.Font.FontFamily, 18); // Set larger font
|
|
}
|
|
|
|
private void btnOK_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
// Show a success message with green text
|
|
public static void ShowSuccess(string message)
|
|
{
|
|
CustomMessageBox msgBox = new CustomMessageBox(message, Color.Green);
|
|
msgBox.ShowDialog();
|
|
}
|
|
|
|
// Show an error message with red text
|
|
public static void ShowError(string message)
|
|
{
|
|
CustomMessageBox msgBox = new CustomMessageBox(message, Color.Red);
|
|
msgBox.ShowDialog();
|
|
}
|
|
|
|
private void InitializeComponent()
|
|
{
|
|
this.lblMessage = new System.Windows.Forms.Label();
|
|
this.btnOK = new System.Windows.Forms.Button();
|
|
this.SuspendLayout();
|
|
//
|
|
// lblMessage
|
|
//
|
|
this.lblMessage.AutoSize = true;
|
|
this.lblMessage.BackColor = System.Drawing.SystemColors.ButtonFace;
|
|
this.lblMessage.ForeColor = System.Drawing.SystemColors.ControlLightLight;
|
|
this.lblMessage.Location = new System.Drawing.Point(13, 13);
|
|
this.lblMessage.Name = "lblMessage";
|
|
this.lblMessage.Size = new System.Drawing.Size(35, 13);
|
|
this.lblMessage.TabIndex = 0;
|
|
this.lblMessage.Text = "label1";
|
|
//
|
|
// btnOK
|
|
//
|
|
this.btnOK.BackColor = System.Drawing.SystemColors.ButtonFace;
|
|
this.btnOK.FlatAppearance.BorderSize = 0;
|
|
this.btnOK.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
|
this.btnOK.Location = new System.Drawing.Point(366, 87);
|
|
this.btnOK.Name = "btnOK";
|
|
this.btnOK.Size = new System.Drawing.Size(75, 23);
|
|
this.btnOK.TabIndex = 1;
|
|
this.btnOK.Text = "OK";
|
|
this.btnOK.UseVisualStyleBackColor = false;
|
|
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
|
|
//
|
|
// CustomMessageBox
|
|
//
|
|
this.BackColor = System.Drawing.Color.WhiteSmoke;
|
|
this.ClientSize = new System.Drawing.Size(444, 113);
|
|
this.Controls.Add(this.btnOK);
|
|
this.Controls.Add(this.lblMessage);
|
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
|
this.MaximizeBox = false;
|
|
this.MinimizeBox = false;
|
|
this.Name = "CustomMessageBox";
|
|
this.ShowIcon = false;
|
|
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
|
this.ResumeLayout(false);
|
|
this.PerformLayout();
|
|
|
|
}
|
|
}
|
|
}
|