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

📄 invitecontrol.cs

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

    public class InviteControl : UserControl
    {
        private List<Imps.Client.Core.Contact> _excludeContacts;
        private IFrameworkWindow _framework;
        private ContactMatchHelper _matchHelper;
        private int _maxSelectedCount;
        private bool _onlyShowOnline;
        private bool _searchTextboxAtTop;
        private List<Imps.Client.Core.Contact> _selectedContacts;
        private SelectContactsType _selectType;
        private bool _showGroup;
        private bool _showJ2MER1;
        private bool _showMobileBuddy;
        private bool _showSelf;
        private bool _showSMSOffline;
        private bool _showSMSOnline;
        private bool _showSymbianR1;
        private IContainer components;
        public string emptyText;
        private bool fireByFunction;
        private FlowLayoutPanel flowPanlContacts;
        private int lastCheckIndex;
        private Label lblMessage;
        private Label lblNoneContacts;
        private Label lblSelectInfo;
        private Label lbSpace;
        private Imps.Client.Core.Contact me;
        private ToolStripMenuItem menuDelete;
        private menu_widget menuOperation;
        private Panel panel1;
        private Panel panel2;
        private Panel pnlOnlyForBorderShit;
        private BListControlToolbar toolbarSearch;
        private BuddySelectionTree treeContacts;
        private XTextBox txtSearch;
        private XSplitContainer xSplitContainer;

        public event EventHandler SelectedContactsChanged;

        public event EventHandler<SplitterEventArgs> SplitterMoved;

        public InviteControl(IFrameworkWindow framework) : this(framework, null)
        {
        }

        public InviteControl(IFrameworkWindow framework, List<Imps.Client.Core.Contact> selectedContacts) : this(framework, selectedContacts, null)
        {
        }

        public InviteControl(IFrameworkWindow framework, List<Imps.Client.Core.Contact> selectedContacts, List<Imps.Client.Core.Contact> excludeContacts) : this(framework, selectedContacts, excludeContacts, SelectContactsType.None)
        {
        }

        public InviteControl(IFrameworkWindow framework, List<Imps.Client.Core.Contact> selectedContacts, List<Imps.Client.Core.Contact> excludeContacts, SelectContactsType selectType)
        {
            this._showGroup = true;
            this._maxSelectedCount = 0x7fffffff;
            this._showJ2MER1 = true;
            this._showSymbianR1 = true;
            this._showSMSOffline = true;
            this.emptyText = StringTable.Contact.ContactSearchEmptyText;
            this.lastCheckIndex = -1;
            this.InitializeComponent();
            this.txtSearch = this.toolbarSearch.SearchTextBox;
            this._selectType = selectType;
            this._framework = framework;
            this._selectedContacts = selectedContacts;
            this._excludeContacts = excludeContacts;
            this.xSplitContainer.add_SplitterMoved(new SplitterEventHandler(this.xSplitContainer_SplitterMoved));
            base.GotFocus += new EventHandler(this.InviteControl_GotFocus);
            this.flowPanlContacts.ControlAdded += new ControlEventHandler(this.flowPanlContacts_ControlsChanged);
            this.flowPanlContacts.ControlRemoved += new ControlEventHandler(this.flowPanlContacts_ControlsChanged);
        }

        private void AddBuddyNode(BuddySelectionGroupNode parent, Imps.Client.Core.Contact contact)
        {
            BuddySelectionBuddyNode buddy = new BuddySelectionBuddyNode();
            buddy.NickName = contact.DisplayName;
            buddy.MoodPhrase = contact.Presence.MoodPhrase;
            buddy.Tag = contact;
            buddy.StatusImage = contact.PresenceIcon;
            this.treeContacts.AddBuddyNode(parent, buddy);
        }

        private bool AddLabel(string name, object tag)
        {
            try
            {
                if (tag is Imps.Client.Core.Contact)
                {
                    Imps.Client.Core.Contact contact = tag as Imps.Client.Core.Contact;
                    if (this.GetLabelByContact(contact) != null)
                    {
                        return false;
                    }
                    if (contact.Uri.Raw == this.CurrentUser.Uri.Raw)
                    {
                        name = "我自己";
                    }
                }
                Label label = new Label();
                label.UseMnemonic = false;
                label.Tag = tag;
                label.Text = name;
                label.Font = new Font("SimSun", 9f, FontStyle.Underline, GraphicsUnit.Point, 0x86);
                label.Size = new Size(0x29, 12);
                label.set_AutoSize(true);
                label.set_Padding(new Padding(1, 2, 1, 2));
                this.flowPanlContacts.Controls.Add(label);
                label.add_MouseClick(new MouseEventHandler(this.lblContact_MouseClick));
                label.DoubleClick += new EventHandler(this.lblContact_DoubleClick);
                this.FormatSelectInfo();
            }
            catch
            {
                return false;
            }
            return true;
        }

        private void AddMySelfNode()
        {
            BuddySelectionBuddyNode buddy = new BuddySelectionBuddyNode();
            buddy.set_Name("我自己");
            buddy.NickName = "我自己";
            buddy.MoodPhrase = "";
            buddy.StatusImage = new AmigoImage(ImageHelper.GetThumbnailImage(this.CurrentUser.PersonalInfo.Portrait, 0x10, 0x10));
            buddy.Tag = this.me;
            this.treeContacts.AddBuddyNode(null, buddy);
            if (this._selectedContacts.Contains(this.me))
            {
                buddy.CheckState = CheckState.Checked;
                this.CheckNode(buddy);
            }
        }

        private void BindContacts(BuddySelectionGroupNode parent, List<Imps.Client.Core.Contact> lstContacts)
        {
            lstContacts.Sort();
            List<Imps.Client.Core.Contact>.Enumerator enumerator = lstContacts.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    Imps.Client.Core.Contact contact = enumerator.get_Current();
                    this.AddBuddyNode(parent, contact);
                }
            }
            finally
            {
                enumerator.Dispose();
            }
        }

        private void BindGroups()
        {
            try
            {
                lock (this.CurrentUser.ContactList.Groups)
                {
                    using (IEnumerator<ContactGroupBase> enumerator = this.CurrentUser.ContactList.Groups.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Imps.Client.Core.ContactGroup group = (Imps.Client.Core.ContactGroup) enumerator.get_Current();
                            List<Imps.Client.Core.Contact> lstContacts = this.GetAllowContacts(group.Contacts.ListContacts);
                            if (lstContacts.get_Count() > 0)
                            {
                                BuddySelectionGroupNode gNode = new BuddySelectionGroupNode(group.Name + string.Format(" ({0})", lstContacts.get_Count()), CheckState.Unchecked);
                                gNode.Tag = group;
                                this.treeContacts.AddBuddyGroup(gNode);
                                this.BindContacts(gNode, lstContacts);
                            }
                        }
                    }
                }
                this.BindNoneGroupContacts();
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
            }
        }

        private void bindList()
        {
            try
            {
                if (this.ShowSelf)
                {
                    this.me = this.CurrentUser.ContactList.FindOrCreateContact(this.CurrentUser.Uri.Raw, new AsyncBizOperation());
                    this.AddMySelfNode();
                }
                if (this.ShowGroup)
                {
                    this.BindGroups();
                }
                else
                {
                    List<Imps.Client.Core.Contact> lstContacts = this.GetAllowContacts(this.CurrentUser.ContactList.Contacts.ListContacts);
                    this.BindContacts(null, lstContacts);
                }
                if (this.treeContacts.Nodes.Count > 0)
                {
                    this.treeContacts.SelectedNode = this.treeContacts.Nodes[0] as PaintTreeNode;
                }
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
            }
            finally
            {
                this.lblNoneContacts.Visible = this.treeContacts.Nodes.Count == 0;
            }
        }

        private void BindNoneGroupContacts()
        {
            lock (this.CurrentUser.ContactList.Contacts.SyncRoot)
            {
                List<Imps.Client.Core.Contact> lstContacts = new List<Imps.Client.Core.Contact>();
                using (IEnumerator<Imps.Client.Core.Contact> enumerator = this.CurrentUser.ContactList.Contacts.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Imps.Client.Core.Contact contact = enumerator.get_Current();
                        if ((contact.BelongToGroups.get_Count() == 0) && this.IsContactCanShow(contact))
                        {
                            lstContacts.Add(contact);
                        }
                    }
                }
                if (lstContacts.get_Count() > 0)
                {
                    this.BindContacts(null, lstContacts);
                }
            }
        }

        private void CheckContactNode(Imps.Client.Core.Contact contact)
        {
            for (int i = 0; i < this.treeContacts.Nodes.Count; i++)
            {
                PaintTreeNode node = this.treeContacts.Nodes[i] as PaintTreeNode;
                if ((node.Tag is Imps.Client.Core.Contact) && ((node.Tag as Imps.Client.Core.Contact).Uri.Raw == contact.Uri.Raw))
                {
                    (node as BuddySelectionBuddyNode).CheckState = CheckState.Checked;
                    this.CheckContactNode(node);
                    return;
                }
                foreach (TreeNode node2 in this.treeContacts.Nodes[i].Nodes)
                {
                    if ((node2.Tag as Imps.Client.Core.Contact) != contact)
                    {
                        continue;
                    }
                    if (!this.treeContacts.Nodes[i].IsExpanded)
                    {
                        this.treeContacts.Nodes[i].Expand();
                    }
                    (node2 as BuddySelectionBuddyNode).CheckState = CheckState.Checked;
                    this.CheckContactNode(node2 as PaintTreeNode);
                    return;
                }
            }
        }

        private void CheckContactNode(PaintTreeNode node)
        {
            Imps.Client.Core.Contact tag = node.Tag as Imps.Client.Core.Contact;
            if ((node as BuddySelectionBuddyNode).CheckState == CheckState.Checked)
            {
                if (!this._selectedContacts.Contains(tag))
                {
                    if (this._selectedContacts.get_Count() >= this._maxSelectedCount)
                    {
                        (node as BuddySelectionBuddyNode).CheckState = CheckState.Unchecked;
                        FormatGroupCheckState(node);
                        this._framework.UnifiedMessageBox.ShowWarning(this, string.Format(StringTable.Conversation.MsgSelectLimit, this._maxSelectedCount));
                        return;
                    }
                    this._selectedContacts.Add(tag);
                }
                this.AddLabel(tag.DisplayName, tag);
                FormatGroupCheckState(node);
                this.FormatOtherGroupBuddyNode(node.Parent, tag, true);
            }
            else
            {
                if (this._selectedContacts.Contains(tag))
                {
                    this._selectedContacts.Remove(tag);
                }
                this.RemoveLable(tag);
                FormatGroupCheckState(node);
                this.FormatOtherGroupBuddyNode(node.Parent, tag, false);
            }
        }

        private void CheckGroupNode(PaintTreeNode node)
        {
            bool flag = (node as BuddySelectionGroupNode).CheckState == CheckState.Checked;
            foreach (TreeNode node2 in node.Nodes)
            {
                Imps.Client.Core.Contact tag = node2.Tag as Imps.Client.Core.Contact;
                if (flag)
                {
                    if (this._selectedContacts.get_Count() < this._maxSelectedCount)
                    {
                        (node2 as BuddySelectionBuddyNode).CheckState = CheckState.Checked;
                        if (!this._selectedContacts.Contains(tag))
                        {

⌨️ 快捷键说明

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