📄 displayemoticons.cs
字号:
namespace Imps.Client.Pc.BizControls
{
using Imps.Client.Core.CustomEmotion;
using Imps.Client.Pc;
using Imps.Client.Pc.Controls;
using Imps.Client.Resource;
using Imps.Client.Utils;
using Imps.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
public class DisplayEmoticons : PopupWindow
{
private bool _oldVisible;
private DisplayPreviewEmotion _preview_emotion;
private Color borderHightlightInsideColor = Color.FromArgb(0xd8, 0xe3, 0xf4);
private Color borderHightlightOutsideColor = Color.FromArgb(0x31, 0x6a, 0xc5);
private int colCount = 11;
private const int constBackPageTag = -12;
private const int constMgrTag = -10;
private const int constPrevPageTag = -11;
private const int constShowPageTag = -13;
private int currentCustomPage;
private EmoticonRegion currentEmoticonRS;
private int customRowCount = 2;
private EmoticonEventArgs ee = new EmoticonEventArgs();
private int emoticonImageHeight = 0x13;
private int emoticonImageWidth = 0x13;
private CustomOperation emoticonMgrOperation;
private CustomOperation emoticonMgrPageBack;
private CustomOperation emoticonMgrPagePrev;
private CustomOperation emoticonMgrPageShow;
private List<EmoticonRegion> emoticonRegions;
private List<Emoticon> emoticons;
private List<Emoticon> emoticonsCustom;
private Color fontColor = Color.FromArgb(0x33, 0x33, 0x33);
private Font fontCustomOperation;
private Color fontCustomOperationColor = Color.FromArgb(0, 0x4b, 0x97);
private Font fontCustomOperationHover;
private Color fontCustomOperationHoverColor = Color.FromArgb(0, 0, 0xff);
private Font fontHover;
private Color foreColorHover = Color.FromArgb(0, 0x88, 0xe4);
private EmoticonRegion lastEmoticonRS;
private Color lineColor = Color.FromArgb(0xde, 0xde, 0xde);
private ICustomEmotionManager m_customEmotionMgr;
private IFrameworkWindow m_frameworkWindow;
private long m_lLastUserSid = -1;
private int paddingBottom = 20;
private int paddingLeft = 7;
private int paddingRight = 7;
private int paddingTop = 0x18;
private Pen pen;
private System.Drawing.Point pointSeperatorLine1;
private System.Drawing.Point pointSeperatorLine2;
private Rectangle rectBorder;
private Rectangle rectCustomRegion;
private List<EmoticonRegion> rectDynamicImages = new List<EmoticonRegion>();
private List<Rectangle> rects = new List<Rectangle>();
private List<Rectangle> rectsHightlightInside = new List<Rectangle>();
private List<Rectangle> rectsHightlightOutside = new List<Rectangle>();
private int rowCount = 5;
private int seperatorCustomOperationHeight = 10;
private int seperatorDefault2CustomHeight = 20;
private int seperatorHeight = 5;
private int seperatorPadding = 7;
private Timer timer;
protected ToolTip toolTip;
public event EventHandler DisplayEmoticonsHide;
public event EventHandler<EmoticonEventArgs> EmoticonSelected;
public DisplayEmoticons(List<Emoticon> emoticons, List<Emoticon> emoticonsCustom, IFrameworkWindow frameworkWindow)
{
this.InitComponent();
this.m_frameworkWindow = frameworkWindow;
if (this.m_frameworkWindow != null)
{
this.m_customEmotionMgr = this.m_frameworkWindow.AccountManager.CurrentUser.CustomEmotionManager;
this.m_lLastUserSid = this.m_frameworkWindow.AccountManager.CurrentUser.Sid;
}
this.emoticonsCustom = emoticonsCustom;
base.Width = (this.paddingLeft + this.paddingRight) + (this.ColCount * this.EmoticonSize.Width);
base.Height = (((this.paddingTop + this.paddingBottom) + ((this.RowCount + this.customRowCount) * this.EmoticonSize.Height)) + this.seperatorDefault2CustomHeight) + this.seperatorCustomOperationHeight;
this.rectCustomRegion = new Rectangle(base.Left + this.paddingLeft, (this.paddingTop + (this.RowCount * this.EmoticonSize.Height)) + this.seperatorDefault2CustomHeight, this.ColCount * this.EmoticonSize.Width, ((this.customRowCount * this.EmoticonSize.Height) + this.seperatorDefault2CustomHeight) + this.seperatorCustomOperationHeight);
this.emoticons = emoticons;
this.InitRegions();
}
private void _preview_timer_Tick(object sender, EventArgs e)
{
this._preview_emotion.Visible = true;
this._preview_emotion.BeginAnimate();
GlobalTimer.Unregister(new EventHandler(this._preview_timer_Tick));
}
private void AddDynamicImageRectangle(EmoticonRegion er)
{
if (((er != null) && (er.Emoticon != null)) && ((er.Emoticon.AmigoImage != null) && er.Emoticon.AmigoImage.CanPlay))
{
this.rectDynamicImages.Add(er);
}
}
public void CalCustomOperationRect()
{
int y = ((this.paddingTop + ((this.RowCount + this.customRowCount) * this.EmoticonSize.Height)) + this.seperatorDefault2CustomHeight) + this.seperatorHeight;
this.emoticonMgrOperation.RectOperation = new Rectangle(10, y, 0x7fffffff, 0x7fffffff);
this.emoticonMgrPageShow.RectOperation = new Rectangle(base.Width / 2, y, 0x7fffffff, 0x7fffffff);
this.emoticonMgrPageBack.RectOperation = new Rectangle((base.Width / 5) * 3, y, 0x7fffffff, 0x7fffffff);
this.emoticonMgrPagePrev.RectOperation = new Rectangle((base.Width / 5) * 4, y, 0x7fffffff, 0x7fffffff);
}
private void ClearCurPageCustomEmoticon()
{
try
{
this._preview_emotion.Visible = false;
this._preview_emotion.EndAnimate();
for (int i = this.rectDynamicImages.get_Count() - 1; i >= 0; i--)
{
if (this.rectDynamicImages.get_Item(i).IsCustomEmoticon)
{
this.rectDynamicImages.Remove(this.rectDynamicImages.get_Item(i));
}
}
for (int j = this.emoticonRegions.get_Count() - 1; j >= 0; j--)
{
if (this.emoticonRegions.get_Item(j).IsCustomEmoticon)
{
if ((this.emoticonRegions.get_Item(j).Emoticon != null) && (this.emoticonRegions.get_Item(j).Emoticon.AmigoImage != null))
{
this.emoticonRegions.get_Item(j).Emoticon.AmigoImage.Dispose(false, true);
}
this.emoticonRegions.Remove(this.emoticonRegions.get_Item(j));
}
}
}
catch (Exception exception)
{
ClientLogger.WriteException(exception);
}
}
public void Display(int x, int y)
{
base.DisplayWithActive(x, y);
this._preview_emotion.Visible = false;
}
private void DisplayEmoticons_Activated(object sender, EventArgs e)
{
if ((this.m_frameworkWindow != null) && ((this.m_customEmotionMgr.OwnerEmotions.Count != this.m_frameworkWindow.AccountManager.CurrentUser.CustomEmotionManager.OwnerEmotions.Count) || (this.m_frameworkWindow.AccountManager.CurrentUser.Sid != this.m_lLastUserSid)))
{
this.m_lLastUserSid = this.m_frameworkWindow.AccountManager.CurrentUser.Sid;
this.m_customEmotionMgr = this.m_frameworkWindow.AccountManager.CurrentUser.CustomEmotionManager;
}
this.UpdateCustom(null);
}
private void DisplayEmoticons_Deactivate(object sender, EventArgs e)
{
this.currentCustomPage = 0;
this.Hide();
}
private void DisplayEmoticons_FormClosed(object sender, FormClosedEventArgs e)
{
this.OnDisplayEmoticonsHide(new EventArgs());
}
private void DisplayEmoticons_MouseClick(object sender, MouseEventArgs e)
{
if (((e.Button == MouseButtons.Left) && (this.currentEmoticonRS != null)) && this.currentEmoticonRS.RectEmoticon.Contains(e.get_Location()))
{
this.Hide();
if (this.currentEmoticonRS.IsCustomEmoticon)
{
this.ee.CustomEmotion = this.m_customEmotionMgr.OwnerEmotions[this.currentEmoticonRS.ID];
this.ee.IsCustomEmoticon = true;
}
else
{
this.ee.Emoticon = this.currentEmoticonRS.Emoticon;
this.ee.IsCustomEmoticon = false;
}
this.OnEmoticonSelected(this.ee);
}
}
private void DisplayEmoticons_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
if (this.emoticonMgrOperation.RectOperation.Contains(e.X, e.Y) && this.emoticonMgrOperation.IsCanClick)
{
this.m_frameworkWindow.ConversationManager.ShowCustomEmotionManageForm(this);
}
else if (!this.emoticonMgrPageShow.RectOperation.Contains(e.X, e.Y) || !this.emoticonMgrPageShow.IsCanClick)
{
if (this.emoticonMgrPageBack.RectOperation.Contains(e.X, e.Y) && this.emoticonMgrPageBack.IsCanClick)
{
this.currentCustomPage--;
this.UpdateCustom(null);
base.Invalidate(this.rectCustomRegion);
}
else if (this.emoticonMgrPagePrev.RectOperation.Contains(e.X, e.Y) && this.emoticonMgrPagePrev.IsCanClick)
{
this.currentCustomPage++;
this.UpdateCustom(null);
base.Invalidate(this.rectCustomRegion);
}
}
}
}
private void DisplayEmoticons_MouseLeave(object sender, EventArgs e)
{
}
private void DisplayEmoticons_MouseMove(object sender, MouseEventArgs e)
{
bool flag = false;
int num = 0;
bool flag2 = false;
int num2 = (int) Math.Ceiling(((double) this.m_customEmotionMgr.OwnerEmotions.Count) / (this.customRowCount * this.colCount));
int num3 = this.currentCustomPage + 1;
if (this.emoticonMgrOperation.RectOperation.Contains(e.X, e.Y))
{
this.emoticonMgrPageShow.IsSelected = false;
this.emoticonMgrPageBack.IsSelected = false;
this.emoticonMgrPagePrev.IsSelected = false;
this.emoticonMgrOperation.IsSelected = true;
if (this.emoticonMgrOperation.IsCanClick)
{
this.Cursor = Cursors.Hand;
}
base.Invalidate(this.rectCustomRegion);
int num4 = (int) this.toolTip.get_Tag();
if (num4 != -10)
{
if (!this.toolTip.Active)
{
this.toolTip.Active = true;
}
this.toolTip.set_Tag(-10);
this.toolTip.SetToolTip(this, "管理您的自定义表情");
}
flag2 = true;
}
else if (this.emoticonMgrPageShow.RectOperation.Contains(e.X, e.Y))
{
this.emoticonMgrOperation.IsSelected = false;
this.emoticonMgrPageBack.IsSelected = false;
this.emoticonMgrPagePrev.IsSelected = false;
this.emoticonMgrPageShow.IsSelected = true;
if (this.emoticonMgrPageShow.IsCanClick)
{
this.Cursor = Cursors.Hand;
}
base.Invalidate(this.rectCustomRegion);
int num5 = (int) this.toolTip.get_Tag();
if (num5 != -13)
{
if (!this.toolTip.Active)
{
this.toolTip.Active = true;
}
this.toolTip.set_Tag(-13);
this.toolTip.SetToolTip(this, "共" + num2.ToString() + "页,当前第" + num3.ToString() + "页");
}
flag2 = true;
}
else
{
if (this.emoticonMgrPageBack.RectOperation.Contains(e.X, e.Y))
{
this.emoticonMgrPageShow.IsSelected = false;
this.emoticonMgrOperation.IsSelected = false;
this.emoticonMgrPagePrev.IsSelected = false;
this.emoticonMgrPageBack.IsSelected = true;
if (this.emoticonMgrPageBack.IsCanClick)
{
this.Cursor = Cursors.Hand;
}
base.Invalidate(this.rectCustomRegion);
int num6 = (int) this.toolTip.get_Tag();
if (num6 != -12)
{
if (!this.toolTip.Active)
{
this.toolTip.Active = true;
}
this.toolTip.set_Tag(-12);
this.toolTip.SetToolTip(this, "共" + num2.ToString() + "页,当前第" + num3.ToString() + "页");
}
flag2 = true;
return;
}
if (this.emoticonMgrPagePrev.RectOperation.Contains(e.X, e.Y))
{
this.emoticonMgrPageShow.IsSelected = false;
this.emoticonMgrPageBack.IsSelected = false;
this.emoticonMgrOperation.IsSelected = false;
this.emoticonMgrPagePrev.IsSelected = true;
if (this.emoticonMgrPagePrev.IsCanClick)
{
this.Cursor = Cursors.Hand;
}
base.Invalidate(this.rectCustomRegion);
int num7 = (int) this.toolTip.get_Tag();
if (num7 != -12)
{
if (!this.toolTip.Active)
{
this.toolTip.Active = true;
}
this.toolTip.set_Tag(-12);
this.toolTip.SetToolTip(this, "共" + num2.ToString() + "页,当前第" + num3.ToString() + "页");
}
flag2 = true;
return;
}
this.emoticonMgrOperation.IsSelected = false;
this.emoticonMgrPageBack.IsSelected = false;
this.emoticonMgrPagePrev.IsSelected = false;
this.emoticonMgrPageShow.IsSelected = false;
this.Cursor = Cursors.Arrow;
base.Invalidate(this.rectCustomRegion);
}
List<EmoticonRegion>.Enumerator enumerator = this.emoticonRegions.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
EmoticonRegion region = enumerator.get_Current();
num++;
if (region.RectEmoticon.Contains(e.X, e.Y))
{
flag = true;
int num8 = (int) this.toolTip.get_Tag();
if (num8 != num)
{
if (region.Emoticon != null)
{
if (!this.toolTip.Active)
{
this.toolTip.Active = true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -