Ejemplo n.º 1
0
Archivo: Form1.cs Proyecto: koonath/mwp
        private void Merge(pdfforge.PDF.PDF pdf)
        {
            foreach (object item in PathsListBox.Items)
            {
                filePathsList.Add(PathsListBox.GetItemText(item));
            }

            if (filePathsList.Count == 0)
            {
                MessageBox.Show("No files added for merging!");
            }
            else
            {
                bool exist = System.IO.File.Exists(destinationFilePath);
                if ((exist == true) /*&& (overwriteSwitch == false)*/)
                {
                    MessageBox.Show("File already exists, please enter new file name");
                }
                else
                {
                    files = filePathsList.ToArray();
                    pdf.MergePDFFiles(ref files, destinationFilePath, false);
                    System.Diagnostics.Process.Start(destinationFilePath);
                    Forget(false);
                }
            }
        }
Ejemplo n.º 2
0
Archivo: Form1.cs Proyecto: koonath/mwp
 private void PathsListBox_MouseDown(object sender, MouseEventArgs e)
 {
     if (PathsListBox.SelectedItem == null)
     {
         return;
     }
     PathsListBox.DoDragDrop(PathsListBox.SelectedItem, DragDropEffects.Move);
 }
Ejemplo n.º 3
0
Archivo: Form1.cs Proyecto: koonath/mwp
 private void PathsListBox_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
 {
     if (PathsListBox.SelectedItem == null)
     {
         if (e.Data.GetDataPresent(DataFormats.FileDrop))
         {
             string[] fileNames;
             fileNames = (string[])e.Data.GetData(DataFormats.FileDrop);
             //if (actionSelected == (int)features.Merge)
             {
                 foreach (string name in fileNames)
                 {
                     int      length = name.Length - 1;
                     string   temp   = System.IO.Path.GetExtension(name).ToLower();
                     string[] split  = name.Split('\\');
                     if (temp == ".pdf")
                     {
                         FileNameBox.Items.Add(split[split.Length - 1]);
                         PathsListBox.Items.Add(name);
                     }
                 }
             }
             //else if (actionSelected == (int)features.Explode)
             //{
             //    int length = fileNames[0].Length - 1;
             //    string temp = fileNames[0].Substring(length - 2);
             //    string[] split = fileNames[0].Split('\\');
             //    if (temp == "pdf")
             //    {
             //        FileNameBox.Items.Clear();
             //        PathsListBox.Items.Clear();
             //        FileNameBox.Items.Add(split[split.Length - 1]);
             //        PathsListBox.Items.Add(fileNames[0]);
             //    }
             //}
         }
     }
     else
     {
         if (FileNameBox.SelectedItem == null)
         {
             Point point = PathsListBox.PointToClient(new Point(e.X, e.Y));
             int   index = PathsListBox.IndexFromPoint(point);
             if (index < 0)
             {
                 index = PathsListBox.Items.Count - 1;
             }
             object dataPathsListBox = e.Data.GetData(DataFormats.Text);
             object dataFileNameBox  = FileNameBox.Items[PathsListBox.SelectedIndex];
             FileNameBox.Items.Remove(dataFileNameBox);
             FileNameBox.Items.Insert(index, dataFileNameBox);
             PathsListBox.Items.Remove(dataPathsListBox);
             PathsListBox.Items.Insert(index, dataPathsListBox);
         }
     }
 }
Ejemplo n.º 4
0
Archivo: Form1.cs Proyecto: koonath/mwp
 private void HideMergeItems()
 {
     InstructionsLabel1.Hide();
     InstructionsLabel2.Hide();
     FileNameBox.Hide();
     PathsListBox.Hide();
     DestinationFilePathTextBox.Hide();
     RemoveButton.Hide();
     RemoveAllButton.Hide();
     GoButton.Hide();
     HidePathsButton.Hide();
 }
Ejemplo n.º 5
0
Archivo: Form1.cs Proyecto: koonath/mwp
 private void HidePathsButton_Click(object sender, EventArgs e)
 {
     if (PathsListBox.Visible == true)
     {
         PathsListBox.Hide();
         HidePathsButton.Text = "Show Paths";
     }
     else
     {
         PathsListBox.Show();
         HidePathsButton.Text = "Hide Paths";
     }
 }
Ejemplo n.º 6
0
Archivo: Form1.cs Proyecto: koonath/mwp
 private void ShowExplodeItems()
 {
     InstructionsLabel1.Show();
     InstructionsLabel1.Text = "Drag and drop PDF files to explode, into the box below:";
     //InstructionsLabel2.Show();
     //InstructionsLabel2.Text = "Full file path for exploded pages";
     FileNameBox.Show();
     PathsListBox.Show();
     //DestinationFilePathTextBox.Show();
     //DestinationFilePathTextBox.Text = destinationFilePath;
     RemoveButton.Show();
     RemoveAllButton.Show();
     GoButton.Show();
     GoButton.Text = "Kaboom!";
     HidePathsButton.Show();
     HidePathsButton.Text = "Hide Paths";
 }
Ejemplo n.º 7
0
Archivo: Form1.cs Proyecto: koonath/mwp
 private void ShowMergeItems()
 {
     InstructionsLabel1.Show();
     InstructionsLabel1.Text = "Drag and drop PDF files to merge, into the box below:";
     InstructionsLabel2.Show();
     InstructionsLabel2.Text = "Full file path for merged file:";
     FileNameBox.Show();
     PathsListBox.Show();
     DestinationFilePathTextBox.Show();
     DestinationFilePathTextBox.Text = destinationFilePath;
     RemoveButton.Show();
     RemoveAllButton.Show();
     GoButton.Show();
     GoButton.Text = "Merge";
     HidePathsButton.Show();
     HidePathsButton.Text = "Hide Paths";
 }
Ejemplo n.º 8
0
Archivo: Form1.cs Proyecto: 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();
 }
Ejemplo n.º 9
0
Archivo: Form1.cs Proyecto: koonath/mwp
        private void Explode(pdfforge.PDF.PDF pdf)
        {
            foreach (object item in PathsListBox.Items)
            {
                filePathsList.Add(PathsListBox.GetItemText(item));
            }

            if (filePathsList.Count == 0)
            {
                MessageBox.Show("No files added for exploding!");
            }
            else
            {
                foreach (string sourcePath in filePathsList)
                {
                    pdf.SplitPDFFile(sourcePath, sourcePath);
                }
                Forget(true);
            }
        }
Ejemplo n.º 10
0
Archivo: Form1.cs Proyecto: 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);
            }
        }