/// <summary>Creates a PDF of the cover from the bitmap using PDFSharp.</summary> /// <param name="image">The image.</param> /// <returns>The new space PDF.</returns> private static string CreateSpacePdf(Image image) { Contract.Requires <ArgumentNullException>(image != null); using (PdfDocument pdfDocument = new PdfDocument()) { Contract.Assume(pdfDocument.Info != null); pdfDocument.Info.Title = Settings.Default.BookTitle; pdfDocument.Info.Author = Settings.Default.BookAuthor; pdfDocument.Info.CreationDate = DateTime.Now; pdfDocument.Info.ModificationDate = DateTime.Now; pdfDocument.Info.Creator = AssemblyInfo.Attribute <AssemblyTitleAttribute>()?.Title; pdfDocument.Info.Subject = Settings.Default.BookSubtitle; // Create an empty page PdfPage pdfPage = pdfDocument.AddPage(); Contract.Assume(pdfPage != null); pdfPage.Orientation = PdfSharp.PageOrientation.Landscape; pdfPage.Height = XUnit.FromInch(image.Height / image.VerticalResolution); pdfPage.Width = XUnit.FromInch(image.Width / image.HorizontalResolution); // Draw the bitmap on the page XGraphics xgraphics = XGraphics.FromPdfPage(pdfPage); XImage ximage = XImage.FromGdiPlusImage(image); xgraphics.DrawImage(ximage, 0, 0); // Save the document... string fileName = Path.Combine(Path.GetTempPath(), FileNameCreateSpace); pdfDocument.Save(fileName); return(fileName); } }
public void TestMethodReturnIsNotNull() { string company = AssemblyInfo.Attribute()?.Company; var posts = new List <string>() { "abc", "123" }; posts.First()?.Replace('a', 'z'); }
/// <summary>Main entry-point for this application.</summary> private static void Main() { try { Console.OutputEncoding = Encoding.UTF8; Console.WriteLine(AssemblyInfo.Attribute <AssemblyTitleAttribute>()?.Title); Console.WriteLine(AssemblyInfo.Attribute <AssemblyCopyrightAttribute>()?.Copyright); int penroseIterations = Settings.Default.PenroseIterations; RhombusTiler rhombusTiler = new RhombusTiler(penroseIterations); SizeF sizeBookTrimInches = Settings.Default.SizeBookTrimInches; Program.MakeCreateSpaceCover(rhombusTiler, sizeBookTrimInches); Program.MakeKindleCover(rhombusTiler, sizeBookTrimInches); } catch (Exception ex) { // Generic exception handling at the top of the call stack Console.WriteLine(Resources.ErrorMessage, ex.Message); } }