PdfSharp.Xps.Rendering.PdfContentWriter.WriteStrokeGeometry C# (CSharp) Méthode

WriteStrokeGeometry() private méthode

Strokes the path geometry with the Stroke brush.
private WriteStrokeGeometry ( PdfSharp.Xps.XpsModel.Path path ) : void
path PdfSharp.Xps.XpsModel.Path
Résultat void
    private void WriteStrokeGeometry(Path path)
    {
      if (path.Stroke == null)
        return;

      SolidColorBrush sBrush;
      LinearGradientBrush lgBrush;
      RadialGradientBrush rgBrush;
      VisualBrush vBrush;
      ImageBrush iBrush;

      //if (path.Stroke != null && this.renderMode == RenderMode.Default) // HACK

      if ((sBrush = path.Stroke as SolidColorBrush) != null)
      {
        RealizeStroke(path);
        WriteGeometry(path.Data);
        WriteLiteral("S\n");
      }
      else if ((lgBrush = path.Stroke as LinearGradientBrush) != null)
      {
        PdfExtGState xgState = Context.PdfDocument.Internals.CreateIndirectObject<PdfExtGState>();
        xgState.SetDefault1();

        double opacity = Opacity * lgBrush.Opacity; ;
        if (opacity < 1)
        {
          xgState.StrokeAlpha = opacity;
          xgState.NonStrokeAlpha = opacity;
        }
        RealizeExtGState(xgState);

        // /CS1 CS /P0 SCN
        // 7.5 w 
        // q 1 0 0 1 15.5 462.9 cm
        // 0 0 m
        // 153 0 l
        // 153 -93 l
        // 0 -93 l
        // h
        // S
        // Q
        if (lgBrush.GradientStops.HasTransparency)
        {
          // TODO: Create Form
          PdfShadingPattern pattern = LinearShadingBuilder.BuildPatternFromLinearGradientBrush(Context, lgBrush, Transform);
          string paName = Resources.AddPattern(pattern);
          WriteLiteral("/Pattern CS " + paName + " SCN\n");
          WriteLiteral("q {0:0.###} w", path.StrokeThickness);
          WriteGeometry(path.Data);
          WriteLiteral("S Q\n");

          //// Create a FormXObject with a soft mask
          //PdfFormXObject form = LinearShadingBuilder.BuildFormFromLinearGradientBrush(Context, lgBrush, path.Data);
          //string foName = Resources.AddForm(form);
          //WriteLiteral(foName + " Do\n");
        }
        else
        {
          PdfShadingPattern pattern = LinearShadingBuilder.BuildPatternFromLinearGradientBrush(Context, lgBrush, Transform);
          string paName = Resources.AddPattern(pattern);
          WriteLiteral("/Pattern CS " + paName + " SCN\n");
          WriteLiteral("q {0:0.###} w", path.StrokeThickness);
          WriteGeometry(path.Data);
          WriteLiteral("S Q\n");
        }
      }
      else if ((rgBrush = path.Stroke as RadialGradientBrush) != null)
      {
        // HACK
        WriteLiteral("/DeviceRGB CS 0 1 0 RG\n");
        WriteLiteral("q {0:0.###} w", path.StrokeThickness);
        WriteGeometry(path.Data);
        WriteLiteral("S Q\n");
      }
      else if ((iBrush = path.Stroke as ImageBrush) != null)
      {
        // HACK
        WriteLiteral("/DeviceRGB CS 0 1 0 RG\n");
        WriteLiteral("q {0:0.###} w", path.StrokeThickness);
        WriteGeometry(path.Data);
        WriteLiteral("S Q\n");
      }
      else if ((vBrush = path.Stroke as VisualBrush) != null)
      {
        // HACK
        WriteLiteral("/DeviceRGB CS 0 1 0 RG\n");
        WriteLiteral("q {0:0.###} w", path.StrokeThickness);
        WriteGeometry(path.Data);
        WriteLiteral("S Q\n");
      }
      else
        Debug.Assert(false);
    }