Esempio n. 1
0
 private void ShowText(TextBox textBox, string text)
 {
     if (textBox.InvokeRequired)
     {
         SetTextCallback1 callback = new SetTextCallback1(ShowText);
         Invoke(callback, new object[] { textBox, text });
     }
     else
     {
         textBox.Text = text;
     }
 }
Esempio n. 2
0
 private void SetText(string text)
 {
     text = Accessory.FilterZeroChar(text);
     // InvokeRequired required compares the thread ID of the
     // calling thread to the thread ID of the creating thread.
     // If these threads are different, it returns true.
     //if (this.textBox_terminal1.InvokeRequired)
     if (textBox_terminal1.InvokeRequired)
     {
         var d = new SetTextCallback1(SetText);
         BeginInvoke(d, text);
     }
     else
     {
         textBox_terminal1.SelectionStart = textBox_terminal1.TextLength;
         textBox_terminal1.SelectedText   = text;
     }
 }
Esempio n. 3
0
        private void SetText(string text)
        {
            // InvokeRequired required compares the thread ID of the
            // calling thread to the thread ID of the creating thread.
            // If these threads are different, it returns true.
            //if (this.textBox_terminal1.InvokeRequired)
            if (textBox_terminal.InvokeRequired)
            {
                SetTextCallback1 d = new SetTextCallback1(SetText);
                BeginInvoke(d, new object[] { text });
            }
            else
            {
                StringBuilder terminal = new StringBuilder();
                terminal.Append(textBox_terminal.Text);
                terminal.Append(text);
                int pos = textBox_terminal.SelectionStart;
                int l   = terminal.Length - LogBufferLimit;
                if (l < 0)
                {
                    l = 0;
                }
                textBox_terminal.Text = terminal.ToString().Substring(l);

                if (checkBox_autoScroll.Checked)
                {
                    textBox_terminal.SelectionStart = textBox_terminal.Text.Length;
                    textBox_terminal.ScrollToCaret();
                }
                else
                {
                    pos = pos - text.Length;
                    if (pos < 0)
                    {
                        pos = 0;
                    }
                    textBox_terminal.SelectionStart = pos;
                    textBox_terminal.ScrollToCaret();
                }
            }
        }
Esempio n. 4
0
        private void SetText(string text)
        {
            text = Accessory.FilterZeroChar(text);
            // InvokeRequired required compares the thread ID of the
            // calling thread to the thread ID of the creating thread.
            // If these threads are different, it returns true.
            //if (this.textBox_terminal1.InvokeRequired)
            if (textBox_terminal.InvokeRequired)
            {
                var d = new SetTextCallback1(SetText);
                BeginInvoke(d, text);
            }
            else
            {
                var pos = textBox_terminal.SelectionStart;
                textBox_terminal.AppendText(text);
                if (textBox_terminal.Lines.Length > _logLinesLimit)
                {
                    var tmp = new StringBuilder();
                    for (var i = textBox_terminal.Lines.Length - _logLinesLimit; i < textBox_terminal.Lines.Length; i++)
                    {
                        tmp.Append(textBox_terminal.Lines[i]);
                        tmp.Append("\r\n");
                    }

                    textBox_terminal.Text = tmp.ToString();
                }

                if (checkBox_autoscroll.Checked)
                {
                    textBox_terminal.SelectionStart = textBox_terminal.Text.Length;
                    textBox_terminal.ScrollToCaret();
                }
                else
                {
                    textBox_terminal.SelectionStart = pos;
                    textBox_terminal.ScrollToCaret();
                }
            }
        }
Esempio n. 5
0
 private void receptionEventHandler(object sender, receptionEventArgs e)
 {
     if (this.richTextBox1.InvokeRequired)
     {
         SetTextCallback1 b = new SetTextCallback1(receptionEventHandler);
         this.Invoke(b, this, e);
     }
     else
     {
         richTextBox1.AppendText(e.IDsender);
         richTextBox1.AppendText(" : ");
         richTextBox1.AppendText(e.Message);
         richTextBox1.AppendText("\n");
     }
 }
Esempio n. 6
0
 private void SetText(string text)
 {
     // InvokeRequired required compares the thread ID of the
     // calling thread to the thread ID of the creating thread.
     // If these threads are different, it returns true.
     if (this.textBox_terminal.InvokeRequired)
     {
         SetTextCallback1 d = new SetTextCallback1(SetText);
         this.BeginInvoke(d, new object[] { text });
     }
     else
     {
         this.textBox_terminal.Text += text;
     }
 }