Exemple #1
0
	void ShowPreviewDialogButton_Click (object sender, EventArgs e)
	{
		PrintPreviewDialog ppd = new PrintPreviewDialog ();
		ppd.ClientSize = new Size (400, 300);
		ppd.Location = new Point (29, 29);
		ppd.MinimumSize = new Size (375, 250);
		ppd.UseAntiAlias = true;

		ppd.Document = new MyPrintDocument ();
		ppd.ShowDialog ();
	}
Exemple #2
0
        private void btnPrintReport_Click(object sender, EventArgs e)
        {
            try
            {
                this.dtGrdLedgerReport.RowsDefaultCellStyle.BackColor            = Color.White;
                this.dtGrdLedgerReport.AlternatingRowsDefaultCellStyle.BackColor = Color.White;

                if (SetupThePrinting())
                {
                    PrintPreviewDialog MyPrintPreviewDialog = new PrintPreviewDialog();
                    MyPrintPreviewDialog.Document = printDocument1;
                    MyPrintPreviewDialog.ShowDialog();
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show("!!! Please Print Preview or Setup Print only for First time " + exp.Message);
            }
        }
Exemple #3
0
    public ConveyPrinter(string font, int size, int heigth, ref ArrayList lst)
    {
        st_font  = font;
        i_size   = size;
        i_heigth = heigth;

        lstReport = lst;

        pdoc1.PrintPage  += new PrintPageEventHandler(OnPrintPage);
        pdoc1.BeginPrint += new PrintEventHandler(OnBeginPrint);

        PrintPreviewDialog1.Document = pdoc1;
        PrintPreviewDialog1.ShowDialog( );

        if (printDialog1.ShowDialog( ) == DialogResult.OK)
        {
            pdoc1.Print( );
        }
    }
        private void button1_Click(object sender, EventArgs e)
        {
            if (radio_peripheral.Checked)
            {
                DataTable dt = new DataTable();
                foreach (DataGridViewColumn col in dataGridView1.Columns)
                {
                    dt.Columns.Add(col.Name);
                }

                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    DataRow dRow = dt.NewRow();
                    foreach (DataGridViewCell cell in row.Cells)
                    {
                        dRow[cell.ColumnIndex] = cell.Value;
                    }
                    dt.Rows.Add(dRow);
                }

                dataGridPrinter1 = new DataGridPrinter(dataGrid1, printDocument1, dt);

                PrintPreviewDialog ppvw = new PrintPreviewDialog();
                try
                {
                    dataGridPrinter1.PageNumber = 1;
                    dataGridPrinter1.RowCount   = 0;
                    //printDocument1.Print();
                    ppvw.Document = printDocument1;
                    ppvw.ShowDialog();
                }
                catch (Exception ex)
                {
                    throw new Exception("Exception Occured While Printing", ex);
                }
            }
            else
            {
                PrintDocument pd = new PrintDocument();
                pd.PrintPage += PrintPage;
                pd.Print();
            }
        }
Exemple #5
0
 /// <summary>
 /// 列表打印
 /// </summary>
 protected virtual void PrintList()
 {
     this.grdPrinter.DocumentName     = this.Text;
     this.grdPrinter.PageHeaderCenter = this.Text;
     //this.grdData.RootTable.Columns["select"].Visible = false;
     if (this.IsPrintPreview())
     {
         PrintPreviewDialog previewDialog = new PrintPreviewDialog();
         previewDialog.Document = this.grdPrinter;
         previewDialog.Width    = this.Width;
         previewDialog.Height   = this.Height;
         previewDialog.ShowDialog();
     }
     else
     {
         this.grdPrinter.Print();
     }
     //this.grdData.RootTable.Columns["select"].Visible = true;
 }
Exemple #6
0
        private void button3_Click(object sender, System.EventArgs e)
        {
            //initialize the currently printed page number
            m_CurrentPrintPage = 0;

            //check if a document is loaded into PageLayout	control
            if (axPageLayoutControl1.DocumentFilename == null)
            {
                return;
            }
            //set the name of the print preview document to the name of the mxd doc
            document.DocumentName = axPageLayoutControl1.DocumentFilename;

            //set the PrintPreviewDialog.Document property to the PrintDocument object selected by the user
            printPreviewDialog1.Document = document;

            //show the dialog - this triggers the document's PrintPage event
            printPreviewDialog1.ShowDialog();
        }
Exemple #7
0
        private void dgvOUT_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 7)
            {
                txtOUTTotalSKU.Text  = (int.Parse(txtOUTTotalSKU.Text) - ILOUT[e.RowIndex].Quantity).ToString();
                txtOUTTotalUSKU.Text = (int.Parse(txtOUTTotalUSKU.Text) - 1).ToString();
                ILOUT.RemoveAt(e.RowIndex);
                dgvOUT.Rows.RemoveAt(e.RowIndex);
                foreach (DataGridViewRow item in dgvOUT.Rows)
                {
                    item.Cells[seqOut.Name].Value = item.Index + 1;
                }
            }
            if (e.ColumnIndex == 6)
            {
                //frmPrintIN f = new frmPrintIN();
                //f.Barcode = dgvOUT.Rows[e.RowIndex].Cells[clmOutBarcode.Name].Value.ToString();
                //f.SKU = dgvOUT.Rows[e.RowIndex].Cells[clmOUTSKU.Name].Value.ToString();
                //f.Price = dgvOUT.Rows[e.RowIndex].Cells[clmOUTPrice.Name].Value.ToString();
                //f.ItemName = dgvOUT.Rows[e.RowIndex].Cells[clmOUTItemName.Name].Value.ToString();

                //f.ShowDialog();


                string Barcode  = dgvOUT.Rows[e.RowIndex].Cells[clmOutBarcode.Name].Value.ToString();
                string SKU      = dgvOUT.Rows[e.RowIndex].Cells[clmOUTSKU.Name].Value.ToString();
                string Price    = dgvOUT.Rows[e.RowIndex].Cells[clmOUTPrice.Name].Value.ToString();
                string ItemName = dgvOUT.Rows[e.RowIndex].Cells[clmOUTItemName.Name].Value.ToString();


                printDocument1.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", 225, 125);
                PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
                printDocument1.DocumentName = SKU + "," + Barcode + "," + ItemName + "," + Price;
                PrintDialog pd = new PrintDialog();
                pd.ShowDialog();
                printDocument1.PrinterSettings = pd.PrinterSettings;
                printDocument1.PrintPage      += new System.Drawing.Printing.PrintPageEventHandler(printDocument1_PrintPage);
                printPreviewDialog.Document    = printDocument1;

                printPreviewDialog.Shown += new EventHandler(printPreviewDialog_Shown);
                printPreviewDialog.ShowDialog();
            }
        }
Exemple #8
0
        private void printlabel()
        {
            PrintDocument doc = new PrintDocument();

            doc.PrintPage += this.Doc_PrintPage;
            doc.DefaultPageSettings.PaperSize = new PaperSize("100 x 150 mm", 393, 590);

            if (printstatus)
            {
                doc.Print();
                doc.Dispose();
            }
            else
            {
                PrintPreviewDialog pd = new PrintPreviewDialog();
                pd.Document = doc;
                pd.ShowDialog();
            }
        }
Exemple #9
0
        public void startPrint(DataGridView mainTable, bool includeRowHeaders, bool includeColumnHeaders, bool includeHiddenColumns, bool preview)
        {
            portraitPages  = getPages(mainTable, includeRowHeaders, includeColumnHeaders, includeHiddenColumns, true);
            landScapePages = getPages(mainTable, includeRowHeaders, includeColumnHeaders, includeHiddenColumns, false);

            document.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
            document.OriginAtMargins             = true;

            altPrintDialog frm = new altPrintDialog(document, portraitPages.Count, landScapePages.Count);

            if (frm.ShowDialog() == DialogResult.OK)
            {
                Collate   = document.PrinterSettings.Collate;
                Copies    = document.PrinterSettings.Copies;
                Landscape = document.DefaultPageSettings.Landscape;
                FromPage  = document.PrinterSettings.FromPage;
                ToPage    = document.PrinterSettings.ToPage;
                document.PrinterSettings.PrintRange = PrintRange.SomePages;

                pageIndex = FromPage - 1;
                copyIndex = 1;
                if (Landscape)
                {
                    Pages = landScapePages;
                }
                else
                {
                    Pages = portraitPages;
                }
                //
                if (preview)
                {
                    PrintPreviewDialog ppd = new PrintPreviewDialog();
                    ppd.Document    = document;
                    ppd.WindowState = FormWindowState.Maximized;
                    ppd.ShowDialog();
                }
                else
                {
                    document.Print();
                }
            }
        }
Exemple #10
0
        //printpreview the document
        private void bunifuThinButton21_Click(object sender, EventArgs e)
        {
            PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog();

            //printDocument1.DefaultPageSettings.Landscape = true;
            printPreviewDialog1.Document = printDocument1;
            //print preview dialog size
            printPreviewDialog1.ClientSize = new System.Drawing.Size(500, 600);

            //Overriding print function in print preview dialog
            ToolStripButton b = new ToolStripButton();

            b.Image        = JIST.Properties.Resources.print;
            b.DisplayStyle = ToolStripItemDisplayStyle.Image;
            b.Click       += printPreviewDialog1_Click;
            ((System.Windows.Forms.ToolStrip)(printPreviewDialog1.Controls[1])).Items.RemoveAt(0);
            ((System.Windows.Forms.ToolStrip)(printPreviewDialog1.Controls[1])).Items.Insert(0, b);
            printPreviewDialog1.ShowDialog();
        }
Exemple #11
0
        //印刷ボタン
        private void button3_Click(object sender, EventArgs e)
        {
            //インシデント一覧の取得
            //印刷する文字列と位置を設定する
            String context = "";

            if (kubunstr == "インシデント対応")
            {
                context = makeList(1);
            }
            else if (kubunstr == "計画作業")
            {
                context = makeList(3);
            }
            else if (kubunstr == "特別対応")
            {
                context = makeList(4);
            }

            printingText     = context + Environment.NewLine;
            printingPosition = 0;
            //印刷に使うフォントを指定する
            printFont = new Font("MS ゴシック", 12);
            //PrintDocumentオブジェクトの作成
            System.Drawing.Printing.PrintDocument pd =
                new System.Drawing.Printing.PrintDocument();
            //PrintPageイベントハンドラの追加
            pd.PrintPage +=
                new System.Drawing.Printing.PrintPageEventHandler(pd_PrintPage);

            //PrintPreviewDialogオブジェクトの作成
            PrintPreviewDialog ppd = new PrintPreviewDialog();

            //プレビューするPrintDocumentを設定
            ppd.Document = pd;
            //印刷プレビューダイアログを表示する
            ppd.ShowDialog();

            //印刷を開始する
            //pd.Print();

            this.Close();
        }
Exemple #12
0
        private void Print_Badge(object sender, RoutedEventArgs e)
        {
            PrintPreviewDialog pdi = new PrintPreviewDialog();

            //Position de la fenêtre de preview
            //pdi.DesktopLocation = new System.Drawing.Point(0, 0);
            //var locatrion = pdi.Lo
            pdi.Name = "PrintPreviewDialog1";

            BadgeEventSet defaultBadge = this._badgeVM.GetDefaultBadge();

            pdi.ClientSize = new System.Drawing.Size((int)defaultBadge.BadgeSet.Dimension_X, (int)defaultBadge.BadgeSet.Dimension_Y);
            if (defaultBadge == null)
            {
                System.Windows.MessageBox.Show("Please configure a default print in badge settings");
                return;
            }

            PrintDocument printDocument = new PrintDocument();

            printDocument.DefaultPageSettings.PaperSize = new PaperSize("Template",
                                                                        Convert.ToInt32(defaultBadge.BadgeSet.Dimension_X * MM_PX),
                                                                        Convert.ToInt32(defaultBadge.BadgeSet.Dimension_Y * MM_PX));
            printDocument.OriginAtMargins = true;



            printDocument.PrintPage += (sender2, e2) => document_PrintPage(sender2, e2, defaultBadge);
            RectangleF rec    = printDocument.PrinterSettings.DefaultPageSettings.PrintableArea;
            float      rightY = rec.Right;

            pdi.Document             = printDocument;
            pdi.Document.BeginPrint += new PrintEventHandler(end_print);
            //pdi.PrintPreviewControl.Zoom = 1;
            Margins margins = new Margins(10, 10, 10, 10);

            printDocument.DefaultPageSettings.Margins = margins;
            pdi.ShowDialog();
            if (isPrinted)
            {
                this._badgeVM.SaveOnPrintBadge(this._currentUser[0].UserID_User);
            }
        }
Exemple #13
0
        /// <summary>Handles the Click event of the btnPrint control.</summary>
        private void btnPrint_Click(object sender, EventArgs e)
        {
            var doc = new GridPrintDocument(grdBilling, grdBilling.Font, true);

            doc.DocumentName = "Billing Report";

            var printPreviewDialog = new PrintPreviewDialog
            {
                ClientSize   = new Size(400, 300),
                Location     = new Point(29, 29),
                Name         = "Print Preview Dialog",
                UseAntiAlias = true,
                Document     = doc
            };

            printPreviewDialog.ShowDialog();
            doc.Dispose();
            doc = null;
        }
Exemple #14
0
    public void PrintForm()
    {
        ////Open the print dialog
        //PrintDialog printDialog = new PrintDialog();
        //printDialog.Document = _printDocument;
        //printDialog.UseEXDialog = true;

        ////Get the document
        //if (DialogResult.OK == printDialog.ShowDialog())
        //{
        //    _printDocument.DocumentName = "Test Page Print";
        //    _printDocument.Print();
        //}

        //Open the print preview dialog
        PrintPreviewDialog objPPdialog = new PrintPreviewDialog();
        objPPdialog.Document = _printDocument;
        objPPdialog.ShowDialog();
    }
Exemple #15
0
        private void tt()
        {
            wcbj = 0;

            dy(this.PanelZ);
            Thread.Sleep(200);

            Bitmap   bmp1 = new Bitmap(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height);
            Graphics g1   = Graphics.FromImage(bmp1);

            g1.CopyFromScreen(0, 0, 0, 0, new Size(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height));
            if (plz >= curscorll)
            {
                g.DrawImage(bmp1, new Rectangle(0, this.panel1.Height - curscorll, panel1.Width, curscorll), new Rectangle(loc.X, loc.Y + (this.Height - 41 - curscorll), panel1.Width, curscorll), GraphicsUnit.Pixel);//plz
                //MessageBox.Show(Convert.ToString(plz) + "??" + Convert.ToString(curscorll));
            }
            else
            {
                //MessageBox.Show(Convert.ToString(loc.Y));//-(this.Height - 43) + curscorll
                g.DrawImage(bmp1, new Rectangle(0, curscorll, panel1.Width, (this.Height - 43)), new Rectangle(loc.X, loc.Y, panel1.Width, (this.Height - 43)), GraphicsUnit.Pixel);
                // MessageBox.Show(Convert.ToString(2));
            }
            temp = curscorll;

            if (temp >= plz)
            {
                myPic = Image.FromHbitmap(myPic.GetHbitmap());
                myPic.Save(Application.StartupPath + "\\ncycf.gif");
                //打印
                if (checkYl.Checked)
                {
                    PrintPreviewDialog prdlg = new PrintPreviewDialog();
                    prdlg.Document  = this.printDocument1;
                    prdlg.Disposed += new EventHandler(prdlg_Disposed);
                    prdlg.ShowDialog();
                }
                else
                {
                    this.printDocument1.Print();
                }
            }
            wcbj = 1;
        }
Exemple #16
0
        private void menuItem3_Click(object sender, System.EventArgs e)
        {
            //构造打印预览对话框
            PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog();

            //设置Document属性
            printPreviewDialog1.Document = this.pDoc;

            //显示打印预览窗口
            try
            {
                printPreviewDialog1.ShowDialog();
            }
            catch (Exception excep)
            {
                //显示打印出错消息
                MessageBox.Show(excep.Message, "打印出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #17
0
        private void previewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                //initialize the currently printed page number
                m_CurrentPrintPage = 0;

                //set the PrintPreviewDialog.Document property to the PrintDocument object selected by the user
                printPreviewDialog1.Document = pPrintDoc;

                //show the dialog - this triggers the document's PrintPage event
                printPreviewDialog1.ShowDialog();
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
 private void Grafic_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Control && e.KeyCode == Keys.P)
     {
         int contor = 0;
         MessageBox.Show("Tiparire...");
         PrintDocument document = new PrintDocument();
         document.PrintPage += (s, pea) =>
         {
             Desenare(pea.Graphics, pea.MarginBounds);
             contor++;
             pea.Graphics.DrawString("Pagina" + contor, Font, Brushes.Black, pea.MarginBounds.Location);
             pea.HasMorePages = contor < 3;
         };
         PrintPreviewDialog dialog = new PrintPreviewDialog();
         dialog.Document = document;
         dialog.ShowDialog();
     }
 }
Exemple #19
0
        public void Print(StringBuilder content, double width, bool preview = false)
        {
            if (content == null)
            {
                return;
            }

            this.content     = content;
            this.preview     = preview;
            this.pagerHeight = this.content.Length / 30 * 22 + 10;
            this.pagerWidth  = getYc(width);//换算成英寸/像素
            textLines        = content.ToString().TrySplitStrOfLine(lineWordCount);

            if (textLines == null && textLines.Count == 0)
            {
                return;
            }

            this.pagerHeight = (textLines.Count * lineHeight);
            PrintPreviewDialog ppd = new PrintPreviewDialog();
            PrintDocument      pd  = new PrintDocument();

            pd.DocumentName = textLines[0];//使用第一个作为标题
            pd.DefaultPageSettings.Margins = new Margins(10, 10, 10, 10);
            pd.PrintPage += new PrintPageEventHandler(PrintContent);
            //纸张设置默认
            PaperSize pageSize = new PaperSize("自定义纸张", this.pagerWidth, this.pagerHeight);

            pd.DefaultPageSettings.PaperSize = pageSize;
            if (preview)
            {
                ppd.Document = pd;
                ppd.ShowDialog();
            }
            try
            {
                pd.Print();
            }
            catch (Exception ex)
            {
                MessageBox.Show("打印失败." + ex.Message);
            }
        }
Exemple #20
0
        private void _previewButton_Click(object sender, EventArgs e)
        {
            if (_targetCanvas == null)
            {
                return;
            }

            _currentPrintPage = 0;

            using (var preview = new PrintPreviewDialog()) {
                var bounds = _owner.Bounds;
                preview.StartPosition = FormStartPosition.Manual;
                preview.SetBounds(bounds.Left, bounds.Top, bounds.Width, bounds.Height);
                //preview.PrintPreviewControl.Zoom = 1;

                preview.Document = _document;
                preview.ShowDialog(this);
            }
        }
Exemple #21
0
        /// <summary>
        /// This creates and displays the print-preview dialog to both preview
        /// and print the diagram.
        /// </summary>
        /// <remarks>
        /// The dialog is displayed in the modal state.
        /// </remarks>
        public void PrintPreview()
        {
            if (_diagram == null)
            {
                throw new InvalidOperationException("There is no diagram to print");
            }

            PrintPreviewDialog previewDlg = new PrintPreviewDialog();

            Rectangle bounds = Screen.PrimaryScreen.Bounds;

            previewDlg.Width         = (int)(bounds.Width * 2f / 3f);
            previewDlg.Height        = (int)(bounds.Height * 2f / 3f);
            previewDlg.StartPosition = FormStartPosition.CenterParent;
            previewDlg.UseAntiAlias  = true;
            previewDlg.Document      = _printDocument;

            previewDlg.ShowDialog(Form.ActiveForm);
        }
Exemple #22
0
        public bool Print(bool inShowPreview)
        {
            bool curReturnValue = true;

            try {
                PrintPreviewDialog curPreviewDialog = new PrintPreviewDialog();
                PrintDialog        curPrintDialog   = new PrintDialog();

                curPrintDialog.AllowCurrentPage = true;
                curPrintDialog.AllowPrintToFile = true;
                curPrintDialog.AllowSelection   = false;
                curPrintDialog.AllowSomePages   = true;
                curPrintDialog.PrintToFile      = false;
                curPrintDialog.ShowHelp         = false;
                curPrintDialog.ShowNetwork      = false;
                curPrintDialog.UseEXDialog      = true;

                if (curPrintDialog.ShowDialog() == DialogResult.OK)
                {
                    myPrintDoc = new PrintDocument();
                    myPrintDoc.DocumentName        = myReportName;
                    myPrintDoc.PrinterSettings     = curPrintDialog.PrinterSettings;
                    myPrintDoc.DefaultPageSettings = curPrintDialog.PrinterSettings.DefaultPageSettings;
                    InitPrinting(ref myPrintDoc);
                    myPrintDoc.PrintPage += new PrintPageEventHandler(this.PrintReport);

                    if (inShowPreview)
                    {
                        curPreviewDialog.Document    = myPrintDoc;
                        curPreviewDialog.WindowState = FormWindowState.Normal;
                        curPreviewDialog.ShowDialog();
                    }
                    else
                    {
                        myPrintDoc.Print();
                    }
                }
            } catch (Exception ex) {
                MessageBox.Show("Exception encountered in print method of PrintSlalomRecapForm \n Exception: " + ex.ToString());
                curReturnValue = false;
            }
            return(curReturnValue);
        }
Exemple #23
0
 public void PrintRecipt(PaymentInfo pm, bool isShowDialog = false)
 {
     payment = pm;
     // printDocument1.PrintPage += new PrintPageEventHandler(printPage);
     if (isShowDialog)
     {
         PaperSize paperSize = new PaperSize();
         paperSize.Width  = 180;
         paperSize.Height = 320;
         printDocument1.DefaultPageSettings.PaperSize = paperSize;
         previewDialog.Document = printDocument1;
         previewDialog.ShowDialog();
     }
     else
     {
         printDocument1.Print();
         printDocument1.Dispose();
     }
 }
Exemple #24
0
 //打印预览功能的实现
 private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     try
     {
         string             Title        = labelControlTitle.Text;
         string             Title1       = labelControlDateTimeShow.Text;
         string             Title2       = labelControlInTypeShow.Text;
         string             Title3       = labelControlCreateEmp.Text;
         string             Title4       = labelControlCreateDate.Text;
         PrintPreviewDialog PrintPriview = new PrintPreviewDialog();
         PrintPriview.Document    = CreatePrintDocument(dt1, Title, Title1, Title2, Title3, Title4);
         PrintPriview.WindowState = FormWindowState.Maximized;
         PrintPriview.ShowDialog();
     }
     catch (Exception ex)
     {
         MessageBox.Show("打印错误,请检查打印设置!");
     }
 }
Exemple #25
0
        public void PrintPanel(Panel p)
        {
            PrintPreviewDialog ppvw;
            Graphics           mygraphics = p.CreateGraphics();

            mBitmap = GetPanel(panel3);                 //调用方法

            ppvw                = new PrintPreviewDialog();
            ppvw.Width          = 800;
            ppvw.Height         = 600;
            ppvw.Document       = printDoc;
            printDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
            if (ppvw.ShowDialog() != DialogResult.OK)
            {
                printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
                return;
            }
            printDoc.Print();
        }
        public void imprimirCaja(GroupBox cajaFormulario)
        {
            if (cajaFormulario == null)
            {
                return;
            }

            // Setup a PrintDocument
            PrintDocument pd = new PrintDocument();

            pd.BeginPrint += new PrintEventHandler(PrintDocument_BeginPrint);
            pd.PrintPage  += new PrintPageEventHandler(this.PrintDocument_PrintPage);

            // Setup & show the PrintPreviewDialog
            PrintPreviewDialog ppd = new PrintPreviewDialog();

            ppd.Document = pd;
            ppd.ShowDialog();
        }
Exemple #27
0
        private void printButton_Click(object sender, EventArgs e)
        {
            GraphControl control = graphControl;
            // check if the rectangular region or the whole viewport should be printed
            bool  useRect = (bool)handler.GetValue(OUTPUT, EXPORT_RECTANGLE);
            RectD bounds  = useRect ? exportRect.ToRectD() : control.Viewport;

            // check whether decorations (selection, handles, ...) should be hidden
            bool hide = (bool)handler.GetValue(OUTPUT, HIDE_DECORATIONS);

            if (hide)
            {
                // if so, create a new graphcontrol with the same graph
                control = new GraphControl {
                    Graph = graphControl.Graph, Projection = graphControl.Projection
                };
            }

            // read CanvasPrintDocument options
            printDocument.Scale              = (double)Handler.GetValue(DOCUMENT_SETTINGS, SCALE);
            printDocument.CenterContent      = (bool)Handler.GetValue(DOCUMENT_SETTINGS, CENTER_CONTENT);
            printDocument.PageMarkPrinting   = (bool)Handler.GetValue(DOCUMENT_SETTINGS, PAGE_MARK_PRINTING);
            printDocument.ScaleDownToFitPage = (bool)Handler.GetValue(DOCUMENT_SETTINGS, SCALE_DOWN_TO_FIT_PAGE);
            printDocument.ScaleUpToFitPage   = (bool)Handler.GetValue(DOCUMENT_SETTINGS, SCALE_UP_TO_FIT_PAGE);
            // set GraphControl
            printDocument.Canvas = control;
            // set print area
            printDocument.PrintRectangle = bounds;
            printDocument.Projection     = graphControl.Projection;

            // show new PrintPreviewDialog
            PrintPreviewDialog dialog = new PrintPreviewDialog {
                Document = printDocument
            };
            DialogResult result = dialog.ShowDialog(this);

            if (result == DialogResult.Cancel || result == DialogResult.Abort || result == DialogResult.No)
            {
                return;
            }
            // print
            printDocument.Print();
        }
Exemple #28
0
        private void btnPrintStudent_Click(object sender, EventArgs e)
        {
            PrintDocument pd2 = new PrintDocument();

            pd2.PrintPage += new PrintPageEventHandler(this.preluare_date);

            PrintDialog        pdlg = new PrintDialog();
            PrintPreviewDialog ppd  = new PrintPreviewDialog();

            ppd.Document = pd2;
            ppd.ShowDialog();

            pdlg.Document = pd2;

            if (pdlg.ShowDialog() == DialogResult.OK)
            {
                pd2.Print();
            }
        }
 private void verImpressãoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         string texto = "Compromisso"
                        + "\n\n\nData do compromisso: " + this.msk_data.Text
                        + "\n----------------------------------------------------------------------------"
                        + "\n\n" + this.rtb_Infos.Text;
         leitor = new StringReader(texto);
         PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog();
         printPreviewDialog1.Document        = this.printDocument1;
         printPreviewDialog1.FormBorderStyle = FormBorderStyle.Fixed3D;
         printPreviewDialog1.ShowDialog();
     }
     catch (Exception exp)
     {
         MessageBox.Show(" Erro : " + exp.Message.ToString());
     }
 }
Exemple #30
0
        private void MenuItemPrint_Click(object sender, EventArgs e)
        {
            PrintPreviewDialog dialog = new PrintPreviewDialog();

            dialog.Document = this.printDocument;
            ((ToolStrip)(dialog.Controls[1])).Items.RemoveAt(0);

            ToolStripButton b = new ToolStripButton();

            b.Image        = Properties.Resources.PrintDialog_16x;
            b.DisplayStyle = ToolStripItemDisplayStyle.Image;
            b.Click       += dialogPrint_Click;
            ((ToolStrip)(dialog.Controls[1])).Items.Insert(0, b);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                MessageBox.Show("Erfolg");
            }
        }
 private void button1_Click_1(object sender, EventArgs e)
 {
     try
     {
         if (dataGridView1.Rows[0].Cells[0].Value.ToString() != string.Empty)
         {
             dersadi = Microsoft.VisualBasic.Interaction.InputBox("Tahmin yapılan dersin adını giriniz.", "DERS", "", 150, 150);
             PrintPreviewDialog onizleme = new PrintPreviewDialog();
             onizleme.Document                 = printDocument1;
             ((Form)onizleme).WindowState      = FormWindowState.Maximized;
             onizleme.PrintPreviewControl.Zoom = 1.0;
             onizleme.ShowDialog();
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Final notu tahmini alanında yazdırılacak bir veri bulunamadı.", "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #32
0
 private void PrintOut(string data, bool file, bool prview)
 {
     try
     {
         using (streamToPrint = file ? (TextReader)new StreamReader (data) : (TextReader)new StringReader(data))
         {
             printFont = new Font("Arial", 10);
             PrintDocument pd = new PrintDocument();
             pd.PrintPage += new PrintPageEventHandler(PrintPageRoutine);
             if (prview)
             {
                 PrintPreviewDialog dlg = new PrintPreviewDialog();
                 dlg.Document = pd;
                 dlg.ShowDialog();
             }
             else
                 pd.Print();
         }
     }
     catch(Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemple #33
0
 public void PrintPreview(string name)
 {
     SourceCodePrintDocument printDocument = getPrintDocument(name);
     PrintPreviewDialog printPreview = new PrintPreviewDialog() {
         Document = printDocument,
         ShowIcon = false
     };
     printPreview.ShowDialog();
 }