|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using System.Text; |
| 5 | + |
| 6 | +using SharpDX.Mathematics.Interop; |
| 7 | + |
| 8 | +namespace SharpDX.Direct2D1 |
| 9 | +{ |
| 10 | + public partial class SvgElement |
| 11 | + { |
| 12 | + /// <summary> |
| 13 | + /// Gets all children of this element. |
| 14 | + /// </summary> |
| 15 | + public SvgElement[] Children |
| 16 | + { |
| 17 | + get |
| 18 | + { |
| 19 | + if (!HasChildren()) |
| 20 | + return new SvgElement[0]; |
| 21 | + |
| 22 | + //We do not know the amount of children, and nothing in api does help us, count pass |
| 23 | + SvgElement current = FirstChild; |
| 24 | + int childCount = 0; |
| 25 | + |
| 26 | + SvgElement next; |
| 27 | + do |
| 28 | + { |
| 29 | + GetNextChild(current, out next); |
| 30 | + current = next; |
| 31 | + childCount++; |
| 32 | + } |
| 33 | + while (next != null); |
| 34 | + |
| 35 | + SvgElement[] result = new SvgElement[childCount]; |
| 36 | + |
| 37 | + current = FirstChild; |
| 38 | + for (int i = 0; i < childCount; i++) |
| 39 | + { |
| 40 | + result[i] = current; |
| 41 | + GetNextChild(current, out current); |
| 42 | + } |
| 43 | + |
| 44 | + return result; |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + /// <summary> |
| 49 | + /// Sets float attribute |
| 50 | + /// </summary> |
| 51 | + /// <param name="name">Attribute name</param> |
| 52 | + /// <param name="value">New valuee</param> |
| 53 | + public unsafe void SetAttributeValue(string name, float value) |
| 54 | + { |
| 55 | + SetAttributeValue(name, SvgAttributePodType.Float, new IntPtr(&value), sizeof(float)); |
| 56 | + } |
| 57 | + |
| 58 | + /// <summary> |
| 59 | + /// Sets color attribute |
| 60 | + /// </summary> |
| 61 | + /// <param name="name">Attribute name</param> |
| 62 | + /// <param name="color">New color</param> |
| 63 | + public unsafe void SetAttributeValue(string name, RawColor4 color) |
| 64 | + { |
| 65 | + SetAttributeValue(name, SvgAttributePodType.Color, new IntPtr(&color), sizeof(RawColor4)); |
| 66 | + } |
| 67 | + |
| 68 | + /// <summary> |
| 69 | + /// Sets fill mode attribute |
| 70 | + /// </summary> |
| 71 | + /// <param name="name">Attribute name</param> |
| 72 | + /// <param name="fillMode">New fill mode</param> |
| 73 | + public unsafe void SetAttributeValue(string name, FillMode fillMode) |
| 74 | + { |
| 75 | + SetAttributeValue(name, SvgAttributePodType.FillMode, new IntPtr(&fillMode), sizeof(FillMode)); |
| 76 | + } |
| 77 | + |
| 78 | + /// <summary> |
| 79 | + /// Sets display mode attribute |
| 80 | + /// </summary> |
| 81 | + /// <param name="name">Attribute name</param> |
| 82 | + /// <param name="display">New svg display</param> |
| 83 | + public unsafe void SetAttributeValue(string name, SvgDisplay display) |
| 84 | + { |
| 85 | + SetAttributeValue(name, SvgAttributePodType.Display, new IntPtr(&display), sizeof(SvgDisplay)); |
| 86 | + } |
| 87 | + |
| 88 | + /// <summary> |
| 89 | + /// Sets overflow mode attribute |
| 90 | + /// </summary> |
| 91 | + /// <param name="name">Attribute name</param> |
| 92 | + /// <param name="overflow">New svg overfloe<param> |
| 93 | + public unsafe void SetAttributeValue(string name, SvgOverflow overflow) |
| 94 | + { |
| 95 | + SetAttributeValue(name, SvgAttributePodType.Overflow, new IntPtr(&overflow), sizeof(SvgOverflow)); |
| 96 | + } |
| 97 | + |
| 98 | + /// <summary> |
| 99 | + /// Sets line join attribute |
| 100 | + /// </summary> |
| 101 | + /// <param name="name">Attribute name</param> |
| 102 | + /// <param name="lineJoin">New svg line join</param> |
| 103 | + public unsafe void SetAttributeValue(string name, SvgLineJoin lineJoin) |
| 104 | + { |
| 105 | + SetAttributeValue(name, SvgAttributePodType.LineJoin, new IntPtr(&lineJoin), sizeof(SvgLineJoin)); |
| 106 | + } |
| 107 | + |
| 108 | + /// <summary> |
| 109 | + /// Sets visibility attribute |
| 110 | + /// </summary> |
| 111 | + /// <param name="name">Attribute name</param> |
| 112 | + /// <param name="visibility">New svg visibility</param> |
| 113 | + public unsafe void SetAttributeValue(string name, SvgVisibility visibility) |
| 114 | + { |
| 115 | + SetAttributeValue(name, SvgAttributePodType.Visibility, new IntPtr(&visibility), sizeof(SvgVisibility)); |
| 116 | + } |
| 117 | + |
| 118 | + /// <summary> |
| 119 | + /// Sets transform attribute |
| 120 | + /// </summary> |
| 121 | + /// <param name="name">Attribute name</param> |
| 122 | + /// <param name="matrix">New transform</param> |
| 123 | + public unsafe void SetAttributeValue(string name, RawMatrix3x2 matrix) |
| 124 | + { |
| 125 | + SetAttributeValue(name, SvgAttributePodType.Visibility, new IntPtr(&matrix), sizeof(RawMatrix3x2)); |
| 126 | + } |
| 127 | + } |
| 128 | +} |
0 commit comments