📄 conversationwindow.cs
字号:
{
long? sid = null;
string mobileNo = string.Empty;
if (uri2.Belongs(IicUriType.Sip))
{
sid = new long?(uri2.Sid);
}
else
{
mobileNo = uri2.MobileNo;
}
if (!contact.Uri.IsVodafoneUri)
{
this._frameworkWnd.ContactManager.ShowAddBuddyWindow(this, mobileNo, sid, string.Empty, null, ContactType.ImpsContact);
}
else
{
this._frameworkWnd.ContactManager.ShowAddBuddyWindow(this, mobileNo, sid, string.Empty, null, ContactType.Vodafone);
}
}
}
}
catch (Exception exception)
{
this.HandleException(exception);
}
}
private void AppendContentMessage(string content, string color, string face, string size)
{
if (!string.IsNullOrEmpty(color))
{
content = string.Format("<font size={0} face={1} color={2}>{3}</font>", new object[] { size, face, color, content });
}
this.AppendMessage(new CommonMessage(this.CurrentConversation.CurrentDialog, content));
}
private void AppendIMOrSMSMessage(Imps.Client.Core.Message msg)
{
msg.NewLine = this.CurrentConversation.CurrentDialog.MsgManager.IsMessageNewLine(msg);
if (!msg.NewLine)
{
this._historyChatManager.SelectionIdent = this._richIdentity;
this._historyChatManager.AppentString(msg.Content, this._messageEmotionSize);
}
else
{
this._historyChatManager.SelectionIdent = 0;
this._historyChatManager.AppentString(string.Format(StringTable.Conversation.MsgSendIMFormat, ConvertString(msg.From)), this._smallSize);
try
{
this._historyChatManager.SelectionStart = this._historyChatManager.Length;
if (this.CurrentConversation.CurrentDialog.Status != DialogStatus.Invited)
{
this._historyChatManager.AppendRichTextPlainString(msg.MsgTime);
}
else
{
this._historyChatManager.AppendRichTextPlainString(string.Format("({0}):", DateTime.Now.ToString("HH:mm")));
}
}
catch (Exception exception)
{
this.HandleException(exception);
}
this._historyChatManager.AppendCRLF();
this._historyChatManager.SelectionIdent = this._richIdentity;
this._historyChatManager.AppentString(msg.Content, this._messageEmotionSize);
}
}
private void AppendMessage(Imps.Client.Core.Message msg)
{
if (!this.rtfHistory.IsDisposed)
{
try
{
if (!this.BeActivated || (base.WindowState == FormWindowState.Minimized))
{
ControlHelper.FlashWindow(this);
this._manager.PlayMessageReceiveSource();
}
}
catch (Exception exception)
{
this.HandleException(exception);
}
try
{
if ((this.CurrentConversation == null) || (this.CurrentConversation.CurrentDialog == null))
{
this.initConversation();
}
this._historyChatManager.SelectionStart = this._historyChatManager.Length;
if ((msg is IMMessage) || (msg is SMSMessage))
{
this.AppendIMOrSMSMessage(msg);
}
else
{
if (msg is CommonMessage)
{
this._historyChatManager.SelectionIdent = 0;
this._historyChatManager.AppentString(msg.Content, this._smallSize);
}
else if (msg is ShareContentMessage)
{
this.AppendShareContentMessage(msg as ShareContentMessage);
}
else if (msg is ParticipantJoinAndLeftMessage)
{
this.AppendParticipantJoinAndLeftMessage(msg as ParticipantJoinAndLeftMessage);
}
else
{
this._historyChatManager.SelectionIdent = 0;
this._historyChatManager.AppentString(msg.Content, this._smallSize);
}
if ((this.CurrentConversation != null) && (this.CurrentConversation.CurrentDialog != null))
{
this.CurrentConversation.CurrentDialog.MsgManager.SetNextNewLine();
}
}
this._historyChatManager.AppendCRLF();
this._historyChatManager.ScrollToEnd();
}
catch (Exception exception2)
{
this.HandleException(exception2);
}
}
}
private void AppendNudgeMessage(string content)
{
this._historyChatManager.AppendCRLF();
this.AppendContentMessage(content, "\"5, 86, 168\"", "宋体", "10.5");
this.AppendSeparateImage();
this._historyChatManager.AppendCRLF();
}
private void AppendParticipantJoinAndLeftMessage(ParticipantJoinAndLeftMessage msg)
{
this._historyChatManager.SelectionIdent = 0;
Bitmap image = Bitmap.FromHicon(ImpsIcons.Logo.Handle);
this._historyChatManager.AppendImage(image, string.Empty, OleKeyManager.Instance.NewKey, image.Size);
this._historyChatManager.AppentString(msg.Content, this._smallSize);
this._historyChatManager.AppendCRLF();
this._historyChatManager.AppendImage(this._separate, string.Empty, OleKeyManager.Instance.NewKey, this._separate.Size);
this._historyChatManager.AppendCRLF();
}
private void AppendSendMessageError(string message, string error)
{
try
{
message = Imps.Utils.TagParser.TagParser.Create(message, false).Text;
message = StringHelper.GetPaddingStringEndEllipsis(message, 0x12);
message = message + " ";
message = StringHelper.EncodString(message);
message = string.Format(StringTable.Conversation.MsgMessageSendFailed, message, error);
this.AppendMessage(new CommonMessage(null, message));
}
catch (Exception exception)
{
this.HandleException(exception);
}
}
private void AppendSeparateImage()
{
this._historyChatManager.AppendImage(this._separate, string.Empty, OleKeyManager.Instance.NewKey, this._separate.Size);
}
private void AppendShareContentMessage(ShareContentMessage msg)
{
this._historyChatManager.SelectionIdent = 0;
this._historyChatManager.AppendImage(this._separate, string.Empty, OleKeyManager.Instance.NewKey, this._separate.Size);
this._historyChatManager.AppendCRLF();
this._historyChatManager.AppendCRLF();
Image image = ImpsResources.GetImage("Images.Sending.png");
if (msg.IsFailed)
{
image = ImpsResources.GetImage("Images.SendFailed.png");
}
this._historyChatManager.AppendImage(image, string.Empty, OleKeyManager.Instance.NewKey, image.Size);
this._historyChatManager.AppentString(" " + msg.Content, this._smallSize);
if (msg.IsDownloadComplete)
{
this._historyChatManager.AppendCRLF();
OleKey newKey = OleKeyManager.Instance.NewKey;
newKey.Tag = Path.GetDirectoryName(msg.Context.FilePath);
this._historyChatManager.AppentString(" ");
this._historyChatManager.InsertLink(this._historyChatManager.Length - 1, newKey, "打开目录", "SYSTEM");
this._historyChatManager.AppentString(" ");
this._historyChatManager.InsertLink(this._historyChatManager.Length - 1, OleKeyManager.Instance.NewKey, msg.Context.FilePath, "SYSTEM");
}
this._historyChatManager.AppendCRLF();
this.AppendSeparateImage();
this._historyChatManager.AppendCRLF();
}
private void Application_Idle(object sender, EventArgs e)
{
try
{
Application.Idle -= new EventHandler(this.Application_Idle);
this.CaptureScreenAfterIdle();
if (base.WindowState == FormWindowState.Minimized)
{
Imps.Client.Utils.Win32.NativeMethods.ShowWindow(base.Handle, 9);
}
}
finally
{
if (base.Opacity == 0)
{
base.Opacity = 1;
}
}
}
private void BlockContact(Imps.Client.Core.Contact contact)
{
AsyncBizOperation op = new AsyncBizOperation();
if (contact.IsInBlackList)
{
this.CurrentUser.ContactList.AsyncRemoveFromBlackList(contact.Uri, op);
}
else
{
this.CurrentUser.ContactList.AsyncAddToBlackList(contact.Uri, op);
}
}
private void btnSend_ButtonClick(object sender, EventArgs e)
{
this.SendMessage();
}
private void BuildShareContent(ShareContent sc)
{
if (!sc.IsCancel && !base.IsDisposed)
{
OleKey newKey = OleKeyManager.Instance.NewKey;
this._dicShareContent.Add(newKey, sc);
Image defaultPortrait = null;
AmigoImage image2 = null;
if (!string.IsNullOrEmpty(sc.PreviewImageBase64String))
{
defaultPortrait = ImageHelper.Base64ToImage(sc.PreviewImageBase64String);
}
if (defaultPortrait == null)
{
try
{
Bitmap bitmap;
if (this._syncObjTempImageFile == null)
{
this._syncObjTempImageFile = new object();
}
lock (this._syncObjTempImageFile)
{
string path = sc.FilePath;
if (!File.Exists(sc.FilePath))
{
string text2 = this.CurrentUser.Configuration.UserSetting.ConversationSetting.DefaultShareContentSavePath + @"\temp";
if (!Directory.Exists(text2))
{
Directory.CreateDirectory(text2);
}
path = text2 + @"\" + sc.FileName;
if (!File.Exists(path))
{
File.Create(path);
}
}
Icon icon = ImpsFileType.GetIcon(path);
bitmap = new Bitmap(icon.Width, icon.Height);
using (Graphics graphics = Graphics.FromImage(bitmap))
{
graphics.Clear(Color.White);
graphics.DrawIcon(icon, 0, 0);
}
}
defaultPortrait = bitmap;
}
catch
{
defaultPortrait = ImpsPortrait.GetDefaultPortrait(30, 30);
}
}
if (defaultPortrait != null)
{
Bitmap image = new Bitmap(defaultPortrait.Width + 2, defaultPortrait.Height + 2);
using (Graphics graphics2 = Graphics.FromImage(image))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -