本文整理汇总了C#中IVwGraphics.DrawLine方法的典型用法代码示例。如果您正苦于以下问题:C# IVwGraphics.DrawLine方法的具体用法?C# IVwGraphics.DrawLine怎么用?C# IVwGraphics.DrawLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVwGraphics
的用法示例。
在下文中一共展示了IVwGraphics.DrawLine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawUnderline
/// <summary>
/// Draw an underline from xdLeft to xdRight at ydTop, given the specified screen resolution,
/// the desired colur and underline type, and (for aligning squiggles) the offset in the
/// destination drawing rectangle.
/// </summary>
static void DrawUnderline(IVwGraphics pvg, int xdLeft, int xdRight, int ydTop,
int dxScreenPix, int dyScreenPix, int clrUnder, FwUnderlineType unt, int xOffset)
{
int[] rgdx;
pvg.ForeColor = clrUnder;
int xStartPattern;
switch (unt)
{
case FwUnderlineType.kuntSquiggle:
{
// BLOCK for var decls
// ENHANCE JohnT: should we do some trick to make it look continuous
// even if drawn in multiple chunks?
// Note: going up as well as down from ydTop makes the squiggle
// actually touch the bottom of typical letters. This is consistent
// with Word; FrontPage puts the squiggle one pixel clear. If we want
// the latter effect, just use ydTop + dyScreenPix.
int dxdSeg = Math.Max(1, dxScreenPix*2);
int xdStartFromTrueLeft = ((xdLeft - xOffset)/dxdSeg)*dxdSeg; // aligns it to multiple of dxdSeg
int xdStart = xdStartFromTrueLeft + xOffset; // back in drawing coords
int dydStart = -dyScreenPix; // toggle for up/down segs
// Initial value is determined by whether xdStart is an odd or even multiple
// of dxdSeg.
if (xdStartFromTrueLeft%(dxdSeg*2) != 0)
dydStart = -dydStart;
while (xdStart < xdRight)
{
int xdEnd = xdStart + dxdSeg;
pvg.DrawLine(xdStart, ydTop + dydStart, xdEnd, ydTop - dydStart);
dydStart = -dydStart;
xdStart = xdEnd;
}
}
// This uses diagonal lines so don't break and draw a straight one, return
return;
case FwUnderlineType.kuntDotted:
rgdx = new [] {dxScreenPix*2, dxScreenPix*2};
break;
case FwUnderlineType.kuntDashed:
rgdx = new [] { dxScreenPix * 6, dxScreenPix * 3 };
break;
case FwUnderlineType.kuntStrikethrough:
{
int dydAscent = pvg.FontAscent;
ydTop = ydTop - dydAscent/3;
rgdx = new [] {int.MaxValue};
break;
}
case FwUnderlineType.kuntDouble:
xStartPattern = xdLeft;
rgdx = new [] { int.MaxValue };
pvg.DrawHorzLine(xdLeft, xdRight, ydTop + dyScreenPix * 2, dyScreenPix,
1, rgdx, ref xStartPattern);
// continue to draw the upper line as well, just like a normal underline.
break;
case FwUnderlineType.kuntSingle:
// For (some) forwards compatibility, treat any unrecognized underline
// type as single.
default:
rgdx = new [] { int.MaxValue };
break;
}
xStartPattern = xdLeft;
pvg.DrawHorzLine(xdLeft, xdRight, ydTop, dyScreenPix,
rgdx.Length, rgdx, ref xStartPattern);
}