AlertFlags IAlertPopup.ShowPopup(string caption, string text, AlertFlags flags) { NSAlertStyle style = NSAlertStyle.Informational; if ((flags & AlertFlags.WarningIcon) != 0) { style = NSAlertStyle.Warning; } var alert = new NSAlert() { AlertStyle = style, MessageText = caption, InformativeText = text, }; var buttons = new List <AlertFlags>(); Action <AlertFlags, string> addBtn = (code, txt) => { if ((flags & code) == 0) { return; } alert.AddButton(txt); buttons.Add(code); }; addBtn(AlertFlags.Ok, "OK"); addBtn(AlertFlags.Yes, "Yes"); addBtn(AlertFlags.No, "No"); addBtn(AlertFlags.Cancel, "Cancel"); nint idx = alert.RunModal() - 1000; return((idx >= 0 && idx < buttons.Count) ? buttons[(int)idx] : AlertFlags.None); }
private int ShowAlert(string text, NSAlertStyle alertStyle, params string[] buttons) { var alert = CreateAlert(text, alertStyle, buttons); int resp = (int)alert.RunSheetModal(View.Window); alert.Dispose(); return(resp); }
public static NSAlert CreateAlert(string title, string message, NSAlertStyle style) { var alert = new NSAlert(); alert.AlertStyle = style; alert.InformativeText = message; alert.MessageText = title; return(alert); }
private NSAlert CreateAlert(string text, NSAlertStyle alertStyle) { NSAlert alert = new NSAlert { MessageText = text, AlertStyle = alertStyle }; return(alert); }
public static void ShowAlert(string title, string text, NSAlertStyle alertStyle) { using(NSAlert alert = new NSAlert()) { alert.MessageText = title; alert.InformativeText = text; alert.AlertStyle = alertStyle; alert.RunModal(); } }
/// <summary> /// Shows the alert on this window. /// </summary> /// <param name="msg">Message.</param> /// <param name="title">Title.</param> /// <param name="style">Style.</param> private void ShowAlertOnWindow(string msg, string title, NSAlertStyle style = NSAlertStyle.Informational) { var alert = new NSAlert { InformativeText = msg, MessageText = title, AlertStyle = style }; alert.RunSheetModal(Window); }
public static void ShowAlert(string message, NSAlertStyle style = NSAlertStyle.Informational) { var alert = new NSAlert { AlertStyle = style, MessageText = message, }; alert.RunModal(); }
protected void AddIconOrSetStyle(NSImage icon, NSAlertStyle style) { if (icon != null) { alert.Icon = icon; } else { alert.AlertStyle = NSAlertStyle.Critical; } }
public static void Alert(string title, string message, NSAlertStyle style) { NSAlert alert = new NSAlert() { AlertStyle = style, InformativeText = message, MessageText = title }; alert.RunModal(); alert.Dispose(); }
private NSAlert CreateAlert(string text, NSAlertStyle alertStyle, string[] buttons) { NSAlert alert = new NSAlert { MessageText = text, AlertStyle = alertStyle }; foreach (string button in buttons) { alert.AddButton(button); } return(alert); }
NSAlertButtonReturn ShowAlert(string msg, string title, NSAlertStyle alertStyle, bool showYesNo) { using (var alert = new NSAlert()) { alert.MessageText = title; alert.InformativeText = msg; alert.AlertStyle = alertStyle; if (showYesNo) { alert.AddButton("Yes"); alert.AddButton("No"); } return((NSAlertButtonReturn)((int)alert.RunSheetModal(NSApplication.SharedApplication.KeyWindow))); } }
public bool ShowWindow(NSAlertStyle alertStyle, string title, string information, string okBtnText, string canselBtnText = null) { nint result = 0; NSApplication.SharedApplication.InvokeOnMainThread(() => { var alert = CreateAlert(alertStyle, title, information, okBtnText, canselBtnText); result = alert.RunModal(); }); if (result == 1000) { return(true); } return(false); }
public static void Show(string title, string message = null, NSAlertStyle style = NSAlertStyle.Informational) { if (string.IsNullOrEmpty(title) && string.IsNullOrEmpty(message)) { return; } NSRunningApplication.CurrentApplication.Activate(NSApplicationActivationOptions.ActivateIgnoringOtherWindows); var alert = new NSAlert(); alert.AlertStyle = style; if (message != null) { alert.InformativeText = message; } if (title != null) { alert.MessageText = title; } alert.RunModal(); }
private NSAlert CreateAlert(NSAlertStyle alertStyle, string title, string information, string okBtnText, string canselBtnText) { var alert = new NSAlert() { MessageText = title, InformativeText = information, AlertStyle = alertStyle, }; alert.AddButton(okBtnText); //10001 if (!string.IsNullOrEmpty(canselBtnText)) { alert.AddButton(canselBtnText); //1001 var alert1 = new NSAlert(); alert1.AddButton("OK"); alert1.AddButton("Cancel"); alert.Buttons[1].KeyEquivalent = alert1.Buttons[1].KeyEquivalent; } return(alert); }
void Alert(string title, string message, NSAlertStyle style) { new NSAlert { AlertStyle = style, InformativeText = message, MessageText = title, }.RunModal(); }
private void ShowMessage(string message, NSAlertStyle style) { using (NSAlert alert = new NSAlert()) { alert.MessageText = message; alert.AlertStyle = style; alert.RunModal(); } }
public static void CreateAlert(this NSViewController view, string title, string message, Action action, NSAlertStyle style = NSAlertStyle.Informational) { view.InvokeOnMainThread(() => { var alert = new NSAlert { InformativeText = message ?? "", AlertStyle = style, MessageText = title }; alert.BeginSheetForResponse(view.View.Window, (result) => { if (action != null) { action(); } }); }); }