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

📄 contactlistcontrol.cs

📁 飞信的收发使用csharp进行开发
💻 CS
📖 第 1 页 / 共 4 页
字号:
        private void on_group_expand_changed(object sender, object group, bool fExpanded)
        {
            int? nullable = null;
            if (group is ContactGroupBase)
            {
                nullable = new int?((group as ContactGroupBase).Id);
            }
            else if (group is SystemFixedContactGroup)
            {
                nullable = new int?((group as SystemFixedContactGroup).Id);
            }
            if (nullable.HasValue)
            {
                if (fExpanded)
                {
                    if (this._collapsedGroups.Contains(nullable.ToString()))
                    {
                        this._collapsedGroups.Remove(nullable.ToString());
                    }
                }
                else if (!this._collapsedGroups.Contains(nullable.ToString()))
                {
                    this._collapsedGroups.Add(nullable.ToString());
                }
                string str = string.Join(";", (string[]) this._collapsedGroups.ToArray(typeof(string)));
                this.CurrentUser.Configuration.UserSetting.MainWindowSetting.TreeExpandStatus = str;
            }
        }

        private void on_showdetail_change_cmd(object sender, bool command)
        {
            this.changeTreeShowDetail(command, false);
        }

        private void on_showdetailtip_change_cmd(object sender, bool command)
        {
            this.changeTreeShowDetailTip(command, false);
        }

        private void on_sortstyle_change_cmd(object sender, buddytree_widget.SORTSTYLE newStyle)
        {
            switch (newStyle)
            {
                case buddytree_widget.SORTSTYLE.SORT_BY_GROUP:
                    this.changeTreeGroupByType(ContactTreeGroupByType.Group, false);
                    return;

                case buddytree_widget.SORTSTYLE.SORT_BY_DEVICE:
                    this.changeTreeGroupByType(ContactTreeGroupByType.Terminal, false);
                    return;

                case buddytree_widget.SORTSTYLE.SORT_BY_STATE:
                    this.changeTreeGroupByType(ContactTreeGroupByType.Presence, false);
                    return;
            }
            throw new Exception("Unsupported sort style");
        }

        private void refreshContactList()
        {
            try
            {
                if ((this.CurrentUser.Status != UserAccountStatus.Logon) || (this.ContactList == null))
                {
                    return;
                }
                if ((this.ContactList.Contacts.Count <= 0) && (this._forceDisplayGroup != true))
                {
                    this.setWizardUiOnNoneContact(true);
                }
                else
                {
                    this.setWizardUiOnNoneContact(false);
                }
                this.m_buddytree_widget.remove_allitems(false);
                switch (this._currentTreeGroupByType)
                {
                    case ContactTreeGroupByType.Group:
                        lock (this.ContactList.Groups.SyncRoot)
                        {
                            foreach (Imps.Client.Core.ContactGroup group in this.ContactList.Groups)
                            {
                                this.m_buddytree_widget.add_group(group, false);
                            }
                        }
                        lock (this.ContactList.Contacts.SyncRoot)
                        {
                            foreach (Imps.Client.Core.Contact contact in this.ContactList.Contacts)
                            {
                                this.contactNodes_Add(contact);
                            }
                            goto Label_028D;
                        }
                        break;

                    case ContactTreeGroupByType.Terminal:
                        goto Label_01F1;

                    case ContactTreeGroupByType.Presence:
                        break;

                    default:
                        goto Label_028D;
                }
                foreach (SystemFixedContactGroup group2 in this.GroupsByPresence)
                {
                    this.m_buddytree_widget.add_group(group2, false);
                }
                lock (this.ContactList.Contacts.SyncRoot)
                {
                    foreach (Imps.Client.Core.Contact contact2 in this.ContactList.Contacts)
                    {
                        this.contactNodes_Add(contact2);
                    }
                    goto Label_028D;
                }
            Label_01F1:
                foreach (SystemFixedContactGroup group3 in this.GroupsByTerminal)
                {
                    this.m_buddytree_widget.add_group(group3, false);
                }
                lock (this.ContactList.Contacts.SyncRoot)
                {
                    foreach (Imps.Client.Core.Contact contact3 in this.ContactList.Contacts)
                    {
                        this.contactNodes_Add(contact3);
                    }
                }
            Label_028D:
                this.loadGroupCollapse();
                this.m_buddytree_widget.sort_allitems(true);
            }
            catch (Exception exception)
            {
                this.m_buddytree_widget.sort_allitems(true);
                this._iFrameworkWnd.UnifiedMessageBox.ShowError(StringTable.Contact.ContactList_LoadError);
                ClientLogger.WriteException(exception);
            }
        }

        public void SetWizardForceDisplayGroup(bool value)
        {
            this._forceDisplayGroup = new bool?(value);
            if ((this.CurrentUser.ContactList.Contacts.Count <= 0) && (this._forceDisplayGroup == true))
            {
                this.setWizardUiOnNoneContact(false);
            }
        }

        private void setWizardUiOnNoneContact(bool state)
        {
            this.lblId.Visible = this.m_buddytree_widget.searching;
            if (this.m_buddytree_widget.searching)
            {
                this.panelEmpty.Visible = false;
                this._isWizardVisible = false;
            }
            if (state)
            {
                this.panelEmpty.Dock = DockStyle.Fill;
                this.panelEmpty.Visible = true;
                this._isWizardVisible = true;
                bool matchingEnabled = this._iFrameworkWnd.AccountManager.CurrentUser.Configuration.SystemSetting.ServerUriSetting.MatchingEnabled;
                this.lblMatch.Visible = matchingEnabled;
                this.pbMatch.Visible = matchingEnabled;
            }
            else
            {
                this.panelEmpty.Visible = false;
                this._isWizardVisible = false;
            }
        }

        private void stbtnAddBuddy_Click(object sender, EventArgs e)
        {
            try
            {
                this._iFrameworkWnd.ContactManager.ShowAddBuddyWindow(null, string.Empty, null, string.Empty, null, ContactType.ImpsContact);
            }
            catch (Exception exception)
            {
                this._iFrameworkWnd.UnifiedMessageBox.ShowException(exception);
            }
        }

        private void tstbSearch_KeyDown(object sender, KeyEventArgs e)
        {
            Keys keyCode = e.KeyCode;
            if (keyCode != Keys.Return)
            {
                if (keyCode != Keys.Escape)
                {
                    if (keyCode == Keys.Down)
                    {
                        this.m_buddytree_widget.scroll_to_top();
                        this.m_buddytree_widget.change_focus_item(this.m_buddytree_widget.first_item, true);
                        this.m_buddytree_widget.Focus();
                    }
                    return;
                }
            }
            else
            {
                tree<tree_widget.item_type>.iterator item = this.m_buddytree_widget.first_visible_item;
                if (!this.m_buddytree_widget.end.is_equal(item))
                {
                    if (!(item.data is tree_widget_buddy))
                    {
                        return;
                    }
                    this._iFrameworkWnd.ConversationManager.StartConversation(this._iFrameworkWnd as IWin32Window, ConversationOperation.ImChat, new string[] { (item.data as tree_widget_buddy).contact.Uri.Raw });
                    this.tstbSearch.Text = string.Empty;
                }
                return;
            }
            this.tstbSearch.Text = string.Empty;
        }

        private void tstbSearch_TextChanged(object sender, EventArgs e)
        {
            try
            {
                string keyWord = this.tstbSearch.Text.Trim();
                if (keyWord.Length == 0)
                {
                    this.m_buddytree_widget.searching = false;
                    this.m_buddytree_widget.Visible = true;
                    this.refreshContactList();
                    this.mr_d_Presence.Enabled = true;
                    this.mr_d_Terminal.Enabled = true;
                    this.mr_d_Group.Enabled = true;
                    this.MatchHelper.Clear();
                    this._searchResult.Clear();
                }
                else
                {
                    this._searchResult = this.MatchHelper.GetMatchContacts(keyWord);
                    this.m_buddytree_widget.searching = true;
                    this.m_buddytree_widget.Visible = true;
                    this.setWizardUiOnNoneContact(false);
                    this.mr_d_Presence.Enabled = false;
                    this.mr_d_Terminal.Enabled = false;
                    this.mr_d_Group.Enabled = false;
                    this.bindSearchResult();
                }
            }
            catch (Exception exception)
            {
                this.m_buddytree_widget.sort_allitems(true);
                ClientLogger.WriteException(exception);
            }
        }

        private Imps.Client.Core.ContactList ContactList
        {
            get
            {
                return this.CurrentUser.ContactList;
            }
        }

        internal ContactTreeGroupByType CurrentTreeGroupByType
        {
            get
            {
                return this._currentTreeGroupByType;
            }
        }

        private Imps.Client.Core.User CurrentUser
        {
            get
            {
                return this._iFrameworkWnd.AccountManager.CurrentUser;
            }
        }

        public menu_widget DisplayMenu
        {
            get
            {
                return this.mw_DisplayMenu;
            }
        }

        private SystemFixedContactGroupCollection GroupsByPresence
        {
            get
            {
                if (this._groupsByPresence == null)
                {
                    this._groupsByPresence = new SystemFixedContactGroupHelper(this.CurrentUser).GetContactGroup(SystemFixContactGroupType.Presence);
                }
                return this._groupsByPresence;
            }
        }

        private SystemFixedContactGroupCollection GroupsByTerminal
        {
            get
            {
                if (this._gorupsByTerminal == null)
                {
                    this._gorupsByTerminal = new SystemFixedContactGroupHelper(this.CurrentUser).GetContactGroup(SystemFixContactGroupType.Terminal);
                }
                return this._gorupsByTerminal;
            }
        }

        private ContactMatchHelper MatchHelper
        {
            get
            {
                if (this._matchHelper == null)
                {
                    this._matchHelper = new ContactMatchHelper(this.CurrentUser);
                }
                return this._matchHelper;
            }
        }
    }
}

⌨️ 快捷键说明

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