📄 xtipex.cs
字号:
namespace Imps.Client.Pc.BizControls
{
using Imps.Client.Core;
using Imps.Client.Pc;
using Imps.Client.Resource;
using Imps.Utils;
using Imps.Utils.TagParser;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
public class XTipEx : UserControl
{
private int _baseHeight = 9;
private Imps.Client.Pc.BizControls.ConversationTipType _conversationTipType;
private bool _convertSymbol = true;
protected int _currentLines;
private Color _foreColor = Color.Red;
protected string _html = string.Empty;
private int _maxLines = 2;
protected int _oriLines;
private bool _showIcon;
protected string _text = string.Empty;
private Font _textFont = new Font("宋体", 12f);
public ChatEditCtrlManager _tipEditShowMgr;
private Image _tipImage = ImpsIcons.InfoIcon;
private System.Drawing.Point _tipImagePoint = new System.Drawing.Point(0, 0);
private IContainer components;
protected ChatRichTextBox richTextBox1;
public event ChatEditClickEventHandler LinkButtonClick;
public event ChatEditClickEventHandler LinkClick;
public XTipEx()
{
this.InitializeComponent();
this._tipEditShowMgr = new ChatEditCtrlManager(this.richTextBox1, true);
this._tipEditShowMgr.SympolSize = new Size(0x10, 0x10);
this._tipEditShowMgr.ReadOnly = true;
base.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
base.SetStyle(0x20000, true);
base.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.richTextBox1.Visible = false;
this.Visible = false;
this._maxLines = 2;
base.SizeChanged += new EventHandler(this.UserControl1_SizeChanged);
this._tipEditShowMgr.LinkButtonClick += new ChatEditClickEventHandler(this._tipEditShowMgr_LinkButtonClick);
this._tipEditShowMgr.LinkClick += new ChatEditClickEventHandler(this._tipEditShowMgr_LinkClick);
}
private int _tipEditShowMgr_LinkButtonClick(object sender, ChatEditClickEventArgs e)
{
if (this.LinkButtonClick != null)
{
this.LinkButtonClick(sender, e);
}
return 0;
}
private int _tipEditShowMgr_LinkClick(object sender, ChatEditClickEventArgs e)
{
if (this.LinkClick != null)
{
this.LinkClick(sender, e);
}
return 0;
}
protected override void Dispose(bool disposing)
{
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void DrawIconImage(Graphics g, Rectangle clipedRect)
{
if (this._showIcon)
{
int y = 0;
if (this._currentLines < this._maxLines)
{
y = ((this._tipImagePoint.Y + (base.Height / this._currentLines)) - 0x10) / 2;
int num1 = base.Height / this._currentLines;
}
else
{
y = ((this._tipImagePoint.Y + (base.Height / this._maxLines)) - 0x10) / 2;
int num2 = base.Height / this._maxLines;
}
Rectangle rect = new Rectangle(new System.Drawing.Point(this._tipImagePoint.X, y), new Size(0x10, 0x10));
if (rect.IntersectsWith(clipedRect))
{
g.DrawImage(this._tipImage, rect);
}
}
}
private System.Drawing.Point DrawString(Graphics g, string sText, Font font, int x, int y, int iWidth, StringFormat sf)
{
int startIndex = 0;
int length = sText.Length;
int num3 = sText.Length;
int num4 = num3;
int num5 = startIndex;
Label_0015:
if (iWidth >= 0)
{
string text = sText.Substring(startIndex, num3 - startIndex);
SizeF size = g.MeasureString(text, font, 0x989680, sf);
int width = (int) size.Width;
if ((width - font.SizeInPoints) <= (iWidth - 7))
{
if ((num4 == num3) || (num4 == (num3 + 1)))
{
size = this.DrawText(g, x, y, sf, text, size);
if (num3 >= length)
{
x += width;
if (((x - font.SizeInPoints) >= base.ClientRectangle.Right) || (((x - font.SizeInPoints) + 1f) >= base.ClientRectangle.Right))
{
this.SetReturn(font, ref x, ref y);
}
goto Label_0196;
}
this.SetReturn(font, ref x, ref y);
sText = sText.Substring(num3, length - num3);
length = sText.Length;
num3 = length;
num4 = num3;
startIndex = 0;
num5 = startIndex;
}
else
{
num5 = num3;
num3 += (num4 - num3) / 2;
}
goto Label_0015;
}
if (width > (iWidth - x))
{
num4 = num3;
num3 = num5 + ((num3 - num5) / 2);
if ((num3 == startIndex) && (startIndex == 0))
{
this.SetReturn(font, ref x, ref y);
length = sText.Length;
num3 = length;
num4 = num3;
startIndex = 0;
num5 = startIndex;
}
goto Label_0015;
}
size = this.DrawText(g, x, y, sf, text, size);
this.SetReturn(font, ref x, ref y);
if (num3 <= length)
{
sText = sText.Substring(num3, length - num3);
length = sText.Length;
num3 = length;
num4 = num3;
startIndex = 0;
num5 = startIndex;
goto Label_0015;
}
}
Label_0196:
return new System.Drawing.Point(x, y);
}
private SizeF DrawText(Graphics g, int x, int y, StringFormat sf, string sTemp, SizeF size)
{
return size;
}
private void HideEdit()
{
this.richTextBox1.Visible = false;
this._showIcon = false;
}
private void InitializeComponent()
{
this.richTextBox1 = new ChatRichTextBox();
base.SuspendLayout();
this.richTextBox1.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
this.richTextBox1.BackColor = Color.White;
this.richTextBox1.BorderColor = Color.Empty;
this.richTextBox1.BorderStyle = BorderStyle.None;
this.richTextBox1.Location = new System.Drawing.Point(0, 0);
this.richTextBox1.set_Margin(new Padding(0));
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new Size(290, 0x2c);
this.richTextBox1.TabIndex = 0;
this.richTextBox1.Text = "";
base.set_AutoScaleDimensions(new SizeF(6f, 13f));
base.set_AutoScaleMode(1);
this.BackColor = Color.Transparent;
base.Controls.Add(this.richTextBox1);
base.Name = "XTipEx";
base.Size = new Size(290, 0x2e);
base.ResumeLayout(false);
}
private Size MeasureText(Graphics g, Font font, string sText)
{
if (this.richTextBox1.Width < 5)
{
return new Size(0, 0);
}
this._currentLines = 1;
using (StringFormat sf = new StringFormat())
{
sf.Trimming = StringTrimming.None;
int num = 0;
this._baseHeight = 0x10;
if (this._convertSymbol)
{
List<object> list = EmoticonParser.ParseString(null, sText);
int x = ((base.ClientRectangle.X + base.get_Padding().get_Left()) + 0x10) + 1;
int y = (base.ClientRectangle.Y + base.get_Padding().get_Top()) + 2;
int width = base.Width;
int height = base.ClientRectangle.Height;
List<object>.Enumerator enumerator = list.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
object obj2 = enumerator.get_Current();
if (obj2 is Emoticon)
{
Emoticon emoticon = (Emoticon) obj2;
AmigoImage amigoImage = emoticon.AmigoImage;
int num5 = 0x10;
if ((x + num5) > base.Width)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -