📄 contactonlinestatuschangednotify.cs
字号:
namespace Imps.Client.Pc.BizControls.NotifyWindows.Templates
{
using Imps.Client;
using Imps.Client.Core;
using Imps.Client.Pc;
using Imps.Client.Pc.BizControls.NotifyWindows;
using Imps.Client.Resource;
using Imps.Common;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Runtime.CompilerServices;
public class ContactOnlineStatusChangedNotify : NotifyWindowTemplateBase
{
protected NotifyWindowLabel contentLabel;
protected string contentText = "";
protected MainPresence mainPresence;
protected Image portraitImage;
public event NotifyWindowEventHandler ContentClick;
public ContactOnlineStatusChangedNotify(Imps.Client.Core.Contact contact)
{
if (contact is ImpsContact)
{
base.title = this.GenerateTitle(((ImpsContact) contact).Sid);
}
else
{
base.title = contact.DisplayName;
}
this.contentText = this.GenerateMessage(contact.DisplayName, contact.Presence.MainPresence);
try
{
this.portraitImage = contact.PersonalInfo.Portrait;
}
catch
{
if (contact.PersonalInfo.Gender == Gender.Female)
{
this.portraitImage = ImpsPortrait.GetGirlPortrait(0x60, 0x60);
}
else
{
this.portraitImage = ImpsPortrait.GetBoyPortrait(0x60, 0x60);
}
}
base.InitContent();
}
private void content_Click(object sender, NotifyWindowEventArgs e)
{
try
{
this.OnContentClick(e);
}
catch
{
}
}
protected override void CreateContent(NotifyWindowContent content)
{
Rectangle textRectangle = new Rectangle(content.Rectangle.X + 0x49, content.Rectangle.Y + ((content.Rectangle.Height - 60) / 2), 0x88, 60);
this.contentLabel = new NotifyWindowLabel(this.contentText, textRectangle);
this.contentLabel.Clickable = true;
this.contentLabel.Click += new NotifyWindowEventHandler(this.content_Click);
content.Elements.Add(this.contentLabel);
Rectangle rectangle = new Rectangle(content.Rectangle.X + 8, content.Rectangle.Y + ((content.Rectangle.Height - 60) / 2), 60, 60);
Bitmap bitmap = (Bitmap) ImpsResources.GetImage("Images.48.png");
using (Graphics graphics = Graphics.FromImage(bitmap))
{
graphics.DrawImage(this.portraitImage, 8, 8, 0x30, 0x30);
}
NotifyWindowImage image = new NotifyWindowImage(rectangle, bitmap);
image.Clickable = true;
image.Click += new NotifyWindowEventHandler(this.content_Click);
content.Elements.Add(image);
}
protected string GenerateMessage(string displayName, MainPresence mainPresence)
{
string text = "";
float num = 110f;
float num2 = 0f;
List<object> list = EmoticonParser.ParseString(null, displayName);
rich_string _string = new rich_string(displayName);
Graphics g = Graphics.FromHdc(InnerWin32.GetWindowDC(base.Handle));
if (_string.MeasureText(g, this.Font).Width > num)
{
num -= g.MeasureString("...", this.Font).Width - 10f;
}
List<object>.Enumerator enumerator = list.GetEnumerator();
try
{
Label_0133:
while (enumerator.MoveNext())
{
object obj2 = enumerator.get_Current();
if (obj2 is Emoticon)
{
if ((num2 + 16f) >= num)
{
goto Label_014F;
}
text = text + ((Emoticon) obj2).Key;
num2 += 17f;
}
else if (obj2 is string)
{
string text2 = (string) obj2;
SizeF empty = SizeF.Empty;
for (int i = text2.Length; i > 0; i--)
{
string text3 = text2.Substring(0, i);
empty = g.MeasureString(text3, this.Font);
if ((num2 + empty.Width) <= num)
{
text = text + text3;
num2 += empty.Width + 1f;
goto Label_0133;
}
}
}
}
}
finally
{
enumerator.Dispose();
}
Label_014F:
if (num < 110f)
{
text = text + "...";
}
return string.Format(StringTable.NotifyWindow.Online, text);
}
protected string GenerateTitle(long sid)
{
return string.Format("{0} 号: {1}", AppDictionary.ShortEnglishName, sid.ToString());
}
public void OnContentClick(NotifyWindowEventArgs e)
{
if (this.ContentClick != null)
{
this.ContentClick(this, e);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -