How do I process and create PDF patterns and shadings using PDFNet?

Q: In the test I could not figure out a way to create a Patterns and
Shadings when I am reading a page element. There is no constructor
for PatternColor there are no functions that return a PatterColor.
How is it supposed to be used?

When I get an element with a fill pattern I can get the dictionary and
read it. I tried creating a Shading with the object that is in the
dictionary an I get exceptions.
----
A: Did you have a chance to take a look at PatternTest sample project
(http://www.pdftron.com/net/samplecode.html#Pattern)?
This sample show how to use PDFNet API to create both tiling patterns
as well as smooth shading patterns (i.e. gradients such as axial and
radial fill).

In case you would like to process patterns while reading (parsing) PDF
content you can instantiate high-level object from their low-level
objects (i.e. SDF/Cos object). For example,

static void ProcessElements(ElementReader reader)
{
  Element element;
  while ((element = reader.Next()) != null) // Read page contents
  {
    switch (element.GetType())
    {
    case Element.Type.e_shading: // Process Shading (sh operator)
      {
        Obj shad_obj = element.GetShading();
        Shading shading = new pdftron.PDF.Shading(shad_obj);
        ProcessShading(shading);
        break;
      }
    case Element.Type.e_form: // Process form XObjects
      {
        reader.FormBegin();
        ProcessElements(reader);
        reader.End();
        break;
      }
    case Element.Type.e_path: // Process paths...
      {
        ProcessPath(element);
        break;
      }
    case Element.Type.e_text_begin: // Process text...
      {
        ProcessText(element);
        break;
      }
    // ... Process other elements ... }
  }
}

Processing of patterns/shading that are used as a fill color for path
or text element can be done as part of their Process methods. For
example:

static public void ProcessPath(Element path, ElementReader reader)
{
  // See ElementReaderAdv sample (http://www.pdftron.com/net/
samplecode.html#ElementReaderAdv)
  // for more info...

       // This sample is only a minimal sketch illustrating how to
process patterns...
  if (path.IsFilled())
  {
    GState gs = path.GetGState();
    if (gs.GetFillColorSpace().GetType() == ColorSpace.Type.e_pattern)
    {
      Obj pattern = gs.GetFillPattern();
      PatternColor pat = new PatternColor(pattern);
      PatternColor.Type type = pat.GetType();
      if (type == PatternColor.Type.e_shading)
      {
        Shading shading = new pdftron.PDF.Shading(shad_obj);
        // ... ProcessShading(shading) ...
        return;
      }
      else if (type == PatternColor.Type.e_colored_tiling_pattern ||
        type == PatternColor.Type.e_uncolored_tiling_pattern)
      {
        // init_pat_gs is the graphics state that was in effect at the
beginning of the
        // pattern’s parent content stream.
        GState init_pat_gs = reader.PatternBegin(pattern, true); // Open
the pattern
        // ... Process tiling pattern
        reader.End();
    }
    else
    {
      // ColorPt rgb = new ColorPt();
      // gs.GetFillColorSpace().Convert2RGB(gs.GetFillColor(), rgb);
    }
  }
  else
  {
    // Do not fill path
  }
}