Beispiel #1
0
        protected override string GetActualPrecisionString(double value)
        {
            if (base.PrecisionStyle == PrecisionStyle.None)
            {
                return("");
            }
            if (base.PrecisionStyle == PrecisionStyle.FixedDecimalPoints)
            {
                return(Convert2.ToString(base.Precision));
            }
            int num;

            if (this.Style == TextFormatDoubleStyle.Exponent)
            {
                num = base.Precision - 1;
                if (num < 0)
                {
                    num = 0;
                }
                return(Convert2.ToString(num));
            }
            int num2 = (value != 0.0) ? ((int)Math.Log10(Math.Abs(value)) + 1) : 0;

            num = base.Precision - num2;
            if (num < 0)
            {
                num = 0;
            }
            return(Convert2.ToString(num));
        }
Beispiel #2
0
        protected override void SetupObjectBeforeAmbientControlBaseConnection(object value)
        {
            base.SetupObjectBeforeAmbientControlBaseConnection(value);
            PlotObject plotObject = value as PlotObject;

            if (this.BaseName != null && plotObject.Name == Const.EmptyString)
            {
                this.m_InitialSetup = true;
                int num = 0;
                foreach (PlotObject item in this)
                {
                    if (item.Name.ToUpper().StartsWith(this.BaseName.ToUpper()))
                    {
                        string s = item.Name.Substring(this.BaseName.Length);
                        if (double.TryParse(s, NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, (IFormatProvider)CultureInfo.InvariantCulture, out double num2) && (int)num2 > num)
                        {
                            num = (int)num2;
                        }
                    }
                }
                plotObject.Name      = this.BaseName + " " + Convert2.ToString(num + 1);
                plotObject.TitleText = (value as PlotObject).Name;
            }
            else
            {
                this.m_InitialSetup = false;
            }
        }
Beispiel #3
0
        protected virtual string GetActualPrecisionString(double value)
        {
            if (this.PrecisionStyle == PrecisionStyle.None)
            {
                return("");
            }
            if (this.PrecisionStyle == PrecisionStyle.FixedDecimalPoints)
            {
                return(Convert2.ToString(this.Precision));
            }
            int num  = (value != 0.0) ? ((int)Math.Log10(Math.Abs(value)) + 1) : 0;
            int num2 = this.Precision - num;

            if (num2 < 0)
            {
                num2 = 0;
            }
            return(Convert2.ToString(num2));
        }
Beispiel #4
0
        public static string ToString(long value, TextFormatIntegerStyle style, int fixedLength, LeadingStyle leadingStyle)
        {
            long   value2 = (style != 0) ? value : Math.Abs(value);
            string text;

            switch (style)
            {
            case TextFormatIntegerStyle.Binary:
                text = Convert2.ToString(value2, 2);
                goto IL_0048;

            case TextFormatIntegerStyle.Octal:
                text = Convert2.ToString(value2, 8);
                goto IL_0048;

            case TextFormatIntegerStyle.Integer:
                text = Convert2.ToString(value2, 10);
                goto IL_0048;

            case TextFormatIntegerStyle.Hexadecimal:
                text = Convert2.ToString(value2, 16);
                goto IL_0048;

            default:
            {
                return("Not-Supported");
            }
IL_0048:
                text = text.ToUpper(CultureInfo.CurrentCulture);
                if (fixedLength != 0)
                {
                    string value3;
                    if (value < 0L)
                    {
                        switch (style)
                        {
                        case TextFormatIntegerStyle.Binary:
                            value3 = "1";
                            break;

                        case TextFormatIntegerStyle.Octal:
                            value3 = "7";
                            break;

                        case TextFormatIntegerStyle.Integer:
                            value3 = "0";
                            break;

                        case TextFormatIntegerStyle.Hexadecimal:
                            value3 = "F";
                            break;

                        default:
                            value3 = "0";
                            break;
                        }
                    }
                    else
                    {
                        value3 = ((leadingStyle != LeadingStyle.Zeros) ? " " : "0");
                    }
                    if (text.Length > fixedLength)
                    {
                        text = text.Substring(text.Length - fixedLength, fixedLength);
                    }
                    StringBuilder stringBuilder = new StringBuilder(text);
                    for (int i = 0; i < fixedLength - text.Length; i++)
                    {
                        stringBuilder.Insert(0, value3);
                    }
                    text = stringBuilder.ToString();
                }
                if (style == TextFormatIntegerStyle.Integer && value < 0L)
                {
                    text = '-' + text;
                }
                return(text);
            }
        }