本文整理匯總了C#中System.Drawing.Pen.?.Dispose方法的典型用法代碼示例。如果您正苦於以下問題:C# Pen.?.Dispose方法的具體用法?C# Pen.?.Dispose怎麽用?C# Pen.?.Dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Drawing.Pen
的用法示例。
在下文中一共展示了Pen.?.Dispose方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OnPaint
/// <summary>
/// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event.
/// </summary>
/// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data. </param>
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Pen drawPen = null;
try
{
foreach (KeyValuePair<int, LogMessage> keyVal in mColoredLines)
{
if ((keyVal.Value.Level & (LogLevel)Settings.Default.ColorMapAnnotation) != keyVal.Value.Level)
{
continue;
}
switch (keyVal.Value.Level)
{
case LogLevel.Fatal:
drawPen = new Pen(Settings.Default.BackgroundColorFatal);
break;
case LogLevel.Error:
drawPen = new Pen(Settings.Default.BackgroundColorError);
break;
case LogLevel.Warning:
drawPen = new Pen(Settings.Default.BackgroundColorWarning);
break;
case LogLevel.Info:
drawPen = new Pen(Settings.Default.BackgroundColorInfo);
break;
case LogLevel.Debug:
drawPen = new Pen(Settings.Default.BackgroundColorDebug);
break;
case LogLevel.Trace:
drawPen = new Pen(Settings.Default.BackgroundColorTrace);
break;
default:
drawPen = null;
break;
}
if (drawPen != null)
{
e.Graphics.DrawLine(drawPen, 0, keyVal.Key, Width, keyVal.Key);
}
}
}
finally
{
drawPen?.Dispose();
}
}