using System; using System.Drawing; using System.Drawing.Design; namespace Netron.Diagramming.Core { /// /// Abstract base class for more specialized instances of the class. /// abstract class ShapeBaseDescriptor : DiagramEntityBaseDescriptor { #region Constants #endregion #region Fields #endregion #region Properties #endregion #region Constructor /// /// Initializes a new instance of the class. /// /// The provider. /// Type of the object. public ShapeBaseDescriptor(ShapeProvider provider, Type objectType) : base(provider, objectType) { AddBaseProperties(); } #endregion #region Methods /// /// Adds the properties of the /// private void AddBaseProperties() { this.AddProperty("Width", typeof(int), constLayout, "The width of the shape."); this.AddProperty("Height", typeof(int), constLayout, "The height of the shape."); this.AddProperty("Location", typeof(Point), constLayout, "The location of the shape.", Point.Empty, typeof(UITypeEditor), typeof(Netron.Diagramming.Core.PointConverter)); } /// /// Override this method to return the appropriate value corresponding to the property /// /// /// protected override void GetValue(object sender, PropertyEventArgs e) { base.GetValue(sender, e); switch (e.Name.ToLower()) { case "width": e.Value = (e.Component as ShapeBase).Width; break; case "height": e.Value = (e.Component as ShapeBase).Height; break; case "location": e.Value = (e.Component as ShapeBase).Location; break; } } /// /// Override this method to set the appropriate value corresponding to the property /// /// /// protected override void SetValue(object sender, PropertyEventArgs e) { base.SetValue(sender, e); switch (e.Name.ToLower()) { case "width": (e.Component as ShapeBase).Width = (int)e.Value; break; case "height": (e.Component as ShapeBase).Height = (int)e.Value; break; case "location": Point p = (Point)e.Value; (e.Component as ShapeBase).Location = new Point(p.X, p.Y); break; } } #endregion } }