public void Communication_MustCorrectlyHandleMessageBoxRequest() { var args = new MessageBoxRequestEventArgs { Action = (int)MessageBoxAction.YesNo, Icon = (int)MessageBoxIcon.Question, Message = "Some question to be answered", RequestId = Guid.NewGuid(), Title = "A Title" }; messageBox.Setup(m => m.Show( It.Is <string>(s => s == args.Message), It.Is <string>(s => s == args.Title), It.Is <MessageBoxAction>(a => a == (MessageBoxAction)args.Action), It.Is <MessageBoxIcon>(i => i == (MessageBoxIcon)args.Icon), It.IsAny <IWindow>())).Returns(MessageBoxResult.No); sut.TryStart(); clientHost.Raise(c => c.MessageBoxRequested += null, args); runtimeProxy.Verify(p => p.SubmitMessageBoxResult( It.Is <Guid>(g => g == args.RequestId), It.Is <int>(r => r == (int)MessageBoxResult.No)), Times.Once); }
private void ClientHost_MessageBoxRequested(MessageBoxRequestEventArgs args) { logger.Info($"Received message box request with id '{args.RequestId}'."); var result = messageBox.Show(args.Message, args.Title, args.Action, args.Icon); runtime.SubmitMessageBoxResult(args.RequestId, result); logger.Info($"Message box request with id '{args.RequestId}' yielded result '{result}'."); }
private void ClientHost_MessageBoxRequested(MessageBoxRequestEventArgs args) { logger.Info($"Received message box request with id '{args.RequestId}'."); var action = (MessageBoxAction)args.Action; var icon = (MessageBoxIcon)args.Icon; var result = messageBox.Show(args.Message, args.Title, action, icon, parent: splashScreen); runtime.SubmitMessageBoxResult(args.RequestId, (int)result); logger.Info($"Message box request with id '{args.RequestId}' yielded result '{result}'."); }
private void _controller_MessageBoxRequest(object sender, MessageBoxRequestEventArgs e) { try { e.DialogResult = ControllerDisplayMessageBox(this, e); } catch (Exception ex) { ExceptionHandler(ex); } }
protected virtual DialogResult OnMessageBoxRequest(string prompt, string title, MessageBoxButtons buttons, MessageBoxIcon icon) { var handler = MessageBoxRequest; if (handler != null) { var e = new MessageBoxRequestEventArgs() { Prompt = prompt, Title = title, Buttons = buttons, Icon = icon }; handler.Invoke(this, e); return(e.DialogResult); } return(DialogResult.None); }
protected virtual DialogResult ControllerDisplayMessageBox(IWin32Window owner, MessageBoxRequestEventArgs e) { if (this.InvokeRequired) { e.DialogResult = (DialogResult)Invoke(new Func <DialogResult>( () => { return(MessageBox.Show(this, e.Prompt, e.Title, e.Buttons, e.Icon)); })); } else { e.DialogResult = MessageBox.Show(this, e.Prompt, e.Title, e.Buttons, e.Icon); } return(e.DialogResult); }