Example #1
0
    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        CommandTextBox.Text = Command;
        OutputTextBox.Text  = Output;

        CommandTextBox.Focus();
    }
        private void CommandTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode != Keys.Enter)
            {
                return;
            }

            var command = CommandTextBox.Text;

            if (string.IsNullOrEmpty(command))
            {
                return;
            }

            var sendResult = false;

            try
            {
                CommandTextBox.Clear();
                sendResult = m_comConnector.Send(command);
            }
            catch (Exception ex)
            {
                s_logger.Warn(ex);
            }

            AppendTrace(sendResult ? ">" + command : "Failed to send command.");
        }
Example #3
0
        public UserCommandDialog(Action <string> doDommand)
        {
            m_DoCommand = doDommand;
            InitializeComponent();
            CommandTextBox.HistoryLength = 50;      // Keep a fair bit of history for user commands.

            // Initialize from persistent store.
            var history = App.ConfigData["UserCommandHistory"];

            if (history != null)
            {
                CommandTextBox.SetHistory(history.Split(';'));
            }

            Loaded += delegate(object sender, RoutedEventArgs e)
            {
                CommandTextBox.Focus();
            };
            Closing += delegate(object sender, CancelEventArgs e)
            {
                CommandTextBox.Text = "";
                CommandTextBox.Focus();
                Hide();
                e.Cancel = true;
            };
        }
Example #4
0
        private async void GO_Click(object sender, RoutedEventArgs e)
        {
            //take a picture of the person giving the order
            var peopleIdentified = await TakePictureAndIdentifyAsync();

            var result = await WebClientAccess.Order(CommandTextBox.Text);

            var pins = GetAuthorizedPins(result.Entity, peopleIdentified);

            foreach (var pin in pins)
            {
                switch (result.Intent)
                {
                case Intent.LightOn:
                    pin.Write(GpioPinValue.Low);
                    break;

                case Intent.LightOff:
                    pin.Write(GpioPinValue.High);
                    break;

                case Intent.None:
                default:
                    break;
                }
            }

            CommandTextBox.Text = "";
            CommandTextBox.Focus(FocusState.Keyboard);
        }
Example #5
0
        public MainWindow()
        {
            InitializeComponent();
            DataContext    = new MainWindowViewModel();
            _commandFasade = new CommandFasade(DataContext as MainWindowViewModel);

            CommandTextBox.Focus();
        }
Example #6
0
 private void SendCommandButton_Click(object sender, RoutedEventArgs e)
 {
     TheServer.SendCommand(CommandTextBox.Text);
     ConsoleLogTextBox.AppendText($"SYSTEM COMMAND SENT : {CommandTextBox.Text}");
     ConsoleLogTextBox.AppendText(Environment.NewLine);
     ConsoleLogTextBox.ScrollToEnd();
     CommandTextBox.Clear();
 }
Example #7
0
 private void CommandTextBox_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key != Key.Enter)
     {
         return;
     }
     ServerProc.StandardInput.WriteLine(CommandTextBox.Text);
     CommandTextBox.Clear();
 }
Example #8
0
        protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs eventArgs)
        {
            base.OnGotKeyboardFocus(eventArgs);

            if (ReferenceEquals(eventArgs.NewFocus, this))
            {
                // Move focus to text box. (Usually only necessary when the view is focused
                // using the menu item or a key binding.)
                CommandTextBox.Focus();
            }
        }
Example #9
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            if (CommandTextBox.Text.Contains(" "))
            {
                MessageBox.Show("Command Must Be One Word !!!");
                CommandTextBox.Focus();
                return;
            }


            this.cmd.Command        = CommandTextBox.Text;
            this.cmd.Connection     = ConnectionComboBox.Text;
            this.cmd.Description    = DescriptionTextBox.Text;
            this.cmd.SqlCommandText = SqlRichTextBox.Text;
            this.DialogResult       = DialogResult.OK;
        }
Example #10
0
        private void TextBox_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key != Key.Enter)
            {
                return;
            }

            var text = CommandTextBox.Text;

            CommandTextBox.Text = "";
            DoSerialPortAction(() =>
            {
                ExecuteWaitAndRead(text);
            }, () =>
            {
                CommandTextBox.Focus();
            });
        }
Example #11
0
        private void SetupFocus()
        {
            SshConnectViewModel vm = (SshConnectViewModel)DataContext;

            if (vm.CommandInput)
            {
                CommandTextBox.Focus(FocusState.Programmatic);
            }
            else if (string.IsNullOrEmpty(vm.Username))
            {
                UserTextBox.Focus(FocusState.Programmatic);
            }
            else if (string.IsNullOrEmpty(vm.Host))
            {
                HostTextBox.Focus(FocusState.Programmatic);
            }
            else
            {
                Focus(FocusState.Programmatic);
            }
        }
 private void SendBTN_Click(object sender, EventArgs e)
 {
     if (CommandTextBox.Text.ToLower() == "cmds")         //check if the user send cmds so we can display the commands
     {
         CommandBox.AppendText(Functions.TextToBox[0]);   //Append text to the command richtextbox
         CommandTextBox.Clear();                          //clear the command textbox
     }
     else if (CommandTextBox.Text.ToLower() == "credits") //check if the user send credits so we can display the credits
     {
         CommandBox.AppendText(Functions.TextToBox[1]);   //Append text to the command richtextbox
         CommandTextBox.Clear();                          //clear the command textbox
     }
     else if (CommandTextBox.Text.ToLower() == "clear")
     {
         CommandBox.Clear();
         CommandTextBox.Clear();
     }
     else
     {
         NamedPipes.CommandPipe(CommandTextBox.Text); //command pipe function to send the text in the command textbox
         CommandTextBox.Clear();                      //clear the command textbox
     }
 }
Example #13
0
        public CPackConsole(string projectRootDirectory)
        {
            DataContext      = new CPackConsoleViewModel(projectRootDirectory);
            Service          = new CPackService();
            PreviousCommands = new List <string>();
            InitializeComponent();
            CommandTextBox.Focus();
            DialogContext = SynchronizationContext.Current;

            MyContext.PropertyChanged += (sender, args) => {
                if (args.PropertyName == "TextBoxEnabled")
                {
                    Thread.Sleep(200);
                    DialogContext.Post(val => {
                        if (CommandTextBox.IsEnabled)
                        {
                            CommandTextBox.Focus();
                        }
                    }, sender);
                }
            };

            MyContext.Exit += MyContext_Exit;
        }
Example #14
0
 private void SayBtn_Click(object sender, RoutedEventArgs e)
 {
     try { ServerProc.StandardInput.WriteLine("say " + CommandTextBox.Text); }
     catch { }
     CommandTextBox.Clear();
 }
Example #15
0
        /// <summary>
        /// 监听命令框键盘按下事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CommandTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            Console.WriteLine("CommandTextBox_KeyDown input KeyCode: " + e.KeyCode);

            // 如果回退位置在当前行前两个字符,光标跳转到最后
            //if (CommandTextBox.SelectionStart - CommandTextBox.GetFirstCharIndexOfCurrentLine() <= 2)
            //{
            //    CommandTextBox.SelectionStart = CommandTextBox.Text.Length;
            //    e.Handled = true;
            //    return;
            //}
            if ((CommandTextBox.GetLineFromCharIndex(CommandTextBox.SelectionStart) != CommandTextBox.GetLineFromCharIndex(CommandTextBox.Text.Length) || CommandTextBox.SelectionStart - CommandTextBox.GetFirstCharIndexOfCurrentLine() <= 2))
            {
                // && CommandTextBox.SelectionStart < (CommandTextBox.GetFirstCharIndexFromLine(CommandTextBox.GetLineFromCharIndex(CommandTextBox.Text.Length)) + 2)
                // && (!new List<Keys> { Keys.Right, Keys.Left, Keys.Up, Keys.Down }.Contains(e.KeyCode))
                //if(new List<Keys> { Keys.Right, Keys.Left, Keys.Up, Keys.Down }.Contains(e.KeyCode))
                //{
                Console.WriteLine("Invalid input location");
                CommandTextBox.SelectionStart = CommandTextBox.Text.Length;
                //CommandTextBox.SelectionStart = CommandTextBox.Text.Length;
                //}
                //e.SuppressKeyPress = false;
                e.Handled = true;
                return;
            }
            if (e.KeyCode == Keys.Enter)
            {
                var lastLine           = CommandTextBox.GetLineFromCharIndex(CommandTextBox.Text.Length);
                var lastFirstCharIndex = CommandTextBox.GetFirstCharIndexFromLine(lastLine);
                var lastLineText       = CommandTextBox.Text.Substring(lastFirstCharIndex, CommandTextBox.Text.Length - lastFirstCharIndex);
                CommandTextBox.AppendText(Environment.NewLine + "> ");
                Console.WriteLine("last line: " + lastLineText);
                e.Handled = true;
                return;
            }
            //if (e.KeyCode == Keys.Back)
            //{
            //    var backLineFirstCharIndex = CommandTextBox.GetFirstCharIndexOfCurrentLine();
            //    var backLine = CommandTextBox.GetLineFromCharIndex(CommandTextBox.SelectionStart);
            //    var lastLine = CommandTextBox.GetLineFromCharIndex(CommandTextBox.Text.Length);
            //    // 如果当前行不是最后一行,光标跳转到最后
            //    if (backLine != lastLine)
            //    {
            //        CommandTextBox.SelectionStart = CommandTextBox.Text.Length;
            //        e.Handled = true;
            //        return;
            //    }
            //    // 如果回退位置在当前行前两个字符,光标跳转到最后
            //    if (CommandTextBox.SelectionStart - CommandTextBox.GetFirstCharIndexOfCurrentLine() <= 2)
            //    {
            //        CommandTextBox.SelectionStart = CommandTextBox.Text.Length;
            //        e.Handled = true;
            //        return;
            //    }
            //    CommandTextBox.GetFirstCharIndexOfCurrentLine();
            //    var backLineText = CommandTextBox.Text.Substring(backLineFirstCharIndex, CommandTextBox.Text.Length - backLineFirstCharIndex);
            //    Console.WriteLine("back line: " + backLineText);
            //    //if(backLineText == "> " || backLineText.IndexOf("> ") > -1 || backLineText.IndexOf(Environment.NewLine) > -1)
            //    //    e.Handled = true;
            //}
        }
Example #16
0
 private void SetupFocus()
 {
     CommandTextBox.Focus(FocusState.Programmatic);
 }
Example #17
0
 public void RemoveHistory(string command)
 {
     CommandTextBox.RemoveFromHistory(command);
     SaveHistory();
 }
Example #18
0
 private void ResultTextBlock_PreviewMouseLeftButtonDown(Object Sender, MouseButtonEventArgs MouseButtonEventArgs)
 {
     CommandTextBox.Focus();
 }
Example #19
0
        public void TestConstructor()
        {
            var search = new CommandTextBox();

            Assert.AreEqual("Find...", search.PlaceHolderText);
        }