D2Phap.DXControl 1.0.6

Additional Details

Please use v2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package D2Phap.DXControl --version 1.0.6
NuGet\Install-Package D2Phap.DXControl -Version 1.0.6
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="D2Phap.DXControl" Version="1.0.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add D2Phap.DXControl --version 1.0.6
#r "nuget: D2Phap.DXControl, 1.0.6"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install D2Phap.DXControl as a Cake Addin
#addin nuget:?package=D2Phap.DXControl&version=1.0.6

// Install D2Phap.DXControl as a Cake Tool
#tool nuget:?package=D2Phap.DXControl&version=1.0.6

D2Phap.DXControl

  • A WinForms hybrid control that supports Direct2D and GDI+ drawing thanks to DirectN and WicNet.
  • This control is used in ImageGlass software since version 9.0.

Nuget

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 draw by GDI+.
  • Supports animation drawing for both Direct2D and GDI+.

Requirements:

  • .NET 6.0

Installation

Run the command

Install-Package D2Phap.DXControl

Example

Draw 2 rectangles by Direct2D and GDI+ graphics, then animate it to the right side.

<img src="https://user-images.githubusercontent.com/3154213/181906424-27418cfd-5f41-4380-8ae9-0ea577c91b16.png" width="500" />

using D2Phap;

// create a WinForms custom control that extends from DXControl
public class DXCanvas : DXControl
{
    private D2D_RECT_F animatableRectangle = new(100f, 100f, new(400, 200));

    public DXCanvas()
    {
        EnableAnimation = true;
    }

    // use Direct2D graphics
    protected override void OnRender(DXGraphics g)
    {
        // draw a yellow rectangle with green border
        g.FillRectangle(rectText, _D3DCOLORVALUE.FromCOLORREF(_D3DCOLORVALUE.Yellow.Int32Value, 100));
        g.DrawRectangle(rectText, _D3DCOLORVALUE.Green);
    }


    // Use GDI+ graphics
    protected override void OnRender(Graphics g)
    {
        // draw a yellow rectangle with green border
        using var pen = new Pen(Color.Red, 5);
        g.DrawRectangle(pen, new Rectangle((int)rectText.left, (int)rectText.top - 50, (int)rectText.Width, (int)rectText.Height));
    }


    // 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

Support this project

Thanks for your gratitude and finance help!

Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0-windows7.0

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on D2Phap.DXControl:

Repository Stars
d2phap/ImageGlass
🏞 A lightweight, versatile image viewer
Version Downloads Last updated
3.1.0 289 1/21/2024
3.0.2 175 12/28/2023
3.0.1 236 11/16/2023
3.0.0 120 11/8/2023
2.7.0 147 10/6/2023
2.6.0 194 7/8/2023
2.5.0 291 2/25/2023
2.4.1 343 1/28/2023
2.4.0 320 1/28/2023
2.3.1 388 12/15/2022
2.3.0 340 12/14/2022
2.2.0 487 10/20/2022
2.1.0 461 9/24/2022
2.0.0 484 8/20/2022
1.1.0 496 8/5/2022
1.0.6 512 7/31/2022
1.0.5 433 7/31/2022
1.0.4 440 7/31/2022
1.0.3 472 7/30/2022
1.0.2 526 7/30/2022
1.0.1 532 7/30/2022
1.0.0 544 7/30/2022