protected override void OnMouseDown(MouseEventArgs e) { if (!_isDraging) { foreach (TrackBarItem it in _items) { if (it.Contains(e.Location)) { _currentTrackBarItem = it; _currentTrackBarItem.Selected = true; _isDraging = true; _startPoint = e.Location; Invalidate(); break; } } } }
protected override void OnMouseUp(MouseEventArgs e) { if (_isDraging && _currentTrackBarItem != null) { int idx = _items.IndexOf(_currentTrackBarItem); if (BarValueChangedFinished != null) { _isDraging = false; BarValueChangedFinished(this, idx, GetValueAt(idx)); } if (_currentTrackBarItem != null) { _currentTrackBarItem.Selected = false; } _currentTrackBarItem = null; } _isDraging = false; _startPoint = Point.Empty; Invalidate(); }