public void StartPage() { if (PrinterSettings.InstalledPrinters.Count == 0) { Assert.Ignore("The test depends on printer being available."); } using (Form f = new Form()) { PrintPreviewControl p = new PrintPreviewControl(); f.Controls.Add(p); f.Show(); Assert.AreEqual(0, p.StartPage); Assert.AreEqual(1, p.Rows); Assert.AreEqual(1, p.Columns); p.StartPage = 4; Assert.AreEqual(4, p.StartPage); PrintDocument document = new PrintDocument(); int page_number = 0; int page_count = 1; document.BeginPrint += (sender, e) => page_number = 0; document.PrintPage += (sender, e) => e.HasMorePages = ++page_number < page_count; p.Document = document; p.Refresh(); Assert.AreEqual(0, p.StartPage); page_count = 8; p.InvalidatePreview(); p.Refresh(); Assert.AreEqual(4, p.StartPage); } }
// stisk Nastaveni tisku ... private void NastaveniToolStripButton_Click(object sender, EventArgs e) { DialogResult dlg = printDialog1.ShowDialog(); // neumim to osetrit lepe - idealni by bylo tlacitko "Pouzit" z Dialogu, ale to WinForms nezna if (dlg != DialogResult.Cancel) { PrinterSettings mysettings = printDialog1.PrinterSettings; docToPrint.PrinterSettings = mysettings; PrintPreviewControl.Document = docToPrint; PrintPreviewControl.Refresh(); } }