コード例 #1
0
        internal void AddFillRect(float x, float y, float width, float height, StyleInfo si, PdfPattern patterns)
        {
            // Get the fill color - could be a gradient or pattern etc...
            Color  c     = si.BackgroundColor;
            double red   = c.R;
            double green = c.G;
            double blue  = c.B;

            red   = Math.Round((red / 255), 3);
            green = Math.Round((green / 255), 3);
            blue  = Math.Round((blue / 255), 3);


            //Fill the rectangle with the background color first...
            elements.AppendFormat(NumberFormatInfo.InvariantInfo,
                                  "\r\nq\t{0} {1} {2} RG\t{0} {1} {2} rg\t{3} {4} {5} {6} re\tf\tQ\t",
                                  red, green, blue,                              // color
                                  x, pSize.yHeight - y - height, width, height); // positioning

            //if we have a pattern paint it now...
            if (si.PatternType != patternTypeEnum.None)
            {
                string p = patterns.GetPdfPattern(si.PatternType.ToString());
                c     = si.Color;
                red   = Math.Round((c.R / 255.0), 3);
                green = Math.Round((c.G / 255.0), 3);
                blue  = Math.Round((c.B / 255.0), 3);
                elements.AppendFormat("\r\nq");
                elements.AppendFormat("\r\n /CS1 cs");
                elements.AppendFormat("\r\n {0} {1} {2} /{3} scn", red, green, blue, p);
                elements.AppendFormat("\r\n {0} {1} {2} RG", red, green, blue);
                elements.AppendFormat("\r\n {0} {1} {2} {3} re\tf", x, pSize.yHeight - y - height, width, height);
                elements.AppendFormat("\tQ");
            }
        }
コード例 #2
0
/// <summary>
/// Page Polygon
/// </summary>
/// <param name="pts"></param>
/// <param name="si"></param>
/// <param name="url"></param>
/// <param name="patterns"></param>
        internal void AddPolygon(PointF[] pts, StyleInfo si, string url, PdfPattern patterns)
        {
            if (si.BackgroundColor.IsEmpty)
            {
                return;         // nothing to do
            }
            // Get the fill color - could be a gradient or pattern etc...
            Color  c     = si.BackgroundColor;
            double red   = c.R;
            double green = c.G;
            double blue  = c.B;

            red   = Math.Round((red / 255), 3);
            green = Math.Round((green / 255), 3);
            blue  = Math.Round((blue / 255), 3);

            //Fill the polygon with the background color first...
            elements.AppendFormat(NumberFormatInfo.InvariantInfo,
                                  "\r\nq\t{0} {1} {2} RG\t{0} {1} {2} rg\t",
                                  red, green, blue); // color
            AddPoints(elements, pts);

            //if we have a pattern paint it now...
            if (si.PatternType != patternTypeEnum.None)
            {
                string p = patterns.GetPdfPattern(si.PatternType.ToString());
                c     = si.Color;
                red   = Math.Round((c.R / 255.0), 3);
                green = Math.Round((c.G / 255.0), 3);
                blue  = Math.Round((c.B / 255.0), 3);
                elements.AppendFormat("\r\nq");
                elements.AppendFormat("\r\n /CS1 cs");
                elements.AppendFormat("\r\n {0} {1} {2} /{3} scn", red, green, blue, p);
                elements.AppendFormat("\r\n {0} {1} {2} RG", red, green, blue);
                AddPoints(elements, pts);
            }
            elements.AppendFormat("\tQ");
        }