1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using Netron.Diagramming.Core;
|
---|
6 | using System.Drawing;
|
---|
7 | using System.Windows.Forms;
|
---|
8 |
|
---|
9 | namespace HeuristicLab.Netron {
|
---|
10 | public class ExpandableIconMaterial : IconMaterial, IMouseListener {
|
---|
11 | private Bitmap collapsedBitmap;
|
---|
12 | private Bitmap expandedBitmap;
|
---|
13 |
|
---|
14 | public ExpandableIconMaterial(Bitmap collapsedBitmap, Bitmap expandedBitmap)
|
---|
15 | : base() {
|
---|
16 | this.collapsedBitmap = collapsedBitmap;
|
---|
17 | this.expandedBitmap = expandedBitmap;
|
---|
18 |
|
---|
19 | this.Gliding = false;
|
---|
20 | this.Collapsed = true;
|
---|
21 | }
|
---|
22 |
|
---|
23 | public event EventHandler OnCollapse;
|
---|
24 | public event EventHandler OnExpand;
|
---|
25 |
|
---|
26 | private bool collapsed;
|
---|
27 | public bool Collapsed {
|
---|
28 | get { return this.collapsed; }
|
---|
29 | set {
|
---|
30 | if (value != this.collapsed) {
|
---|
31 | if (value) {
|
---|
32 | this.Icon = this.collapsedBitmap;
|
---|
33 | } else
|
---|
34 | this.Icon = this.expandedBitmap;
|
---|
35 | collapsed = value;
|
---|
36 | RaiseOnExpand();
|
---|
37 | }
|
---|
38 | }
|
---|
39 | }
|
---|
40 |
|
---|
41 | private void RaiseOnExpand() {
|
---|
42 | if (OnExpand != null)
|
---|
43 | OnExpand(this, EventArgs.Empty);
|
---|
44 | }
|
---|
45 | private void RaiseOnCollapse() {
|
---|
46 | if (OnCollapse != null)
|
---|
47 | OnCollapse(this, EventArgs.Empty);
|
---|
48 | }
|
---|
49 |
|
---|
50 |
|
---|
51 | #region IMouseListener Members
|
---|
52 | public override object GetService(Type serviceType) {
|
---|
53 | if (serviceType.Equals(typeof(IMouseListener)))
|
---|
54 | return this;
|
---|
55 | return null;
|
---|
56 | }
|
---|
57 |
|
---|
58 | public bool MouseDown(MouseEventArgs e) {
|
---|
59 | if (e.Clicks == 1) {
|
---|
60 | Collapsed = !Collapsed;
|
---|
61 | return true;
|
---|
62 | }
|
---|
63 | return false;
|
---|
64 | }
|
---|
65 |
|
---|
66 | public void MouseMove(System.Windows.Forms.MouseEventArgs e) {
|
---|
67 | }
|
---|
68 |
|
---|
69 | public void MouseUp(System.Windows.Forms.MouseEventArgs e) {
|
---|
70 | }
|
---|
71 | #endregion
|
---|
72 | }
|
---|
73 | }
|
---|