Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/3.2/LineChart.cs @ 1881

Last change on this file since 1881 was 1881, checked in by mstoeger, 15 years ago

renamed xaxis-properties #498

File size: 23.9 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Drawing;
4using System.Drawing.Drawing2D;
5using System.Windows.Forms;
6using HeuristicLab.Core;
7using HeuristicLab.Visualization.DataExport;
8using HeuristicLab.Visualization.Legend;
9using HeuristicLab.Visualization.Options;
10using HeuristicLab.Visualization.Test;
11
12namespace HeuristicLab.Visualization {
13  public partial class LineChart : ViewBase {
14    private readonly IChartDataRowsModel model;
15    private readonly Canvas canvas;
16
17    private readonly TextShape titleShape = new TextShape("Title");
18    private readonly LegendShape legendShape = new LegendShape();
19    private readonly XAxis xAxis = new XAxis();
20    private readonly XAxisGrid xAxisGrid = new XAxisGrid();
21    private readonly List<RowEntry> rowEntries = new List<RowEntry>();
22
23    private readonly Dictionary<IDataRow, RowEntry> rowToRowEntry = new Dictionary<IDataRow, RowEntry>();
24
25    private readonly ViewSettings viewSettings;
26
27    private readonly WorldShape userInteractionShape = new WorldShape();
28    private readonly RectangleShape rectangleShape = new RectangleShape(0, 0, 0, 0, Color.FromArgb(50, 0, 0, 255));
29    private IMouseEventListener mouseEventListener;
30
31    private const int YAxisWidth = 100;
32    private const int XAxisHeight = 40;
33
34    /// <summary>
35    /// This constructor shouldn't be called. Only required for the designer.
36    /// </summary>
37    public LineChart() {
38      InitializeComponent();
39    }
40
41    /// <summary>
42    /// Initializes the chart.
43    /// </summary>
44    /// <param name="model">Referenz to the model, for data</param>
45    public LineChart(IChartDataRowsModel model) : this() {
46      if (model == null) {
47        throw new NullReferenceException("Model cannot be null.");
48      }
49
50      canvas = canvasUI.Canvas;
51
52      this.model = model;
53      viewSettings = model.ViewSettings;
54      viewSettings.OnUpdateSettings += UpdateViewSettings;
55
56      Item = model;
57
58      this.ResizeRedraw = true;
59
60      canvasUI.BeforePaint += delegate { UpdateLayout(); };
61
62      UpdateLayout();
63      ZoomToFullView();
64    }
65
66    /// <summary>
67    /// updates the view settings
68    /// </summary>
69    private void UpdateViewSettings() {
70      titleShape.Font = viewSettings.TitleFont;
71      titleShape.Color = viewSettings.TitleColor;
72      titleShape.Text = model.Title;
73
74      legendShape.Font = viewSettings.LegendFont;
75      legendShape.Color = viewSettings.LegendColor;
76
77      xAxis.Font = viewSettings.XAxisFont;
78      xAxis.Color = viewSettings.XAxisColor;
79
80      SetLegendPosition();
81
82      canvasUI.Invalidate();
83    }
84
85    /// <summary>
86    /// Layout management - arranges the inner shapes.
87    /// </summary>
88    private void UpdateLayout() {
89      canvas.ClearShapes();
90
91      titleShape.Text = model.Title;
92
93      if (model.XAxis.ShowGrid) {
94        canvas.AddShape(xAxisGrid);
95      }
96
97      foreach (YAxisDescriptor yAxisDescriptor in model.YAxes) {
98        YAxisInfo info = GetYAxisInfo(yAxisDescriptor);
99        if (yAxisDescriptor.ShowGrid) {
100          info.Grid.Color = yAxisDescriptor.GridColor;
101          canvas.AddShape(info.Grid);
102        }
103      }
104
105      foreach (RowEntry rowEntry in rowEntries) {
106        canvas.AddShape(rowEntry.LinesShape);
107      }
108
109      xAxis.ShowLabel = model.XAxis.ShowLabel;
110      xAxis.Label = model.XAxis.Label;
111
112      canvas.AddShape(xAxis);
113
114      int yAxesWidthLeft = 0;
115      int yAxesWidthRight = 0;
116
117      foreach (YAxisDescriptor yAxisDescriptor in model.YAxes) {
118        YAxisInfo info = GetYAxisInfo(yAxisDescriptor);
119        if (yAxisDescriptor.ShowYAxis) {
120          canvas.AddShape(info.YAxis);
121          info.YAxis.ShowLabel = yAxisDescriptor.ShowYAxisLabel;
122          info.YAxis.Label = yAxisDescriptor.Label;
123          info.YAxis.Position = yAxisDescriptor.Position;
124          switch (yAxisDescriptor.Position) {
125            case AxisPosition.Left:
126              yAxesWidthLeft += YAxisWidth;
127              break;
128            case AxisPosition.Right:
129              yAxesWidthRight += YAxisWidth;
130              break;
131            default:
132              throw new NotImplementedException();
133          }
134        }
135      }
136
137      canvas.AddShape(titleShape);
138      canvas.AddShape(legendShape);
139
140      canvas.AddShape(userInteractionShape);
141
142      titleShape.X = 10;
143      titleShape.Y = canvasUI.Height - 10;
144
145      RectangleD linesAreaBoundingBox = new RectangleD(yAxesWidthLeft,
146                                                       XAxisHeight,
147                                                       canvasUI.Width - yAxesWidthRight,
148                                                       canvasUI.Height);
149
150      foreach (RowEntry rowEntry in rowEntries) {
151        rowEntry.LinesShape.BoundingBox = linesAreaBoundingBox;
152      }
153
154      xAxisGrid.BoundingBox = linesAreaBoundingBox;
155
156      foreach (YAxisDescriptor yAxisDescriptor in model.YAxes) {
157        YAxisInfo info = GetYAxisInfo(yAxisDescriptor);
158        info.Grid.BoundingBox = linesAreaBoundingBox;
159      }
160
161      int yAxisLeft = 0;
162      int yAxisRight = (int)linesAreaBoundingBox.X2;
163
164      foreach (YAxisDescriptor yAxisDescriptor in model.YAxes) {
165        YAxisInfo info = GetYAxisInfo(yAxisDescriptor);
166        if (yAxisDescriptor.ShowYAxis) {
167          switch (yAxisDescriptor.Position) {
168            case AxisPosition.Left:
169              info.YAxis.BoundingBox = new RectangleD(yAxisLeft,
170                                                      linesAreaBoundingBox.Y1,
171                                                      yAxisLeft + YAxisWidth,
172                                                      linesAreaBoundingBox.Y2);
173              yAxisLeft += YAxisWidth;
174              break;
175            case AxisPosition.Right:
176              info.YAxis.BoundingBox = new RectangleD(yAxisRight,
177                                                      linesAreaBoundingBox.Y1,
178                                                      yAxisRight + YAxisWidth,
179                                                      linesAreaBoundingBox.Y2);
180              yAxisRight += YAxisWidth;
181              break;
182            default:
183              throw new NotImplementedException();
184          }
185        }
186      }
187
188      userInteractionShape.BoundingBox = linesAreaBoundingBox;
189      userInteractionShape.ClippingArea = new RectangleD(0, 0, userInteractionShape.BoundingBox.Width, userInteractionShape.BoundingBox.Height);
190
191      xAxis.BoundingBox = new RectangleD(linesAreaBoundingBox.X1,
192                                         0,
193                                         linesAreaBoundingBox.X2,
194                                         linesAreaBoundingBox.Y1);
195
196      SetLegendPosition();
197    }
198
199    private readonly Dictionary<YAxisDescriptor, YAxisInfo> yAxisInfos = new Dictionary<YAxisDescriptor, YAxisInfo>();
200
201    private YAxisInfo GetYAxisInfo(YAxisDescriptor yAxisDescriptor) {
202      YAxisInfo info;
203
204      if (!yAxisInfos.TryGetValue(yAxisDescriptor, out info)) {
205        info = new YAxisInfo();
206        yAxisInfos[yAxisDescriptor] = info;
207      }
208
209      return info;
210    }
211
212    /// <summary>
213    /// sets the legend position
214    /// </summary>
215    private void SetLegendPosition() {
216      switch (viewSettings.LegendPosition) {
217        case LegendPosition.Bottom:
218          setLegendBottom();
219          break;
220
221        case LegendPosition.Top:
222          setLegendTop();
223          break;
224
225        case LegendPosition.Left:
226          setLegendLeft();
227          break;
228
229        case LegendPosition.Right:
230          setLegendRight();
231          break;
232      }
233    }
234
235    public void setLegendRight() {
236      // legend right
237      legendShape.BoundingBox = new RectangleD(canvasUI.Width - legendShape.GetMaxLabelLength(), 10, canvasUI.Width, canvasUI.Height - 50);
238      legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width, legendShape.BoundingBox.Height);
239      legendShape.Row = false;
240      legendShape.CreateLegend();
241    }
242
243    public void setLegendLeft() {
244      // legend left
245      legendShape.BoundingBox = new RectangleD(10, 10, canvasUI.Width, canvasUI.Height - 50);
246      legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width, legendShape.BoundingBox.Height);
247      legendShape.Row = false;
248      legendShape.CreateLegend();
249
250      canvasUI.Invalidate();
251    }
252
253    public void setLegendTop() {
254      // legend top
255      legendShape.BoundingBox = new RectangleD(100, canvasUI.Height - canvasUI.Height, canvasUI.Width, canvasUI.Height - 10);
256      legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width, legendShape.BoundingBox.Height);
257      legendShape.Row = true;
258      legendShape.Top = true;
259      legendShape.CreateLegend();
260    }
261
262    public void setLegendBottom() {
263      // legend bottom
264      legendShape.BoundingBox = new RectangleD(100, 2, canvasUI.Width, canvasUI.Height);
265      legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width, legendShape.BoundingBox.Height);
266      legendShape.Row = true;
267      legendShape.Top = false;
268      legendShape.CreateLegend();
269    }
270
271    private void optionsToolStripMenuItem_Click(object sender, EventArgs e) {
272      OptionsDialog optionsdlg = new OptionsDialog(model);
273      optionsdlg.Show();
274    }
275
276    private void exportToolStripMenuItem_Click(object sender, EventArgs e) {
277      ExportDialog exportdlg = new ExportDialog();
278      exportdlg.ShowDialog(this);
279
280      IExporter exporter = exportdlg.SelectedExporter;
281
282      if (exporter != null)
283        exporter.Export(model);
284    }
285
286    public void OnDataRowChanged(IDataRow row) {
287      RowEntry rowEntry = rowToRowEntry[row];
288
289      rowEntry.LinesShape.UpdateStyle(row);
290
291      canvasUI.Invalidate();
292    }
293
294    #region Add-/RemoveItemEvents
295
296    protected override void AddItemEvents() {
297      base.AddItemEvents();
298
299      model.DataRowAdded += OnDataRowAdded;
300      model.DataRowRemoved += OnDataRowRemoved;
301      model.ModelChanged += OnModelChanged;
302
303      foreach (IDataRow row in model.Rows) {
304        OnDataRowAdded(row);
305      }
306    }
307
308    protected override void RemoveItemEvents() {
309      base.RemoveItemEvents();
310
311      model.DataRowAdded -= OnDataRowAdded;
312      model.DataRowRemoved -= OnDataRowRemoved;
313      model.ModelChanged -= OnModelChanged;
314    }
315
316    private void OnDataRowAdded(IDataRow row) {
317      row.ValueChanged += OnRowValueChanged;
318      row.ValuesChanged += OnRowValuesChanged;
319      row.DataRowChanged += OnDataRowChanged;
320
321      legendShape.AddLegendItem(new LegendItem(row.Label, row.Color, row.Thickness));
322      legendShape.CreateLegend();
323
324      InitLineShapes(row);
325
326      canvasUI.Invalidate();
327    }
328
329    private void OnDataRowRemoved(IDataRow row) {
330      row.ValueChanged -= OnRowValueChanged;
331      row.ValuesChanged -= OnRowValuesChanged;
332      row.DataRowChanged -= OnDataRowChanged;
333
334      rowToRowEntry.Remove(row);
335      rowEntries.RemoveAll(delegate(RowEntry rowEntry) { return rowEntry.DataRow == row; });
336
337      canvasUI.Invalidate();
338    }
339
340    #endregion
341
342    public void ZoomToFullView() {
343      SetClipX(-0.1, model.MaxDataRowValues - 0.9);
344
345      foreach (RowEntry rowEntry in rowEntries) {
346        YAxisDescriptor yAxisDescriptor = rowEntry.DataRow.YAxis;
347
348        SetClipY(rowEntry,
349                 yAxisDescriptor.MinValue - ((yAxisDescriptor.MaxValue - yAxisDescriptor.MinValue)*0.05),
350                 yAxisDescriptor.MaxValue + ((yAxisDescriptor.MaxValue - yAxisDescriptor.MinValue)*0.05));
351      }
352
353      canvasUI.Invalidate();
354    }
355
356    private void SetClipX(double x1, double x2) {
357      xAxisGrid.ClippingArea = new RectangleD(x1,
358                                              xAxisGrid.ClippingArea.Y1,
359                                              x2,
360                                              xAxisGrid.ClippingArea.Y2);
361
362      xAxis.ClippingArea = new RectangleD(x1,
363                                          0,
364                                          x2,
365                                          XAxisHeight);
366
367      foreach (RowEntry rowEntry in rowEntries) {
368        rowEntry.LinesShape.ClippingArea = new RectangleD(x1,
369                                                          rowEntry.LinesShape.ClippingArea.Y1,
370                                                          x2,
371                                                          rowEntry.LinesShape.ClippingArea.Y2);
372      }
373
374      foreach (YAxisDescriptor yAxisDescriptor in model.YAxes) {
375        YAxisInfo info = GetYAxisInfo(yAxisDescriptor);
376        info.Grid.ClippingArea = new RectangleD(x1,
377                                                info.Grid.ClippingArea.Y1,
378                                                x2,
379                                                info.Grid.ClippingArea.Y2);
380        info.YAxis.ClippingArea = new RectangleD(0,
381                                                 info.YAxis.ClippingArea.Y1,
382                                                 YAxisWidth,
383                                                 info.YAxis.ClippingArea.Y2);
384      }
385    }
386
387    private void SetClipY(RowEntry rowEntry, double y1, double y2) {
388      xAxisGrid.ClippingArea = new RectangleD(xAxisGrid.ClippingArea.X1,
389                                              y1,
390                                              xAxisGrid.ClippingArea.X2,
391                                              y2);
392
393      rowEntry.LinesShape.ClippingArea = new RectangleD(rowEntry.LinesShape.ClippingArea.X1,
394                                                        y1,
395                                                        rowEntry.LinesShape.ClippingArea.X2,
396                                                        y2);
397
398      YAxisInfo info = GetYAxisInfo(rowEntry.DataRow.YAxis);
399
400      info.Grid.ClippingArea = new RectangleD(info.Grid.ClippingArea.X1,
401                                              y1,
402                                              info.Grid.ClippingArea.X2,
403                                              y2);
404      info.YAxis.ClippingArea = new RectangleD(info.YAxis.ClippingArea.X1,
405                                               y1,
406                                               info.YAxis.ClippingArea.X2,
407                                               y2);
408    }
409
410    private void InitLineShapes(IDataRow row) {
411      RowEntry rowEntry = new RowEntry(row);
412      rowEntries.Add(rowEntry);
413      rowToRowEntry[row] = rowEntry;
414
415      if ((row.LineType == DataRowType.SingleValue)) {
416        if (row.Count > 0) {
417          LineShape lineShape = new HorizontalLineShape(0, row[0], double.MaxValue, row[0], row.Color, row.Thickness,
418                                                        row.Style);
419          rowEntry.LinesShape.AddShape(lineShape);
420        }
421      } else {
422        rowEntry.showMarkers(row.ShowMarkers);
423        for (int i = 1; i < row.Count; i++) {
424          LineShape lineShape = new LineShape(i - 1, row[i - 1], i, row[i], row.Color, row.Thickness, row.Style);
425          rowEntry.LinesShape.AddShape(lineShape);
426          rowEntry.LinesShape.AddMarkerShape(new MarkerShape(i - 1, row[i - 1], 8, row.Color));
427        }
428        if (row.Count > 0) {
429          rowEntry.LinesShape.AddMarkerShape(new MarkerShape((row.Count - 1), row[(row.Count - 1)], 8, row.Color));
430        }
431      }
432
433      ZoomToFullView();
434    }
435
436    private void OnRowValueChanged(IDataRow row, double value, int index, Action action) {
437      RowEntry rowEntry = rowToRowEntry[row];
438
439      if (row.LineType == DataRowType.SingleValue) {
440        if (action == Action.Added) {
441          LineShape lineShape = new HorizontalLineShape(0, row[0], double.MaxValue, row[0], row.Color, row.Thickness,
442                                                        row.Style);
443          rowEntry.LinesShape.AddShape(lineShape);
444        } else {
445          LineShape lineShape = rowEntry.LinesShape.GetShape(0);
446          lineShape.Y1 = value;
447          lineShape.Y2 = value;
448        }
449      } else {
450        if (index > rowEntry.LinesShape.Count + 1) {
451          //MarkersShape is on position zero
452          throw new NotImplementedException();
453        }
454
455        if (action == Action.Added) {
456          // new value was added
457          if (index > 0 && index == rowEntry.LinesShape.Count + 1) {
458            LineShape lineShape = new LineShape(index - 1, row[index - 1], index, row[index], row.Color, row.Thickness,
459                                                row.Style);
460            rowEntry.LinesShape.AddShape(lineShape);
461            rowEntry.LinesShape.AddMarkerShape(new MarkerShape(index, row[index], 8, row.Color));
462          }
463        } else if (action == Action.Modified) {
464          // not the first value
465          if (index > 0) {
466            rowEntry.LinesShape.GetShape(index - 1).Y2 = value;
467            ((MarkerShape)rowEntry.LinesShape.markersShape.GetShape(index - 1)).Y = value;
468          }
469
470          // not the last value
471          if (index > 0 && index < row.Count - 1) {
472            rowEntry.LinesShape.GetShape(index).Y1 = value;
473            ((MarkerShape)rowEntry.LinesShape.markersShape.GetShape(index)).Y = value;
474          }
475        }
476      }
477
478      ZoomToFullView();
479    }
480
481    private void OnRowValuesChanged(IDataRow row, double[] values, int index, Action action) {
482      foreach (double value in values) {
483        OnRowValueChanged(row, value, index++, action);
484      }
485    }
486
487    private void OnModelChanged() {
488      canvasUI.Invalidate();
489    }
490
491    #region Begin-/EndUpdate
492
493    private int beginUpdateCount;
494
495    public void BeginUpdate() {
496      beginUpdateCount++;
497    }
498
499    public void EndUpdate() {
500      if (beginUpdateCount == 0) {
501        throw new InvalidOperationException("Too many EndUpdates.");
502      }
503
504      beginUpdateCount--;
505
506      if (beginUpdateCount == 0) {
507        canvasUI.Invalidate();
508      }
509    }
510
511    #endregion
512
513    #region Zooming / Panning
514
515    private void Pan(Point startPoint, Point endPoint) {
516      RectangleD clippingArea = Translate.ClippingArea(startPoint, endPoint, xAxis.ClippingArea, xAxis.Viewport);
517
518      SetClipX(clippingArea.X1, clippingArea.X2);
519
520      foreach (RowEntry rowEntry in rowEntries) {
521        if (rowEntry.DataRow.YAxis.ClipChangeable) {
522          clippingArea = Translate.ClippingArea(startPoint, endPoint, rowEntry.LinesShape.ClippingArea, rowEntry.LinesShape.Viewport);
523          SetClipY(rowEntry, clippingArea.Y1, clippingArea.Y2);
524        }
525      }
526
527      canvasUI.Invalidate();
528    }
529
530    private void PanEnd(Point startPoint, Point endPoint) {
531      Pan(startPoint, endPoint);
532    }
533
534    private void SetClippingArea(Rectangle rectangle) {
535      RectangleD clippingArea = Transform.ToWorld(rectangle, xAxis.Viewport, xAxis.ClippingArea);
536
537      SetClipX(clippingArea.X1, clippingArea.X2);
538
539      foreach (RowEntry rowEntry in rowEntries) {
540        if (rowEntry.DataRow.YAxis.ClipChangeable) {
541          clippingArea = Transform.ToWorld(rectangle, rowEntry.LinesShape.Viewport, rowEntry.LinesShape.ClippingArea);
542
543          SetClipY(rowEntry, clippingArea.Y1, clippingArea.Y2);
544        }
545      }
546
547      userInteractionShape.RemoveShape(rectangleShape);
548      canvasUI.Invalidate();
549    }
550
551    private void DrawRectangle(Rectangle rectangle) {
552      rectangleShape.Rectangle = Transform.ToWorld(rectangle, userInteractionShape.Viewport, userInteractionShape.ClippingArea);
553      canvasUI.Invalidate();
554    }
555
556    private void canvasUI1_KeyDown(object sender, KeyEventArgs e) {}
557
558    private void canvasUI1_MouseDown(object sender, MouseEventArgs e) {
559      Focus();
560
561      if (e.Button == MouseButtons.Right) {
562        contextMenu.Show(PointToScreen(e.Location));
563      } else if (e.Button == MouseButtons.Left) {
564        if (ModifierKeys == Keys.None) {
565          PanListener panListener = new PanListener(e.Location);
566          panListener.Pan += Pan;
567          panListener.PanEnd += PanEnd;
568
569          mouseEventListener = panListener;
570        } else if (ModifierKeys == Keys.Control) {
571          ZoomListener zoomListener = new ZoomListener(e.Location);
572          zoomListener.DrawRectangle += DrawRectangle;
573          zoomListener.SetClippingArea += SetClippingArea;
574
575          rectangleShape.Rectangle = RectangleD.Empty;
576          userInteractionShape.AddShape(rectangleShape);
577
578          mouseEventListener = zoomListener;
579        }
580      }
581    }
582
583    private void canvasUI_MouseMove(object sender, MouseEventArgs e) {
584      if (mouseEventListener != null) {
585        mouseEventListener.MouseMove(sender, e);
586      }
587    }
588
589    private void canvasUI_MouseUp(object sender, MouseEventArgs e) {
590      if (mouseEventListener != null) {
591        mouseEventListener.MouseUp(sender, e);
592      }
593
594      mouseEventListener = null;
595    }
596
597    private void canvasUI1_MouseWheel(object sender, MouseEventArgs e) {
598      if (ModifierKeys == Keys.Control) {
599        double zoomFactor = (e.Delta > 0) ? 0.7 : 1.3;
600
601        PointD world;
602
603        world = Transform.ToWorld(e.Location, xAxis.Viewport, xAxis.ClippingArea);
604
605        double x1 = world.X - (world.X - xAxis.ClippingArea.X1)*zoomFactor;
606        double x2 = world.X + (xAxis.ClippingArea.X2 - world.X)*zoomFactor;
607
608        SetClipX(x1, x2);
609
610        foreach (RowEntry rowEntry in rowEntries) {
611          world = Transform.ToWorld(e.Location, rowEntry.LinesShape.Viewport, rowEntry.LinesShape.ClippingArea);
612
613          double y1 = world.Y - (world.Y - rowEntry.LinesShape.ClippingArea.Y1)*zoomFactor;
614          double y2 = world.Y + (rowEntry.LinesShape.ClippingArea.Y2 - world.Y)*zoomFactor;
615
616          SetClipY(rowEntry, y1, y2);
617        }
618
619        canvasUI.Invalidate();
620      }
621    }
622
623    #endregion
624
625    protected override void OnPaint(PaintEventArgs e) {
626      UpdateLayout();
627      base.OnPaint(e);
628    }
629
630    private class LinesShape : WorldShape {
631      public readonly CompositeShape markersShape = new CompositeShape();
632
633      public void UpdateStyle(IDataRow row) {
634        foreach (IShape shape in shapes) {
635          LineShape lineShape = shape as LineShape;
636          if (lineShape != null) {
637            lineShape.LSColor = row.Color;
638            lineShape.LSDrawingStyle = row.Style;
639            lineShape.LSThickness = row.Thickness;
640          }
641        }
642        this.markersShape.ShowChildShapes = row.ShowMarkers;
643      }
644
645      public override void Draw(Graphics graphics) {
646        GraphicsState gstate = graphics.Save();
647
648        graphics.SetClip(Viewport);
649        foreach (IShape shape in shapes) {
650          // draw child shapes using our own clipping area
651          shape.Draw(graphics);
652        }
653        markersShape.Draw(graphics);
654        graphics.Restore(gstate);
655      }
656
657      public void AddMarkerShape(IShape shape) {
658        shape.Parent = this;
659        markersShape.AddShape(shape);
660      }
661
662      public int Count {
663        get { return shapes.Count; }
664      }
665
666      public LineShape GetShape(int index) {
667        return (LineShape)shapes[index]; //shapes[0] is markersShape!!
668      }
669    }
670
671    private class RowEntry {
672      private readonly IDataRow dataRow;
673
674      private readonly LinesShape linesShape = new LinesShape();
675
676      public RowEntry(IDataRow dataRow) {
677        this.dataRow = dataRow;
678        linesShape.markersShape.Parent = linesShape;
679      }
680
681      public IDataRow DataRow {
682        get { return dataRow; }
683      }
684
685      public LinesShape LinesShape {
686        get { return linesShape; }
687      }
688
689      public void showMarkers(bool flag) {
690        linesShape.markersShape.ShowChildShapes = flag;
691      }
692    }
693
694    private class YAxisInfo {
695      private readonly YAxisGrid grid = new YAxisGrid();
696      private readonly YAxis yAxis = new YAxis();
697
698      public YAxisGrid Grid {
699        get { return grid; }
700      }
701
702      public YAxis YAxis {
703        get { return yAxis; }
704      }
705    }
706  }
707}
Note: See TracBrowser for help on using the repository browser.