예제 #1
0
 public ApplicationPreferences()
 {
     this.currentUnitSystemName = "SI-2";
     this.InitializeCurrentUnitSystem();
     this.numericFormat = NumericFormat.FixedPoint;
     this.decimalPlaces = "3";
 }
예제 #2
0
        private static IGridLabel CreateMixedFontGridLabel()
        {
            IMixedFontGridLabel mixedFontGridLabelClass = new MixedFontGridLabel() as IMixedFontGridLabel;
            IGridLabel          gridLabel    = mixedFontGridLabelClass as IGridLabel;
            IFontDisp           stdFontClass = new StdFont() as IFontDisp;

            stdFontClass.Name     = "Arial";
            stdFontClass.Size     = new decimal(16);
            gridLabel.Font        = stdFontClass;
            gridLabel.Color       = CartoHelper.BuildRGB(0, 0, 0);
            gridLabel.LabelOffset = 2;
            gridLabel.LabelAlignment[esriGridAxisEnum.esriGridAxisLeft]  = false;
            gridLabel.LabelAlignment[esriGridAxisEnum.esriGridAxisRight] = false;
            stdFontClass      = new StdFont() as IFontDisp;
            stdFontClass.Name = "Arial";
            stdFontClass.Size = new decimal(12);
            mixedFontGridLabelClass.SecondaryFont    = stdFontClass;
            mixedFontGridLabelClass.SecondaryColor   = CartoHelper.BuildRGB(0, 0, 0);
            mixedFontGridLabelClass.NumGroupedDigits = 6;
            IFormattedGridLabel formattedGridLabel = mixedFontGridLabelClass as IFormattedGridLabel;
            INumericFormat      format             = new NumericFormat() as INumericFormat;

            format.AlignmentOption = esriNumericAlignmentEnum.esriAlignRight;
            format.RoundingOption  = esriRoundingOptionEnum.esriRoundNumberOfDecimals;
            format.RoundingValue   = 2;
            format.ShowPlusSign    = true;
            format.UseSeparator    = false;
            format.ZeroPad         = true;
            INumericFormat numericFormatClass = format as INumericFormat;

            formattedGridLabel.Format = numericFormatClass as INumberFormat;
            return(gridLabel);
        }
예제 #3
0
        public static string ToFormattedString(this ushort input, [NotNull] NumericFormat format)
        {
            if (format == NumericFormat.RoundTrip)
            {
                ExceptionThrower.ThrowArgumentInvalidException("Invalid number format.", nameof(format));
            }

            return(input.ToString(format.DisplayName, CultureInfo.CurrentCulture));
        }
예제 #4
0
        public static string ToFormattedString(this double input, [NotNull] NumericFormat format)
        {
            if (format == NumericFormat.Decimal || format == NumericFormat.Hexadecimal)
            {
                ExceptionThrower.ThrowArgumentInvalidException("Invalid number format.", nameof(format));
            }

            return(input.ToString(format.DisplayName, CultureInfo.CurrentCulture));
        }
예제 #5
0
        private Series CreateLineSeries(string seriesName, NumericFormat format)
        {
            LineSeriesView lineView   = new LineSeriesView();
            Series         lineSeries = new Series();

            lineSeries.Name         = seriesName;
            lineSeries.ShowInLegend = true;
            lineSeries.View         = lineView;
            lineSeries.Label.PointOptions.ValueNumericOptions.Format = format;
            return(lineSeries);
        }
예제 #6
0
        public virtual void SetObjectData(SerializationInfo info, StreamingContext context)
        {
            int persistedClassVersion = (int)info.GetValue("ClassPersistenceVersionMainNumericFormat", typeof(int));

            switch (persistedClassVersion)
            {
            case 1:
                this.decimalPlaces = (string)info.GetValue("DecimalPlaces", typeof(string));
                this.numericFormat = (NumericFormat)info.GetValue("NumericFormat", typeof(NumericFormat));
                break;
            }
        }
예제 #7
0
 /// <summary>
 /// 饼状Series设置成百分比显示
 /// </summary>
 /// <param name="series">SeriesBase</param>
 /// <param name="valueLegendType">Series对应Lengend显示类型</param>
 /// <param name="lengendPointView">Series对应Lengend PointView类型</param>
 public static void SetPiePercentage(this SeriesBase series, NumericFormat valueLegendType, PointView lengendPointView)
 {
     if (series.View is PieSeriesView || series.View is Pie3DSeriesView)
     {
         PiePointOptions _piePointOptions = (PiePointOptions)series.Label.PointOptions;
         if (_piePointOptions != null)
         {
             _piePointOptions.PercentOptions.ValueAsPercent       = true;
             _piePointOptions.ValueNumericOptions.Format          = NumericFormat.Percent;
             _piePointOptions.ValueNumericOptions.Precision       = 0;
             series.LegendPointOptions.ValueNumericOptions.Format = valueLegendType;
             series.LegendPointOptions.PointView = lengendPointView;
         }
     }
 }
예제 #8
0
        private void WriteArray(IReadOnlyList <double> array, StreamWriter writer, bool writeArrayLengthFirst)
        {
            if (writeArrayLengthFirst)
            {
                writer.WriteLine(array.Count);
            }
            string numberFormat = NumericFormat.GetRealNumberFormat();
            int    last         = array.Count - 1;

            for (int i = 0; i < last; ++i)
            {
                writer.Write(string.Format(numberFormat, array[i]) + EntrySeparator);
            }
            writer.Write(array[last]);
        }
        public static void Run()
        {
            //ExStart: SpecifyWktVariantOnTranslation
            Point point = new Point(23.5732, 25.3421)
            {
                M = 40.3
            };

            point.SpatialReferenceSystem = SpatialReferenceSystem.Wgs84;

            Console.WriteLine(point.AsText(WktVariant.Iso));                         // POINT M (23.5732, 25.3421, 40.3)
            Console.WriteLine(point.AsText(WktVariant.SimpleFeatureAccessOutdated)); // POINT (23.5732, 25.3421)
            Console.WriteLine(point.AsText(WktVariant.ExtendedPostGis));             // SRID=4326;POINTM (23.5732, 25.3421, 40.3)

            // to get max a decimal precision
            Console.WriteLine("G17  : " + point.AsText(WktVariant.Iso, NumericFormat.General(17))); // POINT M (23.5732 25.342099999999999 40.299999999999997)
            Console.WriteLine("R    : " + point.AsText(WktVariant.Iso, NumericFormat.RoundTrip));   // POINT M (23.5732 25.3421 40.3)
            // to trim a decimal precision
            Console.WriteLine("G3   : " + point.AsText(WktVariant.Iso, NumericFormat.General(3)));  // POINT M (23.6 25.3 40.3)
            Console.WriteLine("Flat3: " + point.AsText(WktVariant.Iso, NumericFormat.Flat(3)));     // POINT M (23.573 25.342 40.3)
            //ExEnd: SpecifyWktVariantOnTranslation
        }
예제 #10
0
        public void ApplyFormat(IXLCell cell, object column, bool formatWithEuros = false)
        {
            BooleanFormat booleanFormat = new BooleanFormat();

            booleanFormat.SetFormat(cell, column, _configurationDataFormat);
            NumericFormat numericaFormat = new NumericFormat();

            if (formatWithEuros)
            {
                _configurationDataFormat.NumericFormat = "0.00 €";
            }
            else
            {
                _configurationDataFormat.NumericFormat = "0.00";
            }

            numericaFormat.SetFormat(cell, column, _configurationDataFormat);
            DateTimeFormat datetimeFormat = new DateTimeFormat();

            datetimeFormat.SetFormat(cell, column, _configurationDataFormat);
            TextFormat textFormat = new TextFormat();

            textFormat.SetFormat(cell, column, _configurationDataFormat);
        }
예제 #11
0
    /// <summary>
    /// Converts a numeric string into its coresponding double value,
    /// </summary>
    /// <param name="value">String containing the numeric value.</param>
    /// <param name="fromBase">The numeric base in which the string is represented. Only Decimal and Hexadecimal are supported. </param>
    /// <param name="decimalSeparator"></param>
    /// <returns>The numeric value of the string</returns>
    public static double ToDouble(this String value, NumericFormat fromBase = NumericFormat.Decimal, string decimalSeparator = null)
    {
        switch (fromBase)
        {
        case NumericFormat.Decimal:
            return(Convert.ToDouble(value.Replace(
                                        decimalSeparator ?? ".", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator)));


        //var provider = new NumberFormatInfo();
        //provider.NumberDecimalSeparator = decimalSeparator ?? CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
        //return Convert.ToDouble(value, provider);
        case NumericFormat.Hexadecimal:
            var b = new byte[value.Length / 2];
            for (int i = (value.Length - 2), j = 0; i >= 0; i -= 2, j++)
            {
                b[j] = byte.Parse(value.Substring(i, 2), NumberStyles.HexNumber);
            }
            return(BitConverter.ToDouble(b, 0));

        default:
            throw Api.Create.Exception("Unexpected value for base: '{0}'", fromBase);
        }
    }
        private Series CreateSeries(DataTable dt, DevExpress.XtraCharts.ViewType viewType, NumericFormat format)
        {
            Series series = new Series("Serices1 ", viewType);

            series.DataSource         = dt;
            series.ArgumentScaleType  = ScaleType.Qualitative;
            series.ArgumentDataMember = "argument";
            series.ValueScaleType     = ScaleType.Numerical;
            series.ValueDataMembers.AddRange(new string[] { "datavalue" });
            series.PointOptions.PointView = PointView.ArgumentAndValues;
            series.PointOptions.ValueNumericOptions.Format = format;
            if (format == NumericFormat.Number)
            {
                //series.PointOptions.ValueNumericOptions.Precision = 0;
            }
            series.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;//显示标注标签

            return(series);
        }
예제 #13
0
 public static void SetOnlyNumeric(TextBox element, NumericFormat value) =>
 element.SetValue(OnlyNumericProperty, value);
예제 #14
0
 public void AssignReferences(IEnumerable <ReferenceXml> references)
 {
     NumericFormat.AssignReferences(references);
     CurrencyFormat.AssignReferences(references);
 }
예제 #15
0
 protected void SetNumericOptions(Series series, NumericFormat format, int precision) {
     series.PointOptions.ValueNumericOptions.Format = format;
     series.PointOptions.ValueNumericOptions.Precision = precision;
 }
예제 #16
0
 protected void SetNumericOptions(Series series, NumericFormat format, int precision)
 {
     series.PointOptions.ValueNumericOptions.Format    = format;
     series.PointOptions.ValueNumericOptions.Precision = precision;
 }
예제 #17
0
 public FlowsheetPreferences(Flowsheet flowsheet)
 {
     this.currentUnitSystemName = flowsheet.CurrentUnitSystemName;
     this.numericFormat         = flowsheet.NumericFormat;
     this.decimalPlaces         = flowsheet.DecimalPlaces;
 }