CheckBoxPainter.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // Permission is hereby granted, free of charge, to any person obtaining
  2. // a copy of this software and associated documentation files (the
  3. // "Software"), to deal in the Software without restriction, including
  4. // without limitation the rights to use, copy, modify, merge, publish,
  5. // distribute, sublicense, and/or sell copies of the Software, and to
  6. // permit persons to whom the Software is furnished to do so, subject to
  7. // the following conditions:
  8. //
  9. // The above copyright notice and this permission notice shall be
  10. // included in all copies or substantial portions of the Software.
  11. //
  12. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  13. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  15. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  16. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  17. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  18. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  19. //
  20. // Copyright (c) 2008 George Giolfan
  21. //
  22. // Authors:
  23. // George Giolfan ([email protected])
  24. using System.Drawing;
  25. using System.Windows.Forms.VisualStyles;
  26. namespace System.Windows.Forms.Theming.VisualStyles
  27. {
  28. class CheckBoxPainter : Default.CheckBoxPainter
  29. {
  30. public override void DrawNormalCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
  31. {
  32. CheckBoxState check_box_state;
  33. switch (state) {
  34. case CheckState.Checked:
  35. check_box_state = CheckBoxState.CheckedNormal;
  36. break;
  37. case CheckState.Indeterminate:
  38. check_box_state = CheckBoxState.MixedNormal;
  39. break;
  40. default:
  41. check_box_state = CheckBoxState.UncheckedNormal;
  42. break;
  43. }
  44. DrawCheckBox (g, bounds, check_box_state);
  45. }
  46. public override void DrawHotCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
  47. {
  48. CheckBoxState check_box_state;
  49. switch (state) {
  50. case CheckState.Checked:
  51. check_box_state = CheckBoxState.CheckedHot;
  52. break;
  53. case CheckState.Indeterminate:
  54. check_box_state = CheckBoxState.MixedHot;
  55. break;
  56. default:
  57. check_box_state = CheckBoxState.UncheckedHot;
  58. break;
  59. }
  60. DrawCheckBox (g, bounds, check_box_state);
  61. }
  62. public override void DrawPressedCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
  63. {
  64. CheckBoxState check_box_state;
  65. switch (state) {
  66. case CheckState.Checked:
  67. check_box_state = CheckBoxState.CheckedPressed;
  68. break;
  69. case CheckState.Indeterminate:
  70. check_box_state = CheckBoxState.MixedPressed;
  71. break;
  72. default:
  73. check_box_state = CheckBoxState.UncheckedPressed;
  74. break;
  75. }
  76. DrawCheckBox (g, bounds, check_box_state);
  77. }
  78. public override void DrawDisabledCheckBox (Graphics g, Rectangle bounds, Color backColor, Color foreColor, CheckState state)
  79. {
  80. CheckBoxState check_box_state;
  81. switch (state) {
  82. case CheckState.Checked:
  83. check_box_state = CheckBoxState.CheckedDisabled;
  84. break;
  85. case CheckState.Indeterminate:
  86. check_box_state = CheckBoxState.MixedDisabled;
  87. break;
  88. default:
  89. check_box_state = CheckBoxState.UncheckedDisabled;
  90. break;
  91. }
  92. DrawCheckBox (g, bounds, check_box_state);
  93. }
  94. static void DrawCheckBox (Graphics g, Rectangle bounds, CheckBoxState state)
  95. {
  96. CheckBoxRenderer.DrawCheckBox (
  97. g,
  98. bounds.Location,
  99. state
  100. );
  101. }
  102. }
  103. }