示例#1
0
        private void updateAxisSettingsAndRanges(Axis axis, AxisSettings axisSettings)
        {
            var minValue = axis.GetMinForVisualRange();
            var maxValue = axis.GetMaxForVisualRange();


            axisSettings.Max       = maxValue;
            axisSettings.Min       = minValue;
            axisSettings.AutoRange = axis.VisualRange.Auto;

            // After zoom, there is some strange behaviour around the side margins. When the range is re-applied
            // using SetMinMaxValues, the result is not the same as when first zoom occurred.
            // Easiest way to make the appearance of the chart the same before and after is to apply the zoom range
            // using SetMinMaxValues in the zoom event handler
            axis.VisualRange.SetMinMaxValues(minValue, maxValue);
        }
示例#2
0
        private static void applyAxisZoom(AxisSettings axisSettings, Axis axis)
        {
            if (axisSettings.AutoRange)
            {
                axis.VisualRange.Auto = true;
                return;
            }

            if (!axisSettings.HasRange)
            {
                return;
            }

            axis.VisualRange.Auto = false;
            axis.VisualRange.SetMinMaxValues(axisSettings.Min, axisSettings.Max);
        }
        private int CalculateAxisValue(IntPoint mousePosition, AxisSettings axisSettings)
        {
            switch (axisSettings.MouseAxis)
            {
            case MouseAxis.X:
                return(CalculateAxisValue(mousePosition.X, this._settings.ResolutionX, axisSettings));

            case MouseAxis.Y:
                return(CalculateAxisValue(mousePosition.Y, this._settings.ResolutionY, axisSettings));

            case MouseAxis.None:
                return(this.AxisDisabledValue);

            default:
                this._logger.Log("Invalid MouseAxis");
                return(this.AxisDisabledValue);
            }
        }
示例#4
0
 private void compareAxes(AxisSettings destinationSettings, AxisSettings sourceSettings)
 {
     destinationSettings.Min.ShouldBeEqualTo(sourceSettings.Min);
     destinationSettings.Max.ShouldBeEqualTo(sourceSettings.Max);
     destinationSettings.AutoRange.ShouldBeEqualTo(sourceSettings.AutoRange);
 }
示例#5
0
 public StickSettings()
 {
     Left  = new AxisSettings();
     Right = new AxisSettings();
 }
示例#6
0
 internal void SaveAxisSettings(AxisSettings settings, Axis axis)
 {
     settings.Title     = axis.Title.Text;
     settings.IsVisible = axis.IsVisible;
     settings.Format    = axis.Type.ToString();
 }
示例#7
0
 internal void LoadAxisSettings(AxisSettings settings, Axis axis)
 {
     axis.Title.Text = settings.Title;
     axis.IsVisible  = settings.IsVisible;
     axis.Type       = (AxisType)Enum.Parse(typeof(AxisType), settings.Format);
 }
        // TODO: refactor
        private int CalculateAxisValue(int pixel, int pixelsCount, AxisSettings axisSettings)
        {
            var zoneDistribution = axisSettings.ZoneDistribution;

            var value = (double)pixel / (pixelsCount - 1);

            value *= zoneDistribution.Total;
            var zone = GetZone(value, zoneDistribution);

            switch (zone)
            {
            case Zone.NegativeDead:
                value = 0;
                break;

            case Zone.Negative:
                // value is hard to define
                value -= zoneDistribution.NegativeDeadZoneEnd;
                value /= zoneDistribution.NegativeZone;

                // value is between 0 and 1 (easiest to manipulate)
                switch (axisSettings.NegativeFunctionType)
                {
                case FunctionType.Square:
                    value = Math.Pow(value, 2);
                    break;

                case FunctionType.InvertedSquare:
                    value = Math.Sqrt(value);
                    break;

                case FunctionType.Linear:
                default:
                    break;
                }
                //
                value /= 2;
                // value is between 0 and 0.5
                break;

            case Zone.NeutralDead:
                value = 0.5f;
                break;

            case Zone.Positive:
                // value is hard to define
                value -= zoneDistribution.NeutralDeadZoneEnd;
                value /= zoneDistribution.PositiveZone;

                // value is between 0 and 1 (easiest to manipulate)
                switch (axisSettings.PositiveFunctionType)
                {
                case FunctionType.Square:
                    value = Math.Pow(value, 2);
                    break;

                case FunctionType.InvertedSquare:
                    value = Math.Sqrt(value);
                    break;

                case FunctionType.Linear:
                default:
                    break;
                }
                //
                value /= 2;
                value += 0.5f;
                // value is between 0.5 and 1
                break;

            case Zone.PositiveDead:
                value = 1;
                break;

            default:
                this._logger.Log("Feeder: Invalid Zone");
                break;
            }
            return(Convert.ToInt32(value * this.AxisMaxValue));
        }