?? contactmanager.cs
字號:
?namespace Imps.Client.Pc
{
using Imps.Client;
using Imps.Client.Core;
using Imps.Client.Pc.BizControls;
using Imps.Client.Pc.UIContactList;
using Imps.Client.Pc.UIContactList.AddBuddy;
using Imps.Client.Resource;
using Imps.Client.Utils;
using Imps.Common;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Windows.Forms;
public class ContactManager : IContactManager
{
private Imps.Client.Pc.UIContactList.ContactListControl _contactListControl;
private ContactNotifyWindowManager _contactNotifyWndManger;
private IFrameworkWindow _frameworkWnd;
private InviteIICForm _inviteIICFForm;
private ToolStripMenuItem _menuItem;
private ToolStripItem[] _menuItemsOperation;
private ToolStripMenuItem _miAddContact;
private ToolStripMenuItem _miAddGroup;
private ToolStripMenuItem _miBlackList;
private ToolStripMenuItem _miBlockBuddy;
private ToolStripMenuItem _miExport;
private ToolStripMenuItem _miImport;
private ToolStripMenuItem _miInviteIIC;
private ToolStripMenuItem _miSort;
private Dictionary<string, ProfileForm> _profileForms;
private Dictionary<string, ProfileFormVodafone> _profileFormsVodafone;
private SendRequestForm _sendRequestForm;
private Imps.Client.Core.User _user;
public ContactManager(IFrameworkWindow framework)
{
this._frameworkWnd = framework;
this._user = this._frameworkWnd.AccountManager.CurrentUser;
this.buildMenuItem();
}
private void _menuItem_DropDownOpening(object sender, EventArgs e)
{
try
{
if ((this._miSort.DropDown == null) || (this._miSort.DropDown.Items.Count == 0))
{
this._miSort.DropDown = ((Imps.Client.Pc.UIContactList.ContactListControl) this.ContactListControl).DisplayMenu;
}
bool flag = this._user.Status == UserAccountStatus.Logon;
this._miAddContact.Enabled = flag;
this._miInviteIIC.Enabled = flag;
this._miAddGroup.Enabled = (flag && (this._contactListControl != null)) && (this._contactListControl.CurrentTreeGroupByType == ContactTreeGroupByType.Group);
this._miSort.Enabled = flag;
this._miImport.Enabled = flag;
this._miExport.Enabled = flag;
this._miBlockBuddy.Enabled = flag;
this._miBlackList.Enabled = flag;
}
catch (Exception exception)
{
this._frameworkWnd.UnifiedMessageBox.ShowException(exception);
}
}
private void _miBlackList_Click(object sender, EventArgs e)
{
UiErrorHelper.HandEventSafely(this._frameworkWnd, delegate {
this._frameworkWnd.ShowOptions("PsBlackList");
});
}
private void _miBlockBuddy_Click(object sender, EventArgs e)
{
}
public void AddBuddyByMobileNo(string mobileNo, string domain, int? targetGroupId, string localName, string desc, bool sendRequestAgain, bool copyWhenExist, bool? invite, AsyncBizOperation op)
{
Imps.Client.Core.ContactList.AddBuddyExtraData extraData = new Imps.Client.Core.ContactList.AddBuddyExtraData();
extraData.WhoAmI = desc;
this._user.ContactList.AsyncAddBuddy(true, mobileNo, domain, targetGroupId, localName, extraData, sendRequestAgain, copyWhenExist, invite, op);
}
public void AddBuddyBySid(long sid, string domain, int? targetGroupId, string localName, string desc, bool sendRequestAgain, bool copyWhenExist, AsyncBizOperation op)
{
Imps.Client.Core.ContactList.AddBuddyExtraData extraData = new Imps.Client.Core.ContactList.AddBuddyExtraData();
extraData.WhoAmI = desc;
this._user.ContactList.AsyncAddBuddy(false, sid.ToString(), domain, targetGroupId, localName, extraData, sendRequestAgain, copyWhenExist, null, op);
}
public void AddBuddyByUri(string uri, int? targetGroupId, string localName, string desc, bool sendRequestAgain, bool copyWhenExist, bool? invite, AsyncBizOperation op)
{
IicUri uri2 = new IicUri(uri);
if (uri2.Belongs(IicUriType.Tel))
{
this.AddBuddyByMobileNo(uri2.MobileNo, uri2.Domain, targetGroupId, localName, desc, sendRequestAgain, copyWhenExist, invite, op);
}
else if (uri2.Belongs(IicUriType.Sip))
{
this.AddBuddyBySid(uri2.Sid, uri2.Domain, targetGroupId, localName, desc, sendRequestAgain, copyWhenExist, op);
}
}
public void AddToBlackList(IicUri uri, AsyncBizOperation op)
{
if (uri.IsValid)
{
this._user.ContactList.AsyncAddToBlackList(uri, op);
}
}
private void buildMenuItem()
{
this._menuItem = new ToolStripMenuItem(StringTable.MI_ContactList);
this._miSort = new ToolStripMenuItem(StringTable.MI_CL_Sort);
this._miAddContact = new ToolStripMenuItem(StringTable.MI_CL_AddContact, ImpsIcons.AddBuddy, new EventHandler(this.miAddContact_Click));
this._miAddGroup = new ToolStripMenuItem(StringTable.MI_CL_AddGroup, null, new EventHandler(this.miAddGroup_Click));
this._miImport = new ToolStripMenuItem(StringTable.MI_CL_Import, ImpsResources.GetImage("Images.Import.png"), new EventHandler(this.miImport_Click));
this._miExport = new ToolStripMenuItem(StringTable.MI_CL_Export, ImpsResources.GetImage("Images.Export.png"), new EventHandler(this.miExport_Click));
this._miInviteIIC = new ToolStripMenuItem(StringTable.MI_CL_InviteIIC, null, new EventHandler(this.miInviteIIC_Click));
this._miBlockBuddy = new ToolStripMenuItem("加入黑名單(&B)...", ImpsPresenceIcons.Instance.BlockIcon, new EventHandler(this._miBlockBuddy_Click));
this._miBlackList = new ToolStripMenuItem("黑名單管理(&L)...", null, new EventHandler(this._miBlackList_Click));
this._menuItem.DropDown = new menu_widget(this._frameworkWnd.ComponentContainer);
this._menuItem.DropDownOpening += new EventHandler(this._menuItem_DropDownOpening);
ToolStripSeparator separator = new ToolStripSeparator();
separator.Enabled = false;
ToolStripSeparator separator2 = new ToolStripSeparator();
separator2.Enabled = false;
this._menuItem.DropDown.Items.AddRange(new ToolStripItem[] { this._miAddContact, this._miInviteIIC, this._miAddGroup, this._miBlackList, separator, this._miSort, separator2, this._miImport, this._miExport });
}
private void BuildOperationMenuItems()
{
bool matchingEnabled = this._frameworkWnd.AccountManager.CurrentUser.Configuration.SystemSetting.ServerUriSetting.MatchingEnabled;
List<ToolStripItem> list = new List<ToolStripItem>();
ToolStripItem item = new ToolStripMenuItem(StringTable.MI_IM_Contacts, ImpsResources.GetImage("Images.Chat.png"), new EventHandler(this.mi_Conversion_Click));
list.Add(item);
item = new ToolStripMenuItem(StringTable.MI_SMS_Contacts, ImpsResources.GetImage("Images.Sms.png"), new EventHandler(this.mi_Sms_Click));
list.Add(item);
item = new ToolStripMenuItem(StringTable.MI_Ivr_Contacts, ImpsResources.GetImage("Images.Ivr.png"), new EventHandler(this.mi_Ivr_Click));
list.Add(item);
item = new ToolStripMenuItem(StringTable.MI_File_Contacts, ImpsResources.GetImage("Images.FileShare.png"), new EventHandler(this.mi_File_Click));
list.Add(item);
ToolStripSeparator separator = new ToolStripSeparator();
separator.Enabled = false;
list.Add(separator);
item = new ToolStripMenuItem(StringTable.MI_SendSmsToMe, null, new EventHandler(this.mi_SendSmsToMe_Click));
list.Add(item);
item = new ToolStripMenuItem(StringTable.MI_SendFileToMe, null, new EventHandler(this.mi_SendFileToMe_Click));
list.Add(item);
if (matchingEnabled)
{
ToolStripSeparator separator2 = new ToolStripSeparator();
separator2.Enabled = false;
list.Add(separator2);
item = new ToolStripMenuItem(StringTable.MI_Match_R, null, new EventHandler(this.mi_RMatch_Click));
list.Add(item);
item = new ToolStripMenuItem(StringTable.MI_Match_C, null, new EventHandler(this.mi_CMatch_Click));
list.Add(item);
}
this._menuItemsOperation = list.ToArray();
}
public void ExportContacts()
{
}
private InviteIICForm GetInnerInviteIICFForm(string mobileNo)
{
if ((this._inviteIICFForm == null) || this._inviteIICFForm.IsDisposed)
{
this._inviteIICFForm = new InviteIICForm(this._frameworkWnd, mobileNo);
}
else
{
this._inviteIICFForm.MobileNo = mobileNo;
}
return this._inviteIICFForm;
}
public void ImportContacts()
{
}
void IContactManager.OnOperationMenuItemsOpening(ToolStripMenuItem operationMenuItem)
{
bool flag = this._user.Status == UserAccountStatus.Logon;
foreach (ToolStripItem item in this._menuItemsOperation)
{
if (item is ToolStripSeparator)
{
item.Enabled = false;
}
else
{
item.Enabled = flag;
}
}
}
private void mi_CMatch_Click(object sender, EventArgs e)
{
this._frameworkWnd.ContactManager.ShowConditionalMatchWindow();
}
private void mi_Conversion_Click(object sender, EventArgs e)
{
try
{
this._frameworkWnd.ConversationManager.StartConversation(this._frameworkWnd as Form, ConversationOperation.ImChat, null);
}
catch
{
}
}
private void mi_File_Click(object sender, EventArgs e)
{
this._frameworkWnd.ConversationManager.StartConversation(this._frameworkWnd as Form, ConversationOperation.SendFile, null);
}
private void mi_Ivr_Click(object sender, EventArgs e)
{
this._frameworkWnd.IVRManager.StartIVR(this._frameworkWnd as Form, null);
}
private void mi_RMatch_Click(object sender, EventArgs e)
{
this._frameworkWnd.ContactManager.ShowRadomMatchWindow();
}
private void mi_SendFileToMe_Click(object sender, EventArgs e)
{
this._frameworkWnd.ConversationManager.SendFileToSelf(this._frameworkWnd as Form);
}
private void mi_SendSmsToMe_Click(object sender, EventArgs e)
{
this._frameworkWnd.ConversationManager.StartConversation(this._frameworkWnd as Form, ConversationOperation.SmsChat, new string[] { this._frameworkWnd.AccountManager.CurrentUser.Uri.Raw });
}
private void mi_Sms_Click(object sender, EventArgs e)
{
try
{
this._frameworkWnd.ConversationManager.StartConversation(this._frameworkWnd as Form, ConversationOperation.SmsChat, null);
}
catch
{
}
}
private void miAddContact_Click(object sender, EventArgs e)
{
try
{
this.ShowAddBuddyWindow(null, string.Empty, null, string.Empty, null, ContactType.ImpsContact);
}
catch (Exception exception)
{
this._frameworkWnd.UnifiedMessageBox.ShowException(exception);
}
}
private void miAddGroup_Click(object sender, EventArgs e)
{
try
{
this.ShowGroupCreateWindow(this._frameworkWnd as Form);
}
catch (Exception exception)
{
this._frameworkWnd.UnifiedMessageBox.ShowException(exception);
}
}
private void miExport_Click(object sender, EventArgs e)
{
try
{
this._frameworkWnd.ImportExportManager.Export();
}
catch (ApplicationException exception)
{
this._frameworkWnd.UnifiedMessageBox.ShowError(exception.Message);
}
catch (Exception exception2)
{
this._frameworkWnd.UnifiedMessageBox.ShowException(exception2);
}
}
private void miImport_Click(object sender, EventArgs e)
{
try
{
this._frameworkWnd.ImportExportManager.Import();
}
catch (Exception exception)
{
this._frameworkWnd.UnifiedMessageBox.ShowException(exception);
}
}
private void miInviteIIC_Click(object sender, EventArgs e)
{
try
{
this.ShowInviteIICWindow(null);
}
catch
{
}
}
public void RemoveFromBlackList(IicUri uri, AsyncBizOperation op)
{
if (uri.IsValid)
{
this._user.ContactList.AsyncRemoveFromBlackList(uri, op);
}
}
public void ShowAddBuddyWindow(IWin32Window owner, string mobileNo, long? sid, string desc, int? targetGroupId, ContactType contactType)
{
SendRequestForm innerSendRequestFrom = this.InnerSendRequestFrom;
innerSendRequestFrom.MobileNo = mobileNo;
innerSendRequestFrom.Sid = sid;
innerSendRequestFrom.Desc = desc;
innerSendRequestFrom.TargetGroupId = targetGroupId;
innerSendRequestFrom.ContactType = contactType;
Form parent = owner as Form;
if (parent == null)
{
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -