18 changed files with 256 additions and 38 deletions
@ -0,0 +1,28 @@ |
|||
// -----------------------------------------------------------------------
|
|||
// <copyright file="Direct2D1Initialize.cs" company="Steven Kirk">
|
|||
// Copyright 2014 MIT Licence. See licence.md for more information.
|
|||
// </copyright>
|
|||
// -----------------------------------------------------------------------
|
|||
|
|||
namespace Perspex.Direct2D1 |
|||
{ |
|||
using Perspex.Media; |
|||
using Perspex.Platform; |
|||
using Splat; |
|||
|
|||
public static class Direct2D1Platform |
|||
{ |
|||
public static void Initialize() |
|||
{ |
|||
SharpDX.Direct2D1.Factory d2d1Factory = new SharpDX.Direct2D1.Factory(); |
|||
SharpDX.DirectWrite.Factory dwFactory = new SharpDX.DirectWrite.Factory(); |
|||
TextService textService = new TextService(dwFactory); |
|||
|
|||
var locator = Locator.CurrentMutable; |
|||
locator.Register(() => d2d1Factory, typeof(SharpDX.Direct2D1.Factory)); |
|||
locator.Register(() => dwFactory, typeof(SharpDX.DirectWrite.Factory)); |
|||
locator.Register(() => textService, typeof(ITextService)); |
|||
locator.Register(() => new Renderer(), typeof(IRenderer)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,88 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> |
|||
<PropertyGroup> |
|||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|||
<ProjectGuid>{3E908F67-5543-4879-A1DC-08EACE79B3CD}</ProjectGuid> |
|||
<OutputType>Library</OutputType> |
|||
<AppDesignerFolder>Properties</AppDesignerFolder> |
|||
<RootNamespace>Perspex.Direct2D1</RootNamespace> |
|||
<AssemblyName>Perspex.Direct2D1</AssemblyName> |
|||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> |
|||
<FileAlignment>512</FileAlignment> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|||
<DebugSymbols>true</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\Debug\</OutputPath> |
|||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|||
<DebugType>pdbonly</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>bin\Release\</OutputPath> |
|||
<DefineConstants>TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Reference Include="SharpDX"> |
|||
<HintPath>..\packages\SharpDX.2.5.0\lib\net40\SharpDX.dll</HintPath> |
|||
</Reference> |
|||
<Reference Include="SharpDX.Direct2D1"> |
|||
<HintPath>..\packages\SharpDX.Direct2D1.2.5.0\lib\net40\SharpDX.Direct2D1.dll</HintPath> |
|||
</Reference> |
|||
<Reference Include="SharpDX.DXGI"> |
|||
<HintPath>..\packages\SharpDX.DXGI.2.5.0\lib\net40\SharpDX.DXGI.dll</HintPath> |
|||
</Reference> |
|||
<Reference Include="Splat"> |
|||
<HintPath>..\packages\Splat.1.1.1\lib\Net45\Splat.dll</HintPath> |
|||
</Reference> |
|||
<Reference Include="System" /> |
|||
<Reference Include="System.Core" /> |
|||
<Reference Include="System.Drawing" /> |
|||
<Reference Include="System.Reactive.Core"> |
|||
<HintPath>..\packages\Rx-Core.2.1.30214.0\lib\Net45\System.Reactive.Core.dll</HintPath> |
|||
</Reference> |
|||
<Reference Include="System.Reactive.Interfaces"> |
|||
<HintPath>..\packages\Rx-Interfaces.2.1.30214.0\lib\Net45\System.Reactive.Interfaces.dll</HintPath> |
|||
</Reference> |
|||
<Reference Include="System.Reactive.PlatformServices"> |
|||
<HintPath>..\packages\Rx-PlatformServices.2.1.30214.0\lib\Net45\System.Reactive.PlatformServices.dll</HintPath> |
|||
</Reference> |
|||
<Reference Include="System.Windows.Forms" /> |
|||
<Reference Include="System.Xml.Linq" /> |
|||
<Reference Include="System.Data.DataSetExtensions" /> |
|||
<Reference Include="Microsoft.CSharp" /> |
|||
<Reference Include="System.Data" /> |
|||
<Reference Include="System.Xml" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Compile Include="Direct2D1Platform.cs" /> |
|||
<Compile Include="DrawingContext.cs" /> |
|||
<Compile Include="Properties\AssemblyInfo.cs" /> |
|||
<Compile Include="Renderer.cs" /> |
|||
<Compile Include="TextService.cs" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Perspex\Perspex.csproj"> |
|||
<Project>{3c9f40da-d2a5-43a1-a272-e965876c6d46}</Project> |
|||
<Name>Perspex</Name> |
|||
</ProjectReference> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<None Include="packages.config" /> |
|||
</ItemGroup> |
|||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
|||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
|||
Other similar extension points exist, see Microsoft.Common.targets. |
|||
<Target Name="BeforeBuild"> |
|||
</Target> |
|||
<Target Name="AfterBuild"> |
|||
</Target> |
|||
--> |
|||
</Project> |
|||
@ -0,0 +1,36 @@ |
|||
using System.Reflection; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
// General Information about an assembly is controlled through the following
|
|||
// set of attributes. Change these attribute values to modify the information
|
|||
// associated with an assembly.
|
|||
[assembly: AssemblyTitle("Perspex.Direct2D1")] |
|||
[assembly: AssemblyDescription("")] |
|||
[assembly: AssemblyConfiguration("")] |
|||
[assembly: AssemblyCompany("")] |
|||
[assembly: AssemblyProduct("Perspex.Direct2D1")] |
|||
[assembly: AssemblyCopyright("Copyright © 2014")] |
|||
[assembly: AssemblyTrademark("")] |
|||
[assembly: AssemblyCulture("")] |
|||
|
|||
// Setting ComVisible to false makes the types in this assembly not visible
|
|||
// to COM components. If you need to access a type in this assembly from
|
|||
// COM, set the ComVisible attribute to true on that type.
|
|||
[assembly: ComVisible(false)] |
|||
|
|||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|||
[assembly: Guid("6fb97e2a-0259-435b-b805-478fbab3cbbf")] |
|||
|
|||
// Version information for an assembly consists of the following four values:
|
|||
//
|
|||
// Major Version
|
|||
// Minor Version
|
|||
// Build Number
|
|||
// Revision
|
|||
//
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
|||
// by using the '*' as shown below:
|
|||
// [assembly: AssemblyVersion("1.0.*")]
|
|||
[assembly: AssemblyVersion("1.0.0.0")] |
|||
[assembly: AssemblyFileVersion("1.0.0.0")] |
|||
@ -0,0 +1,10 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<packages> |
|||
<package id="Rx-Core" version="2.1.30214.0" targetFramework="net45" /> |
|||
<package id="Rx-Interfaces" version="2.1.30214.0" targetFramework="net45" /> |
|||
<package id="Rx-PlatformServices" version="2.1.30214.0" targetFramework="net45" /> |
|||
<package id="SharpDX" version="2.5.0" targetFramework="net45" /> |
|||
<package id="SharpDX.Direct2D1" version="2.5.0" targetFramework="net45" /> |
|||
<package id="SharpDX.DXGI" version="2.5.0" targetFramework="net45" /> |
|||
<package id="Splat" version="1.1.1" targetFramework="net45" /> |
|||
</packages> |
|||
@ -0,0 +1,37 @@ |
|||
// -----------------------------------------------------------------------
|
|||
// <copyright file="IRenderer.cs" company="Steven Kirk">
|
|||
// Copyright 2014 MIT Licence. See licence.md for more information.
|
|||
// </copyright>
|
|||
// -----------------------------------------------------------------------
|
|||
|
|||
namespace Perspex.Platform |
|||
{ |
|||
using System; |
|||
|
|||
public interface IRenderer |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes the renderer to draw to the specified handle.
|
|||
/// </summary>
|
|||
/// <param name="handle">The window etc handle</param>
|
|||
/// <param name="width">The initial viewport width.</param>
|
|||
/// <param name="height">The initial viewport height.</param>
|
|||
/// <remarks>
|
|||
/// TODO: This probably should be somewhere else...
|
|||
/// </remarks>
|
|||
void Initialize(IntPtr handle, double width, double height); |
|||
|
|||
/// <summary>
|
|||
/// Renders the specified visual.
|
|||
/// </summary>
|
|||
/// <param name="visual">The visual to render.</param>
|
|||
void Render(IVisual visual); |
|||
|
|||
/// <summary>
|
|||
/// Resizes the rendered viewport.
|
|||
/// </summary>
|
|||
/// <param name="width">The new width.</param>
|
|||
/// <param name="height">The new height.</param>
|
|||
void Resize(int width, int height); |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
namespace TestApplication |
|||
{ |
|||
using Perspex; |
|||
using Perspex.Direct2D1; |
|||
using Perspex.Themes.Default; |
|||
|
|||
public class App : Application |
|||
{ |
|||
public App() |
|||
{ |
|||
RegisterPortableServices(); |
|||
Direct2D1Platform.Initialize(); |
|||
this.Styles = new DefaultTheme(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue