Пример #1
0
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType == null)
     {
         throw new ArgumentNullException("destinationType");
     }
     if (value != null && value is DataGridLength)
     {
         DataGridLength length = (DataGridLength)value;
         if (destinationType == typeof(string))
         {
             return(DataGridLengthConverter.ConvertToString(length, culture));
         }
         if (destinationType == typeof(InstanceDescriptor))
         {
             ConstructorInfo constructor = typeof(DataGridLength).GetConstructor(new Type[]
             {
                 typeof(double),
                 typeof(DataGridLengthUnitType)
             });
             return(new InstanceDescriptor(constructor, new object[]
             {
                 length.Value,
                 length.UnitType
             }));
         }
     }
     throw base.GetConvertToException(value, destinationType);
 }
Пример #2
0
 /// <summary>Converts the specified object to an instance of the <see cref="T:System.Windows.Controls.DataGridLength" /> class.</summary>
 /// <param name="context">An object that provides a format context.</param>
 /// <param name="culture">The object to use as the current culture.</param>
 /// <param name="value">The value to convert.</param>
 /// <returns>The converted value.</returns>
 /// <exception cref="T:System.ArgumentNullException">
 ///         <paramref name="value" /> is <see langword="null" />.</exception>
 /// <exception cref="T:System.ArgumentException">
 ///         <paramref name="value" /> is not a valid type that can be converted to type <see cref="T:System.Windows.Controls.DataGridLength" />.</exception>
 // Token: 0x0600491E RID: 18718 RVA: 0x0014B6F4 File Offset: 0x001498F4
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     if (value != null)
     {
         string text = value as string;
         if (text != null)
         {
             return(DataGridLengthConverter.ConvertFromString(text, culture));
         }
         double num = Convert.ToDouble(value, culture);
         DataGridLengthUnitType type;
         if (DoubleUtil.IsNaN(num))
         {
             num  = 1.0;
             type = DataGridLengthUnitType.Auto;
         }
         else
         {
             type = DataGridLengthUnitType.Pixel;
         }
         if (!double.IsInfinity(num))
         {
             return(new DataGridLength(num, type));
         }
     }
     throw base.GetConvertFromException(value);
 }
Пример #3
0
        private DataGridLength ParseWidth(string defaultWidth)
        {
            if (string.IsNullOrEmpty(defaultWidth))
                return new DataGridLength(100);

            var converter = new DataGridLengthConverter();
            return (DataGridLength)converter.ConvertFromString(defaultWidth);
        }
 /// <summary>Returns a string that represents the current object.</summary>
 /// <returns>A string that represent the current object.</returns>
 // Token: 0x06004916 RID: 18710 RVA: 0x0014B5F9 File Offset: 0x001497F9
 public override string ToString()
 {
     return(DataGridLengthConverter.ConvertToString(this, CultureInfo.InvariantCulture));
 }
Пример #5
0
 public DataGridLengthConverter()
 {
     internalDataGridLengthConverter = new InternalDataGridLengthConverter();
 }