示例#1
0
        //================================================================================
        private void updateCheckList()
        {
            aParticleFilePaths = CajApp.getParticleFilePaths();
            if (aParticleFilePaths == null)
            {
                return;
            }

            string filter   = txtCheckListFilter.Text;
            Thread thFilter = null;

            if (filter != "" && filter != "filter")
            {
                filter = filter.ToLower(CultureInfo.InvariantCulture);
                //check if format rule set:
                bool isSeparatorMore   = false;
                bool isSeparatorEquals = false;
                bool isSeparatorLess   = false;
                var  separator         = filter.IndexOf("e>", StringComparison.InvariantCulture);
                if (separator != -1)
                {
                    isSeparatorMore = true;
                }
                else
                {
                    separator = filter.IndexOf("e=", StringComparison.InvariantCulture);
                    if (separator != -1)
                    {
                        isSeparatorEquals = true;
                    }
                    else
                    {
                        separator = filter.IndexOf("e<", StringComparison.InvariantCulture);
                        if (separator != -1)
                        {
                            isSeparatorLess = true;
                        }
                    }
                }
                //check filter:
                if (separator == -1)
                {
                    //filter by path text: fast, nn thread:
                    var aFiltered = new List <string>();
                    foreach (var r in aParticleFilePaths)
                    {
                        if (r.Contains(filter))
                        {
                            aFiltered.Add(r);
                        }
                    }
                    aParticleFilePaths = aFiltered;
                }
                else
                {
                    //filter by emitters+:
                    enableActions(false);
                    thFilter = new Thread(() => {
                        int filterEmitters = -1;
                        int.TryParse(filter.Substring(separator + 2), out filterEmitters);
                        if (filterEmitters >= 0)
                        {
                            var aFiltered = new List <string>();
                            foreach (var r in aParticleFilePaths)
                            {
                                var node = CajApp.getNode(r);
                                if (node != null)
                                {
                                    int iEmitters = CajApp.recordsChanger.getEmittersNumber(node);
                                    if ((isSeparatorMore && iEmitters > filterEmitters) ||
                                        (isSeparatorEquals && iEmitters == filterEmitters) ||
                                        (isSeparatorLess && iEmitters < filterEmitters)
                                        )
                                    {
                                        aFiltered.Add(r);
                                    }
                                }
                            }
                            aParticleFilePaths = aFiltered;
                        }
                        Invoke(new Action(() => {
                            onFilterQueryEnd();
                        }));
                        enableActions(true);
                    });
                }
            }

            if (thFilter != null)
            {
                thFilter.Start();
                if (isFirstFilterRuleSearch)
                {
                    isFirstFilterRuleSearch = false;
                    MessageBox.Show("This is the first filter rule search." +
                                    Environment.NewLine + "It can take up to 10 seconds, please wait." +
                                    Environment.NewLine + Environment.NewLine +
                                    "Next queries should be instant until you close the app.",
                                    "poeNullEffects :: format query");
                }
            }
            else
            {
                onFilterQueryEnd();
            }
        }