private void DockIconContainer_DragEnter(object sender, DragEventArgs e) { dragInProgress = true; if (!e.Data.GetDataPresent(DataFormats.FileDrop)) { return; } // Note that you can have more than one file. if (dragIndex == -1) { var files = (string[])e.Data.GetData(DataFormats.FileDrop); dragItem = new DockIcon(new IconModel { Path = files[0], Name = Path.GetFileNameWithoutExtension(files[0]) }); dragIndex = container.GetDropIndex(e.GetPosition(container).X - VMLocator.Main.OuterIconWidth / 2); container.Children.Insert(dragIndex, dragItem); } }
private void DockIconContainer_MouseMove(object sender, MouseEventArgs e) { if (draggedIcon == null) { return; } Point pos = e.GetPosition(canvas); Point cpos = e.GetPosition(container); int iconsize = SettingsManager.Settings.OuterIconSize; if (!IsDragging && GetDistance(e.GetPosition(null), startPos) > minDistance) { IsDragging = true; DetachDraggedIcon(); offset.X = cpos.X % iconsize - iconsize / 2; offset.Y = cpos.Y - container.ActualHeight / 2; } if (IsDragging) { MoveDraggedIcon(pos); if (container.IsPositionWithinBounds(cpos)) { int dropIndex = container.GetDropIndex(cpos.X); int count = container.CountIconsBefore(dropIndex); if (lastCount != count) { if (placeholder != null) { RemovePlaceholder(); } AddPlaceholder(dropIndex); lastCount = count; } } else if (placeholder != null) { RemovePlaceholder(); lastCount = -1; } } }