Beispiel #1
0
 void AddEmotions()
 {
     //ตัวสร้างรูปในแชท
     foreach (string emote in emotions.Keys)
     {
         while (TbChatBox.Text.Contains(emote))
         {
             int ind = TbChatBox.Text.IndexOf(emote);
             TbChatBox.Select(ind, emote.Length);
             Clipboard.SetImage((Image)emotions[emote]);
             TbChatBox.Paste();
             Clipboard.Clear();
         }
     }
 }
Beispiel #2
0
 private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
 {
     if (clientChat.Connected)
     {
         STW.WriteLine(TextToSends);
         this.TbChatBox.Invoke(new MethodInvoker(delegate()
         {
             TbChatBox.AppendText("Me:" + TextToSends + "\n");
         }));
     }
     else
     {
         MessageBox.Show("Sending failed");
     }
     backgroundWorker2.CancelAsync();
 }
Beispiel #3
0
 private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
 {
     //WerewolfModel wm = new WerewolfModel();
     while (clientChat.Connected)
     {
         try
         {
             recieve = STR.ReadLine();
             this.TbChatBox.Invoke(new MethodInvoker(delegate()
             {
                 TbChatBox.AppendText("You:" + recieve + "\n");
             }));
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message.ToString());
         }
     }
 }
Beispiel #4
0
        private void bntConnectChat_Click(object sender, EventArgs e)
        {
            clientChat = new TcpClient();
            IPEndPoint IpEnd = new IPEndPoint(IPAddress.Parse(ServerIPtextBox.Text), 1);

            try
            {
                clientChat.Connect(IpEnd);
                if (clientChat.Connected)
                {
                    TbChatBox.AppendText("Connected to server" + "\n");
                    STR           = new StreamReader(clientChat.GetStream());
                    STW           = new StreamWriter(clientChat.GetStream());
                    STW.AutoFlush = true;
                    backgroundWorker1.RunWorkerAsync();
                    backgroundWorker2.WorkerSupportsCancellation = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Beispiel #5
0
 public void AddChatMessage(string str)
 {
     TbChatBox.AppendText(str + Environment.NewLine);
 }