public virtual void HandleCommand(PrintingSystemCommand command, object[] args, IPrintControl control, ref bool handled)
        {
            if (!CanHandleCommand(command, control))
            {
                return;
            }
            handled = true;
            XtraForm1 exportOptionsForm = new XtraForm1();

            if (exportOptionsForm.ShowDialog() == DialogResult.OK)
            {
                if (exportOptionsForm.ExportToDiffrentSheets)
                {
                    SeparateSheetsExportHelper.Export("XtraReport5.xls", exportOptionsForm.ExportOptions);
                }
                else
                {
                    control.PrintingSystem.ExportToXls("XtraReport5.xls", exportOptionsForm.ExportOptions);
                }
            }
            if (File.Exists("XtraReport5.xls"))
            {
                Process.Start("XtraReport5.xls");
            }
        }
Пример #2
0
        public virtual void HandleCommand(PrintingSystemCommand command, object[] args, IPrintControl control, ref bool handled)
        {
            if (!CanHandleCommand(command, control))
            {
                return;
            }

            XtraReport1 report = new XtraReport1();
            Stream      myStream;

            report.Parameters["IsExporting"].Value = true;
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter           = "Excel files (*.xls)|*.xls|All files (*.*)|*.*";
            saveFileDialog1.FilterIndex      = 2;
            saveFileDialog1.RestoreDirectory = true;

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                if ((myStream = saveFileDialog1.OpenFile()) != null)
                {
                    report.ExportToXls(myStream);

                    myStream.Close();
                }
            }


            // Set handled to true to avoid the standard exporting procedure to be called.
            handled = true;
        }
        /// <summary>
        /// <para>
        /// If implemented by a class, allows you to handle Printing System commands (listed in the <see cref="T:DevExpress.XtraPrinting.PrintingSystemCommand"/> enumeration).
        /// </para>
        /// </summary>
        /// <param name="command">A <see cref="T:DevExpress.XtraPrinting.PrintingSystemCommand"/> enumeration value.
        ///             </param><param name="args">An array of <see cref="T:System.Object"/> values, specifying the command arguments.
        ///             </param><param name="printControl">An object implementing the <see cref="T:DevExpress.XtraPrinting.IPrintControl"/> interface (typically, this is a <see cref="T:DevExpress.XtraPrinting.Control.PrintControl"/> instance).
        ///             </param><param name="handled"><b>true</b> if the command has been handled; otherwise <b>false</b>.
        ///             </param>
        public void HandleCommand(PrintingSystemCommand command, object[] args, IPrintControl printControl, ref bool handled)
        {
            if (!CanHandleCommand(command, printControl)) return;

            DocumentViewer documentViewer = printControl as DocumentViewer;

            if (documentViewer != null)
            {
                // Set handled to 'true' to prevent the standard exporting procedure from being called.
                handled = true;

                XtraReportFactura xtraReportFactura = documentViewer.DocumentSource as XtraReportFactura;

                if (xtraReportFactura != null)
                {
                    Factura factura = xtraReportFactura.Factura;

                    string escritorio = Settings.Default.carpetaSalidaPDF;

                    string nombreFichero = Path.Combine(escritorio, string.Format("Factura-{0}.pdf", factura.Numero));

                    if (File.Exists(nombreFichero)
                        && XtraMessageBox.Show(string.Format(@"¿Desea sobreescribir el fichero '{0}'?", nombreFichero),
                        string.Format("Exportar a PDF la factura {0}", factura.Numero),
                        MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                    {
                        return;
                    }

                    xtraReportFactura.ExportToPdf(nombreFichero);
                }
            }
        }
Пример #4
0
        public virtual void HandleCommand(PrintingSystemCommand command, object[] args, IPrintControl control, ref bool handled)
        {
            if (!CanHandleCommand(command, control))
            {
                return;
            }

            try
            {
                if (Report != null)
                {
                    Report.Print();
                }
            }
            catch (Exception)
            {
            }

            handled = true;
            ////To do something
            //if (!this.BeforePrint())
            //{
            //    handled = true;
            //    //return;
            //}

            ////Report is printed
            //this.HasPrinted = true;
        }
Пример #5
0
 public static void ExecutePrintCommand(IPrintable control, PrintingSystemCommand command, object[] args)
 {
     using PrintableComponentLink link = new PrintableComponentLink()
           {
               Component = control
           };
     ExecutePrintCommand(link, command, args);
 }
Пример #6
0
 public static void ExecutePrintCommand(RichTextBox control, PrintingSystemCommand command)
 {
     using RichTextBoxLink link = new RichTextBoxLink()
           {
               RichTextBox = control, PrintFormat = RichTextPrintFormat.ClientPageSize
           };
     ExecutePrintCommand(link, command);
 }
Пример #7
0
            public void HandleCommand(PrintingSystemCommand command, object[] args, IPrintControl printControl, ref bool handled)
            {
                if (!CanHandleCommand(command, printControl))
                {
                    return;
                }

                //handled = true;
            }
Пример #8
0
 public virtual void HandleCommand(PrintingSystemCommand command, object[] args, IPrintControl control, ref bool handled)
 {
     if (!CanHandleCommand(command, control))
     {
         return;
     }
     MessageBox.Show("Handled!");
     handled = true;
 }
            public bool CanHandleCommand(PrintingSystemCommand command, IPrintControl printControl)
            {
                bool handle = false;

                if (command == PrintingSystemCommand.ExportXls)
                {
                    handle = true;
                }
                return(handle);
            }
Пример #10
0
        public static void ExecutePrintCommandForText(string text, PrintingSystemCommand command)
        {
            using RichTextBox box = new RichTextBox()
                  {
                      Visible = false
                  };
            box.CreateControl();
            box.Text = text;

            ExecutePrintCommand(box, command);
        }
Пример #11
0
        public static void ExecutePrintCommandForRtf(string rtf, PrintingSystemCommand command)
        {
            using RichTextBox box = new RichTextBox()
                  {
                      Visible = false
                  };
            box.CreateControl();
            box.Rtf = rtf;

            ExecutePrintCommand(box, command);
        }
Пример #12
0
/// <summary>
/// Complete retrieval and then execute command
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

        private void CompleteRetrievalAndExecCommand(PrintingSystemCommand cmd)
        {
            DialogResult dr = CompleteRetrieval();

            if (dr == DialogResult.Cancel)
            {
                return;
            }

            PrintingSystem ps = (PrintingSystem)Instance.PrintControl.PrintingSystem;

            ps.ExecCommand(cmd);
        }
Пример #13
0
            public virtual void HandleCommand(PrintingSystemCommand command,
                                              object[] args, IPrintControl printControl, ref bool handled)
            {
                if (!CanHandleCommand(command, printControl))
                {
                    return;
                }

                // Export the document to png.
                printControl.PrintingSystem.ExportToImage("C:\\Report.png", ImageFormat.Png);

                // Set handled to 'true' to prevent the standard exporting procedure from being called.
                handled = true;
            }
Пример #14
0
        public bool CanHandleCommand(PrintingSystemCommand command, IPrintControl printControl)
        {
            bool result;

            switch (command)
            {
            case PrintingSystemCommand.Print:
                //result = this.repotPrint.Report.ToString().Equals("HTN.BITS.UIL.PLASESS.Reports.RPT_PRODUCT_CARD");
                switch (this.repotPrint.Report.ToString())
                {
                case "HTN.BITS.UIL.PLASESS.Reports.RPT_PRODUCT_CARD":
                    result = true;
                    break;

                case "HTN.BITS.UIL.PLASESS.Reports.RPT_PRODUCT_CARD_8545":
                    result = true;
                    break;

                default:
                    result = false;
                    break;
                }
                break;

            case PrintingSystemCommand.PrintDirect:
                //result = this.repotPrint.Report.ToString().Equals("HTN.BITS.UIL.PLASESS.Reports.RPT_PRODUCT_CARD");
                switch (this.repotPrint.Report.ToString())
                {
                case "HTN.BITS.UIL.PLASESS.Reports.RPT_PRODUCT_CARD":
                    result = true;
                    break;

                case "HTN.BITS.UIL.PLASESS.Reports.RPT_PRODUCT_CARD_8545":
                    result = true;
                    break;

                default:
                    result = false;
                    break;
                }
                break;

            default:
                result = false;
                break;
            }

            return(result);
        }
 public void HandleCommand(PrintingSystemCommand command, object[] args, IPrintControl printControl, ref bool handled)
 {
     if (command == PrintingSystemCommand.ExportXls)
     {
         handled = true;
         SaveFileDialog dlg = new SaveFileDialog();
         dlg.Title      = "导出Excel";
         dlg.DefaultExt = "";
         dlg.Filter     = "Microsoft Excel 97-2003 工作表|*.xls";
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             string fileName = dlg.FileName;
             printControl.PrintingSystem.ExportOptions.Xls.ExportMode = XlsExportMode.DifferentFiles;
             printControl.PrintingSystem.ExportOptions.Xls.PageRange  = "1-" + printControl.PrintingSystem.Pages.Count;
             printControl.PrintingSystem.ExportToXls(fileName);
         }
     }
 }
Пример #16
0
        private static void ExecutePrintCommand(LinkBase link, PrintingSystemCommand command, object[] args)
        {
            using PrintingSystem ps = new PrintingSystem();
            using (new WaitCursor())
            {
                link.CreateDocument(ps);
            }

            using var printTool = new PrintTool(ps);
            if (args != null)
            {
                printTool.PreviewRibbonForm.PrintControl.ExecCommand(command, args);
            }
            else
            {
                printTool.PreviewRibbonForm.PrintControl.ExecCommand(command);
            }
        }
Пример #17
0
        public void HandleCommand(PrintingSystemCommand command, object[] args, IPrintControl printControl, ref bool handled)
        {
            if (!CanHandleCommand(command, printControl))
            {
                return;
            }

            XlsxExportOptions options = new XlsxExportOptions()
            {
                ExportMode = XlsxExportMode.DifferentFiles
            };

            DialogResult dr = ExportOptionsTool.EditExportOptions(options, printControl.PrintingSystem);

            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.FileName = "XtraReport.xlsx";

                sfd.Filter = "XLSX File|*.xlsx";
                if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    printControl.PrintingSystem.ExportToXlsx(sfd.FileName, options);

                    string fileName = Path.GetFileNameWithoutExtension(sfd.FileName);
                    string path     = Path.GetDirectoryName(sfd.FileName);

                    List <string> fileNames = new List <string>();
                    for (int i = 1; i <= printControl.PrintingSystem.PageCount; i++)
                    {
                        string genFileName = string.Format("{0}\\{1}{2}", path, fileName, i);
                        System.IO.File.Move(genFileName + ".xlsx", String.Format("{0}{1}.xlsx", genFileName, FileName));
                    }
                }
            }

            handled = true;
        }
Пример #18
0
        /// <summary>
        /// <para>
        /// If implemented by a class, allows you to handle Printing System commands (listed in the <see cref="T:DevExpress.XtraPrinting.PrintingSystemCommand"/> enumeration).
        /// </para>
        /// </summary>
        /// <param name="command">A <see cref="T:DevExpress.XtraPrinting.PrintingSystemCommand"/> enumeration value.
        ///             </param><param name="args">An array of <see cref="T:System.Object"/> values, specifying the command arguments.
        ///             </param><param name="printControl">An object implementing the <see cref="T:DevExpress.XtraPrinting.IPrintControl"/> interface (typically, this is a <see cref="T:DevExpress.XtraPrinting.Control.PrintControl"/> instance).
        ///             </param><param name="handled"><b>true</b> if the command has been handled; otherwise <b>false</b>.
        ///             </param>
        public void HandleCommand(PrintingSystemCommand command, object[] args, IPrintControl printControl, ref bool handled)
        {
            if (!CanHandleCommand(command, printControl))
            {
                return;
            }

            DocumentViewer documentViewer = printControl as DocumentViewer;

            if (documentViewer != null)
            {
                // Set handled to 'true' to prevent the standard exporting procedure from being called.
                handled = true;

                XtraReportFactura xtraReportFactura = documentViewer.DocumentSource as XtraReportFactura;

                if (xtraReportFactura != null)
                {
                    Factura factura = xtraReportFactura.Factura;

                    string escritorio = Settings.Default.carpetaSalidaPDF;

                    string nombreFichero = Path.Combine(escritorio, string.Format("Factura-{0}.pdf", factura.Numero));

                    if (File.Exists(nombreFichero) &&
                        XtraMessageBox.Show(string.Format(@"¿Desea sobreescribir el fichero '{0}'?", nombreFichero),
                                            string.Format("Exportar a PDF la factura {0}", factura.Numero),
                                            MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                    {
                        return;
                    }

                    xtraReportFactura.ExportToPdf(nombreFichero);
                }
            }
        }
Пример #19
0
 /// <summary>
 /// <para>
 /// Indicates whether or not the specified Printing System command can be handled.
 /// </para>
 /// </summary>
 /// <param name="command">A <see cref="T:DevExpress.XtraPrinting.PrintingSystemCommand"/> enumeration value.
 ///             </param><param name="printControl">An object implementing the <see cref="T:DevExpress.XtraPrinting.IPrintControl"/> interface (typically, this is a <see cref="T:DevExpress.XtraPrinting.Control.PrintControl"/> instance).
 ///             </param>
 /// <returns>
 /// <b>true</b> if the command can be handled; otherwise <b>false</b>.
 /// </returns>
 public bool CanHandleCommand(PrintingSystemCommand command, IPrintControl printControl)
 {
     return(PrintingSystemCommand.ExportPdf == command);
 }
 /// <summary>
 /// <para>
 /// Indicates whether or not the specified Printing System command can be handled. 
 /// </para>
 /// </summary>
 /// <param name="command">A <see cref="T:DevExpress.XtraPrinting.PrintingSystemCommand"/> enumeration value.
 ///             </param><param name="printControl">An object implementing the <see cref="T:DevExpress.XtraPrinting.IPrintControl"/> interface (typically, this is a <see cref="T:DevExpress.XtraPrinting.Control.PrintControl"/> instance).
 ///             </param>
 /// <returns>
 /// <b>true</b> if the command can be handled; otherwise <b>false</b>.
 /// </returns>
 public bool CanHandleCommand(PrintingSystemCommand command, IPrintControl printControl)
 {
     return PrintingSystemCommand.ExportPdf == command;
 }
        /// <summary>
        /// Indicates whether or not the specified Printing System command can be handled.
        /// </summary>
        /// <param name="command">A <see cref="T:DevExpress.XtraPrinting.PrintingSystemCommand" /> enumeration value.</param>
        /// <param name="printControl">An object implementing the <see cref="T:DevExpress.XtraPrinting.IPrintControl" /> interface (typically, this is a <see cref="T:DevExpress.XtraPrinting.Control.PrintControl" /> instance).</param>
        /// <returns>
        ///   true, if the command can be handled; otherwise, false.
        /// </returns>
        public virtual bool CanHandleCommand(PrintingSystemCommand command, IPrintControl printControl)
        {
            bool canBeHandled = command == PrintingSystemCommand.ExportXlsx || command == PrintingSystemCommand.ExportXls || command == PrintingSystemCommand.ExportCsv;

            return(canBeHandled);
        }
Пример #22
0
 public virtual bool CanHandleCommand(PrintingSystemCommand command, IPrintControl control)
 {
     // This handler is used for the ExportXls command.
     return(command == PrintingSystemCommand.ExportXls);
 }
Пример #23
0
 private static void ExecutePrintCommand(LinkBase link, PrintingSystemCommand command)
 {
     ExecutePrintCommand(link, command, null);
 }
Пример #24
0
        public void HandleCommand(PrintingSystemCommand command, object[] args, IPrintControl printControl, ref bool handled)
        {
            ReportPrintTool printTool = new ReportPrintTool(this.repotPrint);

            switch (command)
            {
            case PrintingSystemCommand.Print:
                try
                {
                    DialogResult result = this.GetLogPrintTime();
                    if (result == DialogResult.OK)
                    {
                        if (printTool.PrintDialog() ?? false)
                        {
                            //if click print
                            if (this.logPrintTime)
                            {
                                UiUtility.UpdatePrintTime(this.seqNo, this.repotPrint.Parameters["paramUserPrint"].Value.ToString());
                            }

                            if (this.autoCloseAfterPrint)
                            {
                                this.tmrClosePreview.Enabled = true;
                            }
                        }
                    }
                }
                catch (Exception ex) { }

                handled = true;
                break;

            case PrintingSystemCommand.PrintDirect:
                try
                {
                    //DialogResult result = XtraMessageBox.Show(this, "Do you want to print?", "Please Confirm", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    DialogResult result = this.GetLogPrintTime();
                    if (result == DialogResult.OK)
                    {
                        printTool.Print();

                        if (this.logPrintTime)
                        {
                            UiUtility.UpdatePrintTime(this.seqNo, this.repotPrint.Parameters["paramUserPrint"].Value.ToString());
                        }

                        if (this.autoCloseAfterPrint)
                        {
                            this.tmrClosePreview.Enabled = true;
                        }
                    }
                }
                catch (Exception ex) { }

                handled = true;
                break;

            default:
                break;
            }
            //if (command == PrintingSystemCommand.Print || command == PrintingSystemCommand.PrintDirect)
            //{
            //    try
            //    {
            //        DialogResult result = XtraMessageBox.Show(this, "Do you want to print?", "Please Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            //        if (result == DialogResult.Yes)
            //        {

            //        }
            //        else
            //        {

            //        }

            //        //ReportPrintTool printTool = new ReportPrintTool(this.repotPrint);
            //        //if (printTool.PrintDialog() ?? false)
            //        //{
            //        //    result = DialogResult.OK;
            //        //}
            //        //else
            //        //    result = DialogResult.Cancel;

            //        //result =printTool.PreviewForm.ShowDialog();

            //    }
            //    catch (Exception) { }
            //    finally
            //    {
            //        // Actually printed?
            //        //this.PrintResult = result;
            //    };

            //    // Set handled to true to avoid the standard procedure to be called.
            //    handled = true;
            //};
            //throw new NotImplementedException();
        }
Пример #25
0
 public bool CanHandleCommand(PrintingSystemCommand command, IPrintControl printControl)
 {
     return(command == PrintingSystemCommand.ExportXlsx);
 }
Пример #26
0
 public virtual bool CanHandleCommand(PrintingSystemCommand command, IPrintControl control)
 {
     // This handler is used for the ExportGraphic command.
     return(command == PrintingSystemCommand.Print || command == PrintingSystemCommand.PrintDirect);
 }
Пример #27
0
 public virtual bool CanHandleCommand(PrintingSystemCommand command, IPrintControl control)
 {
     return(command == PrintingSystemCommand.ZoomIn);
 }