A "please wait" form for the PDFExport.
Inheritance: System.Windows.Forms.Form
示例#1
0
        /// <summary>
        ///     Run-method of the display thread. Shows the form and waits
        ///     for the end.
        /// </summary>
        /// <param name="center">The center of the form.</param>
        private static void Run(object center)
        {
            Point             point        = ( Point )center;
            PDFExportProgress progressForm = new PDFExportProgress( );

            progressForm.Location = new Point(point.X - progressForm.Width / 2, point.Y - progressForm.Height / 2);
            progressForm.Show( );

            try
            {
                while (true)
                {
                    Thread.Sleep(5);
                    Application.DoEvents( );
                }
            }
            catch (ThreadAbortException)
            {
                //We are asked to close the window
                progressForm.Close( );
                progressForm.Dispose( );
            }
        }
示例#2
0
        // ========================================================================
        // Methods

        #region === Methods

        /// <summary>
        ///     Starts the functionality of the plugin.
        /// </summary>
        protected void Launch( )
        {
            if (!DocumentManager.HasDocument)
            {
                return;
            }

            string fileName;

            using (SaveFileDialog dialog = new SaveFileDialog( ))
            {
                dialog.Filter           = Strings.SaveDialogFilter;
                dialog.RestoreDirectory = true;
                if (dialog.ShowDialog( ) == DialogResult.Cancel)
                {
                    return;
                }
                fileName = dialog.FileName;
            }

            PDFExportOptions optionsForm = new PDFExportOptions( );

            if (optionsForm.ShowDialog( ) == DialogResult.Cancel)
            {
                return;
            }
            Padding padding = new Padding(( int )new XUnit(optionsForm.PDFPadding.Left, optionsForm.Unit).Point, ( int )new XUnit(optionsForm.PDFPadding.Top, optionsForm.Unit).Point, ( int )new XUnit(optionsForm.PDFPadding.Right, optionsForm.Unit).Point, ( int )new XUnit(optionsForm.PDFPadding.Bottom, optionsForm.Unit).Point);

            MainForm mainForm = Application.OpenForms.OfType <MainForm>( ).FirstOrDefault( );

            PDFExportProgress.ShowAsync(mainForm);

            PDFExporter exporter = new PDFExporter(fileName, DocumentManager.ActiveDocument, optionsForm.SelectedOnly, padding);

            Application.DoEvents( );
            exporter.Export( );

            // Running the exporter within an extra thread isn't a good idea since
            // the exporter uses GDI+. NClass uses GDI+ also if it has to redraw the
            // diagram. GDI+ can't be used by two threads at the same time.
            //Thread exportThread = new Thread(exporter.Export)
            //                        {
            //                          Name = "PDFExporterThread",
            //                          IsBackground = true
            //                        };
            //exportThread.Start();
            //while (exportThread.IsAlive)
            //{
            //  Application.DoEvents();
            //  exportThread.Join(5);
            //}
            //exportThread.Join();

            PDFExportProgress.CloseAsync( );

            if (exporter.Successful)
            {
                if (new PDFExportFinished( ).ShowDialog(mainForm) == DialogResult.OK)
                {
                    Process.Start(fileName);
                }
            }
        }
示例#3
0
    /// <summary>
    /// Run-method of the display thread. Shows the form and waits
    /// for the end.
    /// </summary>
    /// <param name="center">The center of the form.</param>
    private static void Run(Object center)
    {
      Point point = (Point)center;
      PDFExportProgress progressForm = new PDFExportProgress();
      progressForm.Location = new Point(point.X - progressForm.Width/2, point.Y - progressForm.Height/2);
      progressForm.Show();

      try
      {
        while(true)
        {
          Thread.Sleep(5);
          Application.DoEvents();
        }
      }
      catch(ThreadAbortException)
      {
        //We are asked to close the window
        progressForm.Close();
        progressForm.Dispose();
      }
    }