Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/CanvasUI.cs @ 1038

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

Modified the XAxis labels so they are always visible at the bottom. (#433)
Added simple layout management to the line chart's root shape containing a title-, lines- and xaxis-area. (#345)

File size: 1.5 KB
Line 
1using System;
2using System.Diagnostics;
3using System.Drawing;
4using System.Drawing.Drawing2D;
5using System.Windows.Forms;
6
7namespace HeuristicLab.Visualization {
8  public partial class CanvasUI : Control {
9    private readonly Canvas mainCanvas = new Canvas();
10    private MouseEventListener mouseEventListener;
11
12    public CanvasUI() {
13      InitializeComponent();
14
15      DoubleBuffered = true;
16    }
17
18    public Canvas MainCanvas {
19      get { return mainCanvas; }
20    }
21
22    public MouseEventListener MouseEventListener {
23      get { return mouseEventListener; }
24      set { mouseEventListener = value; }
25    }
26
27    protected override void OnPaint(PaintEventArgs pe) {
28      try {
29        Graphics g = pe.Graphics;
30
31        g.SmoothingMode = SmoothingMode.AntiAlias;
32
33        g.FillRectangle(Brushes.White, ClientRectangle);
34
35        mainCanvas.Draw(g, ClientRectangle);
36
37        g.DrawRectangle(Pens.Black, 0, 0, Width - 1, Height - 1);
38
39        base.OnPaint(pe);
40      } catch (Exception e) {
41       Trace.WriteLine(e);
42      }
43    }
44
45    protected override void OnResize(EventArgs e) {
46      Invalidate();
47
48      base.OnResize(e);
49    }
50
51    private void CanvasUI_MouseMove(object sender, MouseEventArgs e) {
52      if (mouseEventListener != null) {
53        mouseEventListener.MouseMove(e.Location);
54      }
55    }
56
57    private void CanvasUI_MouseUp(object sender, MouseEventArgs e) {
58      if (mouseEventListener != null) {
59        mouseEventListener.MouseUp(e.Location);
60      }
61    }
62  }
63}
Note: See TracBrowser for help on using the repository browser.