/// <summary> /// Define an Asp.net MessageBox instance. /// </summary> /// <param name="text">MessageBox text property.</param> /// <param name="title">MessageBox title property.</param> /// <param name="icons">MessageBox icon property.</param> /// <param name="buttons">MessageBox button style.</param> public MessageBox(string text, string title, MessageBoxIcons icons, MessageBoxButtons buttons, MessageBoxStyle styles) { this.MessageText = text; this.MessageTitle = title; this.MessageIcons = icons; this.MessageButtons = buttons; this.MessageStyles = styles; }
/// <summary> /// Instanciates a new MessageBoxWindow /// </summary> /// <param name="Title">The title of the messagebox</param> /// <param name="Message">The actual message to be delivered</param> /// <param name="messageBoxSize"> Optional Size Parameter changes the width of the window presented</param> /// <param name="messageBoxButtons">Optional (default OK) Allows you to select which buttons to give the user</param> /// <param name="messageBoxIcon"> Optioal (default OK) Allows you to select which Icon to present the user with the message</param> public MessageBox(string Title, string Message, MessageBoxSize messageBoxSize = MessageBoxSize.Medium, MessageBoxButtons messageBoxButtons = MessageBoxButtons.OK, MessageBoxIcons messageBoxIcon = MessageBoxIcons.OK) { Init(); this.DataContext = new MessageBoxModel(Title, Message, messageBoxSize, messageBoxButtons, messageBoxIcon); }
/// <summary> /// Instanciates a new <c>MessageBoxView</c>. /// </summary> /// <param name="Title">The title of the message box</param> /// <param name="Message">The actual message to be delivered</param> /// <param name="messageBoxSize"> Optional size parameter changes the width of the window presented</param> /// <param name="messageBoxButtons">Optional (default "OK"). Allows you to select which buttons to present the user.</param> /// <param name="messageBoxIcon"> Optional (default "OK"). Allows you to select which icon to present the user with the message.</param> public MessageBoxView(string Title, string Message, MessageBoxSize messageBoxSize = MessageBoxSize.Medium, MessageBoxButtons messageBoxButtons = MessageBoxButtons.OK, MessageBoxIcons messageBoxIcon = MessageBoxIcons.OK) { Init(); }
/// <summary> /// Instanciates a new MessageBoxModel /// </summary> /// <param name="Title">Message Box Header Title to be Displayed</param> /// <param name="Message">Actual Message to be displayed in the messageb box</param> /// <param name="messageBoxSize">MessageBox Size (Widht) Default Medium</param> /// <param name="messageBoxButtons">MessageBox Button Combiniation to Display (default OK)</param> /// <param name="messageBoxIcon">MessageBox Icon to Display (Default OK)</param> public MessageBoxModel(string Title, string Message, MessageBoxSize messageBoxSize = MessageBoxSize.Medium, MessageBoxButtons messageBoxButtons = MessageBoxButtons.OK, MessageBoxIcons messageBoxIcon = MessageBoxIcons.OK) { this.Title = Title; this.Message = Message; switch (messageBoxSize) { case MessageBoxSize.XLarge: this.Width = 800; break; case MessageBoxSize.Large: this.Width = 600; break; case MessageBoxSize.Small: this.Width = 200; break; default: { this.Width = 400; } break; } internalIcon = messageBoxIcon switch { MessageBoxIcons.ERROR => "resm:SQRLDotNetClientUI.Assets.Icons.error.png", MessageBoxIcons.WARNING => "resm:SQRLDotNetClientUI.Assets.Icons.warning.png", MessageBoxIcons.QUESTION => "resm:SQRLDotNetClientUI.Assets.Icons.question.png", _ => "resm:SQRLDotNetClientUI.Assets.Icons.ok.png", }; switch (messageBoxButtons) { case MessageBoxButtons.OKCancel: { AddButton("OK", _loc.GetLocalizationValue("BtnOK"), MessagBoxDialogResult.OK, isDefault: true); AddButton("Cancel", _loc.GetLocalizationValue("BtnCancel"), MessagBoxDialogResult.CANCEL); } break; case MessageBoxButtons.YesNo: { AddButton("Yes", _loc.GetLocalizationValue("BtnYes"), MessagBoxDialogResult.YES, isDefault: true); AddButton("No", _loc.GetLocalizationValue("BtnNo"), MessagBoxDialogResult.NO); } break; default: { AddButton("OK", _loc.GetLocalizationValue("BtnOK"), MessagBoxDialogResult.OK, isDefault: true); } break; } Init(); }
public MessageBoxViewModel(string message, MessageBoxButtons messageBoxButtons, MessageBoxIcons messageBoxIcons) { this.Message = message; this.IconKind = messageBoxIcons switch { MessageBoxIcons.Question => MaterialDesign::PackIconKind.HelpCircleOutline, MessageBoxIcons.Caution => MaterialDesign::PackIconKind.AlertOutline, _ => MaterialDesign::PackIconKind.AlertCircleOutline }; this.IconColor = messageBoxIcons switch { MessageBoxIcons.Question => Utils.ConvertToBrush("#42a5f5"), MessageBoxIcons.Caution => Utils.ConvertToBrush("#ffa500"), _ => Utils.ConvertToBrush("#d4000"), }; if (messageBoxButtons.HasFlag(MessageBoxButtons.Yes)) { this.YesVisibility = Visibility.Visible; } else { this.YesVisibility = Visibility.Collapsed; } if (messageBoxButtons.HasFlag(MessageBoxButtons.No)) { this.NoVisibility = Visibility.Visible; } else { this.NoVisibility = Visibility.Collapsed; } if (messageBoxButtons.HasFlag(MessageBoxButtons.OK)) { this.OKVisibility = Visibility.Visible; } else { this.OKVisibility = Visibility.Collapsed; } if (messageBoxButtons.HasFlag(MessageBoxButtons.Cancel)) { this.CancelVisibility = Visibility.Visible; } else { this.CancelVisibility = Visibility.Collapsed; } }
/// <summary> /// メッセージボックスを表示する /// </summary> /// <param name="message"></param> /// <param name="buttons"></param> /// <param name="icon"></param> /// <param name="identifier"></param> /// <returns></returns> public static async Task <MaterialMessageBoxResult> Show(string message, MessageBoxButtons buttons, MessageBoxIcons icon, string identifier = "default") { var dialog = new Niconicome.Views.Controls.MessageBox() { DataContext = new MessageBoxViewModel(message, buttons, icon) }; object?result = await DialogHost.Show(dialog, identifier); return((MaterialMessageBoxResult?)result ?? MaterialMessageBoxResult.No); }
protected MessageBox(string text, string title, MessageBoxButtons buttons = MessageBoxButtons.Ok, MessageBoxIcons icon = MessageBoxIcons.None, int width = 240, int height = 160) : base(width, height) { _result = MessageBoxResult.Cancel; _text = text; _title = title; AddButtons(buttons); switch (icon) { case MessageBoxIcons.Error: _img = Images.GetBitmap(Images.BitmapResources.msg_error); break; case MessageBoxIcons.Delete: _img = Images.GetBitmap(Images.BitmapResources.msg_delete); break; case MessageBoxIcons.Information: _img = Images.GetBitmap(Images.BitmapResources.msg_info); break; case MessageBoxIcons.Question: _img = Images.GetBitmap(Images.BitmapResources.msg_question); break; case MessageBoxIcons.Save: _img = Images.GetBitmap(Images.BitmapResources.msg_save); break; case MessageBoxIcons.Search: _img = Images.GetBitmap(Images.BitmapResources.msg_search); break; default: _img = null; break; } }
public MessageBox(string text, string title, MessageBoxButtons buttons = MessageBoxButtons.Ok, MessageBoxIcons icon = MessageBoxIcons.None, int height = 160) : this(text, title, buttons, icon, DesktopManager.ScreenWidth / 2, height) { }