/// <summary> /// Called to calculate the size that this section requires on /// the next call to Print. This method will be called exactly once /// prior to each call to Print. It must update the values Size and /// Continued of the ReportSection base class. /// </summary> /// <param name="reportDocument">The parent ReportDocument that is printing.</param> /// <param name="g">Graphics object to print on.</param> /// <param name="bounds">Bounds of the area to print within.</param> /// <returns>Size.Width and Size.Height are for the largest sub-section /// in each direction, fits is true if any section fits, and continued /// is true if any section is continued.</returns> protected override SectionSizeValues DoCalcSize( ReportDocument reportDocument, Graphics g, Bounds bounds ) { SectionSizeValues retval = new SectionSizeValues(); if (this.sections.Count == 0) { retval.Fits = true; } else { // TODO: get rid of enumerator, eventually hide sections foreach (ReportSection section in this.sections) { section.CalcSize (reportDocument, g, bounds); retval.RequiredSize.Height = Math.Max ( retval.RequiredSize.Height, section.Size.Height); retval.RequiredSize.Width = Math.Max ( retval.RequiredSize.Width, section.Size.Width); if (section.Continued) { retval.Continued = true; } if (section.Fits) { retval.Fits = true; } } } return retval; }
/// <summary> /// A function that should return the string to be printed on /// this call to Print() /// </summary> /// <param name="reportDocument">The parent ReportDocument</param> /// <returns>A string to be printed on this page</returns> protected override string GetText(ReportDocument reportDocument) { string text; int pageNumber = reportDocument.GetCurrentPage(); if (pageNumber == 1) { text = TextFirstPage; } else if (pageNumber % 2 == 0) { text = TextEvenPage; } else { text = TextOddPage; } if (text == null) { if (this.Text == null) { text = String.Empty; } else { text = this.Text; } } text = text.Replace("%p", pageNumber.ToString()); text = text.Replace("%tp", reportDocument.TotalPages.ToString()); // TODO: Raise event for formatting text??? return text; }
/// <summary> /// Called to actually print this section. /// The DoCalcSize method will be called exactly once prior to each /// call of DoPrint. /// It should obey the value or Size and Continued as set by /// DoCalcSize(). /// </summary> /// <param name="reportDocument">The parent ReportDocument that is printing.</param> /// <param name="g">Graphics object to print on.</param> /// <param name="bounds">Bounds of the area to print within.</param> protected override void DoPrint( ReportDocument reportDocument, Graphics g, Bounds bounds ) { base.DoPrint(reportDocument, g, bounds); this.sectionIndex = 0; Reset(); }
public DialogPrint(string title, DataGrid dataGrid) { InitializeComponent(); // Required for Windows Form Designer support textBox1.Text = title; _reportDocument = new ReportDocument(); _datagridMaker = new PrintDataGrid(dataGrid); _datagridMaker.AddHeader(title); _datagridMaker.MakeDocument(_reportDocument); printControlToolBar1.Document = _datagridMaker.ReportDocument; }
public void MakeDocument(ReportDocument reportDocument) { TextStyle.ResetStyles(); TextStyle.Normal.Size = 7.5f; TextStyle.Heading1.Size = 16; TextStyle.Heading1.Bold = false; TextStyle.TableHeader.BackgroundBrush = Brushes.Gray; TextStyle.TableHeader.Brush = Brushes.White; TextStyle.TableHeader.MarginNear = 0.1f; TextStyle.TableHeader.MarginFar = 0.1f; TextStyle.TableHeader.MarginTop = 0.05f; TextStyle.TableHeader.MarginBottom = 0.05f; TextStyle.TableRow.MarginNear = 0.1f; TextStyle.TableRow.MarginFar = 0.1f; TextStyle.TableRow.MarginTop = 0.05f; ReportBuilder builder = new ReportBuilder(reportDocument); builder.StartLinearLayout(Direction.Vertical); Pen innerPen = new Pen(Color.Green, 0.02f); //DataView dv = SampleReportMaker1.GetDataView(); DataView dv = _dt.DefaultView; builder.AddPageHeader("Người tạo: Đỗ Đình Vương", String.Empty, "Trang %p"); builder.AddPageHeaderLine(); builder.AddText(_reportName); builder.AddText("àd"); builder.PageHeader.MarginRight = 00; builder.PageHeader.UseFullWidth = true; builder.CurrentContainer.UseFullWidth = true; //builder.AddText("Table with lines using default lines\n"); // Following line sets up the pen used for lins for tables builder.DefaultTablePen = reportDocument.ThinPen; builder.AddTable(dv, true); builder.CurrentSection.HorizontalAlignment = HorizontalAlignment.Left; foreach (DataColumn column in _dt.Columns) { //builder.AddColumn(column.ColumnName, column.ColumnName, 1.8f, true, true); builder.AddColumn(column.ColumnName, column.ColumnName, 1f, true, true); } builder.CurrentDocument.Body.UseFullWidth = true; builder.FinishLinearLayout(); }
private void btPrintAutomailReport_Click(object sender, EventArgs e) { try { DateTime dtDate; int iFontSize; if (!DateTime.TryParse(txtReportStartDate.Text, out dtDate)) { MessageBox.Show("Report Start Date is invalid!"); return; } if (!DateTime.TryParse(txtReportEndDate.Text, out dtDate)) { MessageBox.Show("Report End Date is invalid!"); return; } if (!int.TryParse(txtReportFontSize.Text, out iFontSize)) { MessageBox.Show("Report Font Size is invalid!"); return; } var reportDocument1 = new ReportDocument {ReportMaker = new AutomailReport()}; reportDocument1.StartDate = txtReportStartDate.Text; reportDocument1.EndDate = txtReportEndDate.Text; reportDocument1.FontSize = txtReportFontSize.Text; var printControl = new PrintControl {Document = reportDocument1}; printControl.Preview(sender, e); } catch (Exception ex) { //var logger = new ExceptionLogger(); //logger.AddLogger(new EventLogLogger()); //logger.LogException(ex, "Could not print Automail Report!"); //throw new Exception(ex.Message, ex); } }
public doPrinting() { reportDocument1 = new ReportPrinting.ReportDocument(); reportDocument1.Body = null; reportDocument1.PageFooter = null; reportDocument1.PageHeader = null; reportDocument1.DocumentUnit = System.Drawing.GraphicsUnit.Millimeter; // // printControlToolBar1 // printControlToolBar1.Dock = System.Windows.Forms.DockStyle.Top; printControlToolBar1.Document = reportDocument1; printControlToolBar1.Location = new System.Drawing.Point(0, 0); printControlToolBar1.Name = "printControlToolBar1"; printControlToolBar1.ClientSize = new System.Drawing.Size(1024,768); printControlToolBar1.TabIndex = 2; //printControlToolBar1.Load += new System.EventHandler(printControlToolBar1_Load); //pintControlToolBar1.Printing += new System.EventHandler(printControlToolBar1_Printing); }
public void MakeDocument(ReportDocument reportDocument) { // Always reset the text styles if you have multiple methods that // set them TextStyle.ResetStyles(); SectionBox box; LinearSections contents; //TextStyle.Normal.BackgroundBrush = Brushes.Beige; //Szamla iSzamla = new Szamla(_SzamlaId); // Create a ReportBuilder object that assists with building a report ReportBuilder builder = new ReportBuilder(reportDocument); builder.CurrentDocument.DocumentUnit = GraphicsUnit.Millimeter; // Before adding sections, a layout must be started. // We are using a linear layout - vertically, which means // each new section starts below the last one. builder.CurrentDocument.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", DEFS.MMtoInch(210), DEFS.MMtoInch(297)); builder.CurrentDocument.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(DEFS.MMtoInch(8), DEFS.MMtoInch(8), DEFS.MMtoInch(8), DEFS.MMtoInch(8)); builder.HorizLineMargins = 0.2f; builder.StartLinearLayout(Direction.Vertical); builder.AddPageHeader("ALL-IN Cafe", String.Empty, DateTime.Now.ToLongDateString()); #region fejlec builder.StartLayeredLayout(false, false); // Add various text sections in different headings box = new SectionBox(); box.Width = 80; box.Height = 10; box.OffsetLeft = 0; box.OffsetTop = 0; //box.Border. //box.Background = Brushes.Ivory; contents = new LinearSections(); contents.AddSection(new SectionText((string)Syspar2.GetValue(ParamCodes.CEG_NEV), TextStyle.Heading1)); contents.AddSection(new SectionText((string)Syspar2.GetValue(ParamCodes.CEG_CIM), TextStyle.Normal)); box.AddSection(contents); builder.AddSection(box); // Logo box = new SectionBox(); box.Width = 40; box.Height = 10; box.OffsetLeft = 80; box.OffsetTop = 0; box.HorizontalAlignment = HorizontalAlignment.Center; // box.VerticalAlignment = VerticalAlignment.Bottom; //box.Border = reportDocument.NormalPen; SectionImage image = new SectionImage(global::GUI.Properties.Resources.logo); //image.Transparency = 50; //image.PreserveAspectRatio = false; box.AddSection(image); builder.AddSection(box); // Finish a layout that we started // builder.FinishLayeredLayout(); // builder.FinishLayeredLayout(); #endregion builder.AddText(" "); builder.AddText(" "); builder.AddText(" "); builder.AddText("Leltározási ív"); #region Összes eladás DataView dv = ReportData.getLeltarIv(_fej); builder.DefaultTablePen = null; builder.AddTable(dv, true, 100); builder.Table.InnerPenHeaderBottom = reportDocument.NormalPen; builder.Table.InnerPenRow = new Pen(Color.Gray, reportDocument.ThinPen.Width); builder.Table.OuterPenBottom = new Pen(Color.Gray, reportDocument.ThinPen.Width); builder.Table.DetailRowTextStyle.SizeDelta = 8; builder.Table.ShowSummaryRow = true; // 210 széles lehet. builder.AddColumn(dv.Table.Columns[0], "Cikk", 90, false, false, HorizontalAlignment.Left); builder.AddColumn(dv.Table.Columns[1], "Készlet mennyisége", 40, false, false, HorizontalAlignment.Right); builder.AddColumn(dv.Table.Columns[2], "Számolt mennyiség", 50, false, false, HorizontalAlignment.Right); builder.CurrentSection.HorizontalAlignment = HorizontalAlignment.Left; #endregion builder.FinishLinearLayout(); }
/// <summary> /// Sets the TextLayout rectangle to the correct size /// Also sets size, itFits, and continued of the base class /// </summary> /// <param name="doc">The parent ReportDocument</param> /// <param name="g">Graphics object</param> /// <param name="bounds">Bounds to draw within</param> /// <returns>SectionSizeValues</returns> SectionSizeValues SetTextSize(ReportDocument doc, Graphics g, Bounds bounds) { SectionSizeValues retval = new SectionSizeValues(); retval.Fits = true; // Find the height of the actual string + margins to be drawn SizeF requiredSize = g.MeasureString(textToPrint, textFont, textLayout.Size, GetStringFormat(), out charsFitted, out linesFitted); if (charsFitted < textToPrint.Length) { // it doesn't all fit. if (this.KeepTogether) { // try on the next page. // HACK: This is bad if the whole section doesn't // ever fit on a page, since it will end up in an infinite loop. retval.Fits = false; charsFitted = 0; linesFitted = 0; return retval; } retval.Continued = true; } if (this.HorizontalAlignment != HorizontalAlignment.Left) requiredSize.Width = textLayout.Size.Width; // Get a new rectangle aligned within the bounds and margins textLayout = bounds.GetRectangleF(requiredSize, this.HorizontalAlignment, this.VerticalAlignment); retval.RequiredSize = textLayout.Size; if (debugEnabled) { Console.WriteLine ("Layout for string '" + textToPrint + "' is " + textLayout); } return retval; }
/// <summary> /// Called to actually print this section. /// The DoCalcSize method will be called once prior to each /// call of DoPrint. /// DoPrint is not called if DoCalcSize sets fits to false. /// It should obey the values of Size and Continued as set by /// DoCalcSize(). /// </summary> /// <param name="reportDocument">The parent ReportDocument that is printing.</param> /// <param name="g">Graphics object to print on.</param> /// <param name="bounds">Bounds of the area to print within. /// These bounds already take the margins into account. /// </param> protected override void DoPrint( ReportDocument reportDocument, Graphics g, Bounds bounds ) { //g.TextRenderingHint = TextRenderingHint.AntiAlias; // while (this.printLineIndex < this.linesToPrint.Count) // { // LineToPrint line = this.linesToPrint[printLineIndex] as LineToPrint; foreach (LineToPrint line in linesToPrint) { bounds.Position.Y += line.Size.Height; line.Print (g, bounds.Position); this.printLineIndex++; } // SectionSizeValues results = DrawEditControl(g, bounds, false); // SetContinued (results.Continued); // SetFits (results.Fits); // SetSize (results.RequiredSize, bounds); }
/// <summary> /// Called to calculate the size that this section requires on /// the next call to Print. This method will be called once /// prior to each call to Print. /// </summary> /// <param name="reportDocument">The parent ReportDocument that is printing.</param> /// <param name="g">Graphics object to print on.</param> /// <param name="bounds">Bounds of the area to print within. /// The bounds passed already takes the margins into account - so you cannot /// print or do anything within these margins. /// </param> /// <returns>The values for RequireSize, Fits and Continues for this section.</returns> protected abstract SectionSizeValues DoCalcSize( ReportDocument reportDocument, Graphics g, Bounds bounds );
/// <summary> /// Method called to Calculate the size required for /// the next Print. Calling this method initializes /// the values Size and Continued. Once these values /// are initialized, further calls to CalcSize have /// no affect, unless ResetSize() is called. /// </summary> /// <param name="reportDocument">The parent ReportDocument that is printing.</param> /// <param name="g">Graphics object to print on.</param> /// <param name="bounds">Bounds of the area to print within.</param> public void CalcSize( ReportDocument reportDocument, Graphics g, Bounds bounds) { BeginPrint(g); if (this.requiresNonEmptyBounds && bounds.IsEmpty()) { this.fits = false; } else if (!this.sized) { // two default values this.sizingBounds = LimitBounds (bounds); SectionSizeValues vals = DoCalcSize(reportDocument, g, this.sizingBounds); SetSize (vals.RequiredSize, bounds); if (this.keepTogether && vals.Continued) { this.fits = false; } else { this.fits = vals.Fits; } this.continued = vals.Continued; this.sized = true; } }
/// <summary> /// Called to calculate the size that this section requires on /// the next call to Print. /// Simply returns the full size (up to MaxWidth and MaxHeight /// </summary> /// <param name="reportDocument">The parent ReportDocument that is printing.</param> /// <param name="g">Graphics object to print on.</param> /// <param name="bounds">Bounds of the area to print within.</param> /// <returns>size is the full size of the bounds given, /// fits is always true, and continued is always false from this /// routine. Note that DoPrint may change the values of all these. /// </returns> protected override SectionSizeValues DoCalcSize( ReportDocument reportDocument, Graphics g, Bounds bounds ) { SectionSizeValues retvals = new SectionSizeValues(); // assume worst-case size... retvals.RequiredSize = bounds.GetSizeF(); retvals.Fits = true; return retvals; }
/// <summary> /// Called to actually print this section. /// </summary> /// <param name="reportDocument">The parent ReportDocument that is printing.</param> /// <param name="g">Graphics object to print on.</param> /// <param name="bounds">Bounds of the area to print within. /// These bounds already take the margins into account. /// </param> protected override void DoPrint( ReportDocument reportDocument, Graphics g, Bounds bounds ) { if ( !reportDocument.NoPrint ) border.DrawBorder (g, this.borderBounds); if (Background != null) { if ( !reportDocument.NoPrint ) g.FillRectangle (Background, this.paddingBounds.GetRectangleF()); } if (CurrentSection != null) { CurrentSection.Print (reportDocument, g, this.contentBounds); } }
/// <summary> /// Called to calculate the size that this section requires on /// the next call to Print. This method will be called exactly once /// prior to each call to Print. It must update the values Size and /// Continued of the ReportSection base class. /// </summary> /// <param name="reportDocument">The parent ReportDocument that is printing.</param> /// <param name="g">Graphics object to print on.</param> /// <param name="bounds">Bounds of the area to print within.</param> /// <returns>SectionSizeValues of requiredSize, fits, and continues.</returns> protected override SectionSizeValues DoCalcSize( ReportDocument reportDocument, Graphics g, Bounds bounds ) { // Default values SectionSizeValues retvals = new SectionSizeValues(); Bounds insideBorder = this.borderPens.GetInnerBounds (bounds); CalcHeaderSize (g, insideBorder); Bounds tableBounds = GetTableBounds (insideBorder); PointF originalPosition = tableBounds.Position; if (SizePrintHeader (g, ref tableBounds, true)) { if (this.currentHorizPage == 0) { this.dataRowsFit = FindDataRowsFit (g, ref tableBounds); this.tableHeightForPage = tableBounds.Position.Y - originalPosition.Y; } if (this.TotalRows == 0) // special case of 0 rows { retvals.Fits = true; } else if (this.dataRowsFit > 0) { retvals.Fits = true; if (this.currentHorizPage < this.infoForPages.Count - 1) { retvals.Continued = true; } else if (this.rowIndex + this.dataRowsFit < this.TotalRows) { retvals.Continued = true; } } } retvals.RequiredSize = this.borderPens.AddBorderSize ( new SizeF (GetPageInfo().Width, tableHeightForPage)); return retvals; }
/// <summary> /// Called to actually print this section. /// The DoCalcSize method will be called exactly once prior to each /// call of DoPrint. /// It should obey the value or Size and Continued as set by /// DoCalcSize(). /// </summary> /// <param name="reportDocument">The parent ReportDocument that is printing.</param> /// <param name="g">Graphics object to print on.</param> /// <param name="bounds">Bounds of the area to print within.</param> protected override void DoPrint( ReportDocument reportDocument, Graphics g, Bounds bounds ) { if (!this.UseFullWidth) { bounds.Limit.X = bounds.Position.X + this.RequiredSize.Width; } if (!this.UseFullHeight) { bounds.Limit.Y = bounds.Position.Y + this.RequiredSize.Height; } SizePrintLine (reportDocument, g, bounds, false, true); }
/// <summary> /// Sizes all the sections that fit within a single row/column /// </summary> /// <param name="reportDocument">Parent ReportDocument</param> /// <param name="g">Graphics object for sizing / printing</param> /// <param name="bounds">The bounds the line must fit within</param> /// <param name="sizeOnly">Indicates that no printing should be done, /// just size the line</param> /// <param name="advanceSectionIndex">Advance the section index, /// so that it's ready for the next line</param> /// <returns>Size and flags for if it fits and if it's continued</returns> protected SectionSizeValues SizePrintLine( ReportDocument reportDocument, Graphics g, Bounds bounds, bool sizeOnly, bool advanceSectionIndex ) { SectionSizeValues retvals = new SectionSizeValues(); retvals.Fits = false; int savedSectionIndex = this.sectionIndex; // Debug.WriteLine("\nEntering " + Direction + " section, sizeonly = " + sizeOnly); // Debug.WriteLine(" Bounds: " + bounds); // The following loop sizes all sections that fit on one line // If it runs out of room within the current bounds, it returns // and will continue where it left off on the next call. while (this.sectionIndex < this.SectionCount) { CurrentSection.CalcSize (reportDocument, g, bounds); if (CurrentSection.Fits) { retvals.Fits = true; if (!sizeOnly) CurrentSection.Print (reportDocument, g, bounds); AdvancePointers(CurrentSection.Size, ref bounds, ref retvals.RequiredSize); if (CurrentSection.Continued) { break; } else { this.sectionIndex++; } } else // it doesn't fit { // reset size since we didn't print but need the size to be // refigured next time CurrentSection.ResetSize(); break; } } // while // Debug.WriteLine("Leaving " + Direction + " section"); // Debug.WriteLine(" Size: " + RequiredSize); retvals.Continued = this.sectionIndex < this.SectionCount; if (this.sectionIndex == savedSectionIndex && !retvals.Continued) retvals.Fits = true; if (!advanceSectionIndex) this.sectionIndex = savedSectionIndex; return retvals; }
/// <summary> /// Set up all the Default Values /// </summary> private void SetDefaults() { //Default Page Settings pageSettings = new PageSettings(); pageSettings.Margins.Top = 50; pageSettings.Margins.Bottom = 50; pageSettings.Margins.Left = 50; pageSettings.Margins.Right = 50; pageSettings.Landscape = true; //Defaults for the Report Document reportDocument = new ReportDocument(); reportDocument.ReportMaker=this; reportDocument.DefaultPageSettings=pageSettings; //Defaults for Printer Settings printerSettings = new PrinterSettings(); printerSettings.MinimumPage = 1; printerSettings.FromPage = 1; printerSettings.ToPage = 1; //Defaults for the Print Dialog printDialog = new PrintDialog(); printDialog.AllowSomePages = true; printDialog.AllowSelection = true; printDialog.AllowPrintToFile = true; printDialog.PrinterSettings = printerSettings; //Defaults for the PrintPreview Dialog printPreviewDialog = new PrintPreviewDialog(); printPreviewDialog.WindowState = FormWindowState.Maximized; //FullScreen //Defaults for this PrintDataGrid Class printSpecificationPage=false; //The maximum column size maxColumnSize = 5.0f; //Reset Default TextStyles ResetTextStyles(false); // Now use a builder to setup everything else reportBuilder = new ReportBuilder(reportDocument); reportBuilder.MaxHeaderRowHeight = 0.5f; reportBuilder.MaxDetailRowHeight = 1.0f; //Determines Gridlines reportBuilder.DefaultTablePen = reportDocument.ThinPen; }
/// <summary> /// This prints out the contents of a datagrid using ReportBuilder /// </summary> /// <param name="reportDocument"></param> public void MakeDocument(ReportDocument reportDocument, string strFontSize, string strStartDate, string strEndDate) { if (dataGrid == null) return; // We may need a DataSet and Data Table depending on DataGrid source type DataTable dataTable = new DataTable(); DataSet dataSet = new DataSet(); DataViewManager dataViewManager = new DataViewManager(); DataView dataView = new DataView(); // We may need to create a DataView depending on the type of DataSouce that is // in the DataGrid bool dataViewExpected=true; //Depending on the Source and if there is a valid data memember we may need //to create a dataView, We actually will try and get the dataView later on //from the currency manager as this will let us show the datatable if we //have drilled down. switch (dataGrid.DataSource.GetType().ToString()) { case "System.Data.DataViewManager": { //Check that a view is being shown, if no load views into a table if (dataGrid.DataMember == String.Empty) { dataViewExpected = false; //ok no Data View is active so print out he DataView dataTable = new DataTable("DataViewManager"); DataColumn dataColumn = dataTable.Columns.Add("TableID",typeof(String)); //Get the dataViewManger from the DataGrid source dataViewManager = (DataViewManager)dataGrid.DataSource; //Add a dataRow to our little table for each DataView Setting foreach (DataViewSetting dvs in dataViewManager.DataViewSettings) { dataTable.Rows.Add(new string[]{dvs.Table.TableName}); } //Now Create a DataView that the ReportPRinting can use to print dataView = new DataView(dataTable); } break; } case "System.Data.DataView": { dataView = (DataView)dataGrid.DataSource; break; } case "System.Data.DataTable": { dataView = ((DataTable)dataGrid.DataSource).DefaultView; break; } case "System.Data.DataSet": { //If DataGrid uses a Data set than the DataTable is in DataMember if (dataGrid.DataMember == String.Empty) { dataViewExpected = false; //ok no Data View is active so print out tables in DataSet //by first creating a dataTable and loading the dataSet Table names //into it so we can create a dataView dataTable = new DataTable("DataSetTables"); DataColumn dataColumn = dataTable.Columns.Add("TableID",typeof(String)); //Get the DataSet from the DataGrid source dataSet = (DataSet)dataGrid.DataSource; //Load the name of each table in the dataSet into our new table foreach (DataTable dt in dataSet.Tables) { dataTable.Rows.Add(new string[]{dt.TableName}); } //Now Create a DataView that the ReportPRinting can use to print dataView = new DataView(dataTable); } break; } } // See if we can pickup the current view from the currency manager // This should also pickup if we are drilled down on any relations etc // This will be skipped where there was no dataView obtainable from the // dataGrid dataSource and DataMember CurrencyManager currencyManager; if (dataViewExpected) { //Currency Manager for the DataGrid currencyManager = (CurrencyManager)dataGrid.BindingContext [dataGrid.DataSource,dataGrid.DataMember]; //This is the DataView that we are going to fill up... dataView = (DataView)currencyManager.List; } // Setup the document's settings reportDocument.DefaultPageSettings= pageSettings; reportBuilder.StartLinearLayout(Direction.Vertical); // Print out the actual Report Page // // %p is code for the page number // string pageStr = "-%p-"; // // string tableName=dataView.Table.TableName; // // reportBuilder.AddPageHeader( // // First page // pageStr, tableName , String.Empty, // // Right pages // pageStr, tableName , String.Empty, // // Odd pages // String.Empty, tableName, pageStr); // // reportBuilder.AddPageFooter (DateTime.Now.ToLongDateString(), ReportPrinting.HorizontalAlignment.Center); // //Now lets print out the Datagrid - First the Heading reportBuilder.AddText(dataGrid.CaptionText, TextStyle.Heading1); // We need to print any parent row info here // Check the dataGrid.DataMember and see if it is a data relation // If it is then get the first DataRow in the DataGrid and then // use its GetParentRows method, Each row should be checked to see // if there was a DataGridTableStyle set up for it // We have to work our way backwards up the data relation building strings that // need to be printed in reverse order to match the way the dataGrid displays if (dataGrid.ParentRowsVisible && //Are parents rows showing?? dataViewExpected && //If no view then skip this dataGrid.DataMember.LastIndexOf(".") > 0 ) //check Tablename.Relation { DataRowView dataRowView1= dataView[0]; //first get the DataRow View DataRow dataRow1 = dataRowView1.Row; //Now get the DataRow for viewRow //break up the DataRelations string into its parts //[0] will be the original table,[1][..] will be relations //This need to be processed from last to first as the last one is //what is currently being displayed on the data grid string [] relations = dataGrid.DataMember.Split(new Char [] {'.'}); //we will build an array of strings of parent data showing on the //datagrid that needs to be printed in reverse order //of the way they were built on the DataGrid in order //to replicate the drill down on the data grid. string[] parentText = new string[relations.Length - 1]; //Go through each Relation from the last to first and get the parent rows //of the childRow using the data relations for that parent-child relation for (int r=relations.Length-1;r > 0;r--) { //If a child has multiple parent rows than we need to figure out which //is parent for this drill down. To get the information for each //parent row we are going to build a string with table & relations //which is the same as the dataGrid Builds automatically on drilldown //for the DataMember field which we will store in parentMember. //parentMember will then be used to get the correct currencyManager //which in turn will get the correct dataview,dataRowView and DataRow //IE TABLENAME.RELATION1.RELATION2 etc string parentMember = String.Empty; for (int i=0 ; i < r; i++) { parentMember += relations[i]; if (i < r-1) parentMember += "."; //Separate with periods except last } //Now that we have the parentMember we need to get the currency //manager for that parentmember which is holding the current //DataView from which we will get the currencyManager = (CurrencyManager)dataGrid.BindingContext [dataGrid.DataSource,parentMember]; //This is the DataView that we are going to fill up... DataView parentDataView = (DataView)currencyManager.List; DataRowView parentDataRowView = (DataRowView)currencyManager.Current; //first get the DataRow View DataRow parentRow = parentDataRowView.Row; //Start with the TableName: parentText[r-1] = parentRow.Table.TableName+": "; // Determine if there is DataGrid Table Style for the parent table // or do we just go through all the columns in the parent DataTable try { DataGridTableStyle tableStyle = dataGrid.TableStyles[parentRow.Table.TableName]; //Go through the table style columns & build the parent text line foreach(DataGridColumnStyle columnStyle in tableStyle.GridColumnStyles) { parentText[r-1] += columnStyle.MappingName+": " + parentRow[columnStyle.MappingName].ToString()+" "; } } catch { //Go through the columns in the parentRow DataTable and built //the parent text line foreach(DataColumn dataColumn in parentRow.Table.Columns) { parentText[r-1] += dataColumn.ColumnName+": " +parentRow[dataColumn].ToString()+" "; } } } //Now print out all the Parent Text array using the report builder for (int i=0; i < parentText.Length; i++) { reportBuilder.AddHorizontalLine (); reportBuilder.AddText(parentText[i], TextStyle.Normal); } reportBuilder.AddHorizontalLine (); } // Add dataView & all columns that are in the data grid reportBuilder.AddTable(dataView, true); // Now we have to determine if there was a DataGridTableStyle setup for this // DataGrid, The default will be to load from the DataView table columns bool loadFromDataView = true; //If there is a DataGridTableStyle - Add any columns showing in the grid.. foreach (DataGridTableStyle tableStyle in dataGrid.TableStyles) { if(tableStyle.MappingName == dataView.Table.TableName) { loadFromDataView = false; foreach(DataGridColumnStyle columnStyle in tableStyle.GridColumnStyles) { reportBuilder.AddColumn(columnStyle.MappingName, columnStyle.HeaderText, (float)columnStyle.Width/75, //Not sure if correct sizing true, true, (ReportPrinting.HorizontalAlignment)columnStyle.Alignment); DataGridTextBoxColumn textCol = columnStyle as DataGridTextBoxColumn; if (textCol != null) { Debug.WriteLine (textCol.Format); reportBuilder.CurrentColumn.FormatExpression = textCol.Format; } } } } //If this is still true than we have to load from the Table columns in the //dataView that the datagrid is using. // // IE there was NOT a valid DataGridTableStyle in the datagrid if (loadFromDataView) { reportBuilder.AddAllColumns (maxColumnSize, true, true); } reportBuilder.FinishLinearLayout(); }
public void MakeDocument(ReportDocument reportDocument) { // Always reset the text styles if you have multiple methods that // set them TextStyle.ResetStyles(); SectionBox box; LinearSections contents; int h_height = 0; int sor_magas = 6; //TextStyle.Normal.BackgroundBrush = Brushes.Beige; //Szamla iSzamla = new Szamla(_SzamlaId); // Create a ReportBuilder object that assists with building a report ReportBuilder builder = new ReportBuilder(reportDocument); builder.CurrentDocument.DocumentUnit = GraphicsUnit.Millimeter; // Before adding sections, a layout must be started. // We are using a linear layout - vertically, which means // each new section starts below the last one. //builder.CurrentDocument.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", DEFS.MMtoInch(210), DEFS.MMtoInch(297)); //builder.CurrentDocument.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(DEFS.MMtoInch(8), DEFS.MMtoInch(8), DEFS.MMtoInch(8), DEFS.MMtoInch(8)); builder.HorizLineMargins = 0.2f; builder.StartLinearLayout(Direction.Vertical); builder.AddPageHeader("ALL-IN Cafe", String.Empty, DateTime.Now.ToLongDateString()); h_height += sor_magas; #region fejlec builder.StartLayeredLayout(false, false); // Add various text sections in different headings box = new SectionBox(); box.Width = 80; box.Height = 10; box.OffsetLeft = 0; box.OffsetTop = 0; //box.Border. //box.Background = Brushes.Ivory; contents = new LinearSections(); contents.AddSection(new SectionText((string)Syspar2.GetValue(ParamCodes.CEG_NEV), TextStyle.Heading1)); contents.AddSection(new SectionText((string)Syspar2.GetValue(ParamCodes.CEG_CIM), TextStyle.Normal)); box.AddSection(contents); builder.AddSection(box); h_height += 10; // Logo box = new SectionBox(); box.Width = 40; box.Height = 10; box.OffsetLeft = 80; box.OffsetTop = 0; box.HorizontalAlignment = HorizontalAlignment.Center; // box.VerticalAlignment = VerticalAlignment.Bottom; //box.Border = reportDocument.NormalPen; SectionImage image = new SectionImage(global::GUI.Properties.Resources.logo); //image.Transparency = 50; //image.PreserveAspectRatio = false; box.AddSection(image); builder.AddSection(box); // Finish a layout that we started // builder.FinishLayeredLayout(); // builder.FinishLayeredLayout(); #endregion builder.AddText(" "); builder.AddText(" "); builder.AddText(" "); builder.AddText("Napi összesített eladás statisztika"); h_height += 4 * sor_magas; #region Összes eladás DataView dv = ReportData.GetOsszesEladas(_EV, _HO, _NAP); builder.DefaultTablePen = null; builder.AddTable(dv, true, 100); builder.Table.InnerPenHeaderBottom = reportDocument.NormalPen; builder.Table.InnerPenRow = new Pen(Color.Gray, reportDocument.ThinPen.Width); builder.Table.OuterPenBottom = new Pen(Color.Gray, reportDocument.ThinPen.Width); builder.Table.HeaderTextStyle.Size = 8; builder.Table.DetailRowTextStyle.Size = 8; // 210 széles lehet. builder.AddColumn(dv.Table.Columns[0], "Típus", 30, false, false, HorizontalAlignment.Left); builder.AddColumn(dv.Table.Columns[1], "db.", 20, false, false, HorizontalAlignment.Right); builder.AddColumn(dv.Table.Columns[2], "Érték", 20, false, false, HorizontalAlignment.Right); //builder.AddColumn(dv.Table.Columns[3], "Hitel ért.", 40, false, false, HorizontalAlignment.Right); //builder.AddColumn(dv.Table.Columns[4], "Kifiz. hitel db", 20, false, false, HorizontalAlignment.Right); //builder.AddColumn(dv.Table.Columns[5], "Kifiz. hitelek ért.", 40, false, false, HorizontalAlignment.Right); h_height += sor_magas * dv.Count; builder.CurrentSection.HorizontalAlignment = HorizontalAlignment.Left; #endregion builder.AddText(" "); builder.AddText(" "); builder.AddText(" "); builder.AddText("Cikkcsoportonkénti összesített napi statisztika"); h_height += sor_magas * 4; #region Cikkcsoportonkénti összesítő dv = ReportData.GetCikkcsopOsszesEladas(_EV, _HO, _NAP); builder.DefaultTablePen = null; builder.AddTable(dv, true, 100); builder.Table.InnerPenHeaderBottom = reportDocument.NormalPen; builder.Table.InnerPenRow = new Pen(Color.Gray, reportDocument.ThinPen.Width); builder.Table.OuterPenBottom = new Pen(Color.Gray, reportDocument.ThinPen.Width); builder.Table.HeaderTextStyle.Size = 8; builder.Table.DetailRowTextStyle.Size = 8; // 210 széles lehet. builder.AddColumn(dv.Table.Columns[0], "Cikkcsoport", 30, false, false, HorizontalAlignment.Left); builder.AddColumn(dv.Table.Columns[1], "Tipus", 30, false, false, HorizontalAlignment.Left); builder.AddColumn(dv.Table.Columns[2], "db", 10, false, false, HorizontalAlignment.Right); builder.AddColumn(dv.Table.Columns[3], "érték", 20, false, false, HorizontalAlignment.Right); //builder.AddColumn(dv.Table.Columns[3], "Hitelre db", 20, false, false, HorizontalAlignment.Right); //builder.AddColumn(dv.Table.Columns[4], "Hitelre ért.", 30, false, false, HorizontalAlignment.Right); //builder.AddColumn(dv.Table.Columns[5], "Kifiz. hitel db", 20, false, false, HorizontalAlignment.Right); //builder.AddColumn(dv.Table.Columns[6], "Kifiz. hitel ért.", 30, false, false, HorizontalAlignment.Right); h_height += sor_magas * dv.Count; builder.CurrentSection.HorizontalAlignment = HorizontalAlignment.Left; #endregion builder.AddText(" "); builder.AddText(" "); builder.AddText(" "); builder.AddText("Speciális zárás statisztika"); h_height += sor_magas * 4; #region Speciális zárás összesítő dv = ReportData.GetSpecZarasEladas(_EV,_HO,_NAP); builder.DefaultTablePen = null; builder.AddTable(dv, true, 100); builder.Table.InnerPenHeaderBottom = reportDocument.NormalPen; builder.Table.InnerPenRow = new Pen(Color.Gray, reportDocument.ThinPen.Width); builder.Table.OuterPenBottom = new Pen(Color.Gray, reportDocument.ThinPen.Width); builder.Table.HeaderTextStyle.Size = 8; builder.Table.DetailRowTextStyle.Size = 8; // 210 széles lehet. builder.AddColumn(dv.Table.Columns[0], "Cikkcsoport", 30, false, false, HorizontalAlignment.Right); builder.AddColumn(dv.Table.Columns[1], "Összes eladás db", 20, false, false, HorizontalAlignment.Right); builder.AddColumn(dv.Table.Columns[2], "Összes eladás értéke", 30, false, false, HorizontalAlignment.Right); builder.AddColumn(dv.Table.Columns[3], "Hitelre írt db", 20, false, false, HorizontalAlignment.Right); builder.AddColumn(dv.Table.Columns[4], "Hitelre írás értéke", 30, false, false, HorizontalAlignment.Right); builder.AddColumn(dv.Table.Columns[5], "Kifizetett hitel db", 20, false, false, HorizontalAlignment.Right); builder.AddColumn(dv.Table.Columns[6], "Kifizetett hitelek értéke", 30, false, false, HorizontalAlignment.Right); h_height += sor_magas * dv.Count; builder.CurrentSection.HorizontalAlignment = HorizontalAlignment.Left; #endregion builder.AddText(" "); h_height += sor_magas * 2; builder.CurrentDocument.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", DEFS.MMtoInch(75), DEFS.MMtoInch(h_height)); builder.CurrentDocument.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(DEFS.MMtoInch(1), DEFS.MMtoInch(1), DEFS.MMtoInch(1), DEFS.MMtoInch(1)); builder.FinishLinearLayout(); }
/// <summary> /// Called to actually print this section. /// The DoCalcSize method will be called exactly once prior to each /// call of DoPrint. /// It should obey the value or Size and Continued as set by /// DoCalcSize(). /// </summary> /// <param name="reportDocument">The parent ReportDocument that is printing.</param> /// <param name="g">Graphics object to print on.</param> /// <param name="bounds">Bounds of the area to print within.</param> protected override void DoPrint( ReportDocument reportDocument, Graphics g, Bounds bounds ) { int origRowIndex = this.rowIndex; Bounds tableBounds = GetTableBounds (bounds, this.RequiredSize); Bounds insideBorders = borderPens.GetInnerBounds (tableBounds); Bounds printingBounds = insideBorders; SizePrintHeader (g, ref printingBounds, false); PrintRows (g, ref printingBounds); // Draw lines last PrintAllRowLines (g,insideBorders, (!this.SuppressHeaderRow && this.RepeatHeaderRow) ); PrintAllColumnLines (g, insideBorders); this.borderPens.DrawBorder (g, tableBounds); if (this.currentHorizPage < this.infoForPages.Count - 1) { this.currentHorizPage++; this.rowIndex = origRowIndex; } else { this.currentHorizPage = 0; } }
/// <summary> /// Called to calculate the size that this section requires on /// the next call to Print. This method will be called once /// prior to each call to Print. /// </summary> /// <param name="reportDocument">The parent ReportDocument that is printing.</param> /// <param name="g">Graphics object to print on.</param> /// <param name="bounds">Bounds of the area to print within. /// The bounds passed already takes the margins into account - so you cannot /// print or do anything within these margins. /// </param> /// <returns>The values for RequireSize, Fits and Continues for this section.</returns> protected override SectionSizeValues DoCalcSize( ReportDocument reportDocument, Graphics g, Bounds bounds ) { // Take offset into account... bounds.Position.X += OffsetLeft; bounds.Position.Y += OffsetTop; SectionSizeValues retval = new SectionSizeValues(); // need to determine what to do with these values... retval.Fits = true; retval.Continued = false; SizeF contentSize = new SizeF (0,0); if (CurrentSection != null) { CurrentSection.CalcSize (reportDocument, g, GetMaxContentBounds(bounds)); contentSize = CurrentSection.Size; // or could use RequiredSize? } this.borderBounds = GetBorderBounds (bounds, contentSize); this.paddingBounds = border.GetInnerBounds (this.borderBounds); this.contentBounds = paddingBounds.GetBounds (PaddingTop, PaddingRight, PaddingBottom, PaddingLeft); retval.RequiredSize = this.borderBounds.GetSizeF(); return retval; }
/// <summary> /// Called to calculate the size that this section requires on /// the next call to Print. This method will be called exactly once /// prior to each call to Print. It must update the values Size and /// Continued of the ReportSection base class. /// </summary> /// <param name="reportDocument">The parent ReportDocument that is printing.</param> /// <param name="g">Graphics object to print on.</param> /// <param name="bounds">Bounds of the area to print within.</param> protected override SectionSizeValues DoCalcSize( ReportDocument reportDocument, Graphics g, Bounds bounds ) { // get the size of the current line return SizePrintLine (reportDocument, g, bounds, true, false); }
public void MakeDocument(ReportDocument reportDocument) { // Always reset the text styles if you have multiple methods that // set them int height = 0; int sor_magas = 6; TextStyle.ResetStyles(); SectionBox box; LinearSections contents; //TextStyle.Normal.BackgroundBrush = Brushes.Beige; Szamla iSzamla = new Szamla(_SzamlaId); // Create a ReportBuilder object that assists with building a report ReportBuilder builder = new ReportBuilder(reportDocument); builder.CurrentDocument.DocumentUnit = GraphicsUnit.Millimeter; // Before adding sections, a layout must be started. // We are using a linear layout - vertically, which means // each new section starts below the last one. builder.HorizLineMargins = 0.2f; builder.StartLinearLayout(Direction.Vertical); builder.AddPageHeader("ALL-IN Cafe", String.Empty, iSzamla.SZAMLA_DATUMA.ToShortDateString() + " " + iSzamla.SZAMLA_DATUMA.ToLongTimeString()); height += sor_magas; #region fejlec builder.StartLayeredLayout(false, false); // Add various text sections in different headings box = new SectionBox(); box.Width = 80; box.Height = 10; box.OffsetLeft = 0; box.OffsetTop = 0; //box.Border. //box.Background = Brushes.Ivory; contents = new LinearSections(); contents.AddSection(new SectionText((string)Syspar2.GetValue(ParamCodes.CEG_NEV), TextStyle.Heading1)); contents.AddSection(new SectionText((string)Syspar2.GetValue(ParamCodes.CEG_CIM), TextStyle.Normal)); box.AddSection(contents); builder.AddSection(box); height += 10; // Logo box = new SectionBox(); box.Width = 40; box.Height = 10; box.OffsetLeft = 80; box.OffsetTop = 0; box.HorizontalAlignment = HorizontalAlignment.Center; // box.VerticalAlignment = VerticalAlignment.Bottom; //box.Border = reportDocument.NormalPen; SectionImage image; try { image = new SectionImage(Image.FromFile((string)Syspar2.GetValue(ParamCodes.BLOKK_LOGO_PATH))); } catch (Exception ix) { DEFS.ExLog(ix.Message + "\n" + ix.StackTrace); image = new SectionImage(global::GUI.Properties.Resources.logo); } //image.Transparency = 50; //image.PreserveAspectRatio = false; box.AddSection(image); builder.AddSection(box); // Finish a layout that we started // builder.FinishLayeredLayout(); // builder.FinishLayeredLayout(); #endregion builder.AddText("Blokk sorszáma: "+ iSzamla.SZAMLA_SORSZAM.PadLeft(7,'0'), TextStyle.Normal); builder.AddText(" "); height += 2 * sor_magas; builder.StartLayeredLayout(false, false); if (DateTime.Now >= Convert.ToDateTime(new DateTime(2010, 1, 1))) { // Tesztüzem SectionBox box_teszt = new SectionBox(); box_teszt.WidthPercent = 30; //box.Height = 1; box_teszt.HorizontalAlignment = HorizontalAlignment.Center; box.VerticalAlignment = VerticalAlignment.Top; //box.Border = reportDocument.NormalPen; SectionImage image_teszt = new SectionImage(global::GUI.Properties.Resources.tesztuzem); image_teszt.Transparency = 80; //image.PreserveAspectRatio = false; box_teszt.AddSection(image_teszt); builder.AddSection(box_teszt); } #region sorok DataView dv = iSzamla.GetBlokkDataView(); builder.DefaultTablePen = null; // ide még kell egy faktor ami a sortöréseket határozza meg. height += sor_magas * dv.Count; builder.AddTable(dv, true, 100); builder.Table.InnerPenHeaderBottom = reportDocument.NormalPen; builder.Table.InnerPenRow = new Pen(Color.Gray, reportDocument.ThinPen.Width); builder.Table.OuterPenBottom = new Pen(Color.Gray, reportDocument.ThinPen.Width); builder.AddColumn(dv.Table.Columns[0], "Db.", 8, false, false, HorizontalAlignment.Left); builder.AddColumn(dv.Table.Columns[1], "Termék", 30, false, false, HorizontalAlignment.Left); builder.AddColumn(dv.Table.Columns[2], "Összeg", 40, false, false, HorizontalAlignment.Right); //dt.Columns.Add(, typeof(int)); //dt.Columns.Add("Cikk", typeof(string)); //dt.Columns.Add("Összeg", typeof(double)); // builder.AddAllColumns(30.0f, true, true); builder.CurrentSection.HorizontalAlignment = HorizontalAlignment.Left; #endregion builder.FinishLayeredLayout(); #region végösszesen DataView dv2 = iSzamla.GetBlokkOsszegDataView(); builder.DefaultTablePen = null; builder.AddTable(dv2, true, 100); height += sor_magas * dv2.Count; builder.AddColumn(dv2.Table.Columns[0], " ", 50, false, false, HorizontalAlignment.Right); builder.AddColumn(dv2.Table.Columns[1], " ", 30, false, false, HorizontalAlignment.Right); #endregion builder.AddText(" "); builder.AddText((string)Syspar2.GetValue(ParamCodes.BLOKK_LABLEC1), TextStyle.Normal); builder.AddText((string)Syspar2.GetValue(ParamCodes.BLOKK_LABLEC2), TextStyle.Normal); builder.AddText((string)Syspar2.GetValue(ParamCodes.BLOKK_LABLEC3), TextStyle.Normal); //builder.AddText((string)Syspar2.GetValue(ParamCodes.BLOKK_LABLEC4), TextStyle.Normal); height += sor_magas * ((Syspar2.GetValue(ParamCodes.BLOKK_LABLEC1).ToString().Length / 45) + 1); height += sor_magas * ((Syspar2.GetValue(ParamCodes.BLOKK_LABLEC2).ToString().Length / 45) + 1); height += sor_magas * ((Syspar2.GetValue(ParamCodes.BLOKK_LABLEC3).ToString().Length / 45) + 1); //height += sor_magas * (((string)Syspar2.GetValue(ParamCodes.BLOKK_LABLEC4).Length / 45) + 1); height += sor_magas; builder.CurrentDocument.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", DEFS.MMtoInch(75), DEFS.MMtoInch(height)); builder.CurrentDocument.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(DEFS.MMtoInch(1), DEFS.MMtoInch(1), DEFS.MMtoInch(1), DEFS.MMtoInch(1)); builder.FinishLinearLayout(); }
/// <summary> /// Called to calculate the size that this section requires on /// the next call to Print. This method will be called exactly once /// prior to each call to Print. It must update the values Size and /// Continued of the ReportSection base class. /// </summary> /// <param name="reportDocument">Pparent ReportDocument that is printing.</param> /// <param name="g">Graphics object to print on.</param> /// <param name="bounds">Bounds of the area to print within.</param> /// <returns>SectionSizeValues</returns> protected override SectionSizeValues DoCalcSize( ReportDocument reportDocument, Graphics g, Bounds bounds ) { SectionSizeValues retval = new SectionSizeValues(); textFont = this.TextStyle.GetFont(); textLayout = bounds.GetRectangleF(); if (CheckTextLayout(g)) { // Get a new string starting from where-ever we left off on the last page textToPrint = GetText(reportDocument); retval = SetTextSize (reportDocument, g, bounds); } else { retval.Fits = false; } return retval; }
/// <summary> /// Called to actually print this section. /// The DoCalcSize method will be called exactly once prior to each /// call of DoPrint. /// It should obey the value or Size and Continued as set by /// DoCalcSize(). /// </summary> /// <param name="reportDocument">The parent ReportDocument that is printing.</param> /// <param name="g">Graphics object to print on.</param> /// <param name="bounds">Bounds of the area to print within.</param> protected override void DoPrint( ReportDocument reportDocument, Graphics g, Bounds bounds ) { SizeF mySize = new SizeF (0,0); if (ShowDividerFirst && (Divider != null)) { divider.Print (reportDocument, g, bounds); AdvancePointers (divider.Size, ref bounds, ref mySize); } // size first SectionSizeValues oneCall = SizePrintLine (reportDocument, g, bounds, true, false); bool fits = oneCall.Fits; while (oneCall.Fits) { Bounds printBounds = bounds.GetBounds (oneCall.RequiredSize); SizePrintLine (reportDocument, g, printBounds, false, true); // print AdvancePointers (oneCall.RequiredSize, ref bounds, ref mySize); // if this section is not continued, quit now // or if this was the last column/row on this page, quit now if (!oneCall.Continued || bounds.IsEmpty()) { break; } oneCall = SizePrintLine (reportDocument, g, bounds, true, false); // size if ( oneCall.Fits && Divider != null) { divider.Print (reportDocument, g, bounds); AdvancePointers (divider.Size, ref bounds, ref mySize); } } SetSize (mySize, bounds); SetFits (fits); SetContinued (oneCall.Continued); }
/// <summary> /// Called to actually print this section. /// The DoCalcSize method will be called exactly once prior to each /// call of DoPrint. /// It should obey the value or Size and Continued as set by /// DoCalcSize(). /// </summary> /// <param name="reportDocument">The parent ReportDocument that is printing.</param> /// <param name="g">Graphics object to print on.</param> /// <param name="bounds">Bounds of the area to print within.</param> protected override void DoPrint( ReportDocument reportDocument, Graphics g, Bounds bounds ) { if ( !reportDocument.NoPrint ) { // draw background and text if (this.TextStyle.BackgroundBrush != null) { RectangleF backgroundRect = textLayout; if (this.UseFullWidth) { backgroundRect.X = bounds.Position.X; backgroundRect.Width = bounds.Width; } if (this.UseFullHeight) { backgroundRect.Y = bounds.Position.Y; backgroundRect.Height = bounds.Height; } g.FillRectangle (this.TextStyle.BackgroundBrush, backgroundRect); } g.DrawString(textToPrint, textFont, this.TextStyle.Brush, textLayout, GetStringFormat()); if (debugEnabled) { Console.WriteLine ("Draw string '" + textToPrint + "' at " + textLayout); } } // Increment the character pointer... this.CharIndex += charsFitted; }
/// <summary> /// Method called to Print this ReportSection. /// If CalcSize has not already been called, it will call it. /// </summary> /// <param name="reportDocument">The parent ReportDocument that is printing.</param> /// <param name="g">Graphics object to print on.</param> /// <param name="bounds">Bounds of the area to print within.</param> public void Print( ReportDocument reportDocument, Graphics g, Bounds bounds) { Bounds printingBounds = LimitBounds (bounds); if (this.sized && (printingBounds != this.sizingBounds)) { SectionSizeValues vals = BoundsChanged (this.sizingBounds, printingBounds); SetSize (vals.RequiredSize, bounds); this.fits = vals.Fits; this.continued = vals.Continued; } CalcSize (reportDocument, g, bounds); if (this.fits) { DoPrint (reportDocument, g, printingBounds); } ResetSize (); }
/// <summary> /// A function that should return the string to be printed on /// this call to Print() /// </summary> /// <param name="reportDocument">The parent ReportDocument. /// Can be used to overload this function with page specific verions, etc.</param> /// <returns>A string to be printed on this page</returns> protected virtual string GetText(ReportDocument reportDocument) { // TODO: Raise event for printing text... return this.Text.Substring(CharIndex); }
/// <summary> /// Called to actually print this section. /// The DoCalcSize method will be called once prior to each /// call of DoPrint. /// DoPrint is not called if DoCalcSize sets fits to false. /// It should obey the values of Size and Continued as set by /// DoCalcSize(). /// </summary> /// <param name="reportDocument">The parent ReportDocument that is printing.</param> /// <param name="g">Graphics object to print on.</param> /// <param name="bounds">Bounds of the area to print within. /// These bounds already take the margins into account. /// </param> protected abstract void DoPrint( ReportDocument reportDocument, Graphics g, Bounds bounds );
/// <summary> /// Called to calculate the size that this section requires on /// the next call to Print. This method will be called once /// prior to each call to Print. /// </summary> /// <param name="reportDocument">The parent ReportDocument that is printing.</param> /// <param name="g">Graphics object to print on.</param> /// <param name="bounds">Bounds of the area to print within. /// The bounds passed already takes the margins into account - so you cannot /// print or do anything within these margins. /// </param> /// <returns>The values for RequireSize, Fits and Continues for this section.</returns> protected override SectionSizeValues DoCalcSize( ReportDocument reportDocument, Graphics g, Bounds bounds ) { this.linesToPrint = new ArrayList (100); SectionSizeValues retval = new SectionSizeValues(); WordToPrint nextWord = null; int nextIndex; while (charIndex < this.richTextBox1.Text.Length) { LineToPrint line = LineToPrint.Get (charIndex, g, bounds.Position, bounds.Width, this.richTextBox1, ref nextWord, out nextIndex); if (line.Size.Height + bounds.Position.Y < bounds.Limit.Y) { linesToPrint.Add (line); charIndex = nextIndex; retval.RequiredSize.Width = Math.Max (retval.RequiredSize.Width, line.Size.Width); retval.RequiredSize.Height += line.Size.Height; bounds.Position.Y += line.Size.Height; } else { retval.Continued = true; break; } } retval.Fits = true; return retval; }