https://github.com/d2phap/dxcontrol
🖌️ A WinForms hybrid control that supports Direct2D and GDI+ drawing
https://github.com/d2phap/dxcontrol
csharp direct2d direct2d-bitmap direct2d-demo direct2d1 directwrite directx dotnet dotnet-core gdi-plus wic win2d windows-imaging-component winforms
Last synced: about 1 month ago
JSON representation
🖌️ A WinForms hybrid control that supports Direct2D and GDI+ drawing
- Host: GitHub
- URL: https://github.com/d2phap/dxcontrol
- Owner: d2phap
- License: mit
- Created: 2022-07-26T13:45:42.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-30T03:03:34.000Z (6 months ago)
- Last Synced: 2025-03-29T02:12:07.829Z (about 2 months ago)
- Topics: csharp, direct2d, direct2d-bitmap, direct2d-demo, direct2d1, directwrite, directx, dotnet, dotnet-core, gdi-plus, wic, win2d, windows-imaging-component, winforms
- Language: C#
- Homepage:
- Size: 477 KB
- Stars: 32
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# D2Phap.DXControl
- A WinForms control that supports drawing with Direct2D thanks to [WicNet](https://github.com/smourier/WicNet).
- This control has been used in [ImageGlass](https://github.com/d2phap/ImageGlass) software since version 9.0.
## Resource links
- Nuget package: [https://www.nuget.org/packages/D2Phap.DXControl](https://www.nuget.org/packages/D2Phap.DXControl)
- Project url: [https://github.com/d2phap/DXControl](https://github.com/d2phap/DXControl)
- About: [https://imageglass.org/about](https://imageglass.org/about)## Features
- 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.## Requirements:
- .NET 6.0, 7.0, 8.0## Installation
Run the command
```bash
Install-Package D2Phap.DXControl
```## Example
Draws a rectangle, then moves it to the right side.
```cs
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.
## License
[MIT](LICENSE)## Support this project
- [GitHub sponsor](https://github.com/sponsors/d2phap)
- [Patreon](https://www.patreon.com/d2phap)
- [PayPal](https://www.paypal.me/d2phap)Thanks for your gratitude and finance help!