Changeset 4068 for trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/PropertySystem/Descriptors/DiagramEntityBaseDescriptor.cs
- Timestamp:
- 07/22/10 00:44:01 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/PropertySystem/Descriptors/DiagramEntityBaseDescriptor.cs
r2768 r4068 1 1 using System; 2 using System.ComponentModel; 2 3 using System.Drawing; 3 using System.Collections.Generic; 4 using System.Text; 5 using System.ComponentModel; 6 using System.Drawing.Design; 7 namespace Netron.Diagramming.Core 8 { 4 namespace Netron.Diagramming.Core { 5 /// <summary> 6 /// Abstract base class for all descriptors of diagram entities inheriting from <see cref="DiagramEntityBase"/>. 7 /// This descriptor collects all properties common to all the entities inheriting from the <see cref="IDiagramEntity"/> interface. 8 /// </summary> 9 abstract class DiagramEntityBaseDescriptor : DescriptorBase { 10 11 #region Constants 9 12 /// <summary> 10 /// Abstract base class for all descriptors of diagram entities inheriting from <see cref="DiagramEntityBase"/>. 11 /// This descriptor collects all properties common to all the entities inheriting from the <see cref="IDiagramEntity"/> interface. 13 /// the 'Layout' section 12 14 /// </summary> 13 abstract class DiagramEntityBaseDescriptor : DescriptorBase 14 { 15 protected const string constLayout = "Layout"; 16 /// <summary> 17 /// the 'General' section 18 /// </summary> 19 protected const string constGeneral = "General"; 20 /// <summary> 21 /// the 'content' section 22 /// </summary> 23 protected const string constContent = "Content"; 24 #endregion 15 25 16 #region Constants 17 /// <summary> 18 /// the 'Layout' section 19 /// </summary> 20 protected const string constLayout = "Layout"; 21 /// <summary> 22 /// the 'General' section 23 /// </summary> 24 protected const string constGeneral = "General"; 25 /// <summary> 26 /// the 'content' section 27 /// </summary> 28 protected const string constContent = "Content"; 29 #endregion 26 #region Fields 30 27 31 #region Fields28 #endregion 32 29 33 #endregion30 #region Properties 34 31 35 #region Properties32 #endregion 36 33 37 #endregion 34 #region Constructor 35 /// <summary> 36 /// Initializes a new instance of the <see cref="DiagramEntityBaseDescriptor"/> class. 37 /// </summary> 38 /// <param name="provider">The provider.</param> 39 /// <param name="objectType">Type of the object.</param> 40 public DiagramEntityBaseDescriptor(TypeDescriptionProvider provider, Type objectType) 41 : base(provider, objectType) { 42 AddBaseProperties(); 43 } 44 #endregion 38 45 39 #region Constructor 40 /// <summary> 41 /// Initializes a new instance of the <see cref="DiagramEntityBaseDescriptor"/> class. 42 /// </summary> 43 /// <param name="provider">The provider.</param> 44 /// <param name="objectType">Type of the object.</param> 45 public DiagramEntityBaseDescriptor(TypeDescriptionProvider provider, Type objectType) 46 : base(provider, objectType) 47 { 48 AddBaseProperties(); 49 } 50 #endregion 51 52 #region Methods 53 /// <summary> 54 /// Adds the base properties of the <see cref="ShapeBase"/> 55 /// </summary> 56 private void AddBaseProperties() 57 { 58 this.AddProperty("Entity Name", typeof(string), constGeneral, "The name of the type"); 59 this.AddProperty("Name", typeof(string), constGeneral, "The name of the entity"); 60 this.AddProperty("Rectangle", typeof(Rectangle), constLayout, "The bounding rectangle of the entity"); 61 this.AddProperty("Scene index", typeof(int), constLayout, "The index of the entity in the scane graph."); 62 this.AddProperty("Tag", typeof(object), constLayout, "General purpose tag."); 63 } 46 #region Methods 47 /// <summary> 48 /// Adds the base properties of the <see cref="ShapeBase"/> 49 /// </summary> 50 private void AddBaseProperties() { 51 this.AddProperty("Entity Name", typeof(string), constGeneral, "The name of the type"); 52 this.AddProperty("Name", typeof(string), constGeneral, "The name of the entity"); 53 this.AddProperty("Rectangle", typeof(Rectangle), constLayout, "The bounding rectangle of the entity"); 54 this.AddProperty("Scene index", typeof(int), constLayout, "The index of the entity in the scane graph."); 55 this.AddProperty("Tag", typeof(object), constLayout, "General purpose tag."); 56 } 64 57 65 58 66 /// <summary> 67 /// Override this method to return the appropriate value corresponding to the property 68 /// </summary> 69 /// <param name="sender"></param> 70 /// <param name="e"></param> 71 protected override void GetValue(object sender, PropertyEventArgs e) 72 { 73 switch (e.Name.ToLower()) 74 { 75 case "entity name": 76 e.Value = (e.Component as DiagramEntityBase).EntityName; 77 break; 78 case "name": 79 e.Value = (e.Component as DiagramEntityBase).Name; 80 break; 81 case "rectangle": 82 e.Value = (e.Component as DiagramEntityBase).Rectangle; 83 break; 84 case "scene index": 85 e.Value = (e.Component as DiagramEntityBase).SceneIndex; 86 break; 87 case "tag": 88 e.Value = (e.Component as DiagramEntityBase).Tag; 89 break; 90 } 59 /// <summary> 60 /// Override this method to return the appropriate value corresponding to the property 61 /// </summary> 62 /// <param name="sender"></param> 63 /// <param name="e"></param> 64 protected override void GetValue(object sender, PropertyEventArgs e) { 65 switch (e.Name.ToLower()) { 66 case "entity name": 67 e.Value = (e.Component as DiagramEntityBase).EntityName; 68 break; 69 case "name": 70 e.Value = (e.Component as DiagramEntityBase).Name; 71 break; 72 case "rectangle": 73 e.Value = (e.Component as DiagramEntityBase).Rectangle; 74 break; 75 case "scene index": 76 e.Value = (e.Component as DiagramEntityBase).SceneIndex; 77 break; 78 case "tag": 79 e.Value = (e.Component as DiagramEntityBase).Tag; 80 break; 81 } 91 82 92 83 93 84 } 94 85 95 86 96 87 97 /// <summary> 98 /// Override this method to set the appropriate value corresponding to the property 99 /// </summary> 100 /// <param name="sender"></param> 101 /// <param name="e"></param> 102 protected override void SetValue(object sender, PropertyEventArgs e) 103 { 104 switch (e.Name.ToLower()) 105 { 106 case "name": 107 (e.Component as DiagramEntityBase).Name = (string)e.Value; 108 break; 109 case "tag": 110 (e.Component as DiagramEntityBase).Tag = (object) e.Value; 111 break; 112 } 113 } 88 /// <summary> 89 /// Override this method to set the appropriate value corresponding to the property 90 /// </summary> 91 /// <param name="sender"></param> 92 /// <param name="e"></param> 93 protected override void SetValue(object sender, PropertyEventArgs e) { 94 switch (e.Name.ToLower()) { 95 case "name": 96 (e.Component as DiagramEntityBase).Name = (string)e.Value; 97 break; 98 case "tag": 99 (e.Component as DiagramEntityBase).Tag = (object)e.Value; 100 break; 101 } 102 } 114 103 115 104 116 117 105 #endregion 106 } 118 107 }
Note: See TracChangeset
for help on using the changeset viewer.