public void method_3() { PrinterSettings printerSettings = this.printDocument_0.PrinterSettings; int num = printerSettings.MinimumPage - 1; int num2 = printerSettings.MaximumPage - 1; PrintRange printRange = printerSettings.PrintRange; switch (printRange) { case PrintRange.AllPages: this.method_0().Print(); return; case PrintRange.Selection: num = num2 = this.Int32_0; if (this.Enum0_0 == ((Enum0)3)) { num2 = Math.Min((int)(num + 1), (int)(this.Int32_1 - 1)); } break; case PrintRange.SomePages: num = printerSettings.FromPage - 1; num2 = printerSettings.ToPage - 1; break; default: if (printRange == PrintRange.CurrentPage) { num = num2 = this.Int32_0; } break; } new Class7(this, num, num2).Print(); }
private void A(object obj, PrintEventArgs printEventArgs) { this.A = 0; this.a = this.A() - 1; this.A = 0f; this.A = new s1[this.A.E().B()]; for (int i = 0; i < this.A.Length; i++) { this.A[i] = this.A.E().B(i).f(); } if (printEventArgs.PrintAction != PrintAction.PrintToPreview) { PrinterSettings printerSettings = this.A.PrinterSettings; PrintRange printRange = printerSettings.PrintRange; PrintRange printRange2 = printRange; if (printRange2 != PrintRange.SomePages) { if (printRange2 != PrintRange.CurrentPage) { return; } this.A = (this.a = this.a()); return; } else { this.A = printerSettings.FromPage - 1; this.a = printerSettings.ToPage - 1; } } }
public void PrintRange_SetValue_ReturnsExpected(PrintRange printRange) { var printerSettings = new PrinterSettings() { PrintRange = printRange }; Assert.Equal(printRange, printerSettings.PrintRange); }
// Constructor. public PrinterSettings() { collate = false; copies = 1; duplex = Duplex.Default; fromPage = 0; landscapeAngle = 0; maximumCopies = 1; maximumPage = 9999; minimumPage = 0; printerName = null; printRange = PrintRange.AllPages; printToFile = false; toPage = 0; toolkitPrinter = null; }
// Constructor. public PrinterSettings() { collate = false; copies = 1; duplex = Duplex.Default; fromPage = 0; landscapeAngle = 0; maximumCopies = 1; maximumPage = 9999; minimumPage = 0; printerName = null; printRange = PrintRange.AllPages; printToFile = false; toPage = 0; toolkitPrinter = null; }
private PrintRange GetPrintRange() { PrintRange printRange = new PrintRange(); if (radbtnAll.Checked == true) { printRange = PrintRange.AllPages; } else if (radbtnCurrent.Checked == true) { printRange = PrintRange.CurrentPage; } else if (radbtnRange.Checked == true) { printDoc.PrinterSettings.FromPage = Convert.ToInt32(txbRange_From.Text); printDoc.PrinterSettings.ToPage = Convert.ToInt32(txbRange_To.Text); printRange = PrintRange.SomePages; } return(printRange); }
/// <summary> /// Schedules which pages should be rendered /// </summary> private void SchedulePages(LayoutPages pages, IEnumerable <LayoutElement> elements, PrintRange printRange, int?fromPage, int?toPage) { _pages = pages; _elements = elements; pages.MarkUnprinted(); switch (printRange) { case PrintRange.AllPages: foreach (var page in pages) { page.Scheduled = true; } break; case PrintRange.Selection: foreach (var page in pages) { page.Scheduled = page.Selected; } break; case PrintRange.SomePages: foreach (var page in pages) { var index = pages.PageIndex(page); page.Scheduled = (index >= fromPage && index <= toPage); } break; } }
public void PrintRange_Invalid_ThrowsInvalidEnumArgumentException(PrintRange printRange) { var printerSettings = new PrinterSettings(); Assert.ThrowsAny <ArgumentException>(() => printerSettings.PrintRange = printRange); }
/// <summary> /// Set up the print job. Save information from print dialog /// and print document for easy access. Also sets up the rows /// and columns that will be printed. At this point, we're /// collecting all columns in colstoprint. This will be broken /// up into pagesets later on /// </summary> /// <param name="pd">The print dialog the user just filled out</param> void SetupPrint(PrintDialog pd) { //----------------------------------------------------------------- // get info on the limits of the printer's actual print area available. Convert // to int's to work with margins. //----------------------------------------------------------------- int hardx = (int)Math.Round(printDoc.DefaultPageSettings.HardMarginX); int hardy = (int)Math.Round(printDoc.DefaultPageSettings.HardMarginY); int printareawidth; if (printDoc.DefaultPageSettings.Landscape) printareawidth = (int)Math.Round(printDoc.DefaultPageSettings.PrintableArea.Height); else printareawidth = (int)Math.Round(printDoc.DefaultPageSettings.PrintableArea.Width); //----------------------------------------------------------------- // set the print area we're working within //----------------------------------------------------------------- pageHeight = printDoc.DefaultPageSettings.Bounds.Height; pageWidth = printDoc.DefaultPageSettings.Bounds.Width; //----------------------------------------------------------------- // Set the printable area: margins and pagewidth //----------------------------------------------------------------- // Set initial printer margins printmargins = printDoc.DefaultPageSettings.Margins; // adjust for when the margins are less than the printer's hard x/y limits printmargins.Right = (hardx > printmargins.Right) ? hardx : printmargins.Right; printmargins.Left = (hardx > printmargins.Left) ? hardx : printmargins.Left; printmargins.Top = (hardy > printmargins.Top) ? hardy : printmargins.Top; printmargins.Bottom = (hardy > printmargins.Bottom) ? hardy : printmargins.Bottom; // Now, we can calc default print width, again, respecting the printer's limitations printWidth = pageWidth - printmargins.Left - printmargins.Right; printWidth = (printWidth > printareawidth) ? printareawidth : printWidth; //----------------------------------------------------------------- // Figure out which pages / rows to print //----------------------------------------------------------------- // save print range printRange = pd.PrinterSettings.PrintRange; // pages to print handles "some pages" option if (PrintRange.SomePages == printRange) { // set limits to only print some pages fromPage = pd.PrinterSettings.FromPage; toPage = pd.PrinterSettings.ToPage; } else { // set extremes so that we'll print all pages fromPage = 0; toPage = 2147483647; } //----------------------------------------------------------------- // set up the rows and columns to print //----------------------------------------------------------------- // rows to print (handles "selection" and "current page" options if (PrintRange.Selection == printRange) { // if DGV has rows selected, it's easy, selected rows and all visible columns if (0 != dgv.SelectedRows.Count) { rowstoprint = dgv.SelectedRows; colstoprint = new List<object>(dgv.Columns.Count); foreach (DataGridViewColumn col in dgv.Columns) if (col.Visible) colstoprint.Add(col); } // if selected columns, then all rows, and selected columns else if (0 != dgv.SelectedColumns.Count) { rowstoprint = dgv.Rows; colstoprint = dgv.SelectedColumns; } // we just have a bunch of selected cells so we have to do some work else { // set up sorted lists. the selectedcells method does not guarantee // that the cells will always be in left-right top-bottom order. SortedList temprowstoprint = new SortedList(dgv.SelectedCells.Count); SortedList tempcolstoprint = new SortedList(dgv.SelectedCells.Count); // for each selected cell, add unique rows and columns int colindex, rowindex; foreach (DataGridViewCell cell in dgv.SelectedCells) { colindex = cell.ColumnIndex; rowindex = cell.RowIndex; // add unique rows if (!temprowstoprint.Contains(rowindex)) temprowstoprint.Add(rowindex, dgv.Rows[rowindex]); // add unique columns if (!tempcolstoprint.Contains(colindex)) tempcolstoprint.Add(colindex, dgv.Columns[colindex]); } // Move the now-duplicate free columns and rows to our list of what to print rowstoprint = new List<object>(temprowstoprint.Count); foreach (object item in temprowstoprint.Values) rowstoprint.Add(item); colstoprint = new List<object>(tempcolstoprint.Count); foreach (object item in tempcolstoprint.Values) colstoprint.Add(item); } } // if current page was selected, print visible columns for the // displayed rows else if (PrintRange.CurrentPage == printRange) { // create lists rowstoprint = new List<object>(dgv.DisplayedRowCount(true)); colstoprint = new List<object>(dgv.Columns.Count); // select all visible rows on displayed page for (int i = dgv.FirstDisplayedScrollingRowIndex; i < dgv.FirstDisplayedScrollingRowIndex + dgv.DisplayedRowCount(true); i++) { DataGridViewRow row = dgv.Rows[i]; if (row.Visible) rowstoprint.Add(row); } // select all visible columns colstoprint = new List<object>(dgv.Columns.Count); foreach (DataGridViewColumn col in dgv.Columns) if (col.Visible) colstoprint.Add(col); } // this is the default for print all - everything marked visible will be printed else { // select all visible rows and all visible columns rowstoprint = new List<object>(dgv.Rows.Count); foreach (DataGridViewRow row in dgv.Rows) if (row.Visible) rowstoprint.Add(row); colstoprint = new List<object>(dgv.Columns.Count); foreach (DataGridViewColumn col in dgv.Columns) if (col.Visible) colstoprint.Add(col); } // Reorder columns based on Display Index (if the programmer or user has // changed the column display order we want to respect it in the printout) SortedList displayorderlist = new SortedList(colstoprint.Count); foreach (DataGridViewColumn col in colstoprint) displayorderlist.Add(col.DisplayIndex, col); colstoprint.Clear(); foreach (object item in displayorderlist.Values) colstoprint.Add(item); // Adjust override list to have the same number of entries as colstoprint foreach (DataGridViewColumn col in colstoprint) if (publicwidthoverrides.ContainsKey(col.Name)) colwidthsoverride.Add(publicwidthoverrides[col.Name]); else colwidthsoverride.Add(-1); //for (int i = colwidthsoverride.Count; i < colstoprint.Count; i++) // colwidthsoverride.Add(-1); // Measure the print area measureprintarea(printDoc.PrinterSettings.CreateMeasurementGraphics()); // Count the pages totalpages = TotalPages(); }
public void ExportAsFixedFormat(string Path, PpFixedFormatType FixedFormatType, PpFixedFormatIntent Intent, Microsoft.Office.Core.MsoTriState FrameSlides, PpPrintHandoutOrder HandoutOrder, PpPrintOutputType OutputType, Microsoft.Office.Core.MsoTriState PrintHiddenSlides, PrintRange PrintRange, PpPrintRangeType RangeType, string SlideShowName, bool IncludeDocProperties, bool KeepIRMSettings, bool DocStructureTags, bool BitmapMissingFonts, bool UseISO19005_1, [System.Runtime.InteropServices.OptionalAttribute] object ExternalExporter) { throw new NotImplementedException(); }
/// <summary> /// Set up the print job. Save information from print dialog /// and print document for easy access. Also sets up the rows /// and columns that will be printed. /// </summary> /// <param name="pd">The print dialog the user just filled out</param> void SetupPrint(PrintDialog pd) { //----------------------------------------------------------------- // save data from print dialog and document //----------------------------------------------------------------- // check to see if we're doing landscape printing if (docToPrint.DefaultPageSettings.Landscape) { // landscape: switch width and height pageHeight = docToPrint.DefaultPageSettings.PaperSize.Width; pageWidth = docToPrint.DefaultPageSettings.PaperSize.Height; } else { // portrait: keep width and height as expected pageHeight = docToPrint.DefaultPageSettings.PaperSize.Height; pageWidth = docToPrint.DefaultPageSettings.PaperSize.Width; } // save printer margins and calc print width printmargins = docToPrint.DefaultPageSettings.Margins; printWidth = pageWidth - printmargins.Left - printmargins.Right; // save print range printRange = pd.PrinterSettings.PrintRange; // pages to print handles "some pages" option if (PrintRange.SomePages == printRange) { // set limits to only print some pages fromPage = pd.PrinterSettings.FromPage; toPage = pd.PrinterSettings.ToPage; } else { // set extremes so that we'll print all pages fromPage = 0; toPage = 2147483647; } //----------------------------------------------------------------- // set up the pages to print //----------------------------------------------------------------- // pages (handles "selection" and "current page" options if (PrintRange.Selection == printRange) { intCharPrint = this.editForm.TextBox.SelectionStart; intCharFrom = intCharPrint; intCharTo = intCharFrom + this.editForm.TextBox.SelectionLength; } else if (PrintRange.CurrentPage == printRange) { } // this is the default for print all else { intCharPrint = 0; intCharFrom = intCharPrint; intCharTo = this.editForm.TextBox.Text.Length; } }
/// <summary> /// Set up the print job. Save information from print dialog /// and print document for easy access. Also sets up the rows /// and columns that will be printed. /// </summary> /// <param name="pd">The print dialog the user just filled out</param> void SetupPrint(PrintDialog pd) { //----------------------------------------------------------------- // save data from print dialog and document //----------------------------------------------------------------- // check to see if we're doing landscape printing if (printDoc.DefaultPageSettings.Landscape) { // landscape: switch width and height pageHeight = printDoc.DefaultPageSettings.PaperSize.Width; pageWidth = printDoc.DefaultPageSettings.PaperSize.Height; } else { // portrait: keep width and height as expected pageHeight = printDoc.DefaultPageSettings.PaperSize.Height; pageWidth = printDoc.DefaultPageSettings.PaperSize.Width; } // save printer margins and calc print width printmargins = printDoc.DefaultPageSettings.Margins; printWidth = pageWidth - printmargins.Left - printmargins.Right; // save print range printRange = pd.PrinterSettings.PrintRange; // pages to print handles "some pages" option if (PrintRange.SomePages == printRange) { // set limits to only print some pages fromPage = pd.PrinterSettings.FromPage; toPage = pd.PrinterSettings.ToPage; } else { // set extremes so that we'll print all pages fromPage = 0; toPage = 2147483647; } //----------------------------------------------------------------- // set up the rows and columns to print //----------------------------------------------------------------- // rows to print (handles "selection" and "current page" options if (PrintRange.Selection == printRange) { // if DGV has rows selected, it's easy, selected rows and all visible columns if (0 != dgv.SelectedRows.Count) { rowstoprint = dgv.SelectedRows; colstoprint = new List <object>(dgv.Columns.Count - _IgnoreChangeCol.Count); foreach (DataGridViewColumn col in dgv.Columns) { if (col.Visible) { colstoprint.Add(col); } } } // if selected columns, then all rows, and selected columns else if (0 != dgv.SelectedColumns.Count) { rowstoprint = dgv.Rows; colstoprint = dgv.SelectedColumns; } // we just have a bunch of selected cells so we have to do some work else { // set up sorted lists. the selectedcells method does not guarantee // that the cells will always be in left-right top-bottom order. SortedList temprowstoprint = new SortedList(dgv.SelectedCells.Count); SortedList tempcolstoprint = new SortedList(dgv.SelectedCells.Count); // for each selected cell, add unique rows and columns int colindex, rowindex; foreach (DataGridViewCell cell in dgv.SelectedCells) { colindex = cell.ColumnIndex; rowindex = cell.RowIndex; if (!temprowstoprint.Contains(rowindex)) { temprowstoprint.Add(rowindex, dgv.Rows[rowindex]); } if (!tempcolstoprint.Contains(colindex)) { tempcolstoprint.Add(colindex, dgv.Columns[colindex]); } } // Move the now-sorted columns and rows to our list of what to print rowstoprint = new List <object>(temprowstoprint.Count); foreach (object item in temprowstoprint.Values) { rowstoprint.Add(item); } colstoprint = new List <object>(tempcolstoprint.Count); foreach (object item in tempcolstoprint.Values) { colstoprint.Add(item); } } } // if current page was selected, print visible columns for the // displayed rows else if (PrintRange.CurrentPage == printRange) { // create lists rowstoprint = new List <object>(dgv.DisplayedRowCount(true)); colstoprint = new List <object>(dgv.Columns.Count); // select all visible rows on displayed page for (int i = dgv.FirstDisplayedScrollingRowIndex; i < dgv.FirstDisplayedScrollingRowIndex + dgv.DisplayedRowCount(true); i++) { DataGridViewRow row = dgv.Rows[i]; if (row.Visible) { rowstoprint.Add(row); } } // select all visible columns colstoprint = new List <object>(dgv.Columns.Count); foreach (DataGridViewColumn col in dgv.Columns) { if (col.Visible) { colstoprint.Add(col); } } } // this is the default for print all - everything marked visible will be printed else { // select all visible rows and all visible columns rowstoprint = new List <object>(dgv.Rows.Count); foreach (DataGridViewRow row in dgv.Rows) { if (row.Visible) { rowstoprint.Add(row); } } colstoprint = new List <object>(dgv.Columns.Count); foreach (DataGridViewColumn col in dgv.Columns) { if (!_IgnoreChangeCol.Contains(col.Index)) { if (col.Visible) { colstoprint.Add(col); } } } } }
void SetPrinterSettings(string printerName, short copies, bool color, PrintRange printRange, int fromPage=0, int toPage=0) { printDocument.PrinterSettings.PrinterName = printerName; printDocument.PrinterSettings.Copies = copies; printDocument.PrinterSettings.DefaultPageSettings.Color = color; printDocument.PrinterSettings.PrintRange = printRange; printDocument.PrinterSettings.FromPage = fromPage; printDocument.PrinterSettings.ToPage = toPage; RefreshPreview(); }
public void Print(PrintRange range) { this.range = range; this.Print(); }
public void ExportAsFixedFormat(string Path, PpFixedFormatType FixedFormatType, PpFixedFormatIntent Intent, Microsoft.Office.Core.MsoTriState FrameSlides, PpPrintHandoutOrder HandoutOrder, PpPrintOutputType OutputType, Microsoft.Office.Core.MsoTriState PrintHiddenSlides, PrintRange PrintRange, PpPrintRangeType RangeType, string SlideShowName, bool IncludeDocProperties, bool KeepIRMSettings, bool DocStructureTags, bool BitmapMissingFonts, bool UseISO19005_1, [System.Runtime.InteropServices.OptionalAttribute]object ExternalExporter) { throw new NotImplementedException(); }
/// <summary> /// Set up the print job. Save information from print dialog /// and print document for easy access. Also sets up the rows /// and columns that will be printed. At this point, we're /// collecting all columns in colstoprint. This will be broken /// up into pagesets later on /// </summary> void SetupPrint() { //----------------------------------------------------------------- // get info on the limits of the printer's actual print area available. Convert // to int's to work with margins. // // note: do this only if we're not doing embedded printing. //----------------------------------------------------------------- printDoc.DefaultPageSettings.Landscape = false; // true; printDoc.DefaultPageSettings.PrinterResolution.X = KB9Const.IMAGE_DPI; // printDoc.DefaultPageSettings.PrinterResolution.Y = KB9Const.IMAGE_DPI; // //= printDoc.PrinterSettings.PrinterResolutions. int printareawidth; int hardx = (int)Math.Round(printDoc.DefaultPageSettings.HardMarginX); int hardy = (int)Math.Round(printDoc.DefaultPageSettings.HardMarginY); if (printDoc.DefaultPageSettings.Landscape) { printareawidth = (int)Math.Round(printDoc.DefaultPageSettings.PrintableArea.Height); } else { printareawidth = (int)Math.Round(printDoc.DefaultPageSettings.PrintableArea.Width); } //----------------------------------------------------------------- // set the print area we're working within //----------------------------------------------------------------- pageHeight = printDoc.DefaultPageSettings.Bounds.Height; pageWidth = printDoc.DefaultPageSettings.Bounds.Width; //----------------------------------------------------------------- // Set the printable area: margins and pagewidth //----------------------------------------------------------------- // Set initial printer margins PrintMargins = printDoc.DefaultPageSettings.Margins; PrintMargins.Left = 50; //Set printing default to portrait with left margin = 0.5 inch. // adjust for when the margins are less than the printer's hard x/y limits PrintMargins.Right = (hardx > PrintMargins.Right) ? hardx : PrintMargins.Right; PrintMargins.Left = (hardx > PrintMargins.Left) ? hardx : PrintMargins.Left; PrintMargins.Top = (hardy > PrintMargins.Top) ? hardy : PrintMargins.Top; PrintMargins.Bottom = (hardy > PrintMargins.Bottom) ? hardy : PrintMargins.Bottom; // Now, we can calc default print width, again, respecting the printer's limitations printWidth = pageWidth - PrintMargins.Left - PrintMargins.Right; printWidth = (printWidth > printareawidth) ? printareawidth : printWidth; //----------------------------------------------------------------- // Figure out which pages / rows to print //----------------------------------------------------------------- // save print range printRange = printDoc.PrinterSettings.PrintRange; // pages to print handles "some pages" option if (PrintRange.SomePages == printRange) { // set limits to only print some pages fromPage = printDoc.PrinterSettings.FromPage; toPage = printDoc.PrinterSettings.ToPage; } else { // set extremes so that we'll print all pages fromPage = 0; toPage = maxPages; } //----------------------------------------------------------------- // Determine what's going to be printed //----------------------------------------------------------------- //SetupPrintRange(); //----------------------------------------------------------------- // Set up width overrides and fixed columns //----------------------------------------------------------------- //SetupColumns(); //----------------------------------------------------------------- // Now that we know what we're printing, measure the print area and // count the pages. //----------------------------------------------------------------- // Measure the print area // measureprintarea(printDoc.PrinterSettings.CreateMeasurementGraphics()); // Count the pages totalpages = Pagination(); }