Exemple #1
0
        ///
        /// 鼠标单击
        ///

        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();
                }

            }
        }
Exemple #2
0
        private void DownloadSharedFileClick(object sender, RoutedEventArgs e)
        {
            int index = Down_list.SelectedIndex;

            int i = 0;
            if (index != -1)
            {
                for (i = 0; i < talklist.Count; i++)
                {
                    if (talklist[i].Title == AllFiles[index].ip)
                    {
                        break;
                    }
                }
                if (i == talklist.Count)
                {
                    for (i = 0; i < userlist.Count; i++)
                    {
                        if (userlist[i].ip == AllFiles[index].ip)
                        {
                            break;
                        }
                    }
                    if (i != userlist.Count)
                    {
                        TalkWindow talkwindow = new TalkWindow(userlist[i], MyFont, this);
                        talklist.Add(talkwindow);
                        talkwindow.Show();
                        talkwindow.Activate();
                        //请求获得共享文件
                        GetSharedFiles(AllFiles[index].ip);
                        //开始下载文件
                        talkwindow.DownloadFile(AllFiles[index]);
                    }
                    else
                    {
                        MessageBox.Show("拥有该资源的用户已不在!", "错误");
                        UpdateDownClick(sender, e);
                    }
                }
                else
                {
                    if (talklist[i].WindowState == WindowState.Minimized)
                    {
                        talklist[i].WindowState = WindowState.Normal;
                    }
                    talklist[i].Activate();
                    //开始下载文件
                    talklist[i].DownloadFile(AllFiles[index]);
                }
            }
        }
Exemple #3
0
        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();
                }
            }
        }
Exemple #4
0
        //打开文件窗口
        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();
        }