www.pudn.com > Fetion.rar > ContactManager.cs


namespace Imps.Client.Pc 
{ 
    using Imps.Client; 
    using Imps.Client.Core; 
    using Imps.Client.Pc.BizControls; 
    using Imps.Client.Pc.Controls; 
    using Imps.Client.Pc.Options; 
    using Imps.Client.Pc.UIContactList; 
    using Imps.Client.Pc.UIContactList.AddBuddy; 
    using Imps.Client.Resource; 
    using Imps.Client.Utils; 
    using Imps.Common; 
    using System; 
    using System.Collections.Generic; 
    using System.Runtime.InteropServices; 
    using System.Windows.Forms; 
 
    public class ContactManager : IContactManager 
    { 
        private Imps.Client.Pc.UIContactList.ContactListControl _contactListControl; 
        private IFrameworkWindow _frameworkWnd; 
        private InviteIICForm _inviteIICFForm; 
        private ToolStripMenuItem _menuItem; 
        private ToolStripItem[] _menuItemsOperation; 
        private ToolStripMenuItem _miAddContact; 
        private ToolStripMenuItem _miAddGroup; 
        private ToolStripMenuItem _miBlackList; 
        private ToolStripMenuItem _miBlockBuddy; 
        private ToolStripMenuItem _miExport; 
        private ToolStripMenuItem _miImport; 
        private ToolStripMenuItem _miInviteIIC; 
        private ToolStripMenuItem _miSort; 
        private Dictionary _profileForms; 
        private Dictionary _profileFormsVodafone; 
        private SendRequestForm _sendRequestForm; 
        private ToolStripItem _tiMobilemail; 
        private BListControlToolbar _toolbar; 
        private Imps.Client.Core.User _user; 
 
        public ContactManager(IFrameworkWindow framework) 
        { 
            this._frameworkWnd = framework; 
            this._user = this._frameworkWnd.AccountManager.CurrentUser; 
            this.buildMenuItem(); 
        } 
 
        private void _menuItem_DropDownOpening(object sender, EventArgs e) 
        { 
            try 
            { 
                if ((this._miSort.DropDown == null) || (this._miSort.DropDown.Items.Count == 0)) 
                { 
                    this._miSort.DropDown = ((Imps.Client.Pc.UIContactList.ContactListControl) this.ContactListControl).DisplayMenu; 
                } 
                bool flag = this._user.Status == UserAccountStatus.Logon; 
                this._miAddContact.Enabled = flag; 
                this._miInviteIIC.Enabled = flag; 
                this._miAddGroup.Enabled = (flag && (this._contactListControl != null)) && (this._contactListControl.CurrentTreeGroupByType == ContactTreeGroupByType.Group); 
                this._miSort.Enabled = flag; 
                this._miImport.Enabled = flag; 
                this._miExport.Enabled = true; 
                this._miBlockBuddy.Enabled = flag; 
                this._miBlackList.Enabled = flag; 
            } 
            catch (Exception exception) 
            { 
                this._frameworkWnd.UnifiedMessageBox.ShowException(exception); 
            } 
        } 
 
        private void _miBlackList_Click(object sender, EventArgs e) 
        { 
            UiErrorHelper.HandEventSafely(this._frameworkWnd, delegate { 
                this._frameworkWnd.ShowOptions("PsBlackList"); 
            }); 
        } 
 
        private void _miBlockBuddy_Click(object sender, EventArgs e) 
        { 
        } 
 
        public void AddBuddyByMobileNo(string mobileNo, string domain, int? targetGroupId, string localName, string desc, bool sendRequestAgain, bool copyWhenExist, bool? invite, AsyncBizOperation op) 
        { 
            Imps.Client.Core.ContactList.AddBuddyExtraData extraData = new Imps.Client.Core.ContactList.AddBuddyExtraData(); 
            extraData.WhoAmI = desc; 
            this._user.ContactList.AsyncAddBuddy(true, mobileNo, domain, targetGroupId, localName, extraData, sendRequestAgain, copyWhenExist, invite, op); 
        } 
 
        public void AddBuddyBySid(long sid, string domain, int? targetGroupId, string localName, string desc, bool sendRequestAgain, bool copyWhenExist, AsyncBizOperation op) 
        { 
            Imps.Client.Core.ContactList.AddBuddyExtraData extraData = new Imps.Client.Core.ContactList.AddBuddyExtraData(); 
            extraData.WhoAmI = desc; 
            this._user.ContactList.AsyncAddBuddy(false, sid.ToString(), domain, targetGroupId, localName, extraData, sendRequestAgain, copyWhenExist, null, op); 
        } 
 
        public void AddBuddyByUri(string uri, int? targetGroupId, string localName, string desc, bool sendRequestAgain, bool copyWhenExist, bool? invite, AsyncBizOperation op) 
        { 
            IicUri uri2 = new IicUri(uri); 
            if (uri2.Belongs(IicUriType.Tel)) 
            { 
                this.AddBuddyByMobileNo(uri2.MobileNo, uri2.Domain, targetGroupId, localName, desc, sendRequestAgain, copyWhenExist, invite, op); 
            } 
            else if (uri2.Belongs(IicUriType.Sip)) 
            { 
                this.AddBuddyBySid(uri2.Sid, uri2.Domain, targetGroupId, localName, desc, sendRequestAgain, copyWhenExist, op); 
            } 
        } 
 
        public void AddToBlackList(IicUri uri, AsyncBizOperation op) 
        { 
            if (uri.IsValid) 
            { 
                this._user.ContactList.AsyncAddToBlackList(uri, op); 
            } 
        } 
 
        private void buildMenuItem() 
        { 
            this._menuItem = new ToolStripMenuItem(StringTable.MI_ContactList); 
            this._miSort = new ToolStripMenuItem(StringTable.MI_CL_Sort); 
            this._miAddContact = new ToolStripMenuItem(StringTable.MI_CL_AddContact, ImpsIcons.AddBuddy, new EventHandler(this.miAddContact_Click)); 
            this._miAddGroup = new ToolStripMenuItem(StringTable.MI_CL_AddGroup, null, new EventHandler(this.miAddGroup_Click)); 
            this._miImport = new ToolStripMenuItem(StringTable.MI_CL_Import, ImpsResources.GetImage("Images.Import.png"), new EventHandler(this.miImport_Click)); 
            this._miExport = new ToolStripMenuItem(StringTable.MI_CL_Export, ImpsResources.GetImage("Images.Export.png"), new EventHandler(this.miExport_Click)); 
            this._miInviteIIC = new ToolStripMenuItem(StringTable.MI_CL_InviteIIC, null, new EventHandler(this.miInviteIIC_Click)); 
            this._miBlockBuddy = new ToolStripMenuItem("加入黑名单(&B)...", ImpsPresenceIcons.Instance.BlockIcon, new EventHandler(this._miBlockBuddy_Click)); 
            this._miBlackList = new ToolStripMenuItem("黑名单管理(&L)...", null, new EventHandler(this._miBlackList_Click)); 
            this._menuItem.DropDown = new menu_widget(this._frameworkWnd.ComponentContainer); 
            this._menuItem.DropDownOpening += new EventHandler(this._menuItem_DropDownOpening); 
            ToolStripSeparator separator = new ToolStripSeparator(); 
            separator.Enabled = false; 
            ToolStripSeparator separator2 = new ToolStripSeparator(); 
            separator2.Enabled = false; 
            this._menuItem.DropDown.Items.AddRange(new ToolStripItem[] { this._miAddContact, this._miInviteIIC, this._miAddGroup, this._miBlackList, separator, this._miSort, separator2, this._miImport, this._miExport }); 
        } 
 
        private void BuildOperationMenuItems() 
        { 
            bool matchingEnabled = this._frameworkWnd.AccountManager.CurrentUser.Configuration.SystemSetting.ServerUriSetting.MatchingEnabled; 
            List list = new List(); 
            ToolStripItem item = new ToolStripMenuItem(StringTable.MI_IM_Contacts, ImpsResources.GetImage("Images.Chat.png"), new EventHandler(this.mi_Conversion_Click)); 
            list.Add(item); 
            item = new ToolStripMenuItem(StringTable.MI_SMS_Contacts, ImpsResources.GetImage("Images.Sms.png"), new EventHandler(this.mi_Sms_Click)); 
            list.Add(item); 
            item = new ToolStripMenuItem(StringTable.MI_Ivr_Contacts, ImpsResources.GetImage("Images.Ivr.png"), new EventHandler(this.mi_Ivr_Click)); 
            list.Add(item); 
            item = new ToolStripMenuItem(StringTable.MI_File_Contacts, ImpsResources.GetImage("Images.FileShare.png"), new EventHandler(this.mi_File_Click)); 
            list.Add(item); 
            ToolStripSeparator separator = new ToolStripSeparator(); 
            separator.Enabled = false; 
            list.Add(separator); 
            item = new ToolStripMenuItem(StringTable.MI_Group_Create, null, delegate { 
                this._frameworkWnd.PersonalGroupManager.CreatePersonalGroup(this._frameworkWnd.MainWindow); 
            }); 
            list.Add(item); 
            item = new ToolStripMenuItem(StringTable.MI_Group_Search, null, delegate { 
                this._frameworkWnd.PersonalGroupManager.SearchGroup(this._frameworkWnd.MainWindow); 
            }); 
            list.Add(item); 
            ToolStripSeparator separator2 = new ToolStripSeparator(); 
            separator2.Enabled = false; 
            list.Add(separator2); 
            item = new ToolStripMenuItem(StringTable.MI_SendSmsToMe, null, new EventHandler(this.mi_SendSmsToMe_Click)); 
            list.Add(item); 
            item = new ToolStripMenuItem(StringTable.MI_SendFileToMe, null, new EventHandler(this.mi_SendFileToMe_Click)); 
            list.Add(item); 
            this._tiMobilemail = new ToolStripMenuItem("手机邮箱(&M)...", ImpsIcons.Mail, new EventHandler(this.mi_MobileMail_Click)); 
            list.Add(this._tiMobilemail); 
            if (matchingEnabled) 
            { 
                ToolStripSeparator separator3 = new ToolStripSeparator(); 
                separator3.Enabled = false; 
                list.Add(separator3); 
                item = new ToolStripMenuItem(StringTable.MI_Match_R, null, new EventHandler(this.mi_RMatch_Click)); 
                list.Add(item); 
                item = new ToolStripMenuItem(StringTable.MI_Match_C, null, new EventHandler(this.mi_CMatch_Click)); 
                list.Add(item); 
            } 
            this._menuItemsOperation = list.ToArray(); 
        } 
 
        public void ExportContacts() 
        { 
        } 
 
        private InviteIICForm GetInnerInviteIICFForm(string mobileNo) 
        { 
            EventHandler handler = null; 
            if ((this._inviteIICFForm == null) || this._inviteIICFForm.IsDisposed) 
            { 
                this._inviteIICFForm = new InviteIICForm(this._frameworkWnd, mobileNo); 
                if (handler == null) 
                { 
                    handler = delegate { 
                        this._inviteIICFForm = null; 
                    }; 
                } 
                this._inviteIICFForm.Disposed += handler; 
            } 
            else 
            { 
                this._inviteIICFForm.MobileNo = mobileNo; 
            } 
            return this._inviteIICFForm; 
        } 
 
        public void ImportContacts() 
        { 
        } 
 
        void IContactManager.OnOperationMenuItemsOpening(ToolStripMenuItem operationMenuItem) 
        { 
            bool flag = this._user.Status == UserAccountStatus.Logon; 
            foreach (ToolStripItem item in this._menuItemsOperation) 
            { 
                if (item is ToolStripSeparator) 
                { 
                    item.Enabled = false; 
                } 
                else 
                { 
                    item.Enabled = flag; 
                } 
            } 
            if (FuncLimitedSetting.MobileEmailFuncLimited) 
            { 
                this._tiMobilemail.Visible = false; 
            } 
            else 
            { 
                this._tiMobilemail.Visible = true; 
                this._tiMobilemail.Enabled = this._user.MobileMailInfo.IsInRunningProvince.HasValue; 
            } 
        } 
 
        private void mi_CMatch_Click(object sender, EventArgs e) 
        { 
            this._frameworkWnd.ContactManager.ShowConditionalMatchWindow(); 
        } 
 
        private void mi_Conversion_Click(object sender, EventArgs e) 
        { 
            try 
            { 
                this._frameworkWnd.ConversationManager.StartConversation(this._frameworkWnd.MainWindow, ConversationOperation.ImChat, null); 
            } 
            catch 
            { 
            } 
        } 
 
        public void mi_Feike_Click(object sender, EventArgs e) 
        { 
            FunctionHelper.StartFunc(WebFunction.NavigateToFeike, string.Format("SID={0}", this._frameworkWnd.AccountManager.CurrentUser.Sid)); 
        } 
 
        private void mi_File_Click(object sender, EventArgs e) 
        { 
            this._frameworkWnd.ConversationManager.StartConversation(this._frameworkWnd.MainWindow, ConversationOperation.SendFile, null); 
        } 
 
        private void mi_Ivr_Click(object sender, EventArgs e) 
        { 
            this._frameworkWnd.IVRManager.StartIVR(this._frameworkWnd.MainWindow, null); 
        } 
 
        public void mi_MobileMail_Click(object sender, EventArgs e) 
        { 
            if (!this._frameworkWnd.AccountManager.CurrentUser.MobileMailInfo.IsInRunningProvince.HasValue) 
            { 
                this._frameworkWnd.UnifiedMessageBox.ShowInfo(this._frameworkWnd.MainWindow, "对不起。目前无法获取手机邮箱状态。\r\n请在下次登录客户端后重试。"); 
            } 
            else if (this._frameworkWnd.AccountManager.CurrentUser.MobileMailInfo.IsInRunningProvince != true) 
            { 
                this._frameworkWnd.UnifiedMessageBox.ShowInfo(this._frameworkWnd.MainWindow, "对不起。您所在的省份目前无法通过飞信\r\n使用手机邮箱业务。"); 
            } 
            else if (!MobileMailCommandHelper.CheckMailStatus(this._frameworkWnd.AccountManager.CurrentUser)) 
            { 
                new MobileEmailApplyForm().Show(this._frameworkWnd.MainWindow); 
            } 
            else if (this._frameworkWnd.AccountManager.CurrentUser.MobileMailInfo.Binding_Status != 0) 
            { 
                MobileEmailBindForm form = new MobileEmailBindForm(this._frameworkWnd); 
                ControlHelper.ShowDialogCenterOnParent(form, this._frameworkWnd.MainWindow, true); 
            } 
            else 
            { 
                FunctionHelper.StartFunc(WebFunction.MobileEmailNaviToReceiveBox, null); 
            } 
        } 
 
        private void mi_RMatch_Click(object sender, EventArgs e) 
        { 
            this._frameworkWnd.ContactManager.ShowRadomMatchWindow(); 
        } 
 
        public void mi_SendFileToMe_Click(object sender, EventArgs e) 
        { 
            this._frameworkWnd.ConversationManager.SendFileToSelf(this._frameworkWnd.MainWindow); 
        } 
 
        public void mi_SendSmsToMe_Click(object sender, EventArgs e) 
        { 
            this._frameworkWnd.ConversationManager.StartConversation(this._frameworkWnd.MainWindow, ConversationOperation.SmsChat, new string[] { this._frameworkWnd.AccountManager.CurrentUser.Uri.Raw }); 
        } 
 
        private void mi_Sms_Click(object sender, EventArgs e) 
        { 
            try 
            { 
                this._frameworkWnd.ConversationManager.StartConversation(this._frameworkWnd.MainWindow, ConversationOperation.SmsChat, null); 
            } 
            catch 
            { 
            } 
        } 
 
        public void miAddContact_Click(object sender, EventArgs e) 
        { 
            try 
            { 
                this.ShowAddBuddyWindow(null, string.Empty, null, string.Empty, null, ContactType.ImpsContact); 
            } 
            catch (Exception exception) 
            { 
                this._frameworkWnd.UnifiedMessageBox.ShowException(exception); 
            } 
        } 
 
        private void miAddGroup_Click(object sender, EventArgs e) 
        { 
            try 
            { 
                this.ShowGroupCreateWindow(this._frameworkWnd.MainWindow); 
            } 
            catch (Exception exception) 
            { 
                this._frameworkWnd.UnifiedMessageBox.ShowException(exception); 
            } 
        } 
 
        private void miExport_Click(object sender, EventArgs e) 
        { 
            try 
            { 
                this._frameworkWnd.ImportExportManager.Export(); 
            } 
            catch (ApplicationException exception) 
            { 
                this._frameworkWnd.UnifiedMessageBox.ShowError(exception.Message); 
            } 
            catch (Exception exception2) 
            { 
                this._frameworkWnd.UnifiedMessageBox.ShowException(exception2); 
            } 
        } 
 
        private void miImport_Click(object sender, EventArgs e) 
        { 
            try 
            { 
                this._frameworkWnd.ImportExportManager.Import(); 
            } 
            catch (Exception exception) 
            { 
                this._frameworkWnd.UnifiedMessageBox.ShowException(exception); 
            } 
        } 
 
        private void miInviteIIC_Click(object sender, EventArgs e) 
        { 
            try 
            { 
                this.ShowInviteIICWindow(null); 
            } 
            catch 
            { 
            } 
        } 
 
        public void RemoveFromBlackList(IicUri uri, AsyncBizOperation op) 
        { 
            if (uri.IsValid) 
            { 
                this._user.ContactList.AsyncRemoveFromBlackList(uri, op); 
            } 
        } 
 
        public void ShowAddBuddyWindow(IWin32Window owner, string mobileNo, long? sid, string desc, int? targetGroupId, ContactType contactType) 
        { 
            SendRequestForm innerSendRequestFrom = this.InnerSendRequestFrom; 
            innerSendRequestFrom.MobileNo = mobileNo; 
            innerSendRequestFrom.Sid = sid; 
            innerSendRequestFrom.Desc = desc; 
            innerSendRequestFrom.TargetGroupId = targetGroupId; 
            innerSendRequestFrom.ContactType = contactType; 
            Form parent = owner as Form; 
            if (parent == null) 
            { 
                parent = (Form) this._frameworkWnd; 
            } 
            ControlHelper.ShowFormCenterOnParent(innerSendRequestFrom, parent); 
        } 
 
        public void ShowConditionalMatchWindow() 
        { 
            this._frameworkWnd.NavigateToTab("BuddyMatch", "status=2"); 
        } 
 
        public void ShowContactDeleteWindow(IicUri iicUri) 
        { 
            ContactDelete form = new ContactDelete(this._frameworkWnd, iicUri.Raw); 
            ControlHelper.ShowDialogCenterOnParent(form, this._frameworkWnd.MainWindow, true); 
        } 
 
        public void ShowContactDetail(string contactUri) 
        { 
            this.ShowContactDetail(null, contactUri); 
        } 
 
        public void ShowContactDetail(IWin32Window owner, string contactUri) 
        { 
            FormClosedEventHandler handler = null; 
            FormClosedEventHandler handler2 = null; 
            IicUri uri = new IicUri(contactUri); 
            if (uri.IsValid && uri.IsContact) 
            { 
                ProfileForm form; 
                ProfileFormVodafone vodafone; 
                string key = contactUri.ToLower(); 
                if (this.ProfileForms.TryGetValue(key, out form) && !form.IsHandleCreated) 
                { 
                    this.ProfileForms.Remove(key); 
                    form = null; 
                } 
                if (this.ProfileFormsVodafone.TryGetValue(key, out vodafone) && !vodafone.IsHandleCreated) 
                { 
                    this.ProfileFormsVodafone.Remove(key); 
                    vodafone = null; 
                } 
                if (!uri.IsVodafoneUri) 
                { 
                    if (vodafone != null) 
                    { 
                        vodafone.Close(); 
                    } 
                    if (form == null) 
                    { 
                        Imps.Client.Core.Contact contact = this._user.ContactList.FindOrCreateContact(contactUri, null); 
                        form = new ProfileForm(this._frameworkWnd, contact); 
                        if (handler == null) 
                        { 
                            handler = delegate (object sender, FormClosedEventArgs e) { 
                                ProfileForm form = (ProfileForm) sender; 
                                foreach (KeyValuePair pair in this.ProfileForms) 
                                { 
                                    if (pair.Value == form) 
                                    { 
                                        this.ProfileForms.Remove(pair.Key); 
                                        break; 
                                    } 
                                } 
                            }; 
                        } 
                        form.FormClosed += handler; 
                        this.ProfileForms.Add(key, form); 
                    } 
                    if (form.Visible) 
                    { 
                        form.BringToFront(); 
                        form.Activate(); 
                    } 
                    else 
                    { 
                        Form form2 = owner as Form; 
                        if (form2 == null) 
                        { 
                            form2 = (Form) this._frameworkWnd; 
                        } 
                        form.ShowProfile(form2); 
                    } 
                } 
                else 
                { 
                    if (form != null) 
                    { 
                        form.Close(); 
                    } 
                    if (vodafone == null) 
                    { 
                        Imps.Client.Core.Contact contact2 = this._user.ContactList.FindOrCreateContact(contactUri, null); 
                        if (contact2.Uri.IsVodafoneUri) 
                        { 
                            vodafone = new ProfileFormVodafone(this._frameworkWnd, contact2); 
                            if (handler2 == null) 
                            { 
                                handler2 = delegate (object sender, FormClosedEventArgs e) { 
                                    ProfileFormVodafone vodafone = (ProfileFormVodafone) sender; 
                                    foreach (KeyValuePair pair in this.ProfileFormsVodafone) 
                                    { 
                                        if (pair.Value == vodafone) 
                                        { 
                                            this.ProfileFormsVodafone.Remove(pair.Key); 
                                            break; 
                                        } 
                                    } 
                                }; 
                            } 
                            vodafone.FormClosed += handler2; 
                            this.ProfileFormsVodafone.Add(key, vodafone); 
                        } 
                    } 
                    if (vodafone.Visible) 
                    { 
                        vodafone.BringToFront(); 
                        vodafone.Activate(); 
                    } 
                    else 
                    { 
                        Form form3 = owner as Form; 
                        if (form3 == null) 
                        { 
                            form3 = (Form) this._frameworkWnd; 
                        } 
                        vodafone.ShowProfile(form3); 
                    } 
                } 
            } 
        } 
 
        public void ShowContactPermission(IWin32Window owner, IicUri uri) 
        { 
            FormClosedEventHandler handler = null; 
            if (uri.IsValid) 
            { 
                ProfileForm form; 
                string key = uri.Raw.ToLower(); 
                if (this.ProfileForms.TryGetValue(key, out form) && !form.IsHandleCreated) 
                { 
                    this.ProfileForms.Remove(key); 
                    form = null; 
                } 
                if (form == null) 
                { 
                    Imps.Client.Core.Contact contact = this._user.ContactList.FindOrCreateContact(uri.Raw, null); 
                    form = new ProfileForm(this._frameworkWnd, contact); 
                    if (handler == null) 
                    { 
                        handler = delegate (object sender, FormClosedEventArgs e) { 
                            ProfileForm form = (ProfileForm) sender; 
                            foreach (KeyValuePair pair in this.ProfileForms) 
                            { 
                                if (pair.Value == form) 
                                { 
                                    this.ProfileForms.Remove(pair.Key); 
                                    break; 
                                } 
                            } 
                        }; 
                    } 
                    form.FormClosed += handler; 
                    this.ProfileForms.Add(key, form); 
                } 
                form.ShowProfile(owner, StringTable.ContactProfile.KeyPermissionSettring); 
                if (form.Visible) 
                { 
                    form.BringToFront(); 
                    form.Activate(); 
                } 
                else 
                { 
                    Form form2 = owner as Form; 
                    if (form2 == null) 
                    { 
                        form2 = (Form) this._frameworkWnd; 
                    } 
                    form.Location = form2.PointToScreen(form2.ClientRectangle.Location); 
                    form.ShowProfile(form2); 
                } 
            } 
        } 
 
        public void ShowGroupCreateWindow(IWin32Window owner) 
        { 
            if (owner == null) 
            { 
                owner = this._frameworkWnd.MainWindow; 
            } 
            AsyncBizOperation op = new AsyncBizOperation(); 
            ContactGroupForm form = new ContactGroupForm(this._frameworkWnd, null, op); 
            op.ImpsError += delegate (object sender, ImpsErrorEventArgs e) { 
                this._contactListControl.SetWizardForceDisplayGroup(true); 
                UiErrorHelper.ShowImpsError(this._frameworkWnd, form, e); 
            }; 
            op.Successed += delegate (object sender, EventArgs e) { 
                this._contactListControl.SetWizardForceDisplayGroup(true); 
            }; 
            ControlHelper.ShowDialogCenterOnParent(form, owner, true); 
        } 
 
        public void ShowGroupDeleteWindow(int? groupId) 
        { 
            if (groupId.HasValue) 
            { 
                Imps.Client.Core.ContactGroup group = this._user.ContactList.Groups[groupId] as Imps.Client.Core.ContactGroup; 
                if (group != null) 
                { 
                    if (group.Contacts.Count > 0) 
                    { 
                        this._frameworkWnd.UnifiedMessageBox.ShowInfo(StringTable.ContactGroup.MsgCannotDelelte_HasContacts); 
                    } 
                    else if (((this._user.ContactList.Groups[-1] != null) && (this._user.ContactList.Groups.Count == 2)) || ((this._user.ContactList.Groups[-1] == null) && (this._user.ContactList.Groups.Count == 1))) 
                    { 
                        this._frameworkWnd.UnifiedMessageBox.ShowInfo(StringTable.ContactGroup.MsgCannotDelelte_OnlyOne); 
                    } 
                    else 
                    { 
                        group.AsyncDelete(new AsyncBizOperation()); 
                    } 
                } 
            } 
        } 
 
        public void ShowGroupEditWindow(int? groupId) 
        { 
            if (groupId.HasValue) 
            { 
                AsyncBizOperation op = new AsyncBizOperation(); 
                op.ImpsError += delegate (object sender, ImpsErrorEventArgs e) { 
                    this._contactListControl.SetWizardForceDisplayGroup(true); 
                }; 
                op.Successed += delegate (object sender, EventArgs e) { 
                    this._contactListControl.SetWizardForceDisplayGroup(true); 
                }; 
                ContactGroupForm form = new ContactGroupForm(this._frameworkWnd, groupId, op); 
                ControlHelper.ShowDialogCenterOnParent(form, this._frameworkWnd.MainWindow, true); 
            } 
        } 
 
        public void ShowInviteIICWindow(string mobileNo) 
        { 
            InviteIICForm innerInviteIICFForm = this.GetInnerInviteIICFForm(mobileNo); 
            innerInviteIICFForm.Location = this._frameworkWnd.MainWindow.PointToScreen(this._frameworkWnd.MainWindow.ClientRectangle.Location); 
            ControlHelper.ShowFormCenterOnParent(innerInviteIICFForm, this._frameworkWnd.MainWindow); 
        } 
 
        public void ShowMatchWindow() 
        { 
            this._frameworkWnd.NavigateToTab("BuddyMatch", string.Empty); 
        } 
 
        public void ShowRadomMatchWindow() 
        { 
            this._frameworkWnd.NavigateToTab("BuddyMatch", "status=1"); 
        } 
 
        public void ShowSendSmsToMeWindow() 
        { 
        } 
 
        public bool TryAddContactGroup(string name, out int? groupId) 
        { 
            groupId = 1; 
            return true; 
        } 
 
        public Control ContactListControl 
        { 
            get 
            { 
                if ((this._contactListControl == null) || this._contactListControl.IsDisposed) 
                { 
                    this._contactListControl = new Imps.Client.Pc.UIContactList.ContactListControl(this._frameworkWnd); 
                } 
                return this._contactListControl; 
            } 
        } 
 
        private SendRequestForm InnerSendRequestFrom 
        { 
            get 
            { 
                EventHandler handler = null; 
                if ((this._sendRequestForm == null) || this._sendRequestForm.IsDisposed) 
                { 
                    this._sendRequestForm = new SendRequestForm(this._frameworkWnd); 
                    if (handler == null) 
                    { 
                        handler = delegate { 
                            this._sendRequestForm = null; 
                        }; 
                    } 
                    this._sendRequestForm.Disposed += handler; 
                } 
                return this._sendRequestForm; 
            } 
        } 
 
        public ToolStripMenuItem MenuItem 
        { 
            get 
            { 
                return this._menuItem; 
            } 
        } 
 
        public ToolStripItem[] OperationMenuItems 
        { 
            get 
            { 
                this.BuildOperationMenuItems(); 
                return this._menuItemsOperation; 
            } 
        } 
 
        private Dictionary ProfileForms 
        { 
            get 
            { 
                if (this._profileForms == null) 
                { 
                    this._profileForms = new Dictionary(); 
                } 
                return this._profileForms; 
            } 
        } 
 
        private Dictionary ProfileFormsVodafone 
        { 
            get 
            { 
                if (this._profileFormsVodafone == null) 
                { 
                    this._profileFormsVodafone = new Dictionary(); 
                } 
                return this._profileFormsVodafone; 
            } 
        } 
 
        public Control ToolbarControl 
        { 
            get 
            { 
                if ((this._toolbar == null) || this._toolbar.IsDisposed) 
                { 
                    this._toolbar = new BListControlToolbar(); 
                    this._toolbar.SearchTextBox.EmptyTextTip = StringTable.Contact.ContactSearchEmptyText; 
                    this._toolbar.Dock = DockStyle.Top; 
                } 
                return this._toolbar; 
            } 
        } 
    } 
}