コード例 #1
0
        public CardPdfBuilder(PageSize pageSize, double scalingPercent, bool hasCutLines, CutLineSizes cutLineSize, XKnownColor cutLineColor)
        {
            PageSize       = pageSize;
            ScalingPercent = scalingPercent;
            HasCutLines    = hasCutLines;
            CutLineSize    = cutLineSize;
            CutLineColor   = cutLineColor;

            Document = new PdfDocument
            {
                Info =
                {
                    Title        = "Card Mimic",
                    Author       = "Sean Bodine",
                    CreationDate = DateTime.Now,
                    Creator      = "Card Mimic",
                    Subject      = "MTG Proxies",
                }
            };

            var firstPage = new PdfPage {
                Size = PageSize
            };

            Document.AddPage(firstPage);
            Pages = new List <CardPage> {
                new CardPage(firstPage, ScalingPercent, HasCutLines, CutLineSize, CutLineColor)
            };
        }
コード例 #2
0
ファイル: CardPage.cs プロジェクト: bodines1/Boxy
        public CardPage(PdfPage page, double scalingPercent, bool hasCutLines, CutLineSizes cutLineSize, XKnownColor cutLineColor)
        {
            ScalingPercent = scalingPercent;
            HasCutLines    = hasCutLines;
            CutLineSize    = cutLineSize;
            CutLineColor   = cutLineColor;
            Gfx            = XGraphics.FromPdfPage(page);

            // Set Gutter
            GutterThickness = HasCutLines ? CutLineSize.ToPointSize() : 0;

            // Set some properties other methods will need to use.
            PointsPerInch = page.Width.Point / page.Width.Inch;
            Margin        = 0.25 * PointsPerInch;
            UseableX      = page.Width - 2 * Margin;
            UseableY      = page.Height - 2 * Margin;

            // MTG cards are 3.48 x 2.49 inches or 63 x 88 mm, then slightly scaled down to fit better in card sleeves.
            CardSize = new XSize(2.49 * PointsPerInch * ScalingPercent / 100 * 0.99, 3.48 * PointsPerInch * ScalingPercent / 100 * 0.99);

            // Predict the number of cards per row and cards per column.
            Rows         = (int)((UseableY - GutterThickness) / (CardSize.Height + GutterThickness));
            Columns      = (int)((UseableX - GutterThickness) / (CardSize.Width + GutterThickness));
            CardsPerPage = Rows * Columns;

            // Calculate how much to shift all images to center everything on the page. Helps with printers which have trouble printing near the edge.
            var usedY = GutterThickness + (Rows * (CardSize.Height + GutterThickness));
            var usedX = GutterThickness + (Columns * (CardSize.Width + GutterThickness));

            // Half of what is not used inside the margins
            VerticalCenteringOffset   = (UseableY - usedY) / 2.0;
            HorizontalCenteringOffset = (UseableX - usedX) / 2.0;
        }
コード例 #3
0
 public ColorResourceInfo(XKnownColor knownColor, XColor color, uint argb, string name, string nameDE)
 {
     this.knownColor = knownColor;
     this.color      = color;
     this.Argb       = argb;
     this.Name       = name;
     this.NameDE     = nameDE;
 }
コード例 #4
0
 public ColorResourceInfo(XKnownColor knownColor, XColor color, uint argb, string name, string nameDE)
 {
     KnownColor = knownColor;
     Color      = color;
     Argb       = argb;
     Name       = name;
     NameDE     = nameDE;
 }
コード例 #5
0
 public static uint KnownColorToArgb(XKnownColor color)
 {
     if (ColorTable == null)
     {
         InitColorTable();
     }
     return(color <= XKnownColor.YellowGreen ? ColorTable[(int)color] : 0);
 }
コード例 #6
0
 public static uint KnownColorToArgb(XKnownColor color)
 {
   if (XKnownColorTable.colorTable == null)
     InitColorTable();
   if (color <= XKnownColor.YellowGreen)
     return XKnownColorTable.colorTable[(int)color];
   return 0;
 }
コード例 #7
0
 public static uint KnownColorToArgb(XKnownColor color)
 {
     if (ColorTable == null)
         InitColorTable();
     if (color <= XKnownColor.YellowGreen)
         return ColorTable[(int)color];
     return 0;
 }
コード例 #8
0
        /// <summary>
        /// Gets a known color from an ARGB value. Throws an ArgumentException if the value is not a known color.
        /// </summary>
        public static XKnownColor GetKnownColor(uint argb)
        {
            XKnownColor knownColor = XKnownColorTable.GetKnownColor(argb);

            if ((int)knownColor == -1)
            {
                throw new ArgumentException("The argument is not a known color", "argb");
            }
            return(knownColor);
        }
コード例 #9
0
        /// <summary>
        /// Gets all known colors.
        /// </summary>
        /// <param name="includeTransparent">Indicates whether to include the color Transparent.</param>
        public static XKnownColor[] GetKnownColors(bool includeTransparent)
        {
            int count = colorInfos.Length;

            XKnownColor[] knownColor = new XKnownColor[count - (includeTransparent ? 0 : 1)];
            for (int idxIn = includeTransparent ? 0 : 1, idxOut = 0; idxIn < count; idxIn++, idxOut++)
            {
                knownColor[idxOut] = colorInfos[idxIn].KnownColor;
            }
            return(knownColor);
        }
コード例 #10
0
ファイル: ColorComboBox.cs プロジェクト: fedoaa/PDFsharp
        void Fill()
        {
            Items.Add(new ColorItem(XColor.Empty, "custom"));
            XKnownColor[] knownColors = XColorResourceManager.GetKnownColors(false);
            int           count       = knownColors.Length;

            for (int idx = 0; idx < knownColors.Length; idx++)
            {
                XKnownColor color = knownColors[idx];
                Items.Add(new ColorItem(XColor.FromKnownColor(color), _crm.ToColorName(color)));
            }
        }
コード例 #11
0
 static ColorResourceInfo GetColorInfo(XKnownColor knownColor)
 {
     for (int idx = 0; idx < colorInfos.Length; idx++)
     {
         ColorResourceInfo colorInfo = colorInfos[idx];
         if (colorInfo.KnownColor == knownColor)
         {
             return(colorInfo);
         }
     }
     throw new InvalidEnumArgumentException("Enum is not an XKnownColor.");
 }
コード例 #12
0
        /// <summary>
        /// Converts a known color to a localized color name.
        /// </summary>
        public string ToColorName(XKnownColor knownColor)
        {
            ColorResourceInfo colorInfo = GetColorInfo(knownColor);

            // Currently German only
            if (_cultureInfo.TwoLetterISOLanguageName == "de")
            {
                return(colorInfo.NameDE);
            }

            return(colorInfo.Name);
        }
コード例 #13
0
 public static uint KnownColorToArgb(XKnownColor color)
 {
     if (XKnownColorTable.colorTable == null)
     {
         InitColorTable();
     }
     if (color <= XKnownColor.YellowGreen)
     {
         return(XKnownColorTable.colorTable[(int)color]);
     }
     return(0);
 }
コード例 #14
0
ファイル: XColor.cs プロジェクト: inexorabletash/PDFsharp
 /// <summary>
 /// Creates an XColor from the specified pre-defined color.
 /// </summary>
 public static XColor FromKnownColor(XKnownColor color)
 {
   return new XColor(color);
 }
コード例 #15
0
ファイル: XColor.cs プロジェクト: inexorabletash/PDFsharp
 internal XColor(XKnownColor knownColor)
   : this(XKnownColorTable.KnownColorToArgb(knownColor))
 { }
コード例 #16
0
 public ColorResourceInfo(XKnownColor knownColor, XColor color, uint argb, string name, string nameDE)
 {
   this.knownColor = knownColor;
   this.color = color;
   this.Argb = argb;
   this.Name = name;
   this.NameDE = nameDE;
 }
コード例 #17
0
 static ColorResourceInfo GetColorInfo(XKnownColor knownColor)
 {
   for (int idx = 0; idx < colorInfos.Length; idx++)
   {
     ColorResourceInfo colorInfo = colorInfos[idx];
     if (colorInfo.knownColor == knownColor)
       return colorInfo;
   }
   throw new InvalidEnumArgumentException("Enum is not an XKnownColor.");
 }
コード例 #18
0
 public ColorResourceInfo(XKnownColor knownColor, XColor color, uint argb, string name, string nameDE)
 {
     KnownColor = knownColor;
     Color = color;
     Argb = argb;
     Name = name;
     NameDE = nameDE;
 }
コード例 #19
0
 internal XColor(XKnownColor knownColor)
     : this(XKnownColorTable.KnownColorToArgb(knownColor))
 {
 }
コード例 #20
0
    /// <summary>
    /// Converts a known color to a localized color name.
    /// </summary>
    public string ToColorName(XKnownColor knownColor)
    {
      ColorResourceInfo colorInfo = GetColorInfo(knownColor);

      // Currently German only
      if (this.cultureInfo.TwoLetterISOLanguageName == "de")
        return colorInfo.NameDE;

      return colorInfo.Name;
    }
コード例 #21
0
ファイル: XColor.cs プロジェクト: RefactorForce/PDFSharp
 /// <summary>
 /// Creates an XColor from the specified pre-defined color.
 /// </summary>
 public static XColor FromKnownColor(XKnownColor color) => new XColor(color);
コード例 #22
0
 /// <summary>
 /// Creates an XColor from the specified pre-defined color.
 /// </summary>
 public static XColor FromKnownColor(XKnownColor color)
 {
     return(new XColor(color));
 }
コード例 #23
0
 /// <summary>
 /// Gets all known colors.
 /// </summary>
 /// <param name="includeTransparent">Indicates whether to include the color Transparent.</param>
 public static XKnownColor[] GetKnownColors(bool includeTransparent)
 {
   int count = colorInfos.Length;
   XKnownColor[] knownColor = new XKnownColor[count - (includeTransparent ? 0 : 1)];
   for (int idxIn = includeTransparent ? 0 : 1, idxOut = 0; idxIn < count; idxIn++, idxOut++)
     knownColor[idxOut] = colorInfos[idxIn].knownColor;
   return knownColor;
 }