1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
[CategoryAttribute( "Avant" ), DisplayName( "Afficher la courbe" )]
public bool m_bAfficherAv
{
get { return m_bAfficher[(int)EMPLACEMENT.AVANT]; }
set
{
m_bAfficher[(int)EMPLACEMENT.AVANT] = value;
m_plot[(int)EMPLACEMENT.AVANT].Visible = value;
m_plotxy[(int)EMPLACEMENT.AVANT].Visible = value;
DisabledCategory( !value );
if(m_theGrid != null)
m_theGrid.Refresh();
}
}
private void DisabledCategory( bool bvalue, [System.Runtime.CompilerServices.CallerMemberName] string name = "" )
{
PropertyDescriptorCollection desc = TypeDescriptor.GetProperties( this.GetType() );
string caterory = desc[name].Category;
foreach(PropertyDescriptor prop in desc)
{
if(prop.Category == caterory && prop.Name != name) // Permet de tous desactiver la catégorie sauf la property "Afficher la courbe"
{
Attribute att = prop.Attributes[typeof( ReadOnlyAttribute )];
if(att != null)
{
ReadOnlyAttribute ro = (ReadOnlyAttribute)att;
FieldInfo field = ro.GetType().GetField( "isReadOnly", BindingFlags.NonPublic | BindingFlags.Instance );
field.SetValue( ro, bvalue );
}
}
}
} |
Partager