Skip to content

Commit

Permalink
Do not raise drag&drop events for invalid an drop target. Fixes #216
Browse files Browse the repository at this point in the history
  • Loading branch information
oozcitak committed Nov 22, 2019
1 parent a1705cd commit 319c9ec
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 41 deletions.
31 changes: 16 additions & 15 deletions ImageListView/ImageListViewNavigationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -821,11 +821,6 @@ public void KeyUp(KeyEventArgs e)
#endregion

#region Drag and Drop Event Handlers
public void GiveFeedback(GiveFeedbackEventArgs gfbevent)
{

}

/// <summary>
/// Handles control's DragDrop event.
/// </summary>
Expand All @@ -841,15 +836,18 @@ public void DragDrop(DragEventArgs e)
if (index > mImageListView.Items.Count)
index = mImageListView.Items.Count;

int i = 0;
ImageListViewItem[] draggedItems = new ImageListViewItem[mImageListView.SelectedItems.Count];
foreach (ImageListViewItem item in mImageListView.SelectedItems)
if (index != -1)
{
draggedItems[i] = item;
i++;
}
int i = 0;
ImageListViewItem[] draggedItems = new ImageListViewItem[mImageListView.SelectedItems.Count];
foreach (ImageListViewItem item in mImageListView.SelectedItems)
{
draggedItems[i] = item;
i++;
}

mImageListView.OnDropItems(new DropItemEventArgs(index, draggedItems));
mImageListView.OnDropItems(new DropItemEventArgs(index, draggedItems));
}
}
else
{
Expand All @@ -859,11 +857,14 @@ public void DragDrop(DragEventArgs e)
if (index > mImageListView.Items.Count)
index = mImageListView.Items.Count;

if (e.Data != null && e.Data.GetDataPresent(DataFormats.FileDrop))
if (index != -1)
{
string[] filenames = (string[])e.Data.GetData(DataFormats.FileDrop);
if (e.Data != null && e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] filenames = (string[])e.Data.GetData(DataFormats.FileDrop);

mImageListView.OnDropFiles(new DropFileEventArgs(index, filenames));
mImageListView.OnDropFiles(new DropFileEventArgs(index, filenames));
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions ImageListView/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("13.7.0.0")]
[assembly: AssemblyFileVersion("13.7.0.0")]
[assembly: AssemblyVersion("13.7.1.0")]
[assembly: AssemblyFileVersion("13.7.1.0")]
36 changes: 18 additions & 18 deletions ImageListViewDemo/DemoForm.Designer.cs

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

3 changes: 2 additions & 1 deletion ImageListViewDemo/DemoForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public DemoForm()
imageListView1.Columns.Add(ColumnType.Dimensions);
imageListView1.Columns.Add(ColumnType.FileSize);
imageListView1.Columns.Add(ColumnType.FolderName);
imageListView1.Columns.Add(ColumnType.DateModified);
var col = new ImageListView.ImageListViewColumnHeader(ColumnType.Custom, "random", "Random");
col.Comparer = new RandomColumnComparer();
imageListView1.Columns.Add(col);
Expand All @@ -137,7 +138,7 @@ public class RandomColumnComparer : IComparer<ImageListViewItem>
{
public int Compare(ImageListViewItem x, ImageListViewItem y)
{
return int.Parse(x.SubItems["random"].Text.Substring(1, 1)).CompareTo(int.Parse(y.SubItems["random"].Text.Substring(1, 1)));
return int.Parse(x.SubItems["random"].Text).CompareTo(int.Parse(y.SubItems["random"].Text));
}
}
#endregion
Expand Down
10 changes: 5 additions & 5 deletions ImageListViewDemo/DemoForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADi
CgAAAk1TRnQ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Btq88n9gIQgvXwk2YIABAwMAn/6VAK0M5pEAAAAASUVORK5CYII=
</value>
</data>
<data name="verticalStripToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEySURBVDhPY6AYBBaszO5de+dL9fI7/6uWAfGSW/8rF934
X7bg6v/SeVf+F8+99L9o1vn/BTPP/c+fdvp/zpST/6umHfkC0gc2oHXNjb+Tdr74TyrOmrD/L9gAkM3k
X7bg6v/SeVf+F8+99L9o1vn/BTPP/c+fdvp/zpST/6umHfkC0gc2oHXN1b+Tdr74TypOn7D/L9gAkM3k
4LTuA//BBlQtuf2fHJDcvhdiQOXim1AhVNB4GIGxgYTWXVADgAGGDYA0zr+E24C4xu0QA0ChjQ0QckFM
3VaIAaCoIgT+/fsHZSFAVM0miAHFcy5ChVBB/sY0OP779y9UFAEiqjZADMiffgYqhApAGmeenwCmsYGQ
0jUQA/KmnIIKoQJkF2ADwcWrIAbkTDoBFSINBBathBgQWLh8ZUbfYXDKSunY9z+xdff/+OadwFDeAg6o
iOqN/8Mr1/0PK1sLdPZqoM0r/wcWgvDylWADBhgwMAAABCqaOq7F4a4AAAAASUVORK5CYII=
iOqN/8Mr1/0PK1sLdPZqoM0r/wcWgvDylWADBhgwMAAA73uaNK97qNUAAAAASUVORK5CYII=
</value>
</data>
<data name="clearThumbsToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
Expand Down

0 comments on commit 319c9ec

Please sign in to comment.