Пример #1
0
        /// <summary>
        /// Executes this action.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="context">The context.</param>
        public override void Execute(RootModel model, ActionExecutionContext context)
        {
            Assert.ArgumentNotNull(model, "model");
            Assert.ArgumentNotNull(context, "context");

            model.PushCommandToConveyor(new TextCommand(PostProcessString(CommandText + GetParametersString(model, context), model, context)));
        }
Пример #2
0
        private void GotoDirection(ExitDirection exitDirection)
        {
            switch (exitDirection)
            {
            case ExitDirection.North:
                _rootModel.PushCommandToConveyor(new TextCommand("north"));
                break;

            case ExitDirection.South:
                _rootModel.PushCommandToConveyor(new TextCommand("south"));
                break;

            case ExitDirection.East:
                _rootModel.PushCommandToConveyor(new TextCommand("east"));
                break;

            case ExitDirection.West:
                _rootModel.PushCommandToConveyor(new TextCommand("west"));
                break;

            case ExitDirection.Up:
                _rootModel.PushCommandToConveyor(new TextCommand("up"));
                break;

            case ExitDirection.Down:
                _rootModel.PushCommandToConveyor(new TextCommand("down"));
                break;

            default:
                _rootModel.PushMessageToConveyor(new ErrorMessage(Resources.RoomNavigationError));
                break;
            }

            _rootModel.PushCommandToConveyor(FlushOutputQueueCommand.Instance);
        }
Пример #3
0
        /// <summary>
        /// Executes this action.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="context">The context.</param>
        public override void Execute(RootModel model, ActionExecutionContext context)
        {
            Assert.ArgumentNotNull(model, "model");
            Assert.ArgumentNotNull(context, "context");

            var cmd = new TextCommand("#status " + CommandText);

            model.PushCommandToConveyor(cmd);
        }
Пример #4
0
        /// <summary>
        /// Executes this action.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="context">The context.</param>
        public override void Execute([NotNull] RootModel model, [NotNull] ActionExecutionContext context)
        {
            Assert.ArgumentNotNull(model, "model");
            Assert.ArgumentNotNull(context, "context");

            StringBuilder sb = new StringBuilder(CommandText);

            foreach (KeyValuePair <int, string> kvp in context.Parameters)
            {
                sb.Append(kvp.Value);
            }

            //model.PushCommandToConveyor(new TextCommand(ReplaceVariables(sb.ToString(), model)));
            model.PushCommandToConveyor(new TextCommand(sb.ToString()));
        }
Пример #5
0
        /// <summary>
        /// Sends the current command.
        /// </summary>
        public void SendCurrentCommand()
        {
            var command = Text ?? string.Empty;

            if (!string.IsNullOrEmpty(command) && command.Length >= SettingsHolder.Instance.Settings.MinLengthHistory)
            {
                lock (_enteredCommandsQueue)
                {
                    _enteredCommandsQueue.RemoveAll(x => x == command);

                    _enteredCommandsQueue.Add(command);

                    if (_enteredCommandsQueue.Count > _queueSize)
                    {
                        _enteredCommandsQueue.RemoveAt(0);
                    }

                    _currentQueueElementIndex = _enteredCommandsQueue.Count;
                }
            }

            oldText = String.Empty;

            RootModel.PushCommandToConveyor(new TextCommand(command));
            RootModel.PushCommandToConveyor(FlushOutputQueueCommand.Instance);
            if (SettingsHolder.Instance.Settings.AutoClearInput)
            {
                _selfTextChanges = true;
                Clear();
            }
            else
            {
                SelectAll();
                realStartSelection = 0;
            }
        }
 /// <summary>
 /// Executes this action.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="context">The context.</param>
 public override void Execute(RootModel model, ActionExecutionContext context)
 {
     model.PushCommandToConveyor(new ToggleFullScreenModeCommand());
 }
Пример #7
0
        /// <summary>
        /// Invoked when an unhandled <see cref="UIElement.PreviewKeyDown"/> attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.Windows.Input.KeyEventArgs"/> that contains the event data.</param>
        protected override void OnPreviewKeyDown([NotNull] KeyEventArgs e)
        {
            Assert.ArgumentNotNull(e, "e");

            _mainWindow.CheckGlobalHotkeys(e);

            if (e.Handled)
            {
                return;
            }

            var hotkeyCommand = new HotkeyCommand()
            {
                Key          = e.Key == Key.System ? e.SystemKey : e.Key,
                ModifierKeys = Keyboard.Modifiers,
                Handled      = false,
            };

            _rootModel.PushCommandToConveyor(hotkeyCommand);

            if (hotkeyCommand.Handled)
            {
                e.Handled = true;
                return;
            }

            if (e.Key == Key.Up && Keyboard.Modifiers == 0 && txtCommandInput.IsFocused)
            {
                txtCommandInput.ShowPreviousCommand();
                e.Handled = true;
            }

            if (e.Key == Key.Down && Keyboard.Modifiers == 0 && txtCommandInput.IsFocused)
            {
                txtCommandInput.ShowNextCommand();
                e.Handled = true;
            }

            if (e.Key == Key.Enter && txtCommandInput.IsFocused)
            {
                txtCommandInput.SendCurrentCommand();
                e.Handled = true;
            }

            if (e.Key == Key.PageUp)
            {
                if (scrollGridRow.Height.Value == 0)
                {
                    bool scrollToEnd = mainScrollOutput.ExtentHeight - (mainScrollOutput.ViewportHeight + mainScrollOutput.VerticalOffset) < 0.01;
                    scrollGridRow.Height   = new GridLength(Math.Max(mainScrollOutput.ViewportHeight * 0.4, 1));
                    splitterGridRow.Height = new GridLength(5);

                    if (scrollToEnd)
                    {
                        mainScrollOutput.ScrollToEnd();
                    }
                }
                else
                {
                    secondScrollOutput.PageUp();
                }

                e.Handled = true;
            }

            if (e.Key == Key.PageDown)
            {
                secondScrollOutput.PageDown();
                e.Handled = true;
            }

            if (e.Key == Key.End)
            {
                secondScrollOutput.ScrollToEnd();
                e.Handled = true;
            }

            //Очищение коммандной строки клавишей escape
            if (e.Key == Key.Escape && Keyboard.Modifiers == 0 && txtCommandInput.IsFocused)
            {
                txtCommandInput.Clear();
                e.Handled = true;
            }

            if (!e.Handled)
            {
                base.OnPreviewKeyDown(e);
            }
        }
Пример #8
0
 /// <summary>
 /// Executes this action.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="context">The context.</param>
 public override void Execute(RootModel model, ActionExecutionContext context)
 {
     model.PushCommandToConveyor(new SendToWindowCommand(OutputWindowName, ActionsToExecute, SendToAllWindows, context));
 }
Пример #9
0
        /// <summary>
        /// Invoked when an unhandled <see cref="UIElement.PreviewKeyDown"/> attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.Windows.Input.KeyEventArgs"/> that contains the event data.</param>
        protected override void OnPreviewKeyDown([NotNull] KeyEventArgs e)
        {
            Assert.ArgumentNotNull(e, "e");

            var hotkeyCommand = new HotkeyCommand
            {
                Key          = e.Key == Key.System ? e.SystemKey : e.Key,
                ModifierKeys = Keyboard.Modifiers,
                Handled      = false,
            };

            // For hotkeys, only Numpad Enter is processed
            var canPush = true;

            if (e.Key == Key.Enter && Keyboard.Modifiers == ModifierKeys.None)
            {
                var isExtended = (bool)typeof(KeyEventArgs).InvokeMember("IsExtendedKey", System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance, null, e, null);
                if (!isExtended)
                {
                    canPush = false;
                }
            }

            if (canPush)
            {
                RootModel.PushCommandToConveyor(hotkeyCommand);
            }

            if (hotkeyCommand.Handled)
            {
                e.Handled = true;
                return;
            }

            if (e.Key == Key.Up && Keyboard.Modifiers == 0 && txtCommandInput.IsFocused)
            {
                txtCommandInput.ShowPreviousCommand();
                e.Handled = true;
            }

            if (e.Key == Key.Down && Keyboard.Modifiers == 0 && txtCommandInput.IsFocused)
            {
                txtCommandInput.ShowNextCommand();
                e.Handled = true;
            }

            if (e.Key == Key.Enter && txtCommandInput.IsFocused)
            {
                txtCommandInput.SendCurrentCommand();
                e.Handled = true;
            }

            if (e.Key == Key.PageUp && Keyboard.Modifiers == 0)
            {
                PageUp();
                e.Handled = true;
            }

            if (e.Key == Key.PageDown && Keyboard.Modifiers == 0)
            {
                PageDown();
                e.Handled = true;
            }

            if (e.Key == Key.End && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
            {
                ScrollToEnd();
                e.Handled = true;
            }

            //Очищение коммандной строки клавишей escape
            if (e.Key == Key.Escape && Keyboard.Modifiers == 0 && txtCommandInput.IsFocused)
            {
                txtCommandInput.Clear();
                e.Handled = true;
            }

            if (!e.Handled)
            {
                base.OnPreviewKeyDown(e);
            }
        }
Пример #10
0
 /// <summary>
 /// Executes this action.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="context">The context.</param>
 public override void Execute(RootModel model, ActionExecutionContext context)
 {
     model.PushCommandToConveyor(new ShowMainOutputCommand(OutputWindowName));
 }