// Token: 0x06000410 RID: 1040 RVA: 0x0000B9D8 File Offset: 0x00009BD8 internal static string ToString(FigureLength fl, CultureInfo cultureInfo) { FigureUnitType figureUnitType = fl.FigureUnitType; if (figureUnitType == FigureUnitType.Auto) { return("Auto"); } if (figureUnitType != FigureUnitType.Pixel) { return(Convert.ToString(fl.Value, cultureInfo) + " " + fl.FigureUnitType.ToString()); } return(Convert.ToString(fl.Value, cultureInfo)); }
/// <summary>Initializes a new instance of the <see cref="T:System.Windows.FigureLength" /> class with the specified <see cref="P:System.Windows.FigureLength.Value" /> and <see cref="P:System.Windows.FigureLength.FigureUnitType" />.</summary> /// <param name="value">The <see cref="P:System.Windows.FigureLength.Value" /> of the <see cref="T:System.Windows.FigureLength" /> class.</param> /// <param name="type">The <see cref="P:System.Windows.FigureLength.Value" /> of the <see cref="P:System.Windows.FigureLength.FigureUnitType" /> class.</param> // Token: 0x060003FE RID: 1022 RVA: 0x0000B65C File Offset: 0x0000985C public FigureLength(double value, FigureUnitType type) { double num = 1000.0; double num2 = (double)Math.Min(1000000, 3500000); if (DoubleUtil.IsNaN(value)) { throw new ArgumentException(SR.Get("InvalidCtorParameterNoNaN", new object[] { "value" })); } if (double.IsInfinity(value)) { throw new ArgumentException(SR.Get("InvalidCtorParameterNoInfinity", new object[] { "value" })); } if (value < 0.0) { throw new ArgumentOutOfRangeException(SR.Get("InvalidCtorParameterNoNegative", new object[] { "value" })); } if (type != FigureUnitType.Auto && type != FigureUnitType.Pixel && type != FigureUnitType.Column && type != FigureUnitType.Content && type != FigureUnitType.Page) { throw new ArgumentException(SR.Get("InvalidCtorParameterUnknownFigureUnitType", new object[] { "type" })); } if (value > 1.0 && (type == FigureUnitType.Content || type == FigureUnitType.Page)) { throw new ArgumentOutOfRangeException("value"); } if (value > num && type == FigureUnitType.Column) { throw new ArgumentOutOfRangeException("value"); } if (value > num2 && type == FigureUnitType.Pixel) { throw new ArgumentOutOfRangeException("value"); } this._unitValue = ((type == FigureUnitType.Auto) ? 0.0 : value); this._unitType = type; }
/// <summary> /// Constructor, initializes the FigureLength and specifies what kind of value /// it will hold. /// </summary> /// <param name="value">Value to be stored by this FigureLength /// instance.</param> /// <param name="type">Type of the value to be stored by this FigureLength /// instance.</param> /// <remarks> /// If the <c>type</c> parameter is <c>FigureUnitType.Auto</c>, /// then passed in value is ignored and replaced with <c>0</c>. /// </remarks> /// <exception cref="ArgumentException"> /// If <c>value</c> parameter is <c>double.NaN</c> /// or <c>value</c> parameter is <c>double.NegativeInfinity</c> /// or <c>value</c> parameter is <c>double.PositiveInfinity</c>. /// or <c>value</c> parameter is <c>negative</c>. /// </exception> public FigureLength(double value, FigureUnitType type) { double maxColumns = PTS.Restrictions.tscColumnRestriction; double maxPixel = Math.Min(1000000, PTS.MaxPageSize); if (double.IsNaN(value)) { throw new ArgumentException(SR.Get(SRID.InvalidCtorParameterNoNaN, "value")); } if (double.IsInfinity(value)) { throw new ArgumentException(SR.Get(SRID.InvalidCtorParameterNoInfinity, "value")); } if (value < 0.0) { throw new ArgumentOutOfRangeException(SR.Get(SRID.InvalidCtorParameterNoNegative, "value")); } if (type != FigureUnitType.Auto && type != FigureUnitType.Pixel && type != FigureUnitType.Column && type != FigureUnitType.Content && type != FigureUnitType.Page) { throw new ArgumentException(SR.Get(SRID.InvalidCtorParameterUnknownFigureUnitType, "type")); } if (value > 1.0 && (type == FigureUnitType.Content || type == FigureUnitType.Page)) { throw new ArgumentOutOfRangeException("value"); } if (value > maxColumns && type == FigureUnitType.Column) { throw new ArgumentOutOfRangeException("value"); } if (value > maxPixel && type == FigureUnitType.Pixel) { throw new ArgumentOutOfRangeException("value"); } _unitValue = (type == FigureUnitType.Auto) ? 0.0 : value; _unitType = type; }
// Token: 0x06002291 RID: 8849 RVA: 0x000ABA18 File Offset: 0x000A9C18 internal static void FromString(string s, CultureInfo cultureInfo, out double value, out FigureUnitType unit) { string text = s.Trim().ToLowerInvariant(); value = 0.0; unit = FigureUnitType.Pixel; int length = text.Length; int num = 0; double num2 = 1.0; int i = 0; if (text == XamlFigureLengthSerializer.UnitStrings[i].Name) { num = XamlFigureLengthSerializer.UnitStrings[i].Name.Length; unit = XamlFigureLengthSerializer.UnitStrings[i].UnitType; } else { for (i = 1; i < XamlFigureLengthSerializer.UnitStrings.Length; i++) { if (text.EndsWith(XamlFigureLengthSerializer.UnitStrings[i].Name, StringComparison.Ordinal)) { num = XamlFigureLengthSerializer.UnitStrings[i].Name.Length; unit = XamlFigureLengthSerializer.UnitStrings[i].UnitType; break; } } } if (i >= XamlFigureLengthSerializer.UnitStrings.Length) { for (i = 0; i < XamlFigureLengthSerializer.PixelUnitStrings.Length; i++) { if (text.EndsWith(XamlFigureLengthSerializer.PixelUnitStrings[i], StringComparison.Ordinal)) { num = XamlFigureLengthSerializer.PixelUnitStrings[i].Length; num2 = XamlFigureLengthSerializer.PixelUnitFactors[i]; break; } } } if (length == num && unit != FigureUnitType.Pixel) { value = 1.0; return; } string value2 = text.Substring(0, length - num); value = Convert.ToDouble(value2, cultureInfo) * num2; }
// Token: 0x060083A2 RID: 33698 RVA: 0x00245C68 File Offset: 0x00243E68 internal FigureUnitTypeStringConvert(string name, FigureUnitType unitType) { this.Name = name; this.UnitType = unitType; }
internal FigureUnitTypeStringConvert(string name, FigureUnitType unitType) { Name = name; UnitType = unitType; }
// Parse a FigureLength from a string given the CultureInfo. static internal void FromString( string s, CultureInfo cultureInfo, out double value, out FigureUnitType unit) { string goodString = s.Trim().ToLowerInvariant(); value = 0.0; unit = FigureUnitType.Pixel; int i; int strLen = goodString.Length; int strLenUnit = 0; double unitFactor = 1.0; // this is where we would handle trailing whitespace on the input string. // peel [unit] off the end of the string i = 0; if (goodString == UnitStrings[i].Name) { strLenUnit = UnitStrings[i].Name.Length; unit = UnitStrings[i].UnitType; } else { for (i = 1; i < UnitStrings.Length; ++i) { // Note: this is NOT a culture specific comparison. // this is by design: we want the same unit string table to work across all cultures. if (goodString.EndsWith(UnitStrings[i].Name, StringComparison.Ordinal)) { strLenUnit = UnitStrings[i].Name.Length; unit = UnitStrings[i].UnitType; break; } } } // we couldn't match a real unit from FigureUnitTypes. // try again with a converter-only unit (a pixel equivalent). if (i >= UnitStrings.Length) { for (i = 0; i < PixelUnitStrings.Length; ++i) { // Note: this is NOT a culture specific comparison. // this is by design: we want the same unit string table to work across all cultures. if (goodString.EndsWith(PixelUnitStrings[i], StringComparison.Ordinal)) { strLenUnit = PixelUnitStrings[i].Length; unitFactor = PixelUnitFactors[i]; break; } } } // this is where we would handle leading whitespace on the input string. // this is also where we would handle whitespace between [value] and [unit]. // check if we don't have a [value]. This is acceptable for certain UnitTypes. if (strLen == strLenUnit && unit != FigureUnitType.Pixel) { value = 1; } // we have a value to parse. else { Debug.Assert(unit == FigureUnitType.Pixel || DoubleUtil.AreClose(unitFactor, 1.0)); ReadOnlySpan <char> valueString = goodString.AsSpan(0, strLen - strLenUnit); value = double.Parse(valueString, provider: cultureInfo) * unitFactor; } }
internal FigureUnitTypeStringConvert(string name, FigureUnitType unitType) { Name = name; UnitType = unitType; }
// Parse a FigureLength from a string given the CultureInfo. static internal void FromString( string s, CultureInfo cultureInfo, out double value, out FigureUnitType unit) { string goodString = s.Trim().ToLowerInvariant(); value = 0.0; unit = FigureUnitType.Pixel; int i; int strLen = goodString.Length; int strLenUnit = 0; double unitFactor = 1.0; // this is where we would handle trailing whitespace on the input string. // peel [unit] off the end of the string i = 0; if (goodString == UnitStrings[i].Name) { strLenUnit = UnitStrings[i].Name.Length; unit = UnitStrings[i].UnitType; } else { for (i = 1; i < UnitStrings.Length; ++i) { // Note: this is NOT a culture specific comparison. // this is by design: we want the same unit string table to work across all cultures. if (goodString.EndsWith(UnitStrings[i].Name, StringComparison.Ordinal)) { strLenUnit = UnitStrings[i].Name.Length; unit = UnitStrings[i].UnitType; break; } } } // we couldn't match a real unit from FigureUnitTypes. // try again with a converter-only unit (a pixel equivalent). if (i >= UnitStrings.Length) { for (i = 0; i < PixelUnitStrings.Length; ++i) { // Note: this is NOT a culture specific comparison. // this is by design: we want the same unit string table to work across all cultures. if (goodString.EndsWith(PixelUnitStrings[i], StringComparison.Ordinal)) { strLenUnit = PixelUnitStrings[i].Length; unitFactor = PixelUnitFactors[i]; break; } } } // this is where we would handle leading whitespace on the input string. // this is also where we would handle whitespace between [value] and [unit]. // check if we don't have a [value]. This is acceptable for certain UnitTypes. if (strLen == strLenUnit && unit != FigureUnitType.Pixel) { value = 1; } // we have a value to parse. else { Debug.Assert( unit == FigureUnitType.Pixel || DoubleUtil.AreClose(unitFactor, 1.0) ); string valueString = goodString.Substring(0, strLen - strLenUnit); value = Convert.ToDouble(valueString, cultureInfo) * unitFactor; } }
public FigureLength(double value, FigureUnitType type) { Contract.Ensures(!double.IsInfinity(value)); }