protected void LayoutRoundedRectangle (Cairo.Context context, Gdk.Rectangle region, int inflateX = 0, int inflateY = 0, float rounding = 3) { region.Inflate (inflateX, inflateY); CairoExtensions.RoundedRectangle (context, region.X + .5, region.Y + .5, region.Width - 1, region.Height - 1, rounding); }
void RenderBackground (Cairo.Context context, Gdk.Rectangle region) { region.Inflate (-Padding, -Padding); context.RenderOuterShadow (new Gdk.Rectangle (region.X + 10, region.Y + 15, region.Width - 20, region.Height - 15), Padding, 3, .25); context.RoundedRectangle (region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 5); using (var lg = new LinearGradient (0, region.Y, 0, region.Bottom)) { lg.AddColorStop (0, new Cairo.Color (.36, .53, .73)); lg.AddColorStop (1, new Cairo.Color (.21, .37, .54)); context.SetSource (lg); context.FillPreserve (); } context.LineWidth = 1; context.SetSourceRGB (.29, .47, .67); context.Stroke (); }
// VERY SLOW, only use on cached renders public static void RenderOuterShadow (this Cairo.Context self, Gdk.Rectangle area, int size, int rounding, double strength) { area.Inflate (-1, -1); size++; int doubleRounding = rounding * 2; // left side self.Rectangle (area.X - size, area.Y + rounding, size, area.Height - doubleRounding - 1); using (var lg = new LinearGradient (area.X, 0, area.X - size, 0)) { ShadowGradient (lg, strength); self.Pattern = lg; self.Fill (); } // right side self.Rectangle (area.Right, area.Y + rounding, size, area.Height - doubleRounding - 1); using (var lg = new LinearGradient (area.Right, 0, area.Right + size, 0)) { ShadowGradient (lg, strength); self.Pattern = lg; self.Fill (); } // top side self.Rectangle (area.X + rounding, area.Y - size, area.Width - doubleRounding - 1, size); using (var lg = new LinearGradient (0, area.Y, 0, area.Y - size)) { ShadowGradient (lg, strength); self.Pattern = lg; self.Fill (); } // bottom side self.Rectangle (area.X + rounding, area.Bottom, area.Width - doubleRounding - 1, size); using (var lg = new LinearGradient (0, area.Bottom, 0, area.Bottom + size)) { ShadowGradient (lg, strength); self.Pattern = lg; self.Fill (); } // top left corner self.Rectangle (area.X - size, area.Y - size, size + rounding, size + rounding); using (var rg = new RadialGradient (area.X + rounding, area.Y + rounding, rounding, area.X + rounding, area.Y + rounding, size + rounding)) { ShadowGradient (rg, strength); self.Pattern = rg; self.Fill (); } // top right corner self.Rectangle (area.Right - rounding, area.Y - size, size + rounding, size + rounding); using (var rg = new RadialGradient (area.Right - rounding, area.Y + rounding, rounding, area.Right - rounding, area.Y + rounding, size + rounding)) { ShadowGradient (rg, strength); self.Pattern = rg; self.Fill (); } // bottom left corner self.Rectangle (area.X - size, area.Bottom - rounding, size + rounding, size + rounding); using (var rg = new RadialGradient (area.X + rounding, area.Bottom - rounding, rounding, area.X + rounding, area.Bottom - rounding, size + rounding)) { ShadowGradient (rg, strength); self.Pattern = rg; self.Fill (); } // bottom right corner self.Rectangle (area.Right - rounding, area.Bottom - rounding, size + rounding, size + rounding); using (var rg = new RadialGradient (area.Right - rounding, area.Bottom - rounding, rounding, area.Right - rounding, area.Bottom - rounding, size + rounding)) { ShadowGradient (rg, strength); self.Pattern = rg; self.Fill (); } }
void RenderBackground (Cairo.Context context, Gdk.Rectangle region) { region.Inflate (-Padding, -Padding); context.RenderOuterShadow (new Gdk.Rectangle (region.X + 10, region.Y + 15, region.Width - 20, region.Height - 15), Padding, 3, .25); context.RoundedRectangle (region.X + 0.5, region.Y + 0.5, region.Width - 1, region.Height - 1, 5); using (var lg = new LinearGradient (0, region.Y, 0, region.Bottom)) { lg.AddColorStop (0, new Cairo.Color (.36, .53, .73)); lg.AddColorStop (1, new Cairo.Color (.21, .37, .54)); context.Pattern = lg; context.FillPreserve (); } context.Save (); context.Translate (IconPosition.X, IconPosition.Y); context.Scale (0.75, 0.75); Gdk.CairoHelper.SetSourcePixbuf (context, starburst, -starburst.Width / 2, -starburst.Height / 2); context.FillPreserve (); context.Restore (); context.LineWidth = 1; context.Color = new Cairo.Color (.29, .47, .67); context.Stroke (); }