private void FileTabControl_DragOver(object sender, DragEventArgs e)
        {
            TabControl tc = (TabControl)sender;

            // a tab is draged?
            if (e.Data.GetData(typeof(EditorTab)) == null)
            {
                return;
            }
            EditorTab dragTab       = (EditorTab)e.Data.GetData(typeof(EditorTab));
            int       dragTab_index = tc.TabPages.IndexOf(dragTab);

            // hover over a tab?
            int hoverTab_index = this.getHoverTabIndex(tc);

            if (hoverTab_index < 0)
            {
                e.Effect = DragDropEffects.None; return;
            }
            TabPage hoverTab = tc.TabPages[hoverTab_index];

            e.Effect = DragDropEffects.Move;

            // start of drag?
            if (dragTab == hoverTab)
            {
                return;
            }

            // swap dragTab & hoverTab - avoids toggeling
            Rectangle dragTabRect  = tc.GetTabRect(dragTab_index);
            Rectangle hoverTabRect = tc.GetTabRect(hoverTab_index);

            if (dragTabRect.Width < hoverTabRect.Width)
            {
                Point tcLocation = tc.PointToScreen(tc.Location);

                if (dragTab_index < hoverTab_index)
                {
                    if ((e.X - tcLocation.X) > ((hoverTabRect.X + hoverTabRect.Width) - dragTabRect.Width))
                    {
                        this.swapTabPages(tc, dragTab, hoverTab);
                    }
                }
                else if (dragTab_index > hoverTab_index)
                {
                    if ((e.X - tcLocation.X) < (hoverTabRect.X + dragTabRect.Width))
                    {
                        this.swapTabPages(tc, dragTab, hoverTab);
                    }
                }
            }
            else
            {
                this.swapTabPages(tc, dragTab, hoverTab);
            }

            // select new pos of dragTab
            tc.SelectedIndex = tc.TabPages.IndexOf(dragTab);
        }
        private void FileTabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            EditorTab editorTab = (EditorTab)TabPages[SelectedIndex];

            if ((editorTab?.Editor?.TextBox ?? null) != null)
            {
                Font font = editorTab.Editor.TextBox.Font;
                editorTab.Editor.TextBox.Font = new Font(font.FontFamily, RegistryWorker.FontSize);
            }
        }
        private void Close_Click(object sender, EventArgs e)
        {
            if (TabPages.Count <= 1)
            {
                return;
            }
            EditorTab tab = (EditorTab)contextMenuStrip.Tag;

            if (tab.CanClose())
            {
                TabPages.Remove(tab);
            }
        }
        public EditorTab LoadBlank(string file, CodeEditor editor)
        {
            EditorTab newTab = new EditorTab(file, editor);

            TabPages.Add(newTab);
            foreach (TabPage page in TabPages)
            {
                if (page != newTab)
                {
                    TabPages.Remove(page);
                }
            }
            return(newTab);
        }
        private void FileTabControl_MouseMove(object sender, MouseEventArgs e)
        {
            // mouse button down? tab was clicked?
            TabControl tc = (TabControl)sender;

            if ((e.Button != MouseButtons.Left) || (tc.Tag == null))
            {
                return;
            }
            EditorTab clickedTab    = (EditorTab)tc.Tag;
            int       clicked_index = tc.TabPages.IndexOf(clickedTab);

            // start drag n drop
            tc.DoDragDrop(clickedTab, DragDropEffects.All);
        }
        public EditorTab Load(string file, CodeEditor editor)
        {
            foreach (EditorTab tab in TabPages)
            {
                if (tab.File == file)
                {
                    SelectedTab = tab;
                    tab.Reload();
                    Refresh();
                    return(tab);
                }
            }
            EditorTab newTab = new EditorTab(file, editor);

            TabPages.Add(newTab);
            SelectedTab = newTab;
            return(newTab);
        }
 private void ShowInProjectTree_Click(object sender, EventArgs e)
 {
     EditorTab tab  = (EditorTab)contextMenuStrip.Tag;
     var       file = tab.File;
 }