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

📄 personalgroupmanager.cs

📁 破解的飞信源代码
💻 CS
📖 第 1 页 / 共 4 页
字号:
namespace Imps.Client.Pc
{
    using Imps.Client;
    using Imps.Client.Core;
    using Imps.Client.Pc.BizControls;
    using Imps.Client.Pc.BizControls.NotifyWindows;
    using Imps.Client.Pc.BizControls.NotifyWindows.Templates;
    using Imps.Client.Pc.Controls;
    using Imps.Client.Utils;
    using Imps.Client.Utils.Win32;
    using Imps.Common;
    using System;
    using System.Collections.Generic;
    using System.Windows.Forms;

    public class PersonalGroupManager : IPersonalGroupManager
    {
        private List<GroupConversationForm> _convForms;
        private Form _createGroupForm;
        private IFrameworkWindow _framework;
        private Dictionary<PersonalGroup, Form> _groupSettingForms;
        private Dictionary<PersonalGroup, Form> _inviteFriendsForms;
        private Control _personalGroupEntryListControl;
        private Form _serchGroupForm;
        private BGroupListControlToolbar _toolbar;

        public PersonalGroupManager(IFrameworkWindow framework)
        {
            this._framework = framework;
            this.InitImCoreEvent();
            this.CurrentUser.ConversationManager.FindConversationForm += new EventHandler<FindConversationFormEventArgs>(this, (IntPtr) this.ConversationManager_FindConversationWindow);
        }

        public void AddGroupMemberToFriend(IWin32Window ower, PersonalGroupMember member)
        {
            try
            {
                string uriString = member.Uri.Raw;
                IicUri uri = new IicUri(uriString);
                if (uri.IsContact)
                {
                    Contact contact = this.CurrentUser.ContactList.FindOrCreateContact(uriString, new AsyncBizOperation());
                    if (contact != null)
                    {
                        long? sid = null;
                        string mobileNo = string.Empty;
                        if (uri.Belongs(IicUriType.Sip))
                        {
                            sid = new long?(uri.Sid);
                        }
                        else
                        {
                            mobileNo = uri.MobileNo;
                        }
                        if (!contact.Uri.IsVodafoneUri)
                        {
                            this._framework.ContactManager.ShowAddBuddyWindow(ower, mobileNo, sid, string.Empty, null, ContactType.ImpsContact);
                        }
                        else
                        {
                            this._framework.ContactManager.ShowAddBuddyWindow(ower, mobileNo, sid, string.Empty, null, ContactType.Vodafone);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
            }
        }

        public void CancelGroupManager(IWin32Window owner, PersonalGroupMember member)
        {
            EventHandler<ImpsErrorEventArgs> handler = null;
            try
            {
                if (this._framework.UnifiedMessageBox.ShowConfirmation(owner, string.Format("确认取消{0}的管理员身份吗?", member.DisplayName)) == DialogResult.Yes)
                {
                    member.GroupMemeberInfo.GroupUserIdentity.ProposedValue = UserIdentity.Member;
                    AsyncBizOperation op = new AsyncBizOperation(owner);
                    if (handler == null)
                    {
                        handler = new EventHandler<ImpsErrorEventArgs>(this, (IntPtr) this.<CancelGroupManager>b__6);
                    }
                    op.ImpsError += handler;
                    this.CurrentUser.PersonalGroupManager.AsyncSetMemberPermission(member, op);
                }
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
            }
        }

        private void ConversationManager_FindConversationWindow(object sender, FindConversationFormEventArgs e)
        {
            try
            {
                if (e.Conversation.Dialogs.Count > 0)
                {
                    IicUri uri = new IicUri(e.Conversation.Dialogs[0].To);
                    if (uri.Type != IicUriType.PersonalGroup)
                    {
                        return;
                    }
                }
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
            }
            try
            {
                PersonalGroup group = this.CurrentUser.PersonalGroups[e.Conversation.Dialogs[0].To];
                if (group != null)
                {
                    lock (this.ConvForms)
                    {
                        List<GroupConversationForm>.Enumerator enumerator = this.ConvForms.GetEnumerator();
                        try
                        {
                            while (enumerator.MoveNext())
                            {
                                if (enumerator.get_Current().Group == group)
                                {
                                    return;
                                }
                            }
                        }
                        finally
                        {
                            enumerator.Dispose();
                        }
                    }
                    GroupConversationForm form2 = this.CreateConversationForm(group, ConversationOperation.ImChat);
                    if (BossKey.Hidden)
                    {
                        form2.ShowInTaskbar = false;
                        form2.Show();
                        form2.Visible = false;
                    }
                    else
                    {
                        form2.WindowState = FormWindowState.Minimized;
                        form2.Show();
                    }
                }
            }
            catch (Exception exception2)
            {
                ClientLogger.WriteException(exception2);
            }
            finally
            {
                e.AutoEvent.Set();
            }
        }

        private GroupConversationForm CreateConversationForm(PersonalGroup group, ConversationOperation operation)
        {
            List<GroupConversationForm>.Enumerator enumerator = this.ConvForms.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    GroupConversationForm form = enumerator.get_Current();
                    if (form.Group == group)
                    {
                        return form;
                    }
                }
            }
            finally
            {
                enumerator.Dispose();
            }
            if ((group.GroupConversation == null) || (group.GroupConversation.CurrentDialog == null))
            {
                this.CurrentUser.PersonalGroupManager.AsyncStartGroupConversation(group);
            }
            GroupConversationForm form2 = new GroupConversationForm(this._framework, group, operation);
            form2.LoadWindowSetting();
            form2.add_FormClosed(new FormClosedEventHandler(this, (IntPtr) this.form_FormClosed));
            form2.Activated += new EventHandler(this.form_Activated);
            form2.Deactivate += new EventHandler(this.form_Deactivate);
            this.ConvForms.Add(form2);
            return form2;
        }

        public void CreatePersonalGroup(IWin32Window owner)
        {
            EventHandler handler = null;
            try
            {
                if (this.CurrentUser.PersonalGroups.CountSuperManager >= this.CurrentUser.Configuration.SystemSetting.GroupMsgSetting.MaxSuperadminCount)
                {
                    this._framework.UnifiedMessageBox.ShowError(string.Format("您目前已经是{0}个群的超级管理员,无法再继续创建群。", this.CurrentUser.PersonalGroups.CountSuperManager));
                }
                else if ((this._createGroupForm == null) || this._createGroupForm.IsDisposed)
                {
                    this._createGroupForm = new Imps.Client.Pc.CreatePersonalGroup(this._framework);
                    ControlHelper.ShowFormCenterOnParent(this._createGroupForm, owner);
                    if (handler == null)
                    {
                        handler = delegate {
                            this._createGroupForm = null;
                        };
                    }
                    this._createGroupForm.Disposed += handler;
                }
                else
                {
                    Imps.Client.Utils.Win32.NativeMethods.ShowWindow(this._createGroupForm.Handle, 9);
                    this._createGroupForm.Activate();
                }
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
            }
        }

        public void DeleteGroup(PersonalGroup group)
        {
            EventHandler<ImpsErrorEventArgs> handler = null;
            EventHandler handler2 = null;
            try
            {
                if (this._framework.UnifiedMessageBox.ShowConfirmation(string.Format("您确认要删除群{0}({1})吗?", group.GroupInfo.Name, group.GroupInfo.Id)) == DialogResult.Yes)
                {
                    DeleteGroupConfirmForm form = new DeleteGroupConfirmForm();
                    if (ControlHelper.ShowDialogCenterOnParent(form, this._framework.MainWindow, true) == DialogResult.Yes)
                    {
                        AsyncBizOperation op = new AsyncBizOperation(group);
                        if (handler == null)
                        {
                            handler = new EventHandler<ImpsErrorEventArgs>(this, (IntPtr) this.<DeleteGroup>b__c);
                        }
                        op.ImpsError += handler;
                        if (handler2 == null)
                        {
                            handler2 = delegate (object sender, EventArgs e) {
                                AsyncBizOperation operation = sender as AsyncBizOperation;
                                this._framework.UnifiedMessageBox.ShowInfo(this._framework.MainWindow, string.Format("群{0}({1})已经成功删除!", (operation.ContextForUi as PersonalGroup).GroupInfo.Name, (operation.ContextForUi as PersonalGroup).GroupInfo.Id));
                            };
                        }
                        op.Successed += handler2;
                        this.CurrentUser.PersonalGroupManager.AsyncDeletePersonalGroup(group, op);
                    }
                }
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
            }
        }

        public void DeleteGroupMember(IWin32Window owner, PersonalGroupMember member)
        {
            EventHandler<ImpsErrorEventArgs> handler = null;
            try
            {
                if (member.Uri.Raw == this.CurrentUser.Uri.Raw)
                {
                    this._framework.UnifiedMessageBox.ShowError("您不能删除自己!");
                }
                else if (this._framework.UnifiedMessageBox.ShowConfirmation(owner, string.Format("确认要删除{0}吗?", member.DisplayName)) == DialogResult.Yes)

⌨️ 快捷键说明

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