Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/HeuristicLab.Netron-3.0.2672.12446/ExpandableIconMaterial.cs @ 3623

Last change on this file since 3623 was 2934, checked in by mkommend, 15 years ago

added parameters, corrected drag and drop position (ticket #867)

File size: 1.8 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using Netron.Diagramming.Core;
6using System.Drawing;
7using System.Windows.Forms;
8
9namespace 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}
Note: See TracBrowser for help on using the repository browser.