/// <summary>
        /// Loads the list of artists.
        /// </summary>
        /// <param name="settings">The filters to apply to the data.</param>
        public async Task<List<SearchCategoryItem>> LoadCategoriesAsync(SearchSettings settings, SearchFilterEnum groupType) {
            List<SearchCategoryItem> Result = new List<SearchCategoryItem>();
            if (settings.ListIsInDatabase != false) {
                Result.Add(new SearchCategoryItem(SearchFilterEnum.All, null, "All"));
                if (groupType != SearchFilterEnum.Artist)
                    Result.Add(new SearchCategoryItem(SearchFilterEnum.Artist, null, "By Artist"));
                if (groupType != SearchFilterEnum.Category)
                    Result.Add(new SearchCategoryItem(SearchFilterEnum.Category, null, "By Category"));
                if (groupType != SearchFilterEnum.Element)
                    Result.Add(new SearchCategoryItem(SearchFilterEnum.Element, null, "By Element"));
            }
            if (settings.ListIsInDatabase != true)
                Result.Add(new SearchCategoryItem(SearchFilterEnum.Files, null, "Other Files"));
            Result.Add(new SearchCategoryItem(SearchFilterEnum.None, null, "---"));

            if (groupType == SearchFilterEnum.Artist) {
                if (string.IsNullOrEmpty(settings.Search)) {
                    Result.Add(new SearchCategoryItem(SearchFilterEnum.Artist, "", "No Artist"));
                    Result.Add(new SearchCategoryItem(SearchFilterEnum.ArtistSingles, null, "Singles"));
                }
                Result.AddRange(await Task.Run(() => SearchVideoAccess.GetCategoryArtists(settings)));
            } else if (groupType == SearchFilterEnum.Category) {
                if (string.IsNullOrEmpty(settings.Search))
                    Result.Add(new SearchCategoryItem(SearchFilterEnum.Category, "", "No Category"));
                Result.AddRange(await Task.Run(() => SearchVideoAccess.GetCategoryCategories(settings)));
            } else if (groupType == SearchFilterEnum.Element)
                Result.AddRange(await Task.Run(() => SearchVideoAccess.GetCategoryElements(settings)));

            return Result;
        }
Exemplo n.º 2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            SearchFilterEnum       filter = GetFilter();
            List <SearchResult>    res    = Search(expSearchTerm.Expression, filter);
            List <DataGridViewRow> rrs    = new List <DataGridViewRow>();

            statusStrip1.Visible  = false;
            lblResultInfo.Visible = false;
            dgvResults.Rows.Clear();
            foreach (SearchResult sr in res)
            {
                DataGridViewRow r = new DataGridViewRow();
                r.CreateCells(dgvResults, new object[] { sr.MatchItem, sr.MatchType });
                r.Tag = sr;
                rrs.Add(r);
            }
            dgvResults.Rows.AddRange(rrs.ToArray());
            switch (rrs.Count)
            {
            case 0:
                lblResultInfo.Text = I18n.Translate("internal/SearchForm/noresults", "No results");
                break;

            case 1:
                lblResultInfo.Text = I18n.Translate("internal/SearchForm/oneresult", "One result");
                break;

            default:
                lblResultInfo.Text = I18n.Translate("internal/SearchForm/xresults", "{0} results", rrs.Count);
                break;
            }
            lblResultInfo.Visible = true;
            statusStrip1.Visible  = true;
        }
Exemplo n.º 3
0
 /// <summary>
 /// 转换成枚举
 /// </summary>
 public static int SearchFilterToValue(SearchFilterEnum enumOption)
 {
     try{
         return((int)enumOption);
     }catch (Exception ex) {
         throw new ArgumentException("enumOption", ex);
     }
 }
Exemplo n.º 4
0
        public List <SearchResult> Search(string text, SearchFilterEnum filter)
        {
            List <SearchResult> results = new List <SearchResult>();
            Context             ctx     = new Context();

            ctx.plug = plug;
            try
            {
                pathPrefix = I18n.Translate("internal/Configuration/local", "Local triggers") + @"\";
                Regex rex = new Regex(text, RegexOptions.IgnoreCase);
                if ((filter & SearchFilterEnum.ScopeLocal) != 0)
                {
                    results.AddRange(SearchIn(plug.cfg.Root, ctx, rex, filter));
                }
                if ((filter & SearchFilterEnum.Scoperemote) != 0)
                {
                    foreach (Repository r in plug.cfg.RepositoryRoot.Repositories)
                    {
                        pathPrefix = I18n.Translate("internal/Configuration/remote", "Remote triggers") + @"\" + r.Name + @"\";
                        if ((filter & SearchFilterEnum.IncludeDisabled) == 0 && r.Enabled == false)
                        {
                            continue;
                        }
                        if ((filter & SearchFilterEnum.RepoName) != 0)
                        {
                            if (RegexMatches(rex, r.Name) == true)
                            {
                                results.Add(new SearchResult(r)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitreponame", "Repository name")
                                });
                            }
                        }
                        if ((filter & SearchFilterEnum.RepoAddress) != 0)
                        {
                            if (RegexMatches(rex, r.Address) == true)
                            {
                                results.Add(new SearchResult(r)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitrepoaddress", "Repository address")
                                });
                            }
                        }
                        results.AddRange(SearchIn(r.Root, ctx, rex, filter));
                    }
                }
            }
            catch (Exception)
            {
            }
            return(results);
        }
Exemplo n.º 5
0
        private SearchFilterEnum GetFilter()
        {
            SearchFilterEnum filter = 0;

            foreach (int i in clbTriggers.CheckedIndices)
            {
                if (i == 0)
                {
                    filter |= SearchFilterEnum.TriggerId;
                }
                if (i == 1)
                {
                    filter |= SearchFilterEnum.TriggerName;
                }
                if (i == 2)
                {
                    filter |= SearchFilterEnum.TriggerDescription;
                }
                if (i == 3)
                {
                    filter |= SearchFilterEnum.TriggerCondition;
                }
                if (i == 4)
                {
                    filter |= SearchFilterEnum.TriggerFullPath;
                }
                if (i == 5)
                {
                    filter |= SearchFilterEnum.TriggerRegex;
                }
            }
            foreach (int i in clbActions.CheckedIndices)
            {
                if (i == 0)
                {
                    filter |= SearchFilterEnum.ActionDescription;
                }
                if (i == 1)
                {
                    filter |= SearchFilterEnum.ActionCondition;
                }
                if (i == 2)
                {
                    filter |= SearchFilterEnum.ActionDetails;
                }
            }
            foreach (int i in clbRepos.CheckedIndices)
            {
                if (i == 0)
                {
                    filter |= SearchFilterEnum.RepoName;
                }
                if (i == 1)
                {
                    filter |= SearchFilterEnum.RepoAddress;
                }
            }
            foreach (int i in clbScope.CheckedIndices)
            {
                if (i == 0)
                {
                    filter |= SearchFilterEnum.ScopeLocal;
                }
                if (i == 1)
                {
                    filter |= SearchFilterEnum.Scoperemote;
                }
            }
            foreach (int i in clbMisc.CheckedIndices)
            {
                if (i == 0)
                {
                    filter |= SearchFilterEnum.FolderName;
                }
                if (i == 1)
                {
                    filter |= SearchFilterEnum.IncludeDisabled;
                }
            }
            return(filter);
        }
Exemplo n.º 6
0
        internal List <SearchResult> SearchIn(Folder f, Context ctx, Regex rex, SearchFilterEnum filter)
        {
            List <SearchResult> results = new List <SearchResult>();

            if ((filter & SearchFilterEnum.IncludeDisabled) == 0 && f.Enabled == false)
            {
                return(results);
            }
            if ((filter & SearchFilterEnum.FolderName) != 0)
            {
                if (RegexMatches(rex, f.Name.ToString()) == true)
                {
                    results.Add(new SearchResult(f)
                    {
                        MatchType = I18n.Translate("internal/SearchForm/hitfoldername", "Folder name"), Match = plug.LocateNodeHostingFolder(f.Repo == null ? plug.ui.treeView1.Nodes[0] : plug.ui.treeView1.Nodes[1], f)
                    });
                }
            }
            foreach (Trigger t in f.Triggers)
            {
                if ((filter & SearchFilterEnum.IncludeDisabled) == 0 && t.Enabled == false)
                {
                    continue;
                }
                TreeNode tn = plug.LocateNodeHostingTrigger(t.Repo == null ? plug.ui.treeView1.Nodes[0] : plug.ui.treeView1.Nodes[1], t);
                if ((filter & SearchFilterEnum.TriggerId) != 0)
                {
                    if (RegexMatches(rex, t.Id.ToString()) == true)
                    {
                        results.Add(new SearchResult(t)
                        {
                            MatchType = I18n.Translate("internal/SearchForm/hittriggerid", "Trigger ID"), Match = tn
                        });
                    }
                }
                if ((filter & SearchFilterEnum.TriggerName) != 0)
                {
                    if (RegexMatches(rex, t.Name) == true)
                    {
                        results.Add(new SearchResult(t)
                        {
                            MatchType = I18n.Translate("internal/SearchForm/hittriggername", "Trigger name"), Match = tn
                        });
                    }
                    else if ((filter & SearchFilterEnum.TriggerFullPath) != 0)
                    {
                        if (RegexMatches(rex, t.FullPath) == true)
                        {
                            results.Add(new SearchResult(t)
                            {
                                MatchType = I18n.Translate("internal/SearchForm/hitfullpath", "Trigger full path"), Match = tn
                            });
                        }
                    }
                }
                else if ((filter & SearchFilterEnum.TriggerFullPath) != 0)
                {
                    if (RegexMatches(rex, t.FullPath) == true)
                    {
                        results.Add(new SearchResult(t)
                        {
                            MatchType = I18n.Translate("internal/SearchForm/hitfullpath", "Trigger full path"), Match = tn
                        });
                    }
                }
                if ((filter & SearchFilterEnum.TriggerDescription) != 0)
                {
                    if (RegexMatches(rex, t._Description) == true)
                    {
                        results.Add(new SearchResult(t)
                        {
                            MatchType = I18n.Translate("internal/SearchForm/hittriggerdesc", "Trigger description"), Match = tn
                        });
                    }
                }
                if ((filter & SearchFilterEnum.TriggerCondition) != 0)
                {
                    if (ConditionMatches(rex, t.Condition) == true)
                    {
                        results.Add(new SearchResult(t)
                        {
                            MatchType = I18n.Translate("internal/SearchForm/hittriggercond", "Trigger condition"), Match = tn
                        });
                    }
                }
                if ((filter & SearchFilterEnum.TriggerRegex) != 0)
                {
                    if (RegexMatches(rex, t.RegularExpression) == true)
                    {
                        results.Add(new SearchResult(t)
                        {
                            MatchType = I18n.Translate("internal/SearchForm/hittriggerregex", "Trigger regular expression"), Match = tn
                        });
                    }
                }
                int i = 1;
                foreach (Action a in t.Actions)
                {
                    if ((filter & SearchFilterEnum.ActionDescription) != 0)
                    {
                        if (RegexMatches(rex, a.GetDescription(ctx)) == true)
                        {
                            results.Add(new SearchResult(t)
                            {
                                MatchType = I18n.Translate("internal/SearchForm/hitactiondesc", "Action #{0} description", i), Match = tn
                            });
                        }
                    }
                    if ((filter & SearchFilterEnum.ActionCondition) != 0)
                    {
                        if (ConditionMatches(rex, a.Condition) == true)
                        {
                            results.Add(new SearchResult(t)
                            {
                                MatchType = I18n.Translate("internal/SearchForm/hitactioncond", "Action #{0} condition", i), Match = tn
                            });
                        }
                    }
                    if ((filter & SearchFilterEnum.ActionDetails) != 0)
                    {
                        if (RegexMatches(rex, a._ExecutionDelayExpression) == true)
                        {
                            results.Add(new SearchResult(t)
                            {
                                MatchType = I18n.Translate("internal/SearchForm/hitexecdelay", "Action #{0} execution delay", i), Match = tn
                            });
                        }
                        if (a.ActionType == Action.ActionTypeEnum.Aura)
                        {
                            if (RegexMatches(rex, a._AuraImage) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitimgaurasrc", "Action #{0} image aura source", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._AuraName) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitimgauraname", "Action #{0} image aura name", i), Match = tn
                                });
                            }
                        }
                        if (a.ActionType == Action.ActionTypeEnum.DiscordWebhook)
                        {
                            if (RegexMatches(rex, a._DiscordWebhookURL) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitdiscordurl", "Action #{0} Discord webhook URL", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._DiscordWebhookMessage) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitdiscordmsg", "Action #{0} Discord webhook message", i), Match = tn
                                });
                            }
                        }
                        if (a.ActionType == Action.ActionTypeEnum.ExecuteScript)
                        {
                            if (RegexMatches(rex, a._ExecScriptAssembliesExpression) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitscriptassy", "Action #{0} script assemblies", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._ExecScriptExpression) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitscriptassy", "Action #{0} script", i), Match = tn
                                });
                            }
                        }
                        if (a.ActionType == Action.ActionTypeEnum.Folder)
                        {
                            if (RegexMatches(rex, a._FolderId.ToString()) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitactionfolderid", "Action #{0} folder ID", i), Match = tn
                                });
                            }
                        }
                        if (a.ActionType == Action.ActionTypeEnum.GenericJson)
                        {
                            if (RegexMatches(rex, a._JsonEndpointExpression) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitjsonendpoint", "Action #{0} JSON endpoint", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._JsonFiringExpression) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitjsonfiring", "Action #{0} JSON firing expression", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._JsonPayloadExpression) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitjsonpayload", "Action #{0} JSON payload expression", i), Match = tn
                                });
                            }
                        }
                        if (a.ActionType == Action.ActionTypeEnum.KeyPress)
                        {
                            if (RegexMatches(rex, a._KeyPressCode) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitkeypresscode", "Action #{0} keypress code", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._KeyPressExpression) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitkeypressexpression", "Action #{0} keypress expression", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._KeyPressWindow) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitkeypresswindow", "Action #{0} keypress window", i), Match = tn
                                });
                            }
                        }
                        if (a.ActionType == Action.ActionTypeEnum.LaunchProcess)
                        {
                            if (RegexMatches(rex, a._LaunchProcessCmdlineExpression) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitproccmdline", "Action #{0} command line expression", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._LaunchProcessPathExpression) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitpathexpr", "Action #{0} command line path", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._LaunchProcessWorkingDirExpression) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitworkingdir", "Action #{0} working directory", i), Match = tn
                                });
                            }
                        }
                        if (a.ActionType == Action.ActionTypeEnum.ListVariable)
                        {
                            if (RegexMatches(rex, a._ListVariableExpression) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitlistexpr", "Action #{0} list variable expression", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._ListVariableIndex) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitlistindex", "Action #{0} list variable index", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._ListVariableName) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitlistname", "Action #{0} list variable name", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._ListVariableTarget) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitlisttarget", "Action #{0} list variable target", i), Match = tn
                                });
                            }
                        }
                        if (a.ActionType == Action.ActionTypeEnum.LogMessage)
                        {
                            if (RegexMatches(rex, a._LogMessageText) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitlogtext", "Action #{0} log text", i), Match = tn
                                });
                            }
                        }
                        if (a.ActionType == Action.ActionTypeEnum.MessageBox)
                        {
                            if (RegexMatches(rex, a._MessageBoxText) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitmsgboxtext", "Action #{0} message box text", i), Match = tn
                                });
                            }
                        }
                        if (a.ActionType == Action.ActionTypeEnum.ObsControl)
                        {
                            if (RegexMatches(rex, a._OBSSceneName) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitobsscene", "Action #{0} OBS scene name", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._OBSSourceName) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitobssource", "Action #{0} OBS source name", i), Match = tn
                                });
                            }
                        }
                        if (a.ActionType == Action.ActionTypeEnum.PlaySound)
                        {
                            if (RegexMatches(rex, a._PlaySoundFileExpression) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitsfxfile", "Action #{0} sound file", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._PlaySoundVolumeExpression) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitsfxvol", "Action #{0} sound volume", i), Match = tn
                                });
                            }
                        }
                        if (a.ActionType == Action.ActionTypeEnum.SystemBeep)
                        {
                            if (RegexMatches(rex, a._SystemBeepFreqExpression) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitbeepfreq", "Action #{0} beep frequency", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._SystemBeepLengthExpression) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitbeeplen", "Action #{0} beep length", i), Match = tn
                                });
                            }
                        }
                        if (a.ActionType == Action.ActionTypeEnum.TextAura)
                        {
                            if (RegexMatches(rex, a._TextAuraExpression) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hittextauraexpr", "Action #{0} text aura expression", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._TextAuraFontName) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hittextaurafont", "Action #{0} text aura font", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._TextAuraName) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hittextauraname", "Action #{0} text aura name", i), Match = tn
                                });
                            }
                        }
                        if (a.ActionType == Action.ActionTypeEnum.Trigger)
                        {
                            if (RegexMatches(rex, a._TriggerId.ToString()) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hittriggerid", "Action #{0} trigger ID", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._TriggerText) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitactiontriggertext", "Action #{0} trigger firing text", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._TriggerZone) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hittriggerzone", "Action #{0} trigger firing zone", i), Match = tn
                                });
                            }
                        }
                        if (a.ActionType == Action.ActionTypeEnum.UseTTS)
                        {
                            if (RegexMatches(rex, a._UseTTSRateExpression) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitttsexpr", "Action #{0} TTS rate", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._UseTTSTextExpression) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitttstext", "Action #{0} TTS text", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._UseTTSVolumeExpression) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitttsvol", "Action #{0} TTS volume", i), Match = tn
                                });
                            }
                        }
                        if (a.ActionType == Action.ActionTypeEnum.Variable)
                        {
                            if (RegexMatches(rex, a._VariableExpression) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitvarexpr", "Action #{0} variable expression", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._VariableName) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitvarname", "Action #{0} variable name", i), Match = tn
                                });
                            }
                        }
                        if (a.ActionType == Action.ActionTypeEnum.WindowMessage)
                        {
                            if (RegexMatches(rex, a._WmsgTitle) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitwmsgtitle", "Action #{0} window message title", i), Match = tn
                                });
                            }
                        }
                        if (a.ActionType == Action.ActionTypeEnum.DiskFile)
                        {
                            if (RegexMatches(rex, a._DiskFileOpName) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitdiskfilename", "Action #{0} disk operation file name", i), Match = tn
                                });
                            }
                            if (RegexMatches(rex, a._DiskFileOpVar) == true)
                            {
                                results.Add(new SearchResult(t)
                                {
                                    MatchType = I18n.Translate("internal/SearchForm/hitdiskfilevar", "Action #{0} disk operation variable name", i), Match = tn
                                });
                            }
                        }
                    }
                    i++;
                }
            }
            foreach (Folder sf in f.Folders)
            {
                results.AddRange(SearchIn(sf, ctx, rex, filter));
            }
            return(results);
        }
 public SearchCategoryItem(SearchFilterEnum filterType, string filterValue, string text)
 {
     this.FilterType  = filterType;
     this.FilterValue = filterValue;
     this.Text        = text;
 }
Exemplo n.º 8
0
        /// <summary>
        /// Loads the list of artists.
        /// </summary>
        /// <param name="settings">The filters to apply to the data.</param>
        public async Task <List <SearchCategoryItem> > LoadCategoriesAsync(SearchSettings settings, SearchFilterEnum groupType)
        {
            List <SearchCategoryItem> Result = new List <SearchCategoryItem>();

            if (settings.ListIsInDatabase != false)
            {
                Result.Add(new SearchCategoryItem(SearchFilterEnum.All, null, "All"));
                if (groupType != SearchFilterEnum.Artist)
                {
                    Result.Add(new SearchCategoryItem(SearchFilterEnum.Artist, null, "By Artist"));
                }
                if (groupType != SearchFilterEnum.Category)
                {
                    Result.Add(new SearchCategoryItem(SearchFilterEnum.Category, null, "By Category"));
                }
                if (groupType != SearchFilterEnum.Element)
                {
                    Result.Add(new SearchCategoryItem(SearchFilterEnum.Element, null, "By Element"));
                }
            }
            if (settings.ListIsInDatabase != true)
            {
                Result.Add(new SearchCategoryItem(SearchFilterEnum.Files, null, "Other Files"));
            }
            Result.Add(new SearchCategoryItem(SearchFilterEnum.None, null, "---"));

            if (groupType == SearchFilterEnum.Artist)
            {
                if (string.IsNullOrEmpty(settings.Search))
                {
                    Result.Add(new SearchCategoryItem(SearchFilterEnum.Artist, "", "No Artist"));
                    Result.Add(new SearchCategoryItem(SearchFilterEnum.ArtistSingles, null, "Singles"));
                }
                Result.AddRange(await Task.Run(() => SearchVideoAccess.GetCategoryArtists(settings)));
            }
            else if (groupType == SearchFilterEnum.Category)
            {
                if (string.IsNullOrEmpty(settings.Search))
                {
                    Result.Add(new SearchCategoryItem(SearchFilterEnum.Category, "", "No Category"));
                }
                Result.AddRange(await Task.Run(() => SearchVideoAccess.GetCategoryCategories(settings)));
            }
            else if (groupType == SearchFilterEnum.Element)
            {
                Result.AddRange(await Task.Run(() => SearchVideoAccess.GetCategoryElements(settings)));
            }

            return(Result);
        }
 public SearchCategoryItem(SearchFilterEnum filterType, string filterValue, string text) {
     this.FilterType = filterType;
     this.FilterValue = filterValue;
     this.Text = text;
 }