コード例 #1
0
        /// <summary>
        /// Filter the form
        /// - All sub filters are ' AND ' interwinded
        /// - Wildcard '*' or '%' is only at filter start allowed
        /// - Filters may contain a 'NOT ' at the start to invert the logic
        ///
        /// Examples:
        /// 'myFilter'
        /// '%myFilter'
        /// 'NOT myFilter'
        /// 'NOT %myFilter'

        /// https://documentation.devexpress.com/WindowsForms/2567/Controls-and-Libraries/Data-Grid/Filter-and-Search/Filtering-in-Code
        /// </summary>
        private void FilterGrid(bool startAtBeginning = false)
        {
            string firstWildCard = "";

            if (startAtBeginning)
            {
                firstWildCard = "%";
            }
            // Filters to later aggregate to string
            List <string> lFilters = new List <string>();


            // Handle Macro checked
            if (chkOnlyMacros.Checked)
            {
                lFilters.Add($"Implementation <> ''");
            }
            // Handle Implemented by C-Function
            if (chkOnlyCalledInterfaces.Checked)
            {
                lFilters.Add($"isCalled = true");
            }

            GuiHelper.AddSubFilter(lFilters, firstWildCard, "Interface", txtFilterFunctionName.Text);
            GuiHelper.AddSubFilter(lFilters, firstWildCard, "FilePathCallee", txtFilterPathCallee.Text);
            GuiHelper.AddSubFilter(lFilters, firstWildCard, "FilePath", txtFilterPathImpl.Text);


            string filter = GuiHelper.AggregateFilter(lFilters);

            try
            {
                _bsProvidedInterfaces.Filter = filter;
                _bsRequiredInterfaces.Filter = filter;
            }
            catch (Exception e)
            {
                MessageBox.Show($@"Filter: '{filter}'
The Filter may contain:
- '%' or '*' wildcard at string start
- 'NOT ' preceding the filter string

Examples:
'myFilter'
'%myFilter'
'NOT myFilter'
'NOT %myFilter'

hoRerse always adds a wildcard at string end! hoReverse combines filters by ' AND '

Not allowed are wildcard '*' or '%' amidst the filter string.


{e}",

                                @"The filter you have defined is invalid!");
                _bsProvidedInterfaces.Filter = "";
                _bsRequiredInterfaces.Filter = "";
            }
        }