/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ private void LoadFilters() { PaFiltersList filterList = PaFiltersList.Load(); ListViewItem currItem = null; foreach (PaFilter filter in filterList) { ListViewItem item = new ListViewItem(filter.Name); item.ImageIndex = (filter.ShowInToolbarList ? 0 : 1); item.Tag = filter; lvFilters.Items.Add(item); if (FilterHelper.CurrentFilter != null && filter.Name == FilterHelper.CurrentFilter.Name) { currItem = item; } } lvFilters.ItemSelectionChanged += lvFilters_ItemSelectionChanged; if (currItem != null) { lvFilters.FocusedItem = currItem; currItem.Selected = true; } else if (lvFilters.Items.Count > 0) { lvFilters.FocusedItem = lvFilters.Items[0]; lvFilters.Items[0].Selected = true; } btnCopy.Enabled = btnRemove.Enabled = (lvFilters.Items.Count > 0); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Updates each of the filter drop-downs created for the PA main window and all the /// undocked windows. When restorePrevFilter is true, if there is currently a filter /// applied, it will be reapplied after the lists are updated. /// </summary> /// ------------------------------------------------------------------------------------ public static void UpdateDisplayedFilterLists(PaFiltersList filterList, bool restorePrevFilter) { PaFilter prevFilter = s_currFilter; s_filters = (filterList != null ? filterList : PaFiltersList.Load()); foreach (FilterGUIComponent fgc in s_guiComponents.Values) { fgc.RefreshFilterList(); } if (prevFilter != null) { // Because the filter list has been recreated, the previous filter was // orphaned by the recreation of the filter list, we need to find the // new instance of the filter with the same name. If that filter no // longer exists, then we must turn off filtering (i.e. Restore). ApplyFilter(s_filters[prevFilter.Name]); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ protected void AfterDataSourcesLoaded(object args) { PaProject project = args as PaProject; if (project != null) { FilterHelper.UpdateDisplayedFilterLists(PaFiltersList.Load(project), false); // The first time we read the data sources, check if there was a filter // applied when the user closed down PA the last time. If so, then apply // it now. (m_startupFilterName will only be non null the first time the // data sources are read after startup. if (!string.IsNullOrEmpty(m_startupFilterName)) { PaFilter filter = FilterHelper.FilterList[m_startupFilterName]; if (filter != null) { FilterHelper.ApplyFilter(filter); } m_startupFilterName = null; } } }