📄 ivrmanager.cs
字号:
namespace Imps.Client.Pc
{
using Imps.Client;
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, (IntPtr) 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.get_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.Status == UserAccountStatus.Logon)
{
if (this.CurrentUser.IVRManager.IVRStartTime.get_Count() >= 3)
{
int num = 0;
List<DateTime>.Enumerator enumerator = this.CurrentUser.IVRManager.IVRStartTime.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
DateTime time = enumerator.get_Current();
if (DateTime.Now.Subtract(time).TotalSeconds < 60)
{
num++;
}
}
}
finally
{
enumerator.Dispose();
}
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 text in contactUris)
{
Imps.Client.Core.Contact contact = this.CurrentUser.ContactList.Contacts[text];
if (((contact != null) && !selectedContacts.Contains(contact)) && contact.EnableIvr)
{
selectedContacts.Add(contact);
}
}
}
using (InviteForm form = new InviteForm(this._frameworkWnd, StringTable.Conversation.MsgSelectIVRContacts, this.CurrentUser.Configuration.SystemSetting.IvrSetting.MaxNumForIVR - 1, true, true, selectedContacts, null, true))
{
form.SelectType = SelectContactsType.Ivr;
if ((ControlHelper.ShowDialogCenterOnParent(form, owner, false) == DialogResult.OK) && (form.SelectedContacts.get_Count() != 0))
{
string[] textArray = new string[form.SelectedContacts.get_Count()];
for (int i = 0; i < form.SelectedContacts.get_Count(); i++)
{
textArray[i] = form.SelectedContacts.get_Item(i).Uri.Raw;
}
this.StartIVR(owner, textArray);
}
return;
}
}
if (contactUris.Length != 0)
{
if ((this._form != null) && !this._form.IsDisposed)
{
if (((contactUris.Length == 1) && (this._form.OwnerDialog.IVRList.get_Count() == 1)) && (this._form.OwnerDialog.IVRList.get_Item(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 text2 in contactUris)
{
Imps.Client.Core.Contact contact2 = this.CurrentUser.ContactList.FindOrCreateContact(text2, new AsyncBizOperation());
if (((contact2 != null) && !contacts.Contains(contact2)) && contact2.EnableIvr)
{
contacts.Add(contact2);
}
}
if (contacts.get_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 + -