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 |
|
---|
10 | public CanvasUI() {
|
---|
11 | InitializeComponent();
|
---|
12 |
|
---|
13 | DoubleBuffered = true;
|
---|
14 | }
|
---|
15 |
|
---|
16 | public Canvas Canvas {
|
---|
17 | get { return canvas; }
|
---|
18 | }
|
---|
19 |
|
---|
20 | protected override void OnPaint(PaintEventArgs pe) {
|
---|
21 | try {
|
---|
22 | Graphics g = pe.Graphics;
|
---|
23 |
|
---|
24 | canvas.Viewport = ClientRectangle;
|
---|
25 | canvas.Draw(g);
|
---|
26 |
|
---|
27 | base.OnPaint(pe);
|
---|
28 | } catch (Exception e) {
|
---|
29 | Trace.WriteLine(e);
|
---|
30 | }
|
---|
31 | }
|
---|
32 |
|
---|
33 | protected override void OnResize(EventArgs e) {
|
---|
34 | Invalidate();
|
---|
35 |
|
---|
36 | canvas.Viewport = ClientRectangle;
|
---|
37 |
|
---|
38 | base.OnResize(e);
|
---|
39 | }
|
---|
40 | }
|
---|
41 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.