public void Draw(Graphics g, BrushX brush, RectangleD2D innerArea) { innerArea.Inflate(_shadowLength / 2, _shadowLength / 2); // Padding var outerArea = innerArea; outerArea.Inflate(_shadowLength, _shadowLength); brush.SetEnvironment(outerArea, BrushX.GetEffectiveMaximumResolution(g, 1)); g.FillRectangle(brush, (RectangleF)outerArea); var twhite = new SolidBrush(Color.FromArgb(128, 255, 255, 255)); var oA = (RectangleF)outerArea; var iA = (RectangleF)innerArea; g.FillPolygon(twhite, new PointF[] { new PointF(oA.Left, oA.Top), // upper left point new PointF(oA.Right, oA.Top), // go to the right new PointF(iA.Right, iA.Top), // go 45 deg left down in the upper right corner new PointF(iA.Left, iA.Top), // upper left corner of the inner rectangle new PointF(iA.Left, iA.Bottom), // lower left corner of the inner rectangle new PointF(oA.Left, oA.Bottom) // lower left corner }); var tblack = new SolidBrush(Color.FromArgb(128, 0, 0, 0)); g.FillPolygon(tblack, new PointF[] { new PointF(oA.Right, oA.Bottom), new PointF(oA.Right, oA.Top), new PointF(iA.Right, iA.Top), new PointF(iA.Right, iA.Bottom), // upper left corner of the inner rectangle new PointF(iA.Left, iA.Bottom), // lower left corner of the inner rectangle new PointF(oA.Left, oA.Bottom) // lower left corner }); }
public RectangleD2D MeasureItem(System.Drawing.Graphics g, RectangleD2D innerArea) { innerArea.Inflate(_shadowLength / 2, _shadowLength / 2); innerArea.Width += _shadowLength; innerArea.Height += _shadowLength; return(innerArea); }
public void Draw(System.Drawing.Graphics g, BrushX brush, RectangleD2D innerArea) { BrushX shadowBrush = null; if (object.ReferenceEquals(brush, _brush)) { if (null == _cachedShadowBrush) { _cachedShadowBrush = GetShadowBrush(brush); _cachedShadowBrush.ParentObject = this; } shadowBrush = _cachedShadowBrush; } else { shadowBrush = GetShadowBrush(brush); } innerArea.Inflate(_shadowLength / 2, _shadowLength / 2); // please note: m_Bounds is already extended to the shadow // first the shadow shadowBrush.SetEnvironment(innerArea, BrushX.GetEffectiveMaximumResolution(g, 1)); // shortCuts to floats var iArea = (RectangleF)innerArea; float shadowLength = (float)_shadowLength; g.TranslateTransform(shadowLength, shadowLength); g.FillRectangle(shadowBrush, iArea); g.TranslateTransform(-shadowLength, -shadowLength); brush.SetEnvironment(innerArea, BrushX.GetEffectiveMaximumResolution(g, 1)); g.FillRectangle(brush, iArea); g.DrawRectangle(Pens.Black, iArea.Left, iArea.Top, iArea.Width, iArea.Height); }
public RectangleD2D MeasureItem(System.Drawing.Graphics g, RectangleD2D innerArea) { innerArea.Inflate(3.0 * _shadowLength / 2, 3.0 * _shadowLength / 2); return(innerArea); }