Changeset 4068 for trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Diagram elements/Shapes/ShapeFactory.cs
- Timestamp:
- 07/22/10 00:44:01 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Diagram elements/Shapes/ShapeFactory.cs
r3038 r4068 1 1 using System; 2 using System.Collections.Generic;3 using System.Text;4 2 5 namespace Netron.Diagramming.Core 6 { 3 namespace Netron.Diagramming.Core { 4 /// <summary> 5 /// Shape factory for the internally defined shape types. 6 /// </summary> 7 public static class ShapeFactory { 8 7 9 /// <summary> 8 /// Shape factory for the internally defined shape types.10 /// Gets the shape. 9 11 /// </summary> 10 public static class ShapeFactory 11 { 12 /// <param name="shapeName">Name of the shape.</param> 13 /// <returns></returns> 14 public static IShape GetShape(string shapeName) { 15 if (string.IsNullOrEmpty(shapeName)) 16 return null; 12 17 13 /// <summary> 14 /// Gets the shape. 15 /// </summary> 16 /// <param name="shapeName">Name of the shape.</param> 17 /// <returns></returns> 18 public static IShape GetShape(string shapeName) 19 { 20 if(string.IsNullOrEmpty(shapeName)) 21 return null; 18 foreach (string shapeType in Enum.GetNames(typeof(ShapeTypes))) { 19 if (shapeType.ToString().ToLower() == shapeName.ToLower()) { 20 return GetShape((ShapeTypes)Enum.Parse(typeof(ShapeTypes), shapeType)); 21 } 22 } 23 return null; 24 } 22 25 23 foreach(string shapeType in Enum.GetNames(typeof(ShapeTypes))) 24 { 25 if(shapeType.ToString().ToLower() ==shapeName.ToLower()) 26 { 27 return GetShape((ShapeTypes) Enum.Parse(typeof(ShapeTypes), shapeType)); 28 } 29 } 30 return null; 31 } 26 /// <summary> 27 /// Gets the shape. 28 /// </summary> 29 /// <param name="shapeType">Type of the shape.</param> 30 /// <returns></returns> 31 public static IShape GetShape(ShapeTypes shapeType) { 32 switch (shapeType) { 33 case ShapeTypes.SimpleRectangle: 34 return new SimpleRectangle(); 35 case ShapeTypes.SimpleEllipse: 36 return new SimpleEllipse(); 37 case ShapeTypes.TextLabel: 38 return new TextLabel(); 39 case ShapeTypes.ClassShape: 40 return new ClassShape(); 41 case ShapeTypes.TextOnly: 42 return new TextOnly(); 43 case ShapeTypes.ImageShape: 44 return new ImageShape(); 45 case ShapeTypes.ComplexRectangle: 46 return new ComplexRectangle(); 47 default: 48 return null; 49 } 50 } 32 51 33 /// <summary> 34 /// Gets the shape. 35 /// </summary> 36 /// <param name="shapeType">Type of the shape.</param> 37 /// <returns></returns> 38 public static IShape GetShape(ShapeTypes shapeType) 39 { 40 switch(shapeType) 41 { 42 case ShapeTypes.SimpleRectangle: 43 return new SimpleRectangle(); 44 case ShapeTypes.SimpleEllipse: 45 return new SimpleEllipse(); 46 case ShapeTypes.TextLabel: 47 return new TextLabel(); 48 case ShapeTypes.ClassShape: 49 return new ClassShape(); 50 case ShapeTypes.TextOnly: 51 return new TextOnly(); 52 case ShapeTypes.ImageShape: 53 return new ImageShape(); 54 case ShapeTypes.ComplexRectangle: 55 return new ComplexRectangle(); 56 default: 57 return null; 58 } 59 } 60 61 } 52 } 62 53 }
Note: See TracChangeset
for help on using the changeset viewer.