Search code examples
c#.net-4.0c++-clidirect2d

How is selection/picking supposed to work in Direct2D?


I want to move my C# application from GDI+ to Direct2D (C++/CLI wrapper) for performance reasons. However I don't know how to solve the picking part. I have some shapes and images that I can move around. Currently I do it with GraphicsPath.IsVisible most of the time. Do you know what would be the equivalent in Direct2D?


Solution

  • The FillContainsPoint or StrokeContainsPoint methods of shapes implementing ID2D1Geometry might work for you:

    • FillContainsPoint - Indicates whether the area filled by the geometry would contain the specified point.
    • StrokeContainsPoint - Determines whether the geometry's stroke contains the specified point.

    I found these from the Geometries Overview on MSDN.