/// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void lvFilters_AfterLabelEdit(object sender, LabelEditEventArgs e)
        {
            PaFilter filter = lvFilters.Items[e.Item].Tag as PaFilter;

            if (filter == null || e.Label == null || filter.Name == e.Label)
            {
                return;
            }

            if (FilterNameExists(e.Label))
            {
                string msg = string.Format(Properties.Resources.kstidFilterNameExistsMsg, e.Label);
                Utils.MsgBox(msg);
                e.CancelEdit = true;
                return;
            }

            m_dirty     = true;
            filter.Name = e.Label;
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected override bool SaveChanges()
        {
            PaFiltersList filterList = new PaFiltersList();

            foreach (ListViewItem item in lvFilters.Items)
            {
                PaFilter filter = item.Tag as PaFilter;
                if (filter != null)
                {
                    filterList.Add(filter);
                }
            }

            // TODO: Validate expressions with search queries.

            filterList.Save();
            FilterHelper.UpdateDisplayedFilterLists(filterList, true);
            m_dirty        = false;
            m_grid.IsDirty = false;
            return(true);
        }
Ejemplo n.º 3
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]);
            }
        }
Ejemplo n.º 4
0
        /// ------------------------------------------------------------------------------------
        /// <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;
                }
            }
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        void HandleFilterButtonItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            ToolStripMenuItem item = e.ClickedItem as ToolStripMenuItem;

            if (item == null)
            {
                return;
            }

            if (item.Tag != null && item.Tag.GetType() == typeof(PaFilter))
            {
                FilterHelper.ApplyFilter(item.Tag as PaFilter);
            }
            else if (item.Text == Properties.Resources.kstidNoFilterText)
            {
                FilterHelper.ApplyFilter(null);
            }
            else if (item.Text == Properties.Resources.kstidFiltersMenuText)
            {
                string filterName = null;
                foreach (ToolStripItem mnu in m_filterButton.DropDown.Items)
                {
                    PaFilter filter = mnu.Tag as PaFilter;
                    if (filter != null && ((ToolStripMenuItem)mnu).Checked)
                    {
                        filterName = filter.Name;
                        break;
                    }
                }

                using (DefineFiltersDlg dlg = new DefineFiltersDlg(filterName))
                    dlg.ShowDialog();

                return;
            }
        }