protected override void OnMouseWheel(MouseEventArgs e) { base.OnMouseWheel(e); if (_isFocused && _isKnobRotating && KryptonKnobUtilities.IsPointinRectangle(new Point(e.X, e.Y), _rKnob)) { // the Delta value is always 120, as explained in MSDN int v = (e.Delta / 120) * (_maximum - _minimum) / _mouseWheelBarPartitions; SetProperValue(Value + v); // Avoid to send MouseWheel event to the parent container ((HandledMouseEventArgs)e).Handled = true; } }
protected override void OnMouseUp(MouseEventArgs e) { if (KryptonKnobUtilities.IsPointinRectangle(new Point(e.X, e.Y), _rKnob)) { if (_isFocused == true && _isKnobRotating == true) { // Change value is allowed only only after 2nd click this.Value = this.GetValueFromPosition(new Point(e.X, e.Y)); } else { // 1st click = only focus _isFocused = true; _isKnobRotating = true; } } this.Cursor = Cursors.Default; }
protected override void OnMouseDown(MouseEventArgs e) { if (KryptonKnobUtilities.IsPointinRectangle(new Point(e.X, e.Y), _rKnob)) { if (_isFocused) { // was already selected // Start Rotation of knob only if it was selected before _isKnobRotating = true; } else { // Was not selected before => select it Focus(); _isFocused = true; _isKnobRotating = false; // disallow rotation, must click again // draw dotted border to show that it is selected Invalidate(); } } }