📄 xformwndlesslabel.cs
字号:
namespace Imps.Client.Pc.BizControls
{
using Imps.Client.Core;
using Imps.Client.Utils;
using Imps.Utils;
using System;
using System.Drawing;
using System.Windows.Forms;
public class XFormWndlessLabel : XFormWndlessControl
{
private string _CaptionUserName;
private Color _foreColor;
private Point _lastPoint;
protected rich_string _rich_string;
private bool _supportLink;
protected string _text;
protected Font _textFont;
public XFormWndlessLabel(string text)
{
this._lastPoint = new Point();
this._CaptionUserName = "";
this._foreColor = SystemColors.ControlText;
this._textFont = new Font("宋体", 9f);
this._foreColor = SystemColors.ControlText;
this.Text = text;
}
public XFormWndlessLabel(string text, bool bSupportLink)
{
this._lastPoint = new Point();
this._CaptionUserName = "";
this._foreColor = SystemColors.ControlText;
this._textFont = new Font("宋体", 9f);
this._foreColor = SystemColors.ControlText;
this._supportLink = bSupportLink;
this.Text = text;
}
public override void Dispose()
{
this._textFont.Dispose();
}
public override bool MouseClick(EventArgs e)
{
if (this._lastPoint.IsEmpty)
{
return false;
}
if (Control.ModifierKeys == Keys.Control)
{
string url = this.RichText.UrlMouseHitTest(this._lastPoint);
if (!string.IsNullOrEmpty(url))
{
ShellHelper.StartUrl(url);
}
}
return true;
}
public override void MouseDblClick(EventArgs e)
{
base.RaiseDoubleClick(this, e);
}
public override bool NcMouseDblClick(Graphics g, Point pt)
{
return base.RaiseDoubleClick(this, new EventArgs());
}
public override void OnMouseLeave(EventArgs e)
{
if (base._parent.Cursor != Cursors.Default)
{
base._parent.Cursor = Cursors.Default;
}
}
public override bool OnMouseMove(MouseEventArgs e)
{
this._lastPoint = e.get_Location();
if (this.RichText.UrlMouseTest(e.get_Location()) && (Control.ModifierKeys == Keys.Control))
{
base._parent.Cursor = Cursors.Hand;
}
else
{
base._parent.Cursor = Cursors.Default;
}
return true;
}
public override bool OnMouseUp(MouseEventArgs e)
{
if ((e.Button == MouseButtons.Right) && (base._menustrip != null))
{
Point point = base._parent.PointToScreen(new Point(e.X, e.Y));
base._menustrip.Show(point);
}
return true;
}
public override void OnNcMouseLeave(EventArgs e)
{
}
public override bool OnNcMouseMove(Graphics g, Point pt)
{
if (this.RichText.UrlMouseTest(pt))
{
base._parent.Cursor = Cursors.Hand;
}
else
{
base._parent.Cursor = Cursors.Default;
}
return false;
}
public override bool OnNcMouseUp(Graphics g, Point pt, MouseButtons button)
{
if ((button == MouseButtons.Right) && (base._menustrip != null))
{
Point empty = Point.Empty;
ChatEditCtrlManager.GetCursorPos(ref empty);
base._menustrip.Show(empty);
}
return true;
}
public override void OnNcPaint(Graphics g, Rectangle clipRectangle)
{
this.OnPaint(g, clipRectangle);
}
public override void OnPaint(Graphics g, Rectangle clipRectangle)
{
if (base.Visible && !base.NonClientArea)
{
Rectangle rect = base.Rectangle;
if (clipRectangle.IntersectsWith(rect))
{
this.PaintText(g, rect);
}
}
}
protected Size PaintText(Graphics g, Rectangle rect)
{
RectangleF rc = rect;
int offset = rect.Left;
SizeF ef2 = this.RichText.MeasureText(g, this._textFont);
ef2.Height = (float) Math.Ceiling((double) ef2.Height);
if (ef2.Height < 16f)
{
ef2.Height = 16f;
}
rc.Y = ((rc.Top + rc.Bottom) / 2f) - (ef2.Height / 2f);
rc.Height = ef2.Height;
this.RichText.Draw(g, this._textFont, this._foreColor, rc, null, ref offset);
return new Size(offset - rect.Left, rect.Height);
}
public FormDirection UrlHitTest(Point pt)
{
if (this.RichText.UrlMouseTest(pt) && (Control.ModifierKeys == Keys.Control))
{
return FormDirection.Normal;
}
return base.HitTestCode;
}
public string CaptionUserName
{
set
{
this._rich_string.UserName = value;
}
}
public Color ForeColor
{
get
{
return this._foreColor;
}
set
{
this._foreColor = value;
}
}
public rich_string RichText
{
get
{
return (this._rich_string ?? new rich_string());
}
}
public string Text
{
get
{
return this._text;
}
set
{
this._text = StringHelper.ReplaceCrLfToSpace(value);
this._rich_string = new rich_string(this._text, this._supportLink);
}
}
public Font TextFont
{
get
{
return this._textFont;
}
set
{
if (this._textFont != null)
{
this._textFont.Dispose();
}
this._textFont = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -