/// <summary> /// Begins an asynchronous operation showing a <see cref="MessageDialog" />. /// </summary> /// <param name="content">The message displayed to the user.</param> /// <param name="title">The title you want displayed on the dialog.</param> /// <param name="commands"> /// The array of commands that appear in the command bar of the message dialog. These /// commands makes the dialog actionable. /// </param> /// <param name="defaultCommandIndex"> /// The index of the command you want to use as the default. This is the command that fires /// by default when users press the ENTER key. /// </param> /// <param name="cancelCommandIndex"> /// The index of the command you want to use as the cancel command. This is the command /// that fires when users press the ESC key. /// </param> /// <param name="options">The options for the dialog.</param> /// <returns> /// An object that represents the asynchronous operation. For more on the async pattern, see /// <see href="https://msdn.microsoft.com/en-us/windows/uwp/threading-async/asynchronous-programming-universal-windows-platform-apps">Asynchronous programming</see>. /// </returns> public IAsyncOperation <IUICommand> ShowMessageDialogAsync( string content, string title = null, IEnumerable <IUICommand> commands = null, uint?defaultCommandIndex = default(uint?), uint?cancelCommandIndex = default(uint?), MessageDialogOptions options = MessageDialogOptions.None) { if (content == null) { throw new ArgumentNullException(nameof(content)); } Logger.Write($"Title: {title}; Content: {content}"); var messageDialog = new MessageDialog(content) { Options = options }; DoIf(title != null, () => messageDialog.Title = title); DoIf(defaultCommandIndex != null, () => messageDialog.DefaultCommandIndex = defaultCommandIndex.Value); DoIf(cancelCommandIndex != null, () => messageDialog.CancelCommandIndex = cancelCommandIndex.Value); foreach (IUICommand uiCommand in commands ?? Enumerable.Empty <IUICommand>()) { messageDialog.Commands.Add(uiCommand); } return(messageDialog.ShowAsync()); }
public Task <DialogResult?> ShowMessageDialogAsync(MessageDialogOptions options) => _contentDialogService.ShowDialogAsync( new ContentDialogOptions <MessageDialogViewModel>( options.Title, new MessageDialogViewModel(options.Icon, options.Message), options.DialogResults ) );
public MessageDialogMessage() { Title = null; Content = null; DefaultCommandIndex = null; CancelCommandIndex = null; Options = MessageDialogOptions.None; }
public MessageDialogMessage(string key, string content, string title) : base(key) { Title = title; Content = content; DefaultCommandIndex = null; CancelCommandIndex = null; Options = MessageDialogOptions.None; }
public async Task <MessageDialogResult> ShowDialogAsync(MessageDialogOptions options) { return(await ShowAsync(options) switch { MessageBoxResult.OK => OnOkResult(), MessageBoxResult.Yes => OnYesResult(), MessageBoxResult.No => OnNoResult(), MessageBoxResult.Cancel => OnCancelResult(), MessageBoxResult.None => OnNoneResult(), _ => throw new MessageDialogUnknownResultTypeException("An unknown error occurred while reading the result of the dialog box!") });
private async void AppViewModel_MessageToDisplay( string message, string title, MessageDialogOptions option) { MessageDialog messageDialog = new MessageDialog(message, title); switch (option) { case MessageDialogOptions.Okay_Cancel: messageDialog.Commands.Add(new UICommand(Q.Resources.MessageDialog_Okay) { Id = MessageDialogResultsEnum.Okay }); messageDialog.Commands.Add(new UICommand(Q.Resources.MessageDialog_Cancel) { Id = MessageDialogResultsEnum.Cancel }); messageDialog.DefaultCommandIndex = 0; messageDialog.CancelCommandIndex = 1; break; case MessageDialogOptions.OK: messageDialog.Commands.Add(new UICommand(Q.Resources.MessageDialog_Okay) { Id = MessageDialogResultsEnum.Okay }); messageDialog.DefaultCommandIndex = 0; break; default: throw new NotSupportedException(); } var res = await messageDialog.ShowAsync(); AppViewModel.MessageDialogResults = (MessageDialogResultsEnum)(res).Id; }
/// <summary> /// Send message to user. For message results, see: <code>MessageDialogResults</code> /// </summary> /// <param name="message">Message to send</param> public void MessageDialog(string message, string title, MessageDialogOptions option) { MessageDialogResults = MessageDialogResultsEnum.No_Results; MessageToDisplay?.Invoke(message, title, option); }
public IAsyncOperation <IUICommand> ShowMessageDialogAsync(string content, string title = null, IEnumerable <IUICommand> commands = null, uint?defaultCommandIndex = null, uint?cancelCommandIndex = null, MessageDialogOptions options = MessageDialogOptions.None) { if (commands != null) { //TODO: This shouldn't be here. Use Moq to setup required dialog results. // Setting up for Logout test var logoutCommand = commands.FirstOrDefault(c => c.Label == "Logout"); if (logoutCommand != null) { return(Task.FromResult(logoutCommand).AsAsyncOperation()); } } return(Task.FromResult((IUICommand) new UICommand("Mock")).AsAsyncOperation()); }