- A WinForms control that supports drawing with Direct2D thanks to WicNet.
- This control has been used in ImageGlass software since version 9.0.
- Nuget package: https://www.nuget.org/packages/D2Phap.DXControl
- Project url: https://github.com/d2phap/DXControl
- About: https://imageglass.org/about
- High performance drawing using Direct2D.
- Names and types are exactly the same as the native concepts of Direct2D (interfaces, enums, structures, constants, methods, arguments, guids, etc...). So you can read the official documentation, use existing C/C++ samples, and start coding with .NET right away.
- All native COM interfaces are generated as .NET (COM) interfaces, this makes .NET programming easier, but they are not strictly needed.
- Option to use Software or Hardware render target
- Supports animation drawing with Direct2D.
- .NET 6.0, 7.0, 8.0
Run the command
Install-Package D2Phap.DXControl
![](https://private-user-images.githubusercontent.com/3154213/384604406-837414d9-b342-487b-99c9-056b8a24205d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0OTEwNzgsIm5iZiI6MTczOTQ5MDc3OCwicGF0aCI6Ii8zMTU0MjEzLzM4NDYwNDQwNi04Mzc0MTRkOS1iMzQyLTQ4N2ItOTljOS0wNTZiOGEyNDIwNWQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTNUMjM1MjU4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MmNiMzMzYjJmNzQxOTU1MzRjODljNzgzYzNmNGQwMDU0MjA3Njg3NTQ3NmUzMDVkMTVjM2IxMzBjNDY1ODZlOSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.1B9NImWUH4kX5J6v3J9mkt-5w9tquIjxKfYRQaiejck)
Draws a rectangle, then moves it to the right side.
using D2Phap.DXControl;
// create a WinForms custom control that extends from DXCanvas
public class DemoCanvas : DXCanvas
{
private RectangleF animatableRectangle = new(100, 100, 400, 200);
public DemoCanvas()
{
EnableAnimation = true;
UseHardwareAcceleration = true;
}
protected override void OnRender(DXGraphics g)
{
// draw a yellow rectangle with green border
g.FillRectangle(rectText, Color.FromArgb(100, Yellow));
g.DrawRectangle(rectText, Color.Green);
}
// Update frame logics for animation
protected override void OnFrame(FrameEventArgs e)
{
// animate the rectangle to the right
animatableRectangle.left++;
}
}
See Demo project for full details.
Thanks for your gratitude and finance help!