Exemplo n.º 1
0
        private static void Clamp(ValuePicker slider)
        {
            var xMin = Math.Min(slider.XMinimum, slider.XMinimum);
            var xMax = Math.Max(slider.XMaximum, slider.XMinimum);

            if (slider.XValue > xMax)
            {
                slider.XValue = xMax;
            }
            if (slider.XValue < xMin)
            {
                slider.XValue = xMin;
            }
            var yMin = Math.Min(slider.YMaximum, slider.YMinimum);
            var yMax = Math.Max(slider.YMaximum, slider.YMinimum);

            if (slider.YValue > yMax)
            {
                slider.YValue = yMax;
            }
            if (slider.YValue < yMin)
            {
                slider.YValue = yMin;
            }
        }
Exemplo n.º 2
0
        private static Point ConvertPointToValue(Point p, ValuePicker slider)
        {
            var xRange = Math.Max(slider.XMaximum, slider.XMinimum) - Math.Min(slider.XMaximum, slider.XMinimum);
            var yRange = Math.Max(slider.YMaximum, slider.YMinimum) - Math.Min(slider.YMaximum, slider.YMinimum);
            var xValue = (slider.IsXReversed ? slider.ActualWidth - p.X : p.X) * (xRange / slider.ActualWidth);
            var yValue = (slider.IsYReversed ? slider.ActualHeight - p.Y : p.Y) * (yRange / slider.ActualHeight);

            return(new Point(slider.IsXEnabled ? xValue : 0d, slider.IsYEnabled ? yValue : 0d));
        }
Exemplo n.º 3
0
        private static Point ConvertValueToPoint(Point v, ValuePicker slider)
        {
            var xRange = Math.Max(slider.XMaximum, slider.XMinimum) - Math.Min(slider.XMaximum, slider.XMinimum);
            var yRange = Math.Max(slider.YMaximum, slider.YMinimum) - Math.Min(slider.YMaximum, slider.YMinimum);
            var xPoint = v.X / (xRange / slider.ActualWidth);
            var yPoint = v.Y / (yRange / slider.ActualHeight);

            xPoint = slider.IsXReversed ? slider.ActualWidth - xPoint : xPoint;
            yPoint = slider.IsYReversed ? slider.ActualHeight - yPoint : yPoint;
            return(new Point(
                       slider.IsXEnabled ? xPoint : 0d,
                       slider.IsYEnabled ? yPoint : 0d));
        }
Exemplo n.º 4
0
 private static void Clamp(ValuePicker slider)
 {
     var xMin = Math.Min(slider.XMinimum, slider.XMinimum);
     var xMax = Math.Max(slider.XMaximum, slider.XMinimum);
     if (slider.XValue > xMax)
         slider.XValue = xMax;
     if (slider.XValue < xMin)
         slider.XValue = xMin;
     var yMin = Math.Min(slider.YMaximum, slider.YMinimum);
     var yMax = Math.Max(slider.YMaximum, slider.YMinimum);
     if (slider.YValue > yMax)
         slider.YValue = yMax;
     if (slider.YValue < yMin)
         slider.YValue = yMin;
 }
Exemplo n.º 5
0
 private static Point ConvertValueToPoint(Point v, ValuePicker slider)
 {
     var xRange = Math.Max(slider.XMaximum, slider.XMinimum) - Math.Min(slider.XMaximum, slider.XMinimum);
     var yRange = Math.Max(slider.YMaximum, slider.YMinimum) - Math.Min(slider.YMaximum, slider.YMinimum);
     var xPoint = v.X / (xRange / slider.ActualWidth);
     var yPoint = v.Y / (yRange / slider.ActualHeight);
     xPoint = slider.IsXReversed ? slider.ActualWidth - xPoint : xPoint;
     yPoint = slider.IsYReversed ? slider.ActualHeight - yPoint : yPoint;
     return new Point(
         slider.IsXEnabled ? xPoint : 0d,
         slider.IsYEnabled ? yPoint : 0d);
 }
Exemplo n.º 6
0
 private static Point ConvertPointToValue(Point p, ValuePicker slider)
 {
     var xRange = Math.Max(slider.XMaximum, slider.XMinimum) - Math.Min(slider.XMaximum, slider.XMinimum);
     var yRange = Math.Max(slider.YMaximum, slider.YMinimum) - Math.Min(slider.YMaximum, slider.YMinimum);
     var xValue = (slider.IsXReversed ? slider.ActualWidth - p.X : p.X) * (xRange / slider.ActualWidth);
     var yValue = (slider.IsYReversed ? slider.ActualHeight - p.Y : p.Y) * (yRange / slider.ActualHeight);
     return new Point(slider.IsXEnabled ? xValue : 0d, slider.IsYEnabled ? yValue : 0d);
 }