ThinkGeo.com    |     Documentation    |     Premium Support

Rendering Shapes with Gradients & Hatches

I have a couple area based shapefiles that I would like to render  with a hatch style and gradient style instead of a solid color.  In the code below I have tried using the GeoHatchBrush and the AreaStyleAdvanced objects to accomplish the Hatch Style but I'm not sure how to add this style to the zoom level.  When I try to add it to the CustomStyles colllection off of the zoom level it won't take it and throws a compiler error.


Dim MyAreaStyle As New AreaStyleAdvanced()


Dim MyHatchBrush As New GeoHatchBrush(GeoHatchStyle.Percent20, GeoColor.SimpleColors.Black, GeoColor.SimpleColors.Green)


MyAreaStyle.FillCustomBrush = MyHatchBrush
 
worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(MyAreaStyle)

Where should I be setting the style if the CustomStyles collection won't work?


Thanks


 


 



Clint,


You are almost there. I just changed one place and your code now works. Code: 



        Dim myAreaStyle As New AreaStyle()
        Dim MyHatchBrush As New GeoHatchBrush(GeoHatchStyle.Percent20, GeoColor.SimpleColors.Black, GeoColor.SimpleColors.Green)
        myAreaStyle.Advanced.FillCustomBrush = MyHatchBrush

        worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(myAreaStyle)



And here is the result:



Ben



Thanks Ben, that worked great! 
  
 So what is the AreaStyleAdvanced object and when would it be used? 


Clint, 
  
 The reason we have this object is based on the idea of progressive API, which means making common things easier, making advanced things possible, and hiding the fewer used APIs from the mainstream. 
  
 For instance, as SolidBrush is commonly used for an areaStyle, we directly exposed a SolidBrush instead of a general Brush in AreaStyle to make most people easier to find the specific brush they need. For advanced usage, we provide the advanced properties within AreaStyle.Advanced to group them and make them also easy to find. Now you can see it’s no need to create an “advanced object” like AreaStyleAdvanced as that’s only for grouping APIs. 
  
 Not only in AreaStyle, you can also find the “Advanced” properties in other classes like PointStyle and TextStyle. Also you can see the idea of "Progressive API" affects through all our API structure. 
  
 Ben