public IAxis Convert(IDataObject data)
        {
            var axis = new ForegroundLinearAxis();
            if (data == null) return axis;

            var orientation = AxisOrientation.None;
            if (data[AxisDataConstants.Orientation] != null)
                Enum.TryParse<AxisOrientation>(data[AxisDataConstants.Orientation] as string, out orientation);

            int minimum = 0;
            if (data[AxisDataConstants.Minimum] != null)
                int.TryParse(data[AxisDataConstants.Minimum].ToString(), NumberStyles.Integer, CultureInfo.CurrentCulture, out minimum);

            int maximum = 0;
            if (data[AxisDataConstants.Maximum] != null)
                int.TryParse(data[AxisDataConstants.Maximum].ToString(), NumberStyles.Integer, CultureInfo.CurrentCulture, out maximum);

            int interval = int.MinValue;
            if (data[AxisDataConstants.Interval] != null)
                int.TryParse(data[AxisDataConstants.Interval].ToString(), NumberStyles.Integer, CultureInfo.CurrentCulture, out interval);

            bool autoCalculate = true;
            if (data[AxisDataConstants.AutoCalculate] != null)
                bool.TryParse(data[AxisDataConstants.AutoCalculate].ToString(), out autoCalculate);

            axis.Title = data[AxisDataConstants.Title];
            axis.Orientation = orientation;
            // What's the difference if it's foreground or not if you won't show them? :)
            axis.ShowGridLines = true;
            if (autoCalculate) {
                axis.Interval = null;
                // Only maximum and interval values are auto calculated
                axis.Minimum = minimum;
                axis.Maximum = null;
            } else {
                if (interval <= 0) {
                    axis.Interval = null;
                } else {
                    axis.Interval = interval;
                }

                axis.Minimum = minimum;
                if (minimum == maximum) {
                    axis.Maximum = interval > 0 ? minimum + interval : minimum + 1;
                } else {
                    axis.Maximum = maximum;
                }
            }

            return axis;
        }
示例#2
0
        public IAxis Convert(IDataObject data)
        {
            var axis = new ForegroundLinearAxis();

            if (data == null)
            {
                return(axis);
            }

            var orientation = AxisOrientation.None;

            if (data[AxisDataConstants.Orientation] != null)
            {
                Enum.TryParse <AxisOrientation>(data[AxisDataConstants.Orientation] as string, out orientation);
            }

            int minimum = 0;

            if (data[AxisDataConstants.Minimum] != null)
            {
                int.TryParse(data[AxisDataConstants.Minimum].ToString(), NumberStyles.Integer, CultureInfo.CurrentCulture, out minimum);
            }

            int maximum = 0;

            if (data[AxisDataConstants.Maximum] != null)
            {
                int.TryParse(data[AxisDataConstants.Maximum].ToString(), NumberStyles.Integer, CultureInfo.CurrentCulture, out maximum);
            }

            int interval = int.MinValue;

            if (data[AxisDataConstants.Interval] != null)
            {
                int.TryParse(data[AxisDataConstants.Interval].ToString(), NumberStyles.Integer, CultureInfo.CurrentCulture, out interval);
            }

            bool autoCalculate = true;

            if (data[AxisDataConstants.AutoCalculate] != null)
            {
                bool.TryParse(data[AxisDataConstants.AutoCalculate].ToString(), out autoCalculate);
            }

            axis.Title       = data[AxisDataConstants.Title];
            axis.Orientation = orientation;
            // What's the difference if it's foreground or not if you won't show them? :)
            axis.ShowGridLines = true;
            if (autoCalculate)
            {
                axis.Interval = null;
                // Only maximum and interval values are auto calculated
                axis.Minimum = minimum;
                axis.Maximum = null;
            }
            else
            {
                if (interval <= 0)
                {
                    axis.Interval = null;
                }
                else
                {
                    axis.Interval = interval;
                }

                axis.Minimum = minimum;
                if (minimum == maximum)
                {
                    axis.Maximum = interval > 0 ? minimum + interval : minimum + 1;
                }
                else
                {
                    axis.Maximum = maximum;
                }
            }

            return(axis);
        }