A WinForms control that supports drawing with Direct2D thanks to WicNet. This control has being used in https://github.com/d2phap/ImageGlass since version 9.
$ dotnet add package D2Phap.DXControlRun the command
Install-Package D2Phap.DXControl
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!