/// <summary> /// Creates a new tab /// </summary> internal void CreateNewTab() { f0t0page newtab = new f0t0page(); newtab.Name = string.Format("{0}{1}", newtab.Name, this.TabCount); newtab.SetFotoBox(fotoBox); this.TabPages.Add(newtab); this.SelectTab(newtab.Name); newtab.Focus(); }
/// <summary> /// Event: Occurs when the mouse is dragged over the tabcontrol. /// </summary> /// <param name="sender"></param> /// <param name="drgevent"></param> protected override void OnDragOver(DragEventArgs drgevent) { base.OnDragOver(drgevent); Point p = new Point(drgevent.X, drgevent.Y); p = this.PointToClient(p); f0t0page hovered_page = this.GetTabPageByLocation(p) as f0t0page; if (hovered_page != null) { this.SelectedTab = hovered_page; if (drgevent.Data.GetDataPresent(typeof(f0t0page))) { drgevent.Effect = DragDropEffects.Move; f0t0page movingTab = drgevent.Data.GetData(typeof(f0t0page)) as f0t0page; int currentIndex = FindTabIndex(hovered_page); int movingTabIndex = FindTabIndex(movingTab); if (currentIndex.CompareTo(movingTabIndex) != 0) { this.SuspendLayout(); if (currentIndex >= 0 || movingTabIndex >= 0) { this.TabPages[currentIndex] = movingTab; this.TabPages[movingTabIndex] = hovered_page; bool canclose = movingTab.CanClose; movingTab.CanClose = hovered_page.CanClose; hovered_page.CanClose = canclose; } this.ResumeLayout(true); this.SelectedTab = movingTab; } } else { drgevent.Effect = DragDropEffects.Link; hovered_page.Focus(); } } }