Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/PropertySystem/Descriptors/DiagramEntityBaseDescriptor.cs @ 13400

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

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

File size: 3.4 KB
Line 
1using System;
2using System.ComponentModel;
3using System.Drawing;
4namespace 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
12    /// <summary>
13    /// the 'Layout' section
14    /// </summary>
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
25
26    #region Fields
27
28    #endregion
29
30    #region Properties
31
32    #endregion
33
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
45
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    }
57
58
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      }
82
83
84    }
85
86
87
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    }
103
104
105    #endregion
106  }
107}
Note: See TracBrowser for help on using the repository browser.