private static void eventualiStampigli(FixedPage page1, LavoroDiStampaFoto lavoroDiStampa) { SolidColorBrush coloreFg = new SolidColorBrush(Colors.Black); SolidColorBrush coloreBg = new SolidColorBrush(Colors.White); int stampigliMarginBotton = Configurazione.UserConfigLumen.stampigliMarginBottom; int stampigliMarginTop = Configurazione.UserConfigLumen.stampigliMarginBottom; int stampigliMarginRight = Configurazione.UserConfigLumen.stampigliMarginRight; int stampigliMarginLeft = Configurazione.UserConfigLumen.stampigliMarginRight; // Prima era 30 poi 16 poi l'ho reso esterno int fontSize = Configurazione.UserConfigLumen.fontSizeStampaFoto; if (fontSize <= 0) { fontSize = 14; // Default } // Numero della foto if (lavoroDiStampa.param.stampigli.numFoto) { TextBlock textNumero = new TextBlock(); textNumero.Text = lavoroDiStampa.fotografia.etichetta; textNumero.FontSize = fontSize; // 30pt text textNumero.Foreground = coloreFg; textNumero.Background = coloreBg; FixedPage.SetBottom(textNumero, stampigliMarginBotton); FixedPage.SetRight(textNumero, stampigliMarginRight); page1.Children.Add(textNumero); } // Giornata if (lavoroDiStampa.param.stampigli.giornata) { TextBlock textGiorno = new TextBlock(); textGiorno.Text = lavoroDiStampa.fotografia.giornata.ToString("d"); textGiorno.FontSize = fontSize; // 30pt text textGiorno.Foreground = coloreFg; textGiorno.Background = coloreBg; FixedPage.SetBottom(textGiorno, stampigliMarginBotton); FixedPage.SetLeft(textGiorno, stampigliMarginLeft); page1.Children.Add(textGiorno); } // Operatore if (lavoroDiStampa.param.stampigli.operatore) { TextBlock textOperatore = new TextBlock(); textOperatore.Text = lavoroDiStampa.fotografia.fotografo.iniziali; textOperatore.FontSize = fontSize; // 30pt text textOperatore.Foreground = coloreFg; textOperatore.Background = coloreBg; FixedPage.SetTop(textOperatore, stampigliMarginTop); FixedPage.SetRight(textOperatore, stampigliMarginRight); page1.Children.Add(textOperatore); } }
private static Rectangle CreateContentRectangle(Brush vb, Rect rect) { var rc = new Rectangle { Width = rect.Width, Height = rect.Height, Fill = vb }; FixedPage.SetLeft(rc, rect.X); FixedPage.SetTop(rc, rect.Y); FixedPage.SetRight(rc, rect.Width); FixedPage.SetBottom(rc, rect.Height); return(rc); }
/// <summary> /// Print sample document with the specified QR bill /// </summary> /// <param name="bill">QR bill to print</param> internal static void Print(Bill bill) { // show print dialog var pd = new PrintDialog(); pd.PrintTicket.PageMediaSize = new PageMediaSize(PageMediaSizeName.ISOA4); pd.PrintTicket.PageOrientation = PageOrientation.Portrait; if (pd.ShowDialog() != true) { return; } // create page var pageSize = new Size(pd.PrintableAreaWidth, pd.PrintableAreaHeight); var page = new FixedPage { Width = pageSize.Width, Height = pageSize.Height }; // add title var text = new TextBlock { Text = "Swiss QR Bill", FontSize = 40, FontWeight = FontWeights.Bold, Margin = new Thickness(20 / 25.4 * 96) }; page.Children.Add(text); // add QR bill to the bottom var qrBill = new Image { Source = QrBillImage.CreateImage(bill) }; FixedPage.SetBottom(qrBill, 0); page.Children.Add(qrBill); // create document var document = new FixedDocument(); document.DocumentPaginator.PageSize = pageSize; PageContent pageContent = new PageContent(); ((IAddChild)pageContent).AddChild(page); document.Pages.Add(pageContent); // print document pd.PrintDocument(document.DocumentPaginator, "Invoice"); }
/// <summary>method write control to page in absolute position /// </summary> /// <param name="item">adding control</param> /// <param name="left">control left displacement, default is not set</param> /// <param name="top">control top displacement, default is not set</param> /// <param name="right">control right displacement, default is not set</param> /// <param name="bottom">control bottom displacement, default is not set</param> private void WriteItemToPage(UIElement item, double left = double.MinValue, double top = double.MinValue, double right = double.MinValue, double bottom = double.MinValue) { if (left > double.MinValue) { FixedPage.SetLeft(item, m_DisplayResolution * left); } if (top > double.MinValue) { FixedPage.SetTop(item, m_DisplayResolution * top); } if (right > double.MinValue) { FixedPage.SetRight(item, m_DisplayResolution * right); } if (bottom > double.MinValue) { FixedPage.SetBottom(item, m_DisplayResolution * bottom); } FixedPage.Children.Add(item); UpdatePageLayout(); }
private static FixedPage CreateFixedPageForStep(Step st, PrintStuff ps) { FixedPage page = new FixedPage(); page.Background = Brushes.White; page.Width = ps.dpi * ps.page_width; page.Height = ps.dpi * ps.page_height; double picWidth = 4; double picHeight = 4; ViewMaker vo = new ViewMaker(); vo.bAnimate = false; vo.bShowAnnotations = true; vo.bShowAxes = false; vo.bShowEndGrain = true; vo.bShowFaceLabels = true; vo.bShowHighlights = true; vo.bShowLines = true; vo.bStaticLines = true; vo.height = (int)(ps.dpi * picHeight); vo.width = (int)(ps.dpi * picWidth); vo.bCloneTran = true; vo.bAutoZoom = true; vo.transparencies = null; vo.MakeView(st); // Move the picture to the center of the area Rect r = wpfmisc.Get2DBoundingBox(vo.vp); vo.vp.RenderTransform = new TranslateTransform((vo.vp.Width - r.Width) / 2 - r.Left, (vo.vp.Height - r.Height) / 2 - r.Top); Border b = new Border(); //b.Background = Brushes.Yellow; b.BorderThickness = new Thickness(1); b.BorderBrush = Brushes.Black; b.Child = vo.vp; FixedPage.SetLeft(b, ps.dpi * ps.margin_left); FixedPage.SetTop(b, ps.dpi * (ps.margin_left * 2)); page.Children.Add((UIElement)b); TextBlock tbTitle = new TextBlock(); tbTitle.Text = st.Description; tbTitle.FontSize = 24; tbTitle.FontFamily = new FontFamily("Arial"); FixedPage.SetLeft(tbTitle, ps.dpi * ps.margin_left); FixedPage.SetTop(tbTitle, ps.dpi * ps.margin_top); page.Children.Add((UIElement)tbTitle); TextBlock tbProse = new TextBlock(); tbProse.TextWrapping = TextWrapping.Wrap; tbProse.MaxWidth = vo.width; tbProse.Text = st.prose; tbProse.FontSize = 12; tbProse.FontFamily = new FontFamily("serif"); FixedPage.SetLeft(tbProse, ps.dpi * ps.margin_left); FixedPage.SetTop(tbProse, ps.dpi * (ps.margin_top + 1)); page.Children.Add((UIElement)tbProse); FlowDocumentScrollViewer fdsv_notes = new FlowDocumentScrollViewer(); fdsv_notes.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled; fdsv_notes.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled; fdsv_notes.Width = ps.dpi * 3; fdsv_notes.Height = ps.dpi * 3; if (st.Notes != null) { // TODO fdsv_notes.Document = XamlReader.Load(new XmlTextReader(new StringReader(st.Notes))) as FlowDocument; } FixedPage.SetLeft(fdsv_notes, ps.dpi * ps.margin_left); FixedPage.SetTop(fdsv_notes, ps.dpi * 6); page.Children.Add((UIElement)fdsv_notes); TextBlock tbCredit = new TextBlock(new Run("www.sawdust.com")); tbCredit.FontSize = 10; tbCredit.FontFamily = new FontFamily("Arial"); FixedPage.SetRight(tbCredit, ps.dpi * ps.margin_right); FixedPage.SetBottom(tbCredit, ps.dpi * ps.margin_bottom); page.Children.Add(tbCredit); Size sz = new Size(ps.dpi * ps.page_width, ps.dpi * ps.page_height); page.Measure(sz); page.Arrange(new Rect(new Point(), sz)); page.UpdateLayout(); return(page); }