private void tbMouseClick(object sender, MouseEventArgs e)
        {
            if (tabControl.SelectedIndex == tabControl.TabPages.Count - 1)
            {
                MyTabPage current = (MyTabPage)tabControl.TabPages[tabControl.SelectedIndex];
                current.Text = "New Page     ";
                current.webbrowser.Navigate(settings.Home);

                MyTabPage newTabPage = new MyTabPage("+", this);
                tabControl.TabPages.Add(newTabPage);
            }

            Rectangle tabRec = tabControl.GetTabRect(tabControl.SelectedIndex);

            tabRec.Offset(tabRec.Width - 15, 2);
            tabRec.Width  = 10;
            tabRec.Height = 10;
            if (tabRec.Contains(e.X, e.Y))
            {
                tabControl.TabPages.RemoveAt(tabControl.SelectedIndex);
            }

            //Робить знімок вікна браузера

            Bitmap    bitmap     = new Bitmap(500, 500);
            Rectangle bitmapRect = new Rectangle(0, 0, 500, 500);

            (tabControl.SelectedTab.Controls[0] as WebBrowser).DrawToBitmap(bitmap, bitmapRect);
            Image origImage = bitmap;

            origImage.Tag = cb_address.Text;

            tabControl.SelectedTab.DoDragDrop(origImage, DragDropEffects.Copy);
        }
        private void NewPageToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MyTabPage newpage = (MyTabPage)tabControl.TabPages[tabControl.TabPages.Count - 1];

            newpage.Text = "New Page     ";
            MyTabPage newTabPage = new MyTabPage("+", this);

            tabControl.TabPages.Add(newTabPage);
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            // Завантаження параметрів
            settings = BrowserSettings.Load(strAppData);

            //Підказки
            SetToolTip();

            btn_GoBack.Enabled    = false;
            btn_GoForward.Enabled = false;

            this.p_pages.Controls.Add(tabControl);
            tabControl.Dock = DockStyle.Fill;

            MyTabPage tabPage = new MyTabPage("New Page     ", this);

            tabControl.Controls.Add(tabPage);
            tabPage.webbrowser.Navigate(settings.Home);

            tabPage = new MyTabPage("+", this);
            tabControl.Controls.Add(tabPage);

            //tabControl.MouseDown += TabControlMouseDown;
            tabControl.MouseClick += tbMouseClick;

            tabControl.DrawMode  = TabDrawMode.OwnerDrawFixed;
            tabControl.DrawItem += TabControl_DrawItem;
            //tabControl.MouseEnter += TabControl_mouseEnter;
            tabControl.SelectedIndexChanged += OoSelectedIndexChanged;

            // Визначення розмірів і стану вікна
            Bounds      = settings.WindowBounds;
            WindowState = settings.WindowState;
            flp_bookmarkStar.Visible = settings.ViewBookMarksStar;
            tsmi_bookmark2.Checked   = flp_bookmarkStar.Visible;
            ts_star.Visible          = settings.ViewBookMarks;
            tsmi_bookmark1.Checked   = ts_star.Visible;

            //підключаємо введені адреса
            BindingSource bindingSource = new BindingSource();

            bindingSource.DataSource = settings.ManualUrls;
            cb_address.DataSource    = bindingSource;
            //foreach (var item in settings.ManualUrls)
            //{
            //    cb_address.Items.Add(item);
            //}

            //завантажуємо панель закладок
            foreach (var item in settings.Favorites)
            {
                ToolStripButton tsb = new ToolStripButton();
                tsb.Text        = item.Title;
                tsb.Tag         = item.Url;
                tsb.ToolTipText = item.Url;
                tsb.Click      += FavoriteButtonClick;
                ts_star.Items.Add(tsb);
            }

            //завантажуємо панель вибраних закладок
            foreach (var item in settings.FavoSupers)
            {
                Button button = new Button();
                button.Size = new Size(100, 100);
                Image img = item.image;
                button.BackgroundImage       = img;
                button.BackgroundImageLayout = ImageLayout.Stretch;
                button.Tag = item.Url;
                ToolTip tt = new ToolTip();
                tt.SetToolTip(button, item.Url);
                button.TextAlign        = ContentAlignment.TopCenter;
                button.Text             = item.Title;
                button.Click           += ButtonClick;
                button.ContextMenuStrip = cms_forButton;

                flp_bookmarkStar.Controls.Add(button);
            }
        }