Page 1 of 1

Drag and Drop from one control to another

Posted: Fri Jun 29, 2012 3:41 am
by zzfive03
Hello, i am brand new to gdpicture, and am evaluating the product. I need to create a win control that is a "document splitter". I want to have a main document, (shown in thumbnail view) and then several other thumbnail viewers that i can drag document pages into.

How might the code look on the drop event that will allow me to:
1) Add the selected thumbnails to the target control
2) Remove the selected documents from the source control
3) When i click my "split" button, how can i reference my now split thumbnails back to my origial document so I can do the actual splitting.

Thank you in advance for any guideance.


Re: Drag and Drop from one control to another

Posted: Fri Jun 29, 2012 5:44 pm
by zzfive03
Here is how I think i will solve it... (note, i am using PDF4NET to split, just because that was the tool I already had)

private void thumbnailEx2_DragDrop(object sender, DragEventArgs e)
string[] formats = e.Data.GetFormats();
ListView.SelectedListViewItemCollection coll = (ListView.SelectedListViewItemCollection)e.Data.GetData(formats[0].ToString());
MovePages(sOriginalFile, coll, sWorkingFolder + thumbnailEx2.Tag.ToString() + ".pdf");


private void MovePages(string sourcePath, ListView.SelectedListViewItemCollection sourcePages, string targetPath)
bool bDoesTargetExist = File.Exists(targetPath);

PDFDocument objOriginal = new PDFDocument(sourcePath);

PDFDocument objTarget;// = new PDFDocument();

if (bDoesTargetExist)
PDFDocument objT = new PDFDocument(targetPath);
objTarget = objT;
PDFDocument objT = new PDFDocument();
objTarget = objT;

foreach(ListViewItem item in sourcePages)
objTarget.Pages.Add(objOriginal.Pages[Convert.ToInt32(item.Text.Replace("Page ",""))-1]);

int iPagesRemoved = 0;
foreach (ListViewItem item in sourcePages)
objOriginal.Pages.RemoveAt(Convert.ToInt32(item.Text.Replace("Page ", "")) - 1- iPagesRemoved);


GdPicture.GdViewer viewer1 = new GdViewer();