Wednesday, January 30, 2008

Timeline Of Angelfish Reproduction

Incorporate property sheets (PropertyGrid) to our projects

image PropertyGrid control (sheet or property) is a component that we include in our projects, as editor of properties of controls or objects contained therein. Its use allows us to modify the value of a property at run time, the same way as the Properties window of Visual Studio IDE allows us to do at design time.

Its structure consists of two columns and many rows, as properties in control or the associated object. The first column contains the name of the property and the actual value thereof. These values \u200b\u200bcan be entered directly or through the appropriate editor who vary depending on the type of value.

PropertyGrid control allows us to provide greater functionality to our applications, is an interesting way to mechanize the handling properties, and offers users the ability to customize those aspects for which had been scheduled.

PropertyGrid ADDING OUR CONTROL PROJECT

First we add to our project a PropertyGrid control . This we can do with the following line of code. PropertyGrid

HojaPropiedades = new PropertyGrid ();

CONTROLS AND OBJECTS ASSOCIATED

As mentioned above, a PropertyGrid control is typically associated with a control (instance of a class belonging to Visual Studio or other third-suite), or an object (instance of a class created by us). The associated control or object is selected using the property SelectedObject, and how value is entered the name of the elected body.

HojaPropiedades.SelectedObject = Label1; / / Set the properties of Label1 control

HojaPropiedades.SelectedObject = Button1; / / Set the Button1 control's properties

HojaPropiedades.SelectedObject = Entidad3D ; / / Set the object properties Entidad3D

In first two cases, control HojaPropiedades show the properties of each of the associated controls. In the third case, the properties would be shown that the derived class Entidad3D instance, had declared.

DEFINING THE PROPERTIES OF A CLASS

To set a property within a class using the following syntax:

 [  Property Attributes]  TipoPropiedad   propertyName {{ September   for writing code values \u200b\u200b } {  get code to read values}}   
   

So in this way, the class definition Entidad3D , would be as follows.

  1:    public class   Entidad3D 
  2: { 
  3:   / / / The following fields are private fields  properties 
  4:   / / / visible in the property sheet.  
  5:   / / / General category  
  6:   private string    _Name; 
  7:   private string    _Clase; 
  8 :   private  Color _ColorLineas = SystemColors.ControlLight; 
  9:   private  Color _ColorFondo = SystemColors.ControlDarkDark; 
  10:   private string    _Group; 
  11:   / / / category XYZ coordinates  
  12:   private  XYZ = _Coordenadas   new XYZ (); 
  13:   private  XYZ = _CoordenadasEjes   new XYZ ();  



     14:             /// categoría Modificadores 3D   



     15:             private     float   _EscalaX; 



     16:             private     float   _EscalaY; 



     17:             private     float   _EscalaZ; 



     18:             private     float   _RotacionX; 



     19:             private     float   _RotacionY; 
  20:     private float  _RotacionZ; 
  21:   / / / Categoria United  
  22:     private bool  _Activada; 
  23:     private bool  _Visible; 
  24:   private  Font  _Fuente =  new Font ( "Arial" , 8, FontStyle.Regular); 
  25:  
  26:   / / / Definition of the code for properties  
  27:  [CategoryAttribute ( "General" ) 
  28:  DescriptionAttribute ( "Set the name for the instance of the class." ) 
  29:  DefaultValueAttribute ( "Entity" )] 
  30:      public string Name 
  31:  
  {32: get {   _Name return;} 
  33:  _Name set {value =  ;} 
  34 :}  
  35:  [CategoryAttribute ( "General" ) 
  36:  DescriptionAttribute ( "Shows the name of the source class." )  



     37:           ReadOnlyAttribute(  true  )] 



     38:             public     string   Clase 



     39:           { 



     40:               get{  return   _Clase;} 



     41:               set { _Clase =   value  ; } 



     42:           } 



     43:           [CategoryAttribute(  "General"  ) 
  44:  DescriptionAttribute ( "Set the color of the lines in the wireframe." )] 
  45: Color  public   ColorLines 
  46: { 
  47: get {   _ColorLineas return;} 
  48:  _ColorLineas set {value =  ;} 
  49:}  
  50:  [CategoryAttribute ( "General" ) 
  51:  DescriptionAttribute ( "Set the background color in wireframe." )] 
  52:   Color  ColorFondo 
public
  53: { 
  54: get {   _ColorFondo return;} 
  55:  _ColorFondo set {value =  ;} 
  56:}  
  57:  [CategoryAttribute ( "General" ) 
  58:  DescriptionAttribute ( "shows the group to which the entity." ) , 
  59:  DefaultValueAttribute ( "None" ) 
  60:  ReadOnlyAttribute (  true)] 
  61: public      string 
  Group 62:  
  {63: get {   _Grupo return;} 
  64:  _Grupo set {value =  ;} 
  65:  
 } 66:  [CategoryAttribute ( "XYZ" ) 
  67:  DescriptionAttribute ( "Deploy to establish the coordinates of the entity." ) 
  68:  DefaultValueAttribute ( "0, 0, 0" )] 
  69:   public  XYZ coordinates 
  70: { 
  71:  get {return   _Coordenadas;} 
  72:  _Coordenadas set {value =  ;} 
  73:}  
  74:  [CategoryAttribute (  "Coordenadas XYZ" )] 
  75:   public  XYZ CoordenadasEjes 
  76: { 
  77: get {   _CoordenadasEjes return;} 
  78:  _CoordenadasEjes set {value =  ;} 
  79:}  
  80:  [category attribute ( "Modificadores 3D" )] 
     81:             public     float   EscalaX 



     82:           { 



     83:               get{  return   _EscalaX;} 



     84:               set{_EscalaX =   value  ;} 



     85:           } 



     86:           [CategoryAttribute(  "Modificadores 3D"  )] 



     87:             public     float   EscalaY  



     88:           { 



     89:               get{  return   _EscalaY;} 



     90:               set{_EscalaY =   value  ;} 



     91:           } 



     92:           [CategoryAttribute(  "Modificadores 3D"  )] 



     93:             public     float   EscalaZ 



     94:           { 



     95:               get{  return   _EscalaZ;} 



     96:               set{_EscalaZ =   value  ;} 



     97:           } 



     98:           [CategoryAttribute(  "Modificadores 3D"  )] 



     99:             public     float   RotacionX 



    100:           { 



    101:               get{  return   _RotacionX;}  



    102:               set{_RotacionX =   value  ;} 



    103:           } 



    104:           [CategoryAttribute(  "Modificadores 3D"  )] 



    105:             public     float   RotacionY 



    106:           { 



    107:               get{  return   _RotacionY;} 



    108:               set{_RotacionY  =   value  ;} 



    109:           } 



    110:           [CategoryAttribute(  "Modificadores 3D"  )] 



    111:             public     float   RotacionZ 



    112:           { 



    113:               get{  return   _RotacionZ;} 



    114:               set{_RotacionZ =   value  ;} 



    115:  } 
  116:  [category attribute ( "Estados" )] 
  117:   public bool    Activada 
  118: { 
  119: get {   _Activada return;} 
  120:  _Activada set {value =  ;} 
  121:}  
  122:  [category attribute (  "Estados" )] 
  123:     public bool Visible  
  124: { 
  125: get {   _visible return;} 
  126 :  _visible set {value =  ;} 
  127:}  
  128:   public  Font Fuente 
  129: { 
  130: get {   _Fuente return;} 
  131:  _Fuente set {value =  ;} 
  132:  
 } 133:}  
& # 160;
ATTRIBUTES OF PROPERTIES

The definition of class properties Entidad3D , have used some special attributes. This is due, that we may set certain characteristics of properties of the classes whose objects associated with a PropertyGrid control by optional attributes included in the System.ComponentModel space. These attributes are as follows.

  • CategoryAttribute (String) classifies properties into groups.

  • DescriptionAttribute (String) descriptive text that appears in the bottom of the PropertyGrid when you select the property.

  • BrowsableAttribute (Boolean) Determines if the property is or is not in control. The default value is True (True).

  • ReadOnlyAttribute (Boolean) allows or prohibits the user to edit the property to enter values. The default value is False (false).

  • DefaultValueAttribute (Object) Sets the default value of the property.

  • DefaultPropertyAttribute (String) This attribute does not apply to a property but to the class. Sets the property that is selected when the object is given control.

FINAL RESULT image The result of the foregoing in the above lines would be a property sheet object Entidad3D , as we see in the image on the right.

I hope you liked it.

A greeting and to another.




0 comments:

Post a Comment