Example #1
0
		public override void PaintBackground(Common.COMInterfaces.IVwGraphics vg, PaintTransform ptrans)
		{
			base.PaintBackground(vg, ptrans); // might paint some pad or border around the block.
			Rectangle paintRect = ptrans.ToPaint(new Rectangle(Left + GapLeading(ptrans), Top + GapTop(ptrans),
				ptrans.MpToPixelsX(MpWidth), ptrans.MpToPixelsY(MpHeight)));
			vg.BackColor = (int) ColorUtil.ConvertColorToBGR(BlockColor);
			vg.DrawRectangle(paintRect.Left, paintRect.Top, paintRect.Right, paintRect.Bottom);
		}
Example #2
0
        public override void PaintBackground(Common.COMInterfaces.IVwGraphics vg, PaintTransform ptrans)
        {
            base.PaintBackground(vg, ptrans);             // might paint some pad or border around the block.
            Rectangle paintRect = ptrans.ToPaint(new Rectangle(Left + GapLeading(ptrans), Top + GapTop(ptrans),
                                                               ptrans.MpToPixelsX(MpWidth), ptrans.MpToPixelsY(MpHeight)));

            vg.BackColor = (int)ColorUtil.ConvertColorToBGR(BlockColor);
            vg.DrawRectangle(paintRect.Left, paintRect.Top, paintRect.Right, paintRect.Bottom);
        }
Example #3
0
        /// <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);
            }
        }
Example #4
0
		/// <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);
		}