private void OnTabControlDragOver(object sender, DragEventArgs e) { var hi = _tabControl.CalcHitInfo(_tabControl.PointToClient(new Point(e.X, e.Y))); if (hi.Page is TTabPage) { if (hi.Page != _movedPage) { if (_tabControl.TabPages.IndexOf(hi.Page) < _tabControl.TabPages.IndexOf(_movedPage)) { _tabControl.TabPages.Move(_tabControl.TabPages.IndexOf(hi.Page), _movedPage); TabMoved?.Invoke(_tabControl, new TabMoveEventArgs { MovedPage = _movedPage, TargetPage = hi.Page }); } else { _tabControl.TabPages.Move(_tabControl.TabPages.IndexOf(hi.Page) + 1, _movedPage); TabMoved?.Invoke(_tabControl, new TabMoveEventArgs { MovedPage = _movedPage, TargetPage = hi.Page, Offset = 1 }); } } e.Effect = DragDropEffects.Move; } else { e.Effect = DragDropEffects.None; } }
private void Tabs_DragOver(object sender, System.Windows.Forms.DragEventArgs e) { XtraTabControl c = sender as XtraTabControl; if (c == null) { return; } XtraTabHitInfo hi = c.CalcHitInfo(c.PointToClient(new Point(e.X, e.Y))); if (hi.Page != null) { if (hi.Page != TabDragPage && hi.Page != LastSwappedPage) // move it { int hpi = c.TabPages.IndexOf(hi.Page); int dpi = c.TabPages.IndexOf(TabDragPage); if (hpi < dpi) // moving left { c.TabPages.Move(hpi, TabDragPage); } else // moving right { c.TabPages.Move(hpi + 1, TabDragPage); } Document doc = DocumentList[dpi]; // move the query DocumentList.RemoveAt(dpi); if (hpi < 0 || hpi > DocumentList.Count) { throw new DataException("DocumentList.Insert out of range"); } DocumentList.Insert(hpi, doc); SelectQuery(hpi); } LastSwappedPage = hi.Page; e.Effect = DragDropEffects.Move; } else { e.Effect = DragDropEffects.None; } }
private void tcMain_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { XtraTabControl tabCtrl = sender as XtraTabControl; Point pt = MousePosition; XtraTabHitInfo info = tabCtrl.CalcHitInfo(tabCtrl.PointToClient(pt)); if (info.HitTest == XtraTabHitTest.PageHeader) { //contextPage = info.Page; TabContextMenu.Show(pt); } else { } } }
private void Tabs_DragOver(object sender, System.Windows.Forms.DragEventArgs e) { XtraTabControl c = sender as XtraTabControl; if (c == null) { return; } XtraTabHitInfo hi = c.CalcHitInfo(c.PointToClient(new Point(e.X, e.Y))); if (hi.Page != null && c.TabPages.IndexOf(hi.Page) != 0) { if (hi.Page != TabDragPage && hi.Page != LastSwappedPage) // move it { int hpi = c.TabPages.IndexOf(hi.Page); int dpi = c.TabPages.IndexOf(TabDragPage); if (hpi < dpi) // moving left { c.TabPages.Move(hpi, TabDragPage); } else // moving right { c.TabPages.Move(hpi + 1, TabDragPage); } hpi--; // adjust for criteria tab dpi--; QueryTable qt = Query.Tables[dpi]; // move the query table Query.RemoveQueryTableAt(dpi); Query.InsertQueryTable(hpi, qt); } LastSwappedPage = hi.Page; e.Effect = DragDropEffects.Move; } else { e.Effect = DragDropEffects.None; } }
/// <summary> /// Present a popup menu with all pages to select a page to move to. /// </summary> private void onTabControlCustomHeaderButtonClick(object sender, CustomHeaderButtonEventArgs e) { var popupMenu = new DXPopupMenu { MenuViewType = MenuViewType.Menu }; foreach (XtraTabPage page in _tabControl.TabPages) { var menuitem = new DXMenuItem(page.Text); menuitem.Click += onPageListMenuItemClick; menuitem.Tag = popupMenu; if (page.Image != null) { menuitem.Image = page.Image; } popupMenu.Items.Add(menuitem); } var menuPos = _tabControl.PointToClient(MousePosition); MenuManagerHelper.ShowMenu(popupMenu, _tabControl.LookAndFeel, barManager, _tabControl, menuPos); }
private void ShowTabPageContextMenu(object sender, Point position) { object menu = cmsRightButtonClick; if (menu == null) { return; } XtraTabControl tabCtrl = sender as XtraTabControl; Point pt = MousePosition; XtraTabHitInfo info = tabCtrl.CalcHitInfo(tabCtrl.PointToClient(pt)); ContextMenuStrip contextMenuStrip = menu as ContextMenuStrip; if (contextMenuStrip != null && info.HitTest == XtraTabHitTest.PageHeader) { tabCtrl.SelectedTabPage = info.Page; contextMenuStrip.Show(sender as Control, position); return; } }