📄 htmllabel.cs
字号:
List<RectangleF>.Enumerator enumerator2 = list.GetEnumerator();
try
{
while (enumerator2.MoveNext())
{
if (enumerator2.get_Current().Contains((PointF) e.get_Location()))
{
this.LabelLinkClick.Invoke(this, new LabelLinkClickEventArgs(this._dicLinkRectangleF.get_Item(list)));
return;
}
}
continue;
}
finally
{
enumerator2.Dispose();
}
}
}
finally
{
enumerator.Dispose();
}
}
}
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
lock (this._dicLinkRectangleF)
{
Dictionary<List<RectangleF>, string>.KeyCollection.Enumerator enumerator = this._dicLinkRectangleF.get_Keys().GetEnumerator();
try
{
while (enumerator.MoveNext())
{
List<RectangleF>.Enumerator enumerator2 = enumerator.get_Current().GetEnumerator();
try
{
while (enumerator2.MoveNext())
{
if (enumerator2.get_Current().Contains((PointF) e.get_Location()))
{
this.Cursor = Cursors.Hand;
return;
}
}
continue;
}
finally
{
enumerator2.Dispose();
}
}
}
finally
{
enumerator.Dispose();
}
}
this.Cursor = Cursors.Arrow;
}
protected override void OnPaint(PaintEventArgs e)
{
if (this.ShowBackgroundImage && (IMToolstrip.Style.BackgroundImage != null))
{
Rectangle rect = e.ClipRectangle;
rect.Offset(0, -1);
rect.Inflate(10, 0);
e.Graphics.DrawImage(IMToolstrip.Style.BackgroundImage, rect);
}
this._lineHight = this.Font.Height;
this._dicLinkRectangleF.Clear();
this._drawFinish = false;
if (string.IsNullOrEmpty(this.Text))
{
base.OnPaint(e);
}
else
{
this._nextPoint = new PointF((float) this.ClientRectangle.Left, (float) (this.ClientRectangle.Top + this.SpaceDistance));
for (int i = 0; i < this.parser.Nodes.Count; i++)
{
Font font = this.Font;
Color foreColor = this.ForeColor;
this.DrawNode(e.Graphics, this.parser.Nodes[i], ref font, ref foreColor);
}
}
if (this.AutoResizeHeight && (((this._nextPoint.Y + this._lineHight) + this.SpaceDistance) < this.ClientRectangle.Height))
{
base.Height = (Convert.ToInt32(this._nextPoint.Y) + this._lineHight) + this.SpaceDistance;
}
}
protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);
this.parser = Imps.Utils.TagParser.TagParser.Create(this.Text, true);
base.Invalidate();
}
private static bool ParserFontStyle(TagNode node, ref FontStyle style)
{
bool flag = false;
if (node is BoldElement)
{
style |= FontStyle.Bold;
flag = true;
}
if (node is ItalicElement)
{
style |= FontStyle.Italic;
flag = true;
}
if (node is UnderlineElement)
{
style |= FontStyle.Underline;
flag = true;
}
if (node is StrikeElement)
{
style |= FontStyle.Strikeout;
flag = true;
}
return flag;
}
private string RectangleContainString(Graphics gp, RectangleF rec, string content, Font font)
{
if (gp.MeasureString(content, font).Width > rec.Width)
{
for (int i = 1; i <= content.Length; i++)
{
if (gp.MeasureString(content.Substring(0, i), font).Width > rec.Width)
{
return content.Substring(0, ((i - 1) >= 0) ? (i - 1) : i);
}
}
}
return content;
}
[Category("自定义"), Description("如果解析出Emotion 是否自动播放,false 只自绘出Emotion的第一帧"), DefaultValue(false), Browsable(true)]
public bool AllowAnimate
{
get
{
return this._allowAnimate;
}
set
{
this._allowAnimate = value;
}
}
[DefaultValue(false), Category("自定义"), Browsable(true), Description("是否自动检测URL地址:符合http:// 的才能够自动检测")]
public bool AutoDetectUrls
{
get
{
return this._autoDetectUrls;
}
set
{
this._autoDetectUrls = value;
if (value && (this.regUrl == null))
{
this.regUrl = new Regex(@"\bhttp\:\/\/[^\s]*\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
}
}
}
[DefaultValue(false), Browsable(true), Description("是否自动调整Label的高度 来自动适应文本的内容 主要使用在Dock情况下的LayOut"), Category("自定义")]
public bool AutoResizeHeight
{
get
{
return this._autoResizeHeight;
}
set
{
this._autoResizeHeight = value;
}
}
[Browsable(false)]
public override bool AutoSize
{
get
{
return base.AutoSize;
}
set
{
}
}
public Rectangle ClientRectangle
{
get
{
if (base.get_Padding().get_All() == 0)
{
return base.ClientRectangle;
}
return new Rectangle(base.ClientRectangle.Left + base.get_Padding().get_Left(), base.ClientRectangle.Top + base.get_Padding().get_Top(), (base.ClientRectangle.Width - base.get_Padding().get_Left()) - base.get_Padding().get_Right(), (base.ClientRectangle.Height - base.get_Padding().get_Top()) - base.get_Padding().get_Bottom());
}
}
internal int LineWidth
{
get
{
return ((this.ClientRectangle.Width - base.get_Padding().get_Left()) - base.get_Padding().get_Right());
}
}
[Browsable(true), Description("Html里链接的颜色"), Category("自定义")]
public Color LinkColor
{
get
{
return this._linkColor;
}
set
{
this._linkColor = value;
}
}
[Description("是否自动解析Emotion并且画出"), DefaultValue(false), Category("自定义"), Browsable(true)]
public bool ParseEmotion
{
get
{
return this._parseEmotion;
}
set
{
this._parseEmotion = value;
}
}
public bool ShowBackgroundImage
{
get
{
return this._showBackgroundImage;
}
set
{
this._showBackgroundImage = value;
}
}
[DefaultValue(0), Category("自定义"), Browsable(true), Description("行间距")]
public int SpaceDistance
{
get
{
return this._spaceDistance;
}
set
{
this._spaceDistance = value;
}
}
[Browsable(true), Category("自定义"), Description("Label的Html内容")]
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -