Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 844 was 725, checked in by bspisic, 16 years ago

#319

MouseEventListener implemented
dragDrop MouseEventListener example implemented

File size: 1.3 KB
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 {
8    private readonly Canvas mainCanvas = new Canvas();
[724]9    private MouseEventListener mouseEventListener;
[635]10
11    public CanvasUI() {
12      InitializeComponent();
13    }
14
15    public Canvas MainCanvas {
16      get { return mainCanvas; }
17    }
18
[724]19    public MouseEventListener MouseEventListener {
20      get { return mouseEventListener; }
21      set { mouseEventListener = value; }
22    }
23
[635]24    protected override void OnPaint(PaintEventArgs pe) {
[724]25      try {
26        Graphics g = pe.Graphics;
[635]27
[724]28        g.FillRectangle(Brushes.White, ClientRectangle);
[635]29
[724]30        mainCanvas.Draw(g, ClientRectangle);
[635]31
[724]32        g.DrawRectangle(Pens.Black, 0, 0, Width - 1, Height - 1);
[635]33
[724]34        base.OnPaint(pe);
35      } catch (Exception e) {
36       Debug.WriteLine(e);
37      }
[635]38    }
[724]39
40    private void CanvasUI_MouseMove(object sender, MouseEventArgs e) {
[725]41      if (mouseEventListener != null) {
42        mouseEventListener.MouseMove(e.Location);
43      }
[724]44    }
45
46    private void CanvasUI_MouseUp(object sender, MouseEventArgs e) {
[725]47      if (mouseEventListener != null) {
48        mouseEventListener.MouseUp(e.Location);
49      }
[724]50    }
[635]51  }
[724]52}
Note: See TracBrowser for help on using the repository browser.