Пример #1
1
 /// <summary>
 /// Make thread safe call to update status text box
 /// </summary>
 /// <param name="txt"></param>
 private void setOutputStatus(string txt)
 {
     if (this.textBoxOutputStatus.InvokeRequired)
     {
         setTextCallback d = new setTextCallback(setOutputStatus);
         try
         {
             this.Invoke(d, new object[] { txt });
         }
         catch { }
     }
     else
     {
         updateOutputStatus(txt);
     }
 }
Пример #2
1
 /// <summary>
 /// Sets the output status text
 /// </summary>
 /// <param name="text"></param>
 void setOutputStatusText(string text)
 {
     if (this.textBoxOutputStatus.InvokeRequired)
     {
         setTextCallback d = new setTextCallback(setOutputStatusText);
         this.Invoke(d, new object[] { text });
     }
     else
     {
         this.textBoxOutputStatus.AppendText(text);
         this.textBoxOutputStatus.Update();
     }
 }
Пример #3
0
        private void updateTextBox_grid(string text) {
            if (this.textbox_gameboard.InvokeRequired) {
                setTextCallback d = new setTextCallback(updateTextBox_grid);
                this.Invoke(d, new object[] { text });

            }
            else {
                this.textbox_gameboard.Text = gameboard.ToString();
            }
        }
Пример #4
0
 private void setText(Label b, string text)
 {
     if (Form1.defaultForm.InvokeRequired)
     {
         setTextCallback d = new setTextCallback(setText);
         Form1.defaultForm.Invoke(d, new object[] { b, text });
     }
     else
     {
         b.Text = text;
     }
 }
Пример #5
0
 void setOutputStatusText(string text)
 {
     if (Status_textBox.InvokeRequired)
     {
         setTextCallback d = new setTextCallback(setOutputStatusText);
         this.Invoke(d, new object[] { text });
     }
     else
     {
         Status_textBox.AppendText(text);
         Status_textBox.Update();
     }
 }
Пример #6
0
 private void setText(RichTextBox textBox, string text)
 {
     if (textBox.InvokeRequired)
     {
         setTextCallback d = new setTextCallback(setText);
         Invoke(d, new object[] { textBox, text });
     }
     else
     {
         textBox.Text           = text;
         textBox.SelectionStart = textBox.Text.Length - 1;
         textBox.ScrollToCaret();
         FlashWindow(this.Handle, true);
     }
 }
Пример #7
0
 private void setChatText(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.chatWindow.InvokeRequired)
     {
         setTextCallback d = new setTextCallback(setChatText);
         this.Invoke(d, new object[] { text });
     }
     else
     {
         this.chatWindow.Text = text;
     }
 }
Пример #8
0
        //ContentTextbox 에 입력텍스트를 출력하고 소켓을 통해 서버에 같은 메시지 전송
        private void textWrite(String text, Boolean printId = false, Boolean serverSend = false)
        {
            try
            {
                if (ContentTextbox.InvokeRequired)
                {
                    setTextCallback cb = new setTextCallback(textWrite);
                    Invoke(cb, new object[] { text, printId, serverSend });
                }
                else
                {
                    if (printId)
                    {
                        text = "[" + clientNickname + "] " + text;
                    }

                    if (clientStream != null && clientStream.CanWrite && serverSend)
                    {
                        byte[] sendMsg = new byte[BUFFERSIZE];
                        Encoding.UTF8.GetBytes(text).CopyTo(sendMsg, 0);

                        clientStream.Write(sendMsg, 0, sendMsg.Length);
                        clientStream.Flush();
                    }
                    else if (!serverSend)
                    {
                        //통신불안정으로 서버 브로드캐스팅을 받아오지 못하는 부분이 아닌 명시적으로 내부메세지로 사용하기 위함
                        ContentTextbox.AppendText(text + "\n");
                    }
                }
            }
            catch (SocketException)
            {
                ContentTextbox.AppendText("\n>> Socket Connection Failed Unexpectably! Please click Reconnect\n");
                SendMsgTextbox.Clear();
                CloseSocket();
                button1.Visible = true;
            }
            catch (IOException)
            {
                ContentTextbox.AppendText("\n>> Socket Connection Failed Unexpectably! Please click Reconnect\n");
                SendMsgTextbox.Clear();
                CloseSocket();
                button1.Visible = true;
            }
        }
Пример #9
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 (richTextBox1.InvokeRequired)
            {
                setTextCallback d = new setTextCallback(setText);
                this.Invoke(d, new object[] { text });
            }
            else
            {
                outputLines++;
                if (outputLines % outputLinesThresh == 0)
                {
                    richTextBox1.Text = "";
                }

                richTextBox1.AppendText(text);
                richTextBox1.ScrollToCaret();
            }
        }
Пример #10
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.txtProcessFound.InvokeRequired)
     {
         setTextCallback d = new setTextCallback(SetText);
         this.Invoke(d, new object[] { text });
     }
     else
     {
         txtProcessFound.Text = lastProcessFound;
         for (var i = 0; i < myAvailableProcesses.Count; i++)
         {
             Trace.WriteLine(myAvailableProcesses[i]);
             if (myAvailableProcesses[i] == lastProcessFound)
             {
                 cmbProcessName.SelectedIndex = i + 1;
                 break;
             }
         }
     }
 }
Пример #11
0
 /// <summary>
 /// Shows a dialog with specified message
 /// </summary>
 /// <param name="msg"></param>
 void showDialogMsg(string msg)
 {
     if (this.InvokeRequired)
     {
         setTextCallback d = new setTextCallback(showDialogMsg);
         this.Invoke(d, new object[] { msg });
     }
     else
     {
         MessageBox.Show(msg);
     }
 }
Пример #12
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 (richTextBox1.InvokeRequired)
            {
                setTextCallback d = new setTextCallback(setText);
                this.Invoke(d, new object[] { text });
            }
            else
            {
                outputLines++;
                if (outputLines % outputLinesThresh == 0)
                {
                    richTextBox1.Text = "";
                }

                richTextBox1.AppendText(text);
                richTextBox1.ScrollToCaret();
            }
        }
Пример #13
0
 private void setText(string text)
 {
     if (this.richTextBox1.InvokeRequired)
     {
         setTextCallback cb = new setTextCallback(setText);
         this.Invoke(cb, new object[] { text });
     }
     else
     {
         this.richTextBox1.Text = this.richTextBox1.Text + text;
     }
 }
Пример #14
0
        //ContentTextbox 에 입력텍스트를 출력하고 소켓을 통해 서버에 같은 메시지 전송
        private void textWrite(String text, Boolean printId = false, Boolean serverSend = false)
        {
            try
            {
                if (ContentTextbox.InvokeRequired)
                {
                    setTextCallback cb = new setTextCallback(textWrite);
                    Invoke(cb,new object[]{text, printId, serverSend});
                }
                else
                {
                    if (printId)
                        text = "[" + clientNickname + "] " + text;

                    if (clientStream != null && clientStream.CanWrite && serverSend)
                    {
                        byte[] sendMsg = new byte[BUFFERSIZE];
                        Encoding.UTF8.GetBytes(text).CopyTo(sendMsg, 0);

                        clientStream.Write(sendMsg, 0, sendMsg.Length);
                        clientStream.Flush();
                    }
                    else if (!serverSend)
                        //통신불안정으로 서버 브로드캐스팅을 받아오지 못하는 부분이 아닌 명시적으로 내부메세지로 사용하기 위함
                        ContentTextbox.AppendText(text + "\n");
                }
            }
            catch (SocketException)
            {
                ContentTextbox.AppendText("\n>> Socket Connection Failed Unexpectably! Please click Reconnect\n");
                SendMsgTextbox.Clear();
                CloseSocket();
                button1.Visible = true;
            }
            catch (IOException)
            {
                ContentTextbox.AppendText("\n>> Socket Connection Failed Unexpectably! Please click Reconnect\n");
                SendMsgTextbox.Clear();
                CloseSocket();
                button1.Visible = true;
            }
        }
 protected virtual void setTextLblStatus(string text)
 {
     if (BattleshipsForm.lblStatus.InvokeRequired)
     {
         setTextCallback d = new setTextCallback(setTextLblStatus);
         this.Invoke(d, new object[] { text });
     }
     else
     {
         BattleshipsForm.lblStatus.Text += text;
         BattleshipsForm.panelStatus.VerticalScroll.Value += BattleshipsForm.panelStatus.VerticalScroll.SmallChange;
         BattleshipsForm.panelStatus.Refresh();
     }
 }