Beispiel #1
0
 internal void InvokeConvertPropertyValueToString(ConvertValueEventArgs e)
 {
     OnConvertPropertyValueToString(e);
 }
Beispiel #2
0
 /// <summary>
 /// Raises the ConvertPropertyValueToString event.
 /// </summary>
 /// <param name="e">Provides event data</param>
 protected virtual void OnConvertPropertyValueToString(ConvertValueEventArgs e)
 {
     ConvertValueEventHandler handler = ConvertPropertyValueToString;
     if (handler != null)
         handler(this, e);
 }
Beispiel #3
0
 internal void InvokeConvertFromStringToPropertyValue(ConvertValueEventArgs e)
 {
     OnConvertFromStringToPropertyValue(e);
 }
Beispiel #4
0
 /// <summary>
 /// Raises the ConvertFromStringToPropertyValue event.
 /// </summary>
 /// <param name="e">Provides event data</param>
 protected virtual void OnConvertFromStringToPropertyValue(ConvertValueEventArgs e)
 {
     ConvertValueEventHandler handler = ConvertFromStringToPropertyValue;
     if (handler != null)
         handler(this, e);
 }
Beispiel #5
0
        protected virtual object GetValueFromString(string text, out Exception exception)
        {
            object value = null;
            exception = null;

            if (_PropertySettings != null && _PropertySettings.HasConvertFromStringToPropertyValueHandler)
            {
                ConvertValueEventArgs args = new ConvertValueEventArgs(text, null, GetPropertyName(), GetTargetComponent(), PropertyDescriptor);
                try
                {
                    _PropertySettings.InvokeConvertFromStringToPropertyValue(args);
                }
                catch (Exception e)
                {
                    exception = e;
                }
                if (args.IsConverted)
                    return args.TypedValue;
            }

            AdvPropertyGrid grid = AdvPropertyGrid;
            if (grid != null && grid.HasConvertFromStringToPropertyValueHandler)
            {
                ConvertValueEventArgs args = new ConvertValueEventArgs(text, null, GetPropertyName(), GetTargetComponent(), PropertyDescriptor);
                try
                {
                    grid.InvokeConvertFromStringToPropertyValue(args);
                }
                catch (Exception e)
                {
                    exception = e;
                }
                if (args.IsConverted)
                    return args.TypedValue;
            }

            TypeConverter conv = this.TypeConverter;
            try
            {
                value = conv.ConvertFromString(this, text);
            }
            catch (Exception e)
            {
                exception = e;
            }

            return value;
        }
Beispiel #6
0
        protected string GetPropertyTextValue(object propertyValue)
        {
            if (_PropertySettings != null && _PropertySettings.HasConvertPropertyValueToStringHandler)
            {
                ConvertValueEventArgs e = new ConvertValueEventArgs(null, propertyValue, GetPropertyName(), GetTargetComponent(), PropertyDescriptor);
                _PropertySettings.InvokeConvertPropertyValueToString(e);
                if (e.IsConverted && e.StringValue != null)
                    return e.StringValue;
            }

            AdvPropertyGrid grid = AdvPropertyGrid;
            if (grid != null && grid.HasConvertPropertyValueToStringHandler)
            {
                ConvertValueEventArgs e = new ConvertValueEventArgs(null, propertyValue, GetPropertyName(), GetTargetComponent(), PropertyDescriptor);
                grid.InvokeConvertPropertyValueToString(e);
                if (e.IsConverted && e.StringValue != null)
                    return e.StringValue;
            }

            string textValue = null;
            TypeConverter typeConverter = this.TypeConverter;
            try
            {
                textValue = typeConverter.ConvertToString(this, propertyValue);
            }
            catch (Exception)
            {
            }
            if (textValue == null)
            {
                textValue = string.Empty;
            }
            if (IsPassword)
            {
                textValue = StringHelper.Repeat(AdvPropertyGrid.PasswordChar, textValue.Length);
            }
            return textValue;
        }