public void Generate(IReportWriter writer) { if (doc == null) { return; } var document = view.DocumentViewer.Document; bool found = false; bool first = true; foreach (XElement change in doc.Root.Elements("change")) { string version = (string)change.Attribute("version"); if (string.IsNullOrEmpty(version)) { continue; } bool match = IsSameOrOlder(previousVersion, version); if (!found && match) { writer.WriteHeading("The following changes were already installed"); found = true; } if (first && !found) { writer.WriteHeading("The following changes are now available"); first = false; } string date = (string)change.Attribute("date"); writer.WriteSubHeading(version + " " + date); foreach (string line in change.Value.Split('\r', '\n')) { string trimmed = line.Trim(); if (!string.IsNullOrEmpty(trimmed)) { string brush = found ? "ListItemForegroundBrush" : "ListItemSelectedForegroundBrush"; FlowDocumentReportWriter fwriter = (FlowDocumentReportWriter)writer; Paragraph p = fwriter.WriteParagraph(trimmed, FontStyles.Normal, FontWeights.Normal, AppTheme.Instance.GetThemedBrush(brush), null); p.TextIndent = 20; p.Margin = new Thickness(0); p.Padding = new Thickness(0); } } } if (installButton && !HasLatestVersion()) { document.Blocks.InsertAfter(document.Blocks.FirstBlock, new BlockUIContainer(CreateInstallButton())); } }
public void Generate(IReport report) { FlowDocumentReportWriter writer = new FlowDocumentReportWriter(this.Viewer.Document); report.Generate(writer); this.writer = writer; ResetExpandAllToggleButton(); }
private void AddHyperlink(Category c, IReportWriter writer) { FlowDocumentReportWriter fw = (FlowDocumentReportWriter)writer; Paragraph p = fw.CurrentParagraph; p.Tag = c; p.PreviewMouseLeftButtonDown += OnReportCellMouseDown; p.Cursor = Cursors.Arrow; p.SetResourceReference(Paragraph.ForegroundProperty, "HyperlinkForeground"); }
public void Generate(IReport report) { this.Viewer.Document.Blocks.Clear(); Paragraph p = new Paragraph(); p.Inlines.Add(new Run() { Text = "Loading..." }); p.FontSize = 18; this.Viewer.Document.Blocks.Add(p); this.Viewer.Dispatcher.BeginInvoke(new Action(() => { FlowDocumentReportWriter writer = new FlowDocumentReportWriter(this.Viewer.Document); report.Generate(writer); this.writer = writer; ResetExpandAllToggleButton(); }), DispatcherPriority.ContextIdle); }
public void Generate(IReport report) { this.report = report; this.Viewer.Document.Blocks.Clear(); Paragraph p = new Paragraph(); p.Inlines.Add(new Run() { Text = "Loading..." }); p.FontSize = 18; this.Viewer.Document.Blocks.Add(p); this.Viewer.Dispatcher.BeginInvoke(new Action(() => { var pixelsPerDip = VisualTreeHelper.GetDpi(this).PixelsPerDip; FlowDocumentReportWriter writer = new FlowDocumentReportWriter(this.Viewer.Document, pixelsPerDip); report.Generate(writer); this.writer = writer; ResetExpandAllToggleButton(); OnAfterViewStateChanged(); }), DispatcherPriority.ContextIdle); }
public void SaveReport(string fileName) { string ext = Path.GetExtension(fileName); if (ext == null) { return; } ext = ext.ToLower(); var r = this.CreateReport(fileName); var reportStyle = new ReportStyle(); switch (ext) { case ".txt": using (var s = File.Create(fileName)) { using (var w = new TextReportWriter(s)) { r.Write(w); } } break; case ".html": using (var s = File.Create(fileName)) { using (var w = new HtmlReportWriter(s)) { w.WriteReport(r, reportStyle); } } break; case ".pdf": using (var w = new PdfReportWriter(fileName)) { w.WriteReport(r, reportStyle); } break; case ".rtf": using (var w = new RtfReportWriter(fileName)) { w.WriteReport(r, reportStyle); } break; case ".tex": using (var s = File.Create(fileName)) { using (var w = new LatexReportWriter(s, "Example report", "oxyplot")) { w.WriteReport(r, reportStyle); } } break; case ".xps": using (var w = new FlowDocumentReportWriter()) { w.WriteReport(r, reportStyle); w.Save(fileName); } break; case ".docx": using (var w = new WordDocumentReportWriter(fileName)) { w.WriteReport(r, reportStyle); w.Save(); } break; } }
public override void Generate(IReportWriter writer) { this.transactionsByCategory = new Dictionary <Category, List <Transaction> >(); FlowDocumentReportWriter fwriter = (FlowDocumentReportWriter)writer; writer.WriteHeading("Select year for report: "); ICollection <Transaction> transactions = this.myMoney.Transactions.GetAllTransactionsByDate(); int startYear = year; int lastYear = year; Transaction first = transactions.FirstOrDefault(); if (first != null) { startYear = first.Date.Year; } Transaction last = transactions.LastOrDefault(); if (last != null) { lastYear = last.Date.Year; } Paragraph heading = fwriter.CurrentParagraph; ComboBox byYearCombo = new ComboBox(); byYearCombo.Margin = new System.Windows.Thickness(5, 0, 0, 0); int selected = -1; for (int i = startYear; i <= lastYear; i++) { if (i == this.year) { selected = i; } byYearCombo.Items.Add(i); } byYearCombo.SelectedItem = selected != -1 ? selected : lastYear; byYearCombo.SelectionChanged += OnYearChanged; byYearCombo.Margin = new Thickness(10, 0, 0, 0); heading.Inlines.Add(new InlineUIContainer(byYearCombo)); bool empty = true; foreach (TaxForm form in taxCategories.GetForms()) { if (GenerateForm(form, writer, transactions)) { empty = false; } } if (empty) { writer.WriteParagraph("You have not associated any of your categories with Tax Categories. See the Category Properties dialog for more information."); } writer.WriteParagraph("Generated on " + DateTime.Today.ToLongDateString(), System.Windows.FontStyles.Italic, System.Windows.FontWeights.Normal, System.Windows.Media.Brushes.Gray); }
public void Generate(IReportWriter writer) { if (doc == null) { return; } var document = view.DocumentViewer.Document; bool found = false; bool first = true; var style = new Style(typeof(Paragraph)); style.Setters.Add(new Setter(Paragraph.BackgroundProperty, Brushes.Teal)); style.Setters.Add(new Setter(Paragraph.ForegroundProperty, Brushes.White)); style.Setters.Add(new Setter(Paragraph.FontSizeProperty, 18.0)); document.Resources.Remove("HeadingStyle"); document.Resources.Add("HeadingStyle", style); foreach (XElement change in doc.Root.Elements("change")) { string version = (string)change.Attribute("version"); if (string.IsNullOrEmpty(version)) { continue; } bool match = IsSameOrOlder(previousVersion, version); if (!found && match) { writer.WriteHeading("The following changes were already installed"); found = true; } if (first && !found) { writer.WriteHeading("The following changes are now available"); first = false; } string date = (string)change.Attribute("date"); writer.WriteSubHeading(version + " " + date); foreach (string line in change.Value.Split('\r', '\n')) { string trimmed = line.Trim(); if (!string.IsNullOrEmpty(trimmed)) { FlowDocumentReportWriter fwriter = (FlowDocumentReportWriter)writer; Paragraph p = fwriter.WriteParagraph(trimmed, FontStyles.Normal, FontWeights.Normal, found ? Brushes.Gray : Brushes.Black, 11); p.TextIndent = 20; p.Margin = new Thickness(0); p.Padding = new Thickness(0); } } } if (installButton && !HasLatestVersion()) { document.Blocks.InsertAfter(document.Blocks.FirstBlock, new BlockUIContainer(CreateInstallButton())); } }
public override void Generate(IReportWriter writer) { FlowDocumentReportWriter fwriter = (FlowDocumentReportWriter)writer; writer.WriteHeading("Tax Report For "); int startYear = year; int lastYear = year; ICollection <Transaction> transactions = this.money.Transactions.GetAllTransactionsByDate(); Transaction first = transactions.FirstOrDefault(); if (first != null) { startYear = first.Date.Year; } Transaction last = transactions.LastOrDefault(); if (last != null) { lastYear = last.Date.Year; } Paragraph heading = fwriter.CurrentParagraph; ComboBox byYearCombo = new ComboBox(); byYearCombo.Margin = new System.Windows.Thickness(5, 0, 0, 0); int selected = -1; for (int i = startYear; i <= lastYear; i++) { if (i == this.year) { selected = i; } byYearCombo.Items.Add(i); } byYearCombo.SelectedItem = selected != -1 ? selected : lastYear; byYearCombo.SelectionChanged += OnYearChanged; byYearCombo.Margin = new Thickness(10, 0, 0, 0); heading.Inlines.Add(new InlineUIContainer(byYearCombo)); /* * <StackPanel Margin="10,5,10,5" Grid.Row="2" Orientation="Horizontal"> * <TextBlock Text="Consolidate securities by: " Background="Transparent"/> * <ComboBox x:Name="ConsolidateSecuritiesCombo" SelectedIndex="0"> * <ComboBoxItem>Date Acquired</ComboBoxItem> * <ComboBoxItem>Date Sold</ComboBoxItem> * </ComboBox> * </StackPanel> * <CheckBox Margin="10,5,10,5" x:Name="CapitalGainsOnlyCheckBox" Grid.Row="3">Capital Gains Only</CheckBox> */ ComboBox consolidateCombo = new ComboBox(); consolidateCombo.Items.Add("Date Acquired"); consolidateCombo.Items.Add("Date Sold"); consolidateCombo.SelectedIndex = this.consolidateOnDateSold ? 1 : 0; consolidateCombo.SelectionChanged += OnConsolidateComboSelectionChanged; writer.WriteParagraph("Consolidate securities by: "); Paragraph prompt = fwriter.CurrentParagraph; prompt.Margin = new Thickness(0, 0, 0, 4); prompt.Inlines.Add(new InlineUIContainer(consolidateCombo)); CheckBox checkBox = new CheckBox(); checkBox.Content = "Capital Gains Only"; checkBox.IsChecked = this.capitalGainsOnly; checkBox.Checked += OnCapitalGainsOnlyChanged; checkBox.Unchecked += OnCapitalGainsOnlyChanged; writer.WriteParagraph(""); Paragraph checkBoxParagraph = fwriter.CurrentParagraph; checkBoxParagraph.Inlines.Add(new InlineUIContainer(checkBox)); if (!capitalGainsOnly) { // find all tax related categories and summarize accordingly. GenerateCategories(writer); } GenerateCapitalGains(writer); FlowDocument document = view.DocumentViewer.Document; document.Blocks.InsertAfter(document.Blocks.FirstBlock, new BlockUIContainer(CreateExportTxfButton())); }