예제 #1
0
        /// <summary>
        /// Calculates and angle in degrees based on a value, a value range, an angle range and a sweep direction.
        /// </summary>
        /// <param name="context">A context that contains the value to be converted to an angle.</param>
        /// <returns>Returns an angle in radians that corresponds to the provided value in the context.</returns>
        internal static double CalculateAngle(CalculateAngleContext context)
        {
            double angleDeg = RadGauge.MapLogicalToPhysicalValue(context.value - context.startValue, context.gaugePhysicalLength, context.gaugeLogicalLength);

            var angle = RadialGaugePanel.ConvertDegreesToRadians(angleDeg);

            return(RadialGaugePanel.ConvertDegreesToRadians(context.minAngle) + angle);
        }
        private CalculateAngleContext CreateCalculateAngleContext(double value)
        {
            var gauge = (RadRadialGauge)this.Owner.OwnerGauge;

            var gaugeLogicalLength  = gauge.MaxValue - gauge.MinValue;
            var gaugePhysicalLength = gauge.MaxAngle - gauge.MinAngle;

            CalculateAngleContext result = new CalculateAngleContext(
                this.Owner.OwnerGauge.MinValue,
                value,
                this.minAngle,
                this.maxAngle,
                gaugeLogicalLength,
                gaugePhysicalLength);

            return(result);
        }