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/SimpleEllipse.cs @ 3038

Last change on this file since 3038 was 3038, checked in by mkommend, 14 years ago

removed warnings from HeuristicLab.Netron (ticket #915)

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