public static string CalculaCuotaSinInteres(string primatotal, string num_cuotas) { System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo(); nfi.NumberGroupSeparator = ","; DataRow cuotas = ValorCuotaSinInteres(primatotal, num_cuotas); decimal cuota_minima = Convert.ToDecimal(ConfigurationManager.AppSettings["CuotaMinima"].ToString().Replace(",", "."), nfi); decimal cuota = Convert.ToDecimal(cuotas["P_VALOR_CUOTA"].ToString().Replace(",", "."), nfi); string valcuota; if (cuota < cuota_minima) { valcuota = "---"; } else { valcuota = cuotas["P_VALOR_CUOTA"].ToString(); } return(valcuota); }
public static string CalculaCuota(string primatotal, string tip_cuota, string num_cuotas, string descuento, string cod_ramo, string dia_pago) { System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo(); nfi.NumberGroupSeparator = ","; decimal primatotal_d = Convert.ToDecimal(primatotal.Replace(",", "."), nfi); decimal descuento_d = Convert.ToDecimal(descuento.Replace(",", "."), nfi); DataRow cuotas = ValorCuota(primatotal_d, tip_cuota, num_cuotas, descuento_d, cod_ramo, dia_pago); decimal cuota_minima = Convert.ToDecimal(ConfigurationManager.AppSettings["CuotaMinima"].ToString().Replace(",", "."), nfi); decimal cuota = Convert.ToDecimal(cuotas["P_VALOR_CUOTA"].ToString().Replace(",", "."), nfi); string valcuota; if (cuota < cuota_minima) { valcuota = "---"; } else { valcuota = cuotas["P_VALOR_CUOTA"].ToString(); } return(valcuota); }
private TextNumberFormat(TextNumberFormat.formatTypes theType, int digits) { this.numberFormat = System.Globalization.NumberFormatInfo.CurrentInfo; this.numberFormatType = (int)theType; this.groupingActivated = true; this.separator = this.GetSeparator( (int)theType ); this.digits = digits; }
/// <summary> /// Generate The Reputation Bar for the user /// </summary> /// <param name="points"> /// The points. /// </param> /// <param name="userId"> /// The user id. /// </param> /// <returns> /// Returns the Html String /// </returns> public static string GenerateReputationBar([NotNull] int points, [NotNull] int userId) { var formatInfo = new NumberFormatInfo { NumberDecimalSeparator = "." }; var percentage = ConvertPointsToPercentage(points); var pointsSign = string.Empty; if (points > 0) { pointsSign = "+"; } else if (points < 0) { pointsSign = "-"; } return @"<div class=""text-xs-center"">{1}</div> <progress class=""progress progress-striped{2}"" value=""{0}"" max=""100"" aria-describedby=""{3}{4}""> <div class=""progress""> <span class=""progress-bar"" style=""width:25%;""></style> </div>" .FormatWith( percentage.ToString(formatInfo), GetReputationBarText(percentage), GetReputationBarColor(percentage), pointsSign, points); }
/// <param name="typeCode">The <see cref="TypeCode"/> that this <see cref="NumberConversionRule"/> attempts to convert to.</param> public NumberConversionRule(TypeCode typeCode) : base(TypePointers.StringType) { if ((typeCode == TypeCode.String) || (typeCode == TypeCode.DateTime)) { throw new ArgumentException("datatype cannot be String or DateTime.", "typeCode"); } TypeCode = typeCode; numberFormatInfo = NumberFormatInfo.CurrentInfo; switch (typeCode) { case TypeCode.Decimal: NumberStyles = NumberStyles.Number; break; case TypeCode.Double: case TypeCode.Single: NumberStyles = NumberStyles.Float | NumberStyles.AllowThousands; break; case TypeCode.Byte: case TypeCode.SByte: case TypeCode.Int16: case TypeCode.UInt16: case TypeCode.Int32: case TypeCode.UInt32: case TypeCode.Int64: case TypeCode.UInt64: NumberStyles = NumberStyles.Integer; break; } }
static StringBuilderExtensions() { if (m_numberFormatInfoHelper == null) { m_numberFormatInfoHelper = CultureInfo.InvariantCulture.NumberFormat.Clone() as NumberFormatInfo; } }
public static float FromObject (Object Value, NumberFormatInfo NumberFormat) { #if !ECMA_COMPAT if(Value != null) { IConvertible ic = (Value as IConvertible); if(ic != null) { if(ic.GetTypeCode() != TypeCode.String) { return ic.ToSingle(NumberFormat); } else { return FromString(ic.ToString(null), NumberFormat); } } else { throw new InvalidCastException (String.Format (S._("VB_InvalidCast"), Value.GetType(), "System.Single")); } } else { return 0.0f; } #else return (float)(DoubleType.FromObject(Value, NumberFormat)); #endif }
private void writeOptionsFile(int graphWidth, int graphHeight) { string scriptsPath = UtilEncoder.GetSprintPath(); if (UtilAll.IsWindows()) { scriptsPath = scriptsPath.Replace("\\", "/"); } System.Globalization.NumberFormatInfo localeInfo = new System.Globalization.NumberFormatInfo(); localeInfo = System.Globalization.NumberFormatInfo.CurrentInfo; string scriptOptions = "#scriptsPath\n" + UtilEncoder.GetScriptsPath() + "\n" + "#filename\n" + UtilEncoder.GetRaceAnalyzerCSVFileName() + "\n" + "#mass\n" + Util.ConvertToPoint(mass) + "\n" + "#personHeight\n" + Util.ConvertToPoint(personHeight / 100.0) + "\n" + //send it in meters "#tempC\n" + tempC + "\n" + "#testLength\n" + testLength.ToString() + "\n" + "#os\n" + UtilEncoder.OperatingSystemForRGraphs() + "\n" + "#graphWidth\n" + graphWidth.ToString() + "\n" + "#graphHeight\n" + graphHeight.ToString(); TextWriter writer = File.CreateText(Path.GetTempPath() + "Roptions.txt"); writer.Write(scriptOptions); writer.Flush(); writer.Close(); ((IDisposable)writer).Dispose(); }
public static decimal PrimaExenta(string cod_modalidad, string cod_ramo) { DataRow prima_exenta = null; Vehiculo_DB objdb = new Vehiculo_DB(); try { using (OracleConnection Conexion = MConexion.getConexion("OVDES")) { prima_exenta = objdb.PrimaExenta_DB(cod_modalidad, cod_ramo, Conexion); System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo(); nfi.NumberGroupSeparator = ","; return(Convert.ToDecimal(prima_exenta["p_monto_exenta"].ToString(), nfi)); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static float ToFloat(string s) { NumberFormatInfo _NumberFormatInfo = new NumberFormatInfo(); _NumberFormatInfo.NumberDecimalSeparator = "."; return float.Parse(s,_NumberFormatInfo); }
// CONSTRUCTORS public TextNumberFormat() { this.numberFormat = new System.Globalization.NumberFormatInfo(); this.numberFormatType = (int)TextNumberFormat.formatTypes.General; this.groupingActivated = true; this.separator = this.GetSeparator( (int)TextNumberFormat.formatTypes.General ); this.digits = 3; }
private TextNumberFormat(TextNumberFormat.formatTypes theType, System.Globalization.CultureInfo cultureNumberFormat, int digits) { this.numberFormat = cultureNumberFormat.NumberFormat; this.numberFormatType = (int)theType; this.groupingActivated = true; this.separator = this.GetSeparator( (int)theType ); this.digits = digits; }
static TicksGenerator() { //2013-11-12 13:00 var data = new string[] { "USDCHF;4;0.9197", "GBPUSD;4;1.5880", "EURUSD;4;1.3403", "USDJPY;2;99.73", "EURCHF;4;1.2324", "AUDBGN;4;1.3596", "AUDCHF;4;0.8567", "AUDJPY;2;92.96", "BGNJPY;2;68.31", "BGNUSD;4;0.6848", "CADBGN;4;1.3901", "CADCHF;4;0.8759", "CADUSD;4;0.9527", "CHFBGN;4;1.5862", "CHFJPY;2;108.44", "CHFUSD;4;1.0875", "EURAUD;4;1.4375", "EURCAD;4;1.4064", "EURGBP;4;0.8438", "EURJPY;4;133.66", "GBPAUD;4;1.7031", "GBPBGN;4;2.3169", "GBPCAD;4;1.6661", "GBPCHF;4;1.4603", "GBPJPY;2;158.37", "NZDUSD;4;0.8217", "USDBGN;4;1.4594", "USDCAD;4;1.0493", "XAUUSD;2;1281.15", "XAGUSD;2;21.21", "$DAX;2;9078.20","$FTSE;2;6707.49","$NASDAQ;2;3361.02","$SP500;2;1771.32"}; symbols = new string[data.Length]; digits = new int[data.Length]; pipsizes = new double[data.Length]; prices = new double[data.Length]; providers = new string[] { "eSignal", "Gain", "NYSE", "TSE", "NASDAQ", "Euronext", "LSE", "SSE", "ASE", "SE", "NSEI" }; var format = new NumberFormatInfo(); format.NumberDecimalSeparator = "."; for (int i = 0; i < data.Length; i++) { var tokens = data[i].Split(';'); //symbol;digits;price symbols[i] = tokens[0]; digits[i] = Int32.Parse(tokens[1]); pipsizes[i] = Math.Round(Math.Pow(10, -digits[i]), digits[i]); prices[i] = Math.Round(Double.Parse(tokens[2], format), digits[i]); } }
private static void FindCurrency(ref int pos, string s, NumberFormatInfo nfi, ref bool foundCurrency) { if ((pos + nfi.CurrencySymbol.Length) <= s.Length && s.Substring(pos, nfi.CurrencySymbol.Length) == nfi.CurrencySymbol) { foundCurrency = true; pos += nfi.CurrencySymbol.Length; } }
/// <summary> /// Возвращает число в виде строки с проблеами, с проблеами, /// разделяющими группы по три цифры /// </summary> /// <param name="num"></param> /// <returns></returns> public static string ToStringWithDelimiters(this double num) { var nfi = new NumberFormatInfo { NumberGroupSeparator = " ", NumberDecimalDigits = 0 }; nfi.NumberGroupSeparator = " "; return num.ToString("n", nfi); }
private NumberFormatInfo GetNumberFormat1() { NumberFormatInfo format = new NumberFormatInfo(); format.NaNSymbol = "NaN"; format.PositiveSign = "+"; format.NegativeSign = "-"; format.PerMilleSymbol = "x"; format.PositiveInfinitySymbol = "Infinity"; format.NegativeInfinitySymbol = "-Infinity"; format.NumberDecimalDigits = 5; format.NumberDecimalSeparator = ","; format.NumberGroupSeparator = "."; format.NumberGroupSizes = new int[] {3}; format.NumberNegativePattern = 2; format.CurrencyDecimalDigits = 2; format.CurrencyDecimalSeparator = ","; format.CurrencyGroupSeparator = "."; format.CurrencyGroupSizes = new int[] {3}; format.CurrencyNegativePattern = 8; format.CurrencyPositivePattern = 3; format.CurrencySymbol = "EUR"; format.PercentDecimalDigits = 5; format.PercentDecimalSeparator = ","; format.PercentGroupSeparator = "."; format.PercentGroupSizes = new int[] {3}; format.PercentNegativePattern = 0; format.PercentPositivePattern = 0; format.PercentSymbol = "%"; return format; }
internal DecimalFormat(NumberFormatInfo info, char digit, char zeroDigit, char patternSeparator) { this.info = info; this.digit = digit; this.zeroDigit = zeroDigit; this.patternSeparator = patternSeparator; }
/// <summary> /// 把价格精确至小数点两位 /// </summary> /// <param name="dPrice">价格</param> /// <returns>返回值</returns> public static string TransformPrice(double dPrice) { double d = dPrice; var myNfi = new NumberFormatInfo { NumberNegativePattern = 2 }; string s = d.ToString("N", myNfi); return s; }
private void ProcessLine (string testLine, NumberFormatInfo nfi) { string number = "0"; string format = "X"; string expected = "XXX"; int idxStart; int idxEnd; idxStart = testLine.IndexOf ('('); if (idxStart != -1){ idxStart++; idxEnd = testLine.IndexOf (')'); number = testLine.Substring (idxStart, idxEnd - idxStart); } idxStart = testLine.IndexOf ('(', idxStart); if (idxStart != -1) { idxStart++; idxEnd = testLine.IndexOf (')', idxStart); format = testLine.Substring (idxStart, idxEnd - idxStart); } idxStart = testLine.IndexOf ('(', idxStart); if (idxStart != -1) { idxStart++; idxEnd = testLine.LastIndexOf (')'); expected = testLine.Substring (idxStart, idxEnd - idxStart); } DoTest (number, format, expected, nfi); }
public override void SetUp() { base.SetUp(); Dir = NewDirectory(); RandomIndexWriter writer = new RandomIndexWriter(Random(), Dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMaxBufferedDocs(TestUtil.NextInt(Random(), 50, 1000))); Document doc = new Document(); Field field = NewStringField("field", "", Field.Store.NO); doc.Add(field); NumberFormatInfo df = new NumberFormatInfo(); df.NumberDecimalDigits = 0; //NumberFormat df = new DecimalFormat("000", new DecimalFormatSymbols(Locale.ROOT)); for (int i = 0; i < 1000; i++) { field.StringValue = i.ToString(df); writer.AddDocument(doc); } Reader = writer.Reader; Searcher = NewSearcher(Reader); writer.Dispose(); if (VERBOSE) { Console.WriteLine("TEST: setUp searcher=" + Searcher); } }
public void TestSetValue() { string testStr = "testStr"; NumberFormatInfo nfi = new NumberFormatInfo(); nfi.CurrencyDecimalSeparator = testStr; Assert.Equal(testStr, nfi.CurrencyDecimalSeparator); }
/// <summary> /// Initialize a new instance of FrameRateCounter /// </summary> /// <param name="game">The game</param> public FrameRateCounter(Game game) : base(game) { format = new NumberFormatInfo(); format.NumberDecimalSeparator = "."; position = new Vector2(5, 5); }
private static NumberFormatInfo initFormat() { NumberFormatInfo format = new System.Globalization.NumberFormatInfo(); format.NumberDecimalSeparator = "."; format.NumberGroupSeparator = ","; return format; }
internal static int WriteCalibrationGroup(ADatabase db, int average, double firmware, string serial) { try { NumberFormatInfo formatInfo = new NumberFormatInfo(); formatInfo.NumberDecimalSeparator = "."; string sql = "INSERT INTO CalibrationGroup (NumOfAverage, Datetime, SensorSerial, SensorFirmware) VALUES (" + average.ToString() + ",'" + DateTime.Now.ToString("dd.MM.yy HH:mm:ss.ff") + "', '" + serial + "', " + firmware.ToString(formatInfo) + ")"; NpgsqlCommand command = new NpgsqlCommand(sql, db.Connection); command.ExecuteNonQuery(); sql = "SELECT currval(pg_get_serial_sequence('CalibrationGroup', 'calibrationgroupid'));"; command = new NpgsqlCommand(sql, db.Connection); NpgsqlDataReader myreader = command.ExecuteReader(); if (myreader.Read()) { int result = Convert.ToInt32(myreader[0].ToString()); myreader.Close(); return result; } else { myreader.Close(); return -1; } } catch (Exception ex) { FileWorker.WriteEventFile(DateTime.Now, "ACalibrationDatabaseWorker", "WriteCalibrationGroup", ex.Message); return -1; } }
public List<OnibusBO> getOnibus() { List<OnibusBO> lstOnibus = new List<OnibusBO>(); string path = AppDomain.CurrentDomain.BaseDirectory.ToString() + @"csv"; string nomeArquivo = "arquivo.csv"; string pathCompleto = path + "\\" + nomeArquivo; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } DataSet ds = getDadosFromCSV(pathCompleto); if (ds.Tables.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { NumberFormatInfo provider = new NumberFormatInfo(); provider.NumberDecimalSeparator = ","; provider.NumberGroupSeparator = "."; OnibusBO onibus = new OnibusBO(); onibus.DataHora = Convert.ToDateTime(dr["dataHora"]); onibus.Latitude = Convert.ToDouble(dr["Latitude"].ToString().Replace(".", ","), provider); onibus.Longitude = Convert.ToDouble(dr["Longitude"].ToString().Replace(".", ","), provider); onibus.Ordem = dr["ordem"].ToString(); onibus.Velocidade = Convert.ToInt32(dr["Velocidade"].ToString() == "" ? 0 : dr["Velocidade"]); onibus.Linha = dr["linha"].ToString(); lstOnibus.Add(onibus); } } return lstOnibus; }
public static float ParseFloatStr(string str) { float single1; if ((str == null) || (str == string.Empty)) { return 0f; } str = str.Trim(); NumberFormatInfo info1 = new NumberFormatInfo(); info1.NumberDecimalSeparator = "."; try { bool flag1 = false; if (str.EndsWith("%")) { str = str.Substring(0, str.Length - 1); flag1 = true; } single1 = float.Parse(str, NumberStyles.Any, info1); if (flag1) { single1 /= 100f; } } catch (Exception) { throw new Exception(ItopVector.Core.Config.Config.GetLabelForName("invalidnumberformat") + str); } return single1; }
public WeatherForecastService() { var handler = new HttpClientHandler(); _httpClient = new HttpClient(handler); _httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); _numberFormatInfo = new NumberFormatInfo { NumberDecimalSeparator = "." }; }
public BlackBoxFunction() { provider = new NumberFormatInfo(); provider.NumberDecimalSeparator = "."; /// provider.NumberGroupSeparator = "."; provider.NumberGroupSizes = new int[] { 2 }; }
internal static double MatchConfiguredFPS(double probedFps) { if (fpsList == null) { fpsList = new List<double>(); NumberFormatInfo provider = new NumberFormatInfo() { NumberDecimalSeparator = "." }; Settings xmlreader = new MPSettings(); for (int i = 1; i < 100; i++) { string name = xmlreader.GetValueAsString("general", "refreshrate0" + Convert.ToString(i) + "_name", ""); if (string.IsNullOrEmpty(name)) continue; string fps = xmlreader.GetValueAsString("general", name + "_fps", ""); string[] fpsArray = fps.Split(';'); foreach (string fpsItem in fpsArray) { double fpsAsDouble = -1; double.TryParse(fpsItem, NumberStyles.AllowDecimalPoint, provider, out fpsAsDouble); if (fpsAsDouble > -1) fpsList.Add(fpsAsDouble); } } fpsList = fpsList.Distinct().ToList(); fpsList.Sort(); } if (fpsList != null && fpsList.Count > 0) { return fpsList.FirstOrDefault(f => Math.Abs(f - probedFps) < 0.24f); } return default(double); }
public override void SetUp() { base.SetUp(); Dir = NewDirectory(); RandomIndexWriter writer = new RandomIndexWriter(Random(), Dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMaxBufferedDocs(TestUtil.NextInt(Random(), 50, 1000))); Document doc = new Document(); FieldType customType = new FieldType(TextField.TYPE_STORED); customType.OmitNorms = true; Field field = NewField("field", "", customType); doc.Add(field); NumberFormatInfo df = new NumberFormatInfo(); df.NumberDecimalDigits = 0; //NumberFormat df = new DecimalFormat("000", new DecimalFormatSymbols(Locale.ROOT)); for (int i = 0; i < 1000; i++) { field.StringValue = i.ToString(df); writer.AddDocument(doc); } Reader = writer.Reader; writer.Dispose(); Searcher = NewSearcher(Reader); }
public static string ToString(float f) { NumberFormatInfo _NumberFormatInfo = new NumberFormatInfo(); _NumberFormatInfo.NumberDecimalSeparator = "."; return f.ToString(_NumberFormatInfo); }
private NumberFormatInfo GetNumberFormat2() { NumberFormatInfo format = new NumberFormatInfo(); format.NaNSymbol = "Geen"; format.PositiveSign = "+"; format.NegativeSign = "-"; format.PerMilleSymbol = "x"; format.PositiveInfinitySymbol = "Oneindig"; format.NegativeInfinitySymbol = "-Oneindig"; format.NumberDecimalDigits = 2; format.NumberDecimalSeparator = "."; format.NumberGroupSeparator = ","; format.NumberGroupSizes = new int[] {3}; format.NumberNegativePattern = 1; format.CurrencyDecimalDigits = 1; format.CurrencyDecimalSeparator = "."; format.CurrencyGroupSeparator = ","; format.CurrencyGroupSizes = new int[] {3}; format.CurrencyNegativePattern = 3; format.CurrencyPositivePattern = 1; format.CurrencySymbol = "$"; format.PercentDecimalDigits = 2; format.PercentDecimalSeparator = "."; format.PercentGroupSeparator = ","; format.PercentGroupSizes = new int[] {3}; format.PercentNegativePattern = 1; format.PercentPositivePattern = 2; format.PercentSymbol = "##"; return format; }
public FrameRateCounter(ScreenManager screenManager) : base(screenManager.Game) { _screenManager = screenManager; _format = new NumberFormatInfo(); _format.NumberDecimalSeparator = "."; }
private void writeOptionsFile(int graphWidth, int graphHeight) { string scriptsPath = UtilEncoder.GetSprintPath(); if (UtilAll.IsWindows()) { scriptsPath = scriptsPath.Replace("\\", "/"); } System.Globalization.NumberFormatInfo localeInfo = new System.Globalization.NumberFormatInfo(); localeInfo = System.Globalization.NumberFormatInfo.CurrentInfo; string scriptOptions = "#os\n" + UtilEncoder.OperatingSystemForRGraphs() + "\n" + "#decimalChar\n" + localeInfo.NumberDecimalSeparator + "\n" + "#graphWidth\n" + graphWidth.ToString() + "\n" + "#graphHeight\n" + graphHeight.ToString() + "\n" + "#averageLength\n" + Util.ConvertToPoint(averageLength) + "\n" + "#percentChange\n" + Util.ConvertToPoint(percentChange) + "\n" + "#vlineT0\n" + Util.BoolToRBool(vlineT0) + "\n" + "#vline50fmax.raw\n" + Util.BoolToRBool(vline50fmax_raw) + "\n" + "#vline50fmax.fitted\n" + Util.BoolToRBool(vline50fmax_fitted) + "\n" + "#hline50fmax.raw\n" + Util.BoolToRBool(hline50fmax_raw) + "\n" + "#hline50fmax.fitted\n" + Util.BoolToRBool(hline50fmax_fitted) + "\n" + "#RFDs"; foreach (ForceSensorRFD rfd in rfdList) { if (rfd.active) { scriptOptions += "\n" + rfd.ToR(); } else { scriptOptions += "\n-1"; } } if (impulse.active) { scriptOptions += "\n" + impulse.ToR(); } else { scriptOptions += "\n-1"; } scriptOptions += "\n#testLength\n" + testLength.ToString() + "\n" + "#title\n" + title + "\n" + "#scriptsPath\n" + UtilEncoder.GetScriptsPath() + "\n"; TextWriter writer = File.CreateText(Path.GetTempPath() + "Roptions.txt"); writer.Write(scriptOptions); writer.Flush(); writer.Close(); ((IDisposable)writer).Dispose(); }
private TextNumberFormat(TextNumberFormat.formatTypes theType, System.Globalization.CultureInfo cultureNumberFormat, int digits) { this.numberFormat = cultureNumberFormat.NumberFormat; this.numberFormatType = (int)theType; this.groupingActivated = true; this.separator = this.GetSeparator((int)theType); this.digits = digits; }
private TextNumberFormat(TextNumberFormat.formatTypes theType, int digits) { this.numberFormat = System.Globalization.NumberFormatInfo.CurrentInfo; this.numberFormatType = (int)theType; this.groupingActivated = true; this.separator = this.GetSeparator((int)theType); this.digits = digits; }
public TextNumberFormat(int digits, int minint, int maxint, int minfrac, int maxfrac) { numberFormat = System.Globalization.NumberFormatInfo.CurrentInfo; minIntDigits = minint < 0 ? 1 : minint; maxIntDigits = maxint < 0 ? 127 : maxint; minFractionDigits = minfrac < 0 ? 0 : minfrac; maxFractionDigits = maxfrac < 0 ? 3 : maxfrac; }
// CONSTRUCTORS public TextNumberFormat() { this.numberFormat = new System.Globalization.NumberFormatInfo(); this.numberFormatType = (int)TextNumberFormat.formatTypes.General; this.groupingActivated = true; this.separator = this.GetSeparator((int)TextNumberFormat.formatTypes.General); this.digits = 3; }
// CONSTRUCTORS public TextNumberFormat() { this.numberFormat = new System.Globalization.NumberFormatInfo(); this.numberFormatType = (int)TextNumberFormat.formatTypes.General; this.groupingActivated = true; this.separator = this.GetSeparator((int)TextNumberFormat.formatTypes.General); this.maxIntDigits = 127; this.minIntDigits = 1; this.maxFractionDigits = 3; this.minFractionDigits = 0; }
private TextNumberFormat(TextNumberFormat.formatTypes theType, System.Globalization.CultureInfo cultureNumberFormat, int digits) { this.numberFormat = cultureNumberFormat.NumberFormat; this.numberFormatType = (int)theType; this.groupingActivated = true; this.separator = this.GetSeparator((int)theType); this.maxIntDigits = 127; this.minIntDigits = 1; this.maxFractionDigits = 3; this.minFractionDigits = 0; }
protected void fillWindowTitleAndLabelHeader() { edit_event.Title = string.Format(Catalog.GetString("Edit {0}"), eventBigTypeString); System.Globalization.NumberFormatInfo localeInfo = new System.Globalization.NumberFormatInfo(); localeInfo = System.Globalization.NumberFormatInfo.CurrentInfo; label_header.Text = string.Format(Catalog.GetString("Use this window to edit a {0}."), eventBigTypeString); if (headerShowDecimal) { label_header.Text += string.Format(Catalog.GetString("\n(decimal separator: '{0}')"), localeInfo.NumberDecimalSeparator); } }
// Restricts the entry of characters to digits (including hex), the negative sign, // the decimal point, and editing keystrokes (backspace). protected override void OnKeyPress(KeyPressEventArgs e) { base.OnKeyPress(e); System.Globalization.NumberFormatInfo numberFormatInfo = System.Globalization.CultureInfo.CurrentCulture.NumberFormat; string decimalSeparator = numberFormatInfo.NumberDecimalSeparator; string groupSeparator = numberFormatInfo.NumberGroupSeparator; string negativeSign = numberFormatInfo.NegativeSign; string keyInput = e.KeyChar.ToString(); if (Char.IsDigit(e.KeyChar)) { // Digits are OK if (allowDecimalSeparator == true) { if (this.Text.Split('.').Length == 2) { int iLength = this.Text.Split('.').GetValue(0).ToString().Length; int dLength = this.Text.Split('.').GetValue(1).ToString().Length; if ((iLength == (this.MaxLength - this.DecimalLength - 1)) || (dLength == this.DecimalLength) || ((dLength == this.DecimalLength) && (iLength == (this.MaxLength - this.DecimalLength - 1)) && (this.SelectionLength != this.MaxLength))) { e.Handled = true; } } else if ((this.Text.Length == (this.MaxLength - this.DecimalLength - 1)) && (this.SelectionLength != this.Text.Length)) { e.Handled = true; } } } else if ((!(this.IsThereDecimalSeparator) && this.allowDecimalSeparator && keyInput.Equals(decimalSeparator)) || (this.allowGroupSeparator && keyInput.Equals(groupSeparator)) || ((!(this.IsThereNegativeSign) && this.allowNegativeSign && keyInput.Equals(negativeSign)))) { // Decimal separator is OK } else if ((e.KeyChar == '\b') || (this.allowSpace && e.KeyChar == ' ')) { // Backspace key is OK } else if (e.KeyChar == (char)Keys.Return) { return; } else { e.Handled = true; } }
private static void ConvertUInt32WithProvider() { // <Snippet23> uint number = UInt32.MaxValue; System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo(); nfi.NegativeSign = "~"; nfi.PositiveSign = "!"; Console.WriteLine("{0,-8} --> {1,8}", Convert.ToString(number, System.Globalization.CultureInfo.InvariantCulture), Convert.ToString(number, nfi)); // The example displays the following output: // 4294967295 --> 4294967295 // </Snippet23> }
private static void ConvertUInt64WithProvider() { // <Snippet24> ulong number = UInt64.MaxValue; System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo(); nfi.NegativeSign = "~"; nfi.PositiveSign = "!"; Console.WriteLine("{0,-12} --> {1,12}", Convert.ToString(number, System.Globalization.CultureInfo.InvariantCulture), Convert.ToString(number, nfi)); // The example displays the following output: // 18446744073709551615 --> 18446744073709551615 // </Snippet24> }
private static void ConvertUInt16WithProvider() { // <Snippet22> ushort number = UInt16.MaxValue; System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo(); nfi.NegativeSign = "~"; nfi.PositiveSign = "!"; Console.WriteLine("{0,-6} --> {1,6}", Convert.ToString(number, System.Globalization.CultureInfo.InvariantCulture), Convert.ToString(number, nfi)); // The example displays the following output: // 65535 --> 65535 // </Snippet22> }
private void fillDialog(bool simple) { //active the desired radio if (simple) { radiobutton_simple.Active = true; } else { radiobutton_interval.Active = true; } //don't show the radios radiobutton_simple.Visible = false; radiobutton_interval.Visible = false; //if simple don't show nothing label_main_options.Visible = !simple; table_main_options.Visible = !simple; //hbox_fixed.Sensitive = false; button_accept.Sensitive = false; spin_fixed_tracks_or_time.Sensitive = false; label_distance.Text = Catalog.GetString("Distance"); System.Globalization.NumberFormatInfo localeInfo = new System.Globalization.NumberFormatInfo(); label_decimal.Text = string.Format(Catalog.GetString("\n(decimal separator: '{0}')"), localeInfo.NumberDecimalSeparator); radiobutton_dist_different.Visible = !simple; hbox_distance_fixed.Hide(); vbox_distance_variable.Hide(); dd0 = new Gtk.Entry(); dd0.Changed += new EventHandler(on_entries_required_changed); dd1 = new Gtk.Entry(); dd1.Changed += new EventHandler(on_entries_required_changed); dd2 = new Gtk.Entry(); dd2.Changed += new EventHandler(on_entries_required_changed); dd3 = new Gtk.Entry(); dd3.Changed += new EventHandler(on_entries_required_changed); dd4 = new Gtk.Entry(); dd4.Changed += new EventHandler(on_entries_required_changed); dd5 = new Gtk.Entry(); dd5.Changed += new EventHandler(on_entries_required_changed); dd6 = new Gtk.Entry(); dd6.Changed += new EventHandler(on_entries_required_changed); dd7 = new Gtk.Entry(); dd7.Changed += new EventHandler(on_entries_required_changed); dd8 = new Gtk.Entry(); dd8.Changed += new EventHandler(on_entries_required_changed); dd9 = new Gtk.Entry(); dd9.Changed += new EventHandler(on_entries_required_changed); combo_distance_different_tracks.Active = 0; reset_hbox_distance_variable(2); }
private static void ConvertSByteWithProvider() { // <Snippet17> sbyte[] numbers = { SByte.MinValue, -12, 17, SByte.MaxValue }; System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo(); nfi.NegativeSign = "~"; nfi.PositiveSign = "!"; foreach (sbyte number in numbers) { Console.WriteLine(Convert.ToString(number, nfi)); } // The example displays the following output: // ~128 // ~12 // 17 // 127 // </Snippet17> }
private static void ConvertInt32WithProvider() { // <Snippet20> int[] numbers = { Int32.MinValue, Int32.MaxValue }; System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo(); nfi.NegativeSign = "~"; nfi.PositiveSign = "!"; foreach (int number in numbers) { Console.WriteLine("{0,-12} --> {1,12}", Convert.ToString(number, System.Globalization.CultureInfo.InvariantCulture), Convert.ToString(number, nfi)); } // The example displays the following output: // -2147483648 --> ~2147483648 // 2147483647 --> 2147483647 // </Snippet20> }
static void print_results(int bench1, int bench2, double[] bench_res1, System.Globalization.NumberFormatInfo nfi) { const int max_language_len1 = 10; Console.WriteLine("\nThroughput for all benchmarks (loops per sec):"); string str = "BMR (" + prg_language + ")"; for (int i = prg_language.Length; i < max_language_len1; i++) { str += " "; } str += ": "; for (int bench = bench1; bench <= bench2; bench++) { str += String.Format(nfi, "{0,9:F2} ", bench_res1[bench]); } Console.WriteLine(str); Console.WriteLine(""); }
string FileSize(uint?size) { if (!size.HasValue) { return(null); } var f = new System.Globalization.NumberFormatInfo { NumberGroupSeparator = " ", NumberDecimalSeparator = "," }; var unit = new[] { "B", "KB", "MB" }; float s = size.Value; int i; for (i = 0; i < unit.Length && s >= 1000; i++) { s /= 1000; } return($"{s.ToString("0", f)} {unit[i]}"); }
private static void ConvertInt64WithProvider() { // <Snippet21> long[] numbers = { ((long)Int32.MinValue) * 2, ((long)Int32.MaxValue) * 2 }; System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo(); nfi.NegativeSign = "~"; nfi.PositiveSign = "!"; foreach (long number in numbers) { Console.WriteLine("{0,-12} --> {1,12}", Convert.ToString(number, System.Globalization.CultureInfo.InvariantCulture), Convert.ToString(number, nfi)); } // The example displays the following output: // -4294967296 --> ~4294967296 // 4294967294 --> 4294967294 // </Snippet21> }
public void ShowFinishPanel() { wallMenuBackground.SetActive(true); finishPanel.SetActive(true); finishTimeText.gameObject.SetActive(true); timeSpent = DateTime.Now.Subtract(dateStarted); // string.Format("IsLoggedIn='{0}' IsInitialized='{1}'", // var floatNumber = 12.5523; // var x = floatNumber - Math.Truncate(floatNumber); System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo(); nfi.NumberDecimalSeparator = ":"; // nfi.NumberDecimalDigits = 2; // nfi.number // int milliseconds = Convert.ToInt32(Mathf.FloorToInt((float)timeSpent.TotalMilliseconds).ToString().Substring(0, 2)); // int millmilliiseconds = Convert.ToInt32(Mathf.FloorToInt((float)timeSpent.TotalMilliseconds).ToString().Substring(2, 4)); timeString = string.Format("{0}:{1}:{2}", Mathf.FloorToInt((float)timeSpent.TotalHours).ToString("00"), (Mathf.FloorToInt((float)timeSpent.TotalMinutes) % 60).ToString("00"), (Mathf.FloorToInt((float)timeSpent.TotalSeconds) % 60).ToString("00")); finishTimeText.text = "Поздравляем!\nВы прошли «Мою улицу»\nвсего за " + "<color=#30c59d>" + timeString + "</color>"; }
// Update is called once per frame void Update() { if (Input.GetMouseButton(0)) { float xCurrent = transform.position.x; float mousePositionX = Camera.main.ScreenToWorldPoint(Input.mousePosition).x; float targetX = Mathf.Lerp(transform.position.x, mousePositionX, lerpAmount); transform.position = new Vector3(targetX, transform.position.y, transform.position.z); displacement = transform.position.x - xCurrent; transform.GetChild(0).transform.Rotate(0, 0, (-displacement / radius) * Mathf.Rad2Deg); transform.GetChild(1).transform.Rotate(0, 0, (-displacement / radius) * Mathf.Rad2Deg); gun.Active(true); } if (Input.GetMouseButtonUp(0)) { gun.Active(false); } System.Globalization.NumberFormatInfo nfm = new System.Globalization.NumberFormatInfo(); }
private static void ConvertInt16WithProvider() { // <Snippet19> short[] numbers = { Int16.MinValue, Int16.MaxValue }; System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo(); nfi.NegativeSign = "~"; nfi.PositiveSign = "!"; foreach (short number in numbers) { Console.WriteLine("{0,-8} --> {1,8}", Convert.ToString(number, System.Globalization.CultureInfo.InvariantCulture), Convert.ToString(number, nfi)); } // The example displays the following output: // -32768 --> ~32768 // 32767 --> 32767 // </Snippet19> }
private static void ConvertInt32() { // Create a NumberFormatInfo object and set several of its // properties that control default integer formatting. System.Globalization.NumberFormatInfo provider = new System.Globalization.NumberFormatInfo(); provider.NegativeSign = "minus "; int[] values = { -20, 0, 100 }; foreach (int value in values) { Console.WriteLine("{0,-5} --> {1,8}", value, Convert.ToString(value, provider)); } // The example displays the following output: // -20 --> minus 20 // 0 --> 0 // 100 --> 100 }
void FormatInfo() { System.Globalization.NumberFormatInfo formatInfo = new System.Globalization.NumberFormatInfo() { CurrencySymbol = "!!$!!" }; int number = 3; Console.WriteLine(number.ToString("C", formatInfo)); // Also available DateTimeFormatInfo and CultureInfo System.Globalization.DateTimeFormatInfo dateFormat = (System.Globalization.DateTimeFormatInfo)System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.Clone(); dateFormat.TimeSeparator = "-"; Console.WriteLine(DateTime.Now.ToString(dateFormat)); }
Pulse myPulse; //used on button_accept RepairPulseWindow(Gtk.Window parent, Pulse myPulse, int pDN) { Glade.XML gladeXML; gladeXML = Glade.XML.FromAssembly(Util.GetGladePath() + "repair_sub_event.glade", "repair_sub_event", "chronojump"); gladeXML.Autoconnect(this); //put an icon to window UtilGtk.IconWindow(repair_sub_event); repair_sub_event.Parent = parent; this.myPulse = myPulse; repair_sub_event.Title = Catalog.GetString("Repair pulse"); System.Globalization.NumberFormatInfo localeInfo = new System.Globalization.NumberFormatInfo(); localeInfo = System.Globalization.NumberFormatInfo.CurrentInfo; label_header.Text = string.Format(Catalog.GetString("Use this window to repair this test.\nDouble clic any cell to edit it (decimal separator: '{0}')"), localeInfo.NumberDecimalSeparator); pulseType = SqlitePulseType.SelectAndReturnPulseType(myPulse.Type); TextBuffer tb = new TextBuffer(new TextTagTable()); tb.Text = createTextForTextView(pulseType); textview1.Buffer = tb; createTreeView(treeview_subevents); //count, time store = new TreeStore(typeof(string), typeof(string)); treeview_subevents.Model = store; fillTreeView(treeview_subevents, store, myPulse, pDN); button_add_before.Sensitive = false; button_add_after.Sensitive = false; button_delete.Sensitive = false; label_totaltime_value.Text = getTotalTime().ToString() + " " + Catalog.GetString("seconds"); treeview_subevents.Selection.Changed += onSelectionEntry; }
public static decimal IVA() { DataRow diapago = null; Cobranza_DB objcobranza = new Cobranza_DB(); try { using (OracleConnection Conexion = MConexion.getConexion("OVDES")) { diapago = objcobranza.IVA_DB(Conexion); System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo(); nfi.NumberGroupSeparator = ","; return(Convert.ToDecimal(diapago["ivas"].ToString(), nfi)); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public override void OnPreviewGUI(Rect rect_, GUIStyle background) { NoesisView view = target as NoesisView; Noesis.ViewStats stats = view.GetStats(); if (_previewStyle == null) { _previewStyle = new GUIStyle("PreOverlayLabel") { richText = true, fontStyle = FontStyle.Normal }; } StringBuilder header = new StringBuilder(); header.AppendLine("<color=orange>" + view.Xaml.source + "</color>"); _previewStyle.alignment = TextAnchor.UpperLeft; GUI.Label(new Rect(rect_.x + 5, rect_.y + 5, rect_.width, rect_.height), header.ToString(), _previewStyle); StringBuilder left = new StringBuilder(); left.AppendLine("\n\nFrame Time (ms)"); left.AppendLine("Update Time (ms)"); left.AppendLine("Render Time (ms)"); left.AppendLine(); left.AppendLine("Triangles"); left.AppendLine("Draws"); left.AppendLine("Batches"); left.AppendLine("Tessellations"); left.AppendLine("Geometry Size (kB)"); left.AppendLine("Flushes"); left.AppendLine(); left.AppendLine("Stencil Masks"); left.AppendLine("Opacity Groups"); left.AppendLine("RT Switches"); left.AppendLine(); left.AppendLine("Ramps Uploaded"); left.AppendLine("Rasterized Glyphs"); left.AppendLine("Discarded Glyph Tiles"); _previewStyle.alignment = TextAnchor.UpperLeft; GUI.Label(new Rect(rect_.x + 15, rect_.y + 5, 220, 500), left.ToString(), _previewStyle); var format = new System.Globalization.NumberFormatInfo { NumberDecimalSeparator = "." }; StringBuilder right = new StringBuilder(); right.AppendLine("\n\n<b>" + stats.FrameTime.ToString("#,##0.00", format) + "</b>"); right.AppendLine("<b>" + stats.UpdateTime.ToString("#,##0.00", format) + "</b>"); right.AppendLine("<b>" + stats.RenderTime.ToString("#,##0.00", format) + "</b>"); right.AppendLine(); right.AppendLine("<b>" + stats.Triangles + "</b>"); right.AppendLine("<b>" + stats.Draws + "</b>"); right.AppendLine("<b>" + stats.Batches + "</b>"); right.AppendLine("<b>" + stats.Tessellations + "</b>"); right.AppendLine("<b>" + String.Format("{0:F0}", stats.GeometrySize / 1024) + "</b>"); right.AppendLine("<b>" + stats.Flushes + "</b>"); right.AppendLine(); right.AppendLine("<b>" + stats.Masks + "</b>"); right.AppendLine("<b>" + stats.Opacities + "</b>"); right.AppendLine("<b>" + stats.RenderTargetSwitches + "</b>"); right.AppendLine(); right.AppendLine("<b>" + stats.UploadedRamps + "</b>"); right.AppendLine("<b>" + stats.RasterizedGlyphs + "</b>"); right.AppendLine("<b>" + stats.DiscardedGlyphTiles + "</b>"); _previewStyle.alignment = TextAnchor.UpperRight; GUI.Label(new Rect(rect_.x + 15, rect_.y + 5, 220, 500), right.ToString(), _previewStyle); }
static void Main(string[] args) { // установка разделитя в дробных суммах (зависит от настройки локализации) NumberFormatInfo formatSepar = new NumberFormatInfo(); formatSepar.NumberDecimalSeparator = "."; // Загрузка документа в память XDocument xmlDoc = XDocument.Load("books.xml"); IEnumerable<XElement> books = xmlDoc.Root.Elements("book") .Where(t => t.Element("genre").Value == "Computer"); // XDocument.Descendants(XName) // Возвращает коллекцию подчиненных узлов для данного элемента. // Только элементы, имеющие соответствующее XName, включаются в коллекцию. //IEnumerable<XElement> books = xmlDoc.Root.Descendants("book") // .Where(t => t.Element("genre").Value == "Computer"); books.Remove(); xmlDoc.Save("booksNew.xml"); Console.WriteLine("Удаление выполнено успешно..."); Console.ReadKey(); }