MatrixStyleSheet.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Drawing;
  5. namespace FastReport.Matrix
  6. {
  7. internal class MatrixStyleSheet : StyleSheet
  8. {
  9. public Bitmap GetStyleBitmap(int index)
  10. {
  11. StyleCollection styleCollection = this[index];
  12. Style style = styleCollection[styleCollection.IndexOf("Header")];
  13. Color headerColor = Color.White;
  14. if (style.Fill is SolidFill)
  15. headerColor = (style.Fill as SolidFill).Color;
  16. else if (style.Fill is LinearGradientFill)
  17. headerColor = (style.Fill as LinearGradientFill).StartColor;
  18. style = styleCollection[styleCollection.IndexOf("Body")];
  19. Color bodyColor = Color.White;
  20. if (style.Fill is SolidFill)
  21. bodyColor = (style.Fill as SolidFill).Color;
  22. else if (style.Fill is LinearGradientFill)
  23. bodyColor = (style.Fill as LinearGradientFill).StartColor;
  24. // draw style picture
  25. Bitmap result = new Bitmap(16, 16);
  26. using (Graphics g = Graphics.FromImage(result))
  27. {
  28. g.FillRectangle(Brushes.White, 0, 0, 16, 16);
  29. using (Brush b = new SolidBrush(headerColor))
  30. {
  31. g.FillRectangle(b, 0, 0, 15, 8);
  32. }
  33. using (Brush b = new SolidBrush(bodyColor))
  34. {
  35. g.FillRectangle(b, 0, 8, 15, 8);
  36. }
  37. g.DrawRectangle(Pens.Silver, 0, 0, 14, 14);
  38. }
  39. return result;
  40. }
  41. }
  42. }