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) }; }
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; }
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; }
public ColorResourceInfo(XKnownColor knownColor, XColor color, uint argb, string name, string nameDE) { KnownColor = knownColor; Color = color; Argb = argb; Name = name; NameDE = nameDE; }
public static uint KnownColorToArgb(XKnownColor color) { if (ColorTable == null) { InitColorTable(); } return(color <= XKnownColor.YellowGreen ? ColorTable[(int)color] : 0); }
public static uint KnownColorToArgb(XKnownColor color) { if (XKnownColorTable.colorTable == null) InitColorTable(); if (color <= XKnownColor.YellowGreen) return XKnownColorTable.colorTable[(int)color]; return 0; }
public static uint KnownColorToArgb(XKnownColor color) { if (ColorTable == null) InitColorTable(); if (color <= XKnownColor.YellowGreen) return ColorTable[(int)color]; return 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); }
/// <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); }
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))); } }
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."); }
/// <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); }
public static uint KnownColorToArgb(XKnownColor color) { if (XKnownColorTable.colorTable == null) { InitColorTable(); } if (color <= XKnownColor.YellowGreen) { return(XKnownColorTable.colorTable[(int)color]); } return(0); }
/// <summary> /// Creates an XColor from the specified pre-defined color. /// </summary> public static XColor FromKnownColor(XKnownColor color) { return new XColor(color); }
internal XColor(XKnownColor knownColor) : this(XKnownColorTable.KnownColorToArgb(knownColor)) { }
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; }
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."); }
public ColorResourceInfo(XKnownColor knownColor, XColor color, uint argb, string name, string nameDE) { KnownColor = knownColor; Color = color; Argb = argb; Name = name; NameDE = nameDE; }
internal XColor(XKnownColor knownColor) : this(XKnownColorTable.KnownColorToArgb(knownColor)) { }
/// <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; }
/// <summary> /// Creates an XColor from the specified pre-defined color. /// </summary> public static XColor FromKnownColor(XKnownColor color) => new XColor(color);
/// <summary> /// Creates an XColor from the specified pre-defined color. /// </summary> public static XColor FromKnownColor(XKnownColor color) { return(new XColor(color)); }
/// <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; }