Browse Source

PropertyGrid EnumComboBoxEditor: removed values with Browsable attribute

pull/1645/head
brianlagunas_cp 16 years ago
parent
commit
4ee183976b
  1. 12
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/EnumComboBoxEditor.cs

12
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/EnumComboBoxEditor.cs

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.ComponentModel;
namespace Microsoft.Windows.Controls.PropertyGrid.Editors namespace Microsoft.Windows.Controls.PropertyGrid.Editors
{ {
@ -14,11 +15,20 @@ namespace Microsoft.Windows.Controls.PropertyGrid.Editors
private static object[] GetValues(Type enumType) private static object[] GetValues(Type enumType)
{ {
List<object> values = new List<object>(); List<object> values = new List<object>();
var fields = enumType.GetFields().Where(x => x.IsLiteral); var fields = enumType.GetFields().Where(x => x.IsLiteral);
foreach (FieldInfo field in fields) foreach (FieldInfo field in fields)
{ {
// Get array of BrowsableAttribute attributes
object[] attrs = field.GetCustomAttributes(typeof(BrowsableAttribute), false);
if (attrs.Length == 1)
{
// If attribute exists and its value is false continue to the next field...
BrowsableAttribute brAttr = (BrowsableAttribute)attrs[0];
if (brAttr.Browsable == false) continue;
}
values.Add(field.GetValue(enumType)); values.Add(field.GetValue(enumType));
} }

Loading…
Cancel
Save