?? invitecontrol.cs
字號:
?namespace Imps.Client.Pc
{
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 string _lastSearchString;
private ContactMatchHelper _matchHelper;
private int _maxSelectedCount;
private bool _onlyShowOnline;
private List<Imps.Client.Core.Contact> _selectedContacts;
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 Imps.Client.Core.Contact me;
private ToolStripMenuItem menuDelete;
private ContextMenuStrip menuOperation;
private Panel panel1;
private Panel panel2;
private Panel pnlOnlyForBorderShit;
private ToolTip searchTip;
private BuddySelectionTree treeContacts;
private XTextBox txtSearch;
private XSplitContainer xSplitContainer;
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.searchTip = new ToolTip();
this._showGroup = true;
this._maxSelectedCount = 0x7fffffff;
this._showJ2MER1 = true;
this._showSymbianR1 = true;
this._showSMSOffline = true;
this.emptyText = " " + StringTable.Contact.ContactSearchEmptyText;
this.lastCheckIndex = -1;
this._lastSearchString = string.Empty;
this.InitializeComponent();
this._framework = framework;
this._selectedContacts = selectedContacts;
this._excludeContacts = excludeContacts;
this.xSplitContainer.SplitterMoved += new SplitterEventHandler(this.xSplitContainer_SplitterMoved);
}
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;
if (contact.Type != ContactType.MobileBuddy)
{
buddy.StatusImage = contact.Presence.Icon;
}
else
{
buddy.StatusImage = ImpsPresenceIconsEx.Instance.MobileBuddy;
}
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.AutoSize = true;
this.flowPanlContacts.Controls.Add(label);
label.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.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();
foreach (Imps.Client.Core.Contact contact in lstContacts)
{
this.AddBuddyNode(parent, contact);
}
}
private void BindGroups()
{
try
{
lock (this.CurrentUser.ContactList.Groups)
{
foreach (Imps.Client.Core.ContactGroup group in this.CurrentUser.ContactList.Groups)
{
List<Imps.Client.Core.Contact> allowContacts = this.GetAllowContacts(group.Contacts.ListContacts);
if (allowContacts.Count > 0)
{
BuddySelectionGroupNode gNode = new BuddySelectionGroupNode(group.Name + string.Format(" ({0})", allowContacts.Count), CheckState.Unchecked);
gNode.Tag = group;
this.treeContacts.AddBuddyGroup(gNode);
this.BindContacts(gNode, allowContacts);
}
}
}
this.BindNoneGroupContacts();
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
private void bindList()
{
try
{
if (this.ShowSelf)
{
this.CurrentUser.ContactList.TryFindOrCreateContactAndGetContactInfo(this.CurrentUser.Uri.Raw, out this.me, new AsyncBizOperation(), ConversationManager.ConversationNeedProperty);
this.AddMySelfNode();
}
if (this.ShowGroup)
{
this.BindGroups();
}
else
{
List<Imps.Client.Core.Contact> allowContacts = this.GetAllowContacts(this.CurrentUser.ContactList.Contacts.ListContacts);
this.BindContacts(null, allowContacts);
}
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>();
foreach (Imps.Client.Core.Contact contact in this.CurrentUser.ContactList.Contacts)
{
if ((contact.BelongToGroups.Count == 0) && this.IsContactCanShow(contact))
{
lstContacts.Add(contact);
}
}
if (lstContacts.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.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.Count < this._maxSelectedCount)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -