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

📄 conversationmanagerimp.cs

📁 飞信的收发使用csharp进行开发
💻 CS
📖 第 1 页 / 共 3 页
字号:
                            {
                                for (int j = list.Count - 1; j >= 0; j--)
                                {
                                    if (!list[j].EnableMultiIM)
                                    {
                                        list.Remove(list[j]);
                                    }
                                }
                            }
                            if (list.Count != 0)
                            {
                                Imps.Client.Core.Conversation conversation = null;
                                string to = null;
                                if (list.Count == 1)
                                {
                                    to = list[0].Uri.Raw;
                                    foreach (Imps.Client.Core.Conversation conversation2 in this.CurrentUser.ConversationManager.Conversations)
                                    {
                                        if (conversation2.CurrentDialog != null)
                                        {
                                            if (!conversation2.CurrentDialog.IsMulitiConversation)
                                            {
                                                if (conversation2.CurrentDialog.To == to)
                                                {
                                                    conversation = conversation2;
                                                }
                                            }
                                            else if ((conversation2.CurrentDialog.Participants.Count == 1) && (conversation2.CurrentDialog.Participants[0].Contact.Uri.Raw == to))
                                            {
                                                conversation = conversation2;
                                            }
                                            continue;
                                        }
                                        try
                                        {
                                            if (this.CurrentUser.ConversationManager.Conversations.Contains(conversation))
                                            {
                                                this.CurrentUser.ConversationManager.Conversations.Remove(conversation);
                                            }
                                            conversation = null;
                                            continue;
                                        }
                                        catch (Exception exception)
                                        {
                                            ClientLogger.WriteException(exception);
                                            continue;
                                        }
                                    }
                                }
                                ConversationWindow window = null;
                                if (list.Count == 1)
                                {
                                    foreach (ConversationWindow window2 in this.AllConversatonWindows)
                                    {
                                        if (window2.Uri == list[0].Uri.Raw)
                                        {
                                            window = window2;
                                            break;
                                        }
                                        if ((conversation != null) && (window2.CurrentConversation == conversation))
                                        {
                                            window = window2;
                                            break;
                                        }
                                    }
                                    if (window == null)
                                    {
                                        Imps.Client.Core.Contact contact2 = list[0];
                                        if (((contact2.RelationStatus != 1) || (contact2 is Imps.Client.Core.ChatFriend)) || (contact2 is Stranger))
                                        {
                                            string str2;
                                            if ((contact2.RelationStatus == 0) || (contact2.RelationStatus == 2))
                                            {
                                                str2 = "由于对方尚未同意成为您的好友,所以您不能给对方发消息,\r\n\r\n是否再次发送添加好友申请?";
                                            }
                                            else
                                            {
                                                str2 = "由于对方不是您的好友,所以您不能给对方发送消息,\r\n\r\n是否添加对方为好友?";
                                            }
                                            if (this._frameworkWnd.UnifiedMessageBox.ShowConfirmation(this._frameworkWnd as IWin32Window, str2) == DialogResult.Yes)
                                            {
                                                string mobileNo = string.IsNullOrEmpty(contact2.PersonalInfo.MobileNo) ? contact2.PersonalInfo.MobileNoUserSet : contact2.PersonalInfo.MobileNo;
                                                this._frameworkWnd.ContactManager.ShowAddBuddyWindow(this._frameworkWnd as IWin32Window, mobileNo, new long?(contact2.Uri.Sid), string.Empty, null, ContactType.ImpsContact);
                                            }
                                            return;
                                        }
                                    }
                                }
                                if (conversation == null)
                                {
                                    conversation = this.CurrentUser.ConversationManager.OpenConversation(to, list);
                                }
                                if (window == null)
                                {
                                    window = this.CreateConversationWindow(conversation);
                                    window.Show();
                                }
                                else
                                {
                                    if (window.CurrentConversation == null)
                                    {
                                        window.CurrentConversation = conversation;
                                    }
                                    Imps.Client.Utils.Win32.NativeMethods.ShowWindow(window.Handle, 9);
                                    window.Activate();
                                }
                                if (operation == ConversationOperation.SendFile)
                                {
                                    if (context == null)
                                    {
                                        window.SendFile();
                                    }
                                    else if (context is string[])
                                    {
                                        foreach (string str4 in context as string[])
                                        {
                                            window.SendFile(str4);
                                        }
                                    }
                                }
                                if ((operation == ConversationOperation.SmsChat) && (contactUris.Length == 1))
                                {
                                    window.SendSMS = true;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception exception2)
            {
                ClientLogger.WriteException(exception2);
            }
        }

        public void StartConversationAfterSelectContacts(IWin32Window owner, List<Imps.Client.Core.Contact> list)
        {
            try
            {
                InviteForm form = new InviteForm(this._frameworkWnd, StringTable.Conversation.MsgSelectConversationContacts, this.CurrentUser.Configuration.SystemSetting.SysConversationSetting.MaxParticipations - 1, true, true, list, null, false, false, false, false);
                if (owner is Form)
                {
                    form.Location = (owner as Form).Location;
                }
                if ((form.ShowDialog(owner) == DialogResult.OK) && (form.SelectedContacts.Count != 0))
                {
                    string[] contactUris = new string[form.SelectedContacts.Count];
                    for (int i = 0; i < form.SelectedContacts.Count; i++)
                    {
                        contactUris[i] = form.SelectedContacts[i].Uri.Raw;
                    }
                    this.StartConversation(owner, ConversationOperation.ImChat, null, contactUris);
                }
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
            }
        }

        public void StartMultiSMS(IWin32Window owner)
        {
            this.StartMultiSMS(owner, null);
        }

        public void StartMultiSMS(IWin32Window owner, List<Imps.Client.Core.Contact> list)
        {
            if (((this._smsForm == null) || this._smsForm.IsDisposed) || (list != null))
            {
                if (this._smsForm != null)
                {
                    this._smsForm.Close();
                }
                this._smsForm = new GroupSMSForm(this.FrameworkWnd, list);
                ControlHelper.ShowFormCenterOnParent(this._smsForm, owner);
            }
            else
            {
                Imps.Client.Utils.Win32.NativeMethods.ShowWindow(this._smsForm.Handle, 9);
                this._smsForm.Activate();
            }
        }

        public List<ConversationWindow> AllConversatonWindows
        {
            get
            {
                if (this._allConversatonWindows == null)
                {
                    this._allConversatonWindows = new List<ConversationWindow>();
                }
                return this._allConversatonWindows;
            }
            set
            {
                this._allConversatonWindows = value;
            }
        }

        internal Imps.Client.Core.User CurrentUser
        {
            get
            {
                return this._frameworkWnd.AccountManager.CurrentUser;
            }
        }

        public bool ForceToCloseWindow
        {
            get
            {
                return this._forceToCloseWindow;
            }
            set
            {
                this._forceToCloseWindow = value;
            }
        }

        internal IFrameworkWindow FrameworkWnd
        {
            get
            {
                return this._frameworkWnd;
            }
        }
    }
}

⌨️ 快捷键说明

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