Exemple #1
0
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     if (value is Slider)
     {
         string param = parameter.ToString();
         if (param == "0")
         {
             return(RangeSlider.GetThumbWidth((Slider)value));
         }
         else if (param == "1")
         {
             return(RangeSlider.GetThumbHeight((Slider)value));
         }
     }
     return(0d);
 }
Exemple #2
0
        private void AdjustView()
        {
            //Coerce values to make them consistent.
            var 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;
            }
        }
Exemple #3
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);
                }
            }
        }