GetNumberOfDecimalsForMinimumDifference() static private method

static private GetNumberOfDecimalsForMinimumDifference ( double minDifference ) : int
minDifference double
return int
示例#1
0
        public string FormatTime(float time, float frameRate, TimeFormat timeFormat)
        {
            if (timeFormat == TimeFormat.None)
            {
                int numberOfDecimalsForMinimumDifference;
                if (frameRate != 0f)
                {
                    numberOfDecimalsForMinimumDifference = MathUtils.GetNumberOfDecimalsForMinimumDifference((float)(1f / frameRate));
                }
                else
                {
                    numberOfDecimalsForMinimumDifference = MathUtils.GetNumberOfDecimalsForMinimumDifference((float)(base.shownArea.width / base.drawRect.width));
                }
                return(time.ToString("N" + numberOfDecimalsForMinimumDifference));
            }
            int num2 = Mathf.RoundToInt(time * frameRate);

            if (timeFormat == TimeFormat.TimeFrame)
            {
                int    num4   = (int)frameRate;
                int    length = num4.ToString().Length;
                string str2   = string.Empty;
                if (num2 < 0)
                {
                    str2 = "-";
                    num2 = -num2;
                }
                int   num5 = num2 / ((int)frameRate);
                float num6 = ((float)num2) % frameRate;
                return(str2 + num5.ToString() + ":" + num6.ToString().PadLeft(length, '0'));
            }
            return(num2.ToString());
        }
示例#2
0
 internal static double RoundBasedOnMinimumDifference(double valueToRound, double minDifference)
 {
     if (minDifference == 0.0)
     {
         return(MathUtils.DiscardLeastSignificantDecimal(valueToRound));
     }
     return(Math.Round(valueToRound, MathUtils.GetNumberOfDecimalsForMinimumDifference(minDifference), MidpointRounding.AwayFromZero));
 }
示例#3
0
        internal static float RoundBasedOnMinimumDifference(float valueToRound, float minDifference)
        {
            float result;

            if (minDifference == 0f)
            {
                result = MathUtils.DiscardLeastSignificantDecimal(valueToRound);
            }
            else
            {
                result = (float)Math.Round((double)valueToRound, MathUtils.GetNumberOfDecimalsForMinimumDifference(minDifference), MidpointRounding.AwayFromZero);
            }
            return(result);
        }
示例#4
0
        private static string ConvertTexelWorldSizeToString(float texelWorldSize)
        {
            if (texelWorldSize == -1f)
            {
                return("Always Full Size");
            }
            if (texelWorldSize == 0f)
            {
                return("Hide All Icons");
            }
            float num = texelWorldSize * 32f;
            int   numberOfDecimalsForMinimumDifference = MathUtils.GetNumberOfDecimalsForMinimumDifference((float)(num * 0.1f));

            return(num.ToString("N" + numberOfDecimalsForMinimumDifference));
        }
        static string ConvertTexelWorldSizeToString(float texelWorldSize)
        {
            if (texelWorldSize == -1.0f)
            {
                return(kAlwaysFullSizeText);
            }
            if (texelWorldSize == 0.0f)
            {
                return(kHideAllIconsText);
            }

            float displaySize = texelWorldSize * 32.0f; // The 32 is default icon size, so we show worldsize for 32 pixel icons.
            int   numDecimals = MathUtils.GetNumberOfDecimalsForMinimumDifference(displaySize * 0.1f);

            return(displaySize.ToString("N" + numDecimals));
        }
        private static string ConvertTexelWorldSizeToString(float texelWorldSize)
        {
            string result;

            if (texelWorldSize == -1f)
            {
                result = "Always Full Size";
            }
            else if (texelWorldSize == 0f)
            {
                result = "Hide All Icons";
            }
            else
            {
                float num = texelWorldSize * 32f;
                int   numberOfDecimalsForMinimumDifference = MathUtils.GetNumberOfDecimalsForMinimumDifference(num * 0.1f);
                result = num.ToString("N" + numberOfDecimalsForMinimumDifference);
            }
            return(result);
        }
示例#7
0
        public string FormatTime(float time, float frameRate, TimeArea.TimeFormat timeFormat)
        {
            string result;

            if (timeFormat == TimeArea.TimeFormat.None)
            {
                int numberOfDecimalsForMinimumDifference;
                if (frameRate != 0f)
                {
                    numberOfDecimalsForMinimumDifference = MathUtils.GetNumberOfDecimalsForMinimumDifference(1f / frameRate);
                }
                else
                {
                    numberOfDecimalsForMinimumDifference = MathUtils.GetNumberOfDecimalsForMinimumDifference(base.shownArea.width / base.drawRect.width);
                }
                result = time.ToString("N" + numberOfDecimalsForMinimumDifference);
            }
            else
            {
                int num = Mathf.RoundToInt(time * frameRate);
                if (timeFormat == TimeArea.TimeFormat.TimeFrame)
                {
                    int    length = ((int)frameRate).ToString().Length;
                    string str    = string.Empty;
                    if (num < 0)
                    {
                        str = "-";
                        num = -num;
                    }
                    result = str + (num / (int)frameRate).ToString() + ":" + ((float)num % frameRate).ToString().PadLeft(length, '0');
                }
                else
                {
                    result = num.ToString();
                }
            }
            return(result);
        }
示例#8
0
        public string FormatTime(float time, float frameRate, TimeFormat timeFormat)
        {
            if (timeFormat == TimeFormat.None)
            {
                int hDecimals;
                if (frameRate != 0)
                {
                    hDecimals = MathUtils.GetNumberOfDecimalsForMinimumDifference(1 / frameRate);
                }
                else
                {
                    hDecimals = MathUtils.GetNumberOfDecimalsForMinimumDifference(shownArea.width / drawRect.width);
                }

                return(time.ToString("N" + hDecimals));
            }

            int frame = Mathf.RoundToInt(time * frameRate);

            if (timeFormat == TimeFormat.TimeFrame)
            {
                int    frameDigits = frameRate != 0 ? ((int)frameRate - 1).ToString().Length : 1;
                string sign        = string.Empty;
                if (frame < 0)
                {
                    sign  = "-";
                    frame = -frame;
                }
                return(sign + (frame / (int)frameRate).ToString() + ":" +
                       (frame % frameRate).ToString().PadLeft(frameDigits, '0'));
            }
            else
            {
                return(frame.ToString());
            }
        }
示例#9
0
        public string FormatValue(float value)
        {
            int vDecimals = MathUtils.GetNumberOfDecimalsForMinimumDifference(shownArea.height / drawRect.height);

            return(value.ToString("N" + vDecimals));
        }
示例#10
0
        public string FormatValue(float value)
        {
            int numberOfDecimalsForMinimumDifference = MathUtils.GetNumberOfDecimalsForMinimumDifference(base.shownArea.height / base.drawRect.height);

            return(value.ToString("N" + numberOfDecimalsForMinimumDifference));
        }