Exemple #1
0
        /// <summary>
        /// 处理语音请求消息
        /// </summary>
        /// <param name="mesg"></param>
        private void ReceiveAudioMessage(Message mesg)
        {
            ///已经语音,不能再跟其他人语音
            DataUtil.FriendMessageTabItems[(mesg.from as Member).id].audioMenu.IsEnabled = false;

            AudioMessage am = mesg as AudioMessage;
            AudioForm af = new AudioForm(am, false);

            ///结束语音,enable语音按钮,能继续跟其他人语音
            af.Closed += new EventHandler((obj, args) =>
            {
                DataUtil.FriendMessageTabItems[(mesg.from as Member).id].audioMenu.IsEnabled = true;
            }
            );
            af.Show();


        }
Exemple #2
0
        void MyMenu_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {

            if (this.baseRole is Member)
            {
                Member member = this.baseRole as Member;
                if (member.status == MemberStatus.Offline)
                {
                    return;
                }

                switch(messageType)
                {
                    case MessageType.File:
                        {
                            OpenFileDialog ofd = new OpenFileDialog();
                            ofd.RestoreDirectory = true;
                            ofd.ShowDialog();

                            FileMessage fm = new FileMessage();
                            fm.from = DataUtil.Member;
                            fm.to = this.baseRole;

                            fm.Path = ofd.FileName;
                            if (!File.Exists(fm.Path))
                                return;
                            fm.FileName = ofd.SafeFileName;
                            fm.Size = ofd.OpenFile().Length;
                            fm.sendTime = DateTime.Now;
                            fm.Guid = Guid.NewGuid().ToString();


                            DataUtil.Transfer.SendFile(fm);
                            break;
                        }
                    case MessageType.Audio:
                        {

                            this.IsEnabled = false;
                            AudioMessage am = new AudioMessage();
                            am.from = DataUtil.Member;
                            am.to = this.baseRole;

                            DataUtil.Client.SendMesg(am);
                            AudioForm af = new AudioForm(am, true);
                            
                            af.Show();
                            af.Closed += new EventHandler((obj, args) =>
                                {
                                    this.IsEnabled = true;
                                });
                            break;
                        }
            }

            }
        }