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:
1.5 KB
|
Line | |
---|
1 | using System;
|
---|
2 |
|
---|
3 | namespace Netron.Diagramming.Core {
|
---|
4 | /// <summary>
|
---|
5 | /// Shape factory for the internally defined shape types.
|
---|
6 | /// </summary>
|
---|
7 | public static class ShapeFactory {
|
---|
8 |
|
---|
9 | /// <summary>
|
---|
10 | /// Gets the shape.
|
---|
11 | /// </summary>
|
---|
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;
|
---|
17 |
|
---|
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 | }
|
---|
25 |
|
---|
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 | }
|
---|
51 |
|
---|
52 | }
|
---|
53 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.