Exemplo n.º 1
1
    protected Base()
    {
      this.backColor = XColors.Ivory;
      this.backColor2 = XColors.WhiteSmoke;

      this.backColor = XColor.FromArgb(212, 224, 240);
      this.backColor2 = XColor.FromArgb(253, 254, 254);

      this.shadowColor = XColors.Gainsboro;
      this.borderWidth = 4.5;
      this.borderPen = new XPen(XColor.FromArgb(94, 118, 151), this.borderWidth);//new XPen(XColors.SteelBlue, this.borderWidth);
    }
        /// <summary>
        /// Initializes a new instance of the <see cref="ArrowAnnotation"/> class.
        /// </summary>
        /// <param name="color">The arrow color.</param>
        /// <param name="x1">The x1.</param>
        /// <param name="y1">The y1.</param>
        /// <param name="x2">The x2.</param>
        /// <param name="y2">The y2.</param>
        public ArrowAnnotation(XColor color, float x1, float y1, float x2, float y2)
        {
            Elements.SetName(Keys.Subtype, "/Line");

            var line = new PdfArray();
            line.Elements.Add(new PdfReal(x1));
            line.Elements.Add(new PdfReal(y1));
            line.Elements.Add(new PdfReal(x2));
            line.Elements.Add(new PdfReal(y2));
            Elements["/L"] = line;

            // change line ending
            PdfArray end = new PdfArray();
            end.Elements.Add(new PdfName("/ClosedArrow"));
            end.Elements.Add(new PdfName("/None"));
            Elements["/LE"] = end;

            // change all color properties
            Elements.SetColor("/IC", color);
            Color = color;

            // change line width
            var bsDict = new PdfBorderStyle(3, BorderStyle.Solid);
            Elements[Keys.BS] = bsDict;
        }
Exemplo n.º 3
0
 public PageOfCards(XColor foregroundColor, XColor backgroundColor, IEnumerable<Card> cards, string fontName)
 {
     _foregroundColor = foregroundColor;
     _backgroundColor = backgroundColor;
     _cards = cards;
     _fontName = fontName;
 }
Exemplo n.º 4
0
    /// <summary>
    /// Checks whether the color mode of a document and a color match.
    /// </summary>
    public static XColor EnsureColorMode(PdfDocument document, XColor color)
    {
      if (document == null)
        throw new ArgumentNullException("document");

      return EnsureColorMode(document.Options.ColorMode, color);
    }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PdfOutline"/> class.
 /// </summary>
 /// <param name="title">The outline text.</param>
 /// <param name="destinationPage">The destination page.</param>
 /// <param name="opened">Specifies whether the node is displayed expanded (opened) or collapsed.</param>
 /// <param name="style">The font style used to draw the outline text.</param>
 /// <param name="textColor">The color used to draw the outline text.</param>
 public PdfOutline(string title, PdfPage destinationPage, bool opened, PdfOutlineStyle style, XColor textColor)
 {
     Title = title;
     DestinationPage = destinationPage;
     Opened = opened;
     Style = style;
     TextColor = textColor;
 }
 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 {
     SolidColorBrush brush = (SolidColorBrush)value;
     XColor xColor = new XColor();
     xColor.R = brush.Color.R;
     xColor.G = brush.Color.G;
     xColor.B = brush.Color.B;
     xColor.A = (double)brush.Color.A / 255.0;
     return xColor;
 }
 /// <summary>
 /// Sets the color to the specified key.
 /// </summary>
 /// <param name="elements">The elements.</param>
 /// <param name="key">The key.</param>
 /// <param name="color">The color.</param>
 public static void SetColor(this PdfDictionary.DictionaryElements elements, string key, XColor color)
 {
     if (elements == null) { throw new ArgumentNullException("elements"); }
     if (!string.IsNullOrEmpty(key))
     {
         var arr = new PdfArray();
         arr.Elements.Add(new PdfReal(color.R / (double)byte.MaxValue));
         arr.Elements.Add(new PdfReal(color.G / (double)byte.MaxValue));
         arr.Elements.Add(new PdfReal(color.B / (double)byte.MaxValue));
         elements[key] = arr;
     }
 }
Exemplo n.º 8
0
    /// <summary>
    /// Checks whether a color mode and a color match.
    /// </summary>
    public static XColor EnsureColorMode(PdfColorMode colorMode, XColor color)
    {
#if true
      if (colorMode == PdfColorMode.Rgb && color.ColorSpace != XColorSpace.Rgb)
        return XColor.FromArgb((int)(color.A * 255), color.R, color.G, color.B);

      if (colorMode == PdfColorMode.Cmyk && color.ColorSpace != XColorSpace.Cmyk)
        return XColor.FromCmyk(color.A, color.C, color.M, color.Y, color.K);

      return color;
#else
      if (colorMode == PdfColorMode.Rgb && color.ColorSpace != XColorSpace.Rgb)
        throw new InvalidOperationException(PSSR.InappropriateColorSpace(colorMode, color.ColorSpace));

      if (colorMode == PdfColorMode.Cmyk && color.ColorSpace != XColorSpace.Cmyk)
        throw new InvalidOperationException(PSSR.InappropriateColorSpace(colorMode, color.ColorSpace));
#endif
    }
        /// <summary>
        /// Initializes a new instance of the <see cref="FreeTextAnnotation"/> class.
        /// </summary>
        /// <param name="color">The text color.</param>
        /// <param name="font">The font name.</param>
        /// <param name="fontSize">Size of the font.</param>
        public FreeTextAnnotation(XColor color, string font, double fontSize)
        {
            Elements.SetName(Keys.Subtype, "/FreeText");
            
            string daString = string.Format(CultureInfo.InvariantCulture,
                "{0} {1} {2} rg /{3} {4} Tf /BG []",
                color.R / (double)byte.MaxValue,
                color.G / (double)byte.MaxValue,
                color.B / (double)byte.MaxValue,
                font, fontSize);
            Elements["/DA"] = new PdfString(daString);

            // no border
            var border = new PdfArray();
            border.Elements.Add(new PdfInteger(0));
            border.Elements.Add(new PdfInteger(0));
            border.Elements.Add(new PdfInteger(0));
            Elements[Keys.Border] = border;
        }
Exemplo n.º 10
0
    /// <summary>
    /// Gets a PdfExtGState with the key 'ca' set to the specified alpha value.
    /// </summary>
    public PdfExtGState GetExtGState(XColor strokeColor, XColor nonStrokeColor)
    {
      if (strokeColor.IsEmpty)
      {
      }
      else if (nonStrokeColor.IsEmpty)
      {
      }
      else
      {
      }

      return null;
      //string key = MakeKey(alpha);
      //PdfExtGState extGState = this.nonStrokeAlphaValues[key] as PdfExtGState;
      //if (extGState == null)
      //{
      //  extGState = new PdfExtGState(this.document);
      //  extGState.Elements[PdfExtGState.Keys.ca] = new PdfReal(alpha);
      //
      //  this.nonStrokeAlphaValues[key] = extGState;
      //}
      //return extGState;
    }
Exemplo n.º 11
0
    /// <summary>
    /// Creates a XPen based on the specified line format. If not specified color, width and dash style
    /// will be taken from the defaultColor, defaultWidth and defaultDashStyle parameters.
    /// </summary>
    internal static XPen ToXPen(LineFormat lineFormat, XColor defaultColor, double defaultWidth, XDashStyle defaultDashStyle)
    {
      XPen pen = null;
      if (lineFormat == null)
      {
        pen = new XPen(defaultColor, defaultWidth);
        pen.DashStyle = defaultDashStyle;
      }
      else
      {
        XColor color = defaultColor;
        if (!lineFormat.Color.IsEmpty)
          color = lineFormat.Color;

        double width = lineFormat.Width.Point;
        if (!lineFormat.Visible)
          width = 0;
        if (lineFormat.Visible && width == 0)
          width = defaultWidth;

        pen = new XPen(color, width);
        pen.DashStyle = lineFormat.dashStyle;
        pen.DashOffset = 10 * width;
      }
      return pen;
    }
Exemplo n.º 12
0
 /// <summary>
 /// Creates a XPen based on the specified line format. If not specified color and width will be taken
 /// from the defaultColor and defaultWidth parameter.
 /// </summary>
 internal static XPen ToXPen(LineFormat lineFormat, XColor defaultColor, double defaultWidth)
 {
   return ToXPen(lineFormat, defaultColor, defaultWidth, XDashStyle.Solid);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Creates a XBrush based on the specified font color. If not specified, color will be taken
 /// from the defaultColor parameter.
 /// </summary>
 internal static XBrush ToXBrush(Font font, XColor defaultColor)
 {
   if (font == null || font.color.IsEmpty)
     return new XSolidBrush(defaultColor);
   return new XSolidBrush(font.color);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Creates a XBrush based on the specified fill format. If not specified, color will be taken
 /// from the defaultColor parameter.
 /// </summary>
 internal static XBrush ToXBrush(FillFormat fillFormat, XColor defaultColor)
 {
   if (fillFormat == null || fillFormat.color.IsEmpty)
     return new XSolidBrush(defaultColor);
   return new XSolidBrush(fillFormat.color);
 }
Exemplo n.º 15
0
    /// <summary>
    /// Converts an XColor into a string with up to 3 decimal digits and a decimal point.
    /// </summary>
    public static string ToString(XColor color, PdfColorMode colorMode)
    {
      // If not defined let color decide
      if (colorMode == PdfColorMode.Undefined)
      {
        if (color.ColorSpace == XColorSpace.Cmyk)
          colorMode = PdfColorMode.Cmyk;
        else
          colorMode = PdfColorMode.Rgb;
      }
      switch (colorMode)
      {
        case PdfColorMode.Cmyk:
          return String.Format(CultureInfo.InvariantCulture, "{0:0.###} {1:0.###} {2:0.###} {3:0.###}",
            color.C, color.M, color.Y, color.K);

        default:
          return String.Format(CultureInfo.InvariantCulture, "{0:0.###} {1:0.###} {2:0.###}",
            color.R / 255.0, color.G / 255.0, color.B / 255.0);
      }
    }
Exemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XPen"/> class.
 /// </summary>
 public XPen(XColor color, double width)
     : this(color, width, false)
 {
 }
Exemplo n.º 17
0
 /// <summary>
 /// Determines wheter two colors are equal refering to their CMYK color values.
 /// </summary>
 public static bool IsEqualCmyk(XColor x, XColor y)
 {
   if (x.ColorSpace != XColorSpace.Cmyk || y.ColorSpace != XColorSpace.Cmyk)
     return false;
   return x.C == y.C && x.M == y.M && x.Y == y.Y && x.K == y.K;
 }
Exemplo n.º 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XSolidBrush"/> class.
 /// </summary>
 public XSolidBrush(XColor color)
     : this(color, false)
 {
 }
Exemplo n.º 19
0
 /// <summary>
 /// Creates an XColor structure from the specified alpha value and color.
 /// </summary>
 public static XColor FromArgb(int alpha, XColor color)
 {
     color.A = ((byte)alpha) / 255.0;
     return(color);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="XLinearGradientBrush"/> class.
 /// </summary>
 public XLinearGradientBrush(PointF point1, PointF point2, XColor color1, XColor color2)
     : this(new XPoint(point1), new XPoint(point2), color1, color2)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="XLinearGradientBrush"/> class.
 /// </summary>
 public XLinearGradientBrush(System.Drawing.Point point1, System.Drawing.Point point2, XColor color1, XColor color2)
     : this(new XPoint(point1), new XPoint(point2), color1, color2)
 {
 }
Exemplo n.º 22
0
 /// <summary>
 /// Converts an XColor into a string with up to 3 decimal digits and a decimal point.
 /// </summary>
 public static string ToString(XColor color)
 {
   return String.Format(CultureInfo.InvariantCulture, "{0:0.###} {1:0.###} {2:0.###}",
     color.R / 255.0, color.G / 255.0, color.B / 255.0);
 }
Exemplo n.º 23
0
 internal XSolidBrush(XColor color, bool immutable)
 {
     this.color     = color;
     this.immutable = immutable;
 }
Exemplo n.º 24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XPen"/> class.
 /// </summary>
 public XPen(XColor color)
     : this(color, 1, false)
 {
 }
Exemplo n.º 25
0
 internal XSolidBrush(XColor color, bool immutable)
 {
     _color     = color;
     _immutable = immutable;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="XLinearGradientBrush"/> class.
 /// </summary>
 public XLinearGradientBrush(RectangleF rect, XColor color1, XColor color2, XLinearGradientMode linearGradientMode)
     : this(new XRect(rect), color1, color2, linearGradientMode)
 {
 }
Exemplo n.º 27
0
 /// <summary>
 /// Adds the specified outline entry.
 /// </summary>
 /// <param name="title">The outline text.</param>
 /// <param name="destinationPage">The destination page.</param>
 /// <param name="opened">Specifies whether the node is displayed expanded (opened) or collapsed.</param>
 /// <param name="style">The font style used to draw the outline text.</param>
 /// <param name="textColor">The color used to draw the outline text.</param>
 public PdfOutline Add(string title, PdfPage destinationPage, bool opened, PdfOutlineStyle style, XColor textColor)
 {
   PdfOutline outline = new PdfOutline(title, destinationPage, opened, style, textColor);
   Add(outline);
   return outline;
 }
Exemplo n.º 28
0
        /// <summary>
        /// Converts an XColor into a string with up to 3 decimal digits and a decimal point.
        /// </summary>
        public static string ToString(XColor color, PdfColorMode colorMode)
        {
            const string format = Config.SignificantFigures3;

            // If not defined let color decide
            if (colorMode == PdfColorMode.Undefined)
                colorMode = color.ColorSpace == XColorSpace.Cmyk ? PdfColorMode.Cmyk : PdfColorMode.Rgb;

            switch (colorMode)
            {
                case PdfColorMode.Cmyk:
                    return String.Format(CultureInfo.InvariantCulture, "{0:" + format + "} {1:" + format + "} {2:" + format + "} {3:" + format + "}",
                      color.C, color.M, color.Y, color.K);

                default:
                    return String.Format(CultureInfo.InvariantCulture, "{0:" + format + "} {1:" + format + "} {2:" + format + "}",
                      color.R / 255.0, color.G / 255.0, color.B / 255.0);
            }
        }