Skip to content
This repository was archived by the owner on Mar 30, 2019. It is now read-only.

Commit ff84fb0

Browse files
committed
Add attribute getters
Fix Transform whic was setting the wrong type
1 parent c578030 commit ff84fb0

1 file changed

Lines changed: 171 additions & 1 deletion

File tree

Source/SharpDX.Direct2D1/SvgElement.cs

Lines changed: 171 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,19 @@ public unsafe void SetAttributeValue(string name, float value)
7171
SetAttributeValue(name, SvgAttributePodType.Float, new IntPtr(&value), sizeof(float));
7272
}
7373

74+
/// <summary>
75+
/// Gets a float attribute
76+
/// </summary>
77+
/// <param name="name">Attribute name</param>
78+
/// <param name="value">When this returns , contains the attribute value</param>
79+
public unsafe void GetAttributeValue(string name, out float value)
80+
{
81+
fixed (float* ptr = &value)
82+
{
83+
GetAttributeValue(name, SvgAttributePodType.Float, new IntPtr(ptr), sizeof(float));
84+
}
85+
}
86+
7487
/// <summary>
7588
/// Sets color attribute
7689
/// </summary>
@@ -81,6 +94,19 @@ public unsafe void SetAttributeValue(string name, RawColor4 color)
8194
SetAttributeValue(name, SvgAttributePodType.Color, new IntPtr(&color), sizeof(RawColor4));
8295
}
8396

97+
/// <summary>
98+
/// Gets a color attribute
99+
/// </summary>
100+
/// <param name="name">Attribute name</param>
101+
/// <param name="color">When this returns , contains the attribute value</param>
102+
public unsafe void GetAttributeValue(string name, out RawColor4 color)
103+
{
104+
fixed (RawColor4* ptr = &color)
105+
{
106+
GetAttributeValue(name, SvgAttributePodType.Color, new IntPtr(ptr), sizeof(RawColor4));
107+
}
108+
}
109+
84110
/// <summary>
85111
/// Sets fill mode attribute
86112
/// </summary>
@@ -91,6 +117,19 @@ public unsafe void SetAttributeValue(string name, FillMode fillMode)
91117
SetAttributeValue(name, SvgAttributePodType.FillMode, new IntPtr(&fillMode), sizeof(FillMode));
92118
}
93119

120+
/// <summary>
121+
/// Gets a fill mode attribute
122+
/// </summary>
123+
/// <param name="name">Attribute name</param>
124+
/// <param name="fillMode">When this returns , contains the attribute value</param>
125+
public unsafe void GetAttributeValue(string name, out FillMode fillMode)
126+
{
127+
fixed (FillMode* ptr = &fillMode)
128+
{
129+
GetAttributeValue(name, SvgAttributePodType.FillMode, new IntPtr(ptr), sizeof(FillMode));
130+
}
131+
}
132+
94133
/// <summary>
95134
/// Sets display mode attribute
96135
/// </summary>
@@ -101,6 +140,19 @@ public unsafe void SetAttributeValue(string name, SvgDisplay display)
101140
SetAttributeValue(name, SvgAttributePodType.Display, new IntPtr(&display), sizeof(SvgDisplay));
102141
}
103142

143+
/// <summary>
144+
/// Gets a display attribute
145+
/// </summary>
146+
/// <param name="name">Attribute name</param>
147+
/// <param name="display">When this returns , contains the attribute value</param>
148+
public unsafe void GetAttributeValue(string name, out SvgDisplay display)
149+
{
150+
fixed (SvgDisplay* ptr = &display)
151+
{
152+
GetAttributeValue(name, SvgAttributePodType.Display, new IntPtr(ptr), sizeof(SvgDisplay));
153+
}
154+
}
155+
104156
/// <summary>
105157
/// Sets overflow mode attribute
106158
/// </summary>
@@ -111,6 +163,19 @@ public unsafe void SetAttributeValue(string name, SvgOverflow overflow)
111163
SetAttributeValue(name, SvgAttributePodType.Overflow, new IntPtr(&overflow), sizeof(SvgOverflow));
112164
}
113165

166+
/// <summary>
167+
/// Gets an overflow attribute
168+
/// </summary>
169+
/// <param name="name">Attribute name</param>
170+
/// <param name="overflow">When this returns , contains the attribute value</param>
171+
public unsafe void GetAttributeValue(string name, out SvgOverflow overflow)
172+
{
173+
fixed (SvgOverflow* ptr = &overflow)
174+
{
175+
GetAttributeValue(name, SvgAttributePodType.Overflow, new IntPtr(ptr), sizeof(SvgOverflow));
176+
}
177+
}
178+
114179
/// <summary>
115180
/// Sets line join attribute
116181
/// </summary>
@@ -121,6 +186,19 @@ public unsafe void SetAttributeValue(string name, SvgLineJoin lineJoin)
121186
SetAttributeValue(name, SvgAttributePodType.LineJoin, new IntPtr(&lineJoin), sizeof(SvgLineJoin));
122187
}
123188

189+
/// <summary>
190+
/// Gets a line join attribute
191+
/// </summary>
192+
/// <param name="name">Attribute name</param>
193+
/// <param name="lineJoin">When this returns , contains the attribute value</param>
194+
public unsafe void GetAttributeValue(string name, out SvgLineJoin lineJoin)
195+
{
196+
fixed (SvgLineJoin* ptr = &lineJoin)
197+
{
198+
GetAttributeValue(name, SvgAttributePodType.LineJoin, new IntPtr(ptr), sizeof(SvgLineJoin));
199+
}
200+
}
201+
124202

125203
/// <summary>
126204
/// Sets line cap attribute
@@ -133,6 +211,20 @@ public unsafe void SetAttributeValue(string name, SvgLineCap lineCap)
133211
}
134212

135213

214+
/// <summary>
215+
/// Gets a line cap attribute
216+
/// </summary>
217+
/// <param name="name">Attribute name</param>
218+
/// <param name="lineCap">When this returns , contains the attribute value</param>
219+
public unsafe void GetAttributeValue(string name, out SvgLineCap lineCap)
220+
{
221+
fixed (SvgLineCap* ptr = &lineCap)
222+
{
223+
GetAttributeValue(name, SvgAttributePodType.LineCap, new IntPtr(ptr), sizeof(SvgLineCap));
224+
}
225+
}
226+
227+
136228
/// <summary>
137229
/// Sets visibility attribute
138230
/// </summary>
@@ -143,14 +235,41 @@ public unsafe void SetAttributeValue(string name, SvgVisibility visibility)
143235
SetAttributeValue(name, SvgAttributePodType.Visibility, new IntPtr(&visibility), sizeof(SvgVisibility));
144236
}
145237

238+
/// <summary>
239+
/// Gets a visibility attribute
240+
/// </summary>
241+
/// <param name="name">Attribute name</param>
242+
/// <param name="visibility">When this returns , contains the attribute value</param>
243+
public unsafe void GetAttributeValue(string name, out SvgVisibility visibility)
244+
{
245+
fixed (SvgVisibility* ptr = &visibility)
246+
{
247+
GetAttributeValue(name, SvgAttributePodType.Visibility, new IntPtr(ptr), sizeof(SvgVisibility));
248+
}
249+
}
250+
146251
/// <summary>
147252
/// Sets transform attribute
148253
/// </summary>
149254
/// <param name="name">Attribute name</param>
150255
/// <param name="matrix">New transform</param>
151256
public unsafe void SetAttributeValue(string name, RawMatrix3x2 matrix)
152257
{
153-
SetAttributeValue(name, SvgAttributePodType.Visibility, new IntPtr(&matrix), sizeof(RawMatrix3x2));
258+
SetAttributeValue(name, SvgAttributePodType.Matrix, new IntPtr(&matrix), sizeof(RawMatrix3x2));
259+
}
260+
261+
262+
/// <summary>
263+
/// Gets a transform attribute
264+
/// </summary>
265+
/// <param name="name">Attribute name</param>
266+
/// <param name="matrix">When this returns , contains the attribute value</param>
267+
public unsafe void GetAttributeValue(string name, out RawMatrix3x2 matrix)
268+
{
269+
fixed (RawMatrix3x2* ptr = &matrix)
270+
{
271+
GetAttributeValue(name, SvgAttributePodType.Matrix, new IntPtr(ptr), sizeof(RawMatrix3x2));
272+
}
154273
}
155274

156275
/// <summary>
@@ -163,6 +282,18 @@ public unsafe void SetAttributeValue(string name, SvgUnitType unitType)
163282
SetAttributeValue(name, SvgAttributePodType.UnitType, new IntPtr(&unitType), sizeof(SvgUnitType));
164283
}
165284

285+
/// <summary>
286+
/// Gets a unit type attribute
287+
/// </summary>
288+
/// <param name="name">Attribute name</param>
289+
/// <param name="unitType">When this returns , contains the attribute value</param>
290+
public unsafe void GetAttributeValue(string name, out SvgUnitType unitType)
291+
{
292+
fixed (SvgUnitType* ptr = &unitType)
293+
{
294+
GetAttributeValue(name, SvgAttributePodType.UnitType, new IntPtr(ptr), sizeof(SvgUnitType));
295+
}
296+
}
166297

167298
/// <summary>
168299
/// Sets extend mode attribute
@@ -174,6 +305,19 @@ public unsafe void SetAttributeValue(string name, ExtendMode extendMode)
174305
SetAttributeValue(name, SvgAttributePodType.ExtendMode, new IntPtr(&extendMode), sizeof(ExtendMode));
175306
}
176307

308+
/// <summary>
309+
/// Gets an extend mode attribute
310+
/// </summary>
311+
/// <param name="name">Attribute name</param>
312+
/// <param name="extendMode">When this returns , contains the attribute value</param>
313+
public unsafe void GetAttributeValue(string name, out ExtendMode extendMode)
314+
{
315+
fixed (ExtendMode* ptr = &extendMode)
316+
{
317+
GetAttributeValue(name, SvgAttributePodType.ExtendMode, new IntPtr(ptr), sizeof(ExtendMode));
318+
}
319+
}
320+
177321
/// <summary>
178322
/// Sets preserve Aspect Ratio attribute
179323
/// </summary>
@@ -184,6 +328,19 @@ public unsafe void SetAttributeValue(string name, SvgPreserveAspectRatio preserv
184328
SetAttributeValue(name, SvgAttributePodType.PreserveAspectRatio, new IntPtr(&preserveAspectRatio), sizeof(SvgPreserveAspectRatio));
185329
}
186330

331+
/// <summary>
332+
/// Gets a preserve aspect ratio attribute
333+
/// </summary>
334+
/// <param name="name">Attribute name</param>
335+
/// <param name="preserveAspectRatio">When this returns , contains the attribute value</param>
336+
public unsafe void GetAttributeValue(string name, out SvgPreserveAspectRatio preserveAspectRatio)
337+
{
338+
fixed (SvgPreserveAspectRatio* ptr = &preserveAspectRatio)
339+
{
340+
GetAttributeValue(name, SvgAttributePodType.PreserveAspectRatio, new IntPtr(ptr), sizeof(SvgPreserveAspectRatio));
341+
}
342+
}
343+
187344
/// <summary>
188345
/// Sets length attribute
189346
/// </summary>
@@ -193,5 +350,18 @@ public unsafe void SetAttributeValue(string name, SvgLength length)
193350
{
194351
SetAttributeValue(name, SvgAttributePodType.Length, new IntPtr(&length), sizeof(SvgLength));
195352
}
353+
354+
/// <summary>
355+
/// Gets an svg length attribute
356+
/// </summary>
357+
/// <param name="name">Attribute name</param>
358+
/// <param name="length">When this returns , contains the attribute value</param>
359+
public unsafe void GetAttributeValue(string name, out SvgLength length)
360+
{
361+
fixed (SvgLength* ptr = &length)
362+
{
363+
GetAttributeValue(name, SvgAttributePodType.Length, new IntPtr(ptr), sizeof(SvgLength));
364+
}
365+
}
196366
}
197367
}

0 commit comments

Comments
 (0)