Beispiel #1
0
        public static PrintSelection ToEto(this swc.PageRangeSelection value)
        {
            switch (value)
            {
            case swc.PageRangeSelection.AllPages:
                return(PrintSelection.AllPages);

            case swc.PageRangeSelection.UserPages:
                return(PrintSelection.SelectedPages);

            default:
                throw new NotSupportedException();
            }
        }
        /// <summary>
        /// Print To.
        /// </summary>
        public void PrintTo()
        {
            int errCnt   = 0;
            int fromPage = -1;
            int toPage   = -1;

            System.Windows.Controls.PrintDialog pd = new System.Windows.Controls.PrintDialog();
            pd.UserPageRangeEnabled = true;
            if (true == pd.ShowDialog())
            {
                if (null != pd.PrintQueue)
                {
                    _printerName = pd.PrintQueue.FullName;
                    short noOfCopies = (!pd.PrintTicket.CopyCount.HasValue) ?
                                       (short)1 : Convert.ToInt16(pd.PrintTicket.CopyCount.Value);

                    System.Windows.Controls.PageRangeSelection sel = pd.PageRangeSelection;
                    if (sel == PageRangeSelection.UserPages)
                    {
                        // User page.
                        if (null != pd.PageRange)
                        {
                            fromPage = pd.PageRange.PageFrom;
                            toPage   = pd.PageRange.PageTo;
                        }
                    }

                    // Print but not raise event.
                    if (!this.Print(fromPage, toPage, noOfCopies, false))
                    {
                        ++errCnt;
                    }
                }
            }
            pd = null;

            // Raise event.
            if (errCnt <= 0)
            {
                if (null != Printed)
                {
                    Printed.Call(this, EventArgs.Empty);
                }
            }
            else
            {
                MessageBox.Show("Print failed.", "CKD Robbing Program");
            }
        }