/// ------------------------------------------------------------------------------------ public void SelectTab(SearchResultTab newSelectedTab, bool makeTabCurrent) { if (newSelectedTab == null) { return; } if (makeTabCurrent) { m_rsltVwMngr.SearchResultTabGroupChanged(this); // This is used to inform other tab groups in the same view tabs manager. App.MsgMediator.SendMessage("SearchResultTabGroupChanged", this); } newSelectedTab.Selected = true; CurrentTab = newSelectedTab; foreach (SearchResultTab tab in Tabs) { if (tab != newSelectedTab) { tab.Selected = false; } } if (makeTabCurrent) { EnsureTabVisible(CurrentTab); // Make sure the tab's grid has focus. if (CurrentTab.ResultView != null && CurrentTab.ResultView.Grid != null) { CurrentTab.ResultView.Grid.Focus(); } m_rsltVwMngr.CurrentSearchResultTabChanged(CurrentTab); // Sometimes selecting an empty tab causes a chain reaction caused by hiding // the former selected tab's grid. Doing that forces the .Net framework to // look for the next visible control in line that can be focused. Sometimes // that means a grid on another tab will get focus and ultimately cause that // grid's tab to become selected, thus negating the fact that we just got // through setting this tab group as current. Therefore, force the issue // again. if (!IsCurrent) { m_rsltVwMngr.SearchResultTabGroupChanged(this); App.MsgMediator.SendMessage("SearchResultTabGroupChanged", this); m_rsltVwMngr.CurrentSearchResultTabChanged(CurrentTab); } if (CurrentTab.ResultView != null && CurrentTab.ResultView.Grid != null) { CurrentTab.ResultView.Grid.IsCurrentPlaybackGrid = true; } } }
/// ------------------------------------------------------------------------------------ /// <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> /// Shows the popup with the specified information and near the mouse pointer. /// </summary> /// ------------------------------------------------------------------------------------ public void Show(SearchResultTab tab) { if (tab == null || tab.ResultView == null) { return; } if (tab.ResultView.SearchQuery.Errors.Count > 0) { lblRecordCount.Visible = false; lblRecordsValue.Text = LocalizationManager.GetString( "Views.WordLists.SearchResults.TabPopup.PatternContainsErrorsMsg", "Search pattern contains errors"); } else { lblRecordCount.Visible = true; lblPatternValue.Text = tab.ResultView.SearchQuery.Pattern; lblRecordsValue.Text = (tab.ResultView.Cache == null ? "0" : tab.ResultView.Cache.Count.ToString("#,###,##0")); } bool queryHasName = !string.IsNullOrEmpty(tab.ResultView.SearchQuery.Name); if (queryHasName && tab.TabTextClipped && tab.ResultView.SearchQuery.Errors.Count == 0) { lblName.Visible = lblNameValue.Visible = true; lblNameValue.Text = tab.ResultView.SearchQuery.Name; } else { lblName.Visible = false; lblNameValue.Visible = false; } if ((queryHasName || tab.TabTextClipped) && tab.ResultView.SearchQuery.Errors.Count == 0) { lblPattern.Visible = true; lblPatternValue.Visible = true; } else { lblPattern.Visible = false; lblPatternValue.Visible = false; } tlpInfo.PerformLayout(); m_popup.Size = Size; Point pt = MousePosition; pt.X += SystemInformation.CursorSize.Width / 2; pt.Y += SystemInformation.CursorSize.Height / 3; m_popup.Show(pt); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds an empty tab to the tab group. /// </summary> /// ------------------------------------------------------------------------------------ public void AddTab(SearchResultTab tab) { tab.Dock = DockStyle.Left; tab.Click += HandleTabClick; tab.MouseDown += HandleMouseDown; InitializeTab(tab, tab.ResultView, false); m_tabsPanel.Controls.Add(tab); tab.BringToFront(); Tabs.Add(tab); AdjustTabContainerWidth(); UseWaitCursor = false; Cursor = Cursors.Default; }
/// ------------------------------------------------------------------------------------ public SearchResultTab AddTab(SearchResultView resultView) { if (m_tabsPanel.Left > 0) { m_tabsPanel.Left = 0; } SearchResultTab tab = new SearchResultTab(this); tab.ResultView = resultView; AddTab(tab); return(tab); }
/// ------------------------------------------------------------------------------------ /// <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(); } } }
/// ------------------------------------------------------------------------------------ protected override void OnDragDrop(DragEventArgs e) { m_dropIndicator.Visible = false; base.OnDragDrop(e); SearchResultTab tab = e.Data.GetData(typeof(SearchResultTab)) as SearchResultTab; SearchQuery query = e.Data.GetData(typeof(SearchQuery)) as SearchQuery; // Is what was dropped appropriate to be dropped in a search pattern? if (tab != null && tab.OwningTabGroup != this) { // Remove the tab from it's owning group. tab.OwningTabGroup.RemoveTab(tab, false); AddTab(tab); HandleTabClick(tab, null); } else if (query != null && !query.PatternOnly) { SelectTab(CurrentTab, true); App.MsgMediator.SendMessage("PatternDroppedOnTabGroup", query); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Removes the specified tab from the group's collection of tabs. /// </summary> /// ------------------------------------------------------------------------------------ public void RemoveTab(SearchResultTab tab, bool disposeOfTab) { // If the tab being removed is selected and owned by a tab group, then make // sure we select an adjacent tab before removing the tab because a tab group // always has to have a selected tab. if (tab.Selected && tab.OwningTabGroup != null) { SearchResultTabGroup tabGroup = tab.OwningTabGroup; SearchResultTab newTabInSendingGroup = null; int i = tabGroup.m_tabsPanel.Controls.IndexOf(tab); if (i - 1 >= 0) { newTabInSendingGroup = tabGroup.m_tabsPanel.Controls[i - 1] as SearchResultTab; } else if (i + 1 < tabGroup.m_tabsPanel.Controls.Count) { newTabInSendingGroup = tabGroup.m_tabsPanel.Controls[i + 1] as SearchResultTab; } if (newTabInSendingGroup != null) { tabGroup.SelectTab(newTabInSendingGroup, true); } } if (m_tabsPanel.Controls.Contains(tab)) { tab.Click -= HandleTabClick; tab.MouseDown -= HandleMouseDown; if (tab.ResultView != null) { tab.ResultView.Click -= HandleClick; tab.ResultView.MouseDown -= HandleMouseDown; } if (Controls.Contains(tab.ResultView)) { Controls.Remove(tab.ResultView); } m_tabsPanel.Controls.Remove(tab); Tabs.Remove(tab); if (disposeOfTab) { tab.Dispose(); } AdjustTabContainerWidth(); RefreshScrollButtonPanel(); // If removing the tab left a gap between the furthest right tab and the // button panel... and all or a portion of the furthest left tab are // scrolled out of view, then scroll right to close that gap. if (m_tabsPanel.Left < 0 && m_tabsPanel.Right < m_buttonPanel.Left) { int dx = (m_buttonPanel.Left - m_tabsPanel.Right); SlideTabs(m_tabsPanel.Left + dx); } } // If the last tab was removed from the group, then close the tab group by // removing ourselves from our parent's control collection. if (Tabs.Count == 0 && Parent != null) { Controls.Clear(); Parent.Controls.Remove(this); Dispose(); } }