예제 #1
0
        private void Tabs_MouseMove(object sender, MouseEventArgs e)
        {
            if (MouseDowned == false || page == null)
            {
                return;
            }
            if (Math.Abs(coords.X - Cursor.Position.X) < 10 && Math.Abs(coords.Y - Cursor.Position.Y) < 10)
            {
                return;
            }
            Bitmap map = new Bitmap(page.Bounds.Width, page.Bounds.Height);

            page.Show();
            page.DrawToBitmap(map, page.Bounds);
            Rectangle r      = Tabs.GetTabRect(0);
            Bitmap    TabMap = new Bitmap(TabSize.Width + TabSize.X, TabSize.Height + TabSize.Y);

            Tabs.DrawToBitmap(TabMap, new Rectangle(0, 0, TabMap.Width, TabMap.Height));
            Graphics.FromImage(map).DrawImage(TabMap.Clone(TabSize, PixelFormat.DontCare), r.X, r.Y);
            MovingForm = new OpacityForm(map, Cursor.Position.X, Cursor.Position.Y, TabSize.Width - container.X, container.Y);
            int   j   = Tabs.TabPages.IndexOf(page);
            Point pos = Cursor.Position;

            if (Tabs.TabPages.Count > 1)
            {
                if (j - 1 >= 0)
                {
                    Tabs.SelectedIndex = j - 1;
                }
                else
                {
                    Tabs.SelectedIndex = 0;
                }
            }
            Tabs.TabPages.Remove(page);
            MovingForm.ShowDialog();
            pos.X -= Cursor.Position.X;
            for (int i = 0; i < this.Tabs.TabPages.Count; i++)
            {
                r = Tabs.GetTabRect(i);
                if (r.X < e.Location.X - pos.X && r.X + r.Width > e.Location.X - pos.X)
                {
                    Tabs.TabPages.Remove(page);
                    Tabs.TabPages.Insert(i, page);
                    Tabs.SelectedTab = page;
                    page             = null;
                    MouseDowned      = false;
                    return;
                }
            }
            if (!Tabs.TabPages.Contains(page))
            {
                if (Tabs.TabPages.Count == 0)
                {
                    Tabs.TabPages.Add(page);
                }
                else if (e.Location.X - pos.X < Tabs.GetTabRect(0).X)
                {
                    Tabs.TabPages.Insert(0, page);
                }
                else
                {
                    Tabs.TabPages.Add(page);
                }
            }
            Tabs.SelectedTab = page;
            page             = null;
            MouseDowned      = false;
        }