/// <summary> /// Copies from another model with a deep copy. /// </summary> /// <param name="m">The model to copy from.</param> public void CopyFrom(GraphModel m) { X0 = m.X0; X1 = m.X1; Y0 = m.Y0; Y1 = m.Y1; Z0 = m.Z0; Z1 = m.Z1; rx = m.rx; ry = m.ry; rz = m.rz; xAxis = m.xAxis; yAxis = m.yAxis; xRaster = m.xRaster; yRaster = m.yRaster; xGrid = m.xGrid; yGrid = m.yGrid; xScale = m.xScale; yScale = m.yScale; zScale = m.zScale; Border = m.Border; FixYtoX = m.FixYtoX; Legend = m.Legend; LegendBorder = m.LegendBorder; xDigits = m.xDigits; yDigits = m.yDigits; zDigits = m.zDigits; xNumberStyle = m.xNumberStyle; yNumberStyle = m.yNumberStyle; zNumberStyle = m.zNumberStyle; ScaleFont = m.ScaleFont; ScaleColor = m.ScaleColor; Filename = (string)m.Filename.Clone(); Items = m.Items.Clone(this); Library = (SourceLibrary)m.Library.Clone(); CompilerImports = (string[])m.CompilerImports.Clone(); //Deep Copy of CompilerOptions CompilerOptions.Clear(); IEnumerator keys, values; keys = m.CompilerOptions.Keys.GetEnumerator(); values = m.CompilerOptions.Values.GetEnumerator(); keys.Reset(); values.Reset(); for (int i = 0; i < m.CompilerOptions.Count; i++) { keys.MoveNext(); values.MoveNext(); CompilerOptions.Add(keys.Current, values.Current); } Modified = true; }
/// <summary> /// Copies all scale data from the parameter source with a deep copy. /// </summary> public void CopyFrom(Scale source) { r = source.r; axis = source.axis; logarithmic = source.logarithmic; scale = source.scale; raster = source.raster; line = source.line; scaleOutside = source.scaleOutside; rasterOutside = source.rasterOutside; oppositeLine = source.oppositeLine; oppositeRaster = source.oppositeRaster; grid = source.grid; fix = source.fix; invert = source.invert; upper = source.upper; lower = source.lower; if (source.unit == null) { unit = null; } else { unit = (string)source.unit.Clone(); } unitAngle = source.unitAngle; unitAngleRelative = source.unitAngleRelative; digits = source.digits; style = source.style; }
static void Main(string[] args) { Spreadsheet spreadsheet = new Spreadsheet(); DecimalNumber decimalNumber1 = new DecimalNumber(); decimalNumber1.DecimalPlaces = 2; decimalNumber1.MinIntegerDigits = 1; decimalNumber1.Grouping = true; NumberStyle numberStyle1 = new NumberStyle("N1"); numberStyle1.Number = decimalNumber1; CellStyle cellStyle1 = new CellStyle("CS1"); cellStyle1.DataStyle = "N1"; spreadsheet.AutomaticStyles.Styles.Add(numberStyle1); spreadsheet.AutomaticStyles.Styles.Add(cellStyle1); Cell a1 = new Cell(9999999); a1.Style = "CS1"; Table sheet1 = new Table(); sheet1["A1"] = a1; spreadsheet.Tables.Add(sheet1); spreadsheet.Save("c:\\test\\output.ods", true); }
public static long Parse(string str, NumberStyle style) { if (style == NumberStyle.Hexadecimal) { return(Int64Extensions.ParseHex(str)); } return(Int64Extensions.Parse(str)); }
public static long Parse(string str, NumberStyle style) { if (style == NumberStyle.Hexadecimal) { return ParseHex(str); } return Parse(str); }
/// <summary> /// The constructor of the Scale class. /// </summary> public Scale(PlotModel model) { this.model = model; r = 0; unit = null; style = NumberStyle.Normal; lower = -1; upper = 1; }
public static bool TryParse(string str, NumberStyle style, out UInt32 result) { bool sign; ulong tmp; bool bresult = Helper.TryParseUInt64Core(str, style == NumberStyle.Hexadecimal ? true : false, out tmp, out sign); result = (UInt32)tmp; return bresult && !sign; }
public static bool TryParse(string str, NumberStyle style, out UInt32 result) { bool sign; ulong tmp; bool bresult = Helper.TryParseUInt64Core(str, style == NumberStyle.Hexadecimal ? true : false, out tmp, out sign); result = (UInt32)tmp; return(bresult && !sign); }
public static bool TryParse(string str, NumberStyle style, out uint result) { ulong result1; bool sign; bool uint64Core = Helper.TryParseUInt64Core(str, style == NumberStyle.Hexadecimal, out result1, out sign); result = (uint)result1; if (uint64Core) { return(!sign); } return(false); }
/// <summary> /// Determines the type of number (int, double, etc) and returns an object /// containing that value. /// </summary> /// <param name="json"></param> /// <param name="index"></param> /// <param name="success"></param> /// <returns></returns> protected static object ParseNumber(char[] json, ref int index, ref bool success) { EatWhitespace(json, ref index); int lastIndex = GetLastIndexOfNumber(json, index); int charLength = (lastIndex - index) + 1; // We now have the number as a string. Parse it to determine the type of number. string value = new string (json, index, charLength); // Since the Json doesn't contain the Type of the property, and since multiple number // values can fit in the various Types (e.g. 33 decimal fits in an Int16, UInt16, // Int32, UInt32, Int64, and UInt64), we need to be a bit smarter in how we deal with // the size of the number, and also the case (negative or positive). object result = null; if (value.Contains(".") || value.Contains(",") || value.Contains("e") || value.Contains("E")) { // We have either a double or a float. Force it to be a double // and let the deserializer unbox it into the proper size. result = Double.Parse(new string (json, index, charLength), CultureInfo.InvariantCulture.NumberFormat); } else { NumberStyle style = NumberStyle.Decimal; if (value.StartsWith("0x") || (value.IndexOfAny(new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'A', 'B', 'C', 'D', 'E', 'F' }) >= 0)) { style = NumberStyle.Hexadecimal; } result = Int64Extensions.Parse(value, style); } index = lastIndex + 1; return(result); }
protected override void WriteKeys(Newtonsoft.Json.JsonWriter writer) { if (!string.IsNullOrEmpty(CurrencyCode)) { writer.WritePropertyName("currencyCode"); writer.WriteValue(CurrencyCode); } if (NumberStyle != FieldNumberStyle.Unspecified) { writer.WritePropertyName("numberStyle"); writer.WriteValue(NumberStyle.ToString()); } }
public static string FormatNumber(object value, NumberStyle numberStyle) { if (!IsNumeric(value)) throw new FormatException("Unknown numeric value type."); if (numberStyle == NumberStyle.Decimal) { return value.ToString(); } else { return IntToHex(value); } }
public UserNumberTextBox() { this.myStyle = NumberStyle.AllFloat; this.myPositiveNegativeStyle = PositiveNegativeStyle.All; this.myDecimalDigits = 4; this.myZeroShow = true; this.myValue = 0.0; this.myMaxValue = Double.MaxValue; this.myMinValue = Double.MinValue; this.myShowComma = true; base.Text = ""; this.Value = 0.0; this.TextAlign = HorizontalAlignment.Right; }
public static string FormatNumber(object value, NumberStyle numberStyle, int size) { if (!IsNumeric(value)) throw new FormatException("Unknown numeric value type."); string result = String.Empty; if (numberStyle == NumberStyle.Decimal) { switch (Type.GetTypeCode(value.GetType())) { case TypeCode.Byte: result = ((byte)(value)).ToString("D" + size); break; case TypeCode.SByte: result = ((sbyte)(value)).ToString("D" + size); break; case TypeCode.UInt16: result = ((ushort)(value)).ToString("D" + size); break; case TypeCode.Int16: result = ((short)(value)).ToString("D" + size); break; case TypeCode.UInt32: result = ((uint)(value)).ToString("D" + size); break; case TypeCode.Int32: result = ((int)(value)).ToString("D" + size); break; case TypeCode.UInt64: result = ((ulong)(value)).ToString("D" + size); break; case TypeCode.Int64: result = ((long)(value)).ToString("D" + size); break; default: throw new FormatException("Unknown integer value type."); } } else { result = IntToHex(value, size); } return result; }
/// <summary> /// The default constructor. /// </summary> public GraphModel() { X0 = Y0 = Z0 = -1; X1 = Y1 = Z1 = rx = ry = rz = 1; xScale = yScale = zScale = xRaster = yRaster = Border = LegendBorder = true; xGrid = yGrid = xAxis = yAxis = Legend = FixYtoX = false; xDigits = yDigits = zDigits = 3; xNumberStyle = yNumberStyle = zNumberStyle = NumberStyle.Normal; ScaleFont = new System.Drawing.Font("Arial", 8); ScaleColor = Color.Black; Items = new ItemList(this); Library = new SourceLibrary(this); CompilerImports = new string[0]; CompilerOptions = new ListDictionary(); CompilerOptions.Add("target", "library"); CompilerOptions.Add("o", true); ResetRaster(); this.Filename = "Noname.fplot"; }
public CellFormatId(string borderStyle, NumberStyle numberStyle, string fontStyle) { BorderStyle = borderStyle; NumberStyle = numberStyle; FontStyle = fontStyle; }
public uint BuildCellFormat(string borderstyle, NumberStyle numberstyle, string fontstyle = "Default") { CellFormatId id = new CellFormatId(borderstyle, numberstyle, fontstyle); uint borderStyleId = 0; BorderStyles.TryGetValue(borderstyle, out borderStyleId); uint fontStyleId = 0; FontStyles.TryGetValue(fontstyle, out fontStyleId); if (CellFormatStyles.ContainsKey(id) == false) { var cell = new CellFormat { NumberFormatId = NumberStyles[numberstyle].NumberFormatId, FontId = fontStyleId, FillId = 0, BorderId = borderStyleId, FormatId = 0, ApplyNumberFormat = BooleanValue.FromBoolean(true) }; CellFormatStyles.Add(id, (uint)MyCellFormats.ChildElements.Count); MyCellFormats.Append(cell); } return CellFormatStyles[id]; }
private static void DrawNumber(Graphics g, int number, PointF numberPosition, NumberStyle numberStyle) { var font = new Font("Arial", numberStyle.FontSize, FontStyle.Regular); var drawFormat = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }; using (font) using (drawFormat) g.DrawString(number.ToString(), font, new SolidBrush(numberStyle.Color), numberPosition, drawFormat); }
/// <summary> /// Style of number to display. /// </summary> public static PassBuilder.StandardFieldBuilder NumberStyle(this PassBuilder.StandardFieldBuilder builder, NumberStyle value) { builder.SetFieldValue(PassBuilder.GetCaller(), value.ToPassKitString()); return(builder); }
/// <summary> /// 获取属性值 /// </summary> /// <param name="name">属性名称</param> /// <param name="value">返回属性值</param> /// <param name="type">返回属性类型</param> public virtual void getProperty(String name, ref String value, ref String type) { if (name == "allowuserpaint") { type = "bool"; value = FCStr.convertBoolToStr(AllowUserPaint); } else if (name == "automaxmin") { type = "bool"; value = FCStr.convertBoolToStr(AutoMaxMin); } else if (name == "basefield") { type = "int"; value = FCStr.convertIntToStr(BaseField); } else if (name == "digit") { type = "int"; value = FCStr.convertIntToStr(Digit); } else if (name == "font") { type = "font"; value = FCStr.convertFontToStr(Font); } else if (name == "textcolor") { type = "color"; value = FCStr.convertColorToStr(TextColor); } else if (name == "textcolor2") { type = "color"; value = FCStr.convertColorToStr(TextColor2); } else if (name == "magnitude") { type = "int"; value = FCStr.convertIntToStr(Magnitude); } else if (name == "midvalue") { type = "double"; value = FCStr.convertDoubleToStr(MidValue); } else if (name == "numberstyle") { type = "enum:NumberStyle"; NumberStyle style = NumberStyle; if (style == NumberStyle.Standard) { value = "Standard"; } else { value = "UnderLine"; } } else if (name == "paddingbottom") { type = "int"; value = FCStr.convertIntToStr(PaddingBottom); } else if (name == "paddingtop") { type = "int"; value = FCStr.convertIntToStr(PaddingTop); } else if (name == "reverse") { type = "bool"; value = FCStr.convertBoolToStr(Reverse); } else if (name == "scalecolor") { type = "color"; value = FCStr.convertColorToStr(ScaleColor); } else if (name == "system") { type = "enum:VScaleSystem"; VScaleSystem system = System; if (system == VScaleSystem.Logarithmic) { value = "Log"; } else { value = "Standard"; } } else if (name == "type") { type = "enum:VScaleType"; VScaleType vScaleType = Type; if (vScaleType == VScaleType.Divide) { value = "Divide"; } else if (vScaleType == VScaleType.EqualDiff) { value = "EqualDiff"; } else if (vScaleType == VScaleType.EqualRatio) { value = "EqualRatio"; } else if (vScaleType == VScaleType.GoldenRatio) { value = "GoldenRatio"; } else { value = "Percent"; } } else if (name == "visiblemax") { type = "double"; value = FCStr.convertDoubleToStr(VisibleMax); } else if (name == "visiblemin") { type = "double"; value = FCStr.convertDoubleToStr(VisibleMin); } }
public IntlNumber(NumberStyle style) : base(IntlFormat.Number) { Number = style; }