Free cookie consent management tool by TermsFeed Policy Generator

source: tags/3.3.12/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Diagram elements/Shapes/SimpleEllipse.cs @ 13398

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

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

File size: 4.8 KB
Line 
1using System.Drawing;
2using System.Drawing.Drawing2D;
3namespace Netron.Diagramming.Core {
4  /// <summary>
5  /// A simple elliptic shape
6  /// </summary>
7  [Shape("Ellipse", "SimpleEllipse", "Standard", "A simple elliptic shape.")]
8  partial class SimpleEllipse : SimpleShapeBase {
9    #region Fields
10
11    // ------------------------------------------------------------------
12    /// <summary>
13    /// Implementation of IVersion - the current version of
14    /// SimpleEllipse.
15    /// </summary>
16    // ------------------------------------------------------------------
17    protected const double simpleEllipseVersion = 1.0;
18
19    /// <summary>
20    /// the connectors
21    /// </summary>
22    //Connector cBottom, cLeft, cRight, cTop;
23    #endregion
24
25    #region Properties
26
27    // ------------------------------------------------------------------
28    /// <summary>
29    /// Gets the current version.
30    /// </summary>
31    // ------------------------------------------------------------------
32    public override double Version {
33      get {
34        return simpleEllipseVersion;
35      }
36    }
37
38    /// <summary>
39    /// Gets the friendly name of the entity to be displayed in the UI
40    /// </summary>
41    /// <value></value>
42    public override string EntityName {
43      get { return "Simple Ellipse"; }
44    }
45    #endregion
46
47    #region Constructor
48    /// <summary>
49    /// Default ctor
50    /// </summary>
51    /// <param name="s"></param>
52    public SimpleEllipse(IModel s)
53      : base(s) {
54    }
55
56    /// <summary>
57    /// Initializes a new instance of the <see cref="T:SimpleEllipse"/> class.
58    /// </summary>
59    public SimpleEllipse()
60      : base() {
61    }
62
63    #endregion
64
65    #region Methods
66
67    // -----------------------------------------------------------------
68    /// <summary>
69    /// Initializes this instance.
70    /// </summary>
71    // -----------------------------------------------------------------
72    protected override void Initialize() {
73      base.Initialize();
74
75      //the initial size
76      Transform(0, 0, 200, 50);
77      this.mTextArea = Rectangle;
78
79      // I'm changing the "simple" shapes to have no connectors.
80      #region Connectors
81      //cTop = new Connector(new Point((int)(Rectangle.Left + Rectangle.Width / 2), Rectangle.Top), Model);
82      //cTop.Name = "Top connector";
83      //cTop.Parent = this;
84      //Connectors.Add(cTop);
85
86      //cRight = new Connector(new Point(Rectangle.Right, (int)(Rectangle.Top + Rectangle.Height / 2)), Model);
87      //cRight.Name = "Right connector";
88      //cRight.Parent = this;
89      //Connectors.Add(cRight);
90
91      //cBottom = new Connector(new Point((int)(Rectangle.Left + Rectangle.Width / 2), Rectangle.Bottom), Model);
92      //cBottom.Name = "Bottom connector";
93      //cBottom.Parent = this;
94      //Connectors.Add(cBottom);
95
96      //cLeft = new Connector(new Point(Rectangle.Left, (int)(Rectangle.Top + Rectangle.Height / 2)), Model);
97      //cLeft.Name = "Left connector";
98      //cLeft.Parent = this;
99      //Connectors.Add(cLeft);
100      #endregion
101    }
102
103    /// <summary>
104    /// Tests whether the mouse hits this shape.
105    /// </summary>
106    /// <param name="p"></param>
107    /// <returns></returns>
108    public override bool Hit(Point p) {
109      GraphicsPath path = new GraphicsPath();
110      path.AddEllipse(Rectangle);
111      return path.IsVisible(p);
112    }
113
114    /// <summary>
115    /// Paints the bundle on the canvas
116    /// </summary>
117    /// <param name="g"></param>
118    public override void Paint(Graphics g) {
119      g.SmoothingMode = SmoothingMode.HighQuality;
120      //the shadow
121      if (ArtPalette.EnableShadows) {
122        g.FillEllipse(
123            ArtPalette.ShadowBrush,
124            Rectangle.X + 5,
125            Rectangle.Y + 5,
126            Rectangle.Width,
127            Rectangle.Height);
128      }
129
130      //the actual bundle
131      g.FillEllipse(mPaintStyle.GetBrush(Rectangle), Rectangle);
132
133      //the edge of the bundle
134      if (Hovered) {
135        g.DrawEllipse(ArtPalette.HighlightPen, Rectangle);
136      } else {
137        g.DrawEllipse(mPenStyle.DrawingPen(), Rectangle);
138      }
139      //the connectors
140      if (this.ShowConnectors) {
141        for (int k = 0; k < Connectors.Count; k++) {
142          Connectors[k].Paint(g);
143        }
144      }
145
146      //here we keep it really simple:
147      if (!string.IsNullOrEmpty(Text)) {
148        //g.DrawString(
149        //    Text,
150        //    ArtPalette.DefaultFont,
151        //    Brushes.Black,
152        //    TextArea);
153        g.DrawString(
154            mTextStyle.GetFormattedText(Text),
155            mTextStyle.Font,
156            mTextStyle.GetBrush(),
157            TextArea,
158            mTextStyle.StringFormat);
159      }
160    }
161
162
163
164
165
166    #endregion
167  }
168}
Note: See TracBrowser for help on using the repository browser.