本文整理汇总了C#中MessageBoxButton类的典型用法代码示例。如果您正苦于以下问题:C# MessageBoxButton类的具体用法?C# MessageBoxButton怎么用?C# MessageBoxButton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageBoxButton类属于命名空间,在下文中一共展示了MessageBoxButton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Show
public static MessageBoxResult Show(
string messageBoxText,
string caption,
MessageBoxButton button)
{
return ShowCore(messageBoxText, caption, button, MessageDialogImage.None, 0);
}
示例2: AlertDialogBackend
public AlertDialogBackend()
{
this.buttons = MessageBoxButton.OKCancel;
this.icon = MessageBoxImage.None;
this.options = MessageBoxOptions.None;
this.defaultResult = MessageBoxResult.Cancel;
}
示例3: Show
/// <summary>
/// Displays a message box that has a message, title bar caption, and button; and that returns a result.
/// </summary>
/// <param name="messageBoxText">A System.String that specifies the text to display.</param>
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
/// <param name="button">A System.Windows.MessageBoxButton value that specifies which button or buttons to display.</param>
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button)
{
CustomMessageBoxWindow msg = new CustomMessageBoxWindow(messageBoxText, caption, button);
msg.ShowDialog();
return msg.Result;
}
示例4: Show
public static MessageBoxResult Show(
Action<Window> setOwner,
string messageBoxText,
string caption,
MessageBoxButton button,
MessageBoxImage icon,
MessageBoxResult defaultResult,
MessageBoxOptions options)
{
if ((options & MessageBoxOptions.DefaultDesktopOnly) == MessageBoxOptions.DefaultDesktopOnly)
{
throw new NotImplementedException();
}
if ((options & MessageBoxOptions.ServiceNotification) == MessageBoxOptions.ServiceNotification)
{
throw new NotImplementedException();
}
_messageBoxWindow = new WpfMessageBoxWindow();
setOwner(_messageBoxWindow);
PlayMessageBeep(icon);
_messageBoxWindow._viewModel = new MessageBoxViewModel(_messageBoxWindow, caption, messageBoxText, button, icon, defaultResult, options);
_messageBoxWindow.DataContext = _messageBoxWindow._viewModel;
_messageBoxWindow.ShowDialog();
return _messageBoxWindow._viewModel.Result;
}
示例5: MessageBoxMessage
public MessageBoxMessage(string text, string caption, MessageBoxButton button, Action<MessageBoxResult> resultCallback)
{
this.Text = text;
this.Caption = caption;
this.Button = button;
this.ResultCallback = resultCallback;
}
示例6: Show
public static MessageBoxResult Show(Window parent, string msg, string title, MessageBoxButton btns, MessageBoxImage 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.
MessageBoxResult rslt;
if (parent == null)
rslt = MessageBox.Show(msg, title, btns, icon);
else
rslt = MessageBox.Show(parent, msg, title, btns, icon);
// Release hook, clean up (may have already occurred)
Unhook();
return rslt;
}
示例7: MessageBoxMessage
public MessageBoxMessage(string key, string text, string caption, MessageBoxButton button)
: base(key)
{
this.Text = text;
this.Caption = caption;
this.Button = button;
}
示例8: ShowQuestion
internal static MessageBoxResult ShowQuestion(string message, MessageBoxButton messageBoxButton)
{
return MessageBox.Show(message,
"Question",
messageBoxButton,
MessageBoxImage.Question);
}
示例9: ShowResponse
internal static MessageBoxResult ShowResponse(string message, Response response, MessageBoxButton messageBoxButton)
{
MessageBoxImage messageBoxImage = MessageBoxImage.Information;
string caption = "Information";
if (response.HasErrors)
{
messageBoxImage = MessageBoxImage.Error;
caption = "Error";
}
else if (response.HasWarnings)
{
messageBoxImage = MessageBoxImage.Warning;
caption = "Warning";
}
else if (response.HasInformation)
{
messageBoxImage = MessageBoxImage.Information;
caption = "Information";
}
string responseMessage = (response.Errors.Aggregate(string.Empty, (result, error) => string.Format("{1}{2}{0}", System.Environment.NewLine, result, error.Message)) + System.Environment.NewLine +
response.Warnings.Aggregate(string.Empty, (result, error) => string.Format("{1}{2}{0}", System.Environment.NewLine, result, error.Message)) + System.Environment.NewLine +
response.Information.Aggregate(string.Empty, (result, error) => string.Format("{1}{2}{0}", System.Environment.NewLine, result, error.Message))).Trim();
return MessageBox.Show((message + System.Environment.NewLine + responseMessage).Trim(), caption, messageBoxButton, messageBoxImage);
}
示例10: ToOleDefault
private static OLEMSGDEFBUTTON ToOleDefault(MessageBoxResult defaultResult, MessageBoxButton button)
{
switch (button)
{
case MessageBoxButton.OK:
return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;
case MessageBoxButton.OKCancel:
if (defaultResult == MessageBoxResult.Cancel)
return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND;
return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;
case MessageBoxButton.YesNoCancel:
if (defaultResult == MessageBoxResult.No)
return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND;
if (defaultResult == MessageBoxResult.Cancel)
return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_THIRD;
return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;
case MessageBoxButton.YesNo:
if (defaultResult == MessageBoxResult.No)
return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND;
return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;
}
return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;
}
示例11: Show
public static void Show(string msg, string caption, MessageBoxButton button, MessageImage msgImage, Action<MessageBoxResult> callback)
{
DialogMessage result = new DialogMessage(null, msg, callback);
result.Caption = caption + ";" + ((int)msgImage).ToString();
result.Button = button;
AppMessages.SendMessage.Send(result);
}
示例12: MessageWindow
public MessageWindow(string text, MessageBoxButton buttons)
{
InitializeComponent();
Message.Text = text;
if (buttons == MessageBoxButton.OK)
{
AcceptButton.Content = "OK";
AcceptButton.Visibility = Visibility.Visible;
CancelButton.Visibility = Visibility.Hidden;
NoButton.Visibility = Visibility.Hidden;
}
else if (buttons == MessageBoxButton.OKCancel)
{
AcceptButton.Content = "OK";
AcceptButton.Visibility = Visibility.Visible;
CancelButton.Visibility = Visibility.Visible;
NoButton.Visibility = Visibility.Hidden;
}
else if (buttons == MessageBoxButton.YesNo)
{
AcceptButton.Content = "Yes";
AcceptButton.Visibility = Visibility.Visible;
CancelButton.Visibility = Visibility.Hidden;
NoButton.Visibility = Visibility.Visible;
}
else if (buttons == MessageBoxButton.YesNoCancel)
{
AcceptButton.Content = "Yes";
AcceptButton.Visibility = Visibility.Visible;
CancelButton.Visibility = Visibility.Visible;
NoButton.Visibility = Visibility.Visible;
}
}
示例13: ShowCore
private static MessageBoxResult ShowCore(
string messageBoxText,
string caption,
MessageBoxButton button,
MessageDialogImage icon,
MessageBoxResult defaultResult)
{
if (!IsValidMessageBoxButton(button))
{
throw new InvalidEnumArgumentException("button", (int)button, typeof(MessageBoxButton));
}
if (!IsValidMessageDialogImage(icon))
{
throw new InvalidEnumArgumentException("icon", (int)icon, typeof(MessageBoxImage));
}
if (!IsValidMessageBoxResult(defaultResult))
{
throw new InvalidEnumArgumentException("defaultResult", (int)defaultResult, typeof(MessageBoxResult));
}
var dialog = new Dialog(messageBoxText, caption, button, icon, defaultResult);
var flag = dialog.ShowDialog();
return flag == true ? MessageBoxResult.No : MessageBoxResult.None;
}
示例14: IsValidMessageBoxButton
private static bool IsValidMessageBoxButton(MessageBoxButton value)
{
return value == MessageBoxButton.OK
|| value == MessageBoxButton.OKCancel
|| value == MessageBoxButton.YesNo
|| value == MessageBoxButton.YesNoCancel;
}
示例15: Show
public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button)
{
UIAlertView messageBox;
if (button == MessageBoxButton.OKCancel)
messageBox = new UIAlertView (caption, messageBoxText, null, "OK", "Cancel");
else
messageBox = new UIAlertView (caption, messageBoxText, null, "OK");
messageBox.Show ();
int clicked = -1;
messageBox.Clicked += (s, buttonArgs) =>
{
clicked = buttonArgs.ButtonIndex;
};
while (clicked == -1)
{
NSRunLoop.Current.RunUntil (NSDate.FromTimeIntervalSinceNow (0.5));
if (messageBox.BecomeFirstResponder() == false)
break;
}
if (clicked == 0)
return MessageBoxResult.OK;
else
return MessageBoxResult.Cancel;
}