public static void DrawCachedShadow(Graphics g, Rectangle rect, StiShadowSides sides) { var cachedRect = rect; if (rect.Width <= 0) { rect.Width = 1; } if (rect.Height <= 0) { rect.Height = 1; } using (var bmp = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb)) { //Color shadowColor = Color.FromArgb(ShadowPower, 0, 0, 0); using (var gg = Graphics.FromImage(bmp)) //using (Brush shadowBrush = new SolidBrush(shadowColor)) { //Core drawing //gg.FillRectangle(shadowBrush, new Rectangle(4, 0, cachedRect.Width - 8, cachedRect.Height - 4)); cachedRect.X = -4; cachedRect.Y = -4; if ((sides & StiShadowSides.Top) > 0) { StiShadow.DrawTopShadow(gg, cachedRect); } if ((sides & StiShadowSides.Right) > 0) { StiShadow.DrawRightShadow(gg, cachedRect); } if ((sides & StiShadowSides.Edge) > 0) { StiShadow.DrawEdgeShadow(gg, cachedRect); } if ((sides & StiShadowSides.Bottom) > 0) { StiShadow.DrawBottomShadow(gg, cachedRect); } if ((sides & StiShadowSides.Left) > 0) { StiShadow.DrawLeftShadow(gg, cachedRect); } } g.DrawImageUnscaled(bmp, rect.X + 4, rect.Y + 4); } }
public static void DrawCachedShadow(Graphics g, RectangleF rect, StiShadowSides sides, bool isSimple) { if (isSimple) { using (var path = new GraphicsPath()) using (var brush = new SolidBrush(Color.FromArgb(50, Color.Black))) { if ((sides & StiShadowSides.Top) > 0) { path.AddRectangle(new RectangleF(rect.Right, rect.Y + 4, 4, 4)); } if ((sides & StiShadowSides.Right) > 0) { path.AddRectangle(new RectangleF(rect.Right, rect.Y + 8, 4, rect.Height - 8)); } if ((sides & StiShadowSides.Edge) > 0) { path.AddRectangle(new RectangleF(rect.Right, rect.Bottom, 4, 4)); } if ((sides & StiShadowSides.Bottom) > 0) { path.AddRectangle(new RectangleF(rect.X + 8, rect.Bottom, rect.Width - 8, 4)); } if ((sides & StiShadowSides.Left) > 0) { path.AddRectangle(new RectangleF(rect.X + 4, rect.Bottom, 4, 4)); } g.FillPath(brush, path); } } else { DrawCachedShadow(g, ConvertRect(rect), sides); } }
public StiCachedShadowGeom(RectangleF rect, StiShadowSides sides, bool isPrinting) { this.Rect = rect; this.Sides = sides; this.IsPrinting = isPrinting; }
public void DrawCachedShadow(RectangleF rect, StiShadowSides sides, bool isPrinting) { geoms.Add(new StiCachedShadowGeom(rect, sides, isPrinting)); }