当前位置: 首页>>代码示例>>C#>>正文


C# IVwGraphics.DrawRectangle方法代码示例

本文整理汇总了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);
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:65,代码来源:Box.cs


注:本文中的IVwGraphics.DrawRectangle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。