Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 1388 was 1249, checked in by bspisic, 16 years ago

reimplemented panning and zooming (#424)

File size: 842 bytes
Line 
1using System;
2using System.Diagnostics;
3using System.Drawing;
4using System.Windows.Forms;
5
6namespace 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.