Inheritance: IScreenAction
        public void SetUp()
        {
            command = MockRepository.GenerateMock<ICommand>();
            command.Expect(x => x.CanExecute(null)).Return(true).IgnoreArguments();

            screenAction = new ScreenAction
            {
                Binding = new InputBinding(command, new KeyGesture(Key.F3)),
                Name = "some text"
            };

            item = new CommandMenuItem(screenAction);
        }
Example #2
0
        public CommandMenuItem(ScreenAction screenAction)
        {
            this.SetIcon(screenAction.Icon);
            Header = new DockPanel()
                .Left<Label>(x => x.Content = screenAction.Name)
                .Right<Label>(x =>
                {
                    x.Content = screenAction.KeyString;
                    x.HorizontalAlignment = HorizontalAlignment.Right;
                });

            ScreenAction = ScreenAction;
            Command = screenAction.Command;
        }
        public void Add(Icon icon, string text, Action action, KeyGesture gesture)
        {
            var screenAction = new ScreenAction()
            {
                Binding = new InputBinding(new ActionCommand(action), gesture),
                Icon = icon,
                Name = text
            };

            InputBindings.Add(screenAction.Binding);
            var item = CommandMenuItem.Build(screenAction);
            item.StaysOpenOnClick = true;

            Items.Add(item);
        }
        public static MenuItem Build(ScreenAction screenAction)
        {
            var item = new MenuItem()
            {
                //Header = new DockPanel().Left<Label>(x => x.Content = screenAction.Name),
                Header = screenAction.Name,
                InputGestureText = screenAction.KeyString,
                Tag = screenAction,
                Command = screenAction.Command
            };

            item.Icon = new TextBlock().Configure(x => x.SetIcon(screenAction.Icon));

            return item;
        }
Example #5
0
        public void shortcut_creates_a_button()
        {
            var command = MockRepository.GenerateMock<ICommand>();

            var shortcut = new ScreenAction
            {
                Name = "some text",
                Binding = new InputBinding(command, new KeyGesture(Key.F8)),
                Icon = Icon.Run
            };

            shortcut.BuildButton(_commands);

            _commands.AssertWasCalled(x => x.AddCommand("some text", command, Icon.Run));
        }
Example #6
0
 protected void register(ScreenAction screenAction)
 {
     _actions.Add(screenAction);
     _window.InputBindings.Add(screenAction.Binding);
 }