82 lines
2.2 KiB
C#
82 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace OwnMessageBoxes
|
|
{
|
|
public partial class OwnMessageBox : Form
|
|
{
|
|
private static string text, title;
|
|
private static MessageBoxButtons buttons;
|
|
private static System.Drawing.Image img;
|
|
private static DialogResult result;
|
|
private static Form form;
|
|
|
|
private OwnMessageBox()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void OwnMessageBox_Load(object sender, EventArgs e)
|
|
{
|
|
OwnMessageBox.GetMessage(labelText, labelTitle, pictureBoxImage, buttonYes, buttonNo);
|
|
}
|
|
|
|
private void buttonYes_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void buttonNo_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
public static DialogResult Show(string mText, string mTitle, MessageBoxButtons mButtons, System.Drawing.Image mImg, Form mForm)
|
|
{
|
|
text = mText;
|
|
title = mTitle;
|
|
buttons = mButtons;
|
|
img = mImg;
|
|
form = mForm;
|
|
form.ShowDialog();
|
|
return result;
|
|
}
|
|
|
|
public static void GetMessage(Control mTextControl, Control mTitleControl, Control mImgControl, Control btYes, Control btNo)
|
|
{
|
|
mTextControl.Text = text;
|
|
mTitleControl.Text = title;
|
|
if (buttons != MessageBoxButtons.YesNo)
|
|
{
|
|
btYes.Visible = false;
|
|
btNo.Text = "OK";
|
|
}
|
|
btYes.Click += new EventHandler(Yes);
|
|
btNo.Click += new EventHandler(No);
|
|
mImgControl.BackgroundImageLayout = ImageLayout.Center;
|
|
mImgControl.BackgroundImage = img;
|
|
result = DialogResult.Abort;
|
|
}
|
|
|
|
private static void Yes(object sender, EventArgs e)
|
|
{
|
|
result = DialogResult.Yes;
|
|
form.Close();
|
|
}
|
|
|
|
private static void No(object sender, EventArgs e)
|
|
{
|
|
result = DialogResult.No;
|
|
form.Close();
|
|
}
|
|
|
|
}
|
|
}
|