Defines a tool bar command
예제 #1
0
        private void ShowAddressBook()
        {
            activeContactController = container.GetExportedValue<ContactController>();
            activeContactController.Root = root;
            activeContactController.Initialize();
            activeContactController.Run();

            ToolBarCommand uiNewContactCommand = new ToolBarCommand(activeContactController.NewContactCommand, "_New contact",
                "Creates a new contact.");
            ToolBarCommand uiDeleteCommand = new ToolBarCommand(activeContactController.DeleteContactCommand, "_Delete",
                "Deletes the selected contact.");
            shellService.AddToolBarCommands(new[] { uiNewContactCommand, uiDeleteCommand });
        }
예제 #2
0
        private void ShowEmails(EmailFolder emailFolder)
        {
            activeEmailFolderController = container.GetExportedValue<EmailFolderController>();
            activeEmailFolderController.EmailFolder = emailFolder;
            activeEmailFolderController.Initialize();
            activeEmailFolderController.Run();

            ToolBarCommand uiNewEmailCommand = new ToolBarCommand(newEmailCommand, "_New email", 
                "Creates a new email.");
            ToolBarCommand uiDeleteEmailCommand = new ToolBarCommand(activeEmailFolderController.DeleteEmailCommand, "_Delete",
                "Deletes the selected email.");
            ToolBarCommand uiEmailAccountsCommand = new ToolBarCommand(emailAccountsController.EmailAccountsCommand, "_Email accounts",
                "Opens a window that shows the email accounts.");
            shellService.AddToolBarCommands(new[] { uiNewEmailCommand, uiDeleteEmailCommand, uiEmailAccountsCommand });
        }
예제 #3
0
        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);
        }
예제 #4
0
        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());
        }
예제 #5
0
        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());
        }