Пример #1
0
 /// <summary>
 /// Raises the ProvidePropertyValueList event.
 /// </summary>
 /// <param name="e">Provides event data</param>
 protected virtual void OnProvidePropertyValueList(PropertyValueListEventArgs e)
 {
     PropertyValueListEventHandler handler = ProvidePropertyValueList;
     if (handler != null)
         handler(this, e);
 }
Пример #2
0
 internal void InvokeProvidePropertyValueList(PropertyValueListEventArgs e)
 {
     OnProvidePropertyValueList(e);
 }
Пример #3
0
        protected virtual string[] GetPopupListContent()
        {
            if (_PropertySettings != null && _PropertySettings.HasProvidePropertyValueListHandler)
            {
                PropertyValueListEventArgs args = new PropertyValueListEventArgs(GetPropertyName(), GetTargetComponent(), PropertyDescriptor);
                _PropertySettings.InvokeProvidePropertyValueList(args);
                if (args.IsListValid)
                {
                    if (args.ValueList == null) return null;
                    return args.ValueList.ToArray();
                }
            }

            AdvPropertyGrid grid = AdvPropertyGrid;
            if (grid != null && grid.HasProvidePropertyValueListHandler)
            {
                PropertyValueListEventArgs args = new PropertyValueListEventArgs(GetPropertyName(), GetTargetComponent(), PropertyDescriptor);
                grid.InvokeProvidePropertyValueList(args);
                if (args.IsListValid)
                {
                    if (args.ValueList == null) return null;
                    return args.ValueList.ToArray();
                }
            }

            TypeConverter converter = this.TypeConverter;
            if(converter!=null && converter.GetStandardValuesSupported(this))
            {
                System.ComponentModel.TypeConverter.StandardValuesCollection stdValues = converter.GetStandardValues(this);
                if (stdValues != null && stdValues.Count > 0)
                {
                    string[] values = new string[stdValues.Count];
                    for (int i = 0; i < stdValues.Count; i++)
                    {
                        object item = stdValues[i];
                        values[i] = converter.ConvertToString(item);
                    }
                    return values;
                }
            }

            if (this.PropertyType.IsEnum)
            {
                return Enum.GetNames(this.PropertyType);
            }
            else if (this.PropertyType == typeof(bool))
            {
                string[] items = new string[2];
                
                if (converter != null && converter.CanConvertTo(typeof(string)))
                {
                    items[0] = (string)converter.ConvertTo(false, typeof(string));
                    items[1] = (string)converter.ConvertTo(true, typeof(string));
                }
                else
                {
                    items[0] = bool.FalseString;
                    items[1] = bool.TrueString;
                }
                return items;
            }
            return null;
        }