Chart.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. //
  2. // Authors:
  3. // Jonathan Pobst ([email protected])
  4. // Francis Fisher ([email protected])
  5. //
  6. // Copyright (C) 2009 Novell, Inc (http://www.novell.com)
  7. //
  8. // Permission is hereby granted, free of charge, to any person obtaining
  9. // a copy of this software and associated documentation files (the
  10. // "Software"), to deal in the Software without restriction, including
  11. // without limitation the rights to use, copy, modify, merge, publish,
  12. // distribute, sublicense, and/or sell copies of the Software, and to
  13. // permit persons to whom the Software is furnished to do so, subject to
  14. // the following conditions:
  15. //
  16. // The above copyright notice and this permission notice shall be
  17. // included in all copies or substantial portions of the Software.
  18. //
  19. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  23. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  24. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  25. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26. using System;
  27. using System.Drawing;
  28. using System.Drawing.Imaging;
  29. using System.IO;
  30. using System.ComponentModel;
  31. using System.Data.Common;
  32. namespace System.Windows.Forms.DataVisualization.Charting
  33. {
  34. public class Chart : Control, ISupportInitialize, IDisposable
  35. {
  36. public Chart ()
  37. {
  38. BackColor = Color.White;
  39. ChartAreas = new ChartAreaCollection ();
  40. Series = new SeriesCollection ();
  41. }
  42. public AnnotationCollection Annotations { get; private set;}
  43. public AntiAliasingStyles AntiAliasing { get; set; }
  44. public override Color BackColor { get; set; }
  45. public GradientStyle BackGradientStyle { get; set; }
  46. public override Image BackgroundImage { get; set; }
  47. public ChartHatchStyle BackHatchStyle { get; set; }
  48. public string BackImage { get; set; }
  49. public ChartImageAlignmentStyle BackImageAlignment { get; set; }
  50. public Color BackImageTransparentColor { get; set; }
  51. public ChartImageWrapMode BackImageWrapMode { get; set; }
  52. public Color BackSecondaryColor { get; set; }
  53. public Color BorderColor { get; set; }
  54. public ChartDashStyle BorderDashStyle { get; set; }
  55. public Color BorderlineColor { get; set; }
  56. public ChartDashStyle BorderlineDashStyle { get; set; }
  57. public int BorderlineWidth { get; set; }
  58. public BorderSkin BorderSkin { get; set; }
  59. public int BorderWidth { get; set; }
  60. public string BuildNumber { get; private set;}
  61. public ChartAreaCollection ChartAreas { get; private set; }
  62. public DataManipulator DataManipulator { get; private set;}
  63. public Object DataSource { get; set; }
  64. protected override Size DefaultSize { get { return DefaultSize; } }//FIXME
  65. public Font Font { get; set; }
  66. public override Color ForeColor { get; set; }
  67. public NamedImagesCollection Images { get; private set;}
  68. public bool IsSoftShadows { get; set; }
  69. public LegendCollection Legends { get; private set; }
  70. public ChartColorPalette Palette { get; set; }
  71. public Color[] PaletteCustomColors { get; set; }
  72. public PrintingManager Printing { get; private set;}
  73. public double RenderingDpiX { get; set; }
  74. public double RenderingDpiY { get; set; }
  75. public ChartSerializer Serializer { get; private set; }
  76. public SeriesCollection Series { get; private set; }
  77. public Size Size { get; set; }
  78. public bool SuppressExceptions { get; set; }
  79. public TextAntiAliasingQuality TextAntiAliasingQuality { get; set; }
  80. public TitleCollection Titles { get; private set;}
  81. #region Protected Properties
  82. protected override void OnPaint (PaintEventArgs e)
  83. {
  84. base.OnPaint (e);
  85. ChartGraphics g = new ChartGraphics (e.Graphics);
  86. PaintElement (g, this, new ElementPosition (0, 0, 100, 100));
  87. foreach (var area in ChartAreas)
  88. PaintElement (g, area, new ElementPosition (9.299009f, 6.15f, 86.12599f, 81.1875f));
  89. foreach (var series in Series)
  90. PaintElement (g, series, new ElementPosition (9.299009f, 6.15f, 86.12599f, 81.1875f));
  91. }
  92. protected override void OnPaintBackground (PaintEventArgs pevent)
  93. {
  94. base.OnPaintBackground (pevent);
  95. }
  96. protected virtual void OnPostPaint (ChartPaintEventArgs e)
  97. {
  98. }
  99. protected virtual void OnPrePaint (ChartPaintEventArgs e)
  100. {
  101. }
  102. #endregion
  103. public event EventHandler AnnotationPlaced;
  104. public event EventHandler AnnotationPositionChanged;
  105. public event EventHandler<AnnotationPositionChangingEventArgs> AnnotationPositionChanging;
  106. public event EventHandler AnnotationSelectionChanged;
  107. public event EventHandler AnnotationTextChanged;
  108. public event EventHandler<ScrollBarEventArgs> AxisScrollBarClicked;
  109. public event EventHandler<ViewEventArgs> AxisViewChanged;
  110. public event EventHandler<ViewEventArgs> AxisViewChanging;
  111. public event EventHandler<CursorEventArgs> CursorPositionChanged;
  112. public event EventHandler<CursorEventArgs> CursorPositionChanging;
  113. public event EventHandler Customize;
  114. public event EventHandler<CustomizeLegendEventArgs> CustomizeLegend;
  115. public event EventHandler<FormatNumberEventArgs> FormatNumber;
  116. public event EventHandler<ToolTipEventArgs> GetToolTipText;
  117. public event EventHandler<ChartPaintEventArgs> PostPaint;
  118. public event EventHandler<ChartPaintEventArgs> PrePaint;
  119. public event EventHandler<CursorEventArgs> SelectionRangeChanged;
  120. public event EventHandler<CursorEventArgs> SelectionRangeChanging;
  121. #region Public Methods
  122. [MonoTODO]
  123. public void AlignDataPointsByAxisLabel ()
  124. {
  125. throw new NotImplementedException ();
  126. }
  127. [MonoTODO]
  128. public void AlignDataPointsByAxisLabel (PointSortOrder sortingOrder)
  129. {
  130. throw new NotImplementedException ();
  131. }
  132. [MonoTODO]
  133. public void AlignDataPointsByAxisLabel(string series)
  134. {
  135. throw new NotImplementedException ();
  136. }
  137. [MonoTODO]
  138. public void AlignDataPointsByAxisLabel (string series, PointSortOrder sortingOrder)
  139. {
  140. throw new NotImplementedException ();
  141. }
  142. [MonoTODO]
  143. public void ApplyPaletteColors ()
  144. {
  145. throw new NotImplementedException ();
  146. }
  147. [MonoTODO]
  148. public void BeginInit ()
  149. {
  150. throw new NotImplementedException ();
  151. }
  152. [MonoTODO]
  153. public void DataBind ()
  154. {
  155. throw new NotImplementedException ();
  156. }
  157. [MonoTODO]
  158. public void DataBindCrossTable (System.Collections.IEnumerable dataSource, string seriesGroupByField, string xField, string yFields, string otherFields)
  159. {
  160. throw new NotImplementedException ();
  161. }
  162. [MonoTODO]
  163. public void DataBindCrossTable (System.Collections.IEnumerable dataSource, string seriesGroupByField, string xField, string yFields, string otherFields, PointSortOrder sortingOrder)
  164. {
  165. throw new NotImplementedException ();
  166. }
  167. [MonoTODO]
  168. public void DataBindTable (System.Collections.IEnumerable dataSource)
  169. {
  170. throw new NotImplementedException ();
  171. }
  172. [MonoTODO]
  173. public void DataBindTable (System.Collections.IEnumerable dataSource, string xField)
  174. {
  175. throw new NotImplementedException ();
  176. }
  177. [MonoTODO]
  178. public void EndInit ()
  179. {
  180. throw new NotImplementedException ();
  181. }
  182. [MonoTODO]
  183. public HitTestResult HitTest (int x, int y)
  184. {
  185. throw new NotImplementedException ();
  186. }
  187. [MonoTODO]
  188. public HitTestResult HitTest (int x, int y, bool ignoreTransparent)
  189. {
  190. throw new NotImplementedException ();
  191. }
  192. [MonoTODO]
  193. public HitTestResult HitTest (int x, int y, ChartElementType requestedElement)
  194. {
  195. throw new NotImplementedException ();
  196. }
  197. [MonoTODO]
  198. public HitTestResult[] HitTest (int x, int y, bool ignoreTransparent, params ChartElementType[] requestedElement)
  199. {
  200. throw new NotImplementedException ();
  201. }
  202. [MonoTODO]
  203. public void LoadTemplate (Stream stream)
  204. {
  205. throw new NotImplementedException ();
  206. }
  207. [MonoTODO]
  208. public void LoadTemplate (string name)
  209. {
  210. throw new NotImplementedException ();
  211. }
  212. [MonoTODO]
  213. public void ResetAutoValues ()
  214. {
  215. throw new NotImplementedException ();
  216. }
  217. [MonoTODO]
  218. public void SaveImage (Stream imageStream, ImageFormat format)
  219. {
  220. throw new NotImplementedException ();
  221. }
  222. [MonoTODO]
  223. public void SaveImage (Stream imageStream, ChartImageFormat format)
  224. {
  225. throw new NotImplementedException ();
  226. }
  227. [MonoTODO]
  228. public void SaveImage (string imageFileName, ImageFormat format)
  229. {
  230. throw new NotImplementedException ();
  231. }
  232. [MonoTODO]
  233. public void SaveImage (string imageFileName, ChartImageFormat format)
  234. {
  235. throw new NotImplementedException ();
  236. }
  237. #endregion
  238. #region Protected Methods
  239. protected override void Dispose (bool disposing)
  240. {
  241. }
  242. #endregion
  243. #region Private Methods
  244. private void PaintElement (ChartGraphics g, object element, ElementPosition position)
  245. {
  246. ChartPaintEventArgs e = new ChartPaintEventArgs (this, element, g, position);
  247. OnPrePaint (e);
  248. OnPostPaint (e);
  249. }
  250. #endregion
  251. }
  252. }