public Task ShowAsync() { var commands = new List <IDialogUICommand <DialogResult> >(); _loginCommand = new DialogUICommand <DialogResult>("Login", DialogResult.Ok, true); _loginCommand.Invoked += async(sender, args) => { args.Cancel(); // Cancel command, we'll take it from here. await LoginAsync(); if (_authenticationService.IsLoggedIn) { args.DialogHost.TryClose(_loginCommand.DialogResult); } }; commands.Add(_loginCommand); #if !SILVERLIGHT var closeCommand = new DialogUICommand <DialogResult>("Close", DialogResult.Cancel, false, true); commands.Add(closeCommand); #endif UpdateCommands(); return(_dialogManager.ShowDialogAsync(commands, this)); }
public Task <DialogResult> ShowDialogAsync() { _okCommand = new DialogUICommand <DialogResult>(DialogResult.Ok, true) { Enabled = IsComplete }; var cancelCommand = new DialogUICommand <DialogResult>(DialogResult.Cancel, false, true); return(_dialogManager.ShowDialogAsync(new[] { _okCommand, cancelCommand }, this)); }
public void ShouldCancelCommand() { var cmd1 = new DialogUICommand<DialogResult>(DialogResult.Ok); cmd1.Invoked += (sender, args) => args.Cancel(); var button1 = new DialogButton(cmd1, new DialogHostBase()); Assert.IsFalse(button1.InvokeCommand()); Assert.IsTrue(cmd1.WasCancelled); IUICommand cmd2 = new DialogUICommand<DialogResult>(DialogResult.Ok); cmd2.Invoked += (sender, args) => args.Cancel(); var button2 = new DialogButton(cmd2, new DialogHostBase()); Assert.IsFalse(button2.InvokeCommand()); Assert.IsTrue(cmd2.WasCancelled); }
public void ShouldInvokeCustomCommand() { var invokeCount = 0; TestWindowManager.Instance.TestDialogResult = DialogResult.Ok; var command = new DialogUICommand<DialogResult>(DialogResult.Ok); command.Invoked += (sender, args) => invokeCount++; ((IUICommand) command).Invoked += (sender, args) => invokeCount++; var task = _dialogManager.ShowMessageAsync(new[] {command}, "Test"); Assert.IsTrue(invokeCount == 2); Assert.IsTrue(task.Result == DialogResult.Ok); Assert.IsFalse(task.IsCanceled); Assert.IsTrue(task.IsCompleted); }
public void ShouldInvokeCustomCommand() { var invokeCount = 0; TestWindowManager.Instance.TestDialogResult = DialogResult.Ok; var command = new DialogUICommand <DialogResult>(DialogResult.Ok); command.Invoked += (sender, args) => invokeCount++; ((IUICommand)command).Invoked += (sender, args) => invokeCount++; var task = _dialogManager.ShowMessageAsync(new[] { command }, "Test"); Assert.IsTrue(invokeCount == 2); Assert.IsTrue(task.Result == DialogResult.Ok); Assert.IsFalse(task.IsCanceled); Assert.IsTrue(task.IsCompleted); }
public void ShouldCancelCommand() { var cmd1 = new DialogUICommand <DialogResult>(DialogResult.Ok); cmd1.Invoked += (sender, args) => args.Cancel(); var button1 = new DialogButton(cmd1, new DialogHostBase()); Assert.IsFalse(button1.InvokeCommand()); Assert.IsTrue(cmd1.WasCancelled); IUICommand cmd2 = new DialogUICommand <DialogResult>(DialogResult.Ok); cmd2.Invoked += (sender, args) => args.Cancel(); var button2 = new DialogButton(cmd2, new DialogHostBase()); Assert.IsFalse(button2.InvokeCommand()); Assert.IsTrue(cmd2.WasCancelled); }
public Task<DialogResult> ShowDialogAsync() { _okCommand = new DialogUICommand<DialogResult>(DialogResult.Ok, true) {Enabled = IsComplete}; var cancelCommand = new DialogUICommand<DialogResult>(DialogResult.Cancel, false, true); return _dialogManager.ShowDialogAsync(new[] {_okCommand, cancelCommand}, this); }
public Task ShowAsync() { var commands = new List<IDialogUICommand<DialogResult>>(); _loginCommand = new DialogUICommand<DialogResult>("Login", DialogResult.Ok, true); _loginCommand.Invoked += async (sender, args) => { args.Cancel(); // Cancel command, we'll take it from here. await LoginAsync(); if (_authenticationService.IsLoggedIn) args.DialogHost.TryClose(_loginCommand.DialogResult); }; commands.Add(_loginCommand); #if !SILVERLIGHT var closeCommand = new DialogUICommand<DialogResult>("Close", DialogResult.Cancel, false, true); commands.Add(closeCommand); #endif UpdateCommands(); return _dialogManager.ShowDialogAsync(commands, this); }