Exemple #1
0
        // Token: 0x06006134 RID: 24884 RVA: 0x001B47DC File Offset: 0x001B29DC
        private void ComputeSliderLengths(Size arrangeSize, bool isVertical, out double decreaseButtonLength, out double thumbLength, out double increaseButtonLength)
        {
            double minimum = this.Minimum;
            double num     = Math.Max(0.0, this.Maximum - minimum);
            double num2    = Math.Min(num, this.Value - minimum);
            double num3;

            if (isVertical)
            {
                num3        = arrangeSize.Height;
                thumbLength = ((this.Thumb == null) ? 0.0 : this.Thumb.DesiredSize.Height);
            }
            else
            {
                num3        = arrangeSize.Width;
                thumbLength = ((this.Thumb == null) ? 0.0 : this.Thumb.DesiredSize.Width);
            }
            Track.CoerceLength(ref thumbLength, num3);
            double num4 = num3 - thumbLength;

            decreaseButtonLength = num4 * num2 / num;
            Track.CoerceLength(ref decreaseButtonLength, num4);
            increaseButtonLength = num4 - decreaseButtonLength;
            Track.CoerceLength(ref increaseButtonLength, num4);
            this.Density = num / num4;
        }
Exemple #2
0
        // Token: 0x06006135 RID: 24885 RVA: 0x001B48BC File Offset: 0x001B2ABC
        private bool ComputeScrollBarLengths(Size arrangeSize, double viewportSize, bool isVertical, out double decreaseButtonLength, out double thumbLength, out double increaseButtonLength)
        {
            double minimum = this.Minimum;
            double num     = Math.Max(0.0, this.Maximum - minimum);
            double num2    = Math.Min(num, this.Value - minimum);
            double num3    = Math.Max(0.0, num) + viewportSize;
            double num4;
            double val;

            if (isVertical)
            {
                num4 = arrangeSize.Height;
                object obj  = base.TryFindResource(SystemParameters.VerticalScrollBarButtonHeightKey);
                double num5 = (obj is double) ? ((double)obj) : SystemParameters.VerticalScrollBarButtonHeight;
                val = Math.Floor(num5 * 0.5);
            }
            else
            {
                num4 = arrangeSize.Width;
                object obj2 = base.TryFindResource(SystemParameters.HorizontalScrollBarButtonWidthKey);
                double num6 = (obj2 is double) ? ((double)obj2) : SystemParameters.HorizontalScrollBarButtonWidth;
                val = Math.Floor(num6 * 0.5);
            }
            thumbLength = num4 * viewportSize / num3;
            Track.CoerceLength(ref thumbLength, num4);
            thumbLength = Math.Max(val, thumbLength);
            bool flag  = DoubleUtil.LessThanOrClose(num, 0.0);
            bool flag2 = thumbLength > num4;

            if (flag || flag2)
            {
                if (base.Visibility != Visibility.Hidden)
                {
                    base.Visibility = Visibility.Hidden;
                }
                this.ThumbCenterOffset = double.NaN;
                this.Density           = double.NaN;
                decreaseButtonLength   = 0.0;
                increaseButtonLength   = 0.0;
                return(false);
            }
            if (base.Visibility != Visibility.Visible)
            {
                base.Visibility = Visibility.Visible;
            }
            double num7 = num4 - thumbLength;

            decreaseButtonLength = num7 * num2 / num;
            Track.CoerceLength(ref decreaseButtonLength, num7);
            increaseButtonLength = num7 - decreaseButtonLength;
            Track.CoerceLength(ref increaseButtonLength, num7);
            this.Density = num / num7;
            return(true);
        }
Exemple #3
0
        /// <summary>Creates the layout for the <see cref="T:System.Windows.Controls.Primitives.Track" />.</summary>
        /// <param name="arrangeSize">The area that is provided for the <see cref="T:System.Windows.Controls.Primitives.Track" />.</param>
        /// <returns>The <see cref="T:System.Windows.Size" /> to use for the <see cref="T:System.Windows.Controls.Primitives.Track" /> content.</returns>
        // Token: 0x06006133 RID: 24883 RVA: 0x001B4580 File Offset: 0x001B2780
        protected override Size ArrangeOverride(Size arrangeSize)
        {
            bool   flag = this.Orientation == Orientation.Vertical;
            double num  = Math.Max(0.0, this.ViewportSize);
            double num2;
            double num3;
            double num4;

            if (double.IsNaN(num))
            {
                this.ComputeSliderLengths(arrangeSize, flag, out num2, out num3, out num4);
            }
            else if (!this.ComputeScrollBarLengths(arrangeSize, num, flag, out num2, out num3, out num4))
            {
                return(arrangeSize);
            }
            Point location            = default(Point);
            Size  size                = arrangeSize;
            bool  isDirectionReversed = this.IsDirectionReversed;

            if (flag)
            {
                Track.CoerceLength(ref num2, arrangeSize.Height);
                Track.CoerceLength(ref num4, arrangeSize.Height);
                Track.CoerceLength(ref num3, arrangeSize.Height);
                location.Y  = (isDirectionReversed ? (num2 + num3) : 0.0);
                size.Height = num4;
                if (this.IncreaseRepeatButton != null)
                {
                    this.IncreaseRepeatButton.Arrange(new Rect(location, size));
                }
                location.Y  = (isDirectionReversed ? 0.0 : (num4 + num3));
                size.Height = num2;
                if (this.DecreaseRepeatButton != null)
                {
                    this.DecreaseRepeatButton.Arrange(new Rect(location, size));
                }
                location.Y  = (isDirectionReversed ? num2 : num4);
                size.Height = num3;
                if (this.Thumb != null)
                {
                    this.Thumb.Arrange(new Rect(location, size));
                }
                this.ThumbCenterOffset = location.Y + num3 * 0.5;
            }
            else
            {
                Track.CoerceLength(ref num2, arrangeSize.Width);
                Track.CoerceLength(ref num4, arrangeSize.Width);
                Track.CoerceLength(ref num3, arrangeSize.Width);
                location.X = (isDirectionReversed ? (num4 + num3) : 0.0);
                size.Width = num2;
                if (this.DecreaseRepeatButton != null)
                {
                    this.DecreaseRepeatButton.Arrange(new Rect(location, size));
                }
                location.X = (isDirectionReversed ? 0.0 : (num2 + num3));
                size.Width = num4;
                if (this.IncreaseRepeatButton != null)
                {
                    this.IncreaseRepeatButton.Arrange(new Rect(location, size));
                }
                location.X = (isDirectionReversed ? num4 : num2);
                size.Width = num3;
                if (this.Thumb != null)
                {
                    this.Thumb.Arrange(new Rect(location, size));
                }
                this.ThumbCenterOffset = location.X + num3 * 0.5;
            }
            return(arrangeSize);
        }