Last change
on this file since 2716 was
1964,
checked in by mstoeger, 16 years ago
|
moved the canvas and the basic types of shapes to their own namespace. #498
|
File size:
1.0 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Diagnostics;
|
---|
3 | using System.Drawing;
|
---|
4 | using System.Windows.Forms;
|
---|
5 |
|
---|
6 | namespace HeuristicLab.Visualization.Drawing {
|
---|
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 | public event PaintEventHandler BeforePaint;
|
---|
21 |
|
---|
22 | protected override void OnPaint(PaintEventArgs pe) {
|
---|
23 | try {
|
---|
24 | FireBeforePaint(pe);
|
---|
25 |
|
---|
26 | Graphics g = pe.Graphics;
|
---|
27 |
|
---|
28 | canvas.Viewport = ClientRectangle;
|
---|
29 | canvas.Draw(g);
|
---|
30 |
|
---|
31 | base.OnPaint(pe);
|
---|
32 | } catch (Exception e) {
|
---|
33 | Trace.WriteLine(e);
|
---|
34 | }
|
---|
35 | }
|
---|
36 |
|
---|
37 | protected override void OnResize(EventArgs e) {
|
---|
38 | Invalidate();
|
---|
39 |
|
---|
40 | canvas.Viewport = ClientRectangle;
|
---|
41 |
|
---|
42 | base.OnResize(e);
|
---|
43 | }
|
---|
44 |
|
---|
45 | private void FireBeforePaint(PaintEventArgs e) {
|
---|
46 | if (BeforePaint != null)
|
---|
47 | BeforePaint(this, e);
|
---|
48 | }
|
---|
49 | }
|
---|
50 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.