Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/3.2/Drawing/CanvasUI.cs @ 2716

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
RevLine 
[724]1using System;
2using System.Diagnostics;
3using System.Drawing;
[635]4using System.Windows.Forms;
5
[1964]6namespace HeuristicLab.Visualization.Drawing {
[635]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
[1880]20    public event PaintEventHandler BeforePaint;
21
[635]22    protected override void OnPaint(PaintEventArgs pe) {
[724]23      try {
[1880]24        FireBeforePaint(pe);
25
[724]26        Graphics g = pe.Graphics;
[635]27
[1240]28        canvas.Viewport = ClientRectangle;
29        canvas.Draw(g);
[869]30
[724]31        base.OnPaint(pe);
32      } catch (Exception e) {
[1964]33        Trace.WriteLine(e);
[724]34      }
[635]35    }
[724]36
[869]37    protected override void OnResize(EventArgs e) {
38      Invalidate();
39
[1240]40      canvas.Viewport = ClientRectangle;
41
[869]42      base.OnResize(e);
43    }
[1880]44
45    private void FireBeforePaint(PaintEventArgs e) {
46      if (BeforePaint != null)
47        BeforePaint(this, e);
48    }
[635]49  }
[724]50}
Note: See TracBrowser for help on using the repository browser.