本文整理汇总了C#中System.Drawing.Font.SafeDispose方法的典型用法代码示例。如果您正苦于以下问题:C# Font.SafeDispose方法的具体用法?C# Font.SafeDispose怎么用?C# Font.SafeDispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Font
的用法示例。
在下文中一共展示了Font.SafeDispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDisplayText
//.........这里部分代码省略.........
redline = i;
break;
}
}
}
}
while (lineCounter < linesToDraw) //iterate over all rows
{
int i = 0, j = 0;
var highlight = false;
var oldHighlight = false;
if (redline == curLine)
{
using (var p = new Pen(Color.Red))
{
g.DrawLine(p, 0, startY, Width, startY);
}
}
lineCounter++;
curForeColor = displayLines[curLine].TextColor;
var line = new StringBuilder();
line.Append(displayLines[curLine].Line);
curBackColor = backColor;
//check if in a url, cancel underline if not
if (!isInUrl)
{
underline = false;
font.SafeDispose();
font = new Font(Font, FontStyle.Regular);
}
if (line.Length > 0)
{
do //iterate over every character in a line
{
ch = line.ToString().Substring(i, 1).ToCharArray();
switch (ch[0])
{
case TextColor.EmotChar: //this header is added by SaidLine.cs & SaidLineEx.cs
//draws an emoticon
//[]001
var emotNumber = Convert.ToInt32(line.ToString().Substring(i + 1, 3));
line.Remove(0, i + 4);
i = -1;
//draw text (that wasn't yet drawn up to *this* point)
startX = DT(g, buildString, Font, startX, startY, curForeColor, curBackColor);
//draw an emoticon
g.DrawImage(TextImage.GetImage(emotNumber), startX, startY, 16, 16);
startX += 16;
buildString.Clear(); //reset the content (because we already draw it for user)
break;
case TextColor.UrlStart:
startX = DT(g, buildString, font, startX, startY, curForeColor, curBackColor);
buildString.Clear();
示例2: OnDisplayText
//.........这里部分代码省略.........
{
redline = i;
break;
}
}
}
}
while (lineCounter < linesToDraw) //iterate over all rows
{
int i = 0, j = 0;
var highlight = false;
var oldHighlight = false;
if (redline == curLine)
{
using (var p = new Pen(Color.Red)) {
g.DrawLine(p, 0, startY, Width, startY);
}
}
lineCounter++;
curForeColor = displayLines[curLine].TextColor;
var line = new StringBuilder();
line.Append(displayLines[curLine].Line);
curBackColor = backColor;
//check if in a url, cancel underline if not
if (!isInUrl)
{
underline = false;
font.SafeDispose();
font = new Font(Font.Name, Font.Size, Font.Style);
}
if (line.Length > 0)
{
do //iterate over every character in a line
{
using (SolidBrush backColorBrush = new SolidBrush(TextColor.GetColor(curBackColor))) //refresh backcolor
{
ch = line.ToString().Substring(i, 1).ToCharArray();
switch (ch[0])
{
case TextColor.EmotChar: //this header is added by SaidLine.cs & SaidLineEx.cs
//draws an emoticon
//[]001
var emotNumber = Convert.ToInt32(line.ToString().Substring(i + 1, 3));
line.Remove(0, 3);
if (!isInUrl)
{
//select the emoticon here
var bm = TextImage.GetImage(emotNumber);
if (curBackColor != backColor)
{
textSize = (int)g.MeasureString(buildString.ToString(), Font, 0, sf).Width + 1;
var r = new Rectangle((int)startX, startY, textSize + 1, LineSize + 1);
g.FillRectangle(backColorBrush, r); //draw white (or black) rectangle
}
g.DrawImage(bm, //draw an emoticon
startX + g.MeasureString(buildString.ToString(), Font, 0, sf).Width,