//********************************************************* private void msg() //Prints message to screen (called from getMessage) { string S = ChatCB.SelectedIndex + InitTB.Text + InputTB.Text; string outputText = readData.Substring(0, S.Length); string MessID = outputText.Substring(1, 3); outputText = readData.Substring(4); SoundPlayer simpleSound = new SoundPlayer(@"\\umdfs1.umdar.umassd.edu\studentshares$\pmcgrory\Desktop\FINAL SYSTEM2.0\GUI\msgRec.wav"); if (this.InvokeRequired) { this.Invoke(new MethodInvoker(msg)); } else { switch ((int)Char.GetNumericValue(readData[0])) //Choose which chat { case 0: //Chat A readData = readData.Substring(1, readData.Length - 1); ChatATB.AppendText(MessID + ": " + outputText); ChatATB.Text += "\r\n"; simpleSound.Play(); //Play sound on message break; case 1: //Chat B readData = readData.Substring(1, readData.Length - 1); ChatBTB.AppendText(MessID + ": " + outputText); ChatBTB.Text += "\r\n"; simpleSound.Play(); //Play sound on message break; case 2: //Chat C readData = readData.Substring(1, readData.Length - 1); ChatCTB.AppendText(MessID + ": " + outputText); ChatCTB.Text += "\r\n"; simpleSound.Play(); //Play sound on message break; case 3: //Chat ALL readData = readData.Substring(1, readData.Length - 1); ChatATB.AppendText(readData + Environment.NewLine); ChatBTB.AppendText(readData + Environment.NewLine); ChatCTB.AppendText(readData + Environment.NewLine); ChatATB.Text += "\r\n"; ChatBTB.Text += "\r\n"; ChatCTB.Text += "\r\n"; break; } } }
//******************************************************************************************************************** private void msg() { string S = ChatCB.SelectedIndex + InitTB.Text + InputTB.Text; string MessID = readData.Substring(1, 3); string outputText = readData.Substring(4); if (this.InvokeRequired) { this.Invoke(new MethodInvoker(msg)); } else { switch ((int)Char.GetNumericValue(readData[0])) { case 0: ChatATB.AppendText(MessID + ": " + outputText); ChatATB.Text += "\r\n"; break; case 1: ChatBTB.AppendText(MessID + ": " + outputText); ChatBTB.Text += "\r\n"; break; case 2: ChatCTB.AppendText(MessID + ": " + outputText); ChatCTB.Text += "\r\n"; break; case 3: readData = readData.Substring(1, readData.Length - 1); ChatATB.AppendText(readData + Environment.NewLine); ChatBTB.AppendText(readData + Environment.NewLine); ChatCTB.AppendText(readData + Environment.NewLine); ChatATB.Text += "\r\n"; ChatBTB.Text += "\r\n"; ChatCTB.Text += "\r\n"; break; } } }
private void ChatATB_TextChanged(object sender, EventArgs e) { ChatATB.SelectionStart = ChatATB.TextLength; ChatATB.ScrollToCaret(); }