ThinkGeo.com    |     Documentation    |     Premium Support

Would like to be able to customize display of hatch patterns

We are using MS 10 for WinForms. I would like to know if there is a way I can create a custom area style that would fill a polygon with diagonal lines (like BackwardDiagonal or ForwardDiagonal) but have the ability to adjust the space between the diagonal lines. I have attached a pdf with an example of the drawing we would like to achieve.

Thanks!

SteveRLL_1714cc_Ex_A.pdf (299.1 KB)

Hi Steven,

I think the default styles don’t match your requirement, in fact for areastyle it call the GDI+ API:
Graphics.FillRectangle(Brush…)
and all the styles inclued in System.Drawing.Drawing2D.HatchStyle.

So this is the nearest one style I think:
AreaStyle StyleA = AreaStyles.CreateHatchStyle(GeoHatchStyle.WideUpwardDiagonal, GeoColor.StandardColors.Transparent, GeoColor.FromArgb(150, GeoColor.StandardColors.Red), GeoColor.StandardColors.Transparent, 1, LineDashStyle.Solid, 0, 0);

But it cannot set the distance between lines, so if you found a way to adjust the distance of lines of HatchStyle, I think we can try to apply it to our area style.

Here is all the default styles:

Regards,

Ethan

Hi Ethan,

Thanks for your reply!

I am not sure I understand what you mean by “if you found a way to adjust the distance of lines of HatchStyle.” Are you saying I would need to create a custom HatchStyle (inherit from HatchStyle) and override the DrawCore function? I would do that but I don’t know where to start with drawing a hatch pattern to a feature. Is there some sample code I could use to get started?

Thanks!

Steve

Hi Steve,

I view the enum again, it looks HatchStyle don’t support custom style.

And I search on internet for find a way to implement custom style for HatchStyle but also hadn’t get useful information.

So I means if you can find a way to create the custom style for GDI+, we can try to find a workaround to implement that in our map, if the GDI+ don’t support custom HatchStyle we cannot make it works also.

So you can just ignore override our class and see whether it is supported for GDI+.

Regards,

Ethan