コード例 #1
0
        private async void MainForm_Load(object sender, EventArgs e)
        {
            lpList         = new LastPlayedList();
            filteredLPList = new LastPlayedList();

            if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.LastPath))
            {
                folderTxtBox.Text = Properties.Settings.Default.LastPath;
                await LoadLastPlayed();
            }
        }
コード例 #2
0
        private void SearchLastPlayed()
        {
            lock (syncLock)
            {
                if ((string.IsNullOrWhiteSpace(artistSrchBox.Text) && string.IsNullOrWhiteSpace(titleSrchBox.Text)) || lpList.Count < 1)
                {
                    if (lpList.Count > 0)
                    {
                        filteredLPList        = lpList;
                        lpDataGrid.DataSource = filteredLPList.List;
                        lpDataGrid.Refresh();
                    }
                }
                else
                {
                    IEnumerable <LastPlayed> lpSearch = lpList.List;

                    if (regexChkBox.Checked)
                    {
                        RegexOptions reo = RegexOptions.None;
                        if (casingChkBox.Checked)
                        {
                            reo = RegexOptions.IgnoreCase;
                        }

                        var reArtist = new Regex(artistSrchBox.Text, reo);
                        var reTitle  = new Regex(titleSrchBox.Text, reo);

                        lpSearch = lpSearch.Where(lp => reArtist.IsMatch(lp.Artist) && reTitle.IsMatch(lp.Title));
                    }
                    else
                    {
                        var queries = artistSrchBox.Text.Split(' ');
                        foreach (var q in queries)
                        {
                            lpSearch = lpSearch.Where(lp => lp.Artist.IndexOf(q, StringComparison.InvariantCultureIgnoreCase) >= 0);
                        }

                        queries = titleSrchBox.Text.Split(' ');

                        foreach (var q in queries)
                        {
                            lpSearch = lpSearch.Where(lp => lp.Title.IndexOf(q, StringComparison.InvariantCultureIgnoreCase) >= 0);
                        }
                    }

                    filteredLPList        = new LastPlayedList(lpSearch.ToList());
                    lpDataGrid.DataSource = filteredLPList.List;
                    lpDataGrid.Refresh();
                }
            }
        }