public void OnSaveClicked(object sender, EventArgs args) { // create flow document and register necessary styles FlowDocument doc = new FlowDocument(); doc.Margin = new Thickness (10,10,10,10); // the style for all document's textblocks doc.StyleManager.RegisterStyle("TextBlock, TextBox", new Style() { Font = new Font("Helvetica",20), Color = RgbColors.Black, Display = Display.Block }); // the style for the section that contains employee data doc.StyleManager.RegisterStyle ("#border", new Style () { Padding = new Thickness(10,10,10,10), BorderColor = RgbColors.DarkRed, Border = new Border(5), BorderRadius=5 } ); // add PDF form fields for later processing doc.Fields.Add (new TextField ("firstName", currentEmployee.FirstName)); doc.Fields.Add (new TextField ("lastName", currentEmployee.LastName)); doc.Fields.Add (new TextField ("position", currentEmployee.CurrentPosition)); // create section and add text block inside Section section = new Section (){Id="border"}; // ios PDF preview doesn't display fields correctly, // uncomment this code to use simple text blocks instead of text boxes // section.Add(new TextBlock(string.Format("First name: {0}",currentEmployee.FirstName))); // section.Add(new TextBlock(string.Format("Last name: {0}",currentEmployee.LastName))); // section.Add(new TextBlock(string.Format("Position: {0}",currentEmployee.CurrentPosition))); section.Add(new TextBlock("First name: ")); section.Add(new TextBox("firstName")); section.Add(new TextBlock("Last name: ")); section.Add(new TextBox("lastName")); section.Add(new TextBlock("Position: ")); section.Add(new TextBox("position")); doc.Add (section); // get io service and generate output file path var fileManager = DependencyService.Get<IFileIO>(); string filePath = Path.Combine (fileManager.GetMyDocumentsPath (), "form.pdf"); // generate document using(Stream outputStream = fileManager.CreateFile(filePath)) { doc.Write (outputStream, new ResourceManager()); } // request preview DependencyService.Get<IPDFPreviewProvider>().TriggerPreview (filePath); }
void InitializeSamplesTab() { FontFamily selectedFamily = SelectedFontFamily; var selectedFace = new Typeface( selectedFamily, SelectedFontStyle, SelectedFontWeight, SelectedFontStretch ); fontFamilyNameRun.Text = FontFamilyListItem.GetDisplayName(selectedFamily); typefaceNameRun.Text = TypefaceListItem.GetDisplayName(selectedFace); // Create FontFamily samples document. var doc = new FlowDocument(); foreach (Typeface face in selectedFamily.GetTypefaces()) { var labelPara = new Paragraph(new Run(TypefaceListItem.GetDisplayName(face))); labelPara.Margin = new Thickness(0); doc.Blocks.Add(labelPara); var samplePara = new Paragraph(new Run(_previewSampleText)); samplePara.FontFamily = selectedFamily; samplePara.FontWeight = face.Weight; samplePara.FontStyle = face.Style; samplePara.FontStretch = face.Stretch; samplePara.FontSize = 16.0; samplePara.Margin = new Thickness(0, 0, 0, 8); doc.Blocks.Add(samplePara); } fontFamilySamples.Document = doc; // Create typeface samples document. doc = new FlowDocument(); foreach (double sizeInPoints in new double[] { 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0 }) { string labelText = string.Format("{0} {1}", sizeInPoints, _pointsText); var labelPara = new Paragraph(new Run(labelText)); labelPara.Margin = new Thickness(0); doc.Blocks.Add(labelPara); var samplePara = new Paragraph(new Run(_previewSampleText)); samplePara.FontFamily = selectedFamily; samplePara.FontWeight = selectedFace.Weight; samplePara.FontStyle = selectedFace.Style; samplePara.FontStretch = selectedFace.Stretch; samplePara.FontSize = FontSizeListItem.PointsToPixels(sizeInPoints); samplePara.Margin = new Thickness(0, 0, 0, 8); doc.Blocks.Add(samplePara); } typefaceSamples.Document = doc; }
/// <summary> /// Initializes a new instance of the <see cref="FlowDocumentReportWriter" /> class. /// </summary> public FlowDocumentReportWriter() { this.doc = new FlowDocument(); }
private void AppendText([NotNull] FlowDocument document, [NotNull] IEnumerable <ILogMessage> logMessages) { if (document == null) { throw new ArgumentNullException(nameof(document)); } if (logMessages == null) { throw new ArgumentNullException(nameof(logMessages)); } if (logTextBox != null) { var paragraph = (Paragraph)document.Blocks.AsEnumerable().First(); var stringComparison = SearchMatchCase ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase; var searchToken = SearchToken; foreach (var message in logMessages.Where(x => ShouldDisplayMessage(x.Type))) { var lineText = message + Environment.NewLine; var logColor = GetLogColor(message.Type); if (string.IsNullOrEmpty(searchToken)) { paragraph.Inlines.Add(new Run(lineText) { Foreground = logColor }); } else { do { var tokenIndex = lineText.IndexOf(searchToken, stringComparison); if (tokenIndex == -1) { paragraph.Inlines.Add(new Run(lineText) { Foreground = logColor }); break; } var acceptResult = true; if (SearchMatchWord && lineText.Length > 1) { if (tokenIndex > 0) { var c = lineText[tokenIndex - 1]; if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) { acceptResult = false; } } if (tokenIndex + searchToken.Length < lineText.Length) { var c = lineText[tokenIndex + searchToken.Length]; if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) { acceptResult = false; } } } if (acceptResult) { if (tokenIndex > 0) { paragraph.Inlines.Add(new Run(lineText.Substring(0, tokenIndex)) { Foreground = logColor }); } var tokenRun = new Run(lineText.Substring(tokenIndex, searchToken.Length)) { Background = SearchMatchBrush, Foreground = logColor }; paragraph.Inlines.Add(tokenRun); var tokenRange = new TextRange(tokenRun.ContentStart, tokenRun.ContentEnd); searchMatches.Add(tokenRange); lineText = lineText.Substring(tokenIndex + searchToken.Length); } } while (lineText.Length > 0); } } } }
private void eatin(object sender, RoutedEventArgs e) { ORDERS orderModel = new ORDERS(); item_selection itemSelection = new item_selection(); var testValue = db.ORDERS.OrderByDescending(p => p.orders_number).Where(p => p.id_orders_type == 1).Select(q => q.orders_number).FirstOrDefault(); orderModel.orders_number = Service.GetNextCode("SPL", testValue); orderModel.id_orders_status = 1; orderModel.id_orders_type = Convert.ToInt32(((Button)sender).Tag); orderModel.orders_date = DateTime.Today; orderModel.orders_delay_date = null; orderModel.orders_price = (decimal)totalPrice; // total commande orderModel.orders_leftToPay = (decimal)totalRestPrice; // reste à payer db.ORDERS.Add(orderModel); db.SaveChanges(); int idOrder = orderModel.id_orders; foreach (var item in cartList) { itemSelection = new item_selection(); if (item.SelectedIngredients != null && item.SelectedIngredients.Count > 0) { foreach (var subItem in item.SelectedIngredients) { itemSelection.id_item = item.ItemId; itemSelection.id_orders = idOrder; itemSelection.id_ingredient = subItem.IdIngredient; itemSelection.item_selection_quantity = item.ItemQuantity; db.item_selection.Add(itemSelection); db.SaveChanges(); } } else { itemSelection.id_item = item.ItemId; itemSelection.id_orders = idOrder; itemSelection.item_selection_quantity = item.ItemQuantity; db.item_selection.Add(itemSelection); db.SaveChanges(); } } cvm.Payement = new ObservableCollection <Payement>(); cvm.TotalCart = null; cvm.TotalRest = null; new Commandes(); #region PRINT // Show Print Dialog PrintDialog printDialog = new PrintDialog(); FlowDocument document = new FlowDocument(); System.Windows.Documents.Paragraph par = new System.Windows.Documents.Paragraph(); par.FontFamily = new System.Windows.Media.FontFamily("Times"); System.Windows.Documents.Paragraph subPar = new System.Windows.Documents.Paragraph(); document.ColumnWidth = printDialog.PrintableAreaWidth; document.PagePadding = new Thickness(25); Span s = new Span(); s = new Span(new Run("Le Cezar food")); s.Inlines.Add(new LineBreak()); //Line break is used for next line. par.Inlines.Add(s); // Add the span content into paragraph. par.Inlines.Add(new Span(new Run("Ticket fabrication"))); par.Inlines.Add(new LineBreak()); //Line break is used for next line. par.Inlines.Add(new Span(new Run("Sur place"))); par.Inlines.Add(new LineBreak()); //Line break is used for next line. par.Inlines.Add(new Span(new Run("Commande n° " + orderModel.orders_number))); par.Inlines.Add(new LineBreak()); //Line break is used for next line. par.Inlines.Add(new Span(new Run("-------------------------------------"))); document.Blocks.Add(par); foreach (var item in cartList.Where(c => c.Cooked == true)) { par = new System.Windows.Documents.Paragraph(new Run(item.ItemQuantity.ToString() + " x " + item.ItemTitle.ToString())); par.FontSize = 14; par.TextAlignment = TextAlignment.Left; document.Blocks.Add(par); if (item.SelectedIngredients != null) { subPar = new System.Windows.Documents.Paragraph(); foreach (var subItem in item.SelectedIngredients) { subPar.Inlines.Add(new Span(new Run(subItem.Ingredient_quantity + " x " + subItem.Ingredient_title.ToString()))); subPar.Inlines.Add(new Span(new Run(" "))); subPar.FontSize = 12; subPar.TextAlignment = TextAlignment.Center; document.Blocks.Add(subPar); } } } System.Windows.Documents.Paragraph par1 = new System.Windows.Documents.Paragraph(); par1.Inlines.Add(new LineBreak());//Line break is used for next line. par1.Inlines.Add(new Span(new Run("-------------------------------------"))); document.Blocks.Add(par1); foreach (var item in cartList.Where(c => c.Cooked == false)) { par1 = new System.Windows.Documents.Paragraph(new Run(item.ItemQuantity.ToString() + " x " + item.ItemTitle.ToString())); par1.FontSize = 14; par1.TextAlignment = TextAlignment.Left; document.Blocks.Add(par1); } //Config printer //var query = new ManagementObjectSearcher("SELECT * FROM Win32_Printer"); //var printers = query.Get(); //string printerName = Properties.Settings.Default.printerName; //foreach (ManagementObject p in printers) //{ // if (p["name"].ToString() == printerName.ToString()) // { // p.InvokeMethod("SetDefaultPrinter", null, null); // } //} //document.Blocks.Add(par); // fdViewer.Document = document; IDocumentPaginatorSource idpSource = document; printDialog.PrintDocument(idpSource.DocumentPaginator, "Receipt"); //Give style and formatting to paragraph content. //par.FontSize = 14; //par.FontStyle = FontStyles.Normal; //par.TextAlignment = TextAlignment.Left; //document.Blocks.Add(par); // DoThePrint(document); #endregion //ExportDataTableToPdf(cartList, @"C:\Users\Wave\Documents\Visual Studio 2015\Projects\Le cezar food caisse\CezarCaisse_v.0.1\Ecom\Resources\test.pdf", "Friend List"); cartList.Clear(); }
private static void InitializeWarningPage(string purchaseUrl, string titleHeaderDisplayText, string callingAssemblyNameDisplayText, List <string> typeNameDisplayTextList, string securityExceptionHeaderDisplayText, string securityExceptionDisplayText, string componentsHeaderDisplayText, string assemblyHeaderDisplayText, string purchaseHeaderDisplayText, Window window) { if (warningPage == null) { warningPage = new Page(); } warningPage.Title = titleHeaderDisplayText; Style style = new Style(typeof(FlowDocument)) { Setters = { new Setter(FlowDocument.TextAlignmentProperty, TextAlignment.Left), new Setter(FlowDocument.FontSizeProperty, 16.0) } }; Style basedOn = new Style(typeof(Paragraph)) { Setters = { new Setter(Block.MarginProperty, new Thickness(0.0, 8.0, 0.0, 8.0)) } }; Style style3 = new Style(typeof(Paragraph), basedOn) { Setters = { new Setter(TextElement.FontSizeProperty, 20.0), new Setter(TextElement.FontWeightProperty, FontWeights.Bold), new Setter(Block.MarginProperty, new Thickness(0.0, 16.0, 0.0, 8.0)), new Setter(Paragraph.KeepWithNextProperty, true) } }; Border element = new Border(); warningPage.Content = element; element.Padding = new Thickness(4.0); element.Background = SystemColors.InfoBrush; TextElement.SetForeground(element, SystemColors.InfoTextBrush); FlowDocumentScrollViewer viewer = new FlowDocumentScrollViewer(); element.Child = viewer; ScrollViewer.SetVerticalScrollBarVisibility(viewer, ScrollBarVisibility.Auto); FlowDocument document = new FlowDocument(); viewer.Document = document; document.Style = style; Paragraph item = new Paragraph(new System.Windows.Documents.Run(titleHeaderDisplayText)); document.Blocks.Add(item); item.Style = style3; Paragraph paragraph2 = new Paragraph(new System.Windows.Documents.Run(string.Format("{0}:", componentsHeaderDisplayText))); document.Blocks.Add(paragraph2); paragraph2.Style = basedOn; BlockUIContainer container = new BlockUIContainer(); document.Blocks.Add(container); container.Foreground = Brushes.Red; ItemsControl control = new ItemsControl(); container.Child = control; control.ItemsSource = typeNameDisplayTextList; Paragraph paragraph3 = new Paragraph(new System.Windows.Documents.Run(string.Format("{0}:", assemblyHeaderDisplayText))); document.Blocks.Add(paragraph3); paragraph3.Style = basedOn; BlockUIContainer container2 = new BlockUIContainer(); document.Blocks.Add(container2); container2.Foreground = Brushes.Red; ContentControl control2 = new ContentControl(); container2.Child = control2; control2.Content = callingAssemblyNameDisplayText; KeyValuePair <Window, object> pair = new KeyValuePair <Window, object>(window, (window != null) ? window.Content : null); if (securityExceptionDisplayText == null) { Paragraph paragraph4 = new Paragraph(new System.Windows.Documents.Run(string.Format("{0}:", purchaseHeaderDisplayText))); document.Blocks.Add(paragraph4); paragraph4.Style = basedOn; Paragraph paragraph5 = new Paragraph(); document.Blocks.Add(paragraph5); paragraph5.Style = basedOn; Hyperlink hyperlink = new Hyperlink(); paragraph5.Inlines.Add(hyperlink); hyperlink.Inlines.Add("Open Purchase License page"); hyperlink.NavigateUri = new Uri(purchaseUrl); if (!(window is NavigationWindow)) { hyperlink.Click += new RoutedEventHandler(LicenseWarningGenerator.PurchaseLink_Click); } Rectangle uiElement = new Rectangle { Width = 8.0 }; paragraph5.Inlines.Add(uiElement); Hyperlink hyperlink2 = new Hyperlink(); paragraph5.Inlines.Add(hyperlink2); hyperlink2.Inlines.Add("Continue trial"); hyperlink2.Tag = pair; hyperlink2.Click += new RoutedEventHandler(LicenseWarningGenerator.ContinueLink_Click); } else { Paragraph paragraph6 = new Paragraph(new System.Windows.Documents.Run(string.Format("{0}:", securityExceptionHeaderDisplayText))); document.Blocks.Add(paragraph6); paragraph6.Style = basedOn; Paragraph paragraph7 = new Paragraph(new System.Windows.Documents.Run(securityExceptionDisplayText)); document.Blocks.Add(paragraph7); paragraph7.Foreground = Brushes.Red; paragraph7.Style = basedOn; Paragraph paragraph8 = new Paragraph(); document.Blocks.Add(paragraph8); paragraph8.Style = basedOn; Hyperlink hyperlink3 = new Hyperlink(); paragraph8.Inlines.Add(hyperlink3); hyperlink3.Inlines.Add("Continue"); hyperlink3.Tag = pair; hyperlink3.Click += new RoutedEventHandler(LicenseWarningGenerator.ContinueLink_Click); } }
/// <summary> /// Gets all paragraphs for the given <see cref="FlowDocument"/>. /// </summary> /// <param name="Document"></param> /// <returns></returns> public static IEnumerable <Paragraph> Paragraphs(this FlowDocument Document) { return(Document.GetLogicalChildren <Paragraph>()); }
public static IEnumerable <Paragraph> Paragraphs(this FlowDocument doc) { return(doc.Descendants().OfType <Paragraph>()); }
public FlowDocument ChartFlowDoc(ObservableCollection <BarChart> charts, List <string> filtros) { FlowDocument flow = new FlowDocument(); flow.ColumnGap = 0; // Get the page size of an A4 document //var pageSize = new System.Windows.Size(8.5 * 96.0, 11.0 * 96.0); flow.ColumnWidth = 8.5 * 96.0; flow.PageWidth = 8.5 * 96.0; flow.PageHeight = 11.5 * 96.0; flow.Background = Brushes.White; flow.Foreground = Brushes.Black; flow.FontFamily = new FontFamily("Segoe UI"); flow.FontSize = 11; flow.TextAlignment = System.Windows.TextAlignment.Justify; flow.PagePadding = new System.Windows.Thickness(50); LineBreak lb = new LineBreak(); Paragraph pH = new Paragraph(new Run(NameOrg)); pH.Typography.Capitals = System.Windows.FontCapitals.SmallCaps; pH.FontSize = 20; pH.FontWeight = System.Windows.FontWeights.Bold; pH.Margin = new System.Windows.Thickness(0); Paragraph pH1 = new Paragraph(new Run(SloganOrg)); pH1.FontSize = 9; pH1.Margin = new System.Windows.Thickness(1, 0, 0, 0); Paragraph pH2 = new Paragraph(new Run(DepOrg)); pH2.Typography.Capitals = System.Windows.FontCapitals.SmallCaps; pH2.FontWeight = System.Windows.FontWeights.Bold; pH2.FontSize = 14; pH2.Margin = new System.Windows.Thickness(0, 10, 0, 0); Paragraph pH3 = new Paragraph(new Run(SetorOrg)); pH3.Typography.Capitals = System.Windows.FontCapitals.SmallCaps; pH2.FontWeight = System.Windows.FontWeights.Bold; pH3.FontSize = 12; pH3.Margin = new System.Windows.Thickness(0, 0, 0, 40); flow.Blocks.Add(pH); flow.Blocks.Add(pH1); flow.Blocks.Add(pH2); flow.Blocks.Add(pH3); foreach (BarChart bc in charts) { flow.Blocks.Add(new BlockUIContainer(bc)); } #region Filtros string f = string.Empty; foreach (string filtro in filtros) { f += filtro; } Paragraph ft = new Paragraph(); ft.Margin = new System.Windows.Thickness(0, 30, 0, 0); ft.FontSize = 10; ft.Inlines.Add(new Run("FILTROS: ")); ft.Inlines.Add(new Run(f)); #endregion Paragraph r = new Paragraph(); r.Margin = new System.Windows.Thickness(0, 10, 0, 0); r.FontSize = 10; System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); string version = fvi.FileVersion; r.Inlines.Add(new Run(AppDomain.CurrentDomain.FriendlyName.ToUpper())); r.Inlines.Add(new Run(" / V" + version + " / ")); r.Inlines.Add(new Bold(new Run(AccountOn.Nome))); r.Inlines.Add(new Run(" / " + DateTime.Now.ToString("dd.MM.yyyy"))); r.Inlines.Add(new Run(" / " + DateTime.Now.ToLongTimeString())); flow.Blocks.Add(ft); flow.Blocks.Add(r); return(flow); }
public FlowDocument TextFlowDoc(mEstatistics obj, bool ano, bool nome, bool classificacao, List <string> filtros) { FlowDocument flow = new FlowDocument(); flow.ColumnGap = 0; // Get the page size of an A4 document //var pageSize = new System.Windows.Size(8.5 * 96.0, 11.0 * 96.0); flow.ColumnWidth = 8.5 * 96.0; flow.PageWidth = 8.5 * 96.0; flow.PageHeight = 11.5 * 96.0; flow.Background = Brushes.White; flow.Foreground = Brushes.Black; flow.FontFamily = new FontFamily("Segoe UI"); flow.FontSize = 11; flow.TextAlignment = TextAlignment.Justify; flow.PagePadding = new Thickness(50); LineBreak lb = new LineBreak(); Paragraph pH = new Paragraph(new Run(NameOrg)); pH.Typography.Capitals = FontCapitals.SmallCaps; pH.FontSize = 20; pH.FontWeight = FontWeights.Bold; pH.Margin = new Thickness(0); Paragraph pH1 = new Paragraph(new Run(SloganOrg)); pH1.FontSize = 9; pH1.Margin = new Thickness(1, 0, 0, 0); Paragraph pH2 = new Paragraph(new Run(DepOrg)); pH2.Typography.Capitals = FontCapitals.SmallCaps; pH2.FontWeight = FontWeights.Bold; pH2.FontSize = 14; pH2.Margin = new Thickness(0, 10, 0, 0); Paragraph pH3 = new Paragraph(new Run(SetorOrg)); pH3.Typography.Capitals = FontCapitals.SmallCaps; pH2.FontWeight = FontWeights.Bold; pH3.FontSize = 12; pH3.Margin = new Thickness(0, 0, 0, 40); flow.Blocks.Add(pH); flow.Blocks.Add(pH1); flow.Blocks.Add(pH2); flow.Blocks.Add(pH3); Paragraph pA = new Paragraph(); pA.Margin = new Thickness(0, 20, 0, 0); pA.Inlines.Add(new Bold(new Run(string.Format("Relatório de Portarias").ToUpper()))); flow.Blocks.Add(pA); Table tb = new Table(); tb.Columns.Add(new TableColumn() { Width = GridLength.Auto }); tb.Columns.Add(new TableColumn() { Width = new GridLength(20, GridUnitType.Star) }); tb.Columns.Add(new TableColumn() { Width = new GridLength(10, GridUnitType.Star) }); flow.Blocks.Add(tb); #region Classificacao if (classificacao) { TableRowGroup rg2 = new TableRowGroup(); tb.RowGroups.Add(rg2); TableRow rw2 = new TableRow(); rg2.Rows.Add(rw2); rw2.Background = Brushes.LightSalmon; rw2.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("Por Classificação"))))); rw2.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("Quantidade"))))); rw2.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("..."))))); double mxv = 0; foreach (KeyValuePair <string, int> x in obj.Tipo) { mxv += x.Value; } foreach (KeyValuePair <string, int> x in obj.Tipo) { double perc = 0; perc = (x.Value / mxv); TableRow row = new TableRow(); rg2.Rows.Add(row); row.Cells.Add(new TableCell(new Paragraph(new Run(x.Key)) { Foreground = Brushes.Navy }) { Background = Brushes.WhiteSmoke }); row.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("{0} [{1:P2}]", x.Value, perc)) { Foreground = Brushes.DarkViolet })) { Background = Brushes.WhiteSmoke }); row.Cells.Add(new TableCell(new Paragraph(new Run("Portaria(as)"))) { Background = Brushes.WhiteSmoke }); } /* * TableRow rowtotal = new TableRow(); * rg2.Rows.Add(rowtotal); * rowtotal.Cells.Add(new TableCell(new Paragraph(new Run("Total")))); * rowtotal.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("{0} [{1:P2}]", mxv, (mxv / mxv))) { Foreground = Brushes.DarkViolet })) { Background = Brushes.WhiteSmoke }); * rowtotal.Cells.Add(new TableCell(new Paragraph(new Run(string.Empty)))); */ TableRow rowempty1 = new TableRow(); rg2.Rows.Add(rowempty1); rowempty1.Cells.Add(new TableCell(new Paragraph(new Run(string.Empty)))); } #endregion #region Exercicio if (ano) { TableRowGroup rg = new TableRowGroup(); tb.RowGroups.Add(rg); TableRow rw = new TableRow(); rg.Rows.Add(rw); rw.Background = Brushes.LightSkyBlue; rw.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("Por Exercício"))))); rw.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("Quantidade"))))); rw.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("..."))))); double mxv = 0; foreach (KeyValuePair <string, int> x in obj.Tipo) { mxv += x.Value; } foreach (KeyValuePair <string, int> x in obj.Ano) { double perc = 0; perc = (x.Value / mxv); TableRow row = new TableRow(); rg.Rows.Add(row); row.Cells.Add(new TableCell(new Paragraph(new Run(x.Key)) { Foreground = Brushes.Navy }) { Background = Brushes.WhiteSmoke }); row.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("{0} [{1:P2}]", x.Value, perc)) { Foreground = Brushes.DarkViolet })) { Background = Brushes.WhiteSmoke }); row.Cells.Add(new TableCell(new Paragraph(new Run("Portaria(as)"))) { Background = Brushes.WhiteSmoke }); } /* * TableRow rowtotal = new TableRow(); * rg.Rows.Add(rowtotal); * rowtotal.Cells.Add(new TableCell(new Paragraph(new Run("Total")))); * rowtotal.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("{0} [{1:P2}]", mxv, (mxv / mxv))) { Foreground = Brushes.DarkViolet })) { Background = Brushes.WhiteSmoke }); * rowtotal.Cells.Add(new TableCell(new Paragraph(new Run(string.Empty)))); */ TableRow rowempty = new TableRow(); rg.Rows.Add(rowempty); rowempty.Cells.Add(new TableCell(new Paragraph(new Run(string.Empty)))); } #endregion #region Servidor if (nome) { TableRowGroup rg3 = new TableRowGroup(); tb.RowGroups.Add(rg3); TableRow rw3 = new TableRow(); rg3.Rows.Add(rw3); rw3.Background = Brushes.LightGreen; rw3.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("Por Servidor/Funcionário"))))); rw3.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("Quantidade"))))); rw3.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("..."))))); double mxv = 0; foreach (KeyValuePair <string, int> x in obj.Tipo) { mxv += x.Value; } foreach (KeyValuePair <string, int> x in obj.Servidor) { double perc = 0; perc = (x.Value / mxv); TableRow row = new TableRow(); rg3.Rows.Add(row); row.Cells.Add(new TableCell(new Paragraph(new Run(x.Key)) { Foreground = Brushes.Navy }) { Background = Brushes.WhiteSmoke }); row.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("{0} [{1:P2}]", x.Value, perc)) { Foreground = Brushes.DarkViolet })) { Background = Brushes.WhiteSmoke }); row.Cells.Add(new TableCell(new Paragraph(new Run("Portaria(as)"))) { Background = Brushes.WhiteSmoke }); } /* * TableRow rowtotal = new TableRow(); * rg3.Rows.Add(rowtotal); * rowtotal.Cells.Add(new TableCell(new Paragraph(new Run("Total")))); * rowtotal.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("{0} [{1:P2}]", mxv, (mxv / mxv))) { Foreground = Brushes.DarkViolet })) { Background = Brushes.WhiteSmoke }); * rowtotal.Cells.Add(new TableCell(new Paragraph(new Run(string.Empty)))); */ } #endregion #region Filtros string f = string.Empty; foreach (string filtro in filtros) { f += filtro; } Paragraph ft = new Paragraph(); ft.Margin = new System.Windows.Thickness(0, 0, 0, 0); ft.FontSize = 10; ft.Inlines.Add(new Run("FILTROS: ")); ft.Inlines.Add(new Run(f)); #endregion Paragraph r = new Paragraph(); r.Margin = new Thickness(0, 0, 0, 0); r.FontSize = 10; System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); string version = fvi.FileVersion; r.Inlines.Add(new Run(AppDomain.CurrentDomain.FriendlyName.ToUpper())); r.Inlines.Add(new Run(" / V" + version + " / ")); r.Inlines.Add(new Bold(new Run(AccountOn.Nome))); r.Inlines.Add(new Run(" / " + DateTime.Now.ToString("dd.MM.yyyy"))); r.Inlines.Add(new Run(" / " + DateTime.Now.ToLongTimeString())); flow.Blocks.Add(ft); flow.Blocks.Add(r); return(flow); }
public FlowDocumentPrintManager(FlowDocument flowDocument) { _FlowDocument = flowDocument; }
public ExRichTextBox(FlowDocument flowDocument) : base(flowDocument) { }
public static ReportPrinter For(FlowDocument document) { return(new ReportPrinter(document)); }
private ReportPrinter(FlowDocument document) { _document = document; }
public void printDG(DataGrid dataGrid, string title) { PrintDialog printDialog = new PrintDialog(); FlowDocument fd = new FlowDocument(); Paragraph p = new Paragraph(new Run(title)); p.FontStyle = dataGrid.FontStyle; p.FontFamily = dataGrid.FontFamily; p.FontSize = 18; fd.Blocks.Add(p); Table table = new Table(); TableRowGroup tableRowGroup = new TableRowGroup(); TableRow r = new TableRow(); fd.PageWidth = printDialog.PrintableAreaWidth; fd.PageHeight = printDialog.PrintableAreaHeight; fd.BringIntoView(); fd.TextAlignment = TextAlignment.Center; fd.ColumnWidth = 500; table.CellSpacing = 0; table.FlowDirection = FlowDirection.RightToLeft; var headerList = dataGrid.Columns.Select(e => e.Header.ToString()).ToList(); headerList.Reverse(); List<BindingExpression> bindList = new List<BindingExpression>(); if (dataGrid.ItemsSource != null) { foreach (object item in dataGrid.ItemsSource) { DataGridRow row1 = (DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromItem(item); if (row1 != null) { foreach (BindingExpression binding in row1.BindingGroup.BindingExpressions) { MessageBox.Show(binding.ToString()); bindList.Add(binding); } } } } for (int j = 0; j < headerList.Count; j++) { r.Cells.Add(new TableCell(new Paragraph(new Run(headerList[j])))); r.Cells[j].ColumnSpan = 4; r.Cells[j].Padding = new Thickness(4); r.Cells[j].BorderBrush = Brushes.Black; r.Cells[j].FontWeight = FontWeights.Bold; r.Cells[j].Background = Brushes.DarkGray; r.Cells[j].Foreground = Brushes.White; r.Cells[j].BorderThickness = new Thickness(1, 1, 1, 1); } tableRowGroup.Rows.Add(r); table.RowGroups.Add(tableRowGroup); int count; for (int i = 0; i < dataGrid.Items.Count; i++) { //if(dataGrid.get) dynamic row; if (dataGrid.ItemsSource.ToString() == "") { row = (BalanceClient)dataGrid.Items.GetItemAt(i); } else { row = (DataRowView)dataGrid.Items.GetItemAt(i); } table.BorderBrush = Brushes.Gray; table.BorderThickness = new Thickness(1, 1, 0, 0); table.FontStyle = dataGrid.FontStyle; table.FontFamily = dataGrid.FontFamily; table.FontSize = 13; tableRowGroup = new TableRowGroup(); r = new TableRow(); for (int j = 0; j < bindList.Count; j++) { r.Cells.Add(new TableCell(new Paragraph(new Run(row.bindList[j].ToString())))); r.Cells[j].ColumnSpan = 4; r.Cells[j].Padding = new Thickness(4); r.Cells[j].BorderBrush = Brushes.DarkGray; //r1.Cells[j].Background = Brushes.White; r.Cells[j].BorderThickness = new Thickness(0, 0, 1, 1); } tableRowGroup.Rows.Add(r); table.RowGroups.Add(tableRowGroup); } fd.Blocks.Add(table); printDialog.PrintDocument(((IDocumentPaginatorSource)fd).DocumentPaginator, ""); }
public override void DoPrint(FlowDocument document) { DoPrint(PrinterTools.FlowDocumentToSlipPrinterFormat(document, Printer.CharsPerLine)); }
private FlowDocument GenerateDocument(MedalFormsGenerator.MedalFormsVm results) { FlowDocument doc = this.StandardOneColumnDocument(); bool isFirst = true; foreach (var evt in results.Events) { /* ********** Header *********** */ var section = new Section() { BreakPageBefore = !isFirst }; Table headerTable = new Table() { CellSpacing = 0 }; headerTable.Columns.Add(new TableColumn() { Width = new GridLength(170) }); headerTable.Columns.Add(new TableColumn() { Width = new GridLength(470) }); headerTable.Columns.Add(new TableColumn() { Width = new GridLength(120) }); headerTable.RowGroups.Add(new TableRowGroup()); Image image = new Image(); image.Source = new BitmapImage(new Uri(@"pack://application:,,,/MSOOrganiser;component/Resources/Logo.png", UriKind.Absolute)); var trow = new TableRow(); trow.Cells.Add(new TableCell(new Paragraph(new InlineUIContainer(image)) { Margin = new Thickness(10), FontSize = 10, FontWeight = FontWeights.Bold })); var cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(results.OlympiadTitle)) { Margin = new Thickness(10), FontSize = 18, FontWeight = FontWeights.Bold, TextAlignment = TextAlignment.Center }); cell.Blocks.Add(new Paragraph(new Run(evt.Title)) { Margin = new Thickness(2), FontSize = 32, FontWeight = FontWeights.Bold, TextAlignment = TextAlignment.Center }); trow.Cells.Add(cell); cell = new BorderedTableCell(); cell.Blocks.Add(new Paragraph(new Run(evt.Code)) { Margin = new Thickness(10), FontSize = 12, FontWeight = FontWeights.Bold, TextAlignment = TextAlignment.Center }); cell.Blocks.Add(new Paragraph(new Run(evt.SequenceNumber.ToString())) { Margin = new Thickness(2), FontSize = 64, FontWeight = FontWeights.Bold, TextAlignment = TextAlignment.Center }); trow.Cells.Add(cell); headerTable.RowGroups[0].Rows.Add(trow); section.Blocks.Add(headerTable); doc.Blocks.Add(section); /************ Event metadata ********/ Table metaTable = new Table() { CellSpacing = 0 }; metaTable.Columns.Add(new TableColumn() { Width = new GridLength(256) }); metaTable.Columns.Add(new TableColumn() { Width = new GridLength(256) }); metaTable.Columns.Add(new TableColumn() { Width = new GridLength(256) }); metaTable.RowGroups.Add(new TableRowGroup()); trow = new TableRow(); trow.Cells.Add(new TableCell(new Paragraph(new Run("Times: " + evt.DateString)) { Margin = new Thickness(2), FontSize = 10 })); trow.Cells.Add(new TableCell(new Paragraph(new Run("Location: " + evt.Location)) { Margin = new Thickness(2), FontSize = 10 })); trow.Cells.Add(new TableCell(new Paragraph(new Run("Prize Giving: " + evt.PrizeGiving)) { Margin = new Thickness(2), FontSize = 10 })); metaTable.RowGroups[0].Rows.Add(trow); doc.Blocks.Add(metaTable); /* top 3 */ Table top3Table = new Table() { CellSpacing = 0 }; top3Table.Columns.Add(new TableColumn() { Width = new GridLength(250) }); top3Table.Columns.Add(new TableColumn() { Width = new GridLength(250) }); top3Table.Columns.Add(new TableColumn() { Width = new GridLength(250) }); top3Table.RowGroups.Add(new TableRowGroup()); trow = new TableRow(); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run("1st Place")) { Margin = new Thickness(2), FontSize = 24, FontWeight = FontWeights.Bold, TextAlignment = TextAlignment.Center }); cell.Blocks.Add(new Paragraph(new Run("Gold Medal")) { Margin = new Thickness(2), FontSize = 12, TextAlignment = TextAlignment.Center }); cell.Blocks.Add(new Paragraph(new Run(evt.Prize1)) { Margin = new Thickness(2), FontSize = 12, TextAlignment = TextAlignment.Center }); trow.Cells.Add(cell); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run("2nd Place")) { Margin = new Thickness(2), FontSize = 24, FontWeight = FontWeights.Bold, TextAlignment = TextAlignment.Center }); cell.Blocks.Add(new Paragraph(new Run("Silver Medal")) { Margin = new Thickness(2), FontSize = 12, TextAlignment = TextAlignment.Center }); cell.Blocks.Add(new Paragraph(new Run(evt.Prize2)) { Margin = new Thickness(2), FontSize = 12, TextAlignment = TextAlignment.Center }); trow.Cells.Add(cell); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run("3rd Place")) { Margin = new Thickness(2), FontSize = 24, FontWeight = FontWeights.Bold, TextAlignment = TextAlignment.Center }); cell.Blocks.Add(new Paragraph(new Run("Bronze Medal")) { Margin = new Thickness(2), FontSize = 12, TextAlignment = TextAlignment.Center }); cell.Blocks.Add(new Paragraph(new Run(evt.Prize3)) { Margin = new Thickness(2), FontSize = 12, TextAlignment = TextAlignment.Center }); trow.Cells.Add(cell); top3Table.RowGroups[0].Rows.Add(trow); trow = new TableRow(); cell = new TableCell() { Padding = new Thickness(40), ColumnSpan = 3 }; trow.Cells.Add(cell); top3Table.RowGroups[0].Rows.Add(trow); trow = new TableRow(); cell = new TableCell() { Padding = new Thickness(16), ColumnSpan = 3, BorderBrush = Brushes.Black, BorderThickness = new Thickness(1) }; cell.Blocks.Add(new Paragraph(new Run("Junior Prizes: " + evt.JuniorPrizes))); trow.Cells.Add(cell); top3Table.RowGroups[0].Rows.Add(trow); trow = new TableRow(); cell = new TableCell() { Padding = new Thickness(16), ColumnSpan = 3, BorderBrush = Brushes.Black, BorderThickness = new Thickness(1) }; cell.Blocks.Add(new Paragraph(new Run("Other Prizes: " + evt.OtherPrizes))); trow.Cells.Add(cell); top3Table.RowGroups[0].Rows.Add(trow); trow = new TableRow(); cell = new TableCell() { ColumnSpan = 3 }; cell.Blocks.Add(new Paragraph(new Run("ARBITER: Please print in BLOCK CAPITALS")) { FontSize = 12 }); trow.Cells.Add(cell); top3Table.RowGroups[0].Rows.Add(trow); doc.Blocks.Add(top3Table); /************ Main body *************/ Table mainTable = new Table() { CellSpacing = 0 }; mainTable.Columns.Add(new TableColumn() { Width = new GridLength(60) }); mainTable.Columns.Add(new TableColumn() { Width = new GridLength(170) }); mainTable.Columns.Add(new TableColumn() { Width = new GridLength(170) }); mainTable.Columns.Add(new TableColumn() { Width = new GridLength(100) }); mainTable.Columns.Add(new TableColumn() { Width = new GridLength(120) }); mainTable.Columns.Add(new TableColumn() { Width = new GridLength(130) }); mainTable.RowGroups.Add(new TableRowGroup()); trow = new TableRow(); cell = new BorderedTableCell(new Paragraph(new Run("Position")) { FontSize = 12 }); trow.Cells.Add(cell); cell = new BorderedTableCell(new Paragraph(new Run("First Name:")) { FontSize = 12 }); trow.Cells.Add(cell); cell = new BorderedTableCell(new Paragraph(new Run("Surname:")) { FontSize = 12 }); trow.Cells.Add(cell); cell = new BorderedTableCell(new Paragraph(new Run("Nationality:")) { FontSize = 12 }); trow.Cells.Add(cell); cell = new BorderedTableCell(new Paragraph(new Run("Score:")) { FontSize = 12 }); trow.Cells.Add(cell); cell = new BorderedTableCell(new Paragraph(new Run("Prize:")) { FontSize = 12 }); trow.Cells.Add(cell); mainTable.RowGroups[0].Rows.Add(trow); trow = new TableRow(); cell = new BorderedTableCell() { Padding = new Thickness(210) }; trow.Cells.Add(cell); cell = new BorderedTableCell() { Padding = new Thickness(210) }; trow.Cells.Add(cell); cell = new BorderedTableCell() { Padding = new Thickness(210) }; trow.Cells.Add(cell); cell = new BorderedTableCell() { Padding = new Thickness(210) }; trow.Cells.Add(cell); cell = new BorderedTableCell() { Padding = new Thickness(210) }; trow.Cells.Add(cell); cell = new BorderedTableCell() { Padding = new Thickness(210) }; trow.Cells.Add(cell); mainTable.RowGroups[0].Rows.Add(trow); doc.Blocks.Add(mainTable); /************ Footer *************/ Table footerTable = new Table() { CellSpacing = 0 }; footerTable.Columns.Add(new TableColumn() { Width = new GridLength(170) }); footerTable.Columns.Add(new TableColumn() { Width = new GridLength(270) }); footerTable.Columns.Add(new TableColumn() { Width = new GridLength(330) }); footerTable.RowGroups.Add(new TableRowGroup()); trow = new TableRow(); cell = new BorderedTableCell(new Paragraph(new Run("Attach full list of results")) { FontSize = 12 }); trow.Cells.Add(cell); cell = new BorderedTableCell(new Paragraph(new Run("Arbiter:")) { FontSize = 12 }); trow.Cells.Add(cell); cell = new BorderedTableCell(new Paragraph(new Run("Verified by " + results.ResultsVerifier + ":")) { FontSize = 12 }); trow.Cells.Add(cell); footerTable.RowGroups[0].Rows.Add(trow); doc.Blocks.Add(footerTable); /*********** Page 2 ****************/ doc.Blocks.Add(new Paragraph(new Run(evt.Title)) { BreakPageBefore = true, Margin = new Thickness(2), FontSize = 16, FontWeight = FontWeights.Bold, TextAlignment = TextAlignment.Center }); var Block = new Paragraph(new Run(Page2HeaderText)) { FontSize = 12, FontWeight = FontWeights.Bold }; doc.Blocks.Add(Block); Table page2Outer = new Table() { CellSpacing = 0 }; page2Outer.Columns.Add(new TableColumn() { Width = new GridLength(420) }); page2Outer.Columns.Add(new TableColumn() { Width = new GridLength(330) }); page2Outer.RowGroups.Add(new TableRowGroup()); trow = new TableRow(); var p2OuterLeftCell = new TableCell(); trow.Cells.Add(p2OuterLeftCell); var p2OuterRightCell = new TableCell(); trow.Cells.Add(p2OuterRightCell); page2Outer.RowGroups[0].Rows.Add(trow); doc.Blocks.Add(page2Outer); /*********** Page 2 left **************/ Table page2Left = new Table() { CellSpacing = 0, BorderBrush = Brushes.Black, BorderThickness = new Thickness(1) }; page2Left.Columns.Add(new TableColumn() { Width = new GridLength(160) }); page2Left.Columns.Add(new TableColumn() { Width = new GridLength(60) }); page2Left.Columns.Add(new TableColumn() { Width = new GridLength(65) }); page2Left.Columns.Add(new TableColumn() { Width = new GridLength(90) }); page2Left.Columns.Add(new TableColumn() { Width = new GridLength(35) }); page2Left.RowGroups.Add(new TableRowGroup()); trow = new TableRow(); trow.Cells.Add(new BorderedTableCell(new Paragraph(new Run("Name")) { FontSize = 12 })); trow.Cells.Add(new BorderedTableCell(new Paragraph(new Run("Rank")) { FontSize = 12 })); trow.Cells.Add(new BorderedTableCell(new Paragraph(new Run("Score")) { FontSize = 12 })); trow.Cells.Add(new BorderedTableCell(new Paragraph(new Run("Nationality")) { FontSize = 12 })); trow.Cells.Add(new BorderedTableCell(new Paragraph(new Run("JNR")) { FontSize = 12 })); page2Left.RowGroups[0].Rows.Add(trow); foreach (var entrant in evt.Entrants) { trow = new TableRow(); trow.Cells.Add(new BorderedTableCell(new Paragraph(new Run(entrant.Name)) { FontSize = 12, Padding = new Thickness(4) })); trow.Cells.Add(new BorderedTableCell(new Paragraph(new Run("")) { FontSize = 12 })); trow.Cells.Add(new BorderedTableCell(new Paragraph(new Run("")) { FontSize = 12 })); trow.Cells.Add(new BorderedTableCell(new Paragraph(new Run(entrant.Nationality)) { FontSize = 12, Padding = new Thickness(4) })); trow.Cells.Add(new BorderedTableCell(new Paragraph(new Run(entrant.Junior)) { FontSize = 12, Padding = new Thickness(4) })); page2Left.RowGroups[0].Rows.Add(trow); } trow = new TableRow(); trow.Cells.Add(new TableCell(new Paragraph(new Run("No. of Players: " + evt.Entrants.Count())) { FontSize = 16, FontWeight = FontWeights.Bold, TextAlignment = TextAlignment.Center }) { ColumnSpan = 5 }); page2Left.RowGroups[0].Rows.Add(trow); p2OuterLeftCell.Blocks.Add(page2Left); /**** Page 2 right *****/ p2OuterRightCell.Blocks.Add(new Paragraph(new Run(Page2RightHeaderText)) { Padding = new Thickness(8), FontSize = 12, FontWeight = FontWeights.Bold }); p2OuterRightCell.Blocks.Add(new Paragraph(new Run(Page2RightBlurb1)) { FontSize = 12 }); p2OuterRightCell.Blocks.Add(new BorderedParagraph() { Padding = new Thickness(90) }); p2OuterRightCell.Blocks.Add(new Paragraph(new Run(Page2RightBlurb2)) { FontSize = 12 }); p2OuterRightCell.Blocks.Add(new BorderedParagraph() { Padding = new Thickness(90) }); p2OuterRightCell.Blocks.Add(new Paragraph(new Run(Page2RightBlurb3)) { FontSize = 12 }); isFirst = false; } return(doc); }
/// <summary> /// "actualEvents" are games; the rest are things like T-shirts /// </summary> /// <param name="actualEvents"></param> public FlowDocument Print(bool actualEvents) { var rg = new TotalIncomeByMethodReportGenerator(); var results = rg.GetItemsForLatest(); FlowDocument doc = new FlowDocument(); doc.ColumnWidth = 300; // 96ths of an inch doc.FontFamily = new FontFamily("Verdana"); Paragraph topPara = new Paragraph(); topPara.TextAlignment = TextAlignment.Left; topPara.FontSize = 12; topPara.FontWeight = FontWeights.Bold; topPara.Margin = new Thickness(4); topPara.Inlines.Add(new Run(results.OlympiadName)); topPara.Inlines.Add(new Run("Total Income by method")); doc.Blocks.Add(topPara); var grandTotal = 0m; foreach (var fee in results.Fees) { // Inspired by EventIncome, maybe will expand to show individua lpayments Section topSection = new Section(); // http://stackoverflow.com/questions/12397089/how-can-i-keep-a-table-together-in-a-flowdocument Paragraph para = new Paragraph(); para.TextAlignment = TextAlignment.Left; para.Margin = new Thickness(0); para.FontWeight = FontWeights.Normal; para.FontSize = 10; Figure figure = new Figure(); figure.CanDelayPlacement = false; figure.BorderBrush = Brushes.Black; figure.BorderThickness = new Thickness(1); Paragraph innerpara = new Paragraph(); innerpara.TextAlignment = TextAlignment.Left; innerpara.Margin = new Thickness(4); innerpara.FontWeight = FontWeights.Bold; innerpara.FontSize = 12; innerpara.Inlines.Add(new Run(fee.Method)); figure.Blocks.Add(innerpara); Table table = new Table() { CellSpacing = 0 }; table.Columns.Add(new TableColumn() { Width = new GridLength(190) }); table.Columns.Add(new TableColumn() { Width = new GridLength(40) }); table.Columns.Add(new TableColumn() { Width = new GridLength(70) }); table.RowGroups.Add(new TableRowGroup()); var subtotal = 0m; var row = new TableRow(); row.Cells.Add(new TableCell(new Paragraph(new Run(fee.Method ?? "Unknown")) { Margin = new Thickness(2), FontSize = 10 })); row.Cells.Add(new TableCell(new Paragraph(new Run("")) { Margin = new Thickness(2), FontSize = 10 })); row.Cells.Add(new TableCell(new Paragraph(new Run(fee.TotalFees.ToString("C"))) { Margin = new Thickness(2), FontSize = 10, TextAlignment = TextAlignment.Right })); table.RowGroups[0].Rows.Add(row); grandTotal += fee.TotalFees; figure.Blocks.Add(table); para.Inlines.Add(figure); topSection.Blocks.Add(para); doc.Blocks.Add(topSection); } Paragraph gtpara = new Paragraph(); gtpara.TextAlignment = TextAlignment.Left; gtpara.Margin = new Thickness(0); gtpara.FontWeight = FontWeights.Normal; gtpara.FontSize = 10; Figure gtfigure = new Figure(); gtfigure.CanDelayPlacement = false; gtfigure.BorderBrush = Brushes.Black; gtfigure.BorderThickness = new Thickness(1); Table gttable = new Table() { CellSpacing = 0 }; gttable.Columns.Add(new TableColumn() { Width = new GridLength(40) }); gttable.Columns.Add(new TableColumn() { Width = new GridLength(150) }); gttable.Columns.Add(new TableColumn() { Width = new GridLength(40) }); gttable.Columns.Add(new TableColumn() { Width = new GridLength(70) }); gttable.RowGroups.Add(new TableRowGroup()); var gtrow = new TableRow(); gtrow.Cells.Add(new TableCell(new Paragraph(new Run("")) { Margin = new Thickness(2), FontSize = 10, FontWeight = FontWeights.Bold })); gtrow.Cells.Add(new TableCell(new Paragraph(new Run("Grand Total")) { Margin = new Thickness(2), FontSize = 10, FontWeight = FontWeights.Bold })); gtrow.Cells.Add(new TableCell(new Paragraph(new Run("")) { Margin = new Thickness(2), FontSize = 10, FontWeight = FontWeights.Bold })); gtrow.Cells.Add(new TableCell(new Paragraph(new Run(grandTotal.ToString("C"))) { Margin = new Thickness(2), FontSize = 10, FontWeight = FontWeights.Bold })); gttable.RowGroups[0].Rows.Add(gtrow); gtfigure.Blocks.Add(gttable); gtpara.Inlines.Add(gtfigure); doc.Blocks.Add(gtpara); return(doc); }
private void PrintLabelButton_Click(object sender, RoutedEventArgs e) { FlowDocument flowDocument = new FlowDocument(); //flowDocument.PageHeight = this.MainViewModel.EnvelopeHeightInPixels; //flowDocument.PageWidth = this.MainViewModel.EnvelopeWidthInPixels; flowDocument.Blocks.Add(new Paragraph() { FontSize = 4.0 }); Table byRpadTable = new Table() { Margin = new Thickness(20, 0, 0, 0) }; byRpadTable.Columns.Add(new TableColumn { Width = new GridLength(240) }); TableRowGroup trg = new TableRowGroup() { }; TableRow tr = new TableRow(); tr.Cells.Add(new TableCell(new Paragraph(new Run("By Registered Post with Ack. Due"))) { BorderThickness = new Thickness(0, 0, 0, 1), BorderBrush = Brushes.Black }); trg.Rows.Add(tr); byRpadTable.RowGroups.Add(trg); Table addressTable = new Table() { Margin = new Thickness(20, 0, 0, 0) }; addressTable.Columns.Add(new TableColumn { Width = new GridLength(this.MainViewModel.FromSectionWidthInPixels) }); addressTable.Columns.Add(new TableColumn { Width = new GridLength(this.MainViewModel.ToSectionWidthInPixels) }); TableRowGroup trg1 = new TableRowGroup() { }; TableRow tr1 = new TableRow(); tr1.Cells.Add(new TableCell(new Paragraph(new Run("From")) { Margin = new Thickness(20, 120, 0, 0), FontWeight = FontWeights.Bold })); TableCell cell2 = new TableCell(new Paragraph(new Run("To")) { Margin = new Thickness(50, 60, 0, 0), FontWeight = FontWeights.Bold }) { RowSpan = 2 }; foreach (string toLine in this.MainViewModel.ToAddress) { cell2.Blocks.Add(new Paragraph(new Run(toLine)) { Margin = new Thickness(70, 2, 0, 2) }); } tr1.Cells.Add(cell2); trg1.Rows.Add(tr1); TableRow tr2 = new TableRow(); TableCell cell3 = new TableCell(); foreach (string fromLine in this.MainViewModel.FromAddress) { cell3.Blocks.Add(new Paragraph(new Run(fromLine)) { Margin = new Thickness(35, 0, 35, 0) }); } tr2.Cells.Add(cell3); trg1.Rows.Add(tr2); addressTable.RowGroups.Add(trg1); flowDocument.Blocks.Add(byRpadTable); flowDocument.Blocks.Add(addressTable); flowDocument.ColumnWidth = double.PositiveInfinity; TextRange dest = new TextRange(flowDocument.ContentStart, flowDocument.ContentEnd); PrintDialog printDialog = new PrintDialog(); printDialog.PrintTicket.PageOrientation = PageOrientation.Landscape; if (printDialog.ShowDialog() == true) { //Other settings DocumentPaginator paginator = ((IDocumentPaginatorSource)flowDocument).DocumentPaginator; //paginator.PageSize = new Size(); //Set the size of A4 here accordingly printDialog.PrintDocument(paginator, "My"); } //DoThePrint(fd); }
private async void DecompileCode(UndertaleCode code) { LoaderDialog dialog = new LoaderDialog("Decompiling", "Decompiling, please wait... This can take a while on complex scripts"); dialog.Owner = Window.GetWindow(this); FlowDocument document = new FlowDocument(); document.PagePadding = new Thickness(0); document.FontFamily = new FontFamily("Lucida Console"); Paragraph par = new Paragraph(); UndertaleCode gettextCode = null; if (gettext == null) { gettextCode = (Application.Current.MainWindow as MainWindow).Data.Code.ByName("gml_Script_textdata_en"); } Task t = Task.Run(() => { string decompiled = null; Exception e = null; try { decompiled = Decompiler.Decompile(code).Replace("\r\n", "\n"); } catch (Exception ex) { e = ex; } if (gettextCode != null) { UpdateGettext(gettextCode); } Dispatcher.Invoke(() => { if (e != null) { Brush exceptionBrush = new SolidColorBrush(Color.FromRgb(255, 0, 0)); par.Inlines.Add(new Run("EXCEPTION!\n") { Foreground = exceptionBrush, FontWeight = FontWeights.Bold }); par.Inlines.Add(new Run(e.ToString()) { Foreground = exceptionBrush }); } else if (decompiled != null) { string[] lines = decompiled.Split('\n'); if (lines.Length > 5000) { par.Inlines.Add(new Run(decompiled)); } else { Brush keywordBrush = new SolidColorBrush(Color.FromRgb(0, 0, 150)); Brush stringBrush = new SolidColorBrush(Color.FromRgb(0, 0, 200)); Brush commentBrush = new SolidColorBrush(Color.FromRgb(0, 150, 0)); Brush funcBrush = new SolidColorBrush(Color.FromRgb(100, 100, 0)); Dictionary <string, UndertaleFunction> funcs = new Dictionary <string, UndertaleFunction>(); foreach (var x in (Application.Current.MainWindow as MainWindow).Data.Functions) { funcs.Add(x.Name.Content, x); } foreach (var line in lines) { char[] special = { '.', ',', ')', '(', '[', ']', '>', '<', ':', ';', '=', '"' }; Func <char, bool> IsSpecial = (c) => Char.IsWhiteSpace(c) || special.Contains(c); List <string> split = new List <string>(); string tok = ""; bool readingString = false; for (int i = 0; i < line.Length; i++) { if (tok == "//") { tok += line.Substring(i); break; } if (!readingString && tok.Length > 0 && ( (Char.IsWhiteSpace(line[i]) != Char.IsWhiteSpace(tok[tok.Length - 1])) || (special.Contains(line[i]) != special.Contains(tok[tok.Length - 1])) || (special.Contains(line[i]) && special.Contains(tok[tok.Length - 1])) || line[i] == '"' )) { split.Add(tok); tok = ""; } tok += line[i]; if (line[i] == '"') { if (readingString) { split.Add(tok); tok = ""; } readingString = !readingString; } } if (tok != "") { split.Add(tok); } Dictionary <string, UndertaleObject> usedObjects = new Dictionary <string, UndertaleObject>(); for (int i = 0; i < split.Count; i++) { string token = split[i]; if (token == "if" || token == "else" || token == "return" || token == "break" || token == "continue" || token == "while" || token == "with") { par.Inlines.Add(new Run(token) { Foreground = keywordBrush, FontWeight = FontWeights.Bold }); } else if (token == "self" || token == "global" || token == "local" || token == "other" || token == "noone" || token == "true" || token == "false") { par.Inlines.Add(new Run(token) { Foreground = keywordBrush }); } else if (token.StartsWith("\"")) { par.Inlines.Add(new Run(token) { Foreground = stringBrush }); } else if (token.StartsWith("//")) { par.Inlines.Add(new Run(token) { Foreground = commentBrush }); } else if (token.StartsWith("@")) { par.Inlines.LastInline.Cursor = Cursors.Hand; par.Inlines.LastInline.MouseDown += (sender, ev) => { MainWindow mw = Application.Current.MainWindow as MainWindow; mw.ChangeSelection(mw.Data.Strings[Int32.Parse(token.Substring(1))]); }; } else if (funcs.ContainsKey(token)) { par.Inlines.Add(new Run(token) { Foreground = funcBrush, Cursor = Cursors.Hand }); par.Inlines.LastInline.MouseDown += (sender, ev) => (Application.Current.MainWindow as MainWindow).ChangeSelection(funcs[token]); if (token == "scr_gettext" && gettext != null) { if (split[i + 1] == "(" && split[i + 2].StartsWith("\"") && split[i + 3].StartsWith("@") && split[i + 4] == ")") { string id = split[i + 2].Substring(1, split[i + 2].Length - 2); if (!usedObjects.ContainsKey(id)) { usedObjects.Add(id, (Application.Current.MainWindow as MainWindow).Data.Strings[gettext[id]]); } } } } else if (Char.IsDigit(token[0])) { par.Inlines.Add(new Run(token) { Cursor = Cursors.Hand }); par.Inlines.LastInline.MouseDown += (sender, ev) => { // TODO: Add type resolving to the decompiler so that this is handled mostly automatically UndertaleData data = (Application.Current.MainWindow as MainWindow).Data; int id = Int32.Parse(token); List <UndertaleObject> possibleObjects = new List <UndertaleObject>(); if (id < data.Sprites.Count) { possibleObjects.Add(data.Sprites[id]); } if (id < data.Rooms.Count) { possibleObjects.Add(data.Rooms[id]); } if (id < data.GameObjects.Count) { possibleObjects.Add(data.GameObjects[id]); } if (id < data.Backgrounds.Count) { possibleObjects.Add(data.Backgrounds[id]); } if (id < data.Scripts.Count) { possibleObjects.Add(data.Scripts[id]); } if (id < data.Paths.Count) { possibleObjects.Add(data.Paths[id]); } if (id < data.Fonts.Count) { possibleObjects.Add(data.Fonts[id]); } if (id < data.Sounds.Count) { possibleObjects.Add(data.Sounds[id]); } ContextMenu contextMenu = new ContextMenu(); foreach (UndertaleObject obj in possibleObjects) { MenuItem item = new MenuItem(); item.Header = obj.ToString().Replace("_", "__"); item.Click += (sender2, ev2) => (Application.Current.MainWindow as MainWindow).ChangeSelection(obj); contextMenu.Items.Add(item); } if (id > 0x00050000) { contextMenu.Items.Add(new MenuItem() { Header = "#" + id.ToString("X6") + " (color)", IsEnabled = false }); } contextMenu.Items.Add(new MenuItem() { Header = id + " (number)", IsEnabled = false }); (sender as Run).ContextMenu = contextMenu; contextMenu.IsOpen = true; ev.Handled = true; }; } else { par.Inlines.Add(new Run(token)); } if (token == "." && (Char.IsLetter(split[i + 1][0]) || split[i + 1][0] == '_')) { int id; if (Int32.TryParse(split[i - 1], out id)) { if (!usedObjects.ContainsKey(split[i - 1])) { usedObjects.Add(split[i - 1], (Application.Current.MainWindow as MainWindow).Data.GameObjects[id]); } } } } foreach (var gt in usedObjects) { par.Inlines.Add(new Run(" // ") { Foreground = commentBrush }); par.Inlines.Add(new Run(gt.Key) { Foreground = commentBrush }); par.Inlines.Add(new Run(" = ") { Foreground = commentBrush }); par.Inlines.Add(new Run(gt.Value.ToString()) { Foreground = commentBrush, Cursor = Cursors.Hand }); par.Inlines.LastInline.MouseDown += (sender, ev) => (Application.Current.MainWindow as MainWindow).ChangeSelection(gt.Value); } par.Inlines.Add(new Run("\n")); } } } document.Blocks.Add(par); DecompiledView.Document = document; CurrentDecompiled = code; dialog.Hide(); }); }); dialog.ShowDialog(); await t; }
public PreviewWindow(FlowDocument fdoc) { InitializeComponent(); Viewer.Document = fdoc; Viewer.ViewingMode = FlowDocumentReaderViewingMode.Scroll; }
private void DisassembleCode(UndertaleCode code) { code.UpdateAddresses(); FlowDocument document = new FlowDocument(); document.PagePadding = new Thickness(0); document.FontFamily = new FontFamily("Lucida Console"); Paragraph par = new Paragraph(); if (code.Instructions.Count > 5000) { // Disable syntax highlighting. Loading it can take a few MINUTES on large scripts. var data = (Application.Current.MainWindow as MainWindow).Data; par.Inlines.Add(new Run(code.Disassemble(data.Variables, data.CodeLocals.For(code)))); } else { Brush addressBrush = new SolidColorBrush(Color.FromRgb(50, 50, 50)); Brush opcodeBrush = new SolidColorBrush(Color.FromRgb(0, 100, 0)); Brush argBrush = new SolidColorBrush(Color.FromRgb(0, 0, 150)); Brush typeBrush = new SolidColorBrush(Color.FromRgb(0, 0, 50)); var data = (Application.Current.MainWindow as MainWindow).Data; par.Inlines.Add(new Run(code.GenerateLocalVarDefinitions(data.Variables, data.CodeLocals.For(code))) { Foreground = addressBrush }); foreach (var instr in code.Instructions) { par.Inlines.Add(new Run(instr.Address.ToString("D5") + ": ") { Foreground = addressBrush }); par.Inlines.Add(new Run(instr.Kind.ToString().ToLower()) { Foreground = opcodeBrush, FontWeight = FontWeights.Bold }); switch (UndertaleInstruction.GetInstructionType(instr.Kind)) { case UndertaleInstruction.InstructionType.SingleTypeInstruction: par.Inlines.Add(new Run("." + instr.Type1.ToOpcodeParam()) { Foreground = typeBrush }); if (instr.Kind == UndertaleInstruction.Opcode.Dup) { par.Inlines.Add(new Run(" ")); par.Inlines.Add(new Run(instr.DupExtra.ToString()) { Foreground = argBrush }); } break; case UndertaleInstruction.InstructionType.DoubleTypeInstruction: par.Inlines.Add(new Run("." + instr.Type1.ToOpcodeParam()) { Foreground = typeBrush }); par.Inlines.Add(new Run("." + instr.Type2.ToOpcodeParam()) { Foreground = typeBrush }); break; case UndertaleInstruction.InstructionType.ComparisonInstruction: par.Inlines.Add(new Run("." + instr.Type1.ToOpcodeParam()) { Foreground = typeBrush }); par.Inlines.Add(new Run("." + instr.Type2.ToOpcodeParam()) { Foreground = typeBrush }); par.Inlines.Add(new Run(" ")); par.Inlines.Add(new Run(instr.ComparisonKind.ToString()) { Foreground = opcodeBrush }); break; case UndertaleInstruction.InstructionType.GotoInstruction: par.Inlines.Add(new Run(" ")); string tgt = (instr.Address + instr.JumpOffset).ToString("D5"); if (instr.Address + instr.JumpOffset == code.Length / 4) { tgt = "func_end"; } par.Inlines.Add(new Run(tgt) { Foreground = argBrush, ToolTip = "$" + instr.JumpOffset.ToString("+#;-#;0") }); break; case UndertaleInstruction.InstructionType.PopInstruction: par.Inlines.Add(new Run("." + instr.Type1.ToOpcodeParam()) { Foreground = typeBrush }); par.Inlines.Add(new Run("." + instr.Type2.ToOpcodeParam()) { Foreground = typeBrush }); par.Inlines.Add(new Run(" ")); if (instr.Type1 == UndertaleInstruction.DataType.Variable && instr.TypeInst != UndertaleInstruction.InstanceType.Undefined) { par.Inlines.Add(new Run(instr.TypeInst.ToString().ToLower()) { Foreground = typeBrush }); par.Inlines.Add(new Run(".")); } Run runDest = new Run(instr.Destination.ToString()) { Foreground = argBrush, Cursor = Cursors.Hand }; runDest.MouseDown += (sender, e) => { (Application.Current.MainWindow as MainWindow).ChangeSelection(instr.Destination); }; par.Inlines.Add(runDest); break; case UndertaleInstruction.InstructionType.PushInstruction: par.Inlines.Add(new Run("." + instr.Type1.ToOpcodeParam()) { Foreground = typeBrush }); par.Inlines.Add(new Run(" ")); if (instr.Type1 == UndertaleInstruction.DataType.Variable && instr.TypeInst != UndertaleInstruction.InstanceType.Undefined) { par.Inlines.Add(new Run(instr.TypeInst.ToString().ToLower()) { Foreground = typeBrush }); par.Inlines.Add(new Run(".")); } Run valueRun = new Run((instr.Value as IFormattable)?.ToString(null, CultureInfo.InvariantCulture) ?? instr.Value.ToString()) { Foreground = argBrush, Cursor = (instr.Value is UndertaleObject || instr.Value is UndertaleResourceRef) ? Cursors.Hand : Cursors.Arrow }; if (instr.Value is UndertaleResourceRef) { valueRun.MouseDown += (sender, e) => { (Application.Current.MainWindow as MainWindow).ChangeSelection((instr.Value as UndertaleResourceRef).Resource); }; } else if (instr.Value is UndertaleObject) { valueRun.MouseDown += (sender, e) => { (Application.Current.MainWindow as MainWindow).ChangeSelection(instr.Value); }; } par.Inlines.Add(valueRun); break; case UndertaleInstruction.InstructionType.CallInstruction: par.Inlines.Add(new Run("." + instr.Type1.ToOpcodeParam()) { Foreground = typeBrush }); par.Inlines.Add(new Run(" ")); par.Inlines.Add(new Run(instr.Function.ToString()) { Foreground = argBrush }); par.Inlines.Add(new Run("(argc=")); par.Inlines.Add(new Run(instr.ArgumentsCount.ToString()) { Foreground = argBrush }); par.Inlines.Add(new Run(")")); break; case UndertaleInstruction.InstructionType.BreakInstruction: par.Inlines.Add(new Run("." + instr.Type1.ToOpcodeParam()) { Foreground = typeBrush }); par.Inlines.Add(new Run(" ")); par.Inlines.Add(new Run(instr.Value.ToString()) { Foreground = argBrush }); break; } par.Inlines.Add(new Run("\n")); } } document.Blocks.Add(par); DisassemblyView.Document = document; CurrentDisassembled = code; }
public static void SetDocument(DependencyObject obj, FlowDocument value) => obj.SetValue(DocumentProperty, value);
/// <summary> /// Constructor /// </summary> /// <param name="flowDocument">flow document</param> public ReportPaginatorDynamicCache(FlowDocument flowDocument) { _flowDocument = flowDocument; BuildCache(); }
public string GetText(FlowDocument document) { return(new TextRange(document.ContentStart, document.ContentEnd).Text); }
public EditableRichTextBox(FlowDocument document) : base(document) { }
private void mitPrint_Click(object sender, RoutedEventArgs e) { //this will print the report int intCurrentRow = 0; int intCounter; int intColumns; int intNumberOfRecords; try { PrintDialog pdProblemReport = new PrintDialog(); if (pdProblemReport.ShowDialog().Value) { FlowDocument fdProjectReport = new FlowDocument(); Thickness thickness = new Thickness(50, 50, 50, 50); fdProjectReport.PagePadding = thickness; pdProblemReport.PrintTicket.PageOrientation = System.Printing.PageOrientation.Landscape; //Set Up Table Columns Table ProjectReportTable = new Table(); fdProjectReport.Blocks.Add(ProjectReportTable); ProjectReportTable.CellSpacing = 0; intColumns = TheEmployeeProjectSummaryDataSet.projectsummary.Columns.Count; fdProjectReport.ColumnWidth = 10; fdProjectReport.IsColumnWidthFlexible = false; for (int intColumnCounter = 0; intColumnCounter < intColumns; intColumnCounter++) { ProjectReportTable.Columns.Add(new TableColumn()); } ProjectReportTable.RowGroups.Add(new TableRowGroup()); //Title row ProjectReportTable.RowGroups[0].Rows.Add(new TableRow()); TableRow newTableRow = ProjectReportTable.RowGroups[0].Rows[intCurrentRow]; newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Employee Labor Report for " + MainWindow.gstrFirstName + " " + MainWindow.gstrLastName)))); newTableRow.Cells[0].FontSize = 25; newTableRow.Cells[0].FontFamily = new FontFamily("Times New Roman"); newTableRow.Cells[0].ColumnSpan = intColumns; newTableRow.Cells[0].TextAlignment = TextAlignment.Center; newTableRow.Cells[0].Padding = new Thickness(0, 0, 0, 10); ProjectReportTable.RowGroups[0].Rows.Add(new TableRow()); intCurrentRow++; newTableRow = ProjectReportTable.RowGroups[0].Rows[intCurrentRow]; newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Date Range " + Convert.ToString(MainWindow.gdatStartDate) + " Thru " + Convert.ToString(MainWindow.gdatEndDate))))); newTableRow.Cells[0].FontSize = 18; newTableRow.Cells[0].FontFamily = new FontFamily("Times New Roman"); newTableRow.Cells[0].ColumnSpan = intColumns; newTableRow.Cells[0].TextAlignment = TextAlignment.Center; newTableRow.Cells[0].Padding = new Thickness(0, 0, 0, 10); ProjectReportTable.RowGroups[0].Rows.Add(new TableRow()); intCurrentRow++; newTableRow = ProjectReportTable.RowGroups[0].Rows[intCurrentRow]; newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Total Hours Of " + Convert.ToString(gdecTotalHours))))); newTableRow.Cells[0].FontSize = 18; newTableRow.Cells[0].FontFamily = new FontFamily("Times New Roman"); newTableRow.Cells[0].ColumnSpan = intColumns; newTableRow.Cells[0].TextAlignment = TextAlignment.Center; newTableRow.Cells[0].Padding = new Thickness(0, 0, 0, 10); //Header Row ProjectReportTable.RowGroups[0].Rows.Add(new TableRow()); intCurrentRow++; newTableRow = ProjectReportTable.RowGroups[0].Rows[intCurrentRow]; newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Transaction ID")))); newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Project ID")))); newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Assigned Project ID")))); newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Workt Task ID")))); newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Task")))); newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Total Hours")))); newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Total Footage/Pieces")))); newTableRow.Cells[0].Padding = new Thickness(0, 0, 0, 10); //newTableRow.Cells[0].ColumnSpan = 1; //newTableRow.Cells[1].ColumnSpan = 1; //newTableRow.Cells[2].ColumnSpan = 1; //newTableRow.Cells[3].ColumnSpan = 2; //newTableRow.Cells[4].ColumnSpan = 1; //Format Header Row for (intCounter = 0; intCounter < intColumns; intCounter++) { newTableRow.Cells[intCounter].FontSize = 16; newTableRow.Cells[intCounter].FontFamily = new FontFamily("Times New Roman"); newTableRow.Cells[intCounter].BorderBrush = Brushes.Black; newTableRow.Cells[intCounter].TextAlignment = TextAlignment.Center; newTableRow.Cells[intCounter].BorderThickness = new Thickness(); } intNumberOfRecords = TheEmployeeProjectSummaryDataSet.projectsummary.Rows.Count; //Data, Format Data for (int intReportRowCounter = 0; intReportRowCounter < intNumberOfRecords; intReportRowCounter++) { ProjectReportTable.RowGroups[0].Rows.Add(new TableRow()); intCurrentRow++; newTableRow = ProjectReportTable.RowGroups[0].Rows[intCurrentRow]; for (int intColumnCounter = 0; intColumnCounter < intColumns; intColumnCounter++) { newTableRow.Cells.Add(new TableCell(new Paragraph(new Run(TheEmployeeProjectSummaryDataSet.projectsummary[intReportRowCounter][intColumnCounter].ToString())))); newTableRow.Cells[intColumnCounter].FontSize = 12; newTableRow.Cells[0].FontFamily = new FontFamily("Times New Roman"); newTableRow.Cells[intColumnCounter].BorderBrush = Brushes.LightSteelBlue; newTableRow.Cells[intColumnCounter].BorderThickness = new Thickness(0, 0, 0, 1); newTableRow.Cells[intColumnCounter].TextAlignment = TextAlignment.Center; //if (intColumnCounter == 3) //{ //newTableRow.Cells[intColumnCounter].ColumnSpan = 2; //} } } //Set up page and print fdProjectReport.ColumnWidth = pdProblemReport.PrintableAreaWidth; fdProjectReport.PageHeight = pdProblemReport.PrintableAreaHeight; fdProjectReport.PageWidth = pdProblemReport.PrintableAreaWidth; pdProblemReport.PrintDocument(((IDocumentPaginatorSource)fdProjectReport).DocumentPaginator, "Employee Labor Report"); intCurrentRow = 0; } } catch (Exception Ex) { TheMessagesClass.ErrorMessage(Ex.ToString()); TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Find Employee Hours From Labor // Print Menu Item " + Ex.Message); } }
public static void SaveDocument(Stream documentStream, FlowDocument document, string dataFormat) { TextRange range = new TextRange(document.ContentStart, document.ContentEnd); range.Save(documentStream, dataFormat, true); }
public static void SetBindableDocument(DependencyObject source, FlowDocument value) { source.SetValue(BindableDocumentProperty, value); }
internal ReportContext(ICurrenciesLut lut, Stock stock, FlowDocument document) { myCurrenciesLut = lut; Stock = stock; Document = document; var data = new List <IFigureSeries>(); foreach (var figureType in Dynamics.AllFigures) { // EnableCurrencyCheck has to be true - otherwise we will not have series.Currency property set // except for Price - there we might have different currencies in one collection and currently we anyway // just need one price data.Add(Dynamics.GetSeries(stock, figureType, figureType != typeof(Price))); } Data = data; myProviders = new List <IFigureProvider>(); myProviders.Add(new CurrentPrice()); foreach (var figureType in Dynamics.AllFigures.Where(t => t != typeof(Price))) { myProviders.Add(new GenericFigureProvider(figureType)); } myProviders.Add(new GenericJoinProvider(ProviderNames.Eps, typeof(NetIncome).Name, typeof(SharesOutstanding).Name, (lhs, rhs) => lhs / rhs) { PreserveCurrency = true }); myProviders.Add(new GenericJoinProvider(ProviderNames.BookValue, typeof(Equity).Name, typeof(SharesOutstanding).Name, (lhs, rhs) => lhs / rhs) { PreserveCurrency = true }); myProviders.Add(new GenericJoinProvider(ProviderNames.DividendPayoutRatio, typeof(Dividend).Name, typeof(NetIncome).Name, (lhs, rhs) => lhs / rhs * 100) { PreserveCurrency = false }); myProviders.Add(new GenericJoinProvider(ProviderNames.ReturnOnEquity, typeof(NetIncome).Name, typeof(Equity).Name, (lhs, rhs) => lhs / rhs * 100) { PreserveCurrency = false }); myProviders.Add(new GenericJoinProvider(ProviderNames.DividendPerShare, typeof(Dividend).Name, typeof(SharesOutstanding).Name, (lhs, rhs) => lhs / rhs) { PreserveCurrency = true }); myProviders.Add(new GenericJoinProvider(ProviderNames.DebtEquityRatio, typeof(TotalLiabilities).Name, typeof(Equity).Name, (lhs, rhs) => lhs / rhs) { PreserveCurrency = false }); myProviders.Add(new GenericJoinProvider(ProviderNames.InterestCoverage, typeof(EBIT).Name, typeof(InterestExpense).Name, (lhs, rhs) => lhs / rhs) { PreserveCurrency = false }); myProviders.Add(new GenericJoinProvider(ProviderNames.CurrentRatio, typeof(CurrentAssets).Name, typeof(CurrentLiabilities).Name, (lhs, rhs) => lhs / rhs) { PreserveCurrency = false }); myProviders.Add(new GenericPriceRatioProvider(ProviderNames.MarketCap, typeof(SharesOutstanding).Name, (lhs, rhs) => lhs * rhs) { PreserveCurrency = true }); myProviders.Add(new GenericPriceRatioProvider(ProviderNames.PriceEarningsRatio, ProviderNames.Eps, (lhs, rhs) => lhs / rhs) { PreserveCurrency = false }); myProviders.Add(new GenericPriceRatioProvider(ProviderNames.PriceToBook, ProviderNames.BookValue, (lhs, rhs) => lhs / rhs) { PreserveCurrency = false }); myProviders.Add(new GenericPriceRatioProvider(ProviderNames.DividendYield, ProviderNames.DividendPerShare, (lhs, rhs) => rhs / lhs * 100) { PreserveCurrency = false }); myProviderFailures = new List <IFigureProviderFailure>(); }
public static void RegisterDebugField(FlowDocument debugField) { InfoBox.debugField = debugField; }
public void printDGByName(DataGrid dataGrid, string title) { PrintDialog printDialog = new PrintDialog(); if (printDialog.ShowDialog() == true) { FlowDocument fd = new FlowDocument(); Paragraph p = new Paragraph(new Run(title)); p.FontStyle = dataGrid.FontStyle; p.FontFamily = dataGrid.FontFamily; p.FontSize = 18; fd.Blocks.Add(p); Table table = new Table(); TableRowGroup tableRowGroup = new TableRowGroup(); TableRow r = new TableRow(); fd.PageWidth = printDialog.PrintableAreaWidth; fd.PageHeight = printDialog.PrintableAreaHeight; fd.BringIntoView(); fd.TextAlignment = TextAlignment.Center; fd.ColumnWidth = 500; table.CellSpacing = 0; var headerList = dataGrid.Columns.Select(e => e.Header.ToString()).ToList(); for (int j = 0; j < headerList.Count; j++) { r.Cells.Add(new TableCell(new Paragraph(new Run(headerList[j])))); r.Cells[j].ColumnSpan = 4; r.Cells[j].Padding = new Thickness(4); r.Cells[j].BorderBrush = Brushes.Black; r.Cells[j].FontWeight = FontWeights.Bold; r.Cells[j].Background = Brushes.DarkGray; r.Cells[j].Foreground = Brushes.White; r.Cells[j].BorderThickness = new Thickness(1, 1, 1, 1); } tableRowGroup.Rows.Add(r); table.RowGroups.Add(tableRowGroup); for (int i = 0; i < dataGrid.Items.Count; i++) { DataRowView row = (DataRowView)dataGrid.Items.GetItemAt(i); table.BorderBrush = Brushes.Gray; table.BorderThickness = new Thickness(1, 1, 0, 0); table.FontStyle = dataGrid.FontStyle; table.FontFamily = dataGrid.FontFamily; table.FontSize = 13; tableRowGroup = new TableRowGroup(); r = new TableRow(); for (int j = 0; j < row.Row.ItemArray.Count(); j++) { r.Cells.Add(new TableCell(new Paragraph(new Run(row.Row.ItemArray[j].ToString())))); r.Cells[j].ColumnSpan = 4; r.Cells[j].Padding = new Thickness(4); r.Cells[j].BorderBrush = Brushes.DarkGray; r.Cells[j].BorderThickness = new Thickness(0, 0, 1, 1); } tableRowGroup.Rows.Add(r); table.RowGroups.Add(tableRowGroup); } fd.Blocks.Add(table); printDialog.PrintDocument(((IDocumentPaginatorSource)fd).DocumentPaginator, ""); } }