public void TabStartDrag(TabItem tab, Point mousePosition) { reorderingVisual = new DragDropTabVisual(tab); // set visual location and show it reorderingVisual.Location = GetVisualLocation(tab, mousePosition); reorderingVisual.Show(); // refocus the main form Form parentForm = this.FindForm(); if (parentForm != null) { parentForm.Activate(); } // set the tab that is reordered reorderingTab = tab; reordering = true; }
public void TabEndDrag(TabItem tab, Point mousePosition) { if (reorderingVisual != null) { // destroy the visual reorderingVisual.Hide(); reorderingVisual.Dispose(); reorderingVisual = null; } // do the reordering // get the index of the tab below the mouse int insertIndex = GetReorderInsertLocation(tab, mousePosition); // get the insert direction lastInsertDirection = GetInsertDirection(tab, mousePosition, insertIndex); if (lastInsertDirection != InsertDirection.None) { if (lastInsertDirection == InsertDirection.Left) { InsertTabAt(reorderingTab, insertIndex); } else { InsertTabAt(reorderingTab, insertIndex + 1); } } reorderingTab = null; // remove insertion marker lastInsertDirection = InsertDirection.None; this.Invalidate(); reordering = false; }
public void TabStartDrag(TabItem tab, Point mousePosition) { reorderingVisual = new DragDropTabVisual(tab); // set visual location and show it reorderingVisual.Location = GetVisualLocation(tab, mousePosition); reorderingVisual.Show(); // refocus the main form Form parentForm = this.FindForm(); if(parentForm != null) { parentForm.Activate(); } // set the tab that is reordered reorderingTab = tab; reordering = true; }
public void TabEndDrag(TabItem tab, Point mousePosition) { if(reorderingVisual != null) { // destroy the visual reorderingVisual.Hide(); reorderingVisual.Dispose(); reorderingVisual = null; } // do the reordering // get the index of the tab below the mouse int insertIndex = GetReorderInsertLocation(tab, mousePosition); // get the insert direction lastInsertDirection = GetInsertDirection(tab, mousePosition, insertIndex); if(lastInsertDirection != InsertDirection.None) { if(lastInsertDirection == InsertDirection.Left) { InsertTabAt(reorderingTab, insertIndex); } else { InsertTabAt(reorderingTab, insertIndex + 1); } } reorderingTab = null; // remove insertion marker lastInsertDirection = InsertDirection.None; this.Invalidate(); reordering = false; }