public ObservableCollection <BarChart> Viabilidade(mReportViabilidade reports, bool periodo) { ObservableCollection <BarChart> _chart = new ObservableCollection <BarChart>(); _chart.Clear(); if (periodo) { List <KeyValuePair <string, int> > Viabilidade = new List <KeyValuePair <string, int> >(); List <KeyValuePair <string, int> > Atividades = new List <KeyValuePair <string, int> >(); List <KeyValuePair <string, int> > Bairro = new List <KeyValuePair <string, int> >(); List <KeyValuePair <string, int> > Situacao = new List <KeyValuePair <string, int> >(); foreach (KeyValuePair <string, int> x in reports.Viabilidade) { Viabilidade.Add(new KeyValuePair <string, int>(x.Key.ToUpper(), x.Value)); } foreach (KeyValuePair <string, int> x in reports.Atividades) { Atividades.Add(new KeyValuePair <string, int>(x.Key.ToUpper(), x.Value)); } foreach (KeyValuePair <string, int> x in reports.Bairro) { Bairro.Add(new KeyValuePair <string, int>(x.Key.ToUpper(), x.Value)); } foreach (KeyValuePair <string, int> x in reports.Situacao) { Situacao.Add(new KeyValuePair <string, int>(x.Key.ToUpper(), x.Value)); } if (Viabilidade.Count > 0) { BarChart bc = new BarChart(); bc.Title = string.Format("Periodo entre {0} e {1}", reports.Periodo[0], reports.Periodo[1]); bc.ItemsSource = Viabilidade; _chart.Add(bc); } if (Bairro.Count > 0) { BarChart bc = new BarChart(); bc.Title = string.Format("Viabilidade / Setores"); bc.ItemsSource = Bairro; _chart.Add(bc); } if (Atividades.Count > 0) { BarChart bc = new BarChart(); bc.Title = string.Format("Viabilidade / Atividades"); bc.ItemsSource = Atividades; _chart.Add(bc); } if (Situacao.Count > 0) { BarChart bc = new BarChart(); bc.Title = string.Format("Situação"); bc.ItemsSource = Situacao; _chart.Add(bc); } } return(_chart); }
private FlowDocument PreviewInTable(mReportViabilidade obj) { try { 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); #region Tabela 1 Table tb = new Table(); tb.CellSpacing = 0; tb.BorderThickness = new Thickness(0.5); tb.BorderBrush = Brushes.Black; foreach (KeyValuePair <string, int> x in obj.Viabilidade) { tb.Columns.Add(new TableColumn() { Width = GridLength.Auto }); } foreach (KeyValuePair <string, int> x in obj.Situacao) { tb.Columns.Add(new TableColumn() { Width = GridLength.Auto }); } 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("VIABILIDADES ENTRE O PERIODO DE {0} - {1}", Parametros()[0], Parametros()[1]))) { Padding = new Thickness(5) }) { ColumnSpan = obj.Viabilidade.Count + obj.Situacao.Count, BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); tb.RowGroups.Add(rg); TableRow header = new TableRow(); rg.Rows.Add(pheader); rg.Rows.Add(header); rg.Foreground = Brushes.Black; foreach (KeyValuePair <string, int> x in obj.Viabilidade) { header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run(x.Key))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); } foreach (KeyValuePair <string, int> x in obj.Situacao) { header.Cells.Add(new TableCell(new Paragraph(new Bold(new Run(x.Key))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); } if (obj != null) { TableRow row = new TableRow(); rg.Foreground = Brushes.Black; rg.Rows.Add(row); foreach (KeyValuePair <string, int> x in obj.Viabilidade) { row.Cells.Add(new TableCell(new Paragraph(new Run(x.Value.ToString())) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); } foreach (KeyValuePair <string, int> x in obj.Situacao) { row.Cells.Add(new TableCell(new Paragraph(new Run(x.Value.ToString())) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); } } flow.Blocks.Add(tb); #endregion #region Tabela 2 Table tb1 = new Table(); tb1.Foreground = Brushes.Black; tb1.CellSpacing = 0; tb1.BorderThickness = new Thickness(0.5); tb1.BorderBrush = Brushes.Black; tb1.Columns.Add(new TableColumn() { Width = GridLength.Auto }); tb1.Columns.Add(new TableColumn() { Width = new GridLength(100) }); TableRowGroup rg1 = new TableRowGroup(); rg1.Foreground = Brushes.Black; tb1.RowGroups.Add(rg1); TableRow hcnae2 = new TableRow(); rg1.Rows.Add(hcnae2); hcnae2.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("ATIVIDADE"))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); hcnae2.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("..."))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); if (obj != null) { foreach (KeyValuePair <string, int> x in obj.Atividades) { TableRow row = new TableRow(); rg1.Foreground = Brushes.Black; rg1.Rows.Add(row); row.Cells.Add(new TableCell(new Paragraph(new Run(x.Key)) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); row.Cells.Add(new TableCell(new Paragraph(new Run(x.Value.ToString())) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); } } flow.Blocks.Add(tb1); #endregion #region Tabela 3 Table tb2 = new Table(); tb2.Foreground = Brushes.Black; tb2.CellSpacing = 0; tb2.BorderThickness = new Thickness(0.5); tb2.BorderBrush = Brushes.Black; tb2.Columns.Add(new TableColumn() { Width = GridLength.Auto }); tb2.Columns.Add(new TableColumn() { Width = new GridLength(100) }); TableRowGroup rg2 = new TableRowGroup(); tb2.RowGroups.Add(rg2); TableRow tbairro2 = new TableRow(); rg2.Rows.Add(tbairro2); tbairro2.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("BAIRROS"))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); tbairro2.Cells.Add(new TableCell(new Paragraph(new Bold(new Run("..."))) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); if (obj != null) { foreach (KeyValuePair <string, int> x in obj.Bairro) { TableRow row = new TableRow(); rg2.Foreground = Brushes.Black; rg2.Rows.Add(row); row.Cells.Add(new TableCell(new Paragraph(new Run(x.Key)) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); row.Cells.Add(new TableCell(new Paragraph(new Run(x.Value.ToString())) { Padding = new Thickness(5) }) { BorderThickness = new Thickness(0.5), BorderBrush = Brushes.Black }); } } flow.Blocks.Add(tb2); #endregion 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); } catch { return(new FlowDocument()); } }