using System; using System.ComponentModel; using System.Drawing; namespace Netron.Diagramming.Core { /// /// Abstract base class for all descriptors of diagram entities inheriting from . /// This descriptor collects all properties common to all the entities inheriting from the interface. /// abstract class DiagramEntityBaseDescriptor : DescriptorBase { #region Constants /// /// the 'Layout' section /// protected const string constLayout = "Layout"; /// /// the 'General' section /// protected const string constGeneral = "General"; /// /// the 'content' section /// protected const string constContent = "Content"; #endregion #region Fields #endregion #region Properties #endregion #region Constructor /// /// Initializes a new instance of the class. /// /// The provider. /// Type of the object. public DiagramEntityBaseDescriptor(TypeDescriptionProvider provider, Type objectType) : base(provider, objectType) { AddBaseProperties(); } #endregion #region Methods /// /// Adds the base properties of the /// private void AddBaseProperties() { this.AddProperty("Entity Name", typeof(string), constGeneral, "The name of the type"); this.AddProperty("Name", typeof(string), constGeneral, "The name of the entity"); this.AddProperty("Rectangle", typeof(Rectangle), constLayout, "The bounding rectangle of the entity"); this.AddProperty("Scene index", typeof(int), constLayout, "The index of the entity in the scane graph."); this.AddProperty("Tag", typeof(object), constLayout, "General purpose tag."); } /// /// Override this method to return the appropriate value corresponding to the property /// /// /// protected override void GetValue(object sender, PropertyEventArgs e) { switch (e.Name.ToLower()) { case "entity name": e.Value = (e.Component as DiagramEntityBase).EntityName; break; case "name": e.Value = (e.Component as DiagramEntityBase).Name; break; case "rectangle": e.Value = (e.Component as DiagramEntityBase).Rectangle; break; case "scene index": e.Value = (e.Component as DiagramEntityBase).SceneIndex; break; case "tag": e.Value = (e.Component as DiagramEntityBase).Tag; break; } } /// /// Override this method to set the appropriate value corresponding to the property /// /// /// protected override void SetValue(object sender, PropertyEventArgs e) { switch (e.Name.ToLower()) { case "name": (e.Component as DiagramEntityBase).Name = (string)e.Value; break; case "tag": (e.Component as DiagramEntityBase).Tag = (object)e.Value; break; } } #endregion } }