public static MessageBoxImage Translate(DialogImage image) { switch (image) { case DialogImage.Asterisk: return(MessageBoxImage.Asterisk); case DialogImage.Error: return(MessageBoxImage.Error); case DialogImage.Exclamation: return(MessageBoxImage.Exclamation); case DialogImage.Hand: return(MessageBoxImage.Hand); case DialogImage.Information: return(MessageBoxImage.Information); case DialogImage.None: return(MessageBoxImage.None); case DialogImage.Question: return(MessageBoxImage.Question); case DialogImage.Stop: return(MessageBoxImage.Stop); case DialogImage.Warning: return(MessageBoxImage.Warning); } throw new InvalidOperationException("Unknown image type: " + image); }
static MessageBoxImage GetImage(DialogImage image) { switch (image) { case DialogImage.Asterisk: return MessageBoxImage.Asterisk; case DialogImage.Error: return MessageBoxImage.Error; case DialogImage.Exclamation: return MessageBoxImage.Exclamation; case DialogImage.Hand: return MessageBoxImage.Hand; case DialogImage.Information: return MessageBoxImage.Information; case DialogImage.None: return MessageBoxImage.None; case DialogImage.Question: return MessageBoxImage.Question; case DialogImage.Stop: return MessageBoxImage.Stop; case DialogImage.Warning: return MessageBoxImage.Warning; } throw new ArgumentOutOfRangeException("image", "Invalid image"); }
private void btnChooseAvatar_Click(object sender, EventArgs e) { if (DialogImage.ShowDialog() == DialogResult.OK) { AddStudentBackground.RunWorkerAsync(); } }
static MessageBoxImage GetImage(DialogImage image) { switch (image) { case DialogImage.Asterisk: return(MessageBoxImage.Asterisk); case DialogImage.Error: return(MessageBoxImage.Error); case DialogImage.Exclamation: return(MessageBoxImage.Exclamation); case DialogImage.Hand: return(MessageBoxImage.Hand); case DialogImage.Information: return(MessageBoxImage.Information); case DialogImage.None: return(MessageBoxImage.None); case DialogImage.Question: return(MessageBoxImage.Question); case DialogImage.Stop: return(MessageBoxImage.Stop); case DialogImage.Warning: return(MessageBoxImage.Warning); } throw new ArgumentOutOfRangeException(nameof(image), "Invalid image"); }
public DialogResult ShowDialog ( string message, string caption, DialogButton button, DialogImage image ) { return((DialogResult)MessageBox.Show ( message, caption, (MessageBoxButton)button, (MessageBoxImage )image )); }
public override async Task <DialogResult> ShowDialogAsync( object content, string caption, DialogButton dialogButton, DialogImage dialogImage = DialogImage.None, DialogController dialogController = null) { List <string> buttons = new List <string>(); if (dialogButton == DialogButton.OK) { buttons.Add(DefaultOkaySymbol); } else if (dialogButton == DialogButton.OKCancel || dialogButton == DialogButton.YesNo || dialogButton == DialogButton.YesNoCancel) { buttons.Add(DefaultOkaySymbol); buttons.Add(DefaultCancelSymbol); } var selectedIndex = await ShowDialogAsync(content, buttons, caption, 0, dialogController : dialogController); if (selectedIndex == null || selectedIndex < 0) { return(DialogResult.Cancel); } if (selectedIndex == 0) { return(dialogButton == DialogButton.OKCancel ? DialogResult.OK : DialogResult.Yes); } if (selectedIndex == 1) { return(DialogResult.Cancel); } throw new IndexOutOfRangeException( "Index returned from dialog is out of range. " + selectedIndex); }
/// <summary> /// Shows the exception in a MessageBox. /// </summary> /// <param name="message">The message.</param> /// <param name="image">The image.</param> /// <returns><see cref="DialogResponse"/>.OK</returns> public DialogResponse ShowException(String message, DialogImage image = DialogImage.Error) { MessageBox.Show(message, "Error", MessageBoxButton.OK, GetImage(image)); return DialogResponse.OK; }
/// <summary> /// Shows a dialogue using a known set of buttons and images. /// Override this message in test mocks. /// This is the only place where a MessageBox is shown. /// </summary> /// <param name="content">The message text to display.</param> /// <param name="caption">The caption to display at the top of the dialog.</param> /// <param name="dialogButton">The message box button enum value, /// which determines what buttons are shown.</param> /// <param name="dialogImage">The message box image, /// which determines what icon is used.</param> /// <param name="dialogController">An instance of the DialogController class /// that can be used to dismiss the dialog from calling code.</param> /// <returns>The result of showing the message box.</returns> public abstract Task <DialogResult> ShowDialogAsync( object content, string caption, DialogButton dialogButton, DialogImage dialogImage = DialogImage.None, DialogController dialogController = null);
// public string DefaultOkaySymbol = "Ok";// '\u2714' + ""; // public string DefaultCancelSymbol = "Cancel";// '\u2718' + ""; public override async Task <DialogResult> ShowDialogAsync( object content, string caption, DialogButton dialogButton, DialogImage dialogImage = DialogImage.None, DialogController dialogController = null) { List <string> buttons = new List <string>(); if (dialogButton == DialogButton.OK) { buttons.Add(Strings.Okay()); } else if (dialogButton == DialogButton.OKCancel) { buttons.Add(Strings.Cancel()); buttons.Add(Strings.Okay()); } else if (dialogButton == DialogButton.YesNo) { buttons.Add(Strings.No()); buttons.Add(Strings.Yes()); } else if (dialogButton == DialogButton.YesNoCancel) { buttons.Add(Strings.No()); buttons.Add(Strings.Cancel()); buttons.Add(Strings.Yes()); } var selectedIndex = await ShowDialogAsync( content, buttons, caption, 0, dialogController); if (selectedIndex < 0) { return(DialogResult.Cancel); } switch (selectedIndex) { case 0: switch (dialogButton) { case DialogButton.OK: return(DialogResult.OK); case DialogButton.OKCancel: return(DialogResult.Cancel); case DialogButton.YesNo: return(DialogResult.No); case DialogButton.YesNoCancel: return(DialogResult.No); } break; case 1: switch (dialogButton) { case DialogButton.OKCancel: return(DialogResult.OK); case DialogButton.YesNo: return(DialogResult.Yes); case DialogButton.YesNoCancel: return(DialogResult.Cancel); } break; case 2: switch (dialogButton) { case DialogButton.YesNoCancel: return(DialogResult.Yes); } break; } throw new IndexOutOfRangeException( "Index returned from dialog is out of range. " + selectedIndex); }
/// <summary> /// Shows the exception in a MessageBox. /// </summary> /// <param name="message">The message.</param> /// <param name="image">The image.</param> /// <returns><see cref="DialogResponse"/>.OK</returns> public DialogResponse ShowException(String message, DialogImage image = DialogImage.Error) { MessageBox.Show(message, "Error", MessageBoxButton.OK, GetImage(image)); return(DialogResponse.OK); }
/// <summary> /// Shows the message in a MessageBox. /// </summary> /// <param name="message">The message.</param> /// <param name="caption">The caption.</param> /// <param name="button">The button.</param> /// <param name="image">The image.</param> /// <returns><see cref="DialogResponse"/></returns> public DialogResponse ShowMessage(String message, String caption, DialogResult button, DialogImage image) { return(GetResponse(MessageBox.Show(message, caption, GetButton(button), GetImage(image)))); }
public DialogResult ShowMessage(string text, string caption, DialogButton button, DialogImage image) => (DialogResult)MessageBox.Show(text, caption, (MessageBoxButton)button, (MessageBoxImage)image);
public static MessageBoxImage TranslateToMessageBoxButton(this DialogImage image) { return(Translate(image)); }
public DialogResponse ShowMessage(string message, string caption, DialogButton button, DialogImage image) { return DialogResponse.OK; }
public DialogResponse ShowException(string message, DialogImage image) { return DialogResponse.OK; }
public override async Task <DialogResult> ShowDialogAsync( object message, string caption, DialogButton dialogButton, DialogImage dialogImage = DialogImage.None, DialogController dialogController = null) { int?result; /* TODO: Make localizable resource. */ switch (dialogButton) { case DialogButton.OK: result = await ShowDialogAsync( message, new List <object> { Strings.OK }, caption); if (result == 0) { return(DialogResult.OK); } return(DialogResult.None); case DialogButton.OKCancel: result = await ShowDialogAsync( message, new List <object> { Strings.OK, Strings.Cancel }, caption); if (result == 0) { return(DialogResult.OK); } else if (result == 1) { return(DialogResult.Cancel); } return(DialogResult.None); case DialogButton.YesNo: result = await ShowDialogAsync( message, new List <object> { Strings.Yes, Strings.No }, caption); if (result == 0) { return(DialogResult.Yes); } else if (result == 1) { return(DialogResult.No); } return(DialogResult.None); case DialogButton.YesNoCancel: result = await ShowDialogAsync( message, new List <object> { Strings.Yes, Strings.No, Strings.Cancel }, caption); if (result == 0) { return(DialogResult.Yes); } else if (result == 1) { return(DialogResult.No); } else if (result == 2) { return(DialogResult.Cancel); } return(DialogResult.None); default: throw new InvalidOperationException( "Unknown DialogButton: " + dialogButton); } }
public override Task <DialogResult> ShowDialogAsync( object content, string caption, DialogButton dialogButton, DialogImage dialogImage = DialogImage.None, DialogController dialogController = null) { Window mainWindow = GetActiveWindow(); Dispatcher dispatcher = mainWindow != null ? mainWindow.Dispatcher : Dispatcher.CurrentDispatcher; string bodyString = content?.ToString().Parse() ?? string.Empty; string captionString = caption?.Parse() ?? string.Empty; if (dispatcher == null || dispatcher.CheckAccess()) { MessageBoxResult messageBoxResult; try { Interlocked.Increment(ref openDialogCount); if (mainWindow != null) { /* We are on the UI thread, and hence no need to invoke the call.*/ messageBoxResult = MessageBox.Show( mainWindow, bodyString, captionString, dialogButton.TranslateToMessageBoxButton(), dialogImage.TranslateToMessageBoxButton()); } else { messageBoxResult = MessageBox.Show( bodyString, captionString, dialogButton.TranslateToMessageBoxButton(), dialogImage.TranslateToMessageBoxButton()); } } finally { Interlocked.Decrement(ref openDialogCount); } return(Task.FromResult( messageBoxResult.TranslateToMessageBoxResult())); } DialogResult result = DialogResult.OK; /* Satisfy compiler with default value. */ dispatcher.Invoke((ThreadStart) delegate { MessageBoxResult messageBoxResult; try { Interlocked.Increment(ref openDialogCount); if (mainWindow != null) { /* We are on the UI thread, * and hence no need to invoke the call.*/ messageBoxResult = MessageBox.Show(mainWindow, bodyString, captionString, dialogButton.TranslateToMessageBoxButton(), dialogImage.TranslateToMessageBoxButton()); } else { messageBoxResult = MessageBox.Show(bodyString, captionString, dialogButton.TranslateToMessageBoxButton(), dialogImage.TranslateToMessageBoxButton()); } } finally { Interlocked.Decrement(ref openDialogCount); } result = messageBoxResult.TranslateToMessageBoxResult(); }); return(Task.FromResult(result)); }
/// <summary> /// Shows the message in a MessageBox. /// </summary> /// <param name="message">The message.</param> /// <param name="caption">The caption.</param> /// <param name="button">The button.</param> /// <param name="image">The image.</param> /// <returns><see cref="DialogResponse"/></returns> public DialogResponse ShowMessage(String message, String caption, DialogButton button, DialogImage image) { return GetResponse(MessageBox.Show(message, caption, GetButton(button), GetImage(image))); }
public DialogResult ShowDialog(string message, string title, DialogButton buttons, DialogImage image) { return((DialogResult)MessageBox.Show(message, title, (MessageBoxButton)buttons, (MessageBoxImage)image)); }
public override void Draw(SpriteBatch spriteBatch) { ScreenService.Instance.GraphicsDevice.Viewport = ScreenService.Instance.DefaultScreenCamera.CurrentViewport; spriteBatch.Begin( SpriteSortMode.FrontToBack, // this is also the order for building the screen. null, SamplerState.PointClamp, null, null, null, ScreenService.Instance.DefaultScreenCamera.TransformMatrix); base.Draw(spriteBatch); if (!Images.Any()) { Messages.Add("no image received from server"); } foreach (var img in Images.ToList()) { img.Draw(spriteBatch); } if (!InventoryImages.Any()) { Messages.Add("no inventory image received from server"); } foreach (var img in InventoryImages.ToList()) { img.Draw(spriteBatch); } MultiplayerText.Draw(spriteBatch); HealthImage.Draw(spriteBatch); SpeedImage.Draw(spriteBatch); StrenghImage.Draw(spriteBatch); DialogImage.Draw(spriteBatch); CursorImage.Draw(spriteBatch); //LerpMouseImage.Draw(spriteBatch); if (InfoWindow?.IsVisible == true) { InfoWindow?.Draw(spriteBatch); } if (DialogWindow?.IsVisible == true) { DialogWindow?.Draw(spriteBatch); } if (InventoryWindow?.IsVisible == true) { InventoryWindow.Draw(spriteBatch); } if (CharacterWindow?.IsVisible == true) { MoneyCount.Draw(spriteBatch); CharacterWindow?.Draw(spriteBatch); } if (CharacterWindow?.IsVisible == true) { CharacterWindow?.Draw(spriteBatch); } if (ChatWindow?.IsVisible == true) { ChatWindow?.Draw(spriteBatch); } spriteBatch.End(); }