Inheritance: IScreenAction
コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: OptionsMenu.cs プロジェクト: wbinford/storyteller
        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;
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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;
        }
コード例 #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));
        }
コード例 #6
0
 protected void register(ScreenAction screenAction)
 {
     _actions.Add(screenAction);
     _window.InputBindings.Add(screenAction.Binding);
 }