├── .gitignore
├── BurnSystems.Direct2d
├── BurnSystems.Direct2d.csproj
├── DX10ImageSource.cs
├── Direct2dControl.cs
├── Disposer.cs
├── Example
│ └── RandomLinesControl.cs
├── NativeMethods.cs
├── Properties
│ └── AssemblyInfo.cs
└── packages.config
├── Direct2dWPF.sln
├── Direct2dWPF
├── App.config
├── App.xaml
├── App.xaml.cs
├── Direct2dWPF.csproj
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
└── packages.config
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | /ext-packages
2 |
3 | ## Ignore Visual Studio temporary files, build results, and
4 | ## files generated by popular Visual Studio add-ons.
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.sln.docstates
10 |
11 | # Build results
12 |
13 | [Dd]ebug/
14 | [Rr]elease/
15 | x64/
16 | build/
17 | [Bb]in/
18 | [Oo]bj/
19 |
20 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
21 | !packages/*/build/
22 |
23 | # MSTest test Results
24 | [Tt]est[Rr]esult*/
25 | [Bb]uild[Ll]og.*
26 |
27 | *_i.c
28 | *_p.c
29 | *.ilk
30 | *.meta
31 | *.obj
32 | *.pch
33 | *.pdb
34 | *.pgc
35 | *.pgd
36 | *.rsp
37 | *.sbr
38 | *.tlb
39 | *.tli
40 | *.tlh
41 | *.tmp
42 | *.tmp_proj
43 | *.log
44 | *.vspscc
45 | *.vssscc
46 | .builds
47 | *.pidb
48 | *.log
49 | *.scc
50 |
51 | # Visual C++ cache files
52 | ipch/
53 | *.aps
54 | *.ncb
55 | *.opensdf
56 | *.sdf
57 | *.cachefile
58 |
59 | # Visual Studio profiler
60 | *.psess
61 | *.vsp
62 | *.vspx
63 |
64 | # Guidance Automation Toolkit
65 | *.gpState
66 |
67 | # ReSharper is a .NET coding add-in
68 | _ReSharper*/
69 | *.[Rr]e[Ss]harper
70 |
71 | # TeamCity is a build add-in
72 | _TeamCity*
73 |
74 | # DotCover is a Code Coverage Tool
75 | *.dotCover
76 |
77 | # NCrunch
78 | *.ncrunch*
79 | .*crunch*.local.xml
80 |
81 | # Installshield output folder
82 | [Ee]xpress/
83 |
84 | # DocProject is a documentation generator add-in
85 | DocProject/buildhelp/
86 | DocProject/Help/*.HxT
87 | DocProject/Help/*.HxC
88 | DocProject/Help/*.hhc
89 | DocProject/Help/*.hhk
90 | DocProject/Help/*.hhp
91 | DocProject/Help/Html2
92 | DocProject/Help/html
93 |
94 | # Click-Once directory
95 | publish/
96 |
97 | # Publish Web Output
98 | *.Publish.xml
99 |
100 | # NuGet Packages Directory
101 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
102 | packages/
103 |
104 | # Windows Azure Build Output
105 | csx
106 | *.build.csdef
107 |
108 | # Windows Store app package directory
109 | AppPackages/
110 |
111 | # Others
112 | sql/
113 | *.Cache
114 | ClientBin/
115 | [Ss]tyle[Cc]op.*
116 | ~$*
117 | *~
118 | *.dbmdl
119 | *.[Pp]ublish.xml
120 | *.pfx
121 | *.publishsettings
122 |
123 | # RIA/Silverlight projects
124 | Generated_Code/
125 |
126 | # Backup & report files from converting an old project file to a newer
127 | # Visual Studio version. Backup files are not needed, because we have git ;-)
128 | _UpgradeReport_Files/
129 | Backup*/
130 | UpgradeLog*.XML
131 | UpgradeLog*.htm
132 |
133 | # SQL Server files
134 | App_Data/*.mdf
135 | App_Data/*.ldf
136 |
137 |
138 | #LightSwitch generated files
139 | GeneratedArtifacts/
140 | _Pvt_Extensions/
141 | ModelManifest.xml
142 |
143 | # =========================
144 | # Windows detritus
145 | # =========================
146 |
147 | # Windows image file caches
148 | Thumbs.db
149 | ehthumbs.db
150 |
151 | # Folder config file
152 | Desktop.ini
153 |
154 | # Recycle Bin used on file shares
155 | $RECYCLE.BIN/
156 |
157 | # Mac desktop service store files
158 | .DS_Store
159 |
--------------------------------------------------------------------------------
/BurnSystems.Direct2d/BurnSystems.Direct2d.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {132F00C4-ECFB-49DB-86F6-24C0D054928D}
8 | Library
9 | Properties
10 | BurnSystems.Direct2d
11 | BurnSystems.Direct2d
12 | v4.5
13 | 512
14 | 28c1bc05
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 |
36 |
37 | $(SharpDXPackageBinDir)\SharpDX.dll
38 |
39 |
40 | $(SharpDXPackageBinDir)\SharpDX.D3DCompiler.dll
41 |
42 |
43 | $(SharpDXPackageBinDir)\SharpDX.Direct2D1.dll
44 |
45 |
46 | $(SharpDXPackageBinDir)\SharpDX.Direct3D10.dll
47 |
48 |
49 | $(SharpDXPackageBinDir)\SharpDX.Direct3D9.dll
50 |
51 |
52 | $(SharpDXPackageBinDir)\SharpDX.DXGI.dll
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
82 |
83 |
84 |
85 |
92 |
--------------------------------------------------------------------------------
/BurnSystems.Direct2d/DX10ImageSource.cs:
--------------------------------------------------------------------------------
1 | // Permission is hereby granted, free of charge, to any person obtaining a copy
2 | // of this software and associated documentation files (the "Software"), to deal
3 | // in the Software without restriction, including without limitation the rights
4 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5 | // copies of the Software, and to permit persons to whom the Software is
6 | // furnished to do so, subject to the following conditions:
7 | //
8 | // The above copyright notice and this permission notice shall be included in
9 | // all copies or substantial portions of the Software.
10 | //
11 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
17 | // THE SOFTWARE.
18 | // -----------------------------------------------------------------------------
19 | // Original code from SlimMath project. http://code.google.com/p/slimmath/
20 | // Greetings to SlimDX Group. Original code published with the following license:
21 | // -----------------------------------------------------------------------------
22 | //
23 | // This file is derived from a file under the copy right above.
24 | // Copyright was given by 2010-2012 SharpDX - Alexandre Mutel
25 | /*
26 | * Copyright (c) 2007-2011 SlimDX Group
27 | *
28 | * Permission is hereby granted, free of charge, to any person obtaining a copy
29 | * of this software and associated documentation files (the "Software"), to deal
30 | * in the Software without restriction, including without limitation the rights
31 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
32 | * copies of the Software, and to permit persons to whom the Software is
33 | * furnished to do so, subject to the following conditions:
34 | *
35 | * The above copyright notice and this permission notice shall be included in
36 | * all copies or substantial portions of the Software.
37 | *
38 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
39 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
40 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
41 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
42 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
43 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
44 | * THE SOFTWARE.
45 | */
46 |
47 | namespace BurnSystems.Direct2d
48 | {
49 | using System;
50 | using System.Runtime.InteropServices;
51 | using System.Windows;
52 | using System.Windows.Interop;
53 | using SharpDX.Direct3D9;
54 |
55 | class DX10ImageSource : D3DImage, IDisposable
56 | {
57 | private static int ActiveClients;
58 | private static Direct3DEx D3DContext;
59 | private static DeviceEx D3DDevice;
60 | private Texture RenderTarget;
61 |
62 | public DX10ImageSource()
63 | {
64 | this.StartD3D();
65 | DX10ImageSource.ActiveClients++;
66 | }
67 |
68 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "RenderTarget")]
69 | public void Dispose()
70 | {
71 | this.SetRenderTargetDX10(null);
72 |
73 | // Here, we have our Dispose call
74 | Disposer.SafeDispose(ref this.RenderTarget);
75 |
76 | DX10ImageSource.ActiveClients--;
77 | this.EndD3D();
78 | }
79 |
80 | public void InvalidateD3DImage()
81 | {
82 | if (this.RenderTarget != null)
83 | {
84 | base.Lock();
85 | base.AddDirtyRect(new Int32Rect(0, 0, base.PixelWidth, base.PixelHeight));
86 | base.Unlock();
87 | }
88 | }
89 |
90 | public void SetRenderTargetDX10(SharpDX.Direct3D10.Texture2D renderTarget)
91 | {
92 | if (this.RenderTarget != null)
93 | {
94 | this.RenderTarget = null;
95 |
96 | base.Lock();
97 | base.SetBackBuffer(D3DResourceType.IDirect3DSurface9, IntPtr.Zero);
98 | base.Unlock();
99 | }
100 |
101 | if (renderTarget == null)
102 | return;
103 |
104 | if (!IsShareable(renderTarget))
105 | {
106 | throw new ArgumentException("Texture must be created with ResourceOptionFlags.Shared");
107 | }
108 |
109 | Format format = DX10ImageSource.TranslateFormat(renderTarget);
110 | if (format == Format.Unknown)
111 | {
112 | throw new ArgumentException("Texture format is not compatible with OpenSharedResource");
113 | }
114 |
115 | IntPtr handle = GetSharedHandle(renderTarget);
116 | if (handle == IntPtr.Zero)
117 | {
118 | throw new ArgumentNullException("Handle");
119 | }
120 |
121 | this.RenderTarget = new Texture(DX10ImageSource.D3DDevice, renderTarget.Description.Width, renderTarget.Description.Height, 1, Usage.RenderTarget, format, Pool.Default, ref handle);
122 | using (Surface surface = this.RenderTarget.GetSurfaceLevel(0))
123 | {
124 | base.Lock();
125 | base.SetBackBuffer(D3DResourceType.IDirect3DSurface9, surface.NativePointer);
126 | base.Unlock();
127 | }
128 | }
129 |
130 | private void StartD3D()
131 | {
132 | if (DX10ImageSource.ActiveClients != 0)
133 | {
134 | return;
135 | }
136 |
137 | DX10ImageSource.D3DContext = new Direct3DEx();
138 |
139 | var presentparams = new PresentParameters();
140 | presentparams.Windowed = true;
141 | presentparams.SwapEffect = SwapEffect.Discard;
142 | presentparams.DeviceWindowHandle = NativeMethods.GetDesktopWindow();
143 | presentparams.PresentationInterval = PresentInterval.Default;
144 |
145 | DX10ImageSource.D3DDevice = new DeviceEx(D3DContext, 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.HardwareVertexProcessing | CreateFlags.Multithreaded | CreateFlags.FpuPreserve, presentparams);
146 | }
147 |
148 | private void EndD3D()
149 | {
150 | if (DX10ImageSource.ActiveClients != 0)
151 | {
152 | return;
153 | }
154 |
155 | Disposer.SafeDispose(ref this.RenderTarget);
156 | Disposer.SafeDispose(ref DX10ImageSource.D3DDevice);
157 | Disposer.SafeDispose(ref DX10ImageSource.D3DContext);
158 | }
159 |
160 | private IntPtr GetSharedHandle(SharpDX.Direct3D10.Texture2D Texture)
161 | {
162 | var resource = Texture.QueryInterface();
163 | var result = resource.SharedHandle;
164 | resource.Dispose();
165 | return result;
166 | }
167 |
168 | private static Format TranslateFormat(SharpDX.Direct3D10.Texture2D Texture)
169 | {
170 | switch (Texture.Description.Format)
171 | {
172 | case SharpDX.DXGI.Format.R10G10B10A2_UNorm:
173 | return SharpDX.Direct3D9.Format.A2B10G10R10;
174 |
175 | case SharpDX.DXGI.Format.R16G16B16A16_Float:
176 | return SharpDX.Direct3D9.Format.A16B16G16R16F;
177 |
178 | case SharpDX.DXGI.Format.B8G8R8A8_UNorm:
179 | return SharpDX.Direct3D9.Format.A8R8G8B8;
180 |
181 | default:
182 | return SharpDX.Direct3D9.Format.Unknown;
183 | }
184 | }
185 |
186 | private static bool IsShareable(SharpDX.Direct3D10.Texture2D Texture)
187 | {
188 | return (Texture.Description.OptionFlags & SharpDX.Direct3D10.ResourceOptionFlags.Shared) != 0;
189 | }
190 | }
191 | }
192 |
--------------------------------------------------------------------------------
/BurnSystems.Direct2d/Direct2dControl.cs:
--------------------------------------------------------------------------------
1 | // Permission is hereby granted, free of charge, to any person obtaining a copy
2 | // of this software and associated documentation files (the "Software"), to deal
3 | // in the Software without restriction, including without limitation the rights
4 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5 | // copies of the Software, and to permit persons to whom the Software is
6 | // furnished to do so, subject to the following conditions:
7 | //
8 | // The above copyright notice and this permission notice shall be included in
9 | // all copies or substantial portions of the Software.
10 | //
11 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
17 | // THE SOFTWARE.
18 | //
19 | // This file is derived from a file under the copy right above.
20 | // Copyright was given by 2010-2012 SharpDX - Alexandre Mutel
21 |
22 | namespace BurnSystems.Direct2d
23 | {
24 | using SharpDX;
25 | using SharpDX.Direct2D1;
26 | using SharpDX.Direct3D10;
27 | using SharpDX.DXGI;
28 | using System;
29 | using System.ComponentModel;
30 | using System.Diagnostics;
31 | using System.Windows;
32 | using Device = SharpDX.Direct3D10.Device1;
33 | using FeatureLevel = SharpDX.Direct3D10.FeatureLevel;
34 |
35 | public abstract class Direct2dControl : System.Windows.Controls.Image
36 | {
37 | private Device Device;
38 | private Texture2D RenderTarget;
39 | private DX10ImageSource D3DSurface;
40 | private readonly Stopwatch RenderTimer;
41 | private RenderTarget m_d2dRenderTarget;
42 | private SharpDX.Direct2D1.Factory m_d2dFactory;
43 |
44 | public Direct2dControl()
45 | {
46 | this.RenderTimer = new Stopwatch();
47 | this.Loaded += this.Window_Loaded;
48 | this.Unloaded += this.Window_Closing;
49 | this.Stretch = System.Windows.Media.Stretch.Fill;
50 | }
51 |
52 | private void Window_Loaded(object sender, RoutedEventArgs e)
53 | {
54 | if (Direct2dControl.IsInDesignMode)
55 | {
56 | return;
57 | }
58 |
59 | this.StartD3D();
60 | this.StartRendering();
61 | }
62 |
63 | private void Window_Closing(object sender, RoutedEventArgs e)
64 | {
65 | if (Direct2dControl.IsInDesignMode)
66 | {
67 | return;
68 | }
69 |
70 | this.StopRendering();
71 | this.EndD3D();
72 | }
73 |
74 | private void StartD3D()
75 | {
76 | this.Device = new Device(DriverType.Hardware, DeviceCreationFlags.BgraSupport, FeatureLevel.Level_10_0);
77 |
78 | this.D3DSurface = new DX10ImageSource();
79 | this.D3DSurface.IsFrontBufferAvailableChanged += OnIsFrontBufferAvailableChanged;
80 |
81 | this.CreateAndBindTargets();
82 |
83 | this.Source = this.D3DSurface;
84 | }
85 |
86 | private void EndD3D()
87 | {
88 | this.D3DSurface.IsFrontBufferAvailableChanged -= OnIsFrontBufferAvailableChanged;
89 | this.Source = null;
90 |
91 | Disposer.SafeDispose(ref this.m_d2dRenderTarget);
92 | Disposer.SafeDispose(ref this.m_d2dFactory);
93 | Disposer.SafeDispose(ref this.D3DSurface);
94 | Disposer.SafeDispose(ref this.RenderTarget);
95 | Disposer.SafeDispose(ref this.Device);
96 | }
97 |
98 | private void CreateAndBindTargets()
99 | {
100 | this.D3DSurface.SetRenderTargetDX10(null);
101 |
102 | Disposer.SafeDispose(ref this.m_d2dRenderTarget);
103 | Disposer.SafeDispose(ref this.m_d2dFactory);
104 | Disposer.SafeDispose(ref this.RenderTarget);
105 |
106 | var width = Math.Max((int)this.ActualWidth, 100);
107 | var height = Math.Max((int)this.ActualHeight, 100);
108 |
109 | var colordesc = new Texture2DDescription
110 | {
111 | BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
112 | Format = Format.B8G8R8A8_UNorm,
113 | Width = width,
114 | Height = height,
115 | MipLevels = 1,
116 | SampleDescription = new SampleDescription(1, 0),
117 | Usage = ResourceUsage.Default,
118 | OptionFlags = ResourceOptionFlags.Shared,
119 | CpuAccessFlags = CpuAccessFlags.None,
120 | ArraySize = 1
121 | };
122 |
123 | this.RenderTarget = new Texture2D(this.Device, colordesc);
124 |
125 | var surface = this.RenderTarget.QueryInterface();
126 |
127 | m_d2dFactory = new SharpDX.Direct2D1.Factory();
128 | var rtp = new RenderTargetProperties(new PixelFormat(Format.Unknown, AlphaMode.Premultiplied));
129 | m_d2dRenderTarget = new RenderTarget(m_d2dFactory, surface, rtp);
130 |
131 | this.D3DSurface.SetRenderTargetDX10(this.RenderTarget);
132 | }
133 |
134 | private void StartRendering()
135 | {
136 | if (this.RenderTimer.IsRunning)
137 | {
138 | return;
139 | }
140 |
141 | System.Windows.Media.CompositionTarget.Rendering += OnRendering;
142 | this.RenderTimer.Start();
143 | }
144 |
145 | private void StopRendering()
146 | {
147 | if (!this.RenderTimer.IsRunning)
148 | {
149 | return;
150 | }
151 |
152 | System.Windows.Media.CompositionTarget.Rendering -= OnRendering;
153 | this.RenderTimer.Stop();
154 | }
155 |
156 | private void OnRendering(object sender, EventArgs e)
157 | {
158 | if (!this.RenderTimer.IsRunning)
159 | {
160 | return;
161 | }
162 |
163 | this.PrepareAndCallRender();
164 | this.D3DSurface.InvalidateD3DImage();
165 | }
166 |
167 | protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
168 | {
169 | this.CreateAndBindTargets();
170 | base.OnRenderSizeChanged(sizeInfo);
171 | }
172 |
173 | private void PrepareAndCallRender()
174 | {
175 | var device = this.Device;
176 | if (device == null)
177 | {
178 | return;
179 | }
180 |
181 | var renderTarget = this.RenderTarget;
182 | if (renderTarget == null)
183 | {
184 | return;
185 | }
186 |
187 | var targetWidth = renderTarget.Description.Width;
188 | var targetHeight = renderTarget.Description.Height;
189 |
190 | device.Rasterizer.SetViewports(new Viewport(0, 0, targetWidth, targetHeight, 0.0f, 1.0f));
191 |
192 | // Does the acttual rendering
193 | m_d2dRenderTarget.BeginDraw();
194 | this.Render(m_d2dRenderTarget);
195 | m_d2dRenderTarget.EndDraw();
196 |
197 | this.ShowFramesPerSecondsOnDebug();
198 |
199 | device.Flush();
200 | }
201 |
202 | ///
203 | /// Does the actual rendering.
204 | /// BeginDraw and EndDraw are already called by the caller.
205 | ///
206 | public abstract void Render(RenderTarget target);
207 |
208 | ///
209 | /// Shows the number of frames per seconds on the debug line
210 | ///
211 | private void ShowFramesPerSecondsOnDebug()
212 | {
213 | // Spits out the Frames per second
214 | f++;
215 | if ((DateTime.Now - last).TotalSeconds > 1)
216 | {
217 | System.Diagnostics.Debug.WriteLine(f);
218 | f = 0;
219 | last = DateTime.Now;
220 | }
221 | }
222 |
223 | private DateTime last;
224 | private int f;
225 |
226 | private void OnIsFrontBufferAvailableChanged(object sender, DependencyPropertyChangedEventArgs e)
227 | {
228 | // this fires when the screensaver kicks in, the machine goes into sleep or hibernate
229 | // and any other catastrophic losses of the d3d device from WPF's point of view
230 | if (this.D3DSurface.IsFrontBufferAvailable)
231 | {
232 | this.StartRendering();
233 | }
234 | else
235 | {
236 | this.StopRendering();
237 | }
238 | }
239 |
240 | ///
241 | /// Gets a value indicating whether the control is in design mode
242 | /// (running in Blend or Visual Studio).
243 | ///
244 | public static bool IsInDesignMode
245 | {
246 | get
247 | {
248 | var prop = DesignerProperties.IsInDesignModeProperty;
249 | var isDesignMode = (bool)DependencyPropertyDescriptor.FromProperty(prop, typeof(FrameworkElement)).Metadata.DefaultValue;
250 | return isDesignMode;
251 | }
252 | }
253 | }
254 | }
--------------------------------------------------------------------------------
/BurnSystems.Direct2d/Disposer.cs:
--------------------------------------------------------------------------------
1 |
2 | // Permission is hereby granted, free of charge, to any person obtaining a copy
3 | // of this software and associated documentation files (the "Software"), to deal
4 | // in the Software without restriction, including without limitation the rights
5 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
6 | // copies of the Software, and to permit persons to whom the Software is
7 | // furnished to do so, subject to the following conditions:
8 | //
9 | // The above copyright notice and this permission notice shall be included in
10 | // all copies or substantial portions of the Software.
11 | //
12 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
18 | // THE SOFTWARE.
19 | //
20 | // This file is derived from a file under the copy right above.
21 | // Copyright was given by 2010-2012 SharpDX - Alexandre Mutel
22 |
23 | namespace BurnSystems.Direct2d
24 | {
25 | using System;
26 |
27 | public static class Disposer
28 | {
29 | ///
30 | /// Dispose an object instance and set the reference to null
31 | ///
32 | /// The type of object to dispose
33 | /// A reference to the instance for disposal
34 | /// This method hides any thrown exceptions that might occur during disposal of the object (by design)
35 | public static void SafeDispose(ref T resource) where T : class
36 | {
37 | if (resource == null)
38 | {
39 | return;
40 | }
41 |
42 | var disposer = resource as IDisposable;
43 | if (disposer != null)
44 | {
45 | try
46 | {
47 | disposer.Dispose();
48 | }
49 | catch
50 | {
51 | }
52 | }
53 |
54 | resource = null;
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/BurnSystems.Direct2d/Example/RandomLinesControl.cs:
--------------------------------------------------------------------------------
1 | // Permission is hereby granted, free of charge, to any person obtaining a copy
2 | // of this software and associated documentation files (the "Software"), to deal
3 | // in the Software without restriction, including without limitation the rights
4 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5 | // copies of the Software, and to permit persons to whom the Software is
6 | // furnished to do so, subject to the following conditions:
7 | //
8 | // The above copyright notice and this permission notice shall be included in
9 | // all copies or substantial portions of the Software.
10 | //
11 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
17 | // THE SOFTWARE.
18 |
19 | namespace BurnSystems.Direct2d.Example
20 | {
21 | using SharpDX;
22 | using SharpDX.Direct2D1;
23 | using System;
24 |
25 | public class RandomLinesControl : Direct2dControl
26 | {
27 | ///
28 | /// Does the actual rendering.
29 | /// BeginDraw and EndDraw are already called by the caller.
30 | ///
31 | public override void Render(RenderTarget target)
32 | {
33 | var width = this.ActualWidth;
34 | var height = this.ActualHeight;
35 | target.Clear(Color.Black);
36 | var solidColorBrush1 = new SharpDX.Direct2D1.SolidColorBrush(target, SharpDX.Color.Blue);
37 | var solidColorBrush2 = new SharpDX.Direct2D1.SolidColorBrush(target, SharpDX.Color.Red);
38 | var rnd = new Random();
39 | for (var n = 0; n < 5000; n++)
40 | {
41 | var p0 = new Vector2((float)(rnd.NextDouble() * width), (float)(rnd.NextDouble() * height));
42 | var p1 = new Vector2((float)(rnd.NextDouble() * width), (float)(rnd.NextDouble() * height));
43 | target.DrawLine(
44 | p0,
45 | p1,
46 | n % 2 == 1 ? solidColorBrush1 : solidColorBrush2,
47 | 2);
48 | }
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/BurnSystems.Direct2d/NativeMethods.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace BurnSystems.Direct2d
9 | {
10 | ///
11 | /// Defines the native methods
12 | ///
13 | public static class NativeMethods
14 | {
15 | [DllImport("user32.dll", SetLastError = false)]
16 | public static extern IntPtr GetDesktopWindow();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/BurnSystems.Direct2d/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("BurnSystems.Direct2d")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("BurnSystems.Direct2d")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("1dbdc5f0-ddf9-46ea-a033-f36b206df15d")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/BurnSystems.Direct2d/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Direct2dWPF.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.31101.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Direct2dWPF", "Direct2dWPF\Direct2dWPF.csproj", "{8F9A489F-B239-4FD6-8722-1AE4462416A2}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BurnSystems.Direct2d", "BurnSystems.Direct2d\BurnSystems.Direct2d.csproj", "{132F00C4-ECFB-49DB-86F6-24C0D054928D}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {8F9A489F-B239-4FD6-8722-1AE4462416A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {8F9A489F-B239-4FD6-8722-1AE4462416A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {8F9A489F-B239-4FD6-8722-1AE4462416A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {8F9A489F-B239-4FD6-8722-1AE4462416A2}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {132F00C4-ECFB-49DB-86F6-24C0D054928D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {132F00C4-ECFB-49DB-86F6-24C0D054928D}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {132F00C4-ECFB-49DB-86F6-24C0D054928D}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {132F00C4-ECFB-49DB-86F6-24C0D054928D}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/Direct2dWPF/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Direct2dWPF/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Direct2dWPF/App.xaml.cs:
--------------------------------------------------------------------------------
1 | // Permission is hereby granted, free of charge, to any person obtaining a copy
2 | // of this software and associated documentation files (the "Software"), to deal
3 | // in the Software without restriction, including without limitation the rights
4 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5 | // copies of the Software, and to permit persons to whom the Software is
6 | // furnished to do so, subject to the following conditions:
7 | //
8 | // The above copyright notice and this permission notice shall be included in
9 | // all copies or substantial portions of the Software.
10 | //
11 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
17 | // THE SOFTWARE.
18 |
19 | namespace Direct2dWPF
20 | {
21 | using System.Windows;
22 |
23 | ///
24 | /// Interaction logic for App.xaml
25 | ///
26 | public partial class App : Application
27 | {
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Direct2dWPF/Direct2dWPF.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {8F9A489F-B239-4FD6-8722-1AE4462416A2}
8 | WinExe
9 | Properties
10 | Direct2dWPF
11 | Direct2dWPF
12 | v4.5
13 | 512
14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
15 | 4
16 | fa3edd7b
17 |
18 |
19 | AnyCPU
20 | true
21 | full
22 | false
23 | bin\Debug\
24 | DEBUG;TRACE
25 | prompt
26 | 4
27 |
28 |
29 | AnyCPU
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 |
39 | $(SharpDXPackageBinDir)\SharpDX.dll
40 |
41 |
42 | $(SharpDXPackageBinDir)\SharpDX.Direct2D1.dll
43 |
44 |
45 | $(SharpDXPackageBinDir)\SharpDX.DXGI.dll
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | 4.0
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | MSBuild:Compile
66 | Designer
67 |
68 |
69 | MSBuild:Compile
70 | Designer
71 |
72 |
73 | App.xaml
74 | Code
75 |
76 |
77 | MainWindow.xaml
78 | Code
79 |
80 |
81 |
82 |
83 | Code
84 |
85 |
86 | True
87 | True
88 | Resources.resx
89 |
90 |
91 | True
92 | Settings.settings
93 | True
94 |
95 |
96 | ResXFileCodeGenerator
97 | Resources.Designer.cs
98 |
99 |
100 |
101 | SettingsSingleFileGenerator
102 | Settings.Designer.cs
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 | {132f00c4-ecfb-49db-86f6-24c0d054928d}
112 | BurnSystems.Direct2d
113 |
114 |
115 |
116 |
117 |
118 |
119 | This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
120 |
121 |
122 |
123 |
130 |
--------------------------------------------------------------------------------
/Direct2dWPF/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Direct2dWPF/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | // Permission is hereby granted, free of charge, to any person obtaining a copy
2 | // of this software and associated documentation files (the "Software"), to deal
3 | // in the Software without restriction, including without limitation the rights
4 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5 | // copies of the Software, and to permit persons to whom the Software is
6 | // furnished to do so, subject to the following conditions:
7 | //
8 | // The above copyright notice and this permission notice shall be included in
9 | // all copies or substantial portions of the Software.
10 | //
11 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
17 | // THE SOFTWARE.
18 |
19 | using System;
20 | using System.Collections.Generic;
21 | using System.Linq;
22 | using System.Text;
23 | using System.Threading.Tasks;
24 | using System.Windows;
25 | using System.Windows.Controls;
26 | using System.Windows.Data;
27 | using System.Windows.Documents;
28 | using System.Windows.Input;
29 | using System.Windows.Media;
30 | using System.Windows.Media.Imaging;
31 | using System.Windows.Navigation;
32 | using System.Windows.Shapes;
33 |
34 | namespace Direct2dWPF
35 | {
36 | ///
37 | /// Interaction logic for MainWindow.xaml
38 | ///
39 | public partial class MainWindow : Window
40 | {
41 | public MainWindow()
42 | {
43 | InitializeComponent();
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Direct2dWPF/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("Direct2dWPF")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("Direct2dWPF")]
15 | [assembly: AssemblyCopyright("Copyright © 2014")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/Direct2dWPF/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.34014
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Direct2dWPF.Properties
12 | {
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Direct2dWPF.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Direct2dWPF/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/Direct2dWPF/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.34014
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Direct2dWPF.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Direct2dWPF/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Direct2dWPF/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Direct2dOnWPF
2 | =============
3 |
4 | An example C# project which shows the usage of direct2d within a WPF window via SharpDX. The project also includes some classes, which you can directly copy to your project.
5 |
6 | The library in the example project can be used as a starting point to derive your Direct2DControl by just overwriting the Render method.
7 |
8 | Everything in this project is free for use, but I do not give warranty of any kind.
9 |
10 | Thanks to the author in SharpDX-Forum [1] and thanks to the SharpDX team, who privides the glue between DirectX and .Net.
11 |
12 | [1] http://sharpdx.org/forum/5-api-usage/567-wpf-and-direct2d
13 |
14 | ---
15 |
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 |
--------------------------------------------------------------------------------