Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/PropertySystem/Descriptors/ShapeBaseDescriptor.cs @ 4068

Last change on this file since 4068 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 2.7 KB
Line 
1using System;
2using System.Drawing;
3using System.Drawing.Design;
4namespace Netron.Diagramming.Core {
5  /// <summary>
6  /// Abstract base class for more specialized instances of the <see cref="ShapeBase"/> class.
7  /// </summary>
8  abstract class ShapeBaseDescriptor : DiagramEntityBaseDescriptor {
9
10    #region Constants
11    #endregion
12
13    #region Fields
14
15    #endregion
16
17    #region Properties
18
19    #endregion
20
21    #region Constructor
22    /// <summary>
23    /// Initializes a new instance of the <see cref="ShapeBaseDescriptor"/> class.
24    /// </summary>
25    /// <param name="provider">The provider.</param>
26    /// <param name="objectType">Type of the object.</param>
27    public ShapeBaseDescriptor(ShapeProvider provider, Type objectType)
28      : base(provider, objectType) {
29      AddBaseProperties();
30    }
31    #endregion
32
33    #region Methods
34    /// <summary>
35    /// Adds the properties of the <see cref="ShapeBase"/>
36    /// </summary>
37    private void AddBaseProperties() {
38      this.AddProperty("Width", typeof(int), constLayout, "The width of the shape.");
39      this.AddProperty("Height", typeof(int), constLayout, "The height of the shape.");
40      this.AddProperty("Location", typeof(Point), constLayout, "The location of the shape.", Point.Empty, typeof(UITypeEditor), typeof(Netron.Diagramming.Core.PointConverter));
41    }
42
43
44    /// <summary>
45    /// Override this method to return the appropriate value corresponding to the property
46    /// </summary>
47    /// <param name="sender"></param>
48    /// <param name="e"></param>
49    protected override void GetValue(object sender, PropertyEventArgs e) {
50      base.GetValue(sender, e);
51      switch (e.Name.ToLower()) {
52        case "width":
53          e.Value = (e.Component as ShapeBase).Width;
54          break;
55        case "height":
56          e.Value = (e.Component as ShapeBase).Height;
57          break;
58        case "location":
59          e.Value = (e.Component as ShapeBase).Location;
60          break;
61
62
63      }
64
65
66    }
67
68
69
70    /// <summary>
71    /// Override this method to set the appropriate value corresponding to the property
72    /// </summary>
73    /// <param name="sender"></param>
74    /// <param name="e"></param>
75    protected override void SetValue(object sender, PropertyEventArgs e) {
76      base.SetValue(sender, e);
77
78      switch (e.Name.ToLower()) {
79        case "width":
80          (e.Component as ShapeBase).Width = (int)e.Value;
81          break;
82        case "height":
83          (e.Component as ShapeBase).Height = (int)e.Value;
84          break;
85        case "location":
86          Point p = (Point)e.Value;
87          (e.Component as ShapeBase).Location = new Point(p.X, p.Y);
88          break;
89      }
90    }
91
92
93    #endregion
94  }
95}
Note: See TracBrowser for help on using the repository browser.