Exemplo n.º 1
0
        /// <inheritdoc/>
        protected override Size2D ArrangeOverride(Size2D finalSize, ArrangeOptions options)
        {
            // Calculate the sizes of the track's components.
            var thumbSize          = CalculateThumbSize(finalSize);
            var decreaseButtonSize = CalculateDecreaseButtonSize(finalSize, thumbSize);
            var increaseButtonSize = CalculateIncreaseButtonSize(finalSize, decreaseButtonSize, thumbSize);

            // Arrange the track's components.
            var position    = new Point2D(0, 0);
            var orientation = this.Orientation;

            if (IsDirectionReversed)
            {
                IncreaseButton.Arrange(new RectangleD(position, increaseButtonSize));
                position += (orientation == Orientation.Horizontal) ? new Point2D(increaseButtonSize.Width, 0) : new Point2D(0, increaseButtonSize.Height);

                Thumb.Arrange(new RectangleD(position, thumbSize));
                position += (orientation == Orientation.Horizontal) ? new Point2D(thumbSize.Width, 0) : new Point2D(0, thumbSize.Height);

                DecreaseButton.Arrange(new RectangleD(position, decreaseButtonSize));
            }
            else
            {
                DecreaseButton.Arrange(new RectangleD(position, decreaseButtonSize));
                position += (orientation == Orientation.Horizontal) ? new Point2D(decreaseButtonSize.Width, 0) : new Point2D(0, decreaseButtonSize.Height);

                Thumb.Arrange(new RectangleD(position, thumbSize));
                position += (orientation == Orientation.Horizontal) ? new Point2D(thumbSize.Width, 0) : new Point2D(0, thumbSize.Height);

                IncreaseButton.Arrange(new RectangleD(position, increaseButtonSize));
            }

            return(finalSize);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Performs decrement.
 /// </summary>
 public void Decrement()
 {
     if (AutomationType == AutomationType.UIA2)
     {
         DecreaseButton.Invoke();
         Wait.UntilInputIsProcessed();
     }
     else // UIA3
     {
         SetForeground();
         Wait.UntilInputIsProcessed();
         DecreaseButton.Click();
         Wait.UntilInputIsProcessed();
     }
 }
Exemplo n.º 3
0
        protected override Size ArrangeOverride(Size arrangeSize)
        {
            double decreaseButtonLength, thumbLength, increaseButtonLength;
            var    isVertical   = Orientation == Orientation.Vertical;
            var    viewportSize = Math.Max(0.0, ViewportSize);

            // If viewport is NaN, compute thumb's size based on its desired size,
            // otherwise compute the thumb base on the viewport and extent properties
            if (double.IsNaN(ViewportSize))
            {
                ComputeSliderLengths(arrangeSize, isVertical, out decreaseButtonLength, out thumbLength, out increaseButtonLength);
            }
            else
            {
                // Don't arrange if there's not enough content or the track is too small
                if (!ComputeScrollBarLengths(arrangeSize, viewportSize, isVertical, out decreaseButtonLength, out thumbLength, out increaseButtonLength))
                {
                    return(arrangeSize);
                }
            }

            // Layout the pieces of track
            var offset              = new Point();
            var pieceSize           = arrangeSize;
            var isDirectionReversed = IsDirectionReversed;

            if (isVertical)
            {
                CoerceLength(ref decreaseButtonLength, arrangeSize.Height);
                CoerceLength(ref increaseButtonLength, arrangeSize.Height);
                CoerceLength(ref thumbLength, arrangeSize.Height);

                offset    = offset.WithY(isDirectionReversed ? decreaseButtonLength + thumbLength : 0.0);
                pieceSize = pieceSize.WithHeight(increaseButtonLength);

                if (IncreaseButton != null)
                {
                    IncreaseButton.Arrange(new Rect(offset, pieceSize));
                }

                offset    = offset.WithY(isDirectionReversed ? 0.0 : increaseButtonLength + thumbLength);
                pieceSize = pieceSize.WithHeight(decreaseButtonLength);

                if (DecreaseButton != null)
                {
                    DecreaseButton.Arrange(new Rect(offset, pieceSize));
                }

                offset    = offset.WithY(isDirectionReversed ? decreaseButtonLength : increaseButtonLength);
                pieceSize = pieceSize.WithHeight(thumbLength);

                if (Thumb != null)
                {
                    Thumb.Arrange(new Rect(offset, pieceSize));
                }

                ThumbCenterOffset = offset.Y + (thumbLength * 0.5);
            }
            else
            {
                CoerceLength(ref decreaseButtonLength, arrangeSize.Width);
                CoerceLength(ref increaseButtonLength, arrangeSize.Width);
                CoerceLength(ref thumbLength, arrangeSize.Width);

                offset    = offset.WithX(isDirectionReversed ? increaseButtonLength + thumbLength : 0.0);
                pieceSize = pieceSize.WithWidth(decreaseButtonLength);

                if (DecreaseButton != null)
                {
                    DecreaseButton.Arrange(new Rect(offset, pieceSize));
                }

                offset    = offset.WithX(isDirectionReversed ? 0.0 : decreaseButtonLength + thumbLength);
                pieceSize = pieceSize.WithWidth(increaseButtonLength);

                if (IncreaseButton != null)
                {
                    IncreaseButton.Arrange(new Rect(offset, pieceSize));
                }

                offset    = offset.WithX(isDirectionReversed ? increaseButtonLength : decreaseButtonLength);
                pieceSize = pieceSize.WithWidth(thumbLength);

                if (Thumb != null)
                {
                    Thumb.Arrange(new Rect(offset, pieceSize));
                }

                ThumbCenterOffset = offset.X + (thumbLength * 0.5);
            }

            return(arrangeSize);
        }