private void SendAudioMessage() { if (File.Exists(audiofilename) && isRecord == 1) { //Sending to server byte[] bytes = Encoding.UTF8.GetBytes("audiofile"); stream.Write(bytes, 0, bytes.Length); SendAudio audio = new SendAudio(); audio.SetFile(audiofilename); audio.AudioTime = GetWavFileDuration(audiofilename).ToString(); using (FileStream fstream = new FileStream(audiofilename, FileMode.Open, FileAccess.Read)) { SendFileInfo(fstream); SendFile(fstream); } //Ending send file //Locate control on GUI audio.Left = this.Width - 230; CheckScrollBar(); audio.Top = getPosition(); audio.AddTimeLabelSender(); panel3.Controls.Add(audio); lastObject = audio; audiolist.Add(audio); //Ending add control } }
private void timer1_Tick_1(object sender, EventArgs e) { if (gettedMessage != "") { ReceiveBubble(gettedMessage); gettedMessage = ""; } if (path != "") { image = new SendImage(); image.SetImage(path); image.Left = 5; image.PhotoColor = Color.SkyBlue; image.Top = getPosition(); image.AddTimeLabelGetter(); panel3.Controls.Add(image); lastObject = image; photolist.Add(image); path = ""; CheckScrollBar(); } if (filepath != "") { file = new SendFile(); file.SetFile(filepath); file.FileName = filepath; file.FileSize = fileSizeString; file.Left = 5; file.Top = getPosition(); file.AddTimeLabelGetter(); panel3.Controls.Add(file); lastObject = file; filelist.Add(file); filepath = ""; CheckScrollBar(); } if (audiopath != "") { audio = new SendAudio(); audio.SetFile(audiopath); audio.AudioTime = (GetWavFileDuration(audiopath)).ToString(); audio.Left = 5; audio.Top = getPosition(); audio.AddTimeLabelGetter(); panel3.Controls.Add(audio); lastObject = audio; audiolist.Add(audio); audiopath = ""; CheckScrollBar(); } if (videopath != "") { wideo = new SendVideo(); wideo.SetFile(videopath); wideo.Left = 5; wideo.Top = getPosition(); wideo.AddTimeLabelGetter(); panel3.Controls.Add(wideo); lastObject = wideo; videolist.Add(wideo); videopath = ""; CheckScrollBar(); } }