Esempio n. 1
0
 public static System.Drawing.Bitmap GetImageFromPage(string inputFile,
     string outputFile, int pageNumber, bool ifNice)
 {
     System.Drawing.Bitmap image = null;
     try
     {
         ConvertPage(GetArgsForAPI(inputFile, outputFile, pageNumber, ifNice));
         using (FileStream stream = new FileStream(outputFile, FileMode.Open,
             FileAccess.Read))
         {
             image = new System.Drawing.Bitmap(stream);
             stream.Close();
         }
     }
     catch (Exception ex)
     {
         SendMailForm sendMail = new SendMailForm(ex);
         sendMail.ShowDialog();
     }
     finally
     {
         try
         {
             File.Delete(outputFile);
         }
         catch (IOException ex)
         {
             System.Windows.Forms.MessageBox.Show("Błąd przy próbie usunięcia zasobów tymczasowych.\r\nTreść: "
                 + ex.Message, "Błąd", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
         }
     }
     return image;
 }
Esempio n. 2
0
 private void ShowThreadExceptionDialog(Exception ex)
 {
     SendMailForm sendMail = new SendMailForm(ex);
     sendMail.StartPosition = FormStartPosition.CenterScreen;
     sendMail.ShowDialog();
 }
Esempio n. 3
0
        private static void ConvertPage(string[] argsToAPI)
        {
            IntPtr instance;
            lock (padlock)
            {
                CreateAPI(out instance, IntPtr.Zero);
                try
                {
                    int result = InitAPI(instance, argsToAPI.Length, argsToAPI);

                    if (result < 0)
                    {
                        throw new ExternalException("Błąd konwersji.", result);
                    }
                }
                catch (ExternalException ex)
                {
                    SendMailForm sendMail = new SendMailForm(ex);
                    sendMail.ShowDialog();
                }
                finally
                {
                    Clear(instance);
                }
            }
        }