Last change
on this file since 846 was
725,
checked in by bspisic, 16 years ago
|
#319
MouseEventListener implemented
dragDrop MouseEventListener example implemented
|
File size:
1.3 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Diagnostics;
|
---|
3 | using System.Drawing;
|
---|
4 | using System.Windows.Forms;
|
---|
5 |
|
---|
6 | namespace HeuristicLab.Visualization {
|
---|
7 | public partial class CanvasUI : Control {
|
---|
8 | private readonly Canvas mainCanvas = new Canvas();
|
---|
9 | private MouseEventListener mouseEventListener;
|
---|
10 |
|
---|
11 | public CanvasUI() {
|
---|
12 | InitializeComponent();
|
---|
13 | }
|
---|
14 |
|
---|
15 | public Canvas MainCanvas {
|
---|
16 | get { return mainCanvas; }
|
---|
17 | }
|
---|
18 |
|
---|
19 | public MouseEventListener MouseEventListener {
|
---|
20 | get { return mouseEventListener; }
|
---|
21 | set { mouseEventListener = value; }
|
---|
22 | }
|
---|
23 |
|
---|
24 | protected override void OnPaint(PaintEventArgs pe) {
|
---|
25 | try {
|
---|
26 | Graphics g = pe.Graphics;
|
---|
27 |
|
---|
28 | g.FillRectangle(Brushes.White, ClientRectangle);
|
---|
29 |
|
---|
30 | mainCanvas.Draw(g, ClientRectangle);
|
---|
31 |
|
---|
32 | g.DrawRectangle(Pens.Black, 0, 0, Width - 1, Height - 1);
|
---|
33 |
|
---|
34 | base.OnPaint(pe);
|
---|
35 | } catch (Exception e) {
|
---|
36 | Debug.WriteLine(e);
|
---|
37 | }
|
---|
38 | }
|
---|
39 |
|
---|
40 | private void CanvasUI_MouseMove(object sender, MouseEventArgs e) {
|
---|
41 | if (mouseEventListener != null) {
|
---|
42 | mouseEventListener.MouseMove(e.Location);
|
---|
43 | }
|
---|
44 | }
|
---|
45 |
|
---|
46 | private void CanvasUI_MouseUp(object sender, MouseEventArgs e) {
|
---|
47 | if (mouseEventListener != null) {
|
---|
48 | mouseEventListener.MouseUp(e.Location);
|
---|
49 | }
|
---|
50 | }
|
---|
51 | }
|
---|
52 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.