protected internal virtual void OnTabMoving(TabMovingEventArgs args) { if (TabMoving != null) TabMoving(this, args); }
/// <summary> /// Moves the given page to the new index. /// </summary> private void MovePage(TabPage page, int newIndex) { int oldIndex = TabPages.IndexOf(page); TabMovingEventArgs args = new TabMovingEventArgs(page, oldIndex, newIndex); OnTabMoving(args); if (args.Cancel) return; bool selectTab = (oldIndex == SelectedIndex); // The simple approach here would be to remove the page and insert it at the new location. // However this will produce heavy flickering, so we move the pages one by one instead. // While moving the pages also move their corresponding tab info to keep current states. TabInfo oldInfo = layoutInfo[oldIndex]; if (oldIndex < newIndex) { for (int index = oldIndex; index < newIndex; index++) { TabPages[index] = TabPages[index + 1]; layoutInfo[index] = layoutInfo[index + 1]; } TabPages[newIndex] = page; layoutInfo[newIndex] = oldInfo; AdjustLayoutInfo(TabPages[oldIndex]); } else { for (int index = oldIndex; index > newIndex; index--) { TabPages[index] = TabPages[index - 1]; layoutInfo[index] = layoutInfo[index - 1]; } TabPages[newIndex] = page; layoutInfo[newIndex] = oldInfo; AdjustLayoutInfo(page); } // Keep the tab selected which was selected before. if (selectTab) SelectedIndex = newIndex; Invalidate(); }
private void editorTabControl_TabMoving(object sender, TabMovingEventArgs e) { Logger.LogDebug("WQE.net", 1, "Moving editor tab\n"); dbSqlEditorBE.sql_editor_reorder(e.MovedPage.Tag as AppViewDockContent, e.ToIndex); }