コード例 #1
0
ファイル: TTrackBar.cs プロジェクト: top501/MediImage
 /// <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;
     }
 }
コード例 #2
0
ファイル: TTrackBar.cs プロジェクト: top501/MediImage
        /// <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;
        }
コード例 #3
0
ファイル: TTrackBar.cs プロジェクト: top501/MediImage
        /// <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);
            }
        }
コード例 #4
0
ファイル: TTrackBar.cs プロジェクト: top501/MediImage
        /// <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());
            }
        }
コード例 #5
0
ファイル: TTrackBar.cs プロジェクト: top501/MediImage
        /// <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();
            }
        }
コード例 #6
0
ファイル: TTrackBar.cs プロジェクト: top501/MediImage
        /// <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;
            }
        }
コード例 #7
0
ファイル: TTrackBar.cs プロジェクト: xuchuansheng/GenXSource
 /// <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;
     }
 }
コード例 #8
0
ファイル: TTrackBar.cs プロジェクト: top501/MediImage
 /// <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);
 }
コード例 #9
0
ファイル: TTrackBar.cs プロジェクト: top501/MediImage
 /// <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);
 }
コード例 #10
0
ファイル: TTrackBar.cs プロジェクト: xuchuansheng/GenXSource
 // 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();
 }
コード例 #11
0
ファイル: TTrackBar.cs プロジェクト: top501/MediImage
 // 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();
 }
コード例 #12
0
ファイル: TTrackBar.cs プロジェクト: xuchuansheng/GenXSource
 /// <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;
     }
 }
コード例 #13
0
ファイル: TTrackBar.cs プロジェクト: xuchuansheng/GenXSource
        /// <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;
        }
コード例 #14
0
ファイル: TTrackBar.cs プロジェクト: xuchuansheng/GenXSource
 /// <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;
     }
 }
コード例 #15
0
ファイル: TTrackBar.cs プロジェクト: xuchuansheng/GenXSource
 /// <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();
     }
 }
コード例 #16
0
ファイル: TTrackBar.cs プロジェクト: xuchuansheng/GenXSource
 /// <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);
 }
コード例 #17
0
ファイル: TTrackBar.cs プロジェクト: xuchuansheng/GenXSource
 /// <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);
 }
コード例 #18
0
ファイル: TTrackBar.cs プロジェクト: xuchuansheng/GenXSource
        /// <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();
            }
        }