/// ------------------------------------------------------------------------------------
 /// <summary>
 /// Updates the text on the specified tab.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public void UpdateTabsText(SearchResultTab tab, string text)
 {
     if (tab != null && tab.SearchQuery != null)
     {
         tab.Text = text;
         tab.AdjustWidth();
         AdjustTabContainerWidth();
     }
 }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes the specified tab with the specified text and result view.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void InitializeTab(SearchResultTab tab, SearchResultView resultView,
                                  bool removePreviousResults)
        {
            if (tab == null)
            {
                return;
            }

            bool viewWasInCIEView        = tab.CIEOptionsButton.Visible;
            bool viewWasInCIESimilarView = tab.CIESimilarOptionsButton.Visible;

            // Make sure that if tab already has a result view, it gets removed.
            if (removePreviousResults)
            {
                tab.RemoveResultView();
            }

            // If there is no tab text, then get it from the result view's search query.
            if (tab.GetDoesHaveEmptyText() && resultView != null && resultView.SearchQuery != null)
            {
                tab.Text = resultView.SearchQuery.ToString();
            }

            tab.AdjustWidth();
            tab.OwningTabGroup = this;

            if (resultView != null)
            {
                tab.ResultView            = resultView;
                tab.ResultView.Size       = new Size(Width, Height - TabsContainer.Height);
                tab.ResultView.Click     += HandleClick;
                tab.ResultView.MouseDown += HandleMouseDown;
                Controls.Add(resultView);
                AdjustTabContainerWidth();
                resultView.BringToFront();

                if (viewWasInCIEView)
                {
                    tab.CIEViewRefresh();
                }
                if (viewWasInCIESimilarView)
                {
                    tab.CIEViewSimilarRefresh();
                }
            }
        }