Exemplo n.º 1
0
        private void History_DoubleClick(object sender, EventArgs e)
        {
            TBOrder.Text = History.Items[History.SelectedIndex].ToString();

            string order = TBOrder.Text;

            HistoryIndex = 0;
            string CompleteOrder = order;

            if (RBSlashr.Checked)
            {
                CompleteOrder = order + "\r";
            }
            if (RBSlashn.Checked)
            {
                CompleteOrder = order + "\n";
            }

            TBOutput.Text = TBOutput.Text + order + "\n" + ">>> ";
            ScrollToEnd();
            TBOrder.Text = "";

            try
            {
                Form1.Port.DiscardOutBuffer(); //Clear Buffer
                Form1.Port.DiscardInBuffer();  //Clear Buffer
                Form1.Port.Write(CompleteOrder);
                Thread.Sleep(100);
            }
            catch { }
            TotalTime = 0;
            TimerReceiver.Start();
        }
Exemplo n.º 2
0
        private void TBOrder_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode != Keys.Enter && e.KeyCode != Keys.Up && e.KeyCode != Keys.Down)
            {
                return;
            }
            if (e.KeyCode != Keys.Enter)
            {
                if (e.KeyCode == Keys.Up)
                {
                    HistoryIndex++;
                }
                else
                {
                    HistoryIndex--;
                }
                if (HistoryIndex >= History.Items.Count)
                {
                    HistoryIndex = History.Items.Count - 1;
                }
                if (HistoryIndex < 0)
                {
                    HistoryIndex = 0;
                }
                TBOrder.Text = History.Items[HistoryIndex].ToString();
                return;
            }

            string order = TBOrder.Text;

            if (order != "")
            {
                History.Items.Insert(1, order);
            }
            HistoryIndex = 0;
            string CompleteOrder = order;

            if (RBSlashr.Checked)
            {
                CompleteOrder = order + "\r";
            }
            if (RBSlashn.Checked)
            {
                CompleteOrder = order + "\n";
            }

            TBOutput.Text = TBOutput.Text + order + "\n" + ">>> ";
            ScrollToEnd();
            TBOrder.Text = "";

            try
            {
                Form1.Port.DiscardOutBuffer(); //Clear Buffer
                Form1.Port.DiscardInBuffer();  //Clear Buffer
                Form1.Port.Write(CompleteOrder);
                Thread.Sleep(100);
            }
            catch { }
            TotalTime = 0;
            TimerReceiver.Start();
        }