private void ShowAddressBook() { activeContactController = contactControllerFactory.CreateExport().Value; activeContactController.Root = Root; activeContactController.Initialize(); activeContactController.Run(); var uiNewContactCommand = new ToolBarCommand(activeContactController.NewContactCommand, "_New contact", "Creates a new contact."); var uiDeleteCommand = new ToolBarCommand(activeContactController.DeleteContactCommand, "_Delete", "Deletes the selected contact."); shellService.AddToolBarCommands(new[] { uiNewContactCommand, uiDeleteCommand }); }
private void ShowEmails(EmailFolder emailFolder) { activeEmailFolderController = emailFolderControllerFactory.CreateExport().Value; activeEmailFolderController.EmailFolder = emailFolder; activeEmailFolderController.Initialize(); activeEmailFolderController.Run(); var uiNewEmailCommand = new ToolBarCommand(newEmailCommand, "_New email", "Creates a new email."); var uiDeleteEmailCommand = new ToolBarCommand(activeEmailFolderController.DeleteEmailCommand, "_Delete", "Deletes the selected email."); var uiEmailAccountsCommand = new ToolBarCommand(emailAccountsController.EmailAccountsCommand, "_Email accounts", "Opens a window that shows the email accounts."); shellService.AddToolBarCommands(new[] { uiNewEmailCommand, uiDeleteEmailCommand, uiEmailAccountsCommand }); }
public void ConstructorTest() { var emptyCommand = new DelegateCommand(() => { }); AssertHelper.ExpectedException <ArgumentNullException>(() => new ToolBarCommand(null, null)); AssertHelper.ExpectedException <ArgumentException>(() => new ToolBarCommand(emptyCommand, null)); var toolBarCommand1 = new ToolBarCommand(emptyCommand, "Command 1"); Assert.AreEqual(emptyCommand, toolBarCommand1.Command); Assert.AreEqual("Command 1", toolBarCommand1.Text); Assert.AreEqual("", toolBarCommand1.ToolTip); var toolBarCommand2 = new ToolBarCommand(emptyCommand, "Command 2", "ToolTip 2"); Assert.AreEqual("ToolTip 2", toolBarCommand2.ToolTip); }
public void ToolBarCommandsDelegation() { var shellView = Container.GetExportedValue <MockShellView>(); var shellViewModel = Container.GetExportedValue <ShellViewModel>(); var emptyCommand = new DelegateCommand(() => { }); var newToolBarCommands = new ToolBarCommand[] { new ToolBarCommand(emptyCommand, "Command 1"), new ToolBarCommand(emptyCommand, "Command 2") }; Assert.IsFalse(shellView.ToolBarCommands.Any()); shellViewModel.AddToolBarCommands(newToolBarCommands); Assert.IsTrue(shellView.ToolBarCommands.SequenceEqual(newToolBarCommands)); shellViewModel.ClearToolBarCommands(); Assert.IsFalse(shellView.ToolBarCommands.Any()); }
public void ToolBarCommandsDelegation() { var lazyShellViewModel = new Lazy <IShellViewModel>(() => new MockShellViewModel()); var shellService = new ShellService(lazyShellViewModel); var mockShellViewModel = (MockShellViewModel)lazyShellViewModel.Value; var emptyCommand = new DelegateCommand(() => { }); var newToolBarCommands = new ToolBarCommand[] { new ToolBarCommand(emptyCommand, "Command 1"), new ToolBarCommand(emptyCommand, "Command 2") }; Assert.IsFalse(mockShellViewModel.ToolBarCommands.Any()); shellService.AddToolBarCommands(newToolBarCommands); Assert.IsTrue(mockShellViewModel.ToolBarCommands.SequenceEqual(newToolBarCommands)); shellService.ClearToolBarCommands(); Assert.IsFalse(mockShellViewModel.ToolBarCommands.Any()); }
public ExecuteToolBarCommandMessage(ToolBarCommand command) { Command = command; }