Example #1
0
File: Form1.cs Project: koonath/mwp
 private void HideStampItems()
 {
     StampFileBox.Hide();
     RemoveImageButton.Hide();
     StampAllButton.Hide();
     StampLastPageButton.Hide();
 }
Example #2
0
File: Form1.cs Project: koonath/mwp
 private void StampFileBox_MouseDown(object sender, MouseEventArgs e)
 {
     if (StampFileBox.SelectedItem == null)
     {
         return;
     }
     StampFileBox.DoDragDrop(StampFileBox.SelectedItem, DragDropEffects.Move);
 }
Example #3
0
File: Form1.cs Project: koonath/mwp
 private void ShowStampItems()
 {
     InstructionsLabel1.Show();
     InstructionsLabel1.Text = "Drag and drop PDF files that need stamping, into the box below:";
     InstructionsLabel2.Show();
     InstructionsLabel2.Text = "Drag and drop image/PDF into the box:";
     FileNameBox.Show();
     PathsListBox.Show();
     StampFileBox.Show();
     RemoveButton.Show();
     RemoveAllButton.Show();
     RemoveImageButton.Show();
     GoButton.Show();
     GoButton.Text = "Stamp";
     HidePathsButton.Show();
     HidePathsButton.Text = "Hide Paths";
     StampAllButton.Show();
     StampAllButton.Checked = true;
     StampLastPageButton.Show();
 }
Example #4
0
File: Form1.cs Project: koonath/mwp
 private void StampFileBox_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
 {
     if (StampFileBox.SelectedItem == null)
     {
         if (e.Data.GetDataPresent(DataFormats.FileDrop))
         {
             string[] fileNames;
             fileNames = (string[])e.Data.GetData(DataFormats.FileDrop);
             {
                 int      length = fileNames[0].Length - 1;
                 string   temp   = System.IO.Path.GetExtension(fileNames[0]).ToLower();
                 string[] split  = fileNames[0].Split('\\');
                 if ((temp == ".pdf") || (temp == ".png") || (temp == ".jpg") || (temp == ".jpeg") || (temp == ".bmp") || (temp == ".gif") || (temp == ".tif") || (temp == ".tiff") || (temp == ".dib") || (temp == ".jpe") || (temp == ".jiff"))
                 {
                     StampFileBox.Items.Clear();
                     //StampFileBox.Items.Add(split[split.Length - 1]);
                     StampFileBox.Items.Add(fileNames[0]);
                 }
             }
         }
     }
     else
     {
         //if (PathsListBox.SelectedItem == null)
         {
             Point point = StampFileBox.PointToClient(new Point(e.X, e.Y));
             int   index = StampFileBox.IndexFromPoint(point);
             if (index < 0)
             {
                 index = StampFileBox.Items.Count - 1;
             }
             object dataStampFileBox = e.Data.GetData(DataFormats.Text);
             StampFileBox.Items.Remove(dataStampFileBox);
             StampFileBox.Items.Insert(index, dataStampFileBox);
         }
     }
 }
Example #5
0
File: Form1.cs Project: koonath/mwp
        private void Stamp(pdfforge.PDF.PDF pdf)
        {
            foreach (object item in PathsListBox.Items)
            {
                filePathsList.Add(PathsListBox.GetItemText(item));
            }

            if (filePathsList.Count == 0)
            {
                MessageBox.Show("No PDFs added for stamping!");
            }
            else if (StampFileBox.Items.Count == 0)
            {
                MessageBox.Show("No image added for stamping!");
            }
            else
            {
                foreach (string sourceFile in filePathsList)
                {
                    string fileName = System.IO.Path.GetFileNameWithoutExtension(sourceFile);
                    string filePath = System.IO.Path.GetDirectoryName(sourceFile);

                    string destinationFile = filePath + @"\" + fileName + "_1.pdf";
                    bool   exist           = System.IO.File.Exists(destinationFile);
                    while (exist == true)
                    {
                        fileName        = System.IO.Path.GetFileNameWithoutExtension(destinationFile);
                        destinationFile = filePath + @"\" + fileName + "_1.pdf";
                        exist           = System.IO.File.Exists(destinationFile);
                    }

                    int numberOfPages = pdf.NumberOfPages(sourceFile);

                    string stamp = StampFileBox.GetItemText(StampFileBox.Items[0]);

                    string extension = System.IO.Path.GetExtension(stamp).ToLower();

                    if (extension == ".pdf")
                    {
                        if (StampAllButton.Checked == true)
                        {
                            pdf.StampPDFFileWithPDFFile(sourceFile, destinationFile, stamp, 1, numberOfPages, true, 0.8f, 9);
                        }
                        else if (StampLastPageButton.Checked == true)
                        {
                            pdf.StampPDFFileWithPDFFile(sourceFile, destinationFile, stamp, numberOfPages, numberOfPages, true, 0.9f, 9);
                        }
                    }
                    else
                    {
                        if (StampAllButton.Checked == true)
                        {
                            pdf.StampPDFFileWithImage(sourceFile, destinationFile, stamp, 1, numberOfPages, true, 0.8f, 9);
                        }
                        else if (StampLastPageButton.Checked == true)
                        {
                            pdf.StampPDFFileWithImage(sourceFile, destinationFile, stamp, numberOfPages, numberOfPages, true, 0.8f, 9);
                        }
                    }
                }
                Forget(true);
            }
        }