Merge pull request #900 from Blewzman/FixAggregateExceptionGetBaseException
[mono.git] / mcs / class / System.Windows.Forms.DataVisualization / System.Windows.Forms.DataVisualization.Charting / Chart.cs
1 //
2 // Authors:
3 // Jonathan Pobst (monkey@jpobst.com)
4 // Francis Fisher (frankie@terrorise.me.uk)
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
27 using System;
28 using System.Drawing;
29 using System.Drawing.Imaging;
30 using System.IO;
31 using System.ComponentModel;
32 using System.Data.Common;
33
34 namespace System.Windows.Forms.DataVisualization.Charting
35 {
36         public class Chart : Control, ISupportInitialize, IDisposable
37         {
38                 public Chart ()
39                 {
40                         BackColor = Color.White;
41                         ChartAreas = new ChartAreaCollection ();
42                         Series = new SeriesCollection ();
43                 }
44                 public AnnotationCollection Annotations { get; private set;}
45                 public AntiAliasingStyles AntiAliasing { get; set; }
46                 public override Color BackColor { get; set; }
47                 public GradientStyle BackGradientStyle { get; set; }
48                 public override Image BackgroundImage { get; set; }
49                 public ChartHatchStyle BackHatchStyle { get; set; }
50                 public string BackImage { get; set; }
51                 public ChartImageAlignmentStyle BackImageAlignment { get; set; }
52                 public Color BackImageTransparentColor { get; set; }
53                 public ChartImageWrapMode BackImageWrapMode { get; set; }
54                 public Color BackSecondaryColor { get; set; }
55                 public Color BorderColor { get; set; }
56                 public ChartDashStyle BorderDashStyle { get; set; }
57                 public Color BorderlineColor { get; set; }
58                 public ChartDashStyle BorderlineDashStyle { get; set; }
59                 public int BorderlineWidth { get; set; }
60                 public BorderSkin BorderSkin { get; set; }
61                 public int BorderWidth { get; set; }
62                 public string BuildNumber { get; private set;}
63                 public ChartAreaCollection ChartAreas { get; private set; }
64                 public DataManipulator DataManipulator { get; private set;}
65                 public Object DataSource { get; set; }
66                 protected override Size DefaultSize { get { return base.DefaultSize; } }//FIXME
67                 public Font Font { get; set; }
68                 public override Color ForeColor { get; set; }
69                 public NamedImagesCollection Images { get; private set;}
70                 public bool IsSoftShadows { get; set; }
71                 public LegendCollection Legends { get; private set; }
72                 public ChartColorPalette Palette { get; set; }
73                 public Color[] PaletteCustomColors { get; set; }
74                 public PrintingManager Printing { get; private set;}
75                 public double RenderingDpiX { get; set; }
76                 public double RenderingDpiY { get; set; }
77                 public ChartSerializer Serializer { get; private set; }
78                 public SeriesCollection Series { get; private set; }
79                 public Size Size { get; set; }
80                 public bool SuppressExceptions { get; set; }
81                 public TextAntiAliasingQuality TextAntiAliasingQuality { get; set; }
82                 public TitleCollection Titles { get; private set;}
83
84                 #region Protected Properties
85                 protected override void OnPaint (PaintEventArgs e)
86                 {
87                         base.OnPaint (e);
88
89                         ChartGraphics g = new ChartGraphics (e.Graphics);
90
91                         PaintElement (g, this, new ElementPosition (0, 0, 100, 100));
92
93                         foreach (var area in ChartAreas)
94                                 PaintElement (g, area, new ElementPosition (9.299009f, 6.15f, 86.12599f, 81.1875f));
95
96                         foreach (var series in Series)
97                                 PaintElement (g, series, new ElementPosition (9.299009f, 6.15f, 86.12599f, 81.1875f));
98                 }
99
100                 protected override void OnPaintBackground (PaintEventArgs pevent)
101                 {
102                         base.OnPaintBackground (pevent);
103                 }
104
105                 protected virtual void OnPostPaint (ChartPaintEventArgs e)
106                 {
107                 }
108
109                 protected virtual void OnPrePaint (ChartPaintEventArgs e)
110                 {
111                 }
112                 #endregion
113
114
115
116                 public event EventHandler AnnotationPlaced;
117                 public event EventHandler AnnotationPositionChanged;
118                 public event EventHandler<AnnotationPositionChangingEventArgs> AnnotationPositionChanging;
119                 public event EventHandler AnnotationSelectionChanged;
120                 public event EventHandler AnnotationTextChanged;
121                 public event EventHandler<ScrollBarEventArgs> AxisScrollBarClicked;
122                 public event EventHandler<ViewEventArgs> AxisViewChanged;
123                 public event EventHandler<ViewEventArgs> AxisViewChanging;
124                 public event EventHandler<CursorEventArgs> CursorPositionChanged;
125                 public event EventHandler<CursorEventArgs> CursorPositionChanging;
126                 public event EventHandler Customize;
127                 public event EventHandler<CustomizeLegendEventArgs> CustomizeLegend;
128                 public event EventHandler<FormatNumberEventArgs> FormatNumber;
129                 public event EventHandler<ToolTipEventArgs> GetToolTipText;
130                 public event EventHandler<ChartPaintEventArgs> PostPaint;
131                 public event EventHandler<ChartPaintEventArgs> PrePaint;
132                 public event EventHandler<CursorEventArgs> SelectionRangeChanged;
133                 public event EventHandler<CursorEventArgs> SelectionRangeChanging;
134
135
136                 #region Public Methods
137
138                 [MonoTODO]
139                 public void AlignDataPointsByAxisLabel ()
140                 {
141                         throw new NotImplementedException ();
142                 }
143                 [MonoTODO]
144                 public void AlignDataPointsByAxisLabel (PointSortOrder sortingOrder)
145                 {
146                         throw new NotImplementedException ();
147                 }
148                 [MonoTODO]
149                 public void AlignDataPointsByAxisLabel(string series)
150                 {
151                         throw new NotImplementedException ();
152                 }
153                 [MonoTODO]
154                 public void AlignDataPointsByAxisLabel (string series, PointSortOrder sortingOrder)
155                 {
156                         throw new NotImplementedException ();
157                 }
158
159                 [MonoTODO]
160                 public void ApplyPaletteColors ()
161                 {
162                         throw new NotImplementedException ();
163                 }
164
165                 [MonoTODO]
166                 public void BeginInit ()
167                 {
168                         throw new NotImplementedException ();
169                 }
170
171                 [MonoTODO]
172                 public void DataBind ()
173                 {
174                         throw new NotImplementedException ();
175                 }
176
177                 [MonoTODO]
178                 public void DataBindCrossTable (System.Collections.IEnumerable dataSource, string seriesGroupByField, string xField, string yFields, string otherFields)
179                 {
180                         throw new NotImplementedException ();
181                 }
182                 [MonoTODO]
183                 public void DataBindCrossTable (System.Collections.IEnumerable dataSource, string seriesGroupByField, string xField, string yFields, string otherFields, PointSortOrder sortingOrder)
184                 {
185                         throw new NotImplementedException ();
186                 }
187
188                 [MonoTODO]
189                 public void DataBindTable (System.Collections.IEnumerable dataSource)
190                 {
191                         throw new NotImplementedException ();
192                 }
193                 [MonoTODO]
194                 public void DataBindTable (System.Collections.IEnumerable dataSource, string xField)
195                 {
196                         throw new NotImplementedException ();
197                 }
198
199                 [MonoTODO]
200                 public void EndInit ()
201                 {
202                         throw new NotImplementedException ();
203                 }
204
205                 [MonoTODO]
206                 public HitTestResult HitTest (int x, int y)
207                 {
208                         throw new NotImplementedException ();
209                 }
210
211                 [MonoTODO]
212                 public HitTestResult HitTest (int x, int y, bool ignoreTransparent)
213                 {
214                         throw new NotImplementedException ();
215                 }
216                 [MonoTODO]
217                 public HitTestResult HitTest (int x, int y, ChartElementType requestedElement)
218                 {
219                         throw new NotImplementedException ();
220                 }
221
222                 [MonoTODO]
223                 public HitTestResult[] HitTest (int x, int y, bool ignoreTransparent, params ChartElementType[] requestedElement)
224                 {
225                         throw new NotImplementedException ();
226                 }
227
228                 [MonoTODO]
229                 public void LoadTemplate (Stream stream)
230                 {
231                         throw new NotImplementedException ();
232                 }
233
234                 [MonoTODO]
235                 public void LoadTemplate (string name)
236                 {
237                         throw new NotImplementedException ();
238                 }
239
240                 [MonoTODO]
241                 public void ResetAutoValues ()
242                 {
243                         throw new NotImplementedException ();
244                 }
245
246                 [MonoTODO]
247                 public void SaveImage (Stream imageStream, ImageFormat format)
248                 {
249                         throw new NotImplementedException ();
250                 }
251                 [MonoTODO]
252                 public void SaveImage (Stream imageStream, ChartImageFormat format)
253                 {
254                         throw new NotImplementedException ();
255                 }
256                 [MonoTODO]
257                 public void SaveImage (string imageFileName, ImageFormat format)
258                 {
259                         throw new NotImplementedException ();
260                 }
261                 [MonoTODO]
262                 public void SaveImage (string imageFileName, ChartImageFormat format)
263                 {
264                         throw new NotImplementedException ();
265                 }
266                 #endregion
267
268                 #region Protected Methods
269
270
271                 protected override void Dispose (bool disposing)
272                 {
273                 }
274
275
276
277                 #endregion
278
279                 #region Private Methods
280                 private void PaintElement (ChartGraphics g, object element, ElementPosition position)
281                 {
282                         ChartPaintEventArgs e = new ChartPaintEventArgs (this, element, g, position);
283
284                         OnPrePaint (e);
285                         OnPostPaint (e);
286                 }
287                 #endregion
288         }
289 }