本文整理汇总了C#中LinearGradientMode.GetValueOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# LinearGradientMode.GetValueOrDefault方法的具体用法?C# LinearGradientMode.GetValueOrDefault怎么用?C# LinearGradientMode.GetValueOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinearGradientMode
的用法示例。
在下文中一共展示了LinearGradientMode.GetValueOrDefault方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FillBackground
/// <summary>
/// Fills the specified <paramref name="path"/> either with a gradient background or a solid one.
/// </summary>
/// <param name="g">The <see cref="Graphics"/> object used to draw.</param>
/// <param name="path">The <see cref="GraphicsPath"/> to fill.</param>
/// <param name="colorStart">The start color.</param>
/// <param name="colorEnd">The end color if drawing a gradient background.</param>
/// <param name="mode">The <see cref="LinearGradientMode"/> to use.</param>
/// <exception cref="ArgumentNullException">If <paramref name="path"/> is null.</exception>
public static void FillBackground(
Graphics g,
GraphicsPath path,
Color colorStart,
Color colorEnd,
LinearGradientMode? mode)
{
if (path == null)
{
throw new ArgumentNullException("path", "parameter 'path' cannot be null.");
}
RectangleF rect = path.GetBounds();
if (!CheckParams(g, path.GetBounds()) || colorStart == Color.Empty)
{
return;
}
if (colorEnd == Color.Empty)
{
if (colorStart != Color.Transparent)
{
using (SolidBrush brush = new SolidBrush(colorStart))
{
g.FillPath(brush, path);
}
}
}
else
{
rect.Height += 2;
rect.Y--;
using (LinearGradientBrush brush = new LinearGradientBrush(
rect,
colorStart,
colorEnd,
mode.GetValueOrDefault(LinearGradientMode.Vertical)))
{
g.FillPath(brush, path);
}
}
}