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

📄 contactlistcontrol.cs

📁 破解的飞信源代码
💻 CS
📖 第 1 页 / 共 5 页
字号:
namespace Imps.Client.Pc.UIContactList
{
    using Imps.Client;
    using Imps.Client.Core;
    using Imps.Client.Pc;
    using Imps.Client.Pc.BizControls;
    using Imps.Client.Pc.Controls;
    using Imps.Client.Pc.WndlessControls;
    using Imps.Client.Resource;
    using Imps.Client.Utils;
    using Imps.Common;
    using Imps.Utils;
    using std;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class ContactListControl : UserControl
    {
        private ArrayList _collapsedGroups = new ArrayList();
        private IList<Imps.Client.Core.Contact> _contactForceUpdateCol;
        private IList<Imps.Client.Core.Contact> _contactInfoChangedCol;
        private ContactNotifyWindowManager _contactNotifyWindowManager;
        private IList<ContactChangedEventArgs> _contactPresenceChangedCol;
        private ContactTreeGroupByType _currentTreeGroupByType;
        private bool? _forceDisplayGroup;
        private SystemFixedContactGroupCollection _gorupsByTerminal;
        private SystemFixedContactGroupCollection _groupsByPresence;
        private IFrameworkWindow _iFrameworkWnd;
        private bool _isWizardVisible;
        private ContactMatchHelper _matchHelper;
        private ContactCollection _searchResult;
        private BListControlToolbar _toolbar;
        private WndlessControlCollection _wndlessCtls;
        private IContainer components;
        private ImageList imageListDrag;
        private ImageList imageListTree;
        private Label label1;
        private LinkLabel lblAddBuddy;
        private WndlessLabel lblId;
        private LinkLabel lblImport;
        private LinkLabel lblMatch;
        private vscroll_widget m_buddytree_vscroll_widget;
        private buddytree_widget m_buddytree_widget;
        private bool m_fTreeShowDetailTip = true;
        private ToolStripMenuItem mr_d_DetailMouseOver;
        private menu_radioitem mr_d_Group;
        private menu_radioitem mr_d_Presence;
        private menu_radioitem mr_d_Terminal;
        private menu_widget mw_DisplayMenu;
        private Panel panelEmpty;
        private PictureBox pbAddBuddy;
        private PictureBox pbInput;
        private PictureBox pbMatch;
        private const int TIMESPAN = 10;
        private TextBox tstbSearch;

        public ContactListControl(IFrameworkWindow iFrameworkWnd)
        {
            this._iFrameworkWnd = iFrameworkWnd;
            this.InitializeComponent();
            this.InitInitPanel();
            this.InitToolbar();
            this.InitializeContextMenuComponent();
            this.InitializeWndlessComponent();
            this.m_buddytree_widget.iframework_wnd = iFrameworkWnd;
            this.CurrentUser.StatusChanged += new EventHandler<UserSatusChangedEventArgs>(this, (IntPtr) this._user_StatusChanged);
            this._contactNotifyWindowManager = new ContactNotifyWindowManager(this.CurrentUser, this._iFrameworkWnd);
            this._contactPresenceChangedCol = new List<ContactChangedEventArgs>();
            this._contactInfoChangedCol = new List<Imps.Client.Core.Contact>();
            this._contactForceUpdateCol = new List<Imps.Client.Core.Contact>();
            this.ContactList.AddBuddyResult += new EventHandler<AddBuddyResultEventArgs>(this, (IntPtr) this.contactList_AddBuddyResult);
            this.ContactList.Changed += new EventHandler<ContactListEventArgs>(this, (IntPtr) this.contactList_Changed);
            this.ContactList.ContactsChanged += new EventHandler<ContactsChangedEventArgs>(this, (IntPtr) this.contactList_ContactChanged);
            this.ContactList.ContactGroupChanged += new EventHandler<ContactGroupChangedEventArgs>(this, (IntPtr) this.contactList_ContactGroupChanged);
        }

        private void _user_StatusChanged(object sender, UserSatusChangedEventArgs e)
        {
            try
            {
                if (e.NewStatus == UserAccountStatus.Logoff)
                {
                    this.tstbSearch.Text = string.Empty;
                    this.clear();
                    this._contactNotifyWindowManager.Clear();
                    this._contactForceUpdateCol.Clear();
                    this._contactInfoChangedCol.Clear();
                    this._contactPresenceChangedCol.Clear();
                    this.setWizardUiOnNoneContact(false);
                }
                else if (e.NewStatus == UserAccountStatus.Disconnected)
                {
                    this.clear();
                    this._contactNotifyWindowManager.Clear();
                    this._contactForceUpdateCol.Clear();
                    this._contactInfoChangedCol.Clear();
                    this._contactPresenceChangedCol.Clear();
                    this.setWizardUiOnNoneContact(false);
                }
                else if (e.NewStatus == UserAccountStatus.Loginning)
                {
                    this.setWizardUiOnNoneContact(false);
                }
                else if ((e.NewStatus == UserAccountStatus.Logon) || (e.NewStatus == UserAccountStatus.OfflineLogon))
                {
                    this.tstbSearch.Text = string.Empty;
                    this.m_buddytree_widget.F2Edit = e.NewStatus == UserAccountStatus.Logon;
                    this._currentTreeGroupByType = (ContactTreeGroupByType) Enum.Parse(typeof(ContactTreeGroupByType), this.CurrentUser.Configuration.UserSetting.MainWindowSetting.GroupByMode.Value.ToString());
                    this.changeTreeShowDetail(this.CurrentUser.Configuration.UserSetting.MainWindowSetting.DisplayMode.Value, true);
                    this.changeTreeShowDetailTip(this.CurrentUser.Configuration.UserSetting.MainWindowSetting.ShowMoreDetails.Value, true);
                    this.changeTreeGroupByType(this._currentTreeGroupByType, true);
                    if (this.CurrentUser.ContactList.Contacts.Count == 0)
                    {
                        bool? nullable = this._forceDisplayGroup;
                        if (nullable.GetValueOrDefault() && nullable.get_HasValue())
                        {
                            this.setWizardUiOnNoneContact(true);
                        }
                    }
                    this._contactNotifyWindowManager.ShowWindow();
                }
            }
            catch (Exception exception)
            {
                ClientLogger.WriteGeneral("ContactListControl", exception.ToString(), 10);
            }
        }

        private void bindSearchResult()
        {
            this.m_buddytree_widget.remove_allitems(false);
            if (this._searchResult.Count > 0)
            {
                this.m_buddytree_widget.Visible = true;
                using (IEnumerator<Imps.Client.Core.Contact> enumerator = this._searchResult.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Imps.Client.Core.Contact contact = enumerator.get_Current();
                        this.contactNodes_Add(contact);
                    }
                }
                this.m_buddytree_widget.paint();
            }
            else
            {
                this.m_buddytree_widget.Visible = false;
            }
        }

        private void cacheContactInfoChanged(Imps.Client.Core.Contact contact)
        {
            lock (this._contactInfoChangedCol)
            {
                if (this._contactInfoChangedCol.get_Count() <= 0)
                {
                    GlobalTimer.Register(new EventHandler(this.handleContactInfoChanged_Tick), 10);
                }
                this._contactInfoChangedCol.Add(contact);
            }
        }

        private void cacheContactPresenceChanged(ContactChangedEventArgs e)
        {
            lock (this._contactPresenceChangedCol)
            {
                if (this._contactPresenceChangedCol.get_Count() <= 0)
                {
                    GlobalTimer.Register(new EventHandler(this.handleContactPresenceChanged_Tick), 10);
                }
                this._contactPresenceChangedCol.Add(e);
            }
        }

        private void changeTreeGroupByType(ContactTreeGroupByType type, bool forceUpdate)
        {
            if ((this._currentTreeGroupByType != type) || forceUpdate)
            {
                this._currentTreeGroupByType = type;
                if (this._gorupsByTerminal != null)
                {
                    this._gorupsByTerminal = null;
                }
                if (this._groupsByPresence != null)
                {
                    this._groupsByPresence = null;
                }
                this.refreshContactList();
                this.mr_d_Group.Radioed = type == ContactTreeGroupByType.Group;
                this.mr_d_Terminal.Radioed = type == ContactTreeGroupByType.Terminal;
                this.mr_d_Presence.Radioed = type == ContactTreeGroupByType.Presence;
                this.CurrentUser.Configuration.UserSetting.MainWindowSetting.GroupByMode.ProposedValue = (int) type;
                switch (type)
                {
                    case ContactTreeGroupByType.Group:
                        this.m_buddytree_widget.sort_style = buddytree_widget.SORTSTYLE.SORT_BY_GROUP;
                        return;

                    case ContactTreeGroupByType.Terminal:
                        this.m_buddytree_widget.sort_style = buddytree_widget.SORTSTYLE.SORT_BY_DEVICE;
                        return;

                    case ContactTreeGroupByType.Presence:
                        this.m_buddytree_widget.sort_style = buddytree_widget.SORTSTYLE.SORT_BY_STATE;
                        return;
                }
                throw new Exception("Unsupported sort style");
            }
        }

        private void changeTreeShowDetail(BuddyTreeDisplayMode command, bool forceUpdate)
        {
            if ((command != this.m_buddytree_widget.DisplayMode) || forceUpdate)
            {
                this.m_buddytree_widget.DisplayMode = command;
                this._toolbar.DisplayModeTrackBar.Value = (int) command;
                this.CurrentUser.Configuration.UserSetting.MainWindowSetting.DisplayMode.ProposedValue = this._toolbar.DisplayModeTrackBar.Value;
            }
        }

        private void changeTreeShowDetailTip(bool command, bool forceUpdate)
        {
            if ((command != this.m_fTreeShowDetailTip) || forceUpdate)
            {
                this.m_fTreeShowDetailTip = command;
                this.mr_d_DetailMouseOver.set_Checked(this.m_fTreeShowDetailTip);
                this.CurrentUser.Configuration.UserSetting.MainWindowSetting.ShowMoreDetails.ProposedValue = this.m_fTreeShowDetailTip;
                this.m_buddytree_widget.show_detailtip = this.m_fTreeShowDetailTip;
            }
        }

        private void clear()
        {
            this.m_buddytree_widget.remove_allitems(true);
        }

        private void contactList_AddBuddyResult(object sender, AddBuddyResultEventArgs e)
        {
            try
            {
                Imps.Client.Core.Contact contact = this.ContactList.Contacts[e.Contact.Uri];
                if (contact != null)
                {
                    this.contactNodes_Update(contact);
                    this.m_buddytree_widget.sort_allitems(true);
                }
                else
                {
                    this.contactNodes_Add(e.Contact);
                    this.m_buddytree_widget.sort_allitems(true);
                }
                this._contactNotifyWindowManager.AddNotifyWnd_AddBuddyResult(e);
            }
            catch (Exception exception)
            {
                this.m_buddytree_widget.sort_allitems(true);
                ClientLogger.WriteGeneral("ContactListControl", exception.ToString(), 10);
            }
        }

        private void contactList_Changed(object sender, ContactListEventArgs e)
        {
            this.refreshContactList();
        }

        private void contactList_ContactChanged(object sender, ContactsChangedEventArgs e)
        {
            try
            {
                if ((this.CurrentUser.Status == UserAccountStatus.Logon) || (this.CurrentUser.Status == UserAccountStatus.OfflineLogon))
                {
                    List<ContactChangedEventArgs>.Enumerator enumerator = e.ContactChangedEventArgsCollection.GetEnumerator();
                    try
                    {

⌨️ 快捷键说明

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