📄 conversationmanagerimp.cs
字号:
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.SoundEnabled != 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, new string[] { contactUri });
}
}
public void SendFileAfterSelectContacts(IWin32Window owner, List<Imps.Client.Core.Contact> list)
{
try
{
InviteForm form = new InviteForm(this._frameworkWnd, StringTable.Conversation.MsgSelectSendFileContacts, this.CurrentUser.Configuration.SystemSetting.SysConversationSetting.MaxParticipations - 1, true, true, list, null, false, false, false, false);
if (owner is Form)
{
form.Location = (owner as Form).Location;
}
if ((form.ShowDialog(owner) == DialogResult.OK) && (form.SelectedContacts.Count != 0))
{
string[] contactUris = new string[form.SelectedContacts.Count];
for (int i = 0; i < form.SelectedContacts.Count; i++)
{
contactUris[i] = form.SelectedContacts[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 fileName = dialog.FileName;
if (Array.IndexOf<string>((this.CurrentUser.Configuration.SystemSetting.FileShareSetting.ForbiddenShareContentType + ",lnk").ToLower().Split(new char[] { ',', ';' }), Path.GetExtension(fileName).Replace(".", "").ToLower()) >= 0)
{
this._frameworkWnd.UnifiedMessageBox.ShowInfo(owner, StringTable.Conversation.MsgNotSupportFileFormat);
}
else
{
UploadShareContent sc = new UploadShareContent(fileName, this.CurrentUser, true);
if (sc.FileSize == 0L)
{
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 as Form);
ThreadPool.QueueUserWorkItem(new WaitCallback(sc.SendFileInThread));
}
}
}
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
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 {
newForm.Activate();
newForm.WindowState = FormWindowState.Normal;
};
}
notifyWindow.ContentClick += handler;
NotifyWindowManager.Add(notifyWindow);
}
}
catch (Exception exception)
{
ClientLogger.WriteGeneral("收到消息 弹出爬楼梯窗口失败!", exception.ToString());
}
}
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 ((contactUris != null) && !showSelectContactsForm)
{
if (((operation == ConversationOperation.SmsChat) && (contactUris.Length == 1)) && (contactUris[0] == this.CurrentUser.Uri.Raw))
{
Imps.Client.Core.Contact contact2;
List<Imps.Client.Core.Contact> list2 = new List<Imps.Client.Core.Contact>();
this.CurrentUser.ContactList.TryFindOrCreateContactAndGetContactInfo(this.CurrentUser.Uri.Raw, out contact2, new AsyncBizOperation(), ConversationManager.ConversationNeedProperty);
list2.Add(contact2);
this.StartMultiSMS(owner, list2);
}
else
{
this.StartConversation(owner, operation, null, contactUris);
}
}
else
{
List<Imps.Client.Core.Contact> list = null;
if (contactUris != null)
{
list = new List<Imps.Client.Core.Contact>();
foreach (string str in contactUris)
{
Imps.Client.Core.Contact item = this.CurrentUser.ContactList.FindOrCreateContact(str, new AsyncBizOperation(), false);
if (item != null)
{
list.Add(item);
}
}
}
switch (operation)
{
case ConversationOperation.ImChat:
this.StartConversationAfterSelectContacts(owner, list);
return;
case ConversationOperation.SmsChat:
this.StartMultiSMS(owner, list);
break;
case ConversationOperation.MmsChat:
break;
case ConversationOperation.SendFile:
this.SendFileAfterSelectContacts(owner, list);
return;
default:
return;
}
}
}
private void StartConversation(IWin32Window owner, ConversationOperation operation, object context, params string[] contactUris)
{
try
{
if (operation != ConversationOperation.MmsChat)
{
if ((contactUris.Length == 1) && (contactUris[0] == this.CurrentUser.Uri.Raw))
{
this._frameworkWnd.ShowOptions("PsGeneral");
}
else
{
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 item = this.CurrentUser.ContactList.FindOrCreateContact(contactUris[i], new AsyncBizOperation(), false);
if (item != null)
{
list.Add(item);
}
}
}
if ((operation == ConversationOperation.SmsChat) && (list.Count > 1))
{
this.StartMultiSMS(owner, list);
}
else
{
if (list.Count > 1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -