private void PrintCard() { Debug.Assert(this.CardTemplate != null); Debug.Assert(this.CardTemplate.CanPrint); this.StatusText = PrintingPrompt; PrintDialog printDlg = new PrintDialog(); if (this.PrinterSetupTicket != null) { printDlg.PrintTicket = this.PrinterSetupTicket; } if (this.PrintQueue != null) { printDlg.PrintQueue = this.PrintQueue; } double width = printDlg.PrintableAreaWidth; double height = printDlg.PrintableAreaHeight; PhotoCard cardView = this.CreateCardView(); cardView.Width = width; cardView.Height = height; cardView.Show(); if (this.SaveCards && this.SaveFileLocation.Exists) { string fileName = GetNextCardFileName(); Byte[] jpeg = cardView.GetJpgImage(2.0, 95, Constants.ScreenDPI); System.IO.File.WriteAllBytes(fileName, jpeg); } UIElement content = cardView.RootVisual; FixedDocument document = DocumentUtility.CreateFixedDocument(width, height, content); bool printError = false; try { printDlg.PrintDocument(document.DocumentPaginator, "Photo Booth"); } catch (Exception e) { printError = true; Debug.WriteLine(e); MessageBox.Show(e.Message, "Print exception"); } cardView.Close(); if (!printError) { // Wait so photo capture doesn't get too far ahead of the printer. System.Threading.Thread.Sleep(PrintingDelay); } this.SetStartPrompt(); }
private void DisplayCardView() { PhotoCard card = this.CreateCardView(); if (card != null) { card.ShowDialog(); } }
private PhotoCard CreateCardView() { PhotoCard cardView = null; if (this.CardTemplate != null) { cardView = this.CardTemplate.CreateCard(); } return(cardView); }
private void ShowPreview() { if (this.CardTemplate != null) { for (int i = this.CardTemplate.Images.Count + 1; i <= this.CardTemplate.ImagesRequired; i++) { this.CardTemplate.Images.Add(this.GenerateImage(string.Format("{0}", i))); } PhotoCard card = this.CardTemplate.CreateCard(); card.Owner = this.Owner; card.SizeToContent = SizeToContent.Width; card.Width /= 2; card.ShowDialog(); } }