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

Commit 0793b4e

Browse files
authored
Merge pull request #954 from mrvux/d2d_svg
Direct2D and SVG
2 parents 3991ca4 + d7afe18 commit 0793b4e

5 files changed

Lines changed: 445 additions & 1 deletion

File tree

Source/SharpDX.Direct2D1/DeviceContext5.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
// THE SOFTWARE.
2020

21+
using SharpDX.Win32;
2122
using System;
2223

2324
namespace SharpDX.Direct2D1
@@ -38,5 +39,18 @@ public DeviceContext5(Device5 device, DeviceContextOptions options)
3839
{
3940
device.CreateDeviceContext(options, this);
4041
}
42+
43+
/// <summary>
44+
/// Creates an Svg document from an xml string
45+
/// </summary>
46+
/// <param name="stream"></param>
47+
/// <param name="viewportSize"></param>
48+
/// <returns>Svg document model</returns>
49+
public SvgDocument CreateSvgDocument(IStream stream, SharpDX.Size2F viewportSize)
50+
{
51+
SvgDocument result;
52+
CreateSvgDocument_(ComStream.ToIntPtr(stream), viewportSize, out result);
53+
return result;
54+
}
4155
}
4256
}

Source/SharpDX.Direct2D1/Mapping-direct2d1.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,12 @@
494494
<map param="ID2D\dDeviceContext5::CreateColorContextFromSimpleColorProfile::colorContext" attribute="out fast"/>
495495
<map param="ID2D\dEffectContext2::CreateColorContextFromDxgiColorSpace::colorContext" attribute="out fast"/>
496496
<map param="ID2D\dEffectContext2::CreateColorContextFromSimpleColorProfile::colorContext" attribute="out fast"/>
497+
498+
<!-- Svg documents and elements -->
499+
<map method="ID2D1SvgDocument::FindElementById" hresult="true" check="false" visibility="private" name="TryFindElementById_"/>
500+
<map method="ID2D1SvgAttribute::Clone" visibility="internal" />
497501

498-
<!--
502+
<!--
499503
// *****************************************************************
500504
// D2D1 Functions
501505
// *****************************************************************
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace SharpDX.Direct2D1
7+
{
8+
public partial class SvgAttribute
9+
{
10+
/// <summary>
11+
/// Clones an svg attribute
12+
/// </summary>
13+
/// <returns></returns>
14+
public SvgAttribute Clone()
15+
{
16+
SvgAttribute svgAttribute;
17+
Clone(out svgAttribute);
18+
return svgAttribute;
19+
}
20+
}
21+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace SharpDX.Direct2D1
7+
{
8+
public partial class SvgDocument
9+
{
10+
/// <summary>
11+
/// Finds an svg element by id
12+
/// </summary>
13+
/// <param name="id">Id to lookup for</param>
14+
/// <returns>SvgElement if found, null otherwise</returns>
15+
public SvgElement FindElementById(string id)
16+
{
17+
SharpDX.Result __result__;
18+
SvgElement svgElement;
19+
__result__ = TryFindElementById_(id, out svgElement);
20+
21+
__result__.CheckError();
22+
return svgElement;
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)