Last change
on this file since 1243 was
1240,
checked in by mstoeger, 16 years ago
|
Transformations on shapes are possible outside of the Draw method. (#424)
|
File size:
1.4 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Diagnostics;
|
---|
3 | using System.Drawing;
|
---|
4 | using System.Windows.Forms;
|
---|
5 |
|
---|
6 | namespace HeuristicLab.Visualization {
|
---|
7 | public partial class CanvasUI : Control {
|
---|
8 | private readonly Canvas canvas = new Canvas();
|
---|
9 | private IMouseEventListener mouseEventListener;
|
---|
10 |
|
---|
11 | public CanvasUI() {
|
---|
12 | InitializeComponent();
|
---|
13 |
|
---|
14 | DoubleBuffered = true;
|
---|
15 | }
|
---|
16 |
|
---|
17 | public Canvas Canvas {
|
---|
18 | get { return canvas; }
|
---|
19 | }
|
---|
20 |
|
---|
21 | public IMouseEventListener MouseEventListener {
|
---|
22 | get { return mouseEventListener; }
|
---|
23 | set { mouseEventListener = value; }
|
---|
24 | }
|
---|
25 |
|
---|
26 | protected override void OnPaint(PaintEventArgs pe) {
|
---|
27 | try {
|
---|
28 | Graphics g = pe.Graphics;
|
---|
29 |
|
---|
30 | canvas.Viewport = ClientRectangle;
|
---|
31 | canvas.Draw(g);
|
---|
32 |
|
---|
33 | base.OnPaint(pe);
|
---|
34 | } catch (Exception e) {
|
---|
35 | Trace.WriteLine(e);
|
---|
36 | }
|
---|
37 | }
|
---|
38 |
|
---|
39 | protected override void OnResize(EventArgs e) {
|
---|
40 | Invalidate();
|
---|
41 |
|
---|
42 | canvas.Viewport = ClientRectangle;
|
---|
43 |
|
---|
44 | base.OnResize(e);
|
---|
45 | }
|
---|
46 |
|
---|
47 | private void CanvasUI_MouseMove(object sender, MouseEventArgs e) {
|
---|
48 | if (mouseEventListener != null) {
|
---|
49 | mouseEventListener.MouseMove(sender, e);
|
---|
50 | }
|
---|
51 | }
|
---|
52 |
|
---|
53 | private void CanvasUI_MouseUp(object sender, MouseEventArgs e) {
|
---|
54 | if (mouseEventListener != null) {
|
---|
55 | mouseEventListener.MouseUp(sender, e);
|
---|
56 | }
|
---|
57 | }
|
---|
58 | }
|
---|
59 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.