?? ivrmanager.cs
字號:
?namespace Imps.Client.Pc
{
using Imps.Client.Core;
using Imps.Client.Resource;
using Imps.Client.Utils;
using Imps.Client.Utils.Win32;
using Imps.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Media;
using System.Windows.Forms;
public class IVRManager : IIVRManager
{
private IVRFormBase _form;
private IFrameworkWindow _frameworkWnd;
public IVRManager(IFrameworkWindow frameworkWin)
{
this._frameworkWnd = frameworkWin;
this.CurrentUser.IVRManager.ReceiveIVRInvite += new EventHandler<IVRDialogEventArgs>(this.IVRManager_ReceiveIVRInvite);
}
private void IVRManager_ReceiveIVRInvite(object sender, IVRDialogEventArgs e)
{
UiErrorHelper.HandEventSafely(this._frameworkWnd, delegate {
this.PlaySource();
IVRDialog dialog = e.Dialog;
if (dialog.IVRList.Count != 0)
{
IVRFormBase flashForm = new SingleBeIviteForm(this._frameworkWnd, this, dialog) {
WindowState = FormWindowState.Minimized,
StartPosition = FormStartPosition.CenterScreen
};
flashForm.Show();
ControlHelper.FlashWindow(flashForm);
if ((this.CurrentUser.Presence.MainPresence != MainPresence.Busy) && (this.CurrentUser.Presence.MainPresence != MainPresence.DoNotDisturb))
{
ConversationManagerImp.ShowMessageReceiveNotifyWindow(flashForm, e.Dialog.InviteContactIVR.Contact, string.Format("{0}\r\n邀請您手機語聊!", e.Dialog.InviteContactIVR.Contact.DisplayName));
}
}
});
}
private void PlaySource()
{
try
{
if (File.Exists((string) this.CurrentUser.Configuration.UserSetting.SoundSetting.MsgNotify))
{
using (SoundPlayer player = new SoundPlayer((string) this.CurrentUser.Configuration.UserSetting.SoundSetting.MsgNotify))
{
player.Play();
}
}
}
catch (Exception)
{
}
}
public void ShowIVRControlPanel(IWin32Window owner)
{
if (owner is Form)
{
this._form.StartPosition = FormStartPosition.Manual;
Form form = owner as Form;
if ((form.WindowState == FormWindowState.Maximized) || (form.WindowState == FormWindowState.Normal))
{
this._form.Location = form.Location;
}
else
{
this._form.StartPosition = FormStartPosition.CenterParent;
}
}
this._form.Show();
}
public void StartIVR(IWin32Window owner, params string[] contactUris)
{
this.StartIVR(owner, false, contactUris);
}
public void StartIVR(IWin32Window owner, bool showSelectContactsForm, params string[] contactUris)
{
try
{
if (this.CurrentUser.IVRManager.IVRStartTime.Count >= 3)
{
int num = 0;
foreach (DateTime time in this.CurrentUser.IVRManager.IVRStartTime)
{
if (DateTime.Now.Subtract(time).TotalSeconds < 60.0)
{
num++;
}
}
if (num >= 3)
{
this._frameworkWnd.UnifiedMessageBox.ShowInfo(owner, "一分鐘內只能發起三次手機語聊,請稍后再重新發起!");
return;
}
}
if (showSelectContactsForm || (contactUris == null))
{
List<Imps.Client.Core.Contact> selectedContacts = null;
if ((contactUris != null) && (contactUris.Length != 0))
{
selectedContacts = new List<Imps.Client.Core.Contact>();
foreach (string str in contactUris)
{
Imps.Client.Core.Contact item = this.CurrentUser.ContactList.Contacts[str];
if (((item != null) && !selectedContacts.Contains(item)) && item.EnableIvr)
{
selectedContacts.Add(item);
}
}
}
InviteForm form = new InviteForm(this._frameworkWnd, StringTable.Conversation.MsgSelectIVRContacts, this.CurrentUser.Configuration.SystemSetting.IvrSetting.MaxNumForIVR - 1, true, true, selectedContacts, null, true);
if (owner is Form)
{
form.Location = (owner as Form).Location;
}
if ((form.ShowDialog(owner) == DialogResult.OK) && (form.SelectedContacts.Count != 0))
{
string[] strArray = new string[form.SelectedContacts.Count];
for (int i = 0; i < form.SelectedContacts.Count; i++)
{
strArray[i] = form.SelectedContacts[i].Uri.Raw;
}
this.StartIVR(owner, strArray);
}
}
else if (contactUris.Length != 0)
{
if ((this._form != null) && !this._form.IsDisposed)
{
if (((contactUris.Length == 1) && (this._form.OwnerDialog.IVRList.Count == 1)) && (this._form.OwnerDialog.IVRList[0].Contact.Uri.Raw == contactUris[0]))
{
Imps.Client.Utils.Win32.NativeMethods.ShowWindow(this._form.Handle, 9);
this._form.Activate();
return;
}
if (this._frameworkWnd.UnifiedMessageBox.ShowConfirmation(owner, StringTable.IVR.MsgConfirmExistIVR) != DialogResult.Yes)
{
return;
}
this._form.Close();
this._form = null;
}
List<Imps.Client.Core.Contact> contacts = new List<Imps.Client.Core.Contact>();
foreach (string str2 in contactUris)
{
Imps.Client.Core.Contact contact = null;
try
{
this.CurrentUser.ContactList.TryFindOrCreateContactAndGetContactInfo(str2, out contact, new AsyncBizOperation(), ConversationManager.ConversationNeedProperty);
}
catch
{
}
if (((contact != null) && !contacts.Contains(contact)) && contact.EnableIvr)
{
contacts.Add(contact);
}
}
if (contacts.Count != 0)
{
IVRDialog dialog = this.CurrentUser.IVRManager.OpenIVRDialog(contacts);
if (!dialog.IsMultiDialog)
{
this._form = new SingleIVRForm(this._frameworkWnd, this, dialog);
}
else
{
this._form = new MultiIVRForm(this._frameworkWnd, this, dialog);
}
this._form.StartPosition = FormStartPosition.CenterScreen;
this._form.Show();
dialog.SendInvite();
}
}
}
catch (Exception exception)
{
UiErrorHelper.HandExceptionSafely(this._frameworkWnd, exception);
}
}
public Imps.Client.Core.User CurrentUser
{
get
{
return this._frameworkWnd.AccountManager.CurrentUser;
}
}
public IFrameworkWindow FrameworkWin
{
get
{
return this._frameworkWnd;
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -