Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Operator Architecture Refactoring/HeuristicLab.Visualization/CanvasUI.cs @ 1161

Last change on this file since 1161 was 869, checked in by mstoeger, 16 years ago

Adjustments on LineChart for new interface. #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
16    public Canvas MainCanvas {
17      get { return mainCanvas; }
18    }
19
20    public MouseEventListener MouseEventListener {
21      get { return mouseEventListener; }
22      set { mouseEventListener = value; }
23    }
24
25    protected override void OnPaint(PaintEventArgs pe) {
26      try {
27        Graphics g = pe.Graphics;
28
29        g.SmoothingMode = SmoothingMode.AntiAlias;
30
31        g.FillRectangle(Brushes.White, ClientRectangle);
32
33        mainCanvas.Draw(g, ClientRectangle);
34
35        g.DrawRectangle(Pens.Black, 0, 0, Width - 1, Height - 1);
36
37        base.OnPaint(pe);
38      } catch (Exception e) {
39       Debug.WriteLine(e);
40      }
41    }
42
43    protected override void OnResize(EventArgs e) {
44      Invalidate();
45
46      base.OnResize(e);
47    }
48
49    private void CanvasUI_MouseMove(object sender, MouseEventArgs e) {
50      if (mouseEventListener != null) {
51        mouseEventListener.MouseMove(e.Location);
52      }
53    }
54
55    private void CanvasUI_MouseUp(object sender, MouseEventArgs e) {
56      if (mouseEventListener != null) {
57        mouseEventListener.MouseUp(e.Location);
58      }
59    }
60  }
61}
Note: See TracBrowser for help on using the repository browser.