public static void DrawHorizontalThumb (Graphics g, Rectangle bounds, TrackBarThumbState state)
		{
			if (!IsSupported)
				throw new InvalidOperationException ();

			VisualStyleRenderer vsr;

			switch (state) {
				case TrackBarThumbState.Disabled:
					vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Thumb.Disabled);
					break;
				case TrackBarThumbState.Hot:
					vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Thumb.Hot);
					break;
				case TrackBarThumbState.Normal:
				default:
					vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Thumb.Normal);
					break;
				case TrackBarThumbState.Pressed:
					vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.Thumb.Pressed);
					break;
			}

			vsr.DrawBackground (g, bounds);
		}
예제 #2
0
    /// <summary>
    /// Overriden. Raised when mouse down occured.
    /// Determine whether the user has clicked a track bar thumb.
    /// </summary>
    /// <param name="e">A <see cref="MouseEventArgs"/> that contains the event data. </param>
    protected override void OnMouseDown(MouseEventArgs e)
    {
      //if (!TrackBarRenderer.IsSupported)
      //  return;
      if (_duration != 0)
      {
        if (this._caretThumbBounds.Contains(e.Location) && _showCaret)
        {
          _caretThumbClicked = true;
          _caretThumbState = TrackBarThumbState.Pressed;
        }
        else if (this._leftThumbBounds.Contains(e.Location))
        {
          _leftThumbClicked = true;
          _leftThumbState = TrackBarThumbState.Pressed;
        }
        else if (this._rightThumbBounds.Contains(e.Location))
        {
          _rightThumbClicked = true;
          _rightThumbState = TrackBarThumbState.Pressed;
        }

        this.Invalidate();
      }
    }
		public static Size GetTopPointingThumbSize (Graphics g, TrackBarThumbState state)
		{
			if (!IsSupported)
				throw new InvalidOperationException ();

			VisualStyleRenderer vsr;

			switch (state) {
				case TrackBarThumbState.Disabled:
					vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbTop.Disabled);
					break;
				case TrackBarThumbState.Hot:
					vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbTop.Hot);
					break;
				case TrackBarThumbState.Normal:
				default:
					vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbTop.Normal);
					break;
				case TrackBarThumbState.Pressed:
					vsr = new VisualStyleRenderer (VisualStyleElement.TrackBar.ThumbTop.Pressed);
					break;
			}

			return vsr.GetPartSize (g, ThemeSizeType.Draw);
		}
 public static void DrawVerticalThumb(Graphics g, Rectangle bounds, TrackBarThumbState state)
 {
     InitializeRenderer(VisualStyleElement.TrackBar.ThumbVertical.Normal, (int) state);
     visualStyleRenderer.DrawBackground(g, bounds);
 }
예제 #5
0
 /// <summary>
 /// 
 /// </summary>
 public TimeLineMarker()
 {
   this.state = TrackBarThumbState.Normal;
   this.markerColor = Color.Yellow;
 }
예제 #6
0
        [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] // Using Graphics instead of IDeviceContext intentionally
        public static void DrawLeftPointingThumb(Graphics g, Rectangle bounds, TrackBarThumbState state)
        {
            InitializeRenderer(VisualStyleElement.TrackBar.ThumbLeft.Normal, (int)state);

            visualStyleRenderer.DrawBackground(g, bounds);
        }
 public static Size GetTopPointingThumbSize(Graphics g, TrackBarThumbState state)
 {
     InitializeRenderer(VisualStyleElement.TrackBar.ThumbTop.Normal, (int) state);
     return visualStyleRenderer.GetPartSize(g, ThemeSizeType.True);
 }
예제 #8
0
파일: TimeLine.cs 프로젝트: DeSciL/Ogama
    /// <summary>
    /// Overriden. Raised when mouse down occured.
    /// Determine whether the user has clicked a track bar thumb.
    /// </summary>
    /// <param name="e">A <see cref="MouseEventArgs"/> that contains the event data. </param>
    protected override void OnMouseDown(MouseEventArgs e)
    {
      //if (!TrackBarRenderer.IsSupported)
      //  return;
      if (_duration != 0)
      {
        if (this._caretThumbBounds.Contains(e.Location) && _showCaret)
        {
          _caretThumbClicked = true;
          _caretThumbState = TrackBarThumbState.Pressed;
        }
        else if (this._leftThumbBounds.Contains(e.Location))
        {
          _leftThumbClicked = true;
          _leftThumbState = TrackBarThumbState.Pressed;
        }
        else if (this._rightThumbBounds.Contains(e.Location))
        {
          _rightThumbClicked = true;
          _rightThumbState = TrackBarThumbState.Pressed;
        }

        foreach (TimeLineMarker marker in this.timeLineMarkers)
        {
          Rectangle bounds = new Rectangle(
            GetXCoordinateForPosition(marker.Time / (double)this.Duration) - TimeLineMarker.MARKERWIDTH / 2,
            0,
            TimeLineMarker.MARKERWIDTH,
            this.Height);

          if (bounds.Contains(e.Location))
          {
            marker.State = TrackBarThumbState.Pressed;
            this.movingMarkerEventID = marker.EventID;
          }
        }

        this.Invalidate();
      }
    }
예제 #9
0
        private void DrawThumb(Graphics g, Rectangle bounds, TrackBarThumbState state)
        {
            s_thumbPoints[0] = bounds.Location;
            s_thumbPoints[1] = new Point(bounds.Right, bounds.Top);
            s_thumbPoints[2] = new Point(bounds.Right, bounds.Top + bounds.Height * 3 / 4);
            s_thumbPoints[3] = new Point((bounds.Left + bounds.Right) / 2, bounds.Top + bounds.Height);
            s_thumbPoints[4] = new Point(bounds.Left, bounds.Top + bounds.Height * 3 / 4);

            g.DrawPolygon(Theme.SliderTrackPen, s_thumbPoints);
        }
예제 #10
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     base.OnMouseDown(e);
     state = TrackBarThumbState.Pressed;
     Refresh();
 }
예제 #11
0
파일: TimeLine.cs 프로젝트: DeSciL/Ogama
    /// <summary>
    /// Overriden. Raised when mouse move occured.
    /// Track cursor movements.
    /// </summary>
    /// <param name="e">A <see cref="MouseEventArgs"/> that contains the event data. </param>
    protected override void OnMouseMove(MouseEventArgs e)
    {
      //if (!TrackBarRenderer.IsSupported)
      //  return;

      bool caretMoved = false;

      if (_duration != 0)
      {
        // The user is moving the thumb.
        if (_leftThumbClicked == true)
        {
          if (e.X >= _halfThumbWidth + this.Padding.Left + (int)_timeTextSize.Width &&
            e.X < GetXCoordinateForPosition(_rightThumbPosition))
          {
            _leftThumbPosition = (e.X - _halfThumbWidth -
              this.Padding.Left - (int)_timeTextSize.Width) / (double)_trackBounds.Width;
            _leftThumbBounds.X = GetXCoordinateForPosition(_leftThumbPosition) - _halfThumbWidth;
            OnSectionStartValueChanged(new PositionValueChangedEventArguments(this.SectionStartTime));
          }
          //if caret would be out of bounds reposition caret.
          if (e.X >= GetXCoordinateForPosition(_caretThumbPosition)
            && e.X <= GetXCoordinateForPosition(_rightThumbPosition))
          {
            _caretThumbPosition = (e.X - _halfThumbWidth -
              this.Padding.Left - (int)_timeTextSize.Width) / (double)_trackBounds.Width;
            _caretThumbBounds.X = GetXCoordinateForPosition(_caretThumbPosition) - _halfThumbWidth;
            caretMoved = true;
            OnCaretValueChanged(new PositionValueChangedEventArguments(this.CurrentTime));
          }

          this.Parent.Refresh();
          return;
        }
        // The cursor is passing over the track.
        else
        {
          if (_leftThumbBounds.Contains(e.Location))
          {
            _leftThumbState = TrackBarThumbState.Hot;
            this.Invalidate();
            return;
          }
          else
          {
            _leftThumbState = TrackBarThumbState.Normal;
          }
        }



        // The user is moving the thumb.
        if (_rightThumbClicked == true)
        {
          if (e.X > GetXCoordinateForPosition(_leftThumbPosition) &&
            e.X <= _trackBounds.Width + _halfThumbWidth + this.Padding.Left + (int)_timeTextSize.Width)
          {
            _rightThumbPosition = (e.X - _halfThumbWidth -
              this.Padding.Left - (int)_timeTextSize.Width) / (double)_trackBounds.Width;
            _rightThumbBounds.X = GetXCoordinateForPosition(_rightThumbPosition) - _halfThumbWidth;
            OnSectionEndValueChanged(new PositionValueChangedEventArguments(this.SectionEndTime));
          }
          //if caret would be out of bounds reposition caret.
          if (e.X <= GetXCoordinateForPosition(_caretThumbPosition)
            && e.X >= GetXCoordinateForPosition(_leftThumbPosition))
          {
            _caretThumbPosition = (e.X - _halfThumbWidth -
              this.Padding.Left - (int)_timeTextSize.Width) / (double)_trackBounds.Width;
            _caretThumbBounds.X = GetXCoordinateForPosition(_caretThumbPosition) - _halfThumbWidth;
            caretMoved = true;
            OnCaretValueChanged(new PositionValueChangedEventArguments(this.CurrentTime));
          }

          this.Parent.Refresh();
          return;
        }
        // The cursor is passing over the track.
        else
        {
          if (_rightThumbBounds.Contains(e.Location))
          {
            _rightThumbState = TrackBarThumbState.Hot;
            this.Invalidate();
            return;
          }
          else
          {
            _rightThumbState = TrackBarThumbState.Normal;
          }
        }

        // The user is moving the thumb.
        if (_caretThumbClicked == true)
        {
          if (e.X >= GetXCoordinateForPosition(_leftThumbPosition) &&
            e.X <= GetXCoordinateForPosition(_rightThumbPosition))
          {
            _caretThumbPosition = (e.X - _halfThumbWidth -
              this.Padding.Left - (int)_timeTextSize.Width) / (double)_trackBounds.Width;
            _caretThumbBounds.X = GetXCoordinateForPosition(_caretThumbPosition) - _halfThumbWidth;
            caretMoved = true;
            OnCaretValueChanged(new PositionValueChangedEventArguments(this.CurrentTime));
          }

          this.Parent.Refresh();
          return;
        }
        // The cursor is passing over the track.
        else
        {
          if (_caretThumbBounds.Contains(e.Location))
          {
            _caretThumbState = TrackBarThumbState.Hot;
            this.Invalidate();
            return;
          }
          else
          {
            _caretThumbState = TrackBarThumbState.Normal;
          }
        }

        foreach (TimeLineMarker marker in this.timeLineMarkers)
        {
          // The user is moving the marker.
          if (marker.State == TrackBarThumbState.Pressed)
          {
            if (e.X >= GetXCoordinateForPosition(_leftThumbPosition) &&
              e.X <= GetXCoordinateForPosition(_rightThumbPosition))
            {
              marker.Time = (int)(((e.X - TimeLineMarker.MARKERWIDTH / 2 -
                this.Padding.Left - (int)_timeTextSize.Width) / (double)_trackBounds.Width) * this.Duration);
            }
          }
          // The cursor is passing over the track.
          else
          {
            Rectangle bounds = new Rectangle(
              GetXCoordinateForPosition(marker.Time / (double)Duration) - TimeLineMarker.MARKERWIDTH / 2,
              0,
              TimeLineMarker.MARKERWIDTH,
              this.Height);

            if (bounds.Contains(e.Location))
            {
              marker.State = TrackBarThumbState.Hot;
            }
            else
            {
              marker.State = TrackBarThumbState.Normal;
            }
          }
        }

        if (!caretIsMoving && caretMoved)
        {
          OnCaretMovingStarted(EventArgs.Empty);
          caretIsMoving = true;
        }

        this.Parent.Refresh();
      }
    }
예제 #12
0
 protected override void OnMouseLeave(EventArgs e)
 {
     base.OnMouseLeave(e);
     state = TrackBarThumbState.Normal;
     Refresh();
 }
예제 #13
0
 protected override void OnMouseEnter(EventArgs e)
 {
     base.OnMouseEnter(e);
     state = TrackBarThumbState.Hot;
     Refresh();
 }
예제 #14
0
        // Track cursor movements.
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (!TrackBarRenderer.IsSupported)
            {
                return;
            }

            // The user is moving the thumb.
            if (thumbClickedL == true)
            {
                // Track movements to the next tick to the right, if
                // the cursor has moved halfway to the next tick.

                /*
                 * if (currentTickPositionL < numberTicks - 1 &&
                 *  e.Location.X > CurrentTickXCoordinate(currentTickPositionL) + (int)(tickSpace) &&
                 *  currentTickPositionL < currentTickPositionR-1
                 *  )
                 * {
                 *  currentTickPositionL++;
                 * }
                 *
                 * // Track movements to the next tick to the left, if
                 * // cursor has moved halfway to the next tick.
                 * else if (currentTickPositionL > 0 &&
                 *  e.Location.X < CurrentTickXCoordinate(currentTickPositionL) - (int)(tickSpace / 2)
                 *  )
                 * {
                 *  currentTickPositionL--;
                 * }
                 *
                 *
                 * thumbRectangleL.X = CurrentTickXCoordinate(currentTickPositionL);
                 */
                currentTickPositionL = nearPosition(e.Location.X);
                if (currentTickPositionL >= currentTickPositionR)
                {
                    currentTickPositionL = currentTickPositionR - 1;
                }
                thumbRectangleL.X = CurrentTickXCoordinate(currentTickPositionL);
                if (ValueChanged != null)
                {
                    ValueChanged(this, new EventArgs());
                }
            }
            else if (thumbClickedR == true)
            {
                // Track movements to the next tick to the right, if
                // the cursor has moved halfway to the next tick.

                /*if (currentTickPositionR < numberTicks - 1 &&
                 *  e.Location.X > CurrentTickXCoordinate(currentTickPositionR) + (int)(tickSpace)
                 *  )
                 * {
                 *  currentTickPositionR++;
                 * }
                 *
                 * // Track movements to the next tick to the left, if
                 * // cursor has moved halfway to the next tick.
                 * else if (currentTickPositionR > 0 &&
                 *  e.Location.X < CurrentTickXCoordinate(currentTickPositionR) - (int)(tickSpace / 2) &&
                 *  currentTickPositionL < currentTickPositionR - 1
                 *  )
                 * {
                 *  currentTickPositionR--;
                 * }*/
                currentTickPositionR = nearPosition(e.Location.X);
                if (currentTickPositionL >= currentTickPositionR)
                {
                    currentTickPositionR = currentTickPositionL + 1;
                }
                thumbRectangleR.X = CurrentTickXCoordinate(currentTickPositionR);
                if (ValueChanged != null)
                {
                    ValueChanged(this, new EventArgs());
                }
            }

            // The cursor is passing over the track.
            else
            {
                thumbStateL = thumbRectangleL.Contains(e.Location) ?
                              TrackBarThumbState.Hot : TrackBarThumbState.Normal;
                thumbStateR = thumbRectangleR.Contains(e.Location) ?
                              TrackBarThumbState.Hot : TrackBarThumbState.Normal;
            }
            barRectangleC.X = (thumbRectangleL.X + thumbRectangleR.X + thumbRectangleL.Width) / 2;
            Invalidate();
        }
예제 #15
0
    /// <summary>
    /// Overriden. Raised when mouse up occured.
    /// Redraw the track bar thumb if the user has moved it.
    /// </summary>
    /// <param name="e">A <see cref="MouseEventArgs"/> that contains the event data. </param>
    protected override void OnMouseUp(MouseEventArgs e)
    {
      //if (!TrackBarRenderer.IsSupported)
      //  return;

      if (_duration != 0)
      {
        if (_leftThumbClicked == true)
        {
          if (e.Location.X > _trackBounds.X &&
              e.Location.X < (_trackBounds.X +
              _trackBounds.Width - _leftThumbBounds.Width))
          {
            _leftThumbClicked = false;
            _leftThumbState = TrackBarThumbState.Hot;
            this.Invalidate();
          }

          _leftThumbClicked = false;
        }
        else if (_rightThumbClicked == true)
        {
          if (e.Location.X > _trackBounds.X &&
              e.Location.X < (_trackBounds.X +
              _trackBounds.Width - _leftThumbBounds.Width))
          {
            _rightThumbClicked = false;
            _rightThumbState = TrackBarThumbState.Hot;
            this.Invalidate();
          }

          _rightThumbClicked = false;
        }
        else if (_caretThumbClicked == true)
        {
          if (e.Location.X > _trackBounds.X &&
              e.Location.X < (_trackBounds.X +
              _trackBounds.Width - _leftThumbBounds.Width))
          {
            _caretThumbClicked = false;
            _caretThumbState = TrackBarThumbState.Hot;
            this.Invalidate();
          }

          _caretThumbClicked = false;
        }
      }
    }
예제 #16
0
        private void DrawSlider(Graphics g, TrackBarThumbState state)
        {
            int sliderLocation;

            if (ZoomValue < DefaultValue)
            {
                int regionWidth = Width / 2 - SliderWidth / 2;
                float scale = (float)regionWidth / (DefaultValue - MinValue);
                sliderLocation = (int)Math.Round(scale * (ZoomValue - MinValue)) + SliderWidth / 2;
            }
            else
            {
                int regionWidth = Width / 2 - SliderWidth / 2;
                float scale = (float)regionWidth / (MaxValue - DefaultValue);
                sliderLocation = (int)Math.Round(scale * (ZoomValue - DefaultValue)) + Width / 2;
            }

            Image slider;
            if (state == TrackBarThumbState.Disabled)
                slider = Properties.Resources.DisabledSlider;
            else
                slider = Properties.Resources.Slider;
            int top = Height / 2 - SliderHeight / 2;
            int left = sliderLocation - SliderWidth / 2;

            g.DrawImage(slider, left, top, SliderWidth, SliderHeight);
        }
예제 #17
0
    /// <summary>
    /// Overriden. Raised when mouse move occured.
    /// Track cursor movements.
    /// </summary>
    /// <param name="e">A <see cref="MouseEventArgs"/> that contains the event data. </param>
    protected override void OnMouseMove(MouseEventArgs e)
    {
      //if (!TrackBarRenderer.IsSupported)
      //  return;

      if (_duration != 0)
      {
        // The user is moving the thumb.
        if (_leftThumbClicked == true)
        {
          if (e.X >= _halfThumbWidth + this.Padding.Left + (int)_timeTextSize.Width &&
            e.X < CurrentRightThumbXCoordinate() + this.Padding.Left + (int)_timeTextSize.Width)
          {
            _leftThumbPosition = (e.X - _halfThumbWidth -
              this.Padding.Left - (int)_timeTextSize.Width) / (double)_trackBounds.Width;
            _leftThumbBounds.X = CurrentLeftThumbXCoordinate() - _halfThumbWidth +
              this.Padding.Left + (int)_timeTextSize.Width;
            OnSectionStartValueChanged(new PositionValueChangedEventArguments(this.SectionStartTime));
          }
          //if caret would be out of bounds reposition caret.
          if (e.X >= CurrentCaretThumbXCoordinate() + this.Padding.Left + (int)_timeTextSize.Width
            && e.X <= CurrentRightThumbXCoordinate() + this.Padding.Left + (int)_timeTextSize.Width)
          {
            _caretThumbPosition = (e.X - _halfThumbWidth -
              this.Padding.Left - (int)_timeTextSize.Width) / (double)_trackBounds.Width;
            _caretThumbBounds.X = CurrentCaretThumbXCoordinate() - _halfThumbWidth +
              this.Padding.Left + (int)_timeTextSize.Width;
            OnCaretValueChanged(new PositionValueChangedEventArguments(this.CurrentTime));
          }
        }
        // The cursor is passing over the track.
        else
        {
          _leftThumbState = _leftThumbBounds.Contains(e.Location) ?
              TrackBarThumbState.Hot : TrackBarThumbState.Normal;
        }



        // The user is moving the thumb.
        if (_rightThumbClicked == true)
        {
          if (e.X > CurrentLeftThumbXCoordinate() + this.Padding.Left + (int)_timeTextSize.Width &&
            e.X <= _trackBounds.Width + _halfThumbWidth + this.Padding.Left + (int)_timeTextSize.Width)
          {
            _rightThumbPosition = (e.X - _halfThumbWidth -
              this.Padding.Left - (int)_timeTextSize.Width) / (double)_trackBounds.Width;
            _rightThumbBounds.X = CurrentRightThumbXCoordinate() - _halfThumbWidth +
              this.Padding.Left + (int)_timeTextSize.Width;
            OnSectionEndValueChanged(new PositionValueChangedEventArguments(this.SectionEndTime));
          }
          //if caret would be out of bounds reposition caret.
          if (e.X <= CurrentCaretThumbXCoordinate() + this.Padding.Left + (int)_timeTextSize.Width
            && e.X >= CurrentLeftThumbXCoordinate() + this.Padding.Left + (int)_timeTextSize.Width)
          {
            _caretThumbPosition = (e.X - _halfThumbWidth -
              this.Padding.Left - (int)_timeTextSize.Width) / (double)_trackBounds.Width;
            _caretThumbBounds.X = CurrentCaretThumbXCoordinate() - _halfThumbWidth +
              this.Padding.Left + (int)_timeTextSize.Width;
            OnCaretValueChanged(new PositionValueChangedEventArguments(this.CurrentTime));
          }
        }
        // The cursor is passing over the track.
        else
        {
          _rightThumbState = _rightThumbBounds.Contains(e.Location) ?
              TrackBarThumbState.Hot : TrackBarThumbState.Normal;
        }

        // The user is moving the thumb.
        if (_caretThumbClicked == true)
        {
          if (e.X >= CurrentLeftThumbXCoordinate() + this.Padding.Left + (int)_timeTextSize.Width &&
            e.X <= CurrentRightThumbXCoordinate() + this.Padding.Left + (int)_timeTextSize.Width)
          {
            _caretThumbPosition = (e.X - _halfThumbWidth -
              this.Padding.Left - (int)_timeTextSize.Width) / (double)_trackBounds.Width;
            _caretThumbBounds.X = CurrentCaretThumbXCoordinate() - _halfThumbWidth +
              this.Padding.Left + (int)_timeTextSize.Width;
            OnCaretValueChanged(new PositionValueChangedEventArguments(this.CurrentTime));
          }
        }
        // The cursor is passing over the track.
        else
        {
          _caretThumbState = _caretThumbBounds.Contains(e.Location) ?
              TrackBarThumbState.Hot : TrackBarThumbState.Normal;
        }

        //Refresh();
        //this.Invalidate();
      }
    }
예제 #18
0
        [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] // Using Graphics instead of IDeviceContext intentionally
        public static Size GetBottomPointingThumbSize(Graphics g, TrackBarThumbState state)
        {
            InitializeRenderer(VisualStyleElement.TrackBar.ThumbBottom.Normal, (int)state);

            return(visualStyleRenderer.GetPartSize(g, ThemeSizeType.True));
        }