No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

Quadrilateral.cs

Description du code

Quadrilateral.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;
  2. using System.Drawing;
  3. using System.Drawing.Drawing2D;
  4.  
  5. namespace be.gaudry.model.drawing.chart
  6. {
  7. /// <summary>
  8. /// Quadrilateral object.
  9. /// </summary>
  10. public class Quadrilateral : IDisposable
  11. {
  12. /// <summary>
  13. /// Creates empty <c>Quadrilateral</c> object
  14. /// </summary>
  15. protected Quadrilateral() {
  16. }
  17.  
  18. /// <summary>
  19. /// Initilizes <c>Quadrilateral</c> object with given corner points.
  20. /// </summary>
  21. /// <param name="point1">
  22. /// First <c>PointF</c>.
  23. /// </param>
  24. /// <param name="point2">
  25. /// Second <c>PointF</c>.
  26. /// </param>
  27. /// <param name="point3">
  28. /// Third <c>PointF</c>.
  29. /// </param>
  30. /// <param name="point4">
  31. /// Fourth <c>PointF</c>.
  32. /// </param>
  33. /// <param name="toClose">
  34. /// Indicator should the quadrilateral be closed by the line.
  35. /// </param>
  36. public Quadrilateral(PointF point1, PointF point2, PointF point3, PointF point4, bool toClose) {
  37. byte[] pointTypes = (byte[])s_quadrilateralPointTypes.Clone();
  38. if (toClose)
  39. pointTypes[3] |= (byte)PathPointType.CloseSubpath;
  40. m_path = new GraphicsPath(new PointF[] { point1, point2, point3, point4 }, pointTypes);
  41. }
  42.  
  43. /// <summary>
  44. /// <c>Finalize</c> method.
  45. /// </summary>
  46. ~Quadrilateral() {
  47. Dispose(false);
  48. }
  49.  
  50. /// <summary>
  51. /// Implementation of <c>IDisposable</c> interface.
  52. /// </summary>
  53. public void Dispose() {
  54. Dispose(true);
  55. GC.SuppressFinalize(this);
  56. }
  57.  
  58. /// <summary>
  59. /// Disposes of all pie slices.
  60. /// </summary>
  61. protected virtual void Dispose(bool disposing) {
  62. if (!m_disposed) {
  63. if (disposing) {
  64. m_path.Dispose();
  65. }
  66. m_disposed = true;
  67. }
  68. }
  69.  
  70. /// <summary>
  71. /// Draws the <c>Quadrilateral</c> with <c>Graphics</c> provided.
  72. /// </summary>
  73. /// <param name="graphics">
  74. /// <c>Graphics</c> used to draw.
  75. /// </param>
  76. /// <param name="pen">
  77. /// <c>Pen</c> used to draw outline.
  78. /// </param>
  79. /// <param name="brush">
  80. /// <c>Brush</c> used to fill the inside.
  81. /// </param>
  82. public void Draw(Graphics graphics, Pen pen, Brush brush) {
  83. graphics.FillPath(brush, m_path);
  84. graphics.DrawPath(pen, m_path);
  85. }
  86.  
  87. /// <summary>
  88. /// Checks if the given <c>PointF</c> is contained within the
  89. /// quadrilateral.
  90. /// </summary>
  91. /// <param name="point">
  92. /// <c>PointF</c> structure to check for.
  93. /// </param>
  94. /// <returns>
  95. /// <c>true</c> if the point is contained within the quadrilateral.
  96. /// </returns>
  97. public bool Contains(PointF point) {
  98. if (m_path.PointCount == 0 || m_path.PathPoints.Length == 0)
  99. return false;
  100. return Contains(point, m_path.PathPoints);
  101. }
  102.  
  103. /// <summary>
  104. /// Checks if given <c>PointF</c> is contained within quadrilateral
  105. /// defined by <c>cornerPoints</c> provided.
  106. /// </summary>
  107. /// <param name="point">
  108. /// <c>PointF</c> to check.
  109. /// </param>
  110. /// <param name="cornerPoints">
  111. /// Array of <c>PointF</c> structures defining corners of the
  112. /// quadrilateral.
  113. /// </param>
  114. /// <returns>
  115. /// <c>true</c> if the point is contained within the quadrilateral.
  116. /// </returns>
  117. public static bool Contains(PointF point, PointF[] cornerPoints) {
  118. int intersections = 0;
  119. for (int i = 1; i < cornerPoints.Length; ++i) {
  120. if (DoesIntersect(point, cornerPoints[i], cornerPoints[i - 1]))
  121. ++intersections;
  122. }
  123. if (DoesIntersect(point, cornerPoints[cornerPoints.Length - 1], cornerPoints[0]))
  124. ++intersections;
  125. return (intersections % 2 != 0);
  126. }
  127.  
  128. /// <summary>
  129. /// Checks if the line coming out of the <c>point</c> downwards
  130. /// intersects with a line through <c>point1</c> and <c>point2</c>.
  131. /// </summary>
  132. /// <param name="point">
  133. /// <c>PointF</c> from which vertical line is drawn downwards.
  134. /// </param>
  135. /// <param name="point1">
  136. /// First <c>PointF</c> through which line is drawn.
  137. /// </param>
  138. /// <param name="point2">
  139. /// Second <c>PointF</c> through which line is drawn.
  140. /// </param>
  141. /// <returns>
  142. /// <c>true</c> if lines intersect.
  143. /// </returns>
  144. private static bool DoesIntersect(PointF point, PointF point1, PointF point2) {
  145. float x2 = point2.X;
  146. float y2 = point2.Y;
  147. float x1 = point1.X;
  148. float y1 = point1.Y;
  149. if ((x2 < point.X && x1 >= point.X) || (x2 >= point.X && x1 < point.X)) {
  150. float y = (y2 - y1) / (x2 - x1) * (point.X - x1) + y1;
  151. return y > point.Y;
  152. }
  153. return false;
  154. }
  155.  
  156. /// <summary>
  157. /// <c>GraphicsPath</c> representing the quadrilateral.
  158. /// </summary>
  159. private GraphicsPath m_path = new GraphicsPath();
  160.  
  161. private bool m_disposed = false;
  162.  
  163. /// <summary>
  164. /// <c>PathPointType</c>s decribing the <c>GraphicsPath</c> points.
  165. /// </summary>
  166. private static byte[] s_quadrilateralPointTypes = new byte[] {
  167. (byte)PathPointType.Start,
  168. (byte)PathPointType.Line,
  169. (byte)PathPointType.Line,
  170. (byte)PathPointType.Line | (byte)PathPointType.CloseSubpath
  171. };
  172.  
  173. public static readonly Quadrilateral Empty = new Quadrilateral();
  174. }
  175. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/model/drawing/chart/ 
IcôneNomTailleModification
Pas de sous-répertoires.
IcôneNomTailleModification
| _ Répertoire parent0 octets1715948549 17/05/2024 14:22:29
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/model/drawing/chart/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csShadowStyle.cs620 octets31/10/2018 18:33:22-refusé-
Afficher le fichier .cs|.csEdgeColor.cs2.92 Ko31/10/2018 18:33:21-refusé-
Afficher le fichier .cs|.csPieChart.cs44.97 Ko31/10/2018 18:33:22-refusé-
Afficher le fichier .cs|.csColorUtil.cs2.05 Ko31/10/2018 18:33:21-refusé-
Afficher le fichier .resx|.resxPieChartControl.resx1.69 Ko31/10/2018 18:33:22-refusé-
Afficher le fichier .cs|.csPieChartControl.cs14.04 Ko31/10/2018 18:33:22-refusé-
Afficher le fichier .cs|.csPieSlice.cs52.86 Ko31/10/2018 18:33:22-refusé-
Afficher le fichier .cs|.csGraphicsUtil.cs2.33 Ko31/10/2018 18:33:21-refusé-
Afficher le fichier .cs|.csQuadrilateral.cs6.42 Ko31/10/2018 18:33:22-refusé-
Afficher le fichier .cs|.csEdgeColorType.cs1.64 Ko31/10/2018 18:33:21-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.

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 16/10/2009, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/cs-broldev-source-rf-model/drawing/chart/Quadrilateral.cs.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.