1 | using System;
|
---|
2 |
|
---|
3 | namespace SharpVectors.Dom.Svg
|
---|
4 | {
|
---|
5 | public abstract class SvgPathSeg : ISvgPathSeg
|
---|
6 | {
|
---|
7 | #region Private Fields
|
---|
8 |
|
---|
9 | private int _index;
|
---|
10 | private SvgPathSegList _list;
|
---|
11 | private SvgPathSegType _type;
|
---|
12 |
|
---|
13 | #endregion
|
---|
14 |
|
---|
15 | #region Constructors
|
---|
16 |
|
---|
17 | protected SvgPathSeg(SvgPathSegType type)
|
---|
18 | {
|
---|
19 | this._type = type;
|
---|
20 | }
|
---|
21 |
|
---|
22 | #endregion
|
---|
23 |
|
---|
24 | #region Public Properties
|
---|
25 |
|
---|
26 | public abstract string PathText { get; }
|
---|
27 | public abstract SvgPointF AbsXY { get; }
|
---|
28 | public abstract double StartAngle { get; }
|
---|
29 | public abstract double EndAngle { get; }
|
---|
30 |
|
---|
31 | public SvgPathSeg PreviousSeg
|
---|
32 | {
|
---|
33 | get
|
---|
34 | {
|
---|
35 | return _list.GetPreviousSegment(this);
|
---|
36 | }
|
---|
37 | }
|
---|
38 |
|
---|
39 | public SvgPathSeg NextSeg
|
---|
40 | {
|
---|
41 | get
|
---|
42 | {
|
---|
43 | return _list.GetNextSegment(this);
|
---|
44 | }
|
---|
45 | }
|
---|
46 |
|
---|
47 | public int Index
|
---|
48 | {
|
---|
49 | get
|
---|
50 | {
|
---|
51 | return _index;
|
---|
52 | }
|
---|
53 | }
|
---|
54 |
|
---|
55 | public virtual double Length
|
---|
56 | {
|
---|
57 | get
|
---|
58 | {
|
---|
59 | return 0;
|
---|
60 | }
|
---|
61 | }
|
---|
62 |
|
---|
63 | #endregion
|
---|
64 |
|
---|
65 | #region Internal Methods
|
---|
66 |
|
---|
67 | internal void SetList(SvgPathSegList list)
|
---|
68 | {
|
---|
69 | this._list = list;
|
---|
70 | }
|
---|
71 |
|
---|
72 | internal void SetIndex(int index)
|
---|
73 | {
|
---|
74 | this._index = index;
|
---|
75 | }
|
---|
76 |
|
---|
77 | internal void SetIndexWithDiff(int diff)
|
---|
78 | {
|
---|
79 | this._index += diff;
|
---|
80 | }
|
---|
81 |
|
---|
82 | #endregion
|
---|
83 |
|
---|
84 | #region ISvgPathSeg Members
|
---|
85 |
|
---|
86 | public SvgPathSegType PathSegType
|
---|
87 | {
|
---|
88 | get
|
---|
89 | {
|
---|
90 | return _type;
|
---|
91 | }
|
---|
92 | }
|
---|
93 |
|
---|
94 | public string PathSegTypeAsLetter
|
---|
95 | {
|
---|
96 | get
|
---|
97 | {
|
---|
98 | switch(_type)
|
---|
99 | {
|
---|
100 | case SvgPathSegType.ArcAbs:
|
---|
101 | return "A";
|
---|
102 | case SvgPathSegType.ArcRel:
|
---|
103 | return "a";
|
---|
104 | case SvgPathSegType.ClosePath:
|
---|
105 | return "z";
|
---|
106 | case SvgPathSegType.CurveToCubicAbs:
|
---|
107 | return "C";
|
---|
108 | case SvgPathSegType.CurveToCubicRel:
|
---|
109 | return "c";
|
---|
110 | case SvgPathSegType.CurveToCubicSmoothAbs:
|
---|
111 | return "S";
|
---|
112 | case SvgPathSegType.CurveToCubicSmoothRel:
|
---|
113 | return "s";
|
---|
114 | case SvgPathSegType.CurveToQuadraticAbs:
|
---|
115 | return "Q";
|
---|
116 | case SvgPathSegType.CurveToQuadraticRel:
|
---|
117 | return "q";
|
---|
118 | case SvgPathSegType.CurveToQuadraticSmoothAbs:
|
---|
119 | return "T";
|
---|
120 | case SvgPathSegType.CurveToQuadraticSmoothRel:
|
---|
121 | return "t";
|
---|
122 | case SvgPathSegType.LineToAbs:
|
---|
123 | return "L";
|
---|
124 | case SvgPathSegType.LineToHorizontalAbs:
|
---|
125 | return "H";
|
---|
126 | case SvgPathSegType.LineToHorizontalRel:
|
---|
127 | return "h";
|
---|
128 | case SvgPathSegType.LineToRel:
|
---|
129 | return "l";
|
---|
130 | case SvgPathSegType.LineToVerticalAbs:
|
---|
131 | return "V";
|
---|
132 | case SvgPathSegType.LineToVerticalRel:
|
---|
133 | return "v";
|
---|
134 | case SvgPathSegType.MoveToAbs:
|
---|
135 | return "M";
|
---|
136 | case SvgPathSegType.MoveToRel:
|
---|
137 | return "m";
|
---|
138 | default:
|
---|
139 | return String.Empty;
|
---|
140 | }
|
---|
141 | }
|
---|
142 | }
|
---|
143 |
|
---|
144 | #endregion
|
---|
145 | }
|
---|
146 | }
|
---|