⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 conversationwindow.cs

📁 飞信的收发使用csharp进行开发
💻 CS
📖 第 1 页 / 共 5 页
字号:
        {
            if (((this.tsSendEnter.Checked && (e.KeyCode == Keys.Return)) && !e.Control) || ((this.tsSendCtrlEnter.Checked && e.Control) && (e.KeyCode == Keys.Return)))
            {
                e.SuppressKeyPress = true;
                this.SendMessage();
            }
            if (e.Control)
            {
                if (e.KeyCode == Keys.V)
                {
                    if (Clipboard.ContainsFileDropList() && this.tsSendFile.Enabled)
                    {
                        object data = Clipboard.GetData(DataFormats.FileDrop);
                        if (data != null)
                        {
                            if (((this.CurrentConversation != null) && (this.CurrentConversation.CurrentDialog != null)) && ((this.CurrentConversation.CurrentDialog.ShareContents.Count + (data as string[]).Length) > 5))
                            {
                                this._manager.FrameworkWnd.UnifiedMessageBox.ShowInfo(this, string.Format(StringTable.Conversation.MsgMaxSendShareContentCount, this.CurrentUser.Configuration.SystemSetting.FileShareSetting.MaxShareContentCountOnOneDialog));
                            }
                            else
                            {
                                foreach (string str in data as string[])
                                {
                                    this.SendFile(str);
                                }
                                e.Handled = true;
                            }
                        }
                    }
                }
                else if (((e.KeyCode == Keys.E) || (e.KeyCode == Keys.R)) || (e.KeyCode == Keys.L))
                {
                    e.Handled = true;
                }
                else if (e.KeyCode == Keys.F)
                {
                    this.SendFile();
                }
                else if (e.KeyCode == Keys.H)
                {
                    this.ShowMessageHistory();
                }
            }
        }

        private int _inputChatManager_LinkClick(object sender, ChatEditClickEventArgs e)
        {
            try
            {
                if (e.EventType == ChatEditEventType.Link)
                {
                    this.ExecuteFile(e.Text);
                }
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
            return 1;
        }

        private void _op_ImpsError(object sender, ImpsErrorEventArgs e)
        {
            if (!e.Handled)
            {
                e.Handled = true;
            }
        }

        private void _smsOperation_ImpsError(object sender, ImpsErrorEventArgs e)
        {
            e.Handled = true;
            this.AppendSendMessageError((sender as AsyncBizOperation).ContextForBiz.ToString(), e.Summary);
        }

        private void AddContactEvent(Imps.Client.Core.Contact contact)
        {
            if (!this._hasEventContacts.Contains(contact))
            {
                this._hasEventContacts.Add(contact);
                contact.RelationStatusChanged += new EventHandler(this.contact_RelationStatusChanged);
                contact.PersonalInfo.PropertiesChanged += new EventHandler<PropertiesChangedEventArgs>(this.contact_PersonalInfo_PropertiesChanged);
                contact.Presence.PropertiesChanged += new EventHandler<PropertiesChangedEventArgs>(this.contact_Presence_PropertiesChanged);
                if (contact is ImpsContact)
                {
                    (contact as ImpsContact).PortraitChanged += new EventHandler(this.contact_PortraitChanged);
                }
                contact.TypeChanged += new EventHandler<ContactTypeChangedEventArgs>(this.contact_TypeChanged);
                contact.IsBlockChanged += new EventHandler<BlockEventArgs>(this.contact_IsBlockChanged);
            }
        }

        private void AddContacts(List<Imps.Client.Core.Contact> list)
        {
            if ((this.CurrentConversation != null) && (this.CurrentConversation.CurrentDialog != null))
            {
                lock (this.CurrentConversation.CurrentDialog.Participants)
                {
                    foreach (ConversationParticipant participant in this.CurrentConversation.CurrentDialog.Participants)
                    {
                        if (list.Contains(participant.Contact))
                        {
                            list.Remove(participant.Contact);
                        }
                    }
                }
            }
            if (list.Count != 0)
            {
                if ((this.CurrentConversation != null) && (this.CurrentConversation.CurrentDialog != null))
                {
                    this.CurrentConversation.CurrentDialog.AsyncInviteParticipants(list);
                }
                else
                {
                    Imps.Client.Core.Contact item = this.CurrentUser.ContactList.Contacts.FindContact(this.Uri);
                    if (item != null)
                    {
                        list.Add(item);
                    }
                    this.CurrentConversation = this.CurrentUser.ConversationManager.OpenConversation(null, list);
                }
            }
        }

        private void AddDialogEvents(Dialog dialog)
        {
            try
            {
                dialog.MessageRecieved += new EventHandler<MessageEventArgs>(this.dialog_MessageRecieved);
                dialog.SendMessageFailed += new EventHandler<MessageSendFailedEventArgs>(this.diallg_SendMessageFailed);
                dialog.Closed += new EventHandler(this.dialog_Closed);
                dialog.AddParticipant += new EventHandler<ParticipantEventArgs>(this.dialog_AddParticipant);
                dialog.RemoveParticipant += new EventHandler<ParticipantEventArgs>(this.dialog_RemoveParticipant);
                dialog.AddShareContent += new EventHandler<ShareContentEventArgs>(this.dialog_AddShareContent);
                dialog.StatusChange += new EventHandler<DialogStatusChangeEventArgs>(this.dialog_StatusChange);
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }

        private void AddGlobalEvent()
        {
            this.CurrentUser.StatusChanged += new EventHandler<UserSatusChangedEventArgs>(this.CurrentUser_StatusChanged);
            this.CurrentUser.PersonalInfo.PropertiesChanged += new EventHandler<PropertiesChangedEventArgs>(this.UserInfoPropertiesChange);
            this.CurrentUser.Presence.PropertiesChanged += new EventHandler<PropertiesChangedEventArgs>(this.UserPresencePropertiesChanged);
            this.CurrentUser.Configuration.UserSetting.ConversationSetting.PropertiesChanged += new EventHandler<PropertiesChangedEventArgs>(this.ConversationSetting_PropertiesChanged);
            this._op.ImpsError += new EventHandler<ImpsErrorEventArgs>(this._op_ImpsError);
        }

        private void AddParticipant(Imps.Client.Core.Contact contact)
        {
            if (this.CurrentConversation.CurrentDialog.Participants.Count == 1)
            {
                this.FormatContactInfo(contact);
            }
            else
            {
                this._uri = this.CurrentConversation.CurrentDialog.To;
                if (!this.HasContactAddToMultiConversation(contact))
                {
                    if (this.CurrentConversation.CurrentDialog.Participants.Count > 1)
                    {
                        this.tsInvite.Enabled = true;
                        this.tsSendFile.Enabled = true;
                        this.tsIVR.Enabled = true;
                        this.tsSendSMS.Enabled = true;
                        this.tsSendSMS.Checked = false;
                        this.tsOperationSendSMS.Radioed = false;
                        this.rtfInput.Enabled = true;
                        this.tsOperationSendMessage.Radioed = true;
                    }
                    this.lstContacts.Parent.Visible = true;
                    this.picContact.Visible = false;
                    buddylistbox_item<string> _item = new buddylistbox_item<string>(contact.DisplayName ?? "", contact.Presence.MoodPhrase ?? "", contact.PersonalInfo.Portrait, contact.Uri.Raw);
                    this.lstContacts.add(_item);
                    ToolStripMenuItem item = new ToolStripMenuItem(contact.DisplayName);
                    item.Tag = contact;
                    item.Click += delegate (object sender, EventArgs e) {
                        this.ShowMessageHistory(((sender as ToolStripMenuItem).Tag as Imps.Client.Core.Contact).Uri.Raw);
                    };
                    if (this.tsOperationMessageHistory.DropDown.Items.Count == 0)
                    {
                        this.tsOperationMessageHistory.DropDown = new menu_widget(this.components);
                    }
                    this.tsOperationMessageHistory.DropDown.Items.Add(item);
                    ToolStripMenuItem item2 = new ToolStripMenuItem(contact.DisplayName);
                    item2.Tag = contact;
                    item2.Click += delegate (object sender, EventArgs e) {
                        this.ShowMessageHistory(((sender as ToolStripMenuItem).Tag as Imps.Client.Core.Contact).Uri.Raw);
                    };
                    if (this.tsHistory.DropDown.Items.Count == 0)
                    {
                        this.tsHistory.DropDown = new menu_widget(this.components);
                    }
                    this.tsHistory.DropDown.Items.Add(item2);
                    ToolStripMenuItem item3 = new ToolStripMenuItem(contact.DisplayName);
                    item3.Tag = contact;
                    item3.Click += delegate (object sender, EventArgs e) {
                        this.ShowContactInfo(((sender as ToolStripMenuItem).Tag as Imps.Client.Core.Contact).Uri.Raw);
                    };
                    if (this.tsOperationContactInfo.DropDown.Items.Count == 0)
                    {
                        this.tsOperationContactInfo.DropDown = new menu_widget(this.components);
                    }
                    this.tsOperationContactInfo.DropDown.Items.Add(item3);
                    this.menuBlockUsers.Items.Add(this.GetBlockMenuItem(contact));
                    if (this.tsOperationBlock.DropDown.Items.Count == 0)
                    {
                        this.tsOperationBlock.DropDown = new menu_widget(this.components);
                    }
                    this.tsOperationBlock.DropDownItems.Add(this.GetBlockMenuItem(contact));
                    this.AddContactEvent(contact);
                    this.FormatTooltipInfo();
                    this.FormatFormCaptionAndText();
                    this.CalculateMultiLstHeight();
                }
            }
        }

        private void AddToFriend(string uri)
        {
            try
            {
                IicUri uri2 = new IicUri(uri);
                if (uri2.IsContact)
                {
                    Imps.Client.Core.Contact contact;
                    this.CurrentUser.ContactList.TryFindOrCreateContactAndGetContactInfo(uri, out contact, this._op, ConversationManager.ConversationNeedProperty);
                    if (contact != null)
                    {
                        long? sid = null;
                        string mobileNo = string.Empty;
                        if (uri2.Belongs(IicUriType.Sip))
                        {
                            sid = new long?(uri2.Sid);
                        }
                        else
                        {
                            mobileNo = uri2.MobileNo;
                        }
                        if (!contact.Uri.IsVodafoneUri)
                        {
                            this._frameworkWnd.ContactManager.ShowAddBuddyWindow(this, mobileNo, sid, string.Empty, null, ContactType.ImpsContact);
                        }
                        else
                        {
                            this._frameworkWnd.ContactManager.ShowAddBuddyWindow(this, mobileNo, sid, string.Empty, null, ContactType.Vodafone);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }

        private void AppendIMOrSMSMessage(Imps.Client.Core.Message msg)
        {
            msg.NewLine = this.CurrentConversation.CurrentDialog.MsgManager.IsMessageNewLine(msg);
            if (!msg.NewLine)
            {
                this._historyChatManager.SelectionIdent = this._richIdentity;
                this._historyChatManager.AppentString(msg.Content, this._messageEmotionSize);
            }
            else
            {
                this._historyChatManager.SelectionIdent = 0;
                this._historyChatManager.AppentString(string.Format(StringTable.Conversation.MsgSendIMFormat, ConvertString(msg.From)));
                try
                {
                    this._historyChatManager.SelectionStart = this._historyChatManager.Length;
                    if (this.CurrentConversation.CurrentDialog.Status != DialogStatus.Invited)
                    {
                        this._historyChatManager.AppendRichTextPlainString(msg.MsgTime);
                    }
                    else
                    {
                        this._historyChatManager.AppendRichTextPlainString(string.Format("({0}):", DateTime.Now.ToString("HH:mm")));
                    }
                }
                catch (Exception exception)
                {
                    this.HandleException(exception);
                }
                this._historyChatManager.AppendCRLF();
                this._historyChatManager.SelectionIdent = this._richIdentity;
                this._historyChatManager.AppentString(msg.Content, this._messageEmotionSize);
            }
        }

        private void AppendMessage(Imps.Client.Core.Message msg)
        {
            if (!this.rtfHistory.IsDisposed)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -