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/Diagram elements/Shapes/SimpleRectangle.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: 6.4 KB
Line 
1using System.Drawing;
2namespace Netron.Diagramming.Core {
3  // ----------------------------------------------------------------------
4  /// <summary>
5  /// A simple rectangular shape.
6  /// </summary>
7  // ----------------------------------------------------------------------
8  [Shape(
9      "Rectangle",
10      "SimpleRectangle",
11      "Standard",
12      "A simple rectangular shape.")]
13  public partial class SimpleRectangle : SimpleShapeBase {
14    #region Fields
15
16    // ------------------------------------------------------------------
17    /// <summary>
18    /// Implementation of IVersion - the current version of
19    /// SimpleRectangle.
20    /// </summary>
21    // ------------------------------------------------------------------
22    protected const double simpleRectangleVersion = 1.0;
23
24    // ------------------------------------------------------------------
25    /// <summary>
26    /// The bottom connector.
27    /// </summary>
28    // ------------------------------------------------------------------
29    //Connector cBottom;
30
31    // ------------------------------------------------------------------
32    /// <summary>
33    /// The left connector.
34    /// </summary>
35    // ------------------------------------------------------------------
36    //Connector cLeft;
37
38    // ------------------------------------------------------------------
39    /// <summary>
40    /// The right connector.
41    /// </summary>
42    // ------------------------------------------------------------------
43    //Connector cRight;
44
45    // ------------------------------------------------------------------
46    /// <summary>
47    /// The top connector.
48    /// </summary>
49    // ------------------------------------------------------------------
50    //Connector cTop;
51
52    #endregion
53
54    #region Properties
55
56    // ------------------------------------------------------------------
57    /// <summary>
58    /// Gets the current version.
59    /// </summary>
60    // ------------------------------------------------------------------
61    public override double Version {
62      get {
63        return simpleRectangleVersion;
64      }
65    }
66
67    // ------------------------------------------------------------------
68    /// <summary>
69    /// Gets the friendly name of the entity to be displayed in the UI
70    /// </summary>
71    /// <value>string</value>
72    // ------------------------------------------------------------------
73    public override string EntityName {
74      get { return "Simple Rectangle"; }
75    }
76
77    public override Rectangle Rectangle {
78      get {
79        return base.Rectangle;
80      }
81    }
82
83    #endregion
84
85    #region Constructor
86
87    // ------------------------------------------------------------------
88    /// <summary>
89    /// Default constructor.
90    /// </summary>
91    /// <param name="s"></param>
92    // ------------------------------------------------------------------
93    public SimpleRectangle(IModel s)
94      : base(s) {
95    }
96
97    // ------------------------------------------------------------------
98    /// <summary>
99    /// Initializes a new instance of the
100    /// <see cref="T:SimpleRectangle"/> class.
101    /// </summary>
102    // ------------------------------------------------------------------
103    public SimpleRectangle()
104      : base() {
105    }
106
107    #endregion
108
109    #region Methods
110
111    // -----------------------------------------------------------------
112    /// <summary>
113    /// Initializes this instance.
114    /// </summary>
115    // -----------------------------------------------------------------
116    protected override void Initialize() {
117      base.Initialize();
118      //the initial size
119      Transform(0, 0, 200, 50);
120      this.mTextArea = Rectangle;
121
122      // I'm changing the "simple" shapes to have no connectors.
123      #region Connectors
124      //cTop = new Connector(new Point((int)(Rectangle.Left + Rectangle.Width / 2), Rectangle.Top), Model);
125      //cTop.Name = "Top connector";
126      //cTop.Parent = this;
127      //Connectors.Add(cTop);
128
129      //cRight = new Connector(new Point(Rectangle.Right, (int)(Rectangle.Top + Rectangle.Height / 2)), Model);
130      //cRight.Name = "Right connector";
131      //cRight.Parent = this;
132      //Connectors.Add(cRight);
133
134      //cBottom = new Connector(new Point((int)(Rectangle.Left + Rectangle.Width / 2), Rectangle.Bottom), Model);
135      //cBottom.Name = "Bottom connector";
136      //cBottom.Parent = this;
137      //Connectors.Add(cBottom);
138
139      //cLeft = new Connector(new Point(Rectangle.Left, (int)(Rectangle.Top + Rectangle.Height / 2)), Model);
140      //cLeft.Name = "Left connector";
141      //cLeft.Parent = this;
142      //Connectors.Add(cLeft);
143      #endregion
144    }
145
146    // ------------------------------------------------------------------
147    /// <summary>
148    /// Paints the bundle on the canvas
149    /// </summary>
150    /// <param name="g">Graphics: The GDI+ graphics surface.</param>
151    // ------------------------------------------------------------------
152    public override void Paint(Graphics g) {
153      // Draw the shadow.
154      if (ArtPalette.EnableShadows) {
155        g.FillRectangle(
156            ArtPalette.ShadowBrush,
157            mRectangle.X + 5,
158            mRectangle.Y + 5,
159            mRectangle.Width,
160            mRectangle.Height);
161      }
162
163      // Fill the shape.
164      g.FillRectangle(Brush, mRectangle);
165
166      // Draw the edge of the bundle.
167      if (Hovered) {
168        g.DrawRectangle(ArtPalette.HighlightPen, mRectangle);
169      } else {
170        g.DrawRectangle(Pen, mRectangle);
171      }
172
173      // Finally, the connectors.
174      if (this.ShowConnectors) {
175        for (int k = 0; k < Connectors.Count; k++) {
176          Connectors[k].Paint(g);
177        }
178      }
179
180      //here we keep it really simple:
181      if (!string.IsNullOrEmpty(Text)) {
182        //StringFormat format = new StringFormat();
183        //format.Alignment = this.VerticalAlignment;
184        //format.LineAlignment = this.HorizontalAlignment;
185        //SolidBrush textBrush = new SolidBrush(mForeColor);
186
187        //g.DrawString(
188        //    Text,
189        //    mFont,
190        //    textBrush,
191        //    TextArea,
192        //    format);
193        g.DrawString(
194            mTextStyle.GetFormattedText(Text),
195            mTextStyle.Font,
196            mTextStyle.GetBrush(),
197            TextArea,
198            mTextStyle.StringFormat);
199      }
200    }
201
202    #endregion
203  }
204}
Note: See TracBrowser for help on using the repository browser.