📄 conversationmanagerimp.cs
字号:
}
catch (Exception exception3)
{
ClientLogger.WriteGeneral(exception3.ToString());
}
}
private void form_Activated(object sender, EventArgs e)
{
(sender as ConversationWindow).BeActivated = true;
}
private void form_Deactivate(object sender, EventArgs e)
{
(sender as ConversationWindow).BeActivated = false;
}
private void form_FormClosed(object sender, FormClosedEventArgs e)
{
this.AllConversatonWindows.Remove(sender as ConversationWindow);
if (this.AllConversatonWindows.get_Count() == 0)
{
this.AllConversatonWindows = null;
}
}
public static bool IsShareContentUrl(Imps.Client.Core.User currentUser, string contactUri, string url)
{
Imps.Client.Core.Contact contact = currentUser.ContactList.Contacts[contactUri];
return (((contact != null) && ((contact.Type & ContactType.ImpsContact) != ContactType.None)) && (url.Contains("?") && url.Contains(contact.Uri.Sid.ToString())));
}
private void mainFormclosed(object sender, EventArgs e)
{
this.CloseAllConversationWindow();
}
internal void PlayMessageReceiveSource()
{
try
{
if ((this.CurrentUser.Configuration.UserSetting.SoundSetting.MsgEnabled != null) && 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 exception)
{
ClientLogger.WriteGeneral("播放声音文件失败!", exception.ToString());
}
}
public void SendFile(IWin32Window owner, string contactUri)
{
this.StartConversation(owner, ConversationOperation.SendFile, new string[] { contactUri });
}
public void SendFile(IWin32Window owner, string contactUri, params string[] filePaths)
{
if ((filePaths == null) || (filePaths.Length == 0))
{
this.SendFile(owner, contactUri);
}
else
{
this.StartConversation(owner, ConversationOperation.SendFile, filePaths, false, new string[] { contactUri });
}
}
public void SendFileAfterSelectContacts(IWin32Window owner, List<Imps.Client.Core.Contact> list)
{
try
{
using (InviteForm form = new InviteForm(this._frameworkWnd, StringTable.Conversation.MsgSelectSendFileContacts, this.CurrentUser.Configuration.SystemSetting.SysConversationSetting.MaxParticipations - 1, true, true, list, null, false, false, false, false))
{
form.SelectType = SelectContactsType.MultiConversation;
if ((ControlHelper.ShowDialogCenterOnParent(form, owner, false) == DialogResult.OK) && (form.SelectedContacts.get_Count() != 0))
{
string[] contactUris = new string[form.SelectedContacts.get_Count()];
for (int i = 0; i < form.SelectedContacts.get_Count(); i++)
{
contactUris[i] = form.SelectedContacts.get_Item(i).Uri.Raw;
}
this.StartConversation(owner, ConversationOperation.SendFile, contactUris);
}
}
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
public void SendFileToSelf(IWin32Window owner)
{
try
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Title = "打开";
if (dialog.ShowDialog() == DialogResult.OK)
{
string path = dialog.FileName;
if (Array.IndexOf<string>((this.CurrentUser.Configuration.SystemSetting.FileShareSetting.ForbiddenShareContentType + ",lnk").ToLower().Split(new char[] { ',', ';' }), Path.GetExtension(path).Replace(".", "").ToLower()) >= 0)
{
this._frameworkWnd.UnifiedMessageBox.ShowInfo(owner, StringTable.Conversation.MsgNotSupportFileFormat);
}
else
{
UploadShareContent sc = new UploadShareContent(path, this.CurrentUser, true);
if (sc.FileSize == 0)
{
this._frameworkWnd.UnifiedMessageBox.ShowInfo(owner, StringTable.Conversation.MsgCanNotSendBlankFile);
sc.Close();
}
else if (sc.FileSize > this.CurrentUser.Configuration.SystemSetting.FileShareSetting.MaxSizeWhenOffline)
{
this._frameworkWnd.UnifiedMessageBox.ShowInfo(string.Format(StringTable.Conversation.MsgSendFileLimit, StringHelper.GetFileSize((long) this.CurrentUser.Configuration.SystemSetting.FileShareSetting.MaxSizeWhenOffline)));
sc.Close();
}
else
{
sc.SendToSelf = true;
SendFileToSelfForm form = new SendFileToSelfForm(sc, this._frameworkWnd);
form.Text = "发送文件";
ControlHelper.ShowFormCenterOnParent(form, this._frameworkWnd.MainWindow);
ThreadPool.QueueUserWorkItem(new WaitCallback(sc.SendFileInThread));
}
}
}
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
public void ShowCustomEmotionManageForm(IWin32Window owner)
{
if ((this._ceManagerForm == null) || this._ceManagerForm.IsDisposed)
{
if (this._ceManagerForm != null)
{
this._ceManagerForm.Close();
}
this._ceManagerForm = new CustomEmotionManagerForm(this._frameworkWnd);
ControlHelper.ShowFormCenterOnParent(this._ceManagerForm, owner);
}
else
{
Imps.Client.Utils.Win32.NativeMethods.ShowWindow(this._ceManagerForm.Handle, 9);
this._ceManagerForm.Activate();
this._ceManagerForm.Focus();
}
}
public static void ShowMessageReceiveNotifyWindow(Form newForm, Imps.Client.Core.Contact contact, string message)
{
NotifyWindowEventHandler handler = null;
try
{
if (contact != null)
{
ReciveMessageNotifyForm notifyWindow = new ReciveMessageNotifyForm(contact, message);
notifyWindow.Cursor = Cursors.Hand;
if (handler == null)
{
handler = delegate {
if (!newForm.IsDisposed)
{
newForm.Activate();
newForm.WindowState = FormWindowState.Normal;
}
};
}
notifyWindow.ContentClick += handler;
NotifyWindowManager.Add(notifyWindow);
}
}
catch (Exception exception)
{
ClientLogger.WriteGeneral("收到消息 弹出爬楼梯窗口失败!", exception.ToString());
}
}
public void ShowScheduleSmsForm(IWin32Window owner)
{
if ((this._scheduleSmsform == null) || this._scheduleSmsform.IsDisposed)
{
this._scheduleSmsform = new ManageForm(this._frameworkWnd);
ControlHelper.ShowFormCenterOnParent(this._scheduleSmsform, owner);
if (this._scheduleSmsform != null)
{
this._scheduleSmsform.Left -= 13;
this._scheduleSmsform.Top -= 0x12;
}
}
else
{
Imps.Client.Utils.Win32.NativeMethods.ShowWindow(this._scheduleSmsform.Handle, 9);
this._scheduleSmsform.Activate();
}
}
public void StartConversation(IWin32Window owner, ConversationOperation operation, params string[] contactUris)
{
this.StartConversation(owner, operation, false, contactUris);
}
public void StartConversation(IWin32Window owner, ConversationOperation operation, bool showSelectContactsForm, params string[] contactUris)
{
if (this.CurrentUser.Status == UserAccountStatus.Logon)
{
if ((contactUris != null) && !showSelectContactsForm)
{
if (((operation == ConversationOperation.SmsChat) && (contactUris.Length == 1)) && (contactUris[0] == this.CurrentUser.Uri.Raw))
{
List<Imps.Client.Core.Contact> list = new List<Imps.Client.Core.Contact>();
Imps.Client.Core.Contact contact2 = this.CurrentUser.ContactList.FindOrCreateContact(this.CurrentUser.Uri.Raw, new AsyncBizOperation());
list.Add(contact2);
this.StartMultiSMS(owner, list);
}
else
{
this.StartConversation(owner, operation, null, false, contactUris);
}
}
else
{
List<Imps.Client.Core.Contact> list = null;
if (contactUris != null)
{
list = new List<Imps.Client.Core.Contact>();
foreach (string text in contactUris)
{
Imps.Client.Core.Contact contact = this.CurrentUser.ContactList.FindOrCreateContact(text, new AsyncBizOperation());
if (contact != null)
{
list.Add(contact);
}
}
}
switch (operation)
{
case ConversationOperation.ImChat:
this.StartConversationAfterSelectContacts(owner, list);
return;
case ConversationOperation.SmsChat:
this.StartMultiSMS(owner, list);
return;
case ConversationOperation.MmsChat:
return;
case ConversationOperation.SendFile:
this.SendFileAfterSelectContacts(owner, list);
return;
}
}
}
}
private void StartConversation(IWin32Window owner, ConversationOperation operation, object context, bool allowStranger, params string[] contactUris)
{
try
{
if ((this.CurrentUser.Status != UserAccountStatus.Logon) || (operation == ConversationOperation.MmsChat))
{
return;
}
if ((contactUris.Length == 1) && (contactUris[0] == this.CurrentUser.Uri.Raw))
{
this._frameworkWnd.ShowOptions("PsGeneral");
return;
}
List<Imps.Client.Core.Contact> list = new List<Imps.Client.Core.Contact>();
for (int i = 0; i < contactUris.Length; i++)
{
if (contactUris[i] != this.CurrentUser.Uri.Raw)
{
Imps.Client.Core.Contact contact = this.CurrentUser.ContactList.FindOrCreateContact(contactUris[i], new AsyncBizOperation());
if (contact != null)
{
list.Add(contact);
}
}
}
if ((operation == ConversationOperation.SmsChat) && (list.get_Count() > 1))
{
this.StartMultiSMS(owner, list);
return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -