File: ToolstripTrackBar.cs

package info (click to toggle)
quickroute-gps 2.5-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 19,576 kB
  • sloc: cs: 74,488; makefile: 72; sh: 43
file content (87 lines) | stat: -rw-r--r-- 2,582 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms.Design;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;

namespace QuickRoute.Controls
{
  [DesignerCategory("code")]
  [ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.ToolStrip | ToolStripItemDesignerAvailability.StatusStrip)]
  public class ToolstripTrackBar : ToolStripControlHost
  {
    public ToolstripTrackBar()
      : base(CreateControlInstance())
    {

    }

    /// <summary>
    /// Export a strongly typed property called colorRangeIntervalSlider - handy to prevent casting everywhere.
    /// </summary>
    public TrackBar TrackBarControl
    {
      get
      {
        return Control as TrackBar;
      }
    }

    private static Control CreateControlInstance()
    {
      TrackBar tb = new TrackBar();
      tb.AutoSize = false;
      tb.Size = new Size(60, 24);
      // Add other initialization code here.
      return tb;
    }

    /// <summary>
    /// Attach to events we want to re-wrap
    /// </summary>
    /// <param name="control"></param>
    protected override void OnSubscribeControlEvents(Control control)
    {
      base.OnSubscribeControlEvents(control);
      TrackBarControl.ValueChanged += new System.EventHandler(TrackBarControl_ValueChanged);
      TrackBarControl.MouseDown += new System.Windows.Forms.MouseEventHandler(TrackBarControl_MouseDown);
    }
    /// <summary>
    /// Detach from events.
    /// </summary>
    /// <param name="control"></param>
    protected override void OnUnsubscribeControlEvents(Control control)
    {
      base.OnUnsubscribeControlEvents(control);
      TrackBarControl.ValueChanged -= new System.EventHandler(TrackBarControl_ValueChanged);
      TrackBarControl.MouseDown -= new System.Windows.Forms.MouseEventHandler(TrackBarControl_MouseDown);
    }

    void TrackBarControl_ValueChanged(object sender, EventArgs e)
    {
      if (this.ValueChanged != null) this.ValueChanged(sender, e);
    }

    void TrackBarControl_MouseDown(object sender, MouseEventArgs e)
    {
      if (this.MouseDown != null) this.MouseDown(sender, e);
    }
    
    // add events that are subscribable from the designer.
    public event EventHandler ValueChanged;
    public new event MouseEventHandler MouseDown;

    // set other defaults that are interesting
    protected override Size DefaultSize
    {
      get
      {
        return new Size(60, 24);
      }
    }

  }

}