private void verticalTabs_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0 || e.Index >= verticalTabs.Items.Count)
            {
                return;
            }

            PvsCacheConfigurationPage page = verticalTabs.Items[e.Index] as PvsCacheConfigurationPage;

            if (page == null)
            {
                return;
            }

            Graphics  g = e.Graphics;
            Rectangle b = e.Bounds;

            // draw Delete icon
            Image deleteIcon = Properties.Resources._000_Abort_h32bit_16;

            if (deleteIcon != null)
            {
                page.DeleteIconBounds = new Rectangle(b.Right - deleteIcon.Width - ((32 - deleteIcon.Width) / 2),
                                                      b.Y + ((32 - deleteIcon.Height) / 2), deleteIcon.Width, deleteIcon.Height);
                g.DrawImage(deleteIcon, page.DeleteIconBounds);
            }
        }
        protected override string GetTabTitle(VerticalTabs.IVerticalTab verticalTab)
        {
            PvsCacheConfigurationPage page = verticalTab as PvsCacheConfigurationPage;

            if (page != null)
            {
                return(page.Text);
            }
            return(base.GetTabTitle(verticalTab));
        }
        private PvsCacheConfigurationPage NewPage(PVS_site pvsSite)
        {
            var existingTabNames = (from PvsCacheConfigurationPage page in verticalTabs.Items select page.Text).ToList();
            PvsCacheConfigurationPage editPage = new PvsCacheConfigurationPage(connection, existingTabNames);
            var pvsSiteCopy = pvsSite != null?pvsSite.Clone() : null;

            editPage.SetXenObjects(pvsSite, pvsSiteCopy);
            editPage.Changed             += SomethingChangedOnPage;
            editPage.DeleteButtonClicked += DeleteButtonClickedOnPage;
            ShowTab(editPage);
            RefreshButtons();
            return(editPage);
        }
        private void verticalTabs_MouseClick(object sender, MouseEventArgs e)
        {
            int pageIndex = verticalTabs.IndexFromPoint(e.Location);

            if (pageIndex < 0 || !MouseIsOnDeleteIcon(e.Location))
            {
                return;
            }

            PvsCacheConfigurationPage page = verticalTabs.Items[pageIndex] as PvsCacheConfigurationPage;

            if (page != null)
            {
                DeletePage(page);
                HideTooltip();
            }
        }
        void DeletePage(PvsCacheConfigurationPage page)
        {
            // try to delete the site (asks user for confirmation), also passing the site name, in case it has changed
            if (!DeleteSite(page.PvsSite, page.Text))
            {
                return;
            }
            int selectedIndex = verticalTabs.SelectedIndex;

            verticalTabs.Items.Remove(page);
            verticalTabs.SelectedIndex = selectedIndex < verticalTabs.Items.Count - 1 ? selectedIndex : verticalTabs.Items.Count - 1;
            page.Changed             -= SomethingChangedOnPage;
            page.DeleteButtonClicked -= DeleteButtonClickedOnPage;
            ContentPanel.Controls.Remove(page);
            RefreshButtons();
            ResizeVerticalTabs(verticalTabs.Items.Count);
        }
        private bool MouseIsOnDeleteIcon(Point mouseLocation)
        {
            int pageIndex = verticalTabs.IndexFromPoint(mouseLocation);

            if (pageIndex < 0)
            {
                return(false);
            }

            PvsCacheConfigurationPage page = verticalTabs.Items[pageIndex] as PvsCacheConfigurationPage;

            if (page == null)
            {
                return(false);
            }

            var bounds = page.DeleteIconBounds;

            return(bounds.Contains(mouseLocation));
        }
 private PvsCacheConfigurationPage NewPage(PVS_site pvsSite)
 {
     var existingTabNames = (from PvsCacheConfigurationPage page in verticalTabs.Items select page.Text).ToList();
     PvsCacheConfigurationPage editPage = new PvsCacheConfigurationPage(connection, existingTabNames);
     var pvsSiteCopy = pvsSite != null ? pvsSite.Clone() : null;
     editPage.SetXenObjects(pvsSite, pvsSiteCopy);
     editPage.Changed += SomethingChangedOnPage;
     editPage.DeleteButtonClicked += DeleteButtonClickedOnPage;
     ShowTab(editPage);
     RefreshButtons();
     return editPage;
 }
 void DeletePage(PvsCacheConfigurationPage page)
 {
     // try to delete the site (asks user for confirmation), also passing the site name, in case it has changed
     if (!DeleteSite(page.PvsSite, page.Text))
         return;
     int selectedIndex = verticalTabs.SelectedIndex;
     verticalTabs.Items.Remove(page);
     verticalTabs.SelectedIndex = selectedIndex < verticalTabs.Items.Count - 1 ? selectedIndex : verticalTabs.Items.Count - 1;
     page.Changed -= SomethingChangedOnPage;
     page.DeleteButtonClicked -= DeleteButtonClickedOnPage;
     ContentPanel.Controls.Remove(page);
     RefreshButtons();
     ResizeVerticalTabs(verticalTabs.Items.Count);
 }