SafeDispatch/SubscriberAndUserManager/CustomMessageBox.cs

165 lines
5.6 KiB
C#
Raw Permalink Normal View History

2024-02-22 16:43:59 +00:00
using SafeMobileLib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;
namespace SubscriberAndUserManager
{
public enum CustomMessageBoxType { exclamation, check }
public partial class CustomMessageBox : Telerik.WinControls.UI.RadForm
{
private CustomMessageBoxType type;
private string mess;
private string header;
private bool buttonsYesNo;
private void setLanguage()
{
btnYes.Text = MainForm.returnLNGString("yes");
btnOK.Text = MainForm.returnLNGString("ok");
btnNO.Text = MainForm.returnLNGString("no");
}
internal void increaseLabelHeight(int height)
{
lbMess.Height += height;
}
public CustomMessageBox(CustomMessageBoxType type, string mess,string header)
{
InitializeComponent();
setLanguage();
this.ThemeName = "TelerikMetroBlue";
this.type = type;
this.mess = mess;
this.header = header;
lbMess.Text = mess;
Console.WriteLine("label size:" + lbMess.Size.Width);
this.Text = header;
if (type != CustomMessageBoxType.exclamation)
{
panelImage.BackgroundImage = global::SubscriberAndUserManager.Properties.Resources.check;
}
if (MainForm.radioType==RADIOTYPE.HYT)
{
this.Icon = global::SubscriberAndUserManager.Properties.Resources.SYTADMIN24x;
this.BackColor = MainForm.HyteraColor;
}
else if (MainForm.radioType == RADIOTYPE.HARRIS)
{
this.Icon = global::SubscriberAndUserManager.Properties.Resources.visionSmall;
this.BackColor = MainForm.HarrisColor;
this.lbMess.ForeColor = MainForm.HarTextColor;
}
else if (MainForm.radioType == RADIOTYPE.ATLAS)
{
this.Icon = global::SubscriberAndUserManager.Properties.Resources.ATLASadmin32; //ATLASCHANGE
this.BackColor = MainForm.HarrisColor;
this.lbMess.ForeColor = MainForm.HarTextColor;
}
else if (MainForm.radioType == RADIOTYPE.SIMOCO)
{
this.Icon = global::SubscriberAndUserManager.Properties.Resources.simoco_setup_241; //ATLASCHANGE
// this.BackColor = MainForm.HarrisColor;
// this.lbMess.ForeColor = MainForm.HarTextColor;
}
else if (MainForm.radioType == RADIOTYPE.EXCERA)
this.Icon = global::SubscriberAndUserManager.Properties.Resources.AXYS_ICON;
}
public CustomMessageBox(CustomMessageBoxType type, string mess, string header, bool yesNO)
{
InitializeComponent();
this.ThemeName = "TelerikMetroBlue";
setLanguage();
this.type = type;
this.mess = mess;
this.header = header;
buttonsYesNo = yesNO;
lbMess.Text = mess;
this.Text = header;
if (type != CustomMessageBoxType.exclamation)
{
panelImage.BackgroundImage = global::SubscriberAndUserManager.Properties.Resources.check;
}
if (buttonsYesNo)
{
btnOK.Enabled = false;
btnOK.Visible = false;
btnYes.Enabled = true;
btnYes.Visible = true;
btnNO.Enabled = true;
btnNO.Visible = true;
}
}
private void btnOK_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
}
/// <summary>
/// Show message box
/// </summary>
/// <param name="type">exclamation/check</param>
/// <param name="mess">message</param>
/// <param name="header">header text</param>
/// <returns></returns>
public static DialogResult Show(CustomMessageBoxType type, string mess,string header)
{
DialogResult dr;
CustomMessageBox cm = new CustomMessageBox(type, mess, header);
dr = cm.ShowDialog();
return dr;
}
public static DialogResult Show(CustomMessageBoxType type, string mess, string header, int height)
{
DialogResult dr;
CustomMessageBox cm = new CustomMessageBox(type, mess, header);
cm.increaseLabelHeight(height);
cm.Height += height;
dr = cm.ShowDialog();
return dr;
}
public static DialogResult Show(CustomMessageBoxType type, string mess, string header, bool yesNo)
{
DialogResult dr;
CustomMessageBox cm = new CustomMessageBox(type, mess, header,yesNo);
dr = cm.ShowDialog();
return dr;
}
public static DialogResult Show(CustomMessageBoxType type, string mess, string header, bool yesNo, int height)
{
DialogResult dr;
CustomMessageBox cm = new CustomMessageBox(type, mess, header, yesNo);
cm.increaseLabelHeight(height);
cm.Height += height;
dr = cm.ShowDialog();
return dr;
}
private void btnYes_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Yes;
}
private void btnNO_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.No;
}
}
}