本文整理汇总了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();
}
}