📄 rich_string.cs
字号:
if ((maxLines <= 0) || (line < maxLines))
{
ef.Height += num2;
}
line++;
if (charactersFitted > 0)
{
first = first.Substring(charactersFitted);
}
num = 0f;
}
num += ef3.Width;
if ((index != upperBound) && (num != 0f))
{
ef.Height += num2;
num = 0f;
line++;
}
}
}
else
{
if (!(pair.first is AmigoImage))
{
throw new Exception("Unsupport rich_string inner object");
}
if ((num + 16f) > width)
{
if (ef.Width < num)
{
ef.Width = num;
}
if ((maxLines <= 0) || (line < maxLines))
{
ef.Height += num2;
}
line++;
num = 0f;
}
num += 16f;
continue;
}
}
}
finally
{
enumerator.Dispose();
}
}
num = 0f;
}
return ef;
}
public SizeF MeasureText(Graphics g, Font font)
{
return this.MeasureText(g, font, null);
}
public SizeF MeasureText(Graphics g, Font font, StringFormat fmt)
{
if (this._toCalc)
{
if (fmt == null)
{
fmt = new StringFormat();
fmt.Alignment = StringAlignment.Near;
fmt.LineAlignment = StringAlignment.Center;
fmt.FormatFlags |= StringFormatFlags.NoWrap;
fmt.Trimming = StringTrimming.EllipsisCharacter;
}
this._szPrefered = (SizeF) Size.Empty;
List<pair<object, SizeF>>.Enumerator enumerator = this.rich_text.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
SizeF ef;
pair<object, SizeF> pair = enumerator.get_Current();
if ((pair.first is string) || (pair.first is rich_string_link))
{
if (pair.first is string)
{
ef = g.MeasureString(pair.first as string, font, 0x7fffffff, fmt);
}
else
{
ef = g.MeasureString(((rich_string_link) pair.first).URL, font, 0x7fffffff, fmt);
}
ef.Width += 1f;
}
else
{
if (!(pair.first is AmigoImage))
{
throw new Exception("Unsupport rich_string inner object");
}
ef = new SizeF(16f, 16f);
}
pair.second = ef;
this._szPrefered.Width += ef.Width;
if (this._szPrefered.Height < ef.Height)
{
this._szPrefered.Height = ef.Height;
}
}
}
finally
{
enumerator.Dispose();
}
this._szPrefered.Width += 1f;
this._toCalc = false;
}
return this._szPrefered;
}
public string UrlMouseHitTest(Point pt)
{
if (!pt.IsEmpty)
{
this.rich_text.get_Count();
List<pair<object, SizeF>>.Enumerator enumerator = this.rich_text.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
pair<object, SizeF> pair = enumerator.get_Current();
if ((pair.first is rich_string_link) && ((rich_string_link) pair.first).HitTest(pt))
{
((rich_string_link) pair.first).Clicked = true;
return ((rich_string_link) pair.first).URL;
}
}
}
finally
{
enumerator.Dispose();
}
}
return string.Empty;
}
public bool UrlMouseTest(Point pt)
{
if (pt.IsEmpty)
{
return false;
}
this.rich_text.get_Count();
bool flag = false;
List<pair<object, SizeF>>.Enumerator enumerator = this.rich_text.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
pair<object, SizeF> pair = enumerator.get_Current();
if ((pair.first is rich_string_link) && ((rich_string_link) pair.first).MouseHover(pt))
{
flag = true;
}
}
}
finally
{
enumerator.Dispose();
}
return flag;
}
public string plane_text
{
get
{
return this.m_text;
}
set
{
if (this.m_text != value)
{
string strInput;
string text;
this._szPrefered = SizeF.Empty;
this._toCalc = true;
this.m_text = value;
this.m_richtext.Clear();
if ((this._strUserName.Length != 0) && (this.m_text.IndexOf(this._strUserName) == 0))
{
strInput = this.m_text.Substring(0, this._strUserName.Length);
text = this.m_text.Substring(this._strUserName.Length);
}
else
{
strInput = "";
text = this.m_text;
}
List<object>.Enumerator enumerator = EmoticonParser.ParseString(null, strInput).GetEnumerator();
try
{
while (enumerator.MoveNext())
{
object theFirst = enumerator.get_Current();
if (theFirst is Emoticon)
{
this.m_richtext.Insert(this.m_richtext.get_Count(), new pair<object, SizeF>(((Emoticon) theFirst).AmigoImage, SizeF.Empty));
}
else
{
this.m_richtext.Insert(this.m_richtext.get_Count(), new pair<object, SizeF>(theFirst, SizeF.Empty));
}
}
}
finally
{
enumerator.Dispose();
}
List<object>.Enumerator enumerator2 = EmoticonParser.ParseString(null, text).GetEnumerator();
try
{
while (enumerator2.MoveNext())
{
object obj3 = enumerator2.get_Current();
if (obj3 is Emoticon)
{
this.m_richtext.Insert(this.m_richtext.get_Count(), new pair<object, SizeF>(((Emoticon) obj3).AmigoImage, SizeF.Empty));
}
else
{
if (this.support_link)
{
List<object>.Enumerator enumerator3 = LinkParser.ParseString(obj3 as string).GetEnumerator();
try
{
while (enumerator3.MoveNext())
{
object obj4 = enumerator3.get_Current();
this.m_richtext.Insert(this.m_richtext.get_Count(), new pair<object, SizeF>(obj4, SizeF.Empty));
}
continue;
}
finally
{
enumerator3.Dispose();
}
}
this.m_richtext.Insert(this.m_richtext.get_Count(), new pair<object, SizeF>(obj3, SizeF.Empty));
}
}
}
finally
{
enumerator2.Dispose();
}
}
}
}
public SizeF PreferedSize
{
get
{
return this._szPrefered;
}
}
public int PreferedWidth
{
get
{
return (int) Math.Ceiling((double) this._szPrefered.Width);
}
}
public List<pair<object, SizeF>> rich_text
{
get
{
return this.m_richtext;
}
}
public bool support_link
{
get
{
return this._linkSupport;
}
set
{
this._linkSupport = value;
string text = this.m_text;
this.m_text = "";
this.plane_text = text;
}
}
public string UserName
{
set
{
this._strUserName = value;
string text = this.m_text;
this.m_text = "";
this.plane_text = text;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -