public Table GetThreatTable() { var threatTable = new Table(); threatTable.CellSpacing = 0; threatTable.Columns.Add(new TableColumn()); threatTable.Columns.Add(new TableColumn()); threatTable.Columns.Add(new TableColumn()); threatTable.Columns.Add(new TableColumn()); var headerGroup = new TableRowGroup(); headerGroup.Rows.Add(new TableRow()); headerGroup.Rows[0].FontWeight = FontWeights.Bold; var headerRow = headerGroup.Rows[0]; headerRow.Cells.Add(new TableCell(new Paragraph(new Run("Skill")))); headerRow.Cells.Add(new TableCell(new Paragraph(new Run("Count")))); headerRow.Cells.Add(new TableCell(new Paragraph(new Run("Threat")))); headerRow.Cells.Add(new TableCell(new Paragraph(new Run("Threat %")))); threatTable.RowGroups.Add(headerGroup); var rowGroup = new TableRowGroup(); var totalThreat = TotalThreat; foreach (var item in ThreatRecordsBySkill.OrderByDescending(records => records.Sum(record => record.Threat))) { var row = new TableRow(); row.Cells.Add(new TableCell(new Paragraph(new Run(item.Key)))); row.Cells.Add(new TableCell(new Paragraph(new Run(item.Count().ToString())))); row.Cells.Add(new TableCell(new Paragraph(new Run(item.Sum(record => record.Threat).ToString())))); row.Cells.Add(new TableCell(new Paragraph(new Run(item.Sum(record => (double)record.Threat / totalThreat).ToString("0.##%"))))); rowGroup.Rows.Add(row); } rowGroup.Rows.Add(new TableRow()); threatTable.RowGroups.Add(rowGroup); return threatTable; }
public ScoreWindow(List<Game> games) { InitializeComponent(); int cols = 4; int rows = games.Count(); for (int c = 0; c < cols; c++) myTable.Columns.Add(new TableColumn()); TableRow tr0 = new TableRow(); tr0.Cells.Add(new TableCell(new Paragraph(new Run("Gra")))); tr0.Cells.Add(new TableCell(new Paragraph(new Run("Minimalny pomiar")))); tr0.Cells.Add(new TableCell(new Paragraph(new Run("Maksymalny pomiar")))); tr0.Cells.Add(new TableCell(new Paragraph(new Run("Odchylenie standardowe")))); TableRowGroup trg0 = new TableRowGroup(); trg0.Rows.Add(tr0); myTable.RowGroups.Add(trg0); foreach (Game g in games) { if (g.getMaximum() == Double.MinValue) continue; TableRow tr = new TableRow(); tr.Cells.Add(new TableCell(new Paragraph(new Run(g.getName())))); tr.Cells.Add(new TableCell(new Paragraph(new Run(g.getMinimum().ToString("N3"))))); tr.Cells.Add(new TableCell(new Paragraph(new Run(g.getMaximum().ToString("N3"))))); tr.Cells.Add(new TableCell(new Paragraph(new Run(g.getDeviation().ToString("N3"))))); TableRowGroup trg = new TableRowGroup(); trg.Rows.Add(tr); myTable.RowGroups.Add(trg); } }
public void ConfigTableRowGroup(TableRowGroup row, Collection.Messages message, ChatUIElements messagesContainer) { codeEditor = messagesContainer.codeEditor; var currentStamp = Collection.getField(message.data, "stamp"); var charMessageBody = jsonSerializer.Deserialize<ChatMessageBody>(Collection.getField(message.data,"body")); var containsKey = false; if (!charMessageBody.IsCode){ if (!messagesContainer.LastStamp.IsNullOrEmpty() && messagesContainer.MessagesList.ContainsKey(messagesContainer.LastStamp)) { messagesContainer.MessagesList[messagesContainer.LastStamp].MouseLeftButtonDown -= EditMessage; messagesContainer.MessagesList.Remove(messagesContainer.LastStamp); } containsKey = messagesContainer.MessagesList.ContainsKey(currentStamp); if (!containsKey) messagesContainer.MessagesList.Add(currentStamp,row); messagesContainer.LastStamp = currentStamp; } inputMethod = messagesContainer.InputBox; comboRooms = messagesContainer.ComboRooms; row.Dispatcher.Invoke(new Action(() =>{ if (row.Resources["originalMessage"] == null) { row.Resources.Add("originalMessage", message); } else { row.Resources["originalMessage"] = message; } if (!containsKey) row.MouseLeftButtonDown += EditMessage; })); }
public void AddTable(string tableName, params string[] headers) { var table = new Table { CellSpacing = 0, BorderThickness = new Thickness(0.5, 0.5, 0, 0), BorderBrush = Brushes.Black }; Document.Blocks.Add(table); Tables.Add(tableName, table); var lengths = ColumnLengths.ContainsKey(tableName) ? ColumnLengths[tableName] : new[] { GridLength.Auto, GridLength.Auto, new GridLength(1, GridUnitType.Star) }; for (var i = 0; i < headers.Count(); i++) { var c = new TableColumn { Width = lengths[i] }; table.Columns.Add(c); } var rows = new TableRowGroup(); table.RowGroups.Add(rows); rows.Rows.Add(CreateRow(headers, new[] { TextAlignment.Center }, true)); }
public TableRowGroup Clone(TableRowGroup rowGroup, bool returnRowGroup) { var group = rowGroup is TableRowGroupForDataTable && !returnRowGroup ? new TableRowGroupForDataTable() { TableName = ((TableRowGroupForDataTable)rowGroup).TableName } : new TableRowGroup(); CopyProperties(rowGroup, group); foreach (var row in rowGroup.Rows) group.Rows.Add(Clone(row, false)); return group; }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { //rtbMessages.Document.Blocks.Add(new Paragraph()); msgTable = new Table(); rtbMessages.Document.Blocks.Add(msgTable); msgTable.CellSpacing = 10; msgTable.Background = Brushes.White; msgTable.RowGroups.Add(new TableRowGroup()); TX = msgTable.RowGroups[0]; }
public static Table FormatFragmentsList(IEnumerable<Fragment> fragments) { var thetable = new Table(); var tableRowGroup = new TableRowGroup(); var headerRow = new TableRow { Background = new SolidColorBrush(Colors.LightGray) }; headerRow.Cells.Add(new TableCell(new Paragraph(new Run("Déplacement"))) { BorderBrush = new SolidColorBrush(Colors.Gray) }); headerRow.Cells.Add(new TableCell(new Paragraph(new Run("Taille"))) { BorderBrush = new SolidColorBrush(Colors.Gray) }); headerRow.Cells.Add(new TableCell(new Paragraph(new Run("Bit More Fragments"))) { BorderBrush = new SolidColorBrush(Colors.Gray) }); tableRowGroup.Rows.Add(headerRow); foreach (var fragment in fragments) { var row = new TableRow(); row.Cells.Add(new TableCell(new Paragraph(new Run(fragment.Offset.ToString()))) { BorderBrush = new SolidColorBrush(Colors.Gray), BorderThickness = new Thickness(0, 0, 0, 0.2) }); row.Cells.Add(new TableCell(new Paragraph(new Run(fragment.Length.ToString()))) { BorderBrush = new SolidColorBrush(Colors.Gray), BorderThickness = new Thickness(0, 0, 0, 0.2) }); row.Cells.Add(new TableCell(new Paragraph(new Run(fragment.MoreFragments.ToString()))) { BorderBrush = new SolidColorBrush(Colors.Gray), BorderThickness = new Thickness(0, 0, 0, 0.2) }); tableRowGroup.Rows.Add(row); } thetable.RowGroups.Add(tableRowGroup); return thetable; }
private void UpdateContent() { RowGroups.Clear(); if (HeaderRowGroup != null) { RowGroups.Add(HeaderRowGroup); } if (ItemsSource != null) { if (ItemTemplate == null) { throw new InvalidOperationException("When ItemsSource is used then the ItemTemplate must not be null."); } TableRowGroup contentRowGroup = new TableRowGroup(); foreach (object item in ItemsSource) { TableRow tableRow = null; ContentElement contentElement = ItemTemplate.LoadContent() as ContentElement; if (contentElement != null) { tableRow = contentElement.Content as TableRow; } if (tableRow == null) { throw new InvalidOperationException("The ItemTemplate must define: DataTemplate > ContentElement > TableRow."); } tableRow.DataContext = item; contentRowGroup.Rows.Add(tableRow); } if (contentRowGroup.Rows.Any()) { RowGroups.Add(contentRowGroup); } } if (FooterRowGroup != null) { RowGroups.Add(FooterRowGroup); } }
public DayPrintFlowDocument(DayStatisticViewModel dayViewModel) { InitializeComponent(); this.PagePadding = new Thickness(50); Content.Blocks.Add(new Paragraph(new Run(string.Format("Tagserapport: {0:dd.MM.yyyy}", dayViewModel.Day)) { FontWeight = FontWeights.Bold })); var table = new Table(); table.FontSize = 11; table.Columns.Add(new TableColumn() { Width = new GridLength(30) }); table.Columns.Add(new TableColumn() { Width = GridLength.Auto }); table.Columns.Add(new TableColumn() { Width = new GridLength(80) }); table.Columns.Add(new TableColumn() { Width = new GridLength(80) }); table.Columns.Add(new TableColumn() { Width = new GridLength(80) }); table.Columns.Add(new TableColumn() { Width = new GridLength(80) }); table.Columns.Add(new TableColumn() { Width = new GridLength(80) }); table.Columns.Add(new TableColumn() { Width = new GridLength(60) }); table.Columns.Add(new TableColumn() { Width = new GridLength(60) }); var tableRowGroup = new TableRowGroup(); var row = new TableRow(); row.Cells.Add(new TableCell(new Paragraph(new Run("Anz.") { FontWeight = FontWeights.Bold }))); row.Cells.Add(new TableCell(new Paragraph(new Run("Name") { FontWeight = FontWeights.Bold }))); row.Cells.Add(new TableCell(new Paragraph())); row.Cells.Add(new TableCell(new Paragraph())); row.Cells.Add(new TableCell(new Paragraph(new Run("Bargeld") { FontWeight = FontWeights.Bold }) { TextAlignment = System.Windows.TextAlignment.Right })); row.Cells.Add(new TableCell(new Paragraph(new Run("Kreditk.") { FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Colors.Blue) }) { TextAlignment = System.Windows.TextAlignment.Right })); row.Cells.Add(new TableCell(new Paragraph(new Run("Total") { FontWeight = FontWeights.Bold }) { TextAlignment = System.Windows.TextAlignment.Right })); row.Cells.Add(new TableCell(new Paragraph(new Run("Privat") { FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Colors.Green) }) { TextAlignment = System.Windows.TextAlignment.Right })); row.Cells.Add(new TableCell(new Paragraph(new Run("Für Gäste") { FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Colors.Red) }) { TextAlignment = System.Windows.TextAlignment.Right })); tableRowGroup.Rows.Add(row); foreach (var saleProduct in dayViewModel.TotalSaleProducts) { row = new TableRow(); row.Cells.Add(new TableCell(new Paragraph(new Run(saleProduct.Count.ToString())))); row.Cells.Add(new TableCell(new Paragraph(new Run(saleProduct.Name)) { TextAlignment = System.Windows.TextAlignment.Left })); row.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("({0:0.00} CHF)", saleProduct.Price))) { TextAlignment = System.Windows.TextAlignment.Right })); row.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("à {0:0.00} CHF", saleProduct.SellPrice))) { TextAlignment = System.Windows.TextAlignment.Right })); row.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("{0:0.00} CHF", saleProduct.TotalCash))) { TextAlignment = System.Windows.TextAlignment.Right })); row.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("{0:0.00} CHF", saleProduct.TotalCreditCard)) { Foreground = new SolidColorBrush(Colors.Blue) }) { TextAlignment = System.Windows.TextAlignment.Right })); row.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("{0:0.00} CHF", saleProduct.Total)) { FontWeight = FontWeights.Bold }) { TextAlignment = System.Windows.TextAlignment.Right })); row.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("{0:0.00} CHF", saleProduct.TotalPrivate)) { Foreground = new SolidColorBrush(Colors.Green) }) { TextAlignment = System.Windows.TextAlignment.Right })); row.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("{0:0.00} CHF", saleProduct.TotalForGuest)) { Foreground = new SolidColorBrush(Colors.Red) }) { TextAlignment = System.Windows.TextAlignment.Right })); tableRowGroup.Rows.Add(row); } row = new TableRow(); row.Cells.Add(new TableCell(new BlockUIContainer(new Separator() { HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch })) { ColumnSpan = 9 }); tableRowGroup.Rows.Add(row); table.RowGroups.Add(tableRowGroup); Content.Blocks.Add(table); table = new Table(); table.FontSize = 11; table.Columns.Add(new TableColumn() { Width = new GridLength(150) }); table.Columns.Add(new TableColumn() { Width = new GridLength(150) }); table.Columns.Add(new TableColumn() { Width = GridLength.Auto }); table.Columns.Add(new TableColumn() { Width = new GridLength(150) }); tableRowGroup = new TableRowGroup(); row = new TableRow(); row.Cells.Add(new TableCell(new Paragraph(new Run("Privatbezug:")))); row.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("{0:0.00} CHF", dayViewModel.TotalPrivate))))); row.Cells.Add(new TableCell(new Paragraph(new Run("Bargeld:")))); row.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("{0:0.00} CHF", dayViewModel.TotalCash))) { TextAlignment = System.Windows.TextAlignment.Right })); tableRowGroup.Rows.Add(row); row = new TableRow(); row.Cells.Add(new TableCell(new Paragraph(new Run("Für Gäste:")))); row.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("{0:0.00} CHF", dayViewModel.TotalForGuest))))); row.Cells.Add(new TableCell(new Paragraph(new Run("Kreditkarte:")))); row.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("{0:0.00} CHF", dayViewModel.TotalCreditCard))) { TextAlignment = System.Windows.TextAlignment.Right })); tableRowGroup.Rows.Add(row); row = new TableRow(); row.Cells.Add(new TableCell()); row.Cells.Add(new TableCell()); row.Cells.Add(new TableCell(new BlockUIContainer(new Separator() { HorizontalAlignment = HorizontalAlignment.Stretch })) { ColumnSpan = 2 }); tableRowGroup.Rows.Add(row); row = new TableRow(); row.Cells.Add(new TableCell()); row.Cells.Add(new TableCell()); row.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("Total vom {0:dd.MM.yyyy}:", dayViewModel.Day)) { FontWeight = FontWeights.Bold }) { TextAlignment = System.Windows.TextAlignment.Left })); row.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("{0:0.00} CHF", dayViewModel.Total)) { FontWeight = FontWeights.Bold }) { TextAlignment = System.Windows.TextAlignment.Right })); tableRowGroup.Rows.Add(row); row = new TableRow(); row.Cells.Add(new TableCell() { LineHeight = 1 }); row.Cells.Add(new TableCell() { LineHeight = 1 }); row.Cells.Add(new TableCell(new BlockUIContainer(new Separator() { HorizontalAlignment = HorizontalAlignment.Stretch })) { ColumnSpan = 2, LineHeight = 1 }); tableRowGroup.Rows.Add(row); row = new TableRow(); row.Cells.Add(new TableCell() { LineHeight = 1 }); row.Cells.Add(new TableCell() { LineHeight = 1 }); row.Cells.Add(new TableCell(new BlockUIContainer(new Separator() { HorizontalAlignment = HorizontalAlignment.Stretch })) { ColumnSpan = 2, LineHeight = 1 }); tableRowGroup.Rows.Add(row); table.RowGroups.Add(tableRowGroup); Content.Blocks.Add(table); }
public void TableAddPropertyRows_Recurse( ConceptModelZveiTechnicalData theDefs, string defaultLang, AdminShellPackageEnv package, Table table, AdminShell.SubmodelElementWrapperCollection smwc, int depth = 0) { // access if (table == null || smwc == null) { return; } // make a RowGroup var currentRowGroup = new TableRowGroup(); table.RowGroups.Add(currentRowGroup); // go element by element foreach (var smw in smwc) { // access if (smw?.submodelElement == null) { continue; } var sme = smw.submodelElement; // prepare information about displayName, semantics unit var semantics = "-"; var unit = ""; // make up property name (1) var dispName = "" + sme.idShort; var dispNameWithCD = dispName; // make up semantics if (sme.semanticId != null) { if (sme.semanticId.Matches(theDefs.CD_SemanticIdNotAvailable.GetSingleKey())) { semantics = "(not available)"; } else { // the semantics display semantics = "" + sme.semanticId.ToString(2); // find better property name (2) var cd = package?.AasEnv?.FindConceptDescription(sme.semanticId); if (cd != null) { // unit? unit = "" + cd.GetIEC61360()?.unit; // names var dsn = cd.GetDefaultShortName(defaultLang); if (dsn != "") { dispNameWithCD = dsn; } var dpn = cd.GetDefaultPreferredName(defaultLang); if (dpn != "") { dispNameWithCD = dpn; } } } } // make up even better better property name (3) var descDef = "" + sme.description?.langString?.GetDefaultStr(defaultLang); if (descDef.HasContent()) { dispName = descDef; dispNameWithCD = dispName; } // special function? if (sme is AdminShell.SubmodelElementCollection && true == sme.semanticId?.Matches(theDefs.CD_MainSection.GetSingleKey())) { // finalize current row group?? ; // Main Section var cell = NewTableCellPara("" + dispName, null, "ParaStyleSectionMain", columnSpan: 3, padding: new Thickness(5 * depth, 0, 0, 0)); // add cell (to a new row group) currentRowGroup = new TableRowGroup(); table.RowGroups.Add(currentRowGroup); var tr = new TableRow(); currentRowGroup.Rows.Add(tr); tr.Cells.Add(cell); // recurse into that (again, new group) TableAddPropertyRows_Recurse( theDefs, defaultLang, package, table, (sme as AdminShell.SubmodelElementCollection).value, depth + 1); // start new group currentRowGroup = new TableRowGroup(); table.RowGroups.Add(currentRowGroup); } else if (sme is AdminShell.SubmodelElementCollection && true == sme.semanticId?.Matches(theDefs.CD_SubSection.GetSingleKey())) { // finalize current row group?? ; // Sub Section var cell = NewTableCellPara("" + dispName, null, "ParaStyleSectionSub", columnSpan: 3, padding: new Thickness(5 * depth, 0, 0, 0)); // add cell (to a new row group) currentRowGroup = new TableRowGroup(); table.RowGroups.Add(currentRowGroup); var tr = new TableRow(); currentRowGroup.Rows.Add(tr); tr.Cells.Add(cell); // recurse into that TableAddPropertyRows_Recurse( theDefs, defaultLang, package, table, (sme as AdminShell.SubmodelElementCollection).value, depth + 1); // start new group currentRowGroup = new TableRowGroup(); table.RowGroups.Add(currentRowGroup); } else if (sme is AdminShell.Property || sme is AdminShell.MultiLanguageProperty || sme is AdminShell.Range) { // make a row (in current group) var tr = new TableRow(); currentRowGroup.Rows.Add(tr); // add cells tr.Cells.Add(NewTableCellPara(dispNameWithCD, "CellStylePropertyLeftmost", "ParaStyleProperty", padding: new Thickness(5 * depth, 0, 0, 0))); tr.Cells.Add(NewTableCellPara(semantics, "CellStylePropertyOther", "ParaStyleProperty")); tr.Cells.Add(NewTableCellPara("" + sme.ValueAsText(defaultLang) + " " + unit, "CellStylePropertyOther", "ParaStyleProperty")); } } // finalize current row group?? ; }
public static void AddNewMessageRow(this FlowDocument document, Tox tox, MessageData data, bool sameUser) { document.IsEnabled = true; //Make a new row TableRow newTableRow = new TableRow(); newTableRow.Tag = data; //Make a new cell and create a paragraph in it TableCell usernameTableCell = new TableCell(); usernameTableCell.Name = "usernameTableCell"; usernameTableCell.Padding = new Thickness(10, 0, 0, 0); Paragraph usernameParagraph = new Paragraph(); usernameParagraph.TextAlignment = data.IsAction ? TextAlignment.Right : TextAlignment.Left; usernameParagraph.Foreground = new SolidColorBrush(Color.FromRgb(164, 164, 164)); if (data.Username != tox.GetSelfName()) { usernameParagraph.SetResourceReference(Paragraph.ForegroundProperty, "AccentColorBrush"); } if (!sameUser) { usernameParagraph.Inlines.Add(data.Username); } usernameTableCell.Blocks.Add(usernameParagraph); //Make a new cell and create a paragraph in it TableCell messageTableCell = new TableCell(); Paragraph messageParagraph = new Paragraph(); messageParagraph.TextAlignment = TextAlignment.Left; if (data.IsSelf) { messageParagraph.Foreground = new SolidColorBrush(Color.FromRgb(164, 164, 164)); } ProcessMessage(data, messageParagraph, false); //messageParagraph.Inlines.Add(fakeHyperlink); messageTableCell.Blocks.Add(messageParagraph); TableCell timestampTableCell = new TableCell(); Paragraph timestamParagraph = new Paragraph(); timestampTableCell.TextAlignment = TextAlignment.Right; timestamParagraph.Inlines.Add(DateTime.Now.ToShortTimeString()); timestampTableCell.Blocks.Add(timestamParagraph); timestamParagraph.Foreground = new SolidColorBrush(Color.FromRgb(164, 164, 164)); //Add the two cells to the row we made before newTableRow.Cells.Add(usernameTableCell); newTableRow.Cells.Add(messageTableCell); newTableRow.Cells.Add(timestampTableCell); //Adds row to the Table > TableRowGroup TableRowGroup MessageRows = (TableRowGroup)document.FindName("MessageRows"); MessageRows.Rows.Add(newTableRow); }
private FlowDocument PreviewInTable(ObservableCollection <mAmbulante> obj) { FlowDocument flow = new FlowDocument(); flow.ColumnGap = 0; flow.Background = Brushes.White; //flow.ColumnWidth = 8.5 * 96.0; //flow.ColumnWidth = 96.0 * 8.5; //flow.PageHeight = 11.5 * 96.0; //flow.PageWidth = 8.5 * 96.0; flow.PageHeight = 768; flow.PageWidth = 1104; flow.ColumnWidth = 1104; flow.FontFamily = new FontFamily("Segoe UI"); flow.FontSize = 11; flow.PagePadding = new Thickness(40, 20, 40, 20); flow.TextAlignment = TextAlignment.Left; Paragraph pH = new Paragraph(new Run(new mFlowHeader().NameOrg)); pH.Typography.Capitals = FontCapitals.SmallCaps; pH.Foreground = Brushes.Black; pH.FontSize = 16; pH.FontWeight = FontWeights.Bold; pH.Margin = new Thickness(0); Paragraph pH1 = new Paragraph(new Run(new mFlowHeader().SloganOrg)); pH1.Foreground = Brushes.Black; pH1.FontSize = 9; pH1.Margin = new Thickness(2, 0, 0, 0); Paragraph pH2 = new Paragraph(new Run(new mFlowHeader().DepOrg)); pH2.Typography.Capitals = FontCapitals.SmallCaps; pH2.Foreground = Brushes.Black; pH2.FontWeight = FontWeights.Bold; pH2.FontSize = 12; pH2.Margin = new Thickness(0, 10, 0, 0); Paragraph pH3 = new Paragraph(new Run(new mFlowHeader().SetorOrg)); pH3.Typography.Capitals = FontCapitals.SmallCaps; pH3.FontWeight = FontWeights.Bold; pH3.Foreground = Brushes.Black; pH3.Margin = new Thickness(0, 0, 0, 20); flow.Blocks.Add(pH); flow.Blocks.Add(pH1); flow.Blocks.Add(pH2); flow.Blocks.Add(pH3); /* * var lfiltro = new Rectangle(); * lfiltro.Stroke = new SolidColorBrush(Colors.Silver); * lfiltro.StrokeThickness = 1; * lfiltro.Height = 1; * lfiltro.Width = double.NaN; * lfiltro.Margin = new Thickness(0, 0, 0, 0); * * var linefiltro = new BlockUIContainer(lfiltro); * flow.Blocks.Add(linefiltro); */ //SolidColorBrush bgc1 = Application.Current.Resources["ButtonBackgroundHover"] as SolidColorBrush; Table tb = new Table(); tb.CellSpacing = 0; tb.BorderThickness = new Thickness(0.5); tb.BorderBrush = Brushes.Black; tb.Columns.Add(new TableColumn() { Width = new GridLength(50) }); tb.Columns.Add(new TableColumn() { Width = new GridLength(120) }); tb.Columns.Add(new TableColumn() { Width = GridLength.Auto }); tb.Columns.Add(new TableColumn() { Width = new GridLength(120) }); tb.Columns.Add(new TableColumn() { Width = new GridLength(120) }); //tb.Columns.Add(new TableColumn() { Width = new GridLength(200) }); //tb.Columns.Add(new TableColumn() { Width = new GridLength(10, GridUnitType.Star) }); TableRowGroup rg = new TableRowGroup(); string f = string.Empty; foreach (string filtro in Filtros) { f += filtro; } TableRow pheader = new TableRow(); pheader.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("FILTROS: {0}", f))) { Padding = new Thickness(5) }) { ColumnSpan = 4, BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); pheader.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("REGISTROS: {0}", obj.Count))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); tb.RowGroups.Add(rg); Paragraph p = new Paragraph(); p.Padding = new Thickness(5); TableRow header = new TableRow(); rg.Rows.Add(pheader); rg.Rows.Add(header); rg.Foreground = Brushes.Black; //rw2.Background = bgc1; header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run(""))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("CADASTRO"))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("CLIENTE"))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("SITUAÇÃO"))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("TELEFONE"))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); //header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("ASSINATURA"))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(1, 0, 0, 0), BorderBrush = Brushes.Black }); int alt = 0; if (obj != null) { foreach (mAmbulante a in obj) { TableRow row = new TableRow(); rg.Foreground = Brushes.Black; rg.Rows.Add(row); row.Cells.Add(new TableCell(new Paragraph(new Run(a.Contador.ToString())) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); row.Cells.Add(new TableCell(new Paragraph(new Run(a.Cadastro + "\nDE: " + a.DataCadastro.ToShortDateString())) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); Paragraph np = new Paragraph(); np.Padding = new Thickness(5); np.Inlines.Add(new Run(string.Format("{0}", a.Pessoa.NomeRazao))); np.Inlines.Add(new LineBreak()); np.Inlines.Add(new Run(string.Format("EMPRESA: {0}", a.Empresa.Inscricao))); np.Inlines.Add(new LineBreak()); np.Inlines.Add(new Run(string.Format("ATIVIDADE: {0}", a.DescricaoNegocio))); np.Inlines.Add(new LineBreak()); np.Inlines.Add(new Run(string.Format("TEMPO ATIVIDADE: {0} MESES, PESSOAS ENVOLVIDAS: {1}", a.TempoAtividade, a.PessoasEnvolvidas))); np.Inlines.Add(new LineBreak()); np.Inlines.Add(new Run(string.Format("LOCAL: {0}", a.Local))); row.Cells.Add(new TableCell(np) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); row.Cells.Add(new TableCell(new Paragraph(new Run(Situações[a.Situacao].Nome)) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); row.Cells.Add(new TableCell(new Paragraph(new Run(a.Pessoa.Telefones)) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); alt++; } } flow.Blocks.Add(tb); 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(r); return(flow); }
// .................................................................... // // Table Insertion // // .................................................................... #region Table Insertion /// <summary> /// Inserts a table into a position specified by textRange. /// </summary> /// <param name="insertionPosition"> /// Position where table must be inserted. /// </param> /// <param name="rowCount"> /// Number of rows generated in a table /// </param> /// <param name="columnCount"> /// Number of columnns generated in each row /// </param> /// <returns> /// Returns a table inserted. /// </returns> internal static Table InsertTable(TextPointer insertionPosition, int rowCount, int columnCount) { // Inserting tables in lists is currently disabled, so check that we are not in a list TextElement ancestor = insertionPosition.Parent as TextElement; while (ancestor != null) { if (ancestor is List || ancestor is Inline && !TextSchema.IsMergeableInline(ancestor.GetType())) { // insertionPosition is inside a List. // or it is inside a Hyperlink which is a non-splittable element. // Operation disabled. // return null; } ancestor = ancestor.Parent as TextElement; } insertionPosition = TextRangeEditTables.EnsureInsertionPosition(insertionPosition); Paragraph paragraph = insertionPosition.Paragraph; if (paragraph == null) { return null; } // Split current paragraph at insertion position insertionPosition = insertionPosition.InsertParagraphBreak(); // paragraph = insertionPosition.Paragraph; Invariant.Assert(paragraph != null, "Expecting non-null paragraph at insertionPosition"); // Build a table with a given number of rows and columns Table table = new Table(); table.CellSpacing = 0; TableRowGroup rowGroup = new TableRowGroup(); for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) { TableRow row = new TableRow(); for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) { TableCell cell = new TableCell(new Paragraph()); cell.BorderThickness = GetCellBorder(1, rowIndex, columnIndex, 1, 1, rowCount, columnCount); cell.BorderBrush = System.Windows.Media.Brushes.Black; row.Cells.Add(cell); } rowGroup.Rows.Add(row); } table.RowGroups.Add(rowGroup); // Insert a table before the second of split paragraphs paragraph.SiblingBlocks.InsertBefore(paragraph, table); return table; }
/// <summary> /// Setup the main <see cref="Table"/> and the headings. /// </summary> /// <param name="resourceDictionary"></param> /// <returns></returns> private Table SetupTable(ResourceDictionary resourceDictionary) { if (resourceDictionary == null) { throw new ArgumentNullException("resourceDictionary"); } DictionaryHelper.Expect<Style>(resourceDictionary, StyleHelper.DetailRowStyleName); Table table; TableRow tableRow; // reused TableRowGroup tableRowGroup; table = new Table(); table.Style = (Style)resourceDictionary[StyleHelper.DetailRowStyleName]; for (int i = 0; i < (NumEncounters * 3); i++) { table.Columns.Add(new TableColumn()); } tableRowGroup = new TableRowGroup(); tableRow = new TableRow(); tableRow.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("Power")))) { ColumnSpan = NameColumnSpan, TextAlignment = TextAlignment.Center }); tableRow.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("Encounter")))) { ColumnSpan = NumEncounters, TextAlignment = TextAlignment.Center }); tableRowGroup.Rows.Add(tableRow); tableRow = new TableRow(); tableRow.Cells.Add(new TableCell(new Paragraph(new Bold(new Run(string.Empty)))) { ColumnSpan = NameColumnSpan }); for(int i = 1; i <= NumEncounters; i++) { tableRow.Cells.Add(new TableCell(new Paragraph(new Bold(new Run(i.ToString())))) { TextAlignment = TextAlignment.Center } ); } tableRowGroup.Rows.Add(tableRow); table.RowGroups.Add(tableRowGroup); return table; }
private Table CreateSummaryTable() { int resultCount = _testResults.Count; Table summaryTable = new Table(); summaryTable.CellSpacing = 0; summaryTable.BorderBrush = Brushes.Gray; summaryTable.BorderThickness = new Thickness(1); summaryTable.Margin = new Thickness(16, 0, 16, 16); TableColumn categoryCol = new TableColumn(); categoryCol.Width = new GridLength(2, GridUnitType.Star); summaryTable.Columns.Add(categoryCol); TableColumn totalCol = new TableColumn(); totalCol.Width = new GridLength(1, GridUnitType.Star); summaryTable.Columns.Add(totalCol); for (int i = 0; i < resultCount; i++) { TableColumn successCol = new TableColumn(); successCol.Width = new GridLength(1, GridUnitType.Star); summaryTable.Columns.Add(successCol); } TableRowGroup headerGroup = new TableRowGroup(); headerGroup.Background = Brushes.LightGray; TableRow headerRow = new TableRow(); headerRow.Cells.Add(CreateHeaderCell("Category", false, false)); headerRow.Cells.Add(CreateHeaderCell("Total", false, false)); for (int i = 0; i < resultCount; i++) { SvgTestResult testResult = _testResults[i]; headerRow.Cells.Add(CreateHeaderCell(testResult.Version + " (%)", (i == (resultCount - 1)), false)); } headerGroup.Rows.Add(headerRow); summaryTable.RowGroups.Add(headerGroup); int[] successValues = new int[resultCount]; int totalValue = 0; // Start with color of newer vesions Brush[] changedBrushes = { Brushes.LightSeaGreen, // Version 1.2 Brushes.LightSkyBlue, // Version 1.1 Brushes.LightPink, Brushes.LightSalmon, Brushes.LightSteelBlue, Brushes.LightSkyBlue, Brushes.LightSkyBlue }; for (int k = 0; k < _categoryLabels.Count; k++) { TableRowGroup resultGroup = new TableRowGroup(); TableRow resultRow = new TableRow(); bool lastBottom = (k == (_categoryLabels.Count - 1)); resultRow.Cells.Add(CreateCell(_categoryLabels[k], false, lastBottom)); for (int i = 0; i < resultCount; i++) { SvgTestResult testResult = _testResults[i]; IList <SvgTestCategory> testCategories = testResult.Categories; SvgTestCategory testCategory = testCategories[k]; if (!testCategory.IsValid) { continue; } int total = testCategory.Total; if (i == 0) { resultRow.Cells.Add(CreateCell(total, false, lastBottom)); } successValues[i] = testCategory.Successes; totalValue = total; bool lastRight = (i == (resultCount - 1)); double percentValue = Math.Round(testCategory.Successes * 100.0d / total, 2); resultRow.Cells.Add(CreateCell(percentValue.ToString("00.00"), lastRight, lastBottom, false, false)); } int cellCount = resultRow.Cells.Count; if (IsAllZero(successValues)) { for (int i = 1; i < cellCount; i++) { resultRow.Cells[i].Background = Brushes.PaleVioletRed; } } else if (IsAllDone(successValues, totalValue)) { for (int i = 1; i < cellCount; i++) { resultRow.Cells[i].Background = Brushes.Silver; } } else { if (IsNowDone(successValues, totalValue)) { for (int i = 1; i < cellCount; i++) { resultRow.Cells[i].Background = Brushes.Silver; } } if (resultCount > 1) { int i = 0; for (int j = (resultCount - 1); j >= 1; j--) { var selectedBrush = changedBrushes[i]; i++; if (IsBetterResult(successValues, j)) { resultRow.Cells[cellCount - i].Background = selectedBrush; } } } } resultGroup.Rows.Add(resultRow); summaryTable.RowGroups.Add(resultGroup); } return(summaryTable); }
/// <summary> /// Render out the header containing the name, level, class, race and so on. /// </summary> /// <param name="character"> /// The <see cref="Character"/> to render. /// </param> /// <param name="resourceDictionary"> /// A <see cref="ResourceDictionary"/> containing styles. /// </param> /// <returns> /// No argument can be null. /// </returns> private Block RenderHeader(Character character, ResourceDictionary resourceDictionary) { if (character == null) { throw new ArgumentNullException("character"); } if (resourceDictionary == null) { throw new ArgumentNullException("resourceDictionary"); } DictionaryHelper.Expect<Style>(resourceDictionary, StyleHelper.HeaderStyleName); Table table; TableRowGroup tableRowGroup; TableRow tableRow; TableCell leftCell; TableCell rightCell; Paragraph paragraph; // Reused leftCell = new TableCell(); paragraph = new Paragraph(); paragraph.Inlines.Add(new Bold(new Run(character.Name))); leftCell.Blocks.Add(paragraph); rightCell = new TableCell(); paragraph = new Paragraph(); paragraph.Inlines.Add(new Run( string.Format("Level {0} {1} {2}", character.Level, character.PrimaryOrigin.Name, character.SecondaryOrigin.Name))); rightCell.TextAlignment = TextAlignment.Right; rightCell.Blocks.Add(paragraph); tableRow = new TableRow(); tableRow.Cells.Add(leftCell); tableRow.Cells.Add(rightCell); table = new Table(); table.Style = (Style)resourceDictionary[StyleHelper.HeaderStyleName]; table.Columns.Add(new TableColumn()); table.Columns.Add(new TableColumn()); tableRowGroup = new TableRowGroup(); tableRowGroup.Rows.Add(tableRow); table.RowGroups.Add(tableRowGroup); return table; }
/// <summary> /// Render out the section containing hit points and healing surges. /// </summary> /// <param name="displayCharacter"> /// The <see cref="DisplayCharacter"/> to display. /// </param> /// <param name="resourceDictionary"> /// A <see cref="ResourceDictionary"/> containing styles. /// </param> /// <exception cref="ArgumentNullException"> /// No argument can be null. /// </exception> private TableRowGroup RenderHitPoints(DisplayCharacter displayCharacter, ResourceDictionary resourceDictionary) { if (displayCharacter == null) { throw new ArgumentNullException("displayCharacter"); } DictionaryHelper.Expect<Style>(resourceDictionary, StyleHelper.TraitHeaderRowStyleName); TableRowGroup tableRowGroup; TableRow tableRow; // Reused TableCell tableCell; // Reused Style style; style = (Style)resourceDictionary[StyleHelper.TraitHeaderRowStyleName]; tableRowGroup = new TableRowGroup(); tableRowGroup.Style = style; tableRow = new TableRow(); // Add the Hit Points title tableCell = new TableCell() { ColumnSpan = NameColumnSpan + NumEncounters }; tableCell.Blocks.Add(new Paragraph(new Run(string.Format("Hit Points: {0}", displayCharacter.Character[ScoreType.HitPoints].ToString("CS"))))); tableRow = new TableRow(); tableRow.Cells.Add(tableCell); tableRowGroup.Rows.Add(tableRow); // Add the Hit Points box tableCell = new TableCell() { ColumnSpan = NameColumnSpan + NumEncounters }; Table hitPointsTable; TableRowGroup hitPointsTableRowGroup; TableRow hitPointsTableRow; TableCell hitPointsTableCell; Paragraph hitPointParagraph; hitPointParagraph = new Paragraph(); hitPointParagraph.Inlines.Add(new Run(displayCharacter.Character.HitPoints.Total.ToString())); for (int i = 0; i < 4; i++) { hitPointParagraph.Inlines.Add(new LineBreak()); } hitPointsTableCell = new TableCell(); hitPointsTableCell.Blocks.Add(hitPointParagraph); hitPointsTableRow = new TableRow(); hitPointsTableRow.Cells.Add(hitPointsTableCell); hitPointsTableRowGroup = new TableRowGroup(); hitPointsTableRowGroup.Rows.Add(hitPointsTableRow); hitPointsTable = new Table(); hitPointsTable.BorderBrush = Brushes.Black; hitPointsTable.BorderThickness = new Thickness(72 / 96.0); // 1pt hitPointsTable.Background = Brushes.White; hitPointsTable.Margin = new Thickness(0); hitPointsTable.Padding = new Thickness(0); hitPointsTable.RowGroups.Add(hitPointsTableRowGroup); tableCell.Blocks.Add(hitPointsTable); tableRow = new TableRow(); tableRow.Cells.Add(tableCell); tableRowGroup.Rows.Add(tableRow); return tableRowGroup; }
/// <summary> /// Render out encounter powers. /// </summary> /// <param name="displayCharacter"> /// The character to write out the encounter powers for. /// </param> /// <param name="resourceDictionary"> /// A <see cref="ResourceDictionary"/> containing styles. /// </param> /// <exception cref="ArgumentNullException"> /// No argument can be null. /// </exception> private TableRowGroup RenderEncounterPowers(DisplayCharacter displayCharacter, ResourceDictionary resourceDictionary) { if (displayCharacter == null) { throw new ArgumentNullException("displayCharacter"); } DictionaryHelper.Expect<Style>(resourceDictionary, StyleHelper.EncounterHeaderRowStyleName); List<Power> powers; TableRowGroup tableRowGroup; Style style; powers = new List<Power>(); powers.AddRange(displayCharacter.Character.GetUsablePowers().Where(x => x.Frequency == PowerFrequency.Encounter)); powers.Sort((x, y) => x.Name.CompareTo(y.Name)); style = (Style)resourceDictionary[StyleHelper.EncounterHeaderRowStyleName]; tableRowGroup = new TableRowGroup(); foreach (Power power in powers) { TableRow tableRow; tableRow = new TableRow(); tableRow.Cells.Add( new TableCell(new Paragraph(new Run(GetPowerHeading(power))) { Style = style }) { ColumnSpan = NameColumnSpan }); for (int i = 0; i < NumEncounters; i++) { tableRow.Cells.Add(new TableCell(RenderBoxes(1, style)) { TextAlignment = TextAlignment.Center }); } tableRowGroup.Rows.Add(tableRow); } return tableRowGroup; }
private Block TableEvalutor(Match match) { if (match is null) { throw new ArgumentNullException(nameof(match)); } var wholeTable = match.Groups[1].Value; var header = match.Groups[2].Value.Trim(); var style = match.Groups[4].Value.Trim(); var row = match.Groups[6].Value.Trim(); var styles = style.Substring(1, style.Length - 2).Split('|'); var headers = header.Substring(1, header.Length - 2).Split('|'); var rowList = row.Split('\n').Select(ritm => { var trimRitm = ritm.Trim(); return(trimRitm.Substring(1, trimRitm.Length - 2).Split('|')); }).ToList(); int maxColCount = Math.Max( Math.Max(styles.Length, headers.Length), rowList.Select(ritm => ritm.Length).Max() ); // table style var aligns = new List <TextAlignment?>(); foreach (var colStyleTxt in styles) { var firstChar = colStyleTxt.First(); var lastChar = colStyleTxt.Last(); // center if (firstChar == ':' && lastChar == ':') { aligns.Add(TextAlignment.Center); } // right else if (lastChar == ':') { aligns.Add(TextAlignment.Right); } // left else if (firstChar == ':') { aligns.Add(TextAlignment.Left); } // default else { aligns.Add(null); } } while (aligns.Count < maxColCount) { aligns.Add(null); } // table var table = new Table(); if (TableStyle != null) { table.Style = TableStyle; } // table columns while (table.Columns.Count < maxColCount) { table.Columns.Add(new TableColumn()); } // table header var tableHeaderRG = new TableRowGroup(); if (TableHeaderStyle != null) { tableHeaderRG.Style = TableHeaderStyle; } var tableHeader = CreateTableRow(headers, aligns); tableHeaderRG.Rows.Add(tableHeader); table.RowGroups.Add(tableHeaderRG); // row var tableBodyRG = new TableRowGroup(); if (TableBodyStyle != null) { tableBodyRG.Style = TableBodyStyle; } foreach (string[] rowAry in rowList) { var tableBody = CreateTableRow(rowAry, aligns); tableBodyRG.Rows.Add(tableBody); } table.RowGroups.Add(tableBodyRG); return(table); }
// Helper for EnsureInsertionPosition. // Generates minimally necessary content to ensure at least one insertion position. private static TextPointer CreateInsertionPositionInIncompleteContent(TextPointer position) { // Go inside the scoped element to its possible lowest level while (position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart) { position = position.GetNextContextPosition(LogicalDirection.Forward); } while (position.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementEnd) { position = position.GetNextContextPosition(LogicalDirection.Backward); } DependencyObject parent = position.Parent; if (parent != null) { if (parent is Table) { // Creating implicit TableRowGroup TableRowGroup tableRowGroup = new TableRowGroup(); tableRowGroup.Reposition(position, position); position = tableRowGroup.ContentStart; parent = position.Parent; } if (parent is TableRowGroup) { // Creating implicit TableRow TableRow tableRow = new TableRow(); tableRow.Reposition(position, position); position = tableRow.ContentStart; parent = position.Parent; } if (parent is TableRow) { // Creating implicit TableCell TableCell tableCell = new TableCell(); tableCell.Reposition(position, position); position = tableCell.ContentStart; parent = position.Parent; } if (parent is List) { // Creating implicit ListItem ListItem listItem = new ListItem(); listItem.Reposition(position, position); position = listItem.ContentStart; parent = position.Parent; } if (parent is LineBreak || parent is InlineUIContainer) { position = ((Inline)parent).ElementStart; parent = position.Parent; } } if (parent == null) { // throw new InvalidOperationException(SR.Get(SRID.TextSchema_CannotInsertContentInThisPosition)); } TextPointer insertionPosition; if (TextSchema.IsValidChild(/*position:*/position, /*childType:*/typeof(Inline))) { insertionPosition = CreateImplicitRun(position); } else { Invariant.Assert(TextSchema.IsValidChild(/*position:*/position, /*childType:*/typeof(Block)), "Expecting valid parent-child relationship"); insertionPosition = CreateImplicitParagraph(position); } return insertionPosition; }
void AddTableRow(TableRowGroup rowGroup, string leftText, IDictionary<CultureInfo, string> rightStrings) { string rightText = NameDictionaryHelper.GetDisplayName(rightStrings); AddTableRow(rowGroup, leftText, rightText); }
private FlowDocument PreviewInTable(DataTable obj) { FlowDocument flow = new FlowDocument(); flow.ColumnGap = 0; flow.Background = Brushes.White; //flow.ColumnWidth = 8.5 * 96.0; //flow.ColumnWidth = 96.0 * 8.5; //flow.PageHeight = 11.5 * 96.0; //flow.PageWidth = 8.5 * 96.0; flow.PageHeight = 768; flow.PageWidth = 1104; flow.ColumnWidth = 1104; flow.FontFamily = new FontFamily("Segoe UI"); flow.FontSize = 11; flow.PagePadding = new Thickness(40, 20, 40, 20); flow.TextAlignment = TextAlignment.Left; Paragraph pH = new Paragraph(new Run(new mFlowHeader().NameOrg)); pH.Typography.Capitals = FontCapitals.SmallCaps; pH.Foreground = Brushes.Black; pH.FontSize = 16; pH.FontWeight = FontWeights.Bold; pH.Margin = new Thickness(0); Paragraph pH1 = new Paragraph(new Run(new mFlowHeader().SloganOrg)); pH1.Foreground = Brushes.Black; pH1.FontSize = 9; pH1.Margin = new Thickness(1, 0, 0, 0); Paragraph pH2 = new Paragraph(new Run(new mFlowHeader().DepOrg)); pH2.Typography.Capitals = FontCapitals.SmallCaps; pH2.Foreground = Brushes.Black; pH2.FontWeight = FontWeights.Bold; pH2.FontSize = 12; pH2.Margin = new Thickness(0, 10, 0, 0); Paragraph pH3 = new Paragraph(new Run(new mFlowHeader().SetorOrg)); pH3.Typography.Capitals = FontCapitals.SmallCaps; pH3.FontWeight = FontWeights.Bold; pH3.Foreground = Brushes.Black; pH3.Margin = new Thickness(0, 0, 0, 20); flow.Blocks.Add(pH); flow.Blocks.Add(pH1); flow.Blocks.Add(pH2); flow.Blocks.Add(pH3); string f = string.Empty; foreach (string filtro in Filtros) { f += filtro + " "; } Paragraph ft = new Paragraph(); ft.Foreground = Brushes.Black; ft.Margin = new Thickness(0, 0, 0, 0); ft.FontSize = 10; ft.Inlines.Add(new Run("FILTROS: ")); ft.Inlines.Add(new Run(f)); Paragraph ft1 = new Paragraph(); ft1.Foreground = Brushes.Black; ft1.Margin = new Thickness(0, 0, 0, 0); ft1.FontSize = 10; ft1.Inlines.Add(new Run("[REG. ENCONTRADO(S): ")); ft1.Inlines.Add(new Bold(new Run(obj.Rows.Count.ToString()))); ft1.Inlines.Add(new Run("]")); flow.Blocks.Add(ft); flow.Blocks.Add(ft1); /* * var lfiltro = new Rectangle(); * lfiltro.Stroke = new SolidColorBrush(Colors.Silver); * lfiltro.StrokeThickness = 1; * lfiltro.Height = 1; * lfiltro.Width = double.NaN; * lfiltro.Margin = new Thickness(0, 0, 0, 0); * * var linefiltro = new BlockUIContainer(lfiltro); * flow.Blocks.Add(linefiltro); */ Table tb = new Table(); tb.CellSpacing = 0; tb.BorderThickness = new Thickness(0.5); tb.BorderBrush = Brushes.Black; tb.Columns.Add(new TableColumn() { Width = new GridLength(50) }); tb.Columns.Add(new TableColumn() { Width = new GridLength(150) }); tb.Columns.Add(new TableColumn() { Width = GridLength.Auto }); //tb.Columns.Add(new TableColumn() { Width = new GridLength(10, GridUnitType.Star) }); if (Bairro) { tb.Columns.Add(new TableColumn() { Width = GridLength.Auto }); } if (CEP) { tb.Columns.Add(new TableColumn() { Width = new GridLength(80) }); } if (Origem) { tb.Columns.Add(new TableColumn() { Width = new GridLength(150) }); } if (Inicio) { tb.Columns.Add(new TableColumn() { Width = GridLength.Auto }); } if (NomeAnt) { tb.Columns.Add(new TableColumn() { Width = GridLength.Auto }); } if (Observacoes) { tb.Columns.Add(new TableColumn() { Width = GridLength.Auto }); } TableRowGroup rg2 = new TableRowGroup(); rg2.Foreground = Brushes.Black; tb.RowGroups.Add(rg2); TableRow rw2 = new TableRow(); rg2.Rows.Add(rw2); rw2.Foreground = Brushes.Black; rw2.Cells.Add(new TableCell(new Paragraph(new Bold(new Run(""))) { Padding = new Thickness(5), BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black })); rw2.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("TIPO"))) { Padding = new Thickness(5), BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black })); rw2.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("NOME"))) { Padding = new Thickness(5), BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black })); if (Bairro) { rw2.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("BAIRRO"))) { Padding = new Thickness(5), BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black })); } if (CEP) { rw2.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("CEP"))) { Padding = new Thickness(5), BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black })); } if (Origem) { rw2.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("ORIGEM"))) { Padding = new Thickness(5), BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black })); } if (Inicio) { rw2.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("INICIO"))) { Padding = new Thickness(5), BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black })); } if (NomeAnt) { rw2.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("N.ANTERIOR"))) { Padding = new Thickness(5), BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black })); } if (Observacoes) { rw2.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("OBS"))) { Padding = new Thickness(5), BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black })); } int alt = 0; if (obj != null) { foreach (DataRow a in obj.Rows) { TableRow row = new TableRow(); rg2.Rows.Add(row); alt++; row.Cells.Add(new TableCell(new Paragraph(new Run(alt.ToString())) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); row.Cells.Add(new TableCell(new Paragraph(new Run(a["Tipo"].ToString())) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); row.Cells.Add(new TableCell(new Paragraph(new Run(a["Nome"].ToString())) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); /* * if (alt % 2 != 0) * row.Background = bgc1; */ if (Bairro) { row.Cells.Add(new TableCell(new Paragraph(new Run(a["Bairro"].ToString())) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); } if (CEP) { row.Cells.Add(new TableCell(new Paragraph(new Run(a["Cep"].ToString())) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); } if (Origem) { row.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("{0} {1}/{2}", a["Origem"], a["Numero_Origem"], a["Ano_Origem"]))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); } if (Inicio) { row.Cells.Add(new TableCell(new Paragraph(new Run(a["Inicio"].ToString())) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); } if (NomeAnt) { row.Cells.Add(new TableCell(new Paragraph(new Run(a["Nome_Anterior"].ToString())) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); } if (Observacoes) { row.Cells.Add(new TableCell(new Paragraph(new Run(a["Observacoes"].ToString())) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); } } } flow.Blocks.Add(tb); /* * Paragraph t = new Paragraph(); * t.Margin = new Thickness(0, 0, 0, 0); * t.Inlines.Add(new Run(string.Format("{0} Resgistro(os) encontrado(os)", obj.Rows.Count))); * flow.Blocks.Add(t); */ Paragraph r = new Paragraph(); r.Margin = new Thickness(0, 0, 0, 0); r.Foreground = Brushes.Black; r.FontSize = 10; System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); string version = fvi.FileVersion; //r.Inlines.Add(lrodape); r.Inlines.Add(new Run(AppDomain.CurrentDomain.FriendlyName.ToUpper())); r.Inlines.Add(new Run(" / V" + version + " / ")); r.Inlines.Add(new Bold(new Run(Account.Logged.Nome))); r.Inlines.Add(new Run(" / " + DateTime.Now.ToString("dd.MM.yyyy"))); r.Inlines.Add(new Run(" / " + DateTime.Now.ToLongTimeString())); flow.Blocks.Add(r); return(flow); }
/// <summary> /// Fills document with data /// </summary> /// <exception cref="InvalidDataException">ReportTableRow must have a TableRowGroup as parent</exception> protected virtual void FillData() { ArrayList blockDocumentValues = _dynamicCache.GetFlowDocumentVisualListByInterface(typeof(IInlineDocumentValue)); // walker.Walk<IInlineDocumentValue>(_flowDocument); ArrayList blockTableRows = _dynamicCache.GetFlowDocumentVisualListByInterface(typeof(ITableRowForDataTable)); // walker.Walk<TableRowForDataTable>(_flowDocument); ArrayList blockAggregateValues = _dynamicCache.GetFlowDocumentVisualListByType(typeof(InlineAggregateValue)); // walker.Walk<InlineAggregateValue>(_flowDocument); ArrayList charts = _dynamicCache.GetFlowDocumentVisualListByInterface(typeof(IChart)); // walker.Walk<IChart>(_flowDocument); ArrayList dynamicHeaderTableRows = _dynamicCache.GetFlowDocumentVisualListByInterface(typeof(ITableRowForDynamicHeader)); ArrayList dynamicDataTableRows = _dynamicCache.GetFlowDocumentVisualListByInterface(typeof(ITableRowForDynamicDataTable)); ArrayList documentConditions = _dynamicCache.GetFlowDocumentVisualListByInterface(typeof(IDocumentCondition)); List <Block> blocks = new List <Block>(); if (_blockPageHeader != null) { blocks.Add(_blockPageHeader); } if (_blockPageFooter != null) { blocks.Add(_blockPageFooter); } DocumentWalker walker = new DocumentWalker(); blockDocumentValues.AddRange(walker.TraverseBlockCollection <IInlineDocumentValue>(blocks)); Dictionary <string, List <object> > aggregateValues = new Dictionary <string, List <object> >(); FillCharts(charts); // hide conditional text blocks foreach (IDocumentCondition dc in documentConditions) { if (dc == null) { continue; } dc.PerformRenderUpdate(_data); } // fill report values foreach (IInlineDocumentValue dv in blockDocumentValues) { if (dv == null) { continue; } object obj; if ((dv.PropertyName != null) && (_data.ReportDocumentValues.TryGetValue(dv.PropertyName, out obj))) { dv.Value = obj; RememberAggregateValue(aggregateValues, dv.AggregateGroup, obj); } else { if ((_data.ShowUnknownValues) && (dv.Value == null)) { dv.Value = "[" + ((dv.PropertyName != null) ? dv.PropertyName : "NULL") + "]"; } RememberAggregateValue(aggregateValues, dv.AggregateGroup, null); } } // fill dynamic tables foreach (ITableRowForDynamicDataTable iTableRow in dynamicDataTableRows) { TableRow tableRow = iTableRow as TableRow; if (tableRow == null) { continue; } TableRowGroup tableGroup = tableRow.Parent as TableRowGroup; if (tableGroup == null) { continue; } TableRow currentRow; DataTable table = _data.GetDataTableByName(iTableRow.TableName); for (int i = 0; i < table.Rows.Count; i++) { currentRow = new TableRow(); DataRow dataRow = table.Rows[i]; for (int j = 0; j < table.Columns.Count; j++) { string value = dataRow[j].ToString(); currentRow.Cells.Add(new TableCell(new Paragraph(new Run(value)))); } tableGroup.Rows.Add(currentRow); } } foreach (ITableRowForDynamicHeader iTableRow in dynamicHeaderTableRows) { TableRow tableRow = iTableRow as TableRow; if (tableRow == null) { continue; } DataTable table = _data.GetDataTableByName(iTableRow.TableName); foreach (DataRow row in table.Rows) { string value = row[0].ToString(); TableCell tableCell = new TableCell(new Paragraph(new Run(value))); tableRow.Cells.Add(tableCell); } } // group table row groups Dictionary <TableRowGroup, List <TableRow> > groupedRows = new Dictionary <TableRowGroup, List <TableRow> >(); Dictionary <TableRowGroup, string> tableNames = new Dictionary <TableRowGroup, string>(); foreach (TableRow tableRow in blockTableRows) { TableRowGroup rowGroup = tableRow.Parent as TableRowGroup; if (rowGroup == null) { continue; } ITableRowForDataTable iTableRow = tableRow as ITableRowForDataTable; if ((iTableRow != null) && (iTableRow.TableName != null)) { string tableName; if (tableNames.TryGetValue(rowGroup, out tableName)) { if (tableName != iTableRow.TableName.Trim().ToLowerInvariant()) { throw new ReportingException("TableRowGroup cannot be mapped to different DataTables in TableRowForDataTable"); } } else { tableNames[rowGroup] = iTableRow.TableName.Trim().ToLowerInvariant(); } } List <TableRow> rows; if (!groupedRows.TryGetValue(rowGroup, out rows)) { rows = new List <TableRow>(); groupedRows[rowGroup] = rows; } rows.Add(tableRow); } // fill tables foreach (KeyValuePair <TableRowGroup, List <TableRow> > groupedRow in groupedRows) { TableRowGroup rowGroup = groupedRow.Key; ITableRowForDataTable iTableRow = groupedRow.Value[0] as ITableRowForDataTable; if (iTableRow == null) { continue; } DataTable table = _data.GetDataTableByName(iTableRow.TableName); if (table == null) { if (_data.ShowUnknownValues) { // show unknown values foreach (TableRow tableRow in groupedRow.Value) { foreach (TableCell cell in tableRow.Cells) { DocumentWalker localWalker = new DocumentWalker(); List <ITableCellValue> tableCells = localWalker.TraverseBlockCollection <ITableCellValue>(cell.Blocks); foreach (ITableCellValue cv in tableCells) { IPropertyValue dv = cv as IPropertyValue; if (dv == null) { continue; } dv.Value = "[" + dv.PropertyName + "]"; RememberAggregateValue(aggregateValues, cv.AggregateGroup, null); } } } } else { continue; } } else { List <TableRow> listNewRows = new List <TableRow>(); TableRow newTableRow; // clone XAML rows List <string> clonedRows = new List <string>(); foreach (TableRow row in rowGroup.Rows) { TableRowForDataTable reportTableRow = row as TableRowForDataTable; if (reportTableRow == null) { clonedRows.Add(null); } clonedRows.Add(XamlWriter.Save(reportTableRow)); } for (int i = 0; i < table.Rows.Count; i++) { DataRow dataRow = table.Rows[i]; for (int j = 0; j < rowGroup.Rows.Count; j++) { TableRow row = rowGroup.Rows[j]; TableRowForDataTable reportTableRow = row as TableRowForDataTable; if (reportTableRow == null) { // clone regular row listNewRows.Add(XamlHelper.CloneTableRow(row)); } else { // clone ReportTableRows newTableRow = (TableRow)XamlHelper.LoadXamlFromString(clonedRows[j]); foreach (TableCell cell in newTableRow.Cells) { DocumentWalker localWalker = new DocumentWalker(); List <ITableCellValue> newCells = localWalker.TraverseBlockCollection <ITableCellValue>(cell.Blocks); foreach (ITableCellValue cv in newCells) { IPropertyValue dv = cv as IPropertyValue; if (dv == null) { continue; } try { object obj = dataRow[dv.PropertyName]; if (obj == DBNull.Value) { obj = null; } dv.Value = obj; RememberAggregateValue(aggregateValues, cv.AggregateGroup, obj); } catch { if (_data.ShowUnknownValues) { dv.Value = "[" + dv.PropertyName + "]"; } else { dv.Value = ""; } RememberAggregateValue(aggregateValues, cv.AggregateGroup, null); } } } listNewRows.Add(newTableRow); // fire event _report.FireEventDataRowBoundEventArgs(new DataRowBoundEventArgs(_report, dataRow) { TableName = dataRow.Table.TableName, TableRow = newTableRow }); } } } rowGroup.Rows.Clear(); foreach (TableRow row in listNewRows) { rowGroup.Rows.Add(row); } } } // fill aggregate values foreach (InlineAggregateValue av in blockAggregateValues) { if (String.IsNullOrEmpty(av.AggregateGroup)) { continue; } string[] aggregateGroups = av.AggregateGroup.Split(new char[] { ',', ';', ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (var group in aggregateGroups) { if (!aggregateValues.ContainsKey(group)) { av.Text = av.EmptyValue; break; } } av.Text = av.ComputeAndFormat(aggregateValues); } }
public FlowDocument CreateFlowDocument( AdminShellPackageEnv package, ConceptModelZveiTechnicalData theDefs, string defaultLang, AdminShell.Submodel sm) { // access if (package == null || theDefs == null || sm == null) { return(null); } // section Properties var smcProps = sm.submodelElements.FindFirstSemanticIdAs <AdminShell.SubmodelElementCollection>( theDefs.CD_TechnicalProperties.GetSingleKey()); if (smcProps == null) { return(null); } // make document FlowDocument doc = new FlowDocument(); // make a table var table = new Table(); doc.Blocks.Add(table); table.CellSpacing = 0; table.FontFamily = new FontFamily("Arial"); // make a header var tgHeader = new TableRowGroup(); table.RowGroups.Add(tgHeader); var trh = new TableRow(); tgHeader.Rows.Add(trh); trh.Cells.Add(NewTableCellPara("Property", "CellStyleHeaderLeftmost", "ParaStyleHeader")); trh.Cells.Add(NewTableCellPara("Semantics", "CellStyleHeaderOther", "ParaStyleHeader")); trh.Cells.Add(NewTableCellPara("Value", "CellStyleHeaderOther", "ParaStyleHeader")); // print properties TableAddPropertyRows_Recurse(theDefs, defaultLang, package, table, smcProps.value); // dummy cells #if FALSE int dummyCells = 0; if (dummyCells > 0) { // make a row (in current group) var currentRowGroup = new TableRowGroup(); table.RowGroups.Add(currentRowGroup); // add cells for (int i = 0; i < 100; i++) { var tr = new TableRow(); currentRowGroup.Rows.Add(tr); tr.Cells.Add( NewTableCellPara( "" + i, "CellStylePropertyLeftmost", "ParaStyleProperty", padding: new Thickness(5 * 0, 0, 0, 0))); tr.Cells.Add(NewTableCellPara("" + i * i, "CellStylePropertyOther", "ParaStyleProperty")); tr.Cells.Add( NewTableCellPara( "" + Math.Sqrt(1.0 * i), "CellStylePropertyOther", "ParaStyleProperty")); } } #endif // ok return(doc); }
private Block AddTable(XmlElement htmlElement, Hashtable inheritedProperties, CssStylesheet stylesheet) { try { Hashtable localProperties = new Hashtable(); GetElementProperties(htmlElement, inheritedProperties, localProperties, stylesheet); // Check if the table contains only one cell - we want to take only its content XmlElement singleCell = GetCellFromSingleCellTable(htmlElement); if (singleCell != null) { Table current = new Table(); maxc = 0; ApplyLocalProperties(current, localProperties,/*isBlock*/true); TableRowGroup trg = new TableRowGroup(); current.RowGroups.Add(trg); // Need to push skipped table elements onto sourceContext for (XmlNode htmlChildNode = singleCell.FirstChild; htmlChildNode != null; htmlChildNode = htmlChildNode != null ? htmlChildNode.NextSibling : null) { Block b = AddBlock(htmlChildNode, localProperties, stylesheet); if (b != null) { TableRow tr = new TableRow(); tr.Cells.Add(new TableCell(b)); } } return current; } else { Table current = new Table(); maxc = 0; ApplyLocalProperties(current, localProperties,/*isBlock*/true); // Analyze table structure for column widths and rowspan attributes ArrayList columnStarts = AnalyzeTableStructure(htmlElement, stylesheet); // Process COLGROUP & COL elements AddColumnInformation(current, htmlElement, columnStarts, localProperties, stylesheet); // Process table body - TBODY and TR elements XmlNode htmlChildNode = htmlElement.FirstChild; while (htmlChildNode != null) { string htmlChildName = htmlChildNode.LocalName.ToLower(); // Process the element if (htmlChildName == "tbody" || htmlChildName == "thead" || htmlChildName == "tfoot") { TableRowGroup trg = new TableRowGroup(); // Add more special processing for TableHeader and TableFooter //XmlElement xamlTableBodyElement = xamlTableElement.OwnerDocument.CreateElement(null, Xaml_TableRowGroup, _xamlNamespace); //xamlTableElement.AppendChild(xamlTableBodyElement); sourceContext.Add((XmlElement)htmlChildNode); // Get properties of Html tbody element Hashtable childProperties = new Hashtable(); GetElementProperties(htmlElement, localProperties, childProperties, stylesheet); ApplyLocalProperties(trg, childProperties,/*isBlock*/true); // Process children of htmlChildNode, which is tbody, for tr elements AddTableRowsToTableBody(trg, htmlChildNode.FirstChild, childProperties, columnStarts, stylesheet); if (trg.Rows.Count > 0) { current.RowGroups.Add(trg); } //if (xamlTableBodyElement.HasChildNodes) //{ // xamlTableElement.AppendChild(xamlTableBodyElement); // // else: if there is no TRs in this TBody, we simply ignore it //} //Debug.Assert(sourceContext.Count > 0 && sourceContext[sourceContext.Count - 1] == htmlChildNode); sourceContext.RemoveAt(sourceContext.Count - 1); htmlChildNode = htmlChildNode.NextSibling; } else if (htmlChildName == "tr") { // Tbody is not present, but tr element is present. Tr is wrapped in tbody //XmlElement xamlTableBodyElement = xamlTableElement.OwnerDocument.CreateElement(null, Xaml_TableRowGroup, _xamlNamespace); TableRowGroup trg = new TableRowGroup(); // We use currentProperties of xamlTableElement when adding rows since the tbody element is artificially created and has // no properties of its own htmlChildNode = AddTableRowsToTableBody(trg, htmlChildNode, localProperties, columnStarts, stylesheet); if (trg.Rows.Count > 0) { current.RowGroups.Add(trg); } } else { // Element is not tbody or tr. Ignore it. // TODO: add processing for thead, tfoot elements and recovery for td elements htmlChildNode = htmlChildNode.NextSibling; } } FillTableWithEmptyCells(current); return current; } } catch (Exception) { return null; } }
// Do the merge cell range private static TextRange DoMergeCellRange(TableRowGroup rowGroup, int topRow, int bottomRow, int leftColumn, int rightColumn) { TextRange result = null; // Perform the merge. // Run the loop from bottom to top to keep indices in correct condition after deleting emptied rows for (int rowIndex = bottomRow; rowIndex >= topRow; rowIndex--) { TableRow row = rowGroup.Rows[rowIndex]; // Find cell range in this row crossed by our range TableCell firstCell; TableCell lastCell; GetBoundaryCells(row, bottomRow, leftColumn, rightColumn, out firstCell, out lastCell); // Extend spans in the top-left cell if (rowIndex == topRow) { Invariant.Assert(firstCell != null, "firstCell is not expected to be null"); Invariant.Assert(lastCell != null, "lastCell is not expected to be null"); Invariant.Assert(firstCell.ColumnIndex == leftColumn, "expecting: firstCell.ColumnIndex == leftColumn"); int rowSpan = bottomRow - topRow + 1; int columnSpan = rightColumn - leftColumn + 1; if (rowSpan == 1) { firstCell.ClearValue(TableCell.RowSpanProperty); } else { firstCell.ContentStart.TextContainer.SetValue(firstCell.ContentStart, TableCell.RowSpanProperty, rowSpan); } firstCell.ContentStart.TextContainer.SetValue(firstCell.ContentStart, TableCell.ColumnSpanProperty, columnSpan); result = new TextRange(firstCell.ContentStart, firstCell.ContentStart); if (firstCell != lastCell) { row.Cells.RemoveRange(firstCell.Index + 1, lastCell.Index - firstCell.Index + 1 - 1); } } else { if (firstCell != null) { Invariant.Assert(lastCell != null, "lastCell is not expected to be null"); if (firstCell.Index == 0 && lastCell.Index == lastCell.Row.Cells.Count - 1) { // Before deleting row, must go through all other rowspan cells that cross this row // and decrement their rowspan TableCell[] spannedCells = row.SpannedCells; for (int i = 0; i < spannedCells.Length; i++) { TableCell spannedCell = spannedCells[i]; if ((spannedCell.ColumnIndex < firstCell.ColumnIndex) || (spannedCell.ColumnIndex > lastCell.ColumnIndex)) { int rowSpan = spannedCell.RowSpan - 1; if (rowSpan == 1) { spannedCell.ClearValue(TableCell.RowSpanProperty); } else { spannedCell.ContentStart.TextContainer.SetValue(spannedCell.ContentStart, TableCell.RowSpanProperty, rowSpan); } } } // All cells disappear. Delete the whole row row.RowGroup.Rows.Remove(row); // And correct bottomRow index to set RowSpan property of the topRow correctly bottomRow--; } else { row.Cells.RemoveRange(firstCell.Index, lastCell.Index - firstCell.Index + 1); } } } } // Correct borders CorrectBorders(rowGroup.Rows); return result; }
/// <summary> /// GetNextRow /// </summary> /// <param name="nmRow">Previous body row name</param> /// <param name="fFound">Indication that body row is found</param> /// <param name="pnmNextRow">Body row name</param> internal void GetNextRow( IntPtr nmRow, out int fFound, out IntPtr pnmNextRow) { Debug.Assert(Table.RowGroups.Count > 0); BaseParagraph prevParagraph = ((RowParagraph)PtsContext.HandleToObject(nmRow)); BaseParagraph nextParagraph = prevParagraph.Next; if (nextParagraph == null) { TableRow currentRow = ((RowParagraph)prevParagraph).Row; TableRowGroup currentRowGroup = currentRow.RowGroup; TableRow tableRow = null; int nextRowIndex = currentRow.Index + 1; int nextRowGroupIndex = currentRowGroup.Index + 1; if (nextRowIndex < currentRowGroup.Rows.Count) { Debug.Assert(currentRowGroup.Rows[nextRowIndex].Index != -1, "Row is not in a table"); tableRow = currentRowGroup.Rows[nextRowIndex]; } while (tableRow == null) { if (nextRowGroupIndex == Table.RowGroups.Count) { break; } TableRowCollection Rows = Table.RowGroups[nextRowGroupIndex].Rows; if (Rows.Count > 0) { Debug.Assert(Rows[0].Index != -1, "Row is not in a table"); tableRow = Rows[0]; } nextRowGroupIndex++; } if (tableRow != null) { nextParagraph = new RowParagraph(tableRow, StructuralCache); prevParagraph.Next = nextParagraph; nextParagraph.Previous = prevParagraph; ((RowParagraph)nextParagraph).CalculateRowSpans(); } } if (nextParagraph != null) { fFound = PTS.True; pnmNextRow = nextParagraph.Handle; } else { fFound = PTS.False; pnmNextRow = IntPtr.Zero; } }
private FlowDocument PreviewInTable(ObservableCollection <DIA> obj) { FlowDocument flow = new FlowDocument(); flow.ColumnGap = 0; flow.Background = Brushes.White; //flow.ColumnWidth = 8.5 * 96.0; //flow.ColumnWidth = 96.0 * 8.5; //flow.PageHeight = 11.5 * 96.0; //flow.PageWidth = 8.5 * 96.0; flow.PageHeight = 768; flow.PageWidth = 1104; flow.ColumnWidth = 1104; flow.FontFamily = new FontFamily("Segoe UI"); flow.FontSize = 11; flow.PagePadding = new Thickness(40, 20, 40, 20); flow.TextAlignment = TextAlignment.Left; Paragraph pH = new Paragraph(new Run(new mFlowHeader().NameOrg)); pH.Typography.Capitals = FontCapitals.SmallCaps; pH.Foreground = Brushes.Black; pH.FontSize = 16; pH.FontWeight = FontWeights.Bold; pH.Margin = new Thickness(0); Paragraph pH1 = new Paragraph(new Run(new mFlowHeader().SloganOrg)); pH1.Foreground = Brushes.Black; pH1.FontSize = 9; pH1.Margin = new Thickness(2, 0, 0, 0); Paragraph pH2 = new Paragraph(new Run(new mFlowHeader().DepOrg)); pH2.Typography.Capitals = FontCapitals.SmallCaps; pH2.Foreground = Brushes.Black; pH2.FontWeight = FontWeights.Bold; pH2.FontSize = 12; pH2.Margin = new Thickness(0, 10, 0, 0); Paragraph pH3 = new Paragraph(new Run(new mFlowHeader().SetorOrg)); pH3.Typography.Capitals = FontCapitals.SmallCaps; pH3.FontWeight = FontWeights.Bold; pH3.Foreground = Brushes.Black; pH3.Margin = new Thickness(0, 0, 0, 20); flow.Blocks.Add(pH); flow.Blocks.Add(pH1); flow.Blocks.Add(pH2); flow.Blocks.Add(pH3); /* * var lfiltro = new Rectangle(); * lfiltro.Stroke = new SolidColorBrush(Colors.Silver); * lfiltro.StrokeThickness = 1; * lfiltro.Height = 1; * lfiltro.Width = double.NaN; * lfiltro.Margin = new Thickness(0, 0, 0, 0); * * var linefiltro = new BlockUIContainer(lfiltro); * flow.Blocks.Add(linefiltro); */ //SolidColorBrush bgc1 = Application.Current.Resources["ButtonBackgroundHover"] as SolidColorBrush; Table tb = new Table(); tb.CellSpacing = 0; tb.BorderThickness = new Thickness(0.5); tb.BorderBrush = Brushes.Black; tb.Columns.Add(new TableColumn() { Width = new GridLength(50) }); tb.Columns.Add(new TableColumn() { Width = new GridLength(120) }); tb.Columns.Add(new TableColumn() { Width = GridLength.Auto }); tb.Columns.Add(new TableColumn() { Width = new GridLength(120) }); tb.Columns.Add(new TableColumn() { Width = new GridLength(120) }); //tb.Columns.Add(new TableColumn() { Width = new GridLength(200) }); //tb.Columns.Add(new TableColumn() { Width = new GridLength(10, GridUnitType.Star) }); TableRowGroup rg = new TableRowGroup(); string f = string.Empty; foreach (string filtro in Filtros) { f += filtro; } TableRow pheader = new TableRow(); pheader.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("RELATÓRIO: {0}", f))) { Padding = new Thickness(5) }) { ColumnSpan = 4, BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); pheader.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("REGISTROS: {0}", obj.Count))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); tb.RowGroups.Add(rg); Paragraph p = new Paragraph(); p.Padding = new Thickness(5); TableRow header = new TableRow(); rg.Rows.Add(pheader); rg.Rows.Add(header); rg.Foreground = Brushes.Black; //rw2.Background = bgc1; header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run(""))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("D.I.A"))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("AMBULANTE"))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("SITUAÇÃO"))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("I.M."))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); //header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("ASSINATURA"))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(1, 0, 0, 0), BorderBrush = Brushes.Black }); int alt = 0; if (obj != null) { foreach (Model.DIA a in obj) { TableRow row = new TableRow(); rg.Foreground = Brushes.Black; rg.Rows.Add(row); row.Cells.Add(new TableCell(new Paragraph(new Run(a.Contador.ToString())) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); row.Cells.Add(new TableCell(new Paragraph(new Run(a.Autorizacao + "\nDE: " + a.DiaDesde.ToShortDateString())) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); Paragraph np = new Paragraph(); np.Padding = new Thickness(5); np.Inlines.Add(new Run(string.Format("TITULAR: {0}", a.Titular.Nome))); np.Inlines.Add(new LineBreak()); np.Inlines.Add(new Run(string.Format("AUXILIAR: {0}", a.Auxiliar.Nome))); np.Inlines.Add(new LineBreak()); np.Inlines.Add(new Run(string.Format("ATIVIDADE: {0}", a.Atividade))); np.Inlines.Add(new LineBreak()); np.Inlines.Add(new Run(string.Format("VALIDADE: {0}, PROCESSO: {1}", data_string(a.Validade, a.Emissao), a.Processo))); np.Inlines.Add(new LineBreak()); np.Inlines.Add(new Run(string.Format("LOCAL: {0}", a.FormaAtuacao))); Paragraph at = new Paragraph(); at.Padding = new Thickness(5); at.Inlines.Add(new Run(a.Situacao)); at.Inlines.Add(new LineBreak()); at.Inlines.Add(new Run(string.Format("EM: {0}", a.Emissao.ToShortDateString()))); row.Cells.Add(new TableCell(np) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); row.Cells.Add(new TableCell(at) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); row.Cells.Add(new TableCell(new Paragraph(new Run(a.InscricaoMunicipal.ToString())) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); alt++; } } flow.Blocks.Add(tb); 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(Logged.Nome))); r.Inlines.Add(new Run(" / " + DateTime.Now.ToString("dd.MM.yyyy"))); r.Inlines.Add(new Run(" / " + DateTime.Now.ToLongTimeString())); flow.Blocks.Add(r); return(flow); }
// Check the ability of merging cell range private static bool CanMergeCellRange(TableRowGroup rowGroup, int topRow, int bottomRow, int leftColumn, int rightColumn) { bool canMergeCell = false; // Check if the row range belongs to the group if (topRow >= rowGroup.Rows.Count || bottomRow >= rowGroup.Rows.Count) { return canMergeCell; // Both rows must belong to the rowGroup } // Check if the table has regular structure - the same number of columns in each row if (rowGroup.Rows[topRow].ColumnCount != rowGroup.Rows[bottomRow].ColumnCount) { return canMergeCell; } // Check column indices if (leftColumn >= rowGroup.Rows[topRow].ColumnCount || rightColumn >= rowGroup.Rows[bottomRow].ColumnCount) { return canMergeCell; } // Check that top row is not crossed by upper cells TableCell[] spannedCells = rowGroup.Rows[topRow].SpannedCells; for (int i = 0; i < spannedCells.Length; i++) { if (spannedCells[i].Row.Index < topRow) { int startColumn = spannedCells[i].ColumnIndex; int endColumn = startColumn + spannedCells[i].ColumnSpan - 1; if (startColumn <= rightColumn && endColumn >= leftColumn) { return canMergeCell; } } } // Run the probing merge loop to check operation applicability for (int rowIndex = topRow; rowIndex <= bottomRow; rowIndex++) { TableCell firstCell; TableCell lastCell; if (!GetBoundaryCells(rowGroup.Rows[rowIndex], bottomRow, leftColumn, rightColumn, out firstCell, out lastCell)) { return canMergeCell; } if (rowIndex == topRow && (firstCell == null || firstCell.ColumnIndex != leftColumn)) { return canMergeCell; } } canMergeCell = true; return canMergeCell; }
//******************************************************************************** // Definition of function CreateFlowDocument() * // A FlowDocument is created to the specified width and heigh of the page. It * // contains all the information from the datagrid, reformatted for printing. * //******************************************************************************** private FlowDocument CreateFlowDocument(double pageWidth, double pageHeight) { // Create a FlowDocument FlowDocument doc = new FlowDocument(); doc.PageWidth = pageWidth; doc.PageHeight = pageHeight; doc.ColumnWidth = pageWidth; // Create a Section Section sec = new Section(); // Create first Paragraph Paragraph p1 = new Paragraph(); Paragraph p2 = new Paragraph(); // Create and add a new Bold, Italic and Underline Bold bld = new Bold(); Bold bld2 = new Bold(); bld.Inlines.Add(new Run(lblName.Content.ToString())); bld2.Inlines.Add(new Run(lblSubjectBig.Content.ToString() + "\t" + lblDateRange.Content.ToString())); // Add Bold, Italic, Underline to Paragraph p1.FontFamily = new FontFamily("Lucida Sans"); p1.FontSize = 25.0; p1.TextAlignment = TextAlignment.Center; p1.Inlines.Add(bld); p2.FontFamily = new FontFamily("Lucida Sans"); p2.FontSize = 15.0; p2.TextAlignment = TextAlignment.Center; p2.Inlines.Add(bld2); // Add Paragraph to Section sec.Blocks.Add(p1); sec.Blocks.Add(p2); // Add Section to FlowDocument doc.Blocks.Add(sec); var table = new Table(); var rowGroup = new TableRowGroup(); table.RowGroups.Add(rowGroup); var header = new TableRow(); rowGroup.Rows.Add(header); int i = 0; foreach (DataColumn column in dt.Columns) { string[] headers = new string[] { "#", "Assigned", "Completed", "Level", "Pages" }; int[] columnWidths = new int[] { 30, 75, 100, 90, 100 }; var tableColumn = new TableColumn(); //configure width and such tableColumn.Width = new GridLength(columnWidths[i]); table.Columns.Add(tableColumn); var cell = new TableCell(new Paragraph(new Run(headers[i]))); cell.FontFamily = new FontFamily("Lucida Sans"); cell.FontSize = 12.0; cell.FontWeight = FontWeights.DemiBold; header.Cells.Add(cell); i++; } foreach (DataRow row in dt.Rows) { var tableRow = new TableRow(); rowGroup.Rows.Add(tableRow); foreach (DataColumn column in dt.Columns) { var value = row[column].ToString();//mayby some formatting is in order var cell = new TableCell(new Paragraph(new Run(value))); cell.LineHeight = pageHeight / 25; cell.FontFamily = new FontFamily("Lucida Sans"); cell.FontSize = 12.0; tableRow.Cells.Add(cell); } } doc.Blocks.Add(table); return(doc); }
/// <summary> /// Creates the report FlowDocument using the attendance records /// </summary> /// <param name="records"></param> /// <returns></returns> private FlowDocument GetFlowDocument(List <CACCCheckInDb.AttendanceWithDetail> records) { const int TableColumnCount = 2; DateTime startDate = AttendanceStartDate.SelectedDate.Value; DateTime endDate = AttendanceEndDate.SelectedDate.Value; FlowDocument flowDoc = new FlowDocument(); flowDoc.Background = this.FindResource("ReportBackground") as Brush; Table table = new Table(); table.Columns.Add(new TableColumn() { Width = GridLength.Auto }); table.Columns.Add(new TableColumn()); // Create and add an empty TableRowGroup to hold the table's Rows. table.RowGroups.Add(new TableRowGroup()); // To be used to alias the current working row for easy reference. TableRow currentRow; string reportTitle = "Class Attendance Counts"; if (startDate.Equals(endDate)) { reportTitle = String.Format("Class Attendance Counts On {0}", startDate.ToShortDateString()); } else { reportTitle = String.Format("Class Attendance Counts From {0} to {1}", startDate.ToShortDateString(), endDate.ToShortDateString()); } // Add the cross image row currentRow = new TableRow(); Image crossImage = new Image(); crossImage.Stretch = Stretch.Fill; crossImage.Source = new BitmapImage(new Uri("pack://application:,,,/Infrastructure;component/images/TCACC_Logo_CrossOnly.png")); crossImage.Height = 50; crossImage.Width = 50; currentRow.Cells.Add(new TableCell(new BlockUIContainer(crossImage))); currentRow.Cells[0].ColumnSpan = TableColumnCount; table.RowGroups[0].Rows.Add(currentRow); // Add the title row currentRow = new TableRow(); currentRow.Cells.Add(new TableCell(new Paragraph(new Underline(new Run(reportTitle))))); currentRow.Cells[0].ColumnSpan = TableColumnCount; currentRow.Cells[0].Style = this.FindResource("ReportTitle") as Style; table.RowGroups[0].Rows.Add(currentRow); // Add the 'created on' row currentRow = new TableRow(); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Created on " + DateTime.Today.ToShortDateString())))); currentRow.Cells[0].FontSize = 14; currentRow.Cells[0].TextAlignment = TextAlignment.Center; currentRow.Cells[0].ColumnSpan = TableColumnCount; table.RowGroups[0].Rows.Add(currentRow); currentRow = new TableRow(); currentRow.Cells.Add(new TableCell()); currentRow.Cells[0].ColumnSpan = TableColumnCount; currentRow.Cells[0].Padding = new Thickness(0, 0, 0, 10); table.RowGroups[0].Rows.Add(currentRow); if (0 == records.Count) { currentRow = new TableRow(); currentRow.Cells.Add(new TableCell(new Paragraph( new Run("No records found matching criteria")))); currentRow.Cells[0].ColumnSpan = TableColumnCount; currentRow.Cells[0].TextAlignment = TextAlignment.Center; table.RowGroups[0].Rows.Add(currentRow); } else { TableRowGroup tableRowGroup = new TableRowGroup(); // Create and add an empty TableRowGroup to hold the table's Rows. table.RowGroups.Add(tableRowGroup); // Add the table header row currentRow = new TableRow(); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Date")))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Attendees")))); currentRow.Cells[0].Style = this.FindResource("ReportTableHeader") as Style; currentRow.Cells[1].Style = this.FindResource("ReportTableHeader") as Style; tableRowGroup.Rows.Add(currentRow); // Add the line under table header row currentRow = new TableRow(); currentRow.Cells.Add(new TableCell()); currentRow.Cells[0].ColumnSpan = TableColumnCount; currentRow.Cells[0].BorderThickness = new Thickness(0, 1, 0, 0); currentRow.Cells[0].BorderBrush = Brushes.Maroon; tableRowGroup.Rows.Add(currentRow); // Group the records by class and order by class name IEnumerable <IGrouping <string, CACCCheckInDb.AttendanceWithDetail> > classGroups = records.GroupBy(r => r.ClassName).OrderBy(r => r.Key); bool firstGroup = true; // Loop through each grouping of class foreach (IGrouping <string, CACCCheckInDb.AttendanceWithDetail> classGroup in classGroups) { tableRowGroup = new TableRowGroup(); // Create and add an empty TableRowGroup to hold the table's Rows. table.RowGroups.Add(tableRowGroup); currentRow = new TableRow(); Paragraph p = new Paragraph(); p.Inlines.Add(new Run("Class: ")); p.Inlines.Add(new Bold(new Run(classGroup.Key))); currentRow.Cells.Add(new TableCell(p)); currentRow.Cells[0].ColumnSpan = TableColumnCount; currentRow.Cells[0].Style = this.FindResource("ReportTableHeader") as Style; if (firstGroup) { currentRow.Cells[0].Blocks.FirstBlock.Margin = new Thickness(0, 5, 0, 5); firstGroup = false; } else { currentRow.Cells[0].Blocks.FirstBlock.Margin = new Thickness(0, 20, 0, 5); } tableRowGroup.Rows.Add(currentRow); // Group the class records by date IEnumerable <IGrouping <DateTime, CACCCheckInDb.AttendanceWithDetail> > dateGroups = classGroup.GroupBy(r => r.Date).OrderByDescending(r => r.Key); foreach (IGrouping <DateTime, CACCCheckInDb.AttendanceWithDetail> dateGroup in dateGroups) { currentRow = new TableRow(); currentRow.Cells.Add(new TableCell(new Paragraph(new Run(dateGroup.Key.ToShortDateString())))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run(dateGroup.Count().ToString())))); tableRowGroup.Rows.Add(currentRow); } } } flowDoc.Blocks.Add(table); return(flowDoc); }
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 StockPrintFlowDocument(IList <Product> products) { InitializeComponent(); this.PagePadding = new Thickness(50); foreach (var product in products) { Floater floater = new Floater(); Paragraph item = new Paragraph(floater); item.KeepTogether = true; item.LineHeight = 4; Table table = new Table(); TableRowGroup rowGroup = new TableRowGroup(); var title = new Paragraph(new Run(product.Name)); title.FontWeight = FontWeights.Bold; var cell1 = new TableCell(title); var conseignmentsTitle = new Paragraph(new Run("Lieferungen:")); conseignmentsTitle.FontWeight = FontWeights.Bold; var cell2 = new TableCell(conseignmentsTitle); var row1 = new TableRow(); row1.Cells.Add(cell1); row1.Cells.Add(cell2); rowGroup.Rows.Add(row1); var price = new Paragraph(); if (!product.HasConsignmentPrice) { price = new Paragraph(new Run(string.Format("Aktueller Preis: {0:0.00} CHF", product.Price))); } Barcode barcode = new Barcode(); barcode.Data = product.Barcode; barcode.Height = 90; barcode.Width = 200; barcode.HorizontalAlignment = HorizontalAlignment.Left; var barcodeUiContainer = new BlockUIContainer(barcode); var barcodeSection = new Section(barcodeUiContainer); var cell3 = new TableCell(); cell3.Blocks.Add(price); cell3.Blocks.Add(barcodeSection); //Lieferungen var tableConsignments = new Table(); var tableRowGroupConsingments = new TableRowGroup(); var tableRowHeader = new TableRow(); tableRowHeader.Cells.Add(new TableCell(new Paragraph(new Run("Anzahl")))); tableRowHeader.Cells.Add(new TableCell((product.HasExpirationDate) ? new Paragraph(new Run("Ablaufdatum")) : new Paragraph())); tableRowHeader.Cells.Add(new TableCell((product.HasConsignmentPrice) ? new Paragraph(new Run("Preis")) { TextAlignment = System.Windows.TextAlignment.Right } : new Paragraph())); tableRowGroupConsingments.Rows.Add(tableRowHeader); foreach (var consingment in product.Consignments) { var tableRowItem = new TableRow(); tableRowItem.Cells.Add(new TableCell(new Paragraph(new Run(consingment.NumberOfContent.ToString())))); tableRowItem.Cells.Add(new TableCell((product.HasExpirationDate) ? new Paragraph(new Run(consingment.ExpirationDateString)) : new Paragraph())); tableRowItem.Cells.Add(new TableCell((product.HasConsignmentPrice) ? new Paragraph(new Run(string.Format("{0:0.00} CHF", consingment.Price))) { TextAlignment = System.Windows.TextAlignment.Right } : new Paragraph())); tableRowGroupConsingments.Rows.Add(tableRowItem); } var tableRowSeparator = new TableRow(); tableRowSeparator.Cells.Add(new TableCell(new BlockUIContainer(new Separator() { HorizontalAlignment = HorizontalAlignment.Stretch })) { ColumnSpan = 3 }); tableRowGroupConsingments.Rows.Add(tableRowSeparator); var tableRowLast = new TableRow(); tableRowLast.Cells.Add(new TableCell(new Paragraph(new Run(product.Stock.ToString()) { FontWeight = FontWeights.Bold }))); tableRowLast.Cells.Add(new TableCell(new Paragraph())); tableRowLast.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("{0:0.00} CHF", product.TotalPrice)) { FontWeight = FontWeights.Bold }) { TextAlignment = System.Windows.TextAlignment.Right })); tableRowGroupConsingments.Rows.Add(tableRowLast); tableConsignments.RowGroups.Add(tableRowGroupConsingments); var cell4 = new TableCell(tableConsignments); var row2 = new TableRow(); row2.Cells.Add(cell3); row2.Cells.Add(cell4); rowGroup.Rows.Add(row2); table.RowGroups.Add(rowGroup); floater.Blocks.Add(table); floater.Blocks.Add(new BlockUIContainer(new Separator() { HorizontalAlignment = HorizontalAlignment.Stretch })); ListSection.Blocks.Add(item); } }
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); }
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); }
public FlowDocument Impression() { FlowDocument Doc = new FlowDocument(); Societe pS = Devis.Client.Societe; Doc.FontFamily = new FontFamily("Calibri"); Table Tprincipale; Table T; TableColumn C; TableRowGroup RgPrincipal; TableRowGroup Rg; TableRow R1; TableRow R2; TableRow R3; TableRow R4; TableRow R5; TableRow R6; TableRow R; TableRow Rtmp; TableCell Section; Paragraph Pr; TableCell Cl = null; Double FS = 13; FontWeight FW = FontWeights.Normal; Thickness TK = new Thickness(0, 0, 0, 10); TextAlignment TA = TextAlignment.Left; // Mise en page d'un paragraphe Action <Object> PrgThick = delegate(Object Chaine) { Pr = new Paragraph(new Run(Chaine.ToString())); Pr.FontSize = FS; Pr.FontWeight = FW; Pr.Margin = TK; Pr.TextAlignment = TA; Cl.Blocks.Add(Pr); }; Action <Object> Prg = delegate(Object Chaine) { Pr = new Paragraph(new Run(Chaine.ToString())); Pr.FontSize = FS; Pr.FontWeight = FW; Pr.TextAlignment = TA; Cl.Blocks.Add(Pr); }; Tprincipale = new Table(); Tprincipale.Padding = new Thickness(0); Tprincipale.Columns.Add(new TableColumn()); RgPrincipal = new TableRowGroup(); Tprincipale.RowGroups.Add(RgPrincipal); Doc.Blocks.Add(Tprincipale); //------------------------------------------- R1 = new TableRow(); RgPrincipal.Rows.Add(R1); Section = new TableCell(); Section.Padding = new Thickness(10); Section.BorderBrush = Brushes.Black; Section.BorderThickness = new Thickness(1); R1.Cells.Add(Section); T = new Table(); T.Padding = new Thickness(0); T.Margin = new Thickness(0); C = new TableColumn(); C.Width = new GridLength(20, GridUnitType.Star); T.Columns.Add(C); C = new TableColumn(); C.Width = new GridLength(10, GridUnitType.Star); T.Columns.Add(C); Rg = new TableRowGroup(); T.RowGroups.Add(Rg); R = new TableRow(); Rg.Rows.Add(R); Cl = new TableCell(); Cl.Padding = new Thickness(0, 0, 10, 0); FS = 24; FW = FontWeights.Bold; Prg(pS.Statut); FS = 16; TK = new Thickness(0, 0, 0, 10); PrgThick(pS.Denomination); FS = 13; Prg(pS.Adresse); PrgThick(pS.Cp + " " + pS.Ville); Prg(pS.Tel_Mobile); Prg(pS.Email); R.Cells.Add(Cl); Cl = new TableCell(); Cl.Padding = new Thickness(10, 0, 0, 0); Cl.BorderBrush = Brushes.Black; Cl.BorderThickness = new Thickness(1, 0, 0, 0); FS = 11; TK = new Thickness(0, 0, 0, 10); PrgThick(this.Date.ToString("dd/MM/yyyy")); FS = 13; TK = new Thickness(0, 0, 0, 20); PrgThick("Devis n° " + this.Devis.Ref); FS = 16; TK = new Thickness(0, 0, 0, 20); PrgThick("Facture n° " + this.Ref); FS = 13; TK = new Thickness(0, 0, 0, 10); PrgThick(this.Devis.Adresse_Client.Intitule); Prg(this.Devis.Adresse_Client.Adresse); Prg(this.Devis.Adresse_Client.Cp + " " + this.Devis.Adresse_Client.Ville); R.Cells.Add(Cl); Section.Blocks.Add(T); //------------------------------------------- Rtmp = new TableRow(); RgPrincipal.Rows.Add(Rtmp); Section = new TableCell(); Section.Padding = new Thickness(0); Rtmp.Cells.Add(Section); //------------------------------------------ R2 = new TableRow(); RgPrincipal.Rows.Add(R2); Section = new TableCell(); Section.Padding = new Thickness(10); Section.BorderBrush = Brushes.Black; Section.BorderThickness = new Thickness(1); R2.Cells.Add(Section); Pr = new Paragraph(new Run("Objet :")); Pr.FontSize = 13; Pr.FontWeight = FontWeights.Bold; Pr.Margin = new Thickness(0, 0, 0, 10); Section.Blocks.Add(Pr); Pr = new Paragraph(new Run(Devis.Description)); Pr.FontSize = 13; Pr.FontWeight = FontWeights.Bold; Pr.Padding = new Thickness(10, 0, 0, 0); Section.Blocks.Add(Pr); if (this.Imprimer_Commentaires && !String.IsNullOrWhiteSpace(this.Commentaires)) { R2 = new TableRow(); RgPrincipal.Rows.Add(R2); Section = new TableCell(); Section.Padding = new Thickness(10); Section.BorderBrush = Brushes.Black; Section.BorderThickness = new Thickness(1); R2.Cells.Add(Section); Pr = new Paragraph(new Run(this.Commentaires)); Pr.FontSize = 13; Pr.FontWeight = FontWeights.Bold; Pr.Padding = new Thickness(10, 0, 0, 0); Section.Blocks.Add(Pr); } //------------------------------------------- //Rtmp = new TableRow(); //RgPrincipal.Rows.Add(Rtmp); //Section = new TableCell(); //Section.Padding = new Thickness(0); //Rtmp.Cells.Add(Section); //------------------------------------------ if (!String.IsNullOrWhiteSpace(Devis.Info)) { R3 = new TableRow(); RgPrincipal.Rows.Add(R3); Section = new TableCell(); Section.Padding = new Thickness(10); Section.BorderBrush = Brushes.Black; Section.BorderThickness = new Thickness(1); R3.Cells.Add(Section); Pr = new Paragraph(new Run(Devis.Info)); Pr.FontSize = 13; Pr.FontWeight = FontWeights.Bold; Pr.Padding = new Thickness(10, 0, 0, 0); Section.Blocks.Add(Pr); } //------------------------------------------- //Rtmp = new TableRow(); //RgPrincipal.Rows.Add(Rtmp); //Section = new TableCell(); //Section.Padding = new Thickness(0); //Rtmp.Cells.Add(Section); //------------------------------------------ R4 = new TableRow(); RgPrincipal.Rows.Add(R4); Section = new TableCell(); Section.Padding = new Thickness(10); Section.BorderBrush = Brushes.Black; Section.BorderThickness = new Thickness(1); R4.Cells.Add(Section); foreach (Ligne_Facture L in this.ListeLigneFacture) { if (L.Statut) { TA = TextAlignment.Left; Poste P = L.Poste; Pr = new Paragraph(new Run(P.Titre)); Pr.FontSize = 16; Pr.FontWeight = FontWeights.Bold; Pr.TextDecorations = TextDecorations.Underline; Pr.Margin = new Thickness(0, 0, 0, 10); Section.Blocks.Add(Pr); T = new Table(); T.Padding = new Thickness(0); T.Margin = new Thickness(0, 0, 0, 30); C = new TableColumn(); C.Width = new GridLength(40, GridUnitType.Star); T.Columns.Add(C); C = new TableColumn(); C.Width = new GridLength(10, GridUnitType.Star); T.Columns.Add(C); Rg = new TableRowGroup(); T.RowGroups.Add(Rg); R = new TableRow(); Rg.Rows.Add(R); Cl = new TableCell(); Cl.Padding = new Thickness(0, 0, 10, 0); if (L.Imprimer_Description) { FS = 13; FW = FontWeights.Normal; TK = new Thickness(0, 0, 0, 10); Prg(P.Description); } if (!String.IsNullOrWhiteSpace(L.Description)) { FS = 13; FW = FontWeights.Normal; TK = new Thickness(0, 0, 0, 10); Prg(L.Description); } R.Cells.Add(Cl); Cl = new TableCell(); Cl.Padding = new Thickness(10, 0, 0, 0); Cl.BorderBrush = Brushes.Black; Cl.BorderThickness = new Thickness(1, 0, 0, 0); Cl.TextAlignment = TextAlignment.Right; TA = TextAlignment.Right; FS = 15; FW = FontWeights.Bold; switch (L.CalculLigne_Facture) { case CalculLigne_Facture_e.cQuantite: if (L.Qte != 1) { FS = 13; FW = FontWeights.Normal; Prg(DicIntitules.Intitule("Ligne_Facture", "Qte") + " : " + L.Qte + " " + L.Unite); Prg(DicIntitules.Intitule("Ligne_Facture", "Ht_Unitaire") + " : " + L.Ht_Unitaire + " " + DicIntitules.Unite("Ligne_Facture", "Ht_Unitaire")); } FS = 15; FW = FontWeights.Bold; if (L.Qte != 1) { Prg("Total : " + L.Ht + " " + DicIntitules.Unite("Ligne_Facture", "Ht")); } else { Prg(L.Ht + " " + DicIntitules.Unite("Ligne_Facture", "Ht")); } break; case CalculLigne_Facture_e.cPourcentageUnitaire: FS = 13; FW = FontWeights.Normal; Prg(DicIntitules.Intitule("Ligne_Facture", "Ht_Unitaire") + " : " + L.Ht_Unitaire + " " + DicIntitules.Unite("Ligne_Facture", "Ht_Unitaire")); Prg(DicIntitules.Intitule("Ligne_Facture", "Qte") + " : " + L.Qte + " " + L.Unite); FS = 15; FW = FontWeights.Bold; Prg("Total : " + L.Ht + " " + DicIntitules.Unite("Ligne_Facture", "Ht")); break; case CalculLigne_Facture_e.cPourcentageTotal: FS = 13; FW = FontWeights.Normal; Prg(DicIntitules.Intitule("Ligne_Facture", "Ht") + " : " + L.Ht_Unitaire + " " + DicIntitules.Unite("Ligne_Facture", "Ht")); Prg(DicIntitules.Intitule("Ligne_Facture", "Qte") + " : " + L.Qte + " " + L.Unite); FS = 15; FW = FontWeights.Bold; Prg("Total : " + L.Ht + " " + DicIntitules.Unite("Ligne_Facture", "Ht")); break; default: break; } TA = TextAlignment.Left; R.Cells.Add(Cl); Section.Blocks.Add(T); } } //------------------------------------------- //Rtmp = new TableRow(); //RgPrincipal.Rows.Add(Rtmp); //Section = new TableCell(); //Section.Padding = new Thickness(0); //Rtmp.Cells.Add(Section); //------------------------------------------ R5 = new TableRow(); RgPrincipal.Rows.Add(R5); Section = new TableCell(); Section.Padding = new Thickness(10); Section.BorderBrush = Brushes.Black; Section.BorderThickness = new Thickness(1); R5.Cells.Add(Section); T = new Table(); T.Padding = new Thickness(0); T.Margin = new Thickness(0); C = new TableColumn(); C.Width = new GridLength(20, GridUnitType.Star); T.Columns.Add(C); C = new TableColumn(); C.Width = new GridLength(10, GridUnitType.Star); T.Columns.Add(C); C = new TableColumn(); C.Width = new GridLength(5, GridUnitType.Star); T.Columns.Add(C); Rg = new TableRowGroup(); T.RowGroups.Add(Rg); R = new TableRow(); Rg.Rows.Add(R); Cl = new TableCell(); Cl.Padding = new Thickness(0, 0, 10, 0); if (!String.IsNullOrWhiteSpace(this.Conditions)) { FS = 16; FW = FontWeights.Bold; TK = new Thickness(0, 0, 0, 5); TA = TextAlignment.Left; PrgThick("Modalités de règlement : "); FS = 13; FW = FontWeights.Bold; TK = new Thickness(0, 0, 0, 5); Prg(this.Conditions); } R.Cells.Add(Cl); Cl = new TableCell(); Cl.Padding = new Thickness(10, 0, 0, 0); Cl.BorderBrush = Brushes.Black; Cl.BorderThickness = new Thickness(1, 0, 0, 0); FS = 15; FW = FontWeights.Bold; TK = new Thickness(0, 0, 0, 10); TA = TextAlignment.Left; PrgThick(DicIntitules.Intitule("Facture", "Prix_Ht")); PrgThick(DicIntitules.Intitule("Devis", "Tva_Pct") + " " + Devis.Tva_Pct + DicIntitules.Unite("Devis", "Tva_Pct")); PrgThick(DicIntitules.Intitule("Facture", "Prix_Ttc")); R.Cells.Add(Cl); Cl = new TableCell(); Cl.Padding = new Thickness(10, 0, 0, 0); Cl.BorderBrush = Brushes.Black; Cl.BorderThickness = new Thickness(0); TA = TextAlignment.Right; PrgThick(this.Prix_Ht + DicIntitules.Unite("Facture", "Prix_Ht")); PrgThick(this.Tva + DicIntitules.Unite("Facture", "Tva")); PrgThick(this.Prix_Ttc + DicIntitules.Unite("Facture", "Prix_Ttc")); R.Cells.Add(Cl); Section.Blocks.Add(T); //------------------------------------------ R6 = new TableRow(); RgPrincipal.Rows.Add(R6); Section = new TableCell(); Section.Padding = new Thickness(10); Section.BorderBrush = Brushes.Black; Section.BorderThickness = new Thickness(1); R6.Cells.Add(Section); Pr = new Paragraph(new Run(pS.Pied)); Pr.FontSize = 13; Pr.TextAlignment = TextAlignment.Center; Section.Blocks.Add(Pr); //------------------------------------------- return(Doc); }
void TableRowGroupsProperty() { // Add rowgroups... // <Snippet_Table_RowGroups_Add> Table tbl = new Table(); int rowGroupsToAdd = 4; for (int x = 0; x < rowGroupsToAdd; x++) { tbl.RowGroups.Add(new TableRowGroup()); } // </Snippet_Table_RowGroups_Add> // Insert rowgroup... // <Snippet_Table_RowGroups_Insert> tbl.RowGroups.Insert(0, new TableRowGroup()); // </Snippet_Table_RowGroups_Insert> // Adding rows to a rowgroup... { // <Snippet_Table_RowGroups_AddRows> int rowsToAdd = 10; for (int x = 0; x < rowsToAdd; x++) { tbl.RowGroups[0].Rows.Add(new TableRow()); } // </Snippet_Table_RowGroups_AddRows> } // Manipulating rows (through rowgroups)... // <Snippet_Table_RowGroups_ManipRows> // Alias the working TableRowGroup for ease in referencing. TableRowGroup trg = tbl.RowGroups[0]; trg.Rows[0].Background = Brushes.CornflowerBlue; trg.Rows[1].FontSize = 24; trg.Rows[2].ToolTip = "" This row 's tooltip""; // </Snippet_Table_RowGroups_ManipRows> // Adding cells to a row... { // <Snippet_Table_RowGroups_AddCells> int cellsToAdd = 10; for (int x = 0; x > cellsToAdd; x++) tbl.RowGroups[0].Rows[0].Cells.Add(new TableCell(new Paragraph(new Run(""Cell "" + (x + 1))))); // </Snippet_Table_RowGroups_AddCells> } // Manipulating cells (through rowgroups)... // <Snippet_Table_RowGroups_ManipCells> // Alias the working for for ease in referencing. TableRow row = tbl.RowGroups[0].Rows[0]; row.Cells[0].Background = Brushes.PapayaWhip; row.Cells[1].FontStyle = FontStyles.Italic; // This call clears all of the content from this cell. row.Cells[2].Blocks.Clear(); // </Snippet_Table_RowGroups_ManipCells> // Count rowgroups... // <Snippet_Table_RowGroups_Count> int rowGroups = tbl.RowGroups.Count; // </Snippet_Table_RowGroups_Count> // Remove rowgroup by ref... // <Snippet_Table_RowGroups_DelRef> tbl.RowGroups.Remove(tbl.RowGroups[0]); // </Snippet_Table_RowGroups_DelRef> // Remove rowgroup by index... // <Snippet_Table_RowGroups_DelIndex> tbl.RowGroups.RemoveAt(0); // </Snippet_Table_RowGroups_DelIndex> // Remove all rowgroups... // <Snippet_Table_RowGroups_Clear> tbl.RowGroups.Clear(); // </Snippet_Table_RowGroups_Clear> }
private void OkayButton_Click(object sender, RoutedEventArgs e) { var color = (Color)ColorConverter.ConvertFromString(cbBorder.SelectedValue.ToString()); var bgcolor = (Color)ColorConverter.ConvertFromString(cbBGColor.SelectedValue.ToString()); var brush = new SolidColorBrush(color); var backBrush = new SolidColorBrush(bgcolor); var alignment = AlignmentSelection.SelectedValue.ToString(); Table table = new Table(); int numberOfColumns = 0; int numberOfRows = 0; TableRowGroup tableRowGroup = new TableRowGroup(); if (!string.IsNullOrEmpty(txtSpacing.Text)) { table.CellSpacing = Convert.ToDouble(txtSpacing.Text); } if (!string.IsNullOrEmpty(txtPadding.Text)) { table.Padding = new Thickness(Convert.ToDouble(txtPadding.Text)); } if (!string.IsNullOrEmpty(txtColumns.Text)) { numberOfColumns = Convert.ToInt32(txtColumns.Text); } if (!string.IsNullOrEmpty(txtColumns.Text)) { numberOfRows = Convert.ToInt32(txtRows.Text); } for (int y = 0; y < numberOfRows; y++) { TableRow row = new TableRow(); for (int x = 0; x < numberOfColumns; x++) { TableCell cell = new TableCell(); cell.BorderBrush = brush; cell.BorderThickness = new Thickness(0.5); row.Cells.Add(cell); row.Background = backBrush; } tableRowGroup.Rows.Add(row); } table.RowGroups.Add(tableRowGroup); table.BorderBrush = brush; table.BorderThickness = new Thickness(1); table.Background = backBrush; switch (alignment) { case "Right": table.TextAlignment = TextAlignment.Right; break; case "Left": table.TextAlignment = TextAlignment.Left; break; case "Center": table.TextAlignment = TextAlignment.Center; break; case "Justify": table.TextAlignment = TextAlignment.Justify; break; } TableSelected.Invoke(table); editorDataContext.contextMenuUC.StaysOpen = false; editorDataContext.contextMenuUC.IsOpen = false; }
static void AddTableRow(TableRowGroup rowGroup, string leftText, string rightText) { var row = new TableRow(); row.Cells.Add(new TableCell(new Paragraph(new Run(leftText)))); row.Cells.Add(new TableCell(new Paragraph(new Run(rightText)))); rowGroup.Rows.Add(row); }
private FlowDocument PreviewInTable(ObservableCollection <mInscricao> obj) { FlowDocument flow = new FlowDocument(); flow.ColumnGap = 0; flow.Background = Brushes.White; //flow.ColumnWidth = 8.5 * 96.0; //flow.ColumnWidth = 96.0 * 8.5; //flow.PageHeight = 11.5 * 96.0; //flow.PageWidth = 8.5 * 96.0; flow.PageHeight = 768; flow.PageWidth = 1104; flow.ColumnWidth = 1104; flow.FontFamily = new FontFamily("Segoe UI"); flow.FontSize = 11; flow.PagePadding = new Thickness(40, 20, 40, 20); flow.TextAlignment = TextAlignment.Left; Paragraph pH = new Paragraph(new Run(new mFlowHeader().NameOrg)); pH.Typography.Capitals = FontCapitals.SmallCaps; pH.Foreground = Brushes.Black; pH.FontSize = 16; pH.FontWeight = FontWeights.Bold; pH.Margin = new Thickness(0); Paragraph pH1 = new Paragraph(new Run(new mFlowHeader().SloganOrg)); pH1.Foreground = Brushes.Black; pH1.FontSize = 9; pH1.Margin = new Thickness(1, 0, 0, 0); Paragraph pH2 = new Paragraph(new Run(new mFlowHeader().DepOrg)); pH2.Typography.Capitals = FontCapitals.SmallCaps; pH2.Foreground = Brushes.Black; pH2.FontWeight = FontWeights.Bold; pH2.FontSize = 12; pH2.Margin = new Thickness(0, 10, 0, 0); Paragraph pH3 = new Paragraph(new Run(new mFlowHeader().SetorOrg)); pH3.Typography.Capitals = FontCapitals.SmallCaps; pH3.FontWeight = FontWeights.Bold; pH3.Foreground = Brushes.Black; pH3.Margin = new Thickness(0, 0, 0, 20); flow.Blocks.Add(pH); flow.Blocks.Add(pH1); flow.Blocks.Add(pH2); flow.Blocks.Add(pH3); /* * var lfiltro = new Rectangle(); * lfiltro.Stroke = new SolidColorBrush(Colors.Silver); * lfiltro.StrokeThickness = 1; * lfiltro.Height = 1; * lfiltro.Width = double.NaN; * lfiltro.Margin = new Thickness(0, 0, 0, 0); * * var linefiltro = new BlockUIContainer(lfiltro); * flow.Blocks.Add(linefiltro); */ //SolidColorBrush bgc1 = Application.Current.Resources["ButtonBackgroundHover"] as SolidColorBrush; Table tb = new Table(); tb.CellSpacing = 0; tb.BorderThickness = new Thickness(0.5); tb.BorderBrush = Brushes.Black; tb.Columns.Add(new TableColumn() { Width = new GridLength(50) }); tb.Columns.Add(new TableColumn() { Width = GridLength.Auto }); tb.Columns.Add(new TableColumn() { Width = new GridLength(120) }); tb.Columns.Add(new TableColumn() { Width = new GridLength(120) }); tb.Columns.Add(new TableColumn() { Width = new GridLength(120) }); tb.Columns.Add(new TableColumn() { Width = new GridLength(200) }); //tb.Columns.Add(new TableColumn() { Width = new GridLength(10, GridUnitType.Star) }); TableRowGroup rg = new TableRowGroup(); TableRow pheader = new TableRow(); pheader.Cells.Add(new TableCell(new Paragraph(new Bold(new Run(string.Format("EVENTO: {0} {1}", Agenda.TipoString, Agenda.Evento)))) { Padding = new Thickness(5) }) { ColumnSpan = 5, BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); pheader.Cells.Add(new TableCell(new Paragraph(new Bold(new Run(string.Format("DATA: {0}", Agenda.Data.ToShortDateString())))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); tb.RowGroups.Add(rg); Paragraph p = new Paragraph(); p.Padding = new Thickness(5); TableRow header = new TableRow(); rg.Rows.Add(pheader); rg.Rows.Add(header); rg.Foreground = Brushes.Black; //rw2.Background = bgc1; header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run(""))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("NOME"))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("CPF"))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("CNPJ"))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("TELEFONE"))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("ASSINATURA"))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); int alt = 0; if (obj != null) { foreach (mInscricao a in obj) { TableRow row = new TableRow(); rg.Foreground = Brushes.Black; rg.Rows.Add(row); row.Cells.Add(new TableCell(new Paragraph(new Run(a.Contador.ToString())) { Padding = new Thickness(5, 8, 5, 8) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); row.Cells.Add(new TableCell(new Paragraph(new Run(a.Nome.ToString())) { Padding = new Thickness(5, 8, 5, 8) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); row.Cells.Add(new TableCell(new Paragraph(new Run(new mMascaras().CPF(a.CPF.ToString()))) { Padding = new Thickness(5, 8, 5, 8) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); row.Cells.Add(new TableCell(new Paragraph(new Run(new mMascaras().CNPJ(a.CNPJ.ToString()))) { Padding = new Thickness(5, 8, 5, 8) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); row.Cells.Add(new TableCell(new Paragraph(new Run(a.Telefone.ToString())) { Padding = new Thickness(5, 8, 5, 8) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); row.Cells.Add(new TableCell(new Paragraph(new Run("")) { Padding = new Thickness(5, 8, 5, 8) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); /* * if (alt % 2 != 0) * row.Background = bgc1; */ alt++; } } flow.Blocks.Add(tb); /* * var lrodape = new Rectangle(); * lrodape.Stroke = new SolidColorBrush(Colors.Silver); * lrodape.StrokeThickness = 1; * lrodape.Height = 1; * lrodape.Width = double.NaN; * lrodape.Margin = new Thickness(0, 10, 0, 0); * * var lineBlock = new BlockUIContainer(lrodape); * flow.Blocks.Add(lineBlock); */ Paragraph r = new Paragraph(); r.Margin = new Thickness(0, 0, 0, 0); r.FontSize = 10; System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location); string version = fvi.FileVersion; //r.Inlines.Add(lrodape); r.Inlines.Add(new Run(AppDomain.CurrentDomain.FriendlyName.ToUpper())); r.Inlines.Add(new Run(" / V" + version + " / ")); r.Inlines.Add(new Bold(new Run(Account.Logged.Nome))); r.Inlines.Add(new Run(" / " + DateTime.Now.ToString("dd.MM.yyyy"))); r.Inlines.Add(new Run(" / " + DateTime.Now.ToLongTimeString())); //flow.Blocks.Add(r); return(flow); }
void InitializeDescriptiveTextTab() { var selectedTypeface = new Typeface( SelectedFontFamily, SelectedFontStyle, SelectedFontWeight, SelectedFontStretch ); GlyphTypeface glyphTypeface; if (selectedTypeface.TryGetGlyphTypeface(out glyphTypeface)) { // Create a table with two columns. var table = new Table(); table.CellSpacing = 5; var leftColumn = new TableColumn(); leftColumn.Width = new GridLength(2.0, GridUnitType.Star); table.Columns.Add(leftColumn); var rightColumn = new TableColumn(); rightColumn.Width = new GridLength(3.0, GridUnitType.Star); table.Columns.Add(rightColumn); var rowGroup = new TableRowGroup(); AddTableRow(rowGroup, "Family:", glyphTypeface.FamilyNames); AddTableRow(rowGroup, "Face:", glyphTypeface.FaceNames); AddTableRow(rowGroup, "Description:", glyphTypeface.Descriptions); AddTableRow(rowGroup, "Version:", glyphTypeface.VersionStrings); AddTableRow(rowGroup, "Copyright:", glyphTypeface.Copyrights); AddTableRow(rowGroup, "Trademark:", glyphTypeface.Trademarks); AddTableRow(rowGroup, "Manufacturer:", glyphTypeface.ManufacturerNames); AddTableRow(rowGroup, "Designer:", glyphTypeface.DesignerNames); AddTableRow(rowGroup, "Designer URL:", glyphTypeface.DesignerUrls); AddTableRow(rowGroup, "Vendor URL:", glyphTypeface.VendorUrls); AddTableRow(rowGroup, "Win32 Family:", glyphTypeface.Win32FamilyNames); AddTableRow(rowGroup, "Win32 Face:", glyphTypeface.Win32FaceNames); try { AddTableRow(rowGroup, "Font File URI:", glyphTypeface.FontUri.ToString()); } catch (System.Security.SecurityException) { // Font file URI is privileged information; just skip it if we don't have access. } table.RowGroups.Add(rowGroup); fontDescriptionBox.Document = new FlowDocument(table); fontLicenseBox.Text = NameDictionaryHelper.GetDisplayName(glyphTypeface.LicenseDescriptions); } else { fontDescriptionBox.Document = new FlowDocument(); fontLicenseBox.Text = String.Empty; } }
private FlowDocument GenerateFlowDocument() { Table table = new Table() { FontFamily = new FontFamily("Times New Roman"), FontSize = 12, Foreground = Brushes.Black, TextAlignment = TextAlignment.Center }; Style tableCellStyle = new Style(typeof(TableCell)); tableCellStyle.Setters.Add(new Setter(TableCell.BorderBrushProperty, Brushes.Black)); tableCellStyle.Setters.Add(new Setter(TableCell.BorderThicknessProperty, new Thickness(1))); tableCellStyle.Setters.Add(new Setter(TableCell.PaddingProperty, new Thickness(2))); Dealer.Select(new Filter(true)).ForEach(x => { Dealer dealer = Dealer.FromDataRow(x); Contact contact = dealer.Contacts.FirstOrDefault(); Phone phone = contact?.Phones.FirstOrDefault(); TableCell nameCell = new TableCell(new Paragraph(new Run($"{BusinessEntity.Select(dealer.BusinessEntityId).Field<string>("Name")} \"{dealer.Name}\""))) { Style = tableCellStyle }; TableCell regionCell = new TableCell(new Paragraph(new Run(Region.Select(dealer.RegionId).Field <string>("Name")))) { Style = tableCellStyle }; TableCell activityCell = new TableCell(new Paragraph(new Run(Activity.Select(dealer.ActivityId).Field <string>("Name")))) { Style = tableCellStyle }; TableCell activityDirectionCell = new TableCell(new Paragraph(new Run(ActivityDirection.Select(dealer.ActivityDirectionId).Field <string>("Name")))) { Style = tableCellStyle }; TableCell ratingCell = new TableCell(new Paragraph(new Run(new string('★', (int)dealer.Rating)))) { Style = tableCellStyle }; TableCell contactCell = new TableCell(new Paragraph(new Run(contact == null ? "–" : $"{contact.Surname} {contact.Name} {contact.Patronymic}".Trim()))) { Style = tableCellStyle }; TableCell positionCell = new TableCell(new Paragraph(new Run(contact == null || contact.Position == string.Empty ? "–" : contact.Position))) { Style = tableCellStyle }; TableCell phoneCell = new TableCell(new Paragraph(new Run(phone == null ? "–" : phone.Value))) { Style = tableCellStyle }; TableRow tableRow = new TableRow(); tableRow.Cells.Add(nameCell); tableRow.Cells.Add(regionCell); tableRow.Cells.Add(activityCell); tableRow.Cells.Add(activityDirectionCell); tableRow.Cells.Add(ratingCell); tableRow.Cells.Add(contactCell); tableRow.Cells.Add(positionCell); tableRow.Cells.Add(phoneCell); TableRowGroup tableRowGroup = new TableRowGroup(); tableRowGroup.Rows.Add(tableRow); table.RowGroups.Add(tableRowGroup); }); PrintDialog printDialog = new PrintDialog(); return(new FlowDocument(table) { Background = Brushes.White, PageWidth = printDialog.PrintableAreaHeight, PageHeight = printDialog.PrintableAreaWidth, ColumnWidth = printDialog.PrintableAreaHeight }); }
private Table CreateResultTable(IList <SvgTestCategory> testCategories) { Table resultTable = new Table(); resultTable.CellSpacing = 0; resultTable.BorderBrush = Brushes.Gray; resultTable.BorderThickness = new Thickness(1); resultTable.Margin = new Thickness(16, 0, 16, 16); TableColumn categoryCol = new TableColumn(); TableColumn failureCol = new TableColumn(); TableColumn successCol = new TableColumn(); TableColumn partialCol = new TableColumn(); TableColumn unknownCol = new TableColumn(); TableColumn totalCol = new TableColumn(); categoryCol.Width = new GridLength(2, GridUnitType.Star); failureCol.Width = new GridLength(1, GridUnitType.Star); successCol.Width = new GridLength(1, GridUnitType.Star); partialCol.Width = new GridLength(1, GridUnitType.Star); unknownCol.Width = new GridLength(1, GridUnitType.Star); totalCol.Width = new GridLength(1, GridUnitType.Star); resultTable.Columns.Add(categoryCol); resultTable.Columns.Add(failureCol); resultTable.Columns.Add(successCol); resultTable.Columns.Add(partialCol); resultTable.Columns.Add(unknownCol); resultTable.Columns.Add(totalCol); TableRowGroup headerGroup = new TableRowGroup(); headerGroup.Background = Brushes.LightGray; TableRow headerRow = new TableRow(); headerRow.Cells.Add(CreateHeaderCell("Category", false, false)); headerRow.Cells.Add(CreateHeaderCell("Failure", false, false)); headerRow.Cells.Add(CreateHeaderCell("Success", false, false)); headerRow.Cells.Add(CreateHeaderCell("Partial", false, false)); headerRow.Cells.Add(CreateHeaderCell("Unknown", false, false)); headerRow.Cells.Add(CreateHeaderCell("Total", true, false)); headerGroup.Rows.Add(headerRow); resultTable.RowGroups.Add(headerGroup); for (int i = 0; i < testCategories.Count; i++) { SvgTestCategory testCategory = testCategories[i]; if (!testCategory.IsValid) { continue; } TableRowGroup resultGroup = new TableRowGroup(); TableRow resultRow = new TableRow(); bool lastBottom = (i == (testCategories.Count - 1)); resultRow.Cells.Add(CreateCell(testCategory.Label, false, lastBottom)); resultRow.Cells.Add(CreateCell(testCategory.Failures, false, lastBottom)); resultRow.Cells.Add(CreateCell(testCategory.Successes, false, lastBottom)); resultRow.Cells.Add(CreateCell(testCategory.Partials, false, lastBottom)); resultRow.Cells.Add(CreateCell(testCategory.Unknowns, false, lastBottom)); resultRow.Cells.Add(CreateCell(testCategory.Total, true, lastBottom)); resultGroup.Rows.Add(resultRow); resultTable.RowGroups.Add(resultGroup); } return(resultTable); }
/// <summary> /// Adaptado de /// https://www.c-sharpcorner.com/uploadfile/mahesh/printing-in-wpf/ /// https://stackoverflow.com/questions/37698316/print-all-data-in-the-datagrid-in-wpf/50281632#50281632 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="dataGrid"></param> /// <param name="title"></param> static public void printDG <T>(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(); List <dynamic> bindList = new List <dynamic>(); 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); var binding = (dataGrid.Columns[j] as DataGridBoundColumn).Binding as Binding; bindList.Add(binding.Path.Path); } tableRowGroup.Rows.Add(r); table.RowGroups.Add(tableRowGroup); for (int i = 0; i < dataGrid.Items.Count; i++) { dynamic row; if (dataGrid.ItemsSource.ToString().ToLower() == "system.data.linqdataview") { row = (DataRowView)dataGrid.Items.GetItemAt(i); } else { row = (T)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(); var lista = row.GetType().GetProperties(); for (int j = 0; j < lista.Length; j++) { /*if (dataGrid.ItemsSource.ToString().ToLower() == "system.data.linqdataview") * { * r.Cells.Add(new TableCell(new Paragraph(new Run(row.Row.ItemArray[j].ToString())))); * } * else * {*/ //r.Cells.Add(new TableCell(new Paragraph(new Run(row.GetType().GetProperty(bindList[j]).GetValue(row, null))))); // } r.Cells.Add(new TableCell(new Paragraph(new Run(lista[j].GetValue(row).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, ""); } }
/// <summary> /// Adds TableRow elements to xamlTableBodyElement. The rows are converted from Html tr elements that /// may be the children of an Html tbody element or an Html table element with tbody missing /// </summary> /// <param name="xamlTableBodyElement"> /// XmlElement representing Xaml TableRowGroup element to which the converted rows should be added /// </param> /// <param name="htmlTRStartNode"> /// XmlElement representing the first tr child of the tbody element to be read /// </param> /// <param name="currentProperties"> /// Hashtable representing current properties of the tbody element that are generated and applied in the /// AddTable function; to be used as inheritedProperties when adding tr elements /// </param> /// <param name="columnStarts"></param> /// <param name="stylesheet"></param> /// <param name="sourceContext"></param> /// <returns> /// XmlNode representing the current position of the iterator among tr elements /// </returns> private XmlNode AddTableRowsToTableBody( TableRowGroup trg, XmlNode htmlTRStartNode, Hashtable currentProperties, ArrayList columnStarts, CssStylesheet stylesheet) { // Parameter validation Debug.Assert(currentProperties != null); // Initialize child node for iteratimg through children to the first tr element XmlNode htmlChildNode = htmlTRStartNode; ArrayList activeRowSpans = null; if (columnStarts != null) { activeRowSpans = new ArrayList(); InitializeActiveRowSpans(activeRowSpans, columnStarts.Count); } while (htmlChildNode != null && htmlChildNode.LocalName.ToLower() != "tbody") { if (htmlChildNode.LocalName.ToLower() == "tr") { TableRow tr = new TableRow(); //XmlElement xamlTableRowElement = xamlTableBodyElement.OwnerDocument.CreateElement(null, Xaml_TableRow, _xamlNamespace); //sourceContext.Add((XmlElement)htmlChildNode); // Get tr element properties Hashtable trElementCurrentProperties = new Hashtable(); GetElementProperties(htmlChildNode as XmlElement, currentProperties, trElementCurrentProperties, stylesheet); ApplyLocalProperties(tr, trElementCurrentProperties,/*isBlock*/true); // TODO: apply local properties to tr element AddTableCellsToTableRow(tr, htmlChildNode.FirstChild, trElementCurrentProperties, columnStarts, activeRowSpans, stylesheet); if (tr.Cells.Count > 0) { trg.Rows.Add(tr); maxc = (maxc < tr.Cells.Count ? tr.Cells.Count : maxc); // xamlTableBodyElement.AppendChild(xamlTableRowElement); } //Debug.Assert(sourceContext.Count > 0 && sourceContext[sourceContext.Count - 1] == htmlChildNode); //sourceContext.RemoveAt(sourceContext.Count - 1); // Advance htmlChildNode = htmlChildNode.NextSibling; } else if (htmlChildNode.LocalName.ToLower() == "td") { // Tr element is not present. We create one and add td elements to it TableRow tr = new TableRow(); // This is incorrect formatting and the column starts should not be set in this case Debug.Assert(columnStarts == null); htmlChildNode = AddTableCellsToTableRow(tr, htmlChildNode, currentProperties, columnStarts, activeRowSpans, stylesheet); if (tr.Cells.Count > 0) { trg.Rows.Add(tr); maxc = (maxc < tr.Cells.Count ? tr.Cells.Count : maxc); } } else { // Not a tr or td element. Ignore it. // TODO: consider better recovery here htmlChildNode = htmlChildNode.NextSibling; } } return htmlChildNode; }
private void RefreshContents(int index) { RTBNow.Document.Blocks.Clear(); Table t = new Table(); t.Columns.Add(new TableColumn()); t.Columns.Add(new TableColumn()); t.Columns.Add(new TableColumn()); TableRowGroup trg = new TableRowGroup(); trg.Rows.Add(AddTitle(TagList[index])); t.RowGroups.Add(trg); t.RowGroups.Add(AddTextChunkToTable(GetTagContents(TagList[index]).GetMainResult())); t.BorderThickness = new Thickness(RTBWidth/16,0,0,0); t.CellSpacing = 10; double tablewidth = RTBWidth * (13.2 / 16.0); t.Columns[0].Width = new GridLength(tablewidth/2); t.Columns[1].Width = new GridLength(tablewidth/4); t.Columns[2].Width = new GridLength(tablewidth/4); RTBNow.Document.Blocks.Add(t); }
public static string ExportToXaml(OutlinerDocument Document, MainWindow wnd) { FlowDocument wholeDocument = new FlowDocument(); wholeDocument.FontFamily = UVOutliner.Settings.DefaultFontFamily; wholeDocument.FontSize = UVOutliner.Settings.DefaultFontSize; List <OutlinerNote> linearList = new List <OutlinerNote>(); DocumentHelpers.GetLinearNotesList(Document.RootNode, linearList, false); double totalWidth = 0; for (int i = 0; i < Document.ColumnDefinitions.Count; i++) { totalWidth += Document.ColumnDefinitions[i].Width; } // just random if (totalWidth == 0) { totalWidth = 300; } Table table = new Table(); table.LineHeight = 1; table.Margin = new Thickness(0); table.Padding = new Thickness(0); wholeDocument.Blocks.Add(table); for (int i = 0; i < wnd.OutlinerTreeColumns.Count; i++) { int columnId = wnd.GetColumnIdByView(i); TableColumn column = new TableColumn(); column.Width = new GridLength(Document.ColumnDefinitions[columnId].Width / totalWidth, GridUnitType.Star); table.Columns.Add(column); } // add column headers if (Document.ColumnDefinitions.Count > 1) { TableRowGroup rowGroup = new TableRowGroup(); table.RowGroups.Add(rowGroup); TableRow row = new TableRow(); rowGroup.Rows.Add(row); for (int i = 0; i < wnd.OutlinerTreeColumns.Count; i++) { int columnId = wnd.GetColumnIdByView(i); row.Cells.Add(new TableCell(new Paragraph(new Run(Document.ColumnDefinitions[columnId].ColumnName)))); } } TableRowGroup mainRowGroup = new TableRowGroup(); table.RowGroups.Add(mainRowGroup); // add all other columns for (int i = 0; i < linearList.Count; i++) { TableRow tableRow = new TableRow(); OutlinerNote note = linearList[i]; if (note.IsEmpty) { tableRow.Cells.Add(new TableCell(new Paragraph())); mainRowGroup.Rows.Add(tableRow); continue; } for (int c = 0; c < wnd.OutlinerTreeColumns.Count; c++) { int columnId = wnd.GetColumnIdByView(c); FlowDocument flowDocument = linearList[i].Columns[columnId].ColumnData as FlowDocument; if (flowDocument == null) { tableRow.Cells.Add(new TableCell()); continue; } double indent = note.Level * 20; TableCell cell = new TableCell(); tableRow.Cells.Add(cell); Section section = XamlReader.Load(TransformFlowDocumentToSection(flowDocument)) as Section; if (section == null) { continue; } if (columnId != 0) { cell.Blocks.Add(section); } else { Table tbl = new Table(); tbl.LineHeight = 1; tbl.Margin = new Thickness(0); tbl.Padding = new Thickness(0); TableColumn c1 = new TableColumn(); c1.Width = new GridLength(indent + 20 + (Document.CheckboxesVisble ? 20 : 0), GridUnitType.Pixel); TableColumn c2 = new TableColumn(); c2.Width = new GridLength(1, GridUnitType.Auto); tbl.Columns.Add(c1); tbl.Columns.Add(c2); var tmpRowGroup = new TableRowGroup(); var tmpRow = new TableRow(); tmpRowGroup.Rows.Add(tmpRow); tbl.RowGroups.Add(tmpRowGroup); Paragraph para = new Paragraph(); para.Margin = new Thickness(indent, 0, 0, 0); AddImages(Document, note, para); tmpRow.Cells.Add(new TableCell(para)); tmpRow.Cells.Add(new TableCell(section)); cell.Blocks.Add(tbl); } } mainRowGroup.Rows.Add(tableRow); if (note.HasInlineNote) { AddInlineNote(mainRowGroup.Rows, note); } } MemoryStream outStream = new MemoryStream(); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; XmlWriter writer = XmlWriter.Create(outStream, settings); XamlDesignerSerializationManager manager = new XamlDesignerSerializationManager(writer); XamlWriter.Save(wholeDocument, manager); outStream.Seek(0, SeekOrigin.Begin); StreamReader reader = new StreamReader(outStream); return(reader.ReadToEnd()); }
/// <summary> /// The write table. /// </summary> /// <param name="t"> /// The t. /// </param> public void WriteTable(Table t) { var p = new System.Windows.Documents.Paragraph(); var figure = new Figure(); var table = new System.Windows.Documents.Table(); // if (t.HasHeader()) // { // var trg1 = new TableRowGroup(); // SetStyle(trg1, Style.TableHeaderStyle); // var r = new TableRow(); // foreach (var c in columns) // { // var cell = new TableCell(); // var run = new Run() { Text = c.Header }; // cell.Blocks.Add(new System.Windows.Documents.Paragraph(run)); // r.Cells.Add(cell); // } // trg1.Rows.Add(r); // table.RowGroups.Add(trg1); // } var trg2 = new TableRowGroup(); // SetStyle(trg2, Style.TableTextStyle); foreach (var row in t.Rows) { var r = new TableRow(); if (row.IsHeader) { SetStyle(r, row.IsHeader ? this.Style.TableHeaderStyle : this.Style.TableTextStyle); } for (int j = 0; j < t.Columns.Count; j++) { TableCell c = row.Cells[j]; var cell = new System.Windows.Documents.TableCell(); var run = new Run { Text = c.Content }; cell.Blocks.Add(new System.Windows.Documents.Paragraph(run)); r.Cells.Add(cell); } trg2.Rows.Add(r); } table.RowGroups.Add(trg2); figure.Blocks.Add(this.CreateParagraph(t.Caption, this.Style.FigureTextStyle)); figure.Blocks.Add(table); p.Inlines.Add(figure); this.doc.Blocks.Add(p); }
private void SetClipboardWithRTF() { DateTime startDate; DateTime.TryParse(this.StartDate.Text, out startDate); DateTime endDate; DateTime.TryParse(this.EndDate.Text, out endDate); double outstandingAmount; double.TryParse(this.OutstandingAmount.Text, out outstandingAmount); /* * Interest on Rs.4,540.00 at 24% p. a from 1.3.2004 to 19.1.2007 * 2 years : Rs.2,179.00 * 10 months : Rs.907.00 * 18 days : Rs.53.00 * Total : Rs.3,139.00 * */ // Gets a NumberFormatInfo associated with the en-US culture. NumberFormatInfo nfi = new CultureInfo("en-IN", false).NumberFormat; nfi.NumberDecimalDigits = 2; IEnumerable <InterestInfo> interestInfoList = interestInfoListM; if (CompoundInterestTabControl.SelectedIndex == 1) { interestInfoList = interestInfoListQ; } else if (CompoundInterestTabControl.SelectedIndex == 2) { interestInfoList = interestInfoListH; } else if (CompoundInterestTabControl.SelectedIndex == 3) { interestInfoList = interestInfoListA; } if (interestInfoList.Any()) { RichTextBox doc = new RichTextBox() { FontFamily = new FontFamily("Times New Roman"), FontSize = 15 }; Table t = new Table() { FontFamily = new FontFamily("Times New Roman"), FontSize = 12, BorderBrush = Brushes.LightGray, BorderThickness = new Thickness(0.25), CellSpacing = 10.0 }; TableRowGroup trg = new TableRowGroup(); if (doc != null) { if (this.SimpleInterest.IsSelected) { t.Columns.Add(new TableColumn() { Width = new GridLength(200) }); t.Columns.Add(new TableColumn() { Width = new GridLength(125) }); t.Columns.Add(new TableColumn() { Width = new GridLength(200) }); TableRow tr = new TableRow { }; TableCell cell = new TableCell() { }; cell.Blocks.Add(new Paragraph(new Run(GetInterestSummary())) { TextAlignment = TextAlignment.Left }); cell.ColumnSpan = 3; tr.Cells.Add(cell); trg.Rows.Add(tr); tr = new TableRow(); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(this.Years.Text + " : ")) { Margin = new Thickness(2, 0, 5, 0), TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(this.YearsInterest.Text)) { Margin = new Thickness(2, 0, 5, 0), TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run("")) { TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); trg.Rows.Add(tr); tr = new TableRow(); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(this.Months.Text + " : ")) { Margin = new Thickness(2, 0, 5, 0), TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(this.MonthsInterest.Text)) { Margin = new Thickness(2, 0, 5, 0), TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run("")) { TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); trg.Rows.Add(tr); tr = new TableRow(); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(this.Days.Text + " : ")) { Margin = new Thickness(2, 0, 5, 0), TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(this.DaysInterest.Text)) { Margin = new Thickness(2, 0, 5, 0), TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run("")) { TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); trg.Rows.Add(tr); tr = new TableRow(); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run("Total Interest : ")) { Margin = new Thickness(2, 0, 5, 0), FontWeight = FontWeights.Bold, TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); cell = new TableCell(); //cell.BorderBrush = Brushes.Black; //cell.BorderThickness = new Thickness(0,1,0,1); cell.Blocks.Add(new Paragraph(new Run(this.TotalInterest.Text)) { Margin = new Thickness(2, 0, 5, 0), FontWeight = FontWeights.Bold, TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run("")) { TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); trg.Rows.Add(tr); tr = new TableRow(); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(""))); cell.ColumnSpan = 3; tr.Cells.Add(cell); trg.Rows.Add(tr); tr = new TableRow(); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run("")) { TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run("Principal : ")) { Margin = new Thickness(2, 0, 5, 0), TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(double.Parse(this.OutstandingAmount.Text).ToString("C"))) { Margin = new Thickness(2, 0, 5, 0), TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); trg.Rows.Add(tr); tr = new TableRow(); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run("")) { TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(string.Format("Total Interest : "))) { Margin = new Thickness(2, 0, 5, 0), TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(this.TotalInterest.Text)) { Margin = new Thickness(2, 0, 5, 0), TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); trg.Rows.Add(tr); tr = new TableRow(); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run("")) { TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run("Total Amount : ") { FontWeight = FontWeights.Bold }) { Margin = new Thickness(2, 0, 5, 0), TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(this.TotalAmountWithInterest.Text)) { Margin = new Thickness(2, 0, 5, 0), FontWeight = FontWeights.Bold, TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); trg.Rows.Add(tr); //this.TotalInterest.Text = totalinterest.ToString("C"); //this.TotalAmountWithInterest.Text = (principal + totalinterest).ToString("C"); } else { bool hasMultipleInterestRates = input.InterestChangeList.Count > 0; // Create an underline text decoration. Default is underline. TextDecoration myUnderline = new TextDecoration(); // Create a linear gradient pen for the text decoration. Pen myPen = new Pen(); myPen.Brush = Brushes.Black; myPen.Thickness = 5; myPen.DashStyle = DashStyles.Solid; myUnderline.Pen = myPen; myUnderline.PenThicknessUnit = TextDecorationUnit.FontRecommended; // Set the underline decoration to a TextDecorationCollection and add it to the text block. TextDecorationCollection myCollection = new TextDecorationCollection(); myCollection.Add(myUnderline); t.Columns.Add(new TableColumn() { Width = new GridLength(80) }); //Date t.Columns.Add(new TableColumn() { Width = new GridLength(120) }); //IR Period t.Columns.Add(new TableColumn() { Width = new GridLength(40) }); //IR Days if (hasMultipleInterestRates) { t.Columns.Add(new TableColumn() { Width = new GridLength(45) }); //IR ROI } t.Columns.Add(new TableColumn() { Width = new GridLength(90) }); //Principal t.Columns.Add(new TableColumn() { Width = new GridLength(70) }); //IR Amount t.Columns.Add(new TableColumn() { Width = new GridLength(75) }); //Credit t.Columns.Add(new TableColumn() { Width = new GridLength(65) }); //Debit t.Columns.Add(new TableColumn() { Width = new GridLength(110) }); TableRow tr = new TableRow { }; TableCell cell = new TableCell() { }; tr = new TableRow(); cell = new TableCell() { }; //cell.BorderBrush = Brushes.Black; // cell.BorderThickness = new Thickness(0, 0, 0, 1); cell.Blocks.Add(new Paragraph(new Run("Date")) { Margin = new Thickness(0, 3, 0, 0), TextDecorations = myCollection, TextAlignment = TextAlignment.Center }); tr.Cells.Add(cell); cell = new TableCell() { }; //cell.BorderBrush = Brushes.Black; //cell.BorderThickness = new Thickness(0, 0, 0, 1); cell.Blocks.Add(new Paragraph(new Run("Period")) { Margin = new Thickness(0, 3, 0, 0), TextDecorations = myCollection, TextAlignment = TextAlignment.Center }); tr.Cells.Add(cell); cell = new TableCell() { }; //cell.BorderBrush = Brushes.Black; //cell.BorderThickness = new Thickness(0, 0, 0, 1); cell.Blocks.Add(new Paragraph(new Run("Days")) { Margin = new Thickness(0, 3, 0, 0), TextDecorations = myCollection, TextAlignment = TextAlignment.Center }); tr.Cells.Add(cell); if (hasMultipleInterestRates) { cell = new TableCell(); //cell.BorderBrush = Brushes.Black; //cell.BorderThickness = new Thickness(0, 0, 0, 1); cell.Blocks.Add(new Paragraph(new Run("ROI")) { Margin = new Thickness(0, 3, 0, 0), TextDecorations = myCollection, TextAlignment = TextAlignment.Center }); tr.Cells.Add(cell); } cell = new TableCell() { }; // cell.BorderBrush = Brushes.Black; // cell.BorderThickness = new Thickness(0, 0, 0, 1); cell.Blocks.Add(new Paragraph(new Run("Principal")) { Margin = new Thickness(0, 3, 0, 0), TextDecorations = myCollection, TextAlignment = TextAlignment.Center }); cell.Blocks.Add(new Paragraph(new Run("in Rs.")) { TextDecorations = myCollection, TextAlignment = TextAlignment.Center }); tr.Cells.Add(cell); cell = new TableCell() { }; //cell.BorderBrush = Brushes.Black; //cell.BorderThickness = new Thickness(0, 0, 0, 1); cell.Blocks.Add(new Paragraph(new Run("Interest")) { Margin = new Thickness(0, 3, 0, 0), TextDecorations = myCollection, TextAlignment = TextAlignment.Center }); cell.Blocks.Add(new Paragraph(new Run("in Rs.")) { TextDecorations = myCollection, TextAlignment = TextAlignment.Center }); cell.Blocks.Add(new Paragraph(new Run("(+)")) { TextDecorations = myCollection, TextAlignment = TextAlignment.Center }); tr.Cells.Add(cell); cell = new TableCell() { }; //cell.BorderBrush = Brushes.Black; // cell.BorderThickness = new Thickness(0, 0, 0, 1); cell.Blocks.Add(new Paragraph(new Run("Debit")) { Margin = new Thickness(0, 3, 0, 0), TextDecorations = myCollection, TextAlignment = TextAlignment.Center }); cell.Blocks.Add(new Paragraph(new Run("in Rs.")) { TextDecorations = myCollection, TextAlignment = TextAlignment.Center }); cell.Blocks.Add(new Paragraph(new Run("(+)")) { TextDecorations = myCollection, TextAlignment = TextAlignment.Center }); tr.Cells.Add(cell); cell = new TableCell() { }; //cell.BorderBrush = Brushes.Black; // cell.BorderThickness = new Thickness(0, 0, 0, 1); cell.Blocks.Add(new Paragraph(new Run("Credit")) { Margin = new Thickness(0, 3, 0, 0), TextDecorations = myCollection, TextAlignment = TextAlignment.Center }); cell.Blocks.Add(new Paragraph(new Run("in Rs.")) { TextDecorations = myCollection, TextAlignment = TextAlignment.Center }); cell.Blocks.Add(new Paragraph(new Run("(-)")) { TextDecorations = myCollection, TextAlignment = TextAlignment.Center }); tr.Cells.Add(cell); cell = new TableCell() { }; //cell.BorderBrush = Brushes.Black; // cell.BorderThickness = new Thickness(0, 0, 0, 1); cell.Blocks.Add(new Paragraph(new Run("Total")) { Margin = new Thickness(0, 3, 0, 0), TextDecorations = myCollection, TextAlignment = TextAlignment.Center }); cell.Blocks.Add(new Paragraph(new Run("in Rs.")) { TextDecorations = myCollection, TextAlignment = TextAlignment.Center }); tr.Cells.Add(cell); trg.Rows.Add(tr); //cell.BorderThickness = new Thickness(0, 0, 0, 0); foreach (InterestInfo info in interestInfoList) { tr = new TableRow(); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(info.Date)) { TextAlignment = TextAlignment.Center }); tr.Cells.Add(cell); if (info.HasTransaction) { cell = new TableCell(); cell.ColumnSpan = (hasMultipleInterestRates) ? 3 : 2; cell.Blocks.Add(new Paragraph(new Run())); tr.Cells.Add(cell); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(info.DisplayPrincipal.Replace("Rs.", ""))) { Margin = new Thickness(2, 0, 5, 0), TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run())); tr.Cells.Add(cell); } else { cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(string.Format("{0} - {1}", info.DisplayStartDate, info.DisplayEndDate))) { TextAlignment = TextAlignment.Center }); tr.Cells.Add(cell); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(info.Days.ToString())) { Margin = new Thickness(2, 0, 5, 0), TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); if (hasMultipleInterestRates) { cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(info.InterestRate.ToString("N", nfi))) { Margin = new Thickness(2, 0, 5, 0), TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); } cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(info.DisplayPrincipal.Replace("Rs.", ""))) { Margin = new Thickness(2, 0, 5, 0), TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(info.DisplayInterest.Replace("Rs.", ""))) { Margin = new Thickness(2, 0, 5, 0), TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); } cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(info.DebitAmount.Replace("Rs.", ""))) { Margin = new Thickness(2, 0, 5, 0), TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(info.CreditAmount.Replace("Rs.", ""))) { Margin = new Thickness(2, 0, 5, 0), TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run(info.DisplayTotalWithInterest.Replace("Rs.", ""))) { Margin = new Thickness(2, 0, 5, 0), TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); trg.Rows.Add(tr); } tr = new TableRow(); TextDecoration underline = new TextDecoration() { Pen = new Pen(Brushes.Black, 1) { DashStyle = DashStyles.Solid } }; cell = new TableCell(); cell.Blocks.Add(new Paragraph(new Run("Total Amount : ")) { Margin = new Thickness(2, 0, 5, 0), TextAlignment = TextAlignment.Right }); if (hasMultipleInterestRates) { cell.ColumnSpan = 8; } else { cell.ColumnSpan = 7; } tr.Cells.Add(cell); cell = new TableCell() { ColumnSpan = 1 }; cell.Blocks.Add(new Paragraph(new Run((interestInfoList.Last().TotalWithInterest).ToString("C"))) { Margin = new Thickness(2, 0, 5, 0), FontWeight = FontWeights.Bold, TextAlignment = TextAlignment.Right }); tr.Cells.Add(cell); trg.Rows.Add(tr); } t.RowGroups.Add(trg); doc.Document.Blocks.Add(new Paragraph(new Run("INTEREST CALCULATION")) { FontWeight = FontWeights.Bold, TextAlignment = TextAlignment.Center }); doc.Document.Blocks.Add(new Paragraph(new Run(" ")) { TextAlignment = TextAlignment.Center }); Table table = new Table(); table.FontFamily = new FontFamily("Times New Roman"); table.FontSize = 16; table.BorderBrush = Brushes.LightGray; table.BorderThickness = new Thickness(0.25); table.Columns.Add(new TableColumn() { Width = new GridLength(320) }); table.Columns.Add(new TableColumn() { Width = new GridLength(320) }); TableRowGroup trg1 = new TableRowGroup(); TableRow tr1 = new TableRow(); tr1.Cells.Add(new TableCell(new Paragraph(new Run("BORROWER NAME") { FontWeight = FontWeights.Bold }))); tr1.Cells.Add(new TableCell(new Paragraph(new Run("ACCOUNT NUMBER") { FontWeight = FontWeights.Bold }))); TableRow tr2 = new TableRow(); tr2.Cells.Add(new TableCell(new Paragraph(new Run(BorrowerName.Text)))); tr2.Cells.Add(new TableCell(new Paragraph(new Run(AccountNumber.Text)))); trg1.Rows.Add(tr1); trg1.Rows.Add(tr2); table.RowGroups.Add(trg1); doc.Document.Blocks.Add(table); doc.Document.Blocks.Add(new Paragraph(new Run(" ")) { TextAlignment = TextAlignment.Center }); doc.Document.Blocks.Add(new Paragraph(new Run(GetInterestSummary())) { TextAlignment = TextAlignment.Left }); doc.Document.Blocks.Add(new Paragraph(new Run(" ")) { TextAlignment = TextAlignment.Center }); doc.Document.Blocks.Add(t); TextRange range = new TextRange(doc.Document.ContentStart, doc.Document.ContentEnd); MemoryStream ms = new MemoryStream(); range.Save(ms, DataFormats.Rtf); string xamlText = ASCIIEncoding.Default.GetString(ms.ToArray()); Clipboard.SetData(DataFormats.Rtf, xamlText); } } else { Clipboard.SetData(DataFormats.Rtf, string.Empty); } }
/// <summary> /// Handle table row elements /// </summary> /// <param name="props">The element properties</param> private static void RowElement(ElementProperties props) { // If not already in a table row group, add the group first if(!(props.Converter.CurrentBlockElement is TableRowGroup)) { var group = new TableRowGroup(); // We'll use this group as the parent for all child elements but we don't want to // push it on the stack. The current element should be a table. ((Table)props.Converter.CurrentBlockElement).RowGroups.Add(group); props.Converter.CurrentBlockElement = group; } props.Converter.AddToBlockContainer(new TableRow()); }
private static TextElement ConvertHorizontalRulerElement(IHtmlElement smallHtmlElement) { Table horizontalRuler = new Table(); TableRowGroup tableRowGroup = new TableRowGroup(); horizontalRuler.RowGroups.Add(tableRowGroup); TableRow tableRow = new TableRow(); tableRowGroup.Rows.Add(tableRow); TableCell tableCell = new TableCell { BorderBrush = Brushes.Black, BorderThickness = new Thickness(0.0d, 1.0d, 0.0d, 0.0d), FontSize = 0.1 }; tableRow.Cells.Add(tableCell); return horizontalRuler; }
static void WritePage(FlowDocument doc, IList<Lessee> lessees, Project project, bool overview, bool lastpage) { var result = project.Result; double scale = overview ? 0.8 : 1; var llv = overview && lastpage;// print landlord and vacancy columns // create some useful fonts and brushes var heading = CreateStyle(20.0 * scale, FontWeights.Bold); var big = CreateStyle(16 * scale, FontWeights.Bold); var bold = CreateStyle(11 * scale, FontWeights.Bold); var normal = CreateStyle(11 * scale); var small = CreateStyle(9 * scale); var red = CreateStyle(11 * scale, FontWeights.Bold, Brushes.Red); // Nebenkostenabrechnung <jahr>/<jahr+1> // <name mietpartei/Übersicht> // Vom <abrechnungszeitraum anfang> bis zum <abrechnungszeitraum ende> var r = doc.Blocks; r.Add(Text("Nebenkostenabrechnung " + project.StartYear + " / " + project.EndDate.Year, heading)); if ( r.Count != 1 ) r.LastBlock.BreakPageBefore = true;// unless this is the first page, insert a page break r.Add(Text(overview ? "Übersicht" : lessees[0].Name, big)); var start = overview ? project.StartDate : result.Lessees[lessees[0]].StartDate; var end = overview ? project.EndDate : result.Lessees[lessees[0]].EndDate; r.Add(Text("Zeitraum: " + start.ToShortDateString() + " bis " + end.ToShortDateString(), bold)); /* Kostenart Schlüssel Gesamtkosten _______ * Mieter Mieter i * Personen/Firmen i.count * Mietfläche i.room.size * Mietdauer n Monate _______ * Kostenpunkt j j.type j.value k(i, j) _______ * Nebenkosten gesamt in Euro K(false) K(i) * Vorauszahlungen in Euro P() P(i) * Nachzahlung/Erstattung in Euro Z(false) Z(i) *\____________________|_______________|______________|_/ \_____________/ * same for single leccee and overview single first */ var t = new Table(); t.CellSpacing = 0; for ( var i = 0; i < 3 + lessees.Count; ++i ) { t.Columns.Add(new TableColumn() { Width = i == 0 ? new GridLength(160 * scale) : new GridLength(110 * scale) }); } if ( overview && lastpage ) { t.Columns.Add(new TableColumn() { Width = new GridLength(110 * scale) }); t.Columns.Add(new TableColumn() { Width = new GridLength(110 * scale) }); } var headgroup = new TableRowGroup(); headgroup.Rows.Add(Row( Text("Kostenart", bold), Text("Schlüssel", bold), Text("Gesamtkosten", bold), lessees, l => Text(), llv ? Text() : null, llv ? Text() : null, true)); headgroup.Rows.Add(Row( Text(), Text("Mieter", normal), Text(), lessees, l => Text(l.Name, normal), llv ? Text("Leerstand", normal) : null, llv ? Text("Vermieter", normal) : null)); headgroup.Rows.Add(Row( Text(), Text("Personen", normal), Text(), lessees, l => Text(l.Members.ToString(), normal), llv ? Text() : null, llv ? Text() : null)); headgroup.Rows.Add(Row( Text(), Text("Mietfläche", normal), Text(), lessees, l => Text(result.Lessees[l].AverageFlatSize.ToString("F") + " m²", normal), llv ? Text(result.Vacancy.AverageFlatSize.ToString("F") + "~ m²", normal) : null, llv ? Text() : null)); headgroup.Rows.Add(Row( Text(), Text("Mietdauer", normal), Text(), lessees, l => Text(result.Lessees[l].Months + " Monate", normal), llv ? Text(result.Vacancy.Months + " Monate", normal) : null, llv ? Text() : null, true)); t.RowGroups.Add(headgroup); var costgroup = new TableRowGroup(); for ( var i = 0; i < project.Costs.Count; ++i ) { var cost = project.Costs[i]; if ( !overview && !result.Lessees[lessees[0]].Costs.ContainsKey(cost) ) continue; costgroup.Rows.Add(Row( Text(cost.Name, normal), Text(ResultView.CostModeToString(cost.Mode), normal), /* Total */ Text(cost.Amount.ToString("F"), normal), lessees, /* Lessee */ l => result.Lessees[l].Costs.ContainsKey(cost) ? Text(result.Lessees[l].Costs[cost].ToString("F"), normal) : Text(), /* Vacancy */ llv ? (result.Vacancy.Costs.ContainsKey(cost) ? Text(result.Vacancy.Costs[cost].ToString("F"), normal) : Text()) : null, /* Landlord */ llv && result.Landlord.Costs.ContainsKey(cost) ? Text(result.Landlord.Costs[cost].ToString("F"), normal) : null, /* HasBorder */ i == project.Costs.Count - 1)); } t.RowGroups.Add(costgroup); var sumgroup = new TableRowGroup(); double costssum = project.Costs.Sum(c => c.Amount); double paymentsum = result.Lessees.Sum(p => p.Value.AdvancePayment); double vacancysum = result.Vacancy.Costs.Sum(v => v.Value); double landlordsum = result.Landlord.Costs.Sum(l => l.Value); sumgroup.Rows.Add(Row( Text("Nebenkosten gesamt", bold), Text("in Euro", normal), Text(costssum.ToString("F"), bold), lessees, l => Text(result.Lessees[l].Costs.Sum(p => p.Value).ToString("F"), bold), llv ? Text(vacancysum.ToString("F"), bold) : null, llv ? Text(landlordsum.ToString("F"), bold) : null)); sumgroup.Rows.Add(Row( Text("Vorrauszahlungen", bold), Text("in Euro", normal), Text(paymentsum.ToString("F"), bold), lessees, l => Text(result.Lessees[l].AdvancePayment.ToString("F"), bold), llv ? Text() : null, llv ? Text() : null)); sumgroup.Rows.Add(Row( Text("Nachzahlung/Erstattung", bold), Text("in Euro", normal), Text((paymentsum - costssum).ToString("F"), bold), lessees, l => { var sum = result.Lessees[l].AdvancePayment - result.Lessees[l].Costs.Sum(p => p.Value); return Text(sum.ToString("F"), sum < 0 ? red : bold); }, llv ? Text((-vacancysum).ToString("F"), red) : null, llv ? Text((-landlordsum).ToString("F"), red) : null)); t.RowGroups.Add(sumgroup); r.Add(t); }
private TableRowGroup AddTextChunkToTable(string chunk) { TableRowGroup trg = new TableRowGroup(); String[] lines = chunk.Split('\n'); for (int j = 0; j < lines.Count(); j++) if(lines[j]!="")trg.Rows.Add(AddItemRow(lines[j])); return trg; }
private FlowDocument ReportPreview(ObservableCollection <Avaliacoes> obj) { FlowDocument flow = new FlowDocument(); flow.ColumnGap = 0; flow.Background = Brushes.White; //flow.ColumnWidth = 8.5 * 96.0; //flow.ColumnWidth = 96.0 * 8.5; //flow.PageHeight = 11.5 * 96.0; //flow.PageWidth = 8.5 * 96.0; flow.PageHeight = 768; flow.PageWidth = 1104; flow.ColumnWidth = 1104; flow.FontFamily = new FontFamily("Segoe UI"); flow.FontSize = 11; flow.PagePadding = new Thickness(40, 20, 40, 20); flow.TextAlignment = TextAlignment.Left; Paragraph pH = new Paragraph(new Run(new Header().NameOrg)); pH.Typography.Capitals = FontCapitals.SmallCaps; pH.Foreground = Brushes.Black; pH.FontSize = 16; pH.FontWeight = FontWeights.Bold; pH.Margin = new Thickness(0); Paragraph pH1 = new Paragraph(new Run(new Header().SloganOrg)); pH1.Foreground = Brushes.Black; pH1.FontSize = 9; pH1.Margin = new Thickness(1, 0, 0, 0); Paragraph pH2 = new Paragraph(new Run(new Header().DepOrg)); pH2.Typography.Capitals = FontCapitals.SmallCaps; pH2.Foreground = Brushes.Black; pH2.FontWeight = FontWeights.Bold; pH2.FontSize = 12; pH2.Margin = new Thickness(0, 10, 0, 0); Paragraph pH3 = new Paragraph(new Run(new Header().SetorOrg)); pH3.Typography.Capitals = FontCapitals.SmallCaps; pH3.FontWeight = FontWeights.Bold; pH3.Foreground = Brushes.Black; pH3.Margin = new Thickness(0, 0, 0, 20); flow.Blocks.Add(pH); flow.Blocks.Add(pH1); flow.Blocks.Add(pH2); flow.Blocks.Add(pH3); /* * var lfiltro = new Rectangle(); * lfiltro.Stroke = new SolidColorBrush(Colors.Silver); * lfiltro.StrokeThickness = 1; * lfiltro.Height = 1; * lfiltro.Width = double.NaN; * lfiltro.Margin = new Thickness(0, 0, 0, 0); * * var linefiltro = new BlockUIContainer(lfiltro); * flow.Blocks.Add(linefiltro); */ //SolidColorBrush bgc1 = Application.Current.Resources["ButtonBackgroundHover"] as SolidColorBrush; Table tb = new Table(); tb.CellSpacing = 0; tb.BorderThickness = new Thickness(0.5); tb.BorderBrush = Brushes.Black; tb.Columns.Add(new TableColumn() { Width = new GridLength(50) }); tb.Columns.Add(new TableColumn() { Width = GridLength.Auto }); tb.Columns.Add(new TableColumn() { Width = new GridLength(120) }); tb.Columns.Add(new TableColumn() { Width = new GridLength(120) }); tb.Columns.Add(new TableColumn() { Width = new GridLength(120) }); //tb.Columns.Add(new TableColumn() { Width = new GridLength(200) }); //tb.Columns.Add(new TableColumn() { Width = new GridLength(10, GridUnitType.Star) }); TableRowGroup rg = new TableRowGroup(); string f = string.Empty; foreach (string filtro in Parametros()) { f += filtro + ";"; } TableRow pheader = new TableRow(); pheader.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("FILTROS: {0}", f))) { Padding = new Thickness(5) }) { ColumnSpan = 4, BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); pheader.Cells.Add(new TableCell(new Paragraph(new Run(string.Format("REGISTROS: {0}", obj.Count))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); tb.RowGroups.Add(rg); Paragraph p = new Paragraph(); p.Padding = new Thickness(5); TableRow header = new TableRow(); rg.Rows.Add(pheader); rg.Rows.Add(header); rg.Foreground = Brushes.Black; //rw2.Background = bgc1; header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run(""))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("NOME"))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("CARGO"))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("SECRETARIA"))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("SETOR"))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); //header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("ASSINATURA"))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(1, 0, 0, 0), BorderBrush = Brushes.Black }); int alt = 0; if (obj != null) { foreach (Avaliacoes a in obj) { TableRow row = new TableRow(); rg.Foreground = Brushes.Black; rg.Rows.Add(row); row.Cells.Add(new TableCell(new Paragraph(new Run(a.Contador.ToString())) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); row.Cells.Add(new TableCell(new Paragraph(new Run(a.Servidor.Codigo + " - " + a.Servidor.Nome + "\n" + a.Servidor.Situacao + ", " + a.Servidor.AnoParAnoImpar + "\nAVALIAÇÃO: " + a.DataAvaliacao.ToShortDateString() + " PONTOS: " + a.Pontos + "\nRESULTADO: " + a.Resultado + " " + a.DescricaoResultado)) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); row.Cells.Add(new TableCell(new Paragraph(new Run(a.Servidor.Cargo)) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); row.Cells.Add(new TableCell(new Paragraph(new Run(a.Servidor.Secretaria)) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); row.Cells.Add(new TableCell(new Paragraph(new Run(a.Servidor.Setor)) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); //row.Cells.Add(new TableCell(new Paragraph(new Run("")) { Padding = new Thickness(5, 20, 5, 20) }) { BorderThickness = new Thickness(1, 1, 0, 0), BorderBrush = Brushes.Black }); /* * if (alt % 2 != 0) * row.Background = bgc1; */ alt++; } } flow.Blocks.Add(tb); /* * var lrodape = new Rectangle(); * lrodape.Stroke = new SolidColorBrush(Colors.Silver); * lrodape.StrokeThickness = 1; * lrodape.Height = 1; * lrodape.Width = double.NaN; * lrodape.Margin = new Thickness(0, 10, 0, 0); * * var lineBlock = new BlockUIContainer(lrodape); * flow.Blocks.Add(lineBlock); */ Paragraph r = new Paragraph(); r.Margin = new Thickness(0, 0, 0, 0); r.FontSize = 10; System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location); string version = fvi.FileVersion; //r.Inlines.Add(lrodape); r.Inlines.Add(new Run(AppDomain.CurrentDomain.FriendlyName.ToUpper())); r.Inlines.Add(new Run(" / V" + version + " / ")); r.Inlines.Add(new Bold(new Run(Accounts.AccountOn.Nome))); r.Inlines.Add(new Run(" / " + DateTime.Now.ToString("dd.MM.yyyy"))); r.Inlines.Add(new Run(" / " + DateTime.Now.ToLongTimeString())); flow.Blocks.Add(r); return(flow); }
/// <summary> /// Handle table header elements /// </summary> /// <param name="props">The element properties</param> private static void TableHeaderElement(ElementProperties props) { var g = new TableRowGroup(); props.Converter.AddToBlockContainer(g); g.SetResourceReference(TableRowGroup.StyleProperty, NamedStyle.TableHeaderRow); }
public void printDG(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, ""); } }
internal object BuildObjectTree() { IAddChild root; switch (_type) { case ElementType.Table: root = new Table(); break; case ElementType.TableRowGroup: root = new TableRowGroup(); break; case ElementType.TableRow: root = new TableRow(); break; case ElementType.TableCell: root = new TableCell(); break; case ElementType.Paragraph: root = new Paragraph(); break; case ElementType.Hyperlink: Hyperlink link = new Hyperlink(); link.NavigateUri = GetValue(NavigateUriProperty) as Uri; link.RequestNavigate += new RequestNavigateEventHandler(ClickHyperlink); AutomationProperties.SetHelpText(link, (String)this.GetValue(HelpTextProperty)); AutomationProperties.SetName(link, (String)this.GetValue(NameProperty)); root = link; break; default: Debug.Assert(false); root = null; break; } ITextPointer pos = ((ITextPointer)_start).CreatePointer(); while (pos.CompareTo((ITextPointer)_end) < 0) { TextPointerContext tpc = pos.GetPointerContext(LogicalDirection.Forward); if (tpc == TextPointerContext.Text) { root.AddText(pos.GetTextInRun(LogicalDirection.Forward)); } else if (tpc == TextPointerContext.EmbeddedElement) { root.AddChild(pos.GetAdjacentElement(LogicalDirection.Forward)); } else if (tpc == TextPointerContext.ElementStart) { object obj = pos.GetAdjacentElement(LogicalDirection.Forward); if (obj != null) { root.AddChild(obj); pos.MoveToNextContextPosition(LogicalDirection.Forward); pos.MoveToElementEdge(ElementEdge.BeforeEnd); } } pos.MoveToNextContextPosition(LogicalDirection.Forward); } return root; }
public FlowDocument Impression() { FlowDocument Doc = new FlowDocument(); Societe pS = Client.Societe; Doc.FontFamily = new FontFamily("Calibri"); Table Tprincipale; Table T; TableColumn C; TableRowGroup RgPrincipal; TableRowGroup Rg; TableRow R1; TableRow R2; TableRow R3; TableRow R4; TableRow R5; TableRow R6; TableRow R; TableRow Rtmp; TableCell Section; Paragraph Pr; TableCell Cl = null; Double FS = 13; FontWeight FW = FontWeights.Normal; Thickness TK = new Thickness(0, 0, 0, 10); TextAlignment TA = TextAlignment.Left; // Mise en page d'un paragraphe Action <Object> PrgThick = delegate(Object Chaine) { Pr = new Paragraph(new Run(Chaine.ToString())); Pr.FontSize = FS; Pr.FontWeight = FW; Pr.Margin = TK; Pr.TextAlignment = TA; Cl.Blocks.Add(Pr); }; Action <Object> Prg = delegate(Object Chaine) { Pr = new Paragraph(new Run(Chaine.ToString())); Pr.FontSize = FS; Pr.FontWeight = FW; Pr.TextAlignment = TA; Cl.Blocks.Add(Pr); }; Tprincipale = new Table(); Tprincipale.Padding = new Thickness(0); Tprincipale.Columns.Add(new TableColumn()); RgPrincipal = new TableRowGroup(); Tprincipale.RowGroups.Add(RgPrincipal); Doc.Blocks.Add(Tprincipale); //------------------------------------------- R1 = new TableRow(); RgPrincipal.Rows.Add(R1); Section = new TableCell(); Section.Padding = new Thickness(10); Section.BorderBrush = Brushes.Black; Section.BorderThickness = new Thickness(1); R1.Cells.Add(Section); T = new Table(); T.Padding = new Thickness(0); T.Margin = new Thickness(0); C = new TableColumn(); C.Width = new GridLength(20, GridUnitType.Star); T.Columns.Add(C); C = new TableColumn(); C.Width = new GridLength(10, GridUnitType.Star); T.Columns.Add(C); Rg = new TableRowGroup(); T.RowGroups.Add(Rg); R = new TableRow(); Rg.Rows.Add(R); Cl = new TableCell(); Cl.Padding = new Thickness(0, 0, 10, 0); FS = 24; FW = FontWeights.Bold; Prg(pS.Statut); FS = 16; TK = new Thickness(0, 0, 0, 10); PrgThick(pS.Denomination); FS = 13; Prg(pS.Adresse); PrgThick(pS.Cp + " " + pS.Ville); Prg(pS.Tel_Mobile); Prg(pS.Email); R.Cells.Add(Cl); Cl = new TableCell(); Cl.Padding = new Thickness(10, 0, 0, 0); Cl.BorderBrush = Brushes.Black; Cl.BorderThickness = new Thickness(1, 0, 0, 0); FS = 11; TK = new Thickness(0, 0, 0, 10); PrgThick(this.Date.ToString("dd/MM/yyyy")); FS = 16; TK = new Thickness(0, 0, 0, 20); PrgThick("Devis n° " + this.Ref); FS = 13; TK = new Thickness(0, 0, 0, 10); PrgThick(this.Adresse_Client.Intitule); Prg(this.Adresse_Client.Adresse); Prg(this.Adresse_Client.Cp + " " + this.Adresse_Client.Ville); R.Cells.Add(Cl); Section.Blocks.Add(T); //------------------------------------------- Rtmp = new TableRow(); RgPrincipal.Rows.Add(Rtmp); Section = new TableCell(); Section.Padding = new Thickness(0); Rtmp.Cells.Add(Section); //------------------------------------------ R2 = new TableRow(); RgPrincipal.Rows.Add(R2); Section = new TableCell(); Section.Padding = new Thickness(10); Section.BorderBrush = Brushes.Black; Section.BorderThickness = new Thickness(1); R2.Cells.Add(Section); Pr = new Paragraph(new Run("Objet :")); Pr.FontSize = 13; Pr.FontWeight = FontWeights.Bold; Pr.Margin = new Thickness(0, 0, 0, 2); Section.Blocks.Add(Pr); Pr = new Paragraph(new Run(this.Description)); Pr.FontSize = 13; Pr.FontWeight = FontWeights.Bold; Pr.Padding = new Thickness(10, 0, 0, 0); Section.Blocks.Add(Pr); if (!String.IsNullOrWhiteSpace(this.Info)) { R3 = new TableRow(); RgPrincipal.Rows.Add(R3); Section = new TableCell(); Section.Padding = new Thickness(10); Section.BorderBrush = Brushes.Black; Section.BorderThickness = new Thickness(1); R3.Cells.Add(Section); Pr = new Paragraph(new Run(this.Info)); Pr.FontSize = 13; Pr.FontWeight = FontWeights.Bold; Pr.Padding = new Thickness(10, 0, 0, 0); Section.Blocks.Add(Pr); } R4 = new TableRow(); RgPrincipal.Rows.Add(R4); Section = new TableCell(); Section.Padding = new Thickness(10); Section.BorderBrush = Brushes.Black; Section.BorderThickness = new Thickness(1); R4.Cells.Add(Section); foreach (Poste P in this.ListePoste) { if (!P.Statut) { continue; } Pr = new Paragraph(new Run(P.Titre)); Pr.FontSize = 16; Pr.FontWeight = FontWeights.Bold; Pr.TextDecorations = TextDecorations.Underline; Pr.Margin = new Thickness(0, 0, 0, 5); Section.Blocks.Add(Pr); T = new Table(); T.Padding = new Thickness(0); T.Margin = new Thickness(0, 0, 0, 30); C = new TableColumn(); C.Width = new GridLength(40, GridUnitType.Star); T.Columns.Add(C); C = new TableColumn(); C.Width = new GridLength(15, GridUnitType.Star); T.Columns.Add(C); Rg = new TableRowGroup(); T.RowGroups.Add(Rg); R = new TableRow(); Rg.Rows.Add(R); Cl = new TableCell(); Cl.Padding = new Thickness(10, 0, 10, 0); FS = 13; FW = FontWeights.Normal; TK = new Thickness(0, 0, 0, 5); Prg(P.Description); R.Cells.Add(Cl); Cl = new TableCell(); Cl.Padding = new Thickness(10, 0, 0, 0); Cl.BorderBrush = Brushes.Black; Cl.BorderThickness = new Thickness(1, 0, 0, 0); Cl.TextAlignment = TextAlignment.Right; FS = 13; FW = FontWeights.Normal; TK = new Thickness(0, 0, 0, 5); TA = TextAlignment.Right; if (P.Qte != 1) { String pUnite = P.Unite; if (!String.IsNullOrWhiteSpace(pUnite)) { pUnite = "\\" + pUnite; } Prg(DicIntitules.Intitule("Poste", "Qte") + " : " + P.Qte + " " + P.Unite); Prg(DicIntitules.Intitule("Poste", "Prix_Unitaire") + " : " + P.Prix_Unitaire + " " + DicIntitules.Unite("Poste", "Prix_Unitaire") + pUnite); } FS = 15; FW = FontWeights.Bold; if (P.Qte != 1) { Prg("Total : " + P.Prix_Ht + " " + DicIntitules.Unite("Poste", "Prix_Ht")); } else { Prg(P.Prix_Ht + " " + DicIntitules.Unite("Poste", "Prix_Ht")); } TA = TextAlignment.Left; Cl.Blocks.Add(Pr); R.Cells.Add(Cl); Section.Blocks.Add(T); } R5 = new TableRow(); RgPrincipal.Rows.Add(R5); Section = new TableCell(); Section.Padding = new Thickness(10); Section.BorderBrush = Brushes.Black; Section.BorderThickness = new Thickness(1); R5.Cells.Add(Section); T = new Table(); T.Padding = new Thickness(0); T.Margin = new Thickness(0); C = new TableColumn(); C.Width = new GridLength(20, GridUnitType.Star); T.Columns.Add(C); C = new TableColumn(); C.Width = new GridLength(10, GridUnitType.Star); T.Columns.Add(C); C = new TableColumn(); C.Width = new GridLength(5, GridUnitType.Star); T.Columns.Add(C); Rg = new TableRowGroup(); T.RowGroups.Add(Rg); R = new TableRow(); Rg.Rows.Add(R); Cl = new TableCell(); Cl.Padding = new Thickness(0, 0, 10, 0); if (!String.IsNullOrWhiteSpace(this.Conditions)) { FS = 16; FW = FontWeights.Bold; TK = new Thickness(0, 0, 0, 5); TA = TextAlignment.Left; PrgThick("Modalités de règlement : "); FS = 13; FW = FontWeights.Bold; TK = new Thickness(0, 0, 0, 5); Prg(this.Conditions); if (this.Acompte != 0) { Pr = new Paragraph(new Run("Acompte de : " + this.Acompte + DicIntitules.Unite("Devis", "Acompte"))); Pr.FontSize = 13; Pr.FontWeight = FontWeights.Bold; Cl.Blocks.Add(Pr); } } R.Cells.Add(Cl); Cl = new TableCell(); Cl.Padding = new Thickness(10, 0, 0, 0); Cl.BorderBrush = Brushes.Black; Cl.BorderThickness = new Thickness(1, 0, 0, 0); FS = 15; FW = FontWeights.Bold; TK = new Thickness(0, 0, 0, 10); TA = TextAlignment.Left; PrgThick(DicIntitules.Intitule("Devis", "Prix_Ht")); PrgThick(DicIntitules.Intitule("Devis", "Tva_Pct") + " " + this.Tva_Pct + DicIntitules.Unite("Devis", "Tva_Pct")); PrgThick(DicIntitules.Intitule("Devis", "Prix_Ttc")); R.Cells.Add(Cl); Cl = new TableCell(); Cl.Padding = new Thickness(10, 0, 0, 0); Cl.BorderBrush = Brushes.Black; Cl.BorderThickness = new Thickness(0); TA = TextAlignment.Right; PrgThick(this.Prix_Ht + DicIntitules.Unite("Devis", "Prix_Ht")); PrgThick(this.Tva + DicIntitules.Unite("Devis", "Tva")); PrgThick(this.Prix_Ttc + DicIntitules.Unite("Devis", "Prix_Ttc")); R.Cells.Add(Cl); Section.Blocks.Add(T); //------------------------------------------ R6 = new TableRow(); RgPrincipal.Rows.Add(R6); Section = new TableCell(); Section.Padding = new Thickness(10); Section.BorderBrush = Brushes.Black; Section.BorderThickness = new Thickness(1); R6.Cells.Add(Section); Pr = new Paragraph(new Run("BON POUR ACCORD, DATE ET SIGNATURE :")); Pr.FontSize = 16; Pr.FontWeight = FontWeights.Bold; Pr.Margin = new Thickness(0, 0, 0, 50); Section.Blocks.Add(Pr); Pr = new Paragraph(new Run(pS.Pied)); Pr.FontSize = 13; Pr.TextAlignment = TextAlignment.Center; Section.Blocks.Add(Pr); //------------------------------------------- return(Doc); }
public Table GetHealTable() { var threatTable = new Table(); threatTable.CellSpacing = 0; threatTable.Columns.Add(new TableColumn()); threatTable.Columns.Add(new TableColumn()); threatTable.Columns.Add(new TableColumn()); threatTable.Columns.Add(new TableColumn()); var headerGroup = new TableRowGroup(); headerGroup.Rows.Add(new TableRow()); headerGroup.Rows[0].FontWeight = FontWeights.Bold; var headerRow = headerGroup.Rows[0]; headerRow.Cells.Add(new TableCell(new Paragraph(new Run("Skill")))); headerRow.Cells.Add(new TableCell(new Paragraph(new Run("Count")))); headerRow.Cells.Add(new TableCell(new Paragraph(new Run("Heal")))); headerRow.Cells.Add(new TableCell(new Paragraph(new Run("Total Heal %")))); headerRow.Cells.Add(new TableCell(new Paragraph(new Run("Overheal")))); headerRow.Cells.Add(new TableCell(new Paragraph(new Run("Overheal %")))); threatTable.RowGroups.Add(headerGroup); var rowGroup = new TableRowGroup(); var totalHeal = HealsGiven; var totalOverheal = Overheal; foreach (var item in HealRecordsBySkill.OrderByDescending(records => records.Sum(record => record.CalculateOverheal()))) { var row = new TableRow(); row.Cells.Add(new TableCell(new Paragraph(new Run(item.Key)))); row.Cells.Add(new TableCell(new Paragraph(new Run(item.Count().ToString())))); row.Cells.Add(new TableCell(new Paragraph(new Run(item.Sum(record => record.Quantity.Value).ToString())))); row.Cells.Add(new TableCell(new Paragraph(new Run(item.Sum(record => (double)record.Quantity.Value / totalHeal).ToString("0.##%"))))); row.Cells.Add(new TableCell(new Paragraph(new Run(item.Sum(record => record.CalculateOverheal()).ToString())))); row.Cells.Add(new TableCell(new Paragraph(new Run( (item.Sum(record => (double)record.CalculateOverheal())/item.Sum(record => record.Quantity.Value)).ToString("0.##%"))))); rowGroup.Rows.Add(row); } rowGroup.Rows.Add(new TableRow()); threatTable.RowGroups.Add(rowGroup); return threatTable; }
/// <summary> /// Creates the report FlowDocument using the attendance records /// </summary> /// <param name="records"></param> /// <returns></returns> private FlowDocument GetFlowDocument(List <CACCCheckInDb.AttendanceWithDetail> records) { const int TableColumnCount = 3; FlowDocument flowDoc = new FlowDocument(); flowDoc.Background = this.FindResource("ReportBackground") as Brush; Table table = new Table(); table.Columns.Add(new TableColumn() { Width = GridLength.Auto }); table.Columns.Add(new TableColumn()); table.Columns.Add(new TableColumn()); // Create and add an empty TableRowGroup to hold the table's Rows. table.RowGroups.Add(new TableRowGroup()); // To be used to alias the current working row for easy reference. TableRow currentRow; string reportTitle = "Class Attendance"; if (0 != records.Count) { string person = String.Format("{0} {1}", records[0].FirstName, records[0].LastName); if (AttendanceDate.SelectedDate.HasValue) { reportTitle = String.Format("Attendance For {0} on {1}", person, AttendanceDate.SelectedDate.Value.ToShortDateString()); } else { reportTitle = String.Format("Attendance For {0}", person); } } // Add the cross image row currentRow = new TableRow(); Image crossImage = new Image(); crossImage.Stretch = Stretch.Fill; crossImage.Source = new BitmapImage(new Uri("pack://application:,,,/Infrastructure;component/images/TCACC_Logo_CrossOnly.png")); crossImage.Height = 50; crossImage.Width = 50; currentRow.Cells.Add(new TableCell(new BlockUIContainer(crossImage))); currentRow.Cells[0].ColumnSpan = TableColumnCount; table.RowGroups[0].Rows.Add(currentRow); // Add the title row currentRow = new TableRow(); currentRow.Cells.Add(new TableCell(new Paragraph(new Underline(new Run(reportTitle))))); currentRow.Cells[0].ColumnSpan = TableColumnCount; currentRow.Cells[0].Style = this.FindResource("ReportTitle") as Style; table.RowGroups[0].Rows.Add(currentRow); // Add the 'created on' row currentRow = new TableRow(); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Created on " + DateTime.Today.ToShortDateString())))); currentRow.Cells[0].FontSize = 14; currentRow.Cells[0].TextAlignment = TextAlignment.Center; currentRow.Cells[0].ColumnSpan = TableColumnCount; table.RowGroups[0].Rows.Add(currentRow); currentRow = new TableRow(); currentRow.Cells.Add(new TableCell()); currentRow.Cells[0].ColumnSpan = TableColumnCount; currentRow.Cells[0].Padding = new Thickness(0, 0, 0, 10); table.RowGroups[0].Rows.Add(currentRow); if (0 == records.Count) { currentRow = new TableRow(); currentRow.Cells.Add(new TableCell(new Paragraph( new Run("No records found matching criteria")))); currentRow.Cells[0].ColumnSpan = TableColumnCount; currentRow.Cells[0].TextAlignment = TextAlignment.Center; table.RowGroups[0].Rows.Add(currentRow); } else { TableRowGroup tableRowGroup = new TableRowGroup(); // Create and add an empty TableRowGroup to hold the table's Rows. table.RowGroups.Add(tableRowGroup); // Add the table header row currentRow = new TableRow(); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Date")))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Class")))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Security Code")))); currentRow.Cells[0].Style = this.FindResource("ReportTableHeader") as Style; currentRow.Cells[1].Style = this.FindResource("ReportTableHeader") as Style; currentRow.Cells[2].Style = this.FindResource("ReportTableHeader") as Style; tableRowGroup.Rows.Add(currentRow); // Add the line under table header row currentRow = new TableRow(); currentRow.Cells.Add(new TableCell()); currentRow.Cells[0].ColumnSpan = TableColumnCount; currentRow.Cells[0].BorderThickness = new Thickness(0, 1, 0, 0); currentRow.Cells[0].BorderBrush = Brushes.Maroon; tableRowGroup.Rows.Add(currentRow); // Group the records by class and order by class name IEnumerable <IGrouping <string, CACCCheckInDb.AttendanceWithDetail> > classGroups = records.GroupBy(r => r.ClassName).OrderBy(r => r.Key); foreach (IGrouping <string, CACCCheckInDb.AttendanceWithDetail> classGroup in classGroups) { tableRowGroup = new TableRowGroup(); // Create and add an empty TableRowGroup to hold the table's Rows. table.RowGroups.Add(tableRowGroup); // Now enumerate through this grouping of // CACCCheckInDb.AttendanceWithDetail records. foreach (CACCCheckInDb.AttendanceWithDetail record in classGroup.OrderByDescending(r => r.Date)) { currentRow = new TableRow(); currentRow.Cells.Add(new TableCell(new Paragraph(new Run(record.Date.ToShortDateString())))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run(record.ClassName)))); currentRow.Cells.Add(new TableCell(new Paragraph(new Run(record.SecurityCode.ToString())))); tableRowGroup.Rows.Add(currentRow); } } } flowDoc.Blocks.Add(table); return(flowDoc); }