GraphicsTools.cs

Description du code

GraphicsTools.cs est un fichier du projet BrolDev.
Ce fichier est situé dans /var/www/bin/sniplets/bibliobrol/broldev/src/.

Projet BrolDev : Librairie de composants réutilisables pour les applications BrolDev en CSharp.

Code source ou contenu du fichier

  1. using System.Drawing;
  2. using System.Drawing.Drawing2D;
  3.  
  4. namespace be.gaudry.view.style
  5. {
  6. /// <summary>
  7. /// Provides tools for graphics processing
  8. /// </summary>
  9. /// <remarks>
  10. /// 2007 José Manuel Menéndez Poo
  11. /// Visit my blog for upgrades and other renderers - www.menendezpoo.com
  12. /// </remarks>
  13. internal static class GraphicsTools
  14. {
  15. /// <summary>
  16. /// Creates a rounded rectangle from the specified rectangle and radius
  17. /// </summary>
  18. /// <param name="rectangle">Base rectangle</param>
  19. /// <param name="radius">Radius of the corners</param>
  20. /// <returns>Rounded rectangle as a GraphicsPath</returns>
  21. public static GraphicsPath CreateRoundRectangle(Rectangle rectangle, int radius)
  22. {
  23. GraphicsPath path = new GraphicsPath();
  24.  
  25. int l = rectangle.Left;
  26. int t = rectangle.Top;
  27. int w = rectangle.Width;
  28. int h = rectangle.Height;
  29. int d = radius << 1;
  30.  
  31. path.AddArc(l, t, d, d, 180, 90); // topleft
  32. path.AddLine(l + radius, t, l + w - radius, t); // top
  33. path.AddArc(l + w - d, t, d, d, 270, 90); // topright
  34. path.AddLine(l + w, t + radius, l + w, t + h - radius); // right
  35. path.AddArc(l + w - d, t + h - d, d, d, 0, 90); // bottomright
  36. path.AddLine(l + w - radius, t + h, l + radius, t + h); // bottom
  37. path.AddArc(l, t + h - d, d, d, 90, 90); // bottomleft
  38. path.AddLine(l, t + h - radius, l, t + radius); // left
  39. path.CloseFigure();
  40.  
  41. return path;
  42. }
  43.  
  44. /// <summary>
  45. /// Creates a rectangle rounded on the top
  46. /// </summary>
  47. /// <param name="rectangle">Base rectangle</param>
  48. /// <param name="radius">Radius of the top corners</param>
  49. /// <returns>Rounded rectangle (on top) as a GraphicsPath object</returns>
  50. public static GraphicsPath CreateTopRoundRectangle(Rectangle rectangle, int radius)
  51. {
  52. GraphicsPath path = new GraphicsPath();
  53.  
  54. int l = rectangle.Left;
  55. int t = rectangle.Top;
  56. int w = rectangle.Width;
  57. int h = rectangle.Height;
  58. int d = radius << 1;
  59.  
  60. path.AddArc(l, t, d, d, 180, 90); // topleft
  61. path.AddLine(l + radius, t, l + w - radius, t); // top
  62. path.AddArc(l + w - d, t, d, d, 270, 90); // topright
  63. path.AddLine(l + w, t + radius, l + w, t + h); // right
  64. path.AddLine(l + w, t + h, l, t + h); // bottom
  65. path.AddLine(l, t + h, l, t + radius); // left
  66. path.CloseFigure();
  67.  
  68. return path;
  69. }
  70.  
  71. /// <summary>
  72. /// Creates a rectangle rounded on the bottom
  73. /// </summary>
  74. /// <param name="rectangle">Base rectangle</param>
  75. /// <param name="radius">Radius of the bottom corners</param>
  76. /// <returns>Rounded rectangle (on bottom) as a GraphicsPath object</returns>
  77. public static GraphicsPath CreateBottomRoundRectangle(Rectangle rectangle, int radius)
  78. {
  79. GraphicsPath path = new GraphicsPath();
  80.  
  81. int l = rectangle.Left;
  82. int t = rectangle.Top;
  83. int w = rectangle.Width;
  84. int h = rectangle.Height;
  85. int d = radius << 1;
  86.  
  87. path.AddLine(l + radius, t, l + w - radius, t); // top
  88. path.AddLine(l + w, t + radius, l + w, t + h - radius); // right
  89. path.AddArc(l + w - d, t + h - d, d, d, 0, 90); // bottomright
  90. path.AddLine(l + w - radius, t + h, l + radius, t + h); // bottom
  91. path.AddArc(l, t + h - d, d, d, 90, 90); // bottomleft
  92. path.AddLine(l, t + h - radius, l, t + radius); // left
  93. path.CloseFigure();
  94.  
  95. return path;
  96. }
  97. }
  98. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/view/style/vista/ 
IcôneNomTailleModification
Pas de sous-répertoires.
IcôneNomTailleModification
| _ Répertoire parent0 octets1715643392 14/05/2024 01:36:32
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/view/style/vista/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csGraphicsTools.cs3.9 Ko31/10/2018 18:33:22-refusé-
Afficher le fichier .cs|.csWindowsVistaRenderer.cs26.15 Ko31/10/2018 18:33:22-refusé-
Afficher le fichier .cs|.csWindowsVistaColorTable.cs9.6 Ko31/10/2018 18:33:22-refusé-

Utilisation de l'explorateur de code

  • Navigation :
    • Un clic sur une icône de répertoire ouvre ce répertoire pour en afficher les fichiers.
    • Lorsque le répertoire en cours ne contient pas de sous-répertoires il est possible de remonter vers le répertoire parent.
    • La structure de répertoires en treetable (tableau en forme d'arborescence) n'est plus possibledans cette version.
    • Un clic sur une icône de fichier ouvre ce fichier pour en afficher le code avec la coloration syntaxique adaptée en fonction du langage principal utilisé dans le fichier.
  • Affichage :
    • Il est possible de trier les répertoires ou les fichiers selon certains critères (nom, taille, date).
  • Actions :
    • Les actions possible sur les fichiers dépendent de vos droits d'utilisateur sur le site. Veuillez activer le mode utilisateur pour activer les actions.

Document créé le 16/10/2009, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/cs-broldev-source-rf-view/style/vista/GraphicsTools.cs.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.