Skip to content

Commit

Permalink
Version 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnSpahr authored Nov 8, 2019
1 parent e1c8098 commit 5eef2d5
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 47 deletions.
4 changes: 2 additions & 2 deletions PDF Merger/PDF Merger/AboutBox1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 30 additions & 29 deletions PDF Merger/PDF Merger/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 32 additions & 16 deletions PDF Merger/PDF Merger/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,28 @@ public Form1()
private void Button1_Click(object sender, EventArgs e)
{
//add pdf
openFileDialog1.Multiselect = true;

if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
//add selected PDF file to listbox
var file = openFileDialog1.FileName;
listBox1.Items.Add(file);
//add selected PDF files to listbox
foreach (var file in openFileDialog1.FileNames)
{
pdfList.Items.Add(file);
}
}
}

private void RemoveBtn_Click(object sender, EventArgs e)
{
//remove pdf
ListBox.SelectedObjectCollection selectedItems = new ListBox.SelectedObjectCollection(listBox1);
ListBox.SelectedObjectCollection selectedItems = new ListBox.SelectedObjectCollection(pdfList);

if (listBox1.SelectedIndex != -1)
if (pdfList.SelectedIndex != -1)
{
//Removes item
for (int i = selectedItems.Count - 1; i >= 0; i--)
listBox1.Items.Remove(selectedItems[i]);
pdfList.Items.Remove(selectedItems[i]);
}
else
{
Expand All @@ -57,17 +61,18 @@ private void ClearBtn_Click(object sender, EventArgs e)
if (MessageBox.Show("Are you sure you want to clear the list box?", "PDF Merger", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
//clears listbox items
listBox1.Items.Clear();
pdfList.Items.Clear();
}
}

private void MergeBtn_Click(object sender, EventArgs e)
{
if (listBox1.Items.Count > 1)
saveFileDialog1.Filter = "PDF Files (*.pdf)|*.pdf";
if (pdfList.Items.Count > 1)
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
var List = listBox1.Items.Cast<String>().ToList(); //creates list of items in listbox
var List = pdfList.Items.Cast<String>().ToList(); //creates list of items in listbox

PdfDocument outputDocument = new PdfDocument(); //creates output document

Expand Down Expand Up @@ -103,22 +108,22 @@ private void UpBtn_Click(object sender, EventArgs e)

public void MoveItem(int direction)
{
if (listBox1.SelectedItem == null || listBox1.SelectedIndex < 0)
if (pdfList.SelectedItem == null || pdfList.SelectedIndex < 0)
return; //no selected item

int newIndex = listBox1.SelectedIndex + direction;
int newIndex = pdfList.SelectedIndex + direction;

if (newIndex < 0 || newIndex >= listBox1.Items.Count)
if (newIndex < 0 || newIndex >= pdfList.Items.Count)
return;

object selected = listBox1.SelectedItem; //selected item
object selected = pdfList.SelectedItem; //selected item

//removing removable element
listBox1.Items.Remove(selected);
pdfList.Items.Remove(selected);
//inserts in new location
listBox1.Items.Insert(newIndex, selected);
pdfList.Items.Insert(newIndex, selected);
//restore selection
listBox1.SetSelected(newIndex, true);
pdfList.SetSelected(newIndex, true);
}

private void DownBtn_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -158,6 +163,8 @@ private void ImageToPDFToolStripMenuItem_Click(object sender, EventArgs e)
private void SplitPDFToolStripMenuItem_Click(object sender, EventArgs e)
{
//Split PDF by pages
openFileDialog1.Multiselect = false;

if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
//Creates folder browser dialog called folder
Expand Down Expand Up @@ -278,5 +285,14 @@ private void GitHubPageToolStripMenuItem_Click(object sender, EventArgs e)
//github
Process.Start("https://github.com/johnspahr/pdftoolbox");
}

private void listBox1_MouseHover(object sender, EventArgs e)
{
//When mouse is hovered
if (pdfList.SelectedItem != null)
{
toolTip1.SetToolTip(pdfList, pdfList.GetItemText(pdfList.SelectedItem));
}
}
}
}
3 changes: 3 additions & 0 deletions PDF Merger/PDF Merger/Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@
AAAAAElFTkSuQmCC
</value>
</data>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>346, 17</value>
</metadata>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>459, 17</value>
</metadata>
Expand Down
Binary file modified PDF Merger/PDF Merger/bin/Debug/PDF Merger.exe
Binary file not shown.
Binary file modified PDF Merger/PDF Merger/bin/Debug/PDF Merger.pdb
Binary file not shown.
Binary file modified PDF Merger/PDF Merger/bin/Release/PDF Merger.exe
Binary file not shown.
Binary file modified PDF Merger/PDF Merger/bin/Release/PDF Merger.pdb
Binary file not shown.

0 comments on commit 5eef2d5

Please sign in to comment.