/// <summary> /// Determine whether the user has clicked the mouse button on the track bar thumb. /// </summary> /// <param name="e">The mouse event argument.</param> protected override void OnMouseDown(MouseEventArgs e) { if (this._thumbRectangle.Contains(e.Location)) { _thumbState = CrystalThumbState.Pressed; } }
/// <summary> /// Erases the thumb from the CrystalTrackBar. /// </summary> protected virtual void EraseThumb() { CrystalThumbState oldThumbState = _thumbState; _thumbState = CrystalThumbState.Erased; // This will force a repaint in the base class... InvalidateEx(_thumbRectangle); //...by the time we reach here, we know that the // trackbar and ticks have been repainted without the thumb. _thumbState = oldThumbState; }
/// <summary> /// Gets the image field matching a given thumb state. /// </summary> /// <param name="thumbState">The desired thumb state.</param> /// <returns>The Image matching the thumb state.</returns> protected Image GetCachedThumbImage(CrystalThumbState thumbState) { switch (thumbState) { case CrystalThumbState.Pressed: return(_thumbHotImage); case CrystalThumbState.Hover: return(_thumbWarmImage); default: return(_thumbImage); } }
/// <summary> /// Gets the thumb image name that matches the given state. /// </summary> /// <param name="thumbState">The state of the desired thumb image.</param> /// <returns></returns> protected Bitmap GetThumbImageName(CrystalThumbState thumbState) { switch (thumbState) { case CrystalThumbState.Pressed: return(GetHotThumbImageName()); case CrystalThumbState.Hover: return(GetWarmThumbImageName()); default: return(GetNormalThumbImageName()); } }
/// <summary> /// Tracks the mouse movement within the CrystalTrackBar. /// </summary> /// <param name="e">The mouse event argument.</param> protected override void OnMouseMove(MouseEventArgs e) { // The user is moving the thumb. if (IsThumbPressed()) { // if the value hasn't changed (the user is just holding at one position), // then it may not necessary to erase/redraw the thumb, // as it may cause too much flicker. if (!HasTrackValueChanged(e.Location)) { // BUG FIX: Without this call to redraw the control, // the background gets erased when the user holds the mouse // down, but does not move the track value. if (TransparentMode) { RedrawControl(); } return; } // Track movements to the next tick to the right, if // the cursor has moved halfway to the next tick. if (_currentTickValue < (_numberTicks - 1) && CurrentLocation(e.Location) > CurrentThumbTick() + (int)(_tickSpace)) { IncrementValue(); } // Track movements to the next tick to the left, if // cursor has moved halfway to the next tick. else if (_currentTickValue > 0 && CurrentLocation(e.Location) < CurrentThumbTick() - (int)(_tickSpace / 2)) { DecrementValue(); } } else { // ThumbState switches to hover because user is still // in trackbar area. _thumbState = CrystalThumbState.Hover; // Don't call redraw here, it will cause more flicker than necessary. //RedrawControl(); } }
/// <summary> /// Sets the image field matching a given thumb state, allowing us to cache the image. /// </summary> /// <param name="thumbState">The desired thumb state.</param> /// <param name="thumbImage">The image to cache.</param> protected void SetCachedThumbImage(CrystalThumbState thumbState, Image thumbImage) { switch (thumbState) { case CrystalThumbState.Pressed: _thumbHotImage = thumbImage; break; case CrystalThumbState.Hover: _thumbWarmImage = thumbImage; break; default: _thumbImage = thumbImage; break; } }
/// <summary> /// Determines whether the mouse cursor has left the CrystalTrackBar. /// </summary> /// <param name="e">The mouse event argument.</param> protected override void OnMouseLeave(EventArgs e) { _thumbState = CrystalThumbState.Normal; RedrawControl(); base.OnMouseLeave(e); }
/// <summary> /// Determines whether the mouse cursor has entered the CrystalTrackBar. /// </summary> /// <param name="e">The mouse event argument.</param> protected override void OnMouseEnter(EventArgs e) { _thumbState = CrystalThumbState.Hover; RedrawControl(); base.OnMouseEnter(e); }
// Redraw the track bar thumb if the user has moved it. /// <summary> /// Determine whether the user has released the mouse button. /// </summary> /// <param name="e">The mouse event argument.</param> protected override void OnMouseUp(MouseEventArgs e) { _thumbState = CrystalThumbState.Hover; RedrawControl(); }
/// <summary> /// Gets the image field matching a given thumb state. /// </summary> /// <param name="thumbState">The desired thumb state.</param> /// <returns>The Image matching the thumb state.</returns> protected Image GetCachedThumbImage(CrystalThumbState thumbState) { switch (thumbState) { case CrystalThumbState.Pressed: return _thumbHotImage; case CrystalThumbState.Hover: return _thumbWarmImage; default: return _thumbImage; } }
/// <summary> /// Gets the thumb image name that matches the given state. /// </summary> /// <param name="thumbState">The state of the desired thumb image.</param> /// <returns></returns> protected Bitmap GetThumbImageName(CrystalThumbState thumbState) { switch (thumbState) { case CrystalThumbState.Pressed: return GetHotThumbImageName(); case CrystalThumbState.Hover: return GetWarmThumbImageName(); default: return GetNormalThumbImageName(); } }
/// <summary> /// Tracks the mouse movement within the CrystalTrackBar. /// </summary> /// <param name="e">The mouse event argument.</param> protected override void OnMouseMove(MouseEventArgs e) { // The user is moving the thumb. if (IsThumbPressed()) { // if the value hasn't changed (the user is just holding at one position), // then it may not necessary to erase/redraw the thumb, // as it may cause too much flicker. if (!HasTrackValueChanged(e.Location)) { // BUG FIX: Without this call to redraw the control, // the background gets erased when the user holds the mouse // down, but does not move the track value. if (TransparentMode) RedrawControl(); return; } // Track movements to the next tick to the right, if // the cursor has moved halfway to the next tick. if (_currentTickValue < (_numberTicks - 1) && CurrentLocation(e.Location) > CurrentThumbTick() + (int)(_tickSpace)) { IncrementValue(); } // Track movements to the next tick to the left, if // cursor has moved halfway to the next tick. else if (_currentTickValue > 0 && CurrentLocation(e.Location) < CurrentThumbTick() - (int)(_tickSpace / 2)) { DecrementValue(); } } else { // ThumbState switches to hover because user is still // in trackbar area. _thumbState = CrystalThumbState.Hover; // Don't call redraw here, it will cause more flicker than necessary. //RedrawControl(); } }