/// /// 鼠标单击 /// private void notifyIcon_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { if (GetMsgList.Count != 0) { TalkWindow talkwindow = new TalkWindow(GetMsgList[0].user, MyFont, this); for (int i = GetMsgList.Count-1; i >= 0; i--) { if (GetMsgList[i].user.ip == GetMsgList[0].user.ip) { if (GetMsgList[i].ID == MessageID.UserSendFile) { talkwindow.AddRecvFile(GetMsgList[i].file, GetMsgList[i].filesize); } else { talkwindow.ShowMessage(GetMsgList[i].content, GetMsgList[i].font); } GetMsgList.RemoveAt(i); } } talklist.Add(talkwindow); talkwindow.Show(); talkwindow.Activate(); //请求获得共享文件 GetSharedFiles(talkwindow.TalkUser.ip); } else if (this.Visibility == Visibility.Visible) { this.Visibility = Visibility.Visible; this.Activate(); if (this.Top == TOPPOINT) { this.ShowWindow(); this.Top = 1; } else if (this.Top == 1) { this.Top = 0; } } else if(miniwindow != null) { miniwindow.WindowState = System.Windows.WindowState.Normal; miniwindow.Visibility = Visibility.Visible; miniwindow.Activate(); } } }
//打开文件窗口 private void CreateTalkWindiwToFile(Object msg) { Message ReadMessage = (Message)msg; int i = 0; TalkWindow talkwindow = new TalkWindow(ReadMessage.user, MyFont, this); talklist.Add(talkwindow); if (GetMsgList.Count != 0) { for (i = 0; i < GetMsgList.Count; i++) { if (GetMsgList[i].user.ip == GetMsgList[0].user.ip) { talkwindow.ShowMessage(GetMsgList[i].content, GetMsgList[i].font); GetMsgList.RemoveAt(i); i--; } } } notifyIcon.BalloonTipText = ReadMessage.user.name + "发来文件"; notifyIcon.ShowBalloonTip(1000); talkwindow.AddRecvFile(ReadMessage.file, ReadMessage.filesize); talkwindow.Show(); talkwindow.Activate(); System.Windows.Threading.Dispatcher.Run(); }
private void ListDoubleClick(object sender, MouseEventArgs e) { ListBox user = (ListBox)sender; int index = user.SelectedIndex; int i = 0; if (index < user.Items.Count && index != -1) { for (i = 0; i < talklist.Count; i++) { if (talklist[i].Title == userlist[index].ip) { break; } } if (i == talklist.Count) { TalkWindow talkwindow = new TalkWindow(userlist[index],MyFont,this); talklist.Add(talkwindow); if (GetMsgList.Count != 0) { for (i = GetMsgList.Count-1; i >= 0; i--) { if (GetMsgList[i].user.ip == GetMsgList[0].user.ip) { if (GetMsgList[i].ID == MessageID.UserSendFile) { talkwindow.AddRecvFile(GetMsgList[i].file, GetMsgList[i].filesize); } else { talkwindow.ShowMessage(GetMsgList[i].content, GetMsgList[i].font); } GetMsgList.RemoveAt(i); } } } talkwindow.Show(); talkwindow.Activate(); //请求获得共享文件 GetSharedFiles(userlist[index].ip); } else { if (talklist[i].WindowState == WindowState.Minimized) { talklist[i].WindowState = WindowState.Normal; } talklist[i].Activate(); } } }
private void mouseleftup(object sender, MouseButtonEventArgs e) { if (IsWindowMove == false) { if (parent.GetMsgList.Count != 0) { TalkWindow talkwindow = new TalkWindow(parent.GetMsgList[0].user, parent.MyFont, parent); for (int i = parent.GetMsgList.Count-1; i >= 0 ; i--) { if (parent.GetMsgList[i].user.ip == parent.GetMsgList[0].user.ip) { if (parent.GetMsgList[i].ID == MessageID.UserSendFile) { talkwindow.AddRecvFile(parent.GetMsgList[i].file, parent.GetMsgList[i].filesize); } else { talkwindow.ShowMessage(parent.GetMsgList[i].content, parent.GetMsgList[i].font); } parent.GetMsgList.RemoveAt(i); } } parent.talklist.Add(talkwindow); talkwindow.Show(); } else if (userwindow.IsVisible == false) { if ((this.Left + 70 + 600) <= clientWidth) { userwindow.Left = this.Left + 70; } else { userwindow.Left = this.Left - 580; } if ((this.Top + 400) <= clientHeight) { userwindow.Top = this.Top; } else { userwindow.Top = this.Top - 340; } userwindow.Show(); userwindow.Activate(); } else { userwindow.Hide(); } } else { IsWindowMove = false; } }