Ejemplo n.º 1
0
        private static object CoerceStep(DependencyObject sender, object value)
        {
            RangeSlider rangeSlider = sender as RangeSlider;
            double      newValue    = ( double )value;

            return(Math.Max(0.01, newValue));
        }
Ejemplo n.º 2
0
        private static void OnOrientationChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            RangeSlider rangeSlider = sender as RangeSlider;

            if (rangeSlider != null)
            {
                rangeSlider.OnOrientationChanged(( Orientation )e.OldValue, ( Orientation )e.NewValue);
            }
        }
Ejemplo n.º 3
0
        private static void OnMinimumChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            RangeSlider rangeSlider = sender as RangeSlider;

            if (rangeSlider != null)
            {
                rangeSlider.OnMinimumChanged(( double )args.OldValue, ( double )args.NewValue);
            }
        }
Ejemplo n.º 4
0
        private void AdjustView()
        {
            //Coerce values to make them consistent.
            CoercedValues cv = this.GetCoercedValues();

            double actualWidth            = 0;
            double lowerSliderThumbWidth  = 0d;
            double higherSliderThumbWidth = 0d;

            if (this.Orientation == Orientation.Horizontal)
            {
                actualWidth            = this.ActualWidth;
                lowerSliderThumbWidth  = RangeSlider.GetThumbWidth(_lowerSlider);
                higherSliderThumbWidth = RangeSlider.GetThumbWidth(_higherSlider);
            }
            else if (this.Orientation == Orientation.Vertical)
            {
                actualWidth            = this.ActualHeight;
                lowerSliderThumbWidth  = RangeSlider.GetThumbHeight(_lowerSlider);
                higherSliderThumbWidth = RangeSlider.GetThumbHeight(_higherSlider);
            }

            actualWidth -= (lowerSliderThumbWidth + higherSliderThumbWidth);

            this.SetLowerSliderValues(cv.LowerValue, cv.Minimum, cv.Maximum);
            this.SetHigherSliderValues(cv.HigherValue, cv.Minimum, cv.Maximum);

            double entireRange = cv.Maximum - cv.Minimum;

            if (entireRange > 0)
            {
                this.HigherRangeWidth = (actualWidth * (cv.Maximum - cv.HigherValue)) / entireRange;

                this.RangeWidth = (actualWidth * (cv.HigherValue - cv.LowerValue)) / entireRange;

                this.LowerRangeWidth = (actualWidth * (cv.LowerValue - cv.Minimum)) / entireRange;
            }
            else
            {
                this.HigherRangeWidth = 0d;
                this.RangeWidth       = 0d;
                this.LowerRangeWidth  = actualWidth;
            }
        }
Ejemplo n.º 5
0
        private void SetSlidersMargins()
        {
            if ((_lowerSlider != null) && (_higherSlider != null))
            {
                if (this.Orientation == Orientation.Horizontal)
                {
                    double lowerSliderThumbWidth  = RangeSlider.GetThumbWidth(_lowerSlider);
                    double higherSliderThumbWidth = RangeSlider.GetThumbWidth(_higherSlider);

                    _higherSlider.Margin = new Thickness(lowerSliderThumbWidth, 0d, 0d, 0d);
                    _lowerSlider.Margin  = new Thickness(0d, 0d, higherSliderThumbWidth, 0d);
                }
                else
                {
                    double lowerSliderThumbHeight  = RangeSlider.GetThumbHeight(_lowerSlider);
                    double higherSliderThumbHeight = RangeSlider.GetThumbHeight(_higherSlider);

                    _higherSlider.Margin = new Thickness(0d, 0d, 0d, lowerSliderThumbHeight);
                    _lowerSlider.Margin  = new Thickness(0d, higherSliderThumbHeight, 0d, 0d);
                }
            }
        }