本文整理汇总了C#中MessageBoxIcon类的典型用法代码示例。如果您正苦于以下问题:C# MessageBoxIcon类的具体用法?C# MessageBoxIcon怎么用?C# MessageBoxIcon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageBoxIcon类属于命名空间,在下文中一共展示了MessageBoxIcon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Show
// **********************************
// Output an error or warning message
// **********************************
public static DialogResult Show(string messageTitle, string messageText, MessageBoxIcon messageBoxIcon, MessageBoxButtons messageButtons, bool neverShowTouchOptimized = false)
{
// If we are running in SebWindowsClient we need to activate it before showing the password dialog
if (SEBClientInfo.SebWindowsClientForm != null) SebWindowsClientMain.SEBToForeground();
DialogResult messageBoxResult;
if (!neverShowTouchOptimized && (Boolean) SEBClientInfo.getSebSetting(SEBSettings.KeyTouchOptimized)[SEBSettings.KeyTouchOptimized] == true)
{
messageBoxResult =
MetroMessageBox.Show(
new Form()
{
TopMost = true,
Top = 0,
Left = 0,
Width = Screen.PrimaryScreen.Bounds.Width,
Height = Screen.PrimaryScreen.Bounds.Height
}, messageText, messageTitle, messageButtons, messageBoxIcon);
}
else
{
messageBoxResult = MessageBox.Show(new Form() { TopMost = true }, messageText, messageTitle, messageButtons, messageBoxIcon);
}
return messageBoxResult;
}
示例2: Show
public static DialogResult Show(string msg, string title, MessageBoxButtons btns, MessageBoxIcon icon)
{
// Create a callback delegate
_hookProcDelegate = new Win32.WindowsHookProc(HookCallback);
// Remember the title & message that we'll look for.
// The hook sees *all* windows, so we need to make sure we operate on the right one.
_msg = msg;
_title = title;
// Set the hook.
// Suppress "GetCurrentThreadId() is deprecated" warning.
// It's documented that Thread.ManagedThreadId doesn't work with SetWindowsHookEx()
#pragma warning disable 0618
_hHook = Win32.SetWindowsHookEx(Win32.WH_CBT, _hookProcDelegate, IntPtr.Zero, AppDomain.GetCurrentThreadId());
#pragma warning restore 0618
// Pop a standard MessageBox. The hook will center it.
DialogResult rslt = MessageBox.Show(msg, title, btns, icon);
// Release hook, clean up (may have already occurred)
Unhook();
return rslt;
}
示例3: GetShowReference
/// <summary>
/// 获取显示确认对话框的客户端脚本
/// </summary>
/// <param name="message">对话框消息</param>
/// <param name="title">对话框标题</param>
/// <param name="icon">对话框图标</param>
/// <param name="okScriptstring">点击确定按钮执行的客户端脚本</param>
/// <param name="cancelScript">点击取消按钮执行的客户端脚本</param>
/// <param name="target">弹出对话框的目标页面</param>
/// <returns>客户端脚本</returns>
public static string GetShowReference(string message, string title, MessageBoxIcon icon, string okScriptstring, string cancelScript, Target target)
{
//string msgBoxScript = "var msgBox=Ext.MessageBox;";
//msgBoxScript += "if(parent!=window){msgBox=parent.window.Ext.MessageBox;}";
if (String.IsNullOrEmpty(title))
{
title = "X.util.confirmTitle";
}
else
{
title = JsHelper.GetJsString(title.Replace("\r\n", "\n").Replace("\n", "<br/>"));
}
message = message.Replace("\r\n", "\n").Replace("\n", "<br/>");
JsObjectBuilder ob = new JsObjectBuilder();
ob.AddProperty("title", title, true);
ob.AddProperty("msg", JsHelper.GetJsStringWithScriptTag(message), true);
ob.AddProperty("buttons", "Ext.MessageBox.OKCANCEL", true);
ob.AddProperty("icon", String.Format("{0}", MessageBoxIconHelper.GetName(icon)), true);
ob.AddProperty("fn", String.Format("function(btn){{if(btn=='cancel'){{{0}}}else{{{1}}}}}", cancelScript, okScriptstring), true);
string targetName = "window";
if (target != Target.Self)
{
targetName = TargetHelper.GetScriptName(target);
}
return String.Format("{0}.Ext.MessageBox.show({1});", targetName, ob.ToString());
}
示例4: showMessage
public DialogResult showMessage(IWin32Window owner, string message, string title, MessageBoxIcon icon, MessageBoxButtons buttons) {
//Wenn kein Owner mitgegeben wurde, dann Versuchen das Hauptfenster anzuzeigen
if (owner == null || owner.Handle == IntPtr.Zero)
owner = new dummyWindow(Process.GetCurrentProcess().MainWindowHandle);
const string appTitle = "updateSystem.NET Administration";
//Nachricht loggen
logLevel lLevel;
switch (icon) {
case MessageBoxIcon.Error:
lLevel = logLevel.Error;
break;
case MessageBoxIcon.Exclamation:
lLevel = logLevel.Warning;
break;
default:
lLevel = logLevel.Info;
break;
}
Log.writeState(lLevel,
string.Format("{0}{1}", string.IsNullOrEmpty(title) ? "" : string.Format("{0} -> ", title),
message));
var dlgResponse = Environment.OSVersion.Version.Major >= 6
? showTaskDialog(owner, appTitle, title, message, buttons, icon)
: showMessageBox(owner, appTitle, title, message, icon, buttons);
Log.writeKeyValue(lLevel, "Messagedialogresult", dlgResponse.ToString());
return dlgResponse;
}
示例5: GetName
public static string GetName(MessageBoxIcon type)
{
string result = String.Empty;
switch (type)
{
case MessageBoxIcon.Information:
//result = "ext-mb-info";
result = "Ext.MessageBox.INFO";
break;
case MessageBoxIcon.Warning:
//result = "ext-mb-warning";
result = "Ext.MessageBox.WARNING";
break;
case MessageBoxIcon.Question:
//result = "ext-mb-question";
result = "Ext.MessageBox.QUESTION";
break;
case MessageBoxIcon.Error:
//result = "ext-mb-error";
result = "Ext.MessageBox.ERROR";
break;
}
return result;
}
示例6: Show
/// <summary>
/// Shows the alert dialog.
/// </summary>
/// <param name="core">
/// The StyleCop core instance.
/// </param>
/// <param name="parent">
/// The parent control.
/// </param>
/// <param name="message">
/// The message to display on the dialog.
/// </param>
/// <param name="title">
/// The title of the dialog.
/// </param>
/// <param name="buttons">
/// The dialog buttons.
/// </param>
/// <param name="icon">
/// The dialog icon.
/// </param>
/// <returns>
/// Returns the dialog result.
/// </returns>
public static DialogResult Show(StyleCopCore core, Control parent, string message, string title, MessageBoxButtons buttons, MessageBoxIcon icon)
{
Param.RequireNotNull(core, "core");
Param.Ignore(parent);
Param.RequireValidString(message, "message");
Param.RequireValidString(title, "title");
Param.Ignore(buttons);
Param.Ignore(icon);
if (core.DisplayUI)
{
return DisplayMessageBox(parent, message, title, buttons, icon);
}
else
{
// Alert Dialogs which provide options other than OK cannot be handled when the
// program is running in a non-UI mode.
if (buttons != MessageBoxButtons.OK)
{
throw new InvalidOperationException(Strings.AlertDialogWithOptionsInNonUIState);
}
SendToOutput(core, message, icon);
return DialogResult.OK;
}
}
示例7: ShowMessageBox
public static int? ShowMessageBox(string title, string text, IEnumerable<string> buttons, int focusButton, MessageBoxIcon icon)
{
// don't do anything if the guide is visible - one issue this handles is showing dialogs in quick
// succession, we have to wait for the guide to go away before the next dialog can display
if (Guide.IsVisible) return null;
// if we have a result then we're all done and we want to return it
if (dialogResult != null)
{
// preserve the result
int? saveResult = dialogResult;
// reset everything for the next message box
dialogResult = null;
Showing = false;
// return the result
return saveResult;
}
// return nothing if the message box is still being displayed
if (Showing) return null;
// otherwise show it
Showing = true;
Guide.BeginShowMessageBox(title, text, buttons, focusButton, icon, MessageBoxEnd, null);
return null;
}
示例8: frmExceptionHandler
private frmExceptionHandler(Exception exceptionToPublish, bool restartAllowed, MessageBoxIcon iconType)
: this()
{
this.ExceptionToPublish = exceptionToPublish;
this.AllowContinueButton = restartAllowed;
this.m_mode = iconType;
if (iconType == MessageBoxIcon.Asterisk)
this.pbIcon.Image = System.Drawing.SystemIcons.Asterisk.ToBitmap();
else if (iconType == MessageBoxIcon.Error)
this.pbIcon.Image = System.Drawing.SystemIcons.Error.ToBitmap();
else if (iconType == MessageBoxIcon.Exclamation)
this.pbIcon.Image = System.Drawing.SystemIcons.Exclamation.ToBitmap();
else if (iconType == MessageBoxIcon.Hand)
this.pbIcon.Image = System.Drawing.SystemIcons.Hand.ToBitmap();
else if (iconType == MessageBoxIcon.Information)
this.pbIcon.Image = System.Drawing.SystemIcons.Information.ToBitmap();
else if (iconType == MessageBoxIcon.None)
this.pbIcon.Image = null;
else if (iconType == MessageBoxIcon.Question)
this.pbIcon.Image = System.Drawing.SystemIcons.Question.ToBitmap();
else if (iconType == MessageBoxIcon.Stop)
this.pbIcon.Image = System.Drawing.SystemIcons.Shield.ToBitmap();
else if (iconType == MessageBoxIcon.Warning)
this.pbIcon.Image = System.Drawing.SystemIcons.Warning.ToBitmap();
}
示例9: KFreonMessageBox
/// <summary>
/// Provides a more customisable MessageBox with 3 buttons available.
/// DialogResults: Button1 = OK, button2 = Abort, button3 = Cancel.
/// </summary>
/// <param name="Title"></param>
/// <param name="Message"></param>
/// <param name="Button1Text"></param>
/// <param name="Button2Text"></param>
/// <param name="Button3Text"></param>
/// <param name="icon"></param>
public KFreonMessageBox(string Title, string Message, string Button1Text, MessageBoxIcon icon, string Button2Text = null, string Button3Text = null)
{
InitializeComponent();
this.Text = Title;
label1.Text = Message;
button1.Text = Button1Text;
if (Button2Text != null)
button2.Text = Button2Text;
button2.Visible = Button2Text != null;
if (Button3Text != null)
button3.Text = Button3Text;
button3.Visible = Button3Text != null;
// KFreon: Reset positions?
//166, 500 = 330
// KFreon: Deal with icon/picture
if (pictureBox1.Image != null)
pictureBox1.Image.Dispose();
if (icon != 0)
pictureBox1.Image = GetSystemImageForMessageBox(icon);
else
pictureBox1.Image = new Bitmap(1, 1);
}
示例10: ShowMessage
public override void ShowMessage(string text, string caption, MessageBoxIcon icon)
{
var @class = String.Empty;
switch (icon)
{
case MessageBoxIcon.Error:
@class = "alert alert-danger";
break;
case MessageBoxIcon.Information:
@class = "alert alert-success";
break;
case MessageBoxIcon.None:
@class = "alert alert-info";
break;
case MessageBoxIcon.Question:
@class = "alert alert-warning";
break;
case MessageBoxIcon.Warning:
@class = "alert alert-warning";
break;
}
message_container.InnerHtml += RenderMessage(caption, text, @class);
message_container.Visible = true;
}
示例11: DisplayException
/// <summary>
/// Displays a message box containing information about an exception, for the currently executing application, plus optional additional information.
/// </summary>
/// <param name="owner">The window owning the dialog</param>
/// <param name="caption">The caption to display on the dialog</param>
/// <param name="icon">The icon to display on the dialog</param>
/// <param name="buttons">The buttons to display on the dialog</param>
/// <param name="ex">The exception to display on the dialog</param>
/// <param name="infoLines">Optional additional information to display on the dialog</param>
/// <returns>The result of the dialog</returns>
public static DialogResult DisplayException(IWin32Window owner, string caption, MessageBoxIcon icon, MessageBoxButtons buttons, Exception ex, params string[] infoLines)
{
bool hasAdditionalInfo = false;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
/// begin with the application information that generated the exception
sb.Append(string.Format("The application '{0}' has encountered the following exception or condition.\n\n", Path.GetFileName(System.Windows.Forms.Application.ExecutablePath)));
/// append the additional information if any was supplied
if (infoLines != null)
{
hasAdditionalInfo = true;
sb.Append("Additional Information:\n\n");
foreach(string line in infoLines)
sb.Append(string.Format("{0}\n", line));
}
if (ex != null)
{
/// append the information contained in the exception
sb.Append(string.Format("{0}Exception Information:\n\n", (hasAdditionalInfo ? "\n" : null)));
sb.Append(ex.ToString());
}
/// display a message and return the result
return MessageBox.Show(owner, sb.ToString(), caption, buttons, icon);
}
示例12: Show
/// <summary>
/// Displays a message box.
/// </summary>
/// <param name="owner">Owner window.</param>
/// <param name="text">Text to display.</param>
/// <param name="caption">Text to display in the title bar.</param>
/// <param name="cdText">Text to display near check box.</param>
/// <param name="buttons">Buttons to display in the message box.</param>
/// <param name="icon">Icon to display in the mesage box.</param>
/// <returns>One of the <see cref="DialogResult"/> values.</returns>
public DialogResult Show(IWin32Window owner, string text, string caption, string cdText, MessageBoxButtons buttons, MessageBoxIcon icon)
{
button1.Click += new EventHandler(OnButtonClick);
button2.Click += new EventHandler(OnButtonClick);
button3.Click += new EventHandler(OnButtonClick);
this.Text = caption;
msgText.Text = text;
cbOption.Text = cdText;
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
NativeMethods.EnableMenuItem(NativeMethods.GetSystemMenu(this.Handle, false),
NativeMethods.SC_CLOSE, NativeMethods.MF_BYCOMMAND | NativeMethods.MF_GRAYED);
}
else this.ControlBox = false;
SetButtonsToDisplay(buttons);
SetIconToDisplay(icon);
MessageBeep(icon);
ShowDialog(owner);
return m_dialogResult;
}
示例13: Mes
public static DialogResult Mes(string descr, MessageBoxIcon icon = MessageBoxIcon.Information, MessageBoxButtons butt = MessageBoxButtons.OK)
{
if (descr.Length > 0)
return MessageBox.Show(descr, Application.ProductName, butt, icon);
else
return DialogResult.OK;
}
示例14: KryptonMessageBox
private KryptonMessageBox(string text, string caption,
MessageBoxButtons buttons, MessageBoxIcon icon,
MessageBoxDefaultButton defaultButton, MessageBoxOptions options,
HelpInfo helpInfo)
{
// Store incoming values
_text = text;
_caption = caption;
_buttons = buttons;
_icon = icon;
_defaultButton = defaultButton;
_options = options;
_helpInfo = helpInfo;
// Create the form contents
InitializeComponent();
// Update contents to match requirements
UpdateText();
UpdateIcon();
UpdateButtons();
UpdateDefault();
UpdateHelp();
// Finally calculate and set form sizing
UpdateSizing();
}
示例15: smethod_8
// Token: 0x06002C9D RID: 11421
// RVA: 0x0012157C File Offset: 0x0011F77C
public static DialogResult smethod_8(string string_0, MessageBoxButtons messageBoxButtons_0, MessageBoxIcon messageBoxIcon_0)
{
Class115.smethod_6(true);
DialogResult result = MessageBox.Show(string_0, "osu!", messageBoxButtons_0, messageBoxIcon_0);
Class115.smethod_6(false);
return result;
}