Free cookie consent management tool by TermsFeed Policy Generator

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

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

reimplemented panning and zooming (#424)

File size: 842 bytes
RevLine 
[724]1using System;
2using System.Diagnostics;
3using System.Drawing;
[635]4using System.Windows.Forms;
5
6namespace HeuristicLab.Visualization {
7  public partial class CanvasUI : Control {
[1240]8    private readonly Canvas canvas = new Canvas();
[635]9
10    public CanvasUI() {
11      InitializeComponent();
[958]12
13      DoubleBuffered = true;
[635]14    }
15
[1240]16    public Canvas Canvas {
17      get { return canvas; }
[635]18    }
19
20    protected override void OnPaint(PaintEventArgs pe) {
[724]21      try {
22        Graphics g = pe.Graphics;
[635]23
[1240]24        canvas.Viewport = ClientRectangle;
25        canvas.Draw(g);
[869]26
[724]27        base.OnPaint(pe);
28      } catch (Exception e) {
[1038]29       Trace.WriteLine(e);
[724]30      }
[635]31    }
[724]32
[869]33    protected override void OnResize(EventArgs e) {
34      Invalidate();
35
[1240]36      canvas.Viewport = ClientRectangle;
37
[869]38      base.OnResize(e);
39    }
[635]40  }
[724]41}
Note: See TracBrowser for help on using the repository browser.