?? contactlistcontrol.cs
字號:
?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.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 Imps.Client.Core.ContactCollection _searchResult;
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_fTreeShowDetail;
private bool m_fTreeShowDetailTip = true;
private ToolStripMenuItem mr_d_Detail;
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 ToolStripButton stbtnAddBuddy;
private const int TIMESPAN = 10;
private ToolStripDropDownButton tsddbDisplayMode;
private IMToolStripTextBox tstbSearch;
private SearchContactToolstrip xToolBarContactList;
public ContactListControl(IFrameworkWindow iFrameworkWnd)
{
this.InitializeComponent();
this.InitializeMyComponent();
this.InitInitPanel();
this.InitializeContextMenuComponent();
this.InitializeWndlessComponent();
this._iFrameworkWnd = iFrameworkWnd;
this.m_buddytree_widget.iframework_wnd = iFrameworkWnd;
this.CurrentUser.StatusChanged += new EventHandler<UserSatusChangedEventArgs>(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.contactList_AddBuddyResult);
this.ContactList.Changed += new EventHandler<ContactListEventArgs>(this.contactList_Changed);
this.ContactList.ContactsChanged += new EventHandler<ContactsChangedEventArgs>(this.contactList_ContactChanged);
this.ContactList.ContactGroupChanged += new EventHandler<ContactGroupChangedEventArgs>(this.contactList_ContactGroupChanged);
this.tstbSearch.TextBox.KeyDown += new KeyEventHandler(this.tstbSearch_KeyDown);
}
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)
{
this.tstbSearch.Text = string.Empty;
this._currentTreeGroupByType = (ContactTreeGroupByType) Enum.Parse(typeof(ContactTreeGroupByType), this.CurrentUser.Configuration.UserSetting.MainWindowSetting.GroupByMode.Value.ToString());
this.changeTreeShowDetail(this.CurrentUser.Configuration.UserSetting.MainWindowSetting.ShowDetails.Value, true);
this.changeTreeShowDetailTip(this.CurrentUser.Configuration.UserSetting.MainWindowSetting.ShowMoreDetails.Value, true);
this.changeTreeGroupByType(this._currentTreeGroupByType, true);
this.m_buddytree_widget.display_trails = false;
if ((this.CurrentUser.ContactList.Contacts.Count == 0) && (this._forceDisplayGroup == true))
{
this.setWizardUiOnNoneContact(true);
}
this._contactNotifyWindowManager.ShowWindow();
}
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
private void bindSearchResult()
{
this.m_buddytree_widget.remove_allitems(false);
if (this._searchResult.Count > 0)
{
this.m_buddytree_widget.Visible = true;
foreach (Imps.Client.Core.Contact contact in this._searchResult)
{
this.contactNodes_Add(contact);
}
this.m_buddytree_widget.paint();
}
else
{
}
}
private void cacheContactInfoChanged(Imps.Client.Core.Contact contact)
{
lock (this._contactInfoChangedCol)
{
if (this._contactInfoChangedCol.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.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(bool command, bool forceUpdate)
{
if ((command != this.m_fTreeShowDetail) || forceUpdate)
{
this.m_fTreeShowDetail = command;
this.mr_d_Detail.Checked = this.m_fTreeShowDetail;
this.CurrentUser.Configuration.UserSetting.MainWindowSetting.ShowDetails.ProposedValue = this.m_fTreeShowDetail;
this.m_buddytree_widget.show_detail = this.m_fTreeShowDetail;
}
}
private void changeTreeShowDetailTip(bool command, bool forceUpdate)
{
if ((command != this.m_fTreeShowDetailTip) || forceUpdate)
{
this.m_fTreeShowDetailTip = command;
this.mr_d_DetailMouseOver.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.WriteException(exception);
}
}
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)
{
foreach (ContactChangedEventArgs args in e.ContactChangedEventArgsCollection)
{
Imps.Client.Core.Contact contact = args.Contact;
if (args.ContactEventType == ContactEventType.PresenceChanged)
{
this.cacheContactPresenceChanged(args);
continue;
}
if (args.ContactEventType == ContactEventType.PropertiesChanged)
{
if (args.ContactInfoPropertiesChangedEventArgs.ContainsAnyOfProperties(new string[] { "nickname", "name", "DisplayName", "impresa" }))
{
this.cacheContactInfoChanged(contact);
}
if (args.ContactInfoPropertiesChangedEventArgs.ContainsProperty("Portrait"))
{
this.m_buddytree_widget.update_contact_info(contact, ContactEventType.PropertiesChanged, false, true);
}
continue;
}
if (args.ContactEventType == ContactEventType.Added)
{
this.contactNodes_Add(contact);
this.m_buddytree_widget.sort_allitems(true);
continue;
}
if (args.ContactEventType == ContactEventType.BlockChanged)
{
this.m_buddytree_widget.update_contact_info(contact, ContactEventType.BlockChanged, false, true);
continue;
}
if (args.ContactEventType == ContactEventType.BelongGroupChanged)
{
this.contactNodes_Update(contact);
this.m_buddytree_widget.sort_allitems(true);
continue;
}
if (args.ContactEventType == ContactEventType.Deleted)
{
this.contactNodes_Delete(contact);
}
}
}
}
catch (Exception exception)
{
this.m_buddytree_widget.sort_allitems(true);
ClientLogger.WriteException(exception);
}
}
private void contactList_ContactGroupChanged(object sender, ContactGroupChangedEventArgs e)
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -