本文整理汇总了C#中IVwGraphics.DrawRectangle方法的典型用法代码示例。如果您正苦于以下问题:C# IVwGraphics.DrawRectangle方法的具体用法?C# IVwGraphics.DrawRectangle怎么用?C# IVwGraphics.DrawRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVwGraphics
的用法示例。
在下文中一共展示了IVwGraphics.DrawRectangle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PaintBackground
/// <summary>
/// Any box knows how to paint its background. Some subclasses may override.
/// </summary>
public virtual void PaintBackground(IVwGraphics vg, PaintTransform ptrans)
{
if (BorderTop == 0 && BorderBottom == 0 && BorderLeading == 0 && BorderTrailing == 0
&& Style.BackColor.ToArgb() == Color.Transparent.ToArgb())
return;
// Margin thicknesses
int dxsMLeft = ptrans.MpToPixelsX(Style.Margins.LeadingMp);
int dysMTop = ptrans.MpToPixelsY(Style.Margins.TopMp);
int dxsMRight = ptrans.MpToPixelsX(Style.Margins.TrailingMp);
int dysMBottom = ptrans.MpToPixelsY(Style.Margins.BottomMp);
SwapIfRightToLeft(ref dxsMLeft, ref dxsMRight);
// outside of border rectangle
int xdLeftBord = ptrans.ToPaintX(dxsMLeft + Left);
int ydTopBord = ptrans.ToPaintY(dysMTop + Top);
int xdRightBord = ptrans.ToPaintX(Right - dxsMRight);
int ydBottomBord = ptrans.ToPaintY(Bottom - dysMBottom);
// Border thickness in pixels.
int dxdLeftBord = ptrans.MpToBorderPixelsX(BorderLeading);
int dydTopBord = ptrans.MpToBorderPixelsY(BorderTop);
int dxdRightBord = ptrans.MpToBorderPixelsX(BorderTrailing);
int dydBottomBord = ptrans.MpToBorderPixelsY(BorderBottom);
SwapIfRightToLeft(ref dxdLeftBord, ref dxdRightBord);
// inside of border rectangle, outside of pad rectangle
int xdLeftPad = xdLeftBord + dxdLeftBord;
int ydTopPad = ydTopBord + dydTopBord;
int xdRightPad = xdRightBord - dxdRightBord;
int ydBottomPad = ydBottomBord - dydBottomBord;
// Wanted this in the old Views version, not sure if it may become relevant here.
//// no pad, border, or margin to left of extension box.
//if (IsBoxFromTsString())
// xdLeftPad = xdLeftBord = rcSrc.MapXTo(m_xsLeft, rcDst);
//// no pad, border, or margin to right of box followed by
//// extension
//if (m_pboxNext && m_pboxNext->IsBoxFromTsString())
// xdRightPad = xdRightBord = rcSrc.MapXTo(m_xsLeft + m_dxsWidth, rcDst);
// Draw background
if (Style.BackColor.ToArgb() != Color.Transparent.ToArgb())
{
vg.BackColor = (int) ColorUtil.ConvertColorToBGR(Style.BackColor);
vg.DrawRectangle(xdLeftPad, ydTopPad, xdRightPad, ydBottomPad);
}
// Draw border lines. We initially set the background color because we draw the
// borders using rectangles, and DrawRectangle uses the background color
vg.BackColor = (int) ColorUtil.ConvertColorToBGR(Style.BorderColor);
if (xdLeftPad != xdLeftBord)
vg.DrawRectangle(xdLeftBord, ydTopBord, xdLeftPad, ydBottomBord);
if (ydTopBord != ydTopPad)
vg.DrawRectangle(xdLeftBord, ydTopBord, xdRightBord, ydTopPad);
if (xdRightPad != xdRightBord)
vg.DrawRectangle(xdRightPad, ydTopBord, xdRightBord, ydBottomBord);
if (ydBottomPad != ydBottomBord)
vg.DrawRectangle(xdLeftBord, ydBottomPad, xdRightBord, ydBottomBord);
}