private void SendFileButton_Click(object sender, EventArgs e) { SendFileForm form = new SendFileForm(ParentView.UI, 0); form.FileProcessed = new Tuple <FileProcessedHandler, object>(new FileProcessedHandler(Chat.Share_FileProcessed), Room); form.ShowDialog(); }
public void InputControl_SendFile() { SendFileForm form = new SendFileForm(UI, UserID); form.FileProcessed = new Tuple <FileProcessedHandler, object>(new FileProcessedHandler(IM.Share_FileProcessed), (object)UserID); form.ShowDialog(); }
/// <summary> /// 显示发送文件的窗口 /// </summary> /// <param name="msgFrom"></param> /// <param name="remoteIPEndPoint"></param> public void showSendFileForm(string msgFrom, IPEndPoint remoteIPEndPoint) { //获取所有的打开窗体 FormCollection collections = Application.OpenForms; foreach (Form eachForm in collections) { //找出聊天窗口 if (eachForm.GetType().Equals(typeof(ChatForm))) { ChatForm chatForm = (ChatForm)eachForm; //如果对话框已经打开 if (msgFrom == chatForm.username) { AddTipsDelegate addTipsDelegate = new AddTipsDelegate(delegate(ChatForm form, string s) { form.addTips(s); //显示发送文件的窗口 SendFileForm sendFileForm = new SendFileForm(); sendFileForm.remoteIPEndPoint = remoteIPEndPoint; sendFileForm.remoteUsername = msgFrom; sendFileForm.Show();; }); chatForm.Invoke(addTipsDelegate, chatForm, "你请求发送文件\n"); return; } } } UserList userListForm = UserList.getInstance(); showChatFormDelegate showDelegate = new showChatFormDelegate(delegate(string username, IPEndPoint remoteIP) { //对话窗没有打开 ChatForm newChatForm = new ChatForm(); //设置窗体内的具体信息 newChatForm.Text = username; newChatForm.username = username; newChatForm.remoteIPEndPoint = remoteIP; newChatForm.Show(); newChatForm.addTips("你请求发送文件"); //打开文件传输form //显示发送文件的窗口 SendFileForm sendFileForm = new SendFileForm(); sendFileForm.remoteIPEndPoint = remoteIPEndPoint; sendFileForm.remoteUsername = msgFrom; sendFileForm.Show(); }); userListForm.Invoke(showDelegate, msgFrom, remoteIPEndPoint); }