コード例 #1
0
        public Task SetMetaTags(SearchResultModel[] files)
        {
            if (files.Length == 0)
            {
                return(Task.CompletedTask);
            }

            try
            {
                Parallel.ForEach(files, file =>
                {
                    var track = new Track(file.Id);

                    if (file == null)
                    {
                        return;
                    }

                    track.SetMetaTags(MetatagsHelpers.GetMetatags(file.Tags));
                });
            }
            catch (Exception)
            {
            }

            return(Task.CompletedTask);
        }
コード例 #2
0
        private async Task Search(SearchFieldsEnum searchField, string query, string[] terms)
        {
            var indexSearcher = new IndexSearcher();

            if (!indexSearcher.IndexExists)
            {
                return;
            }

            SearchStarted();

            var res = await Task.Run(() => indexSearcher.Search(query, terms, searchField));

            SearchFinished(res);

            dgSearchResult.DataSource = res.Hits
                                        .Select(x => new SearchResultModel
            {
                Id          = x.Id,
                Artist      = MetatagsHelpers.GetMetatags(x.Tags)[0],
                Album       = MetatagsHelpers.GetMetatags(x.Tags)[1],
                Year        = string.IsNullOrWhiteSpace(MetatagsHelpers.GetMetatags(x.Tags)[2]) || !int.TryParse(MetatagsHelpers.GetMetatags(x.Tags)[2], out int value1) ? default(int?) : value1,
                TrackName   = MetatagsHelpers.GetMetatags(x.Tags)[4],
                TrackNumber = string.IsNullOrWhiteSpace(MetatagsHelpers.GetMetatags(x.Tags)[5]) || !int.TryParse(MetatagsHelpers.GetMetatags(x.Tags)[5], out int value2) ? default(int?) : value2,
                Tags        = x.Tags,
                Path        = System.IO.Path.GetDirectoryName(x.Id),
                FileName    = System.IO.Path.GetFileName(x.Id),
                Genre       = MetatagsHelpers.GetMetatags(x.Tags)[3]
            })
コード例 #3
0
        private void txtGenre_TextChanged(object sender, EventArgs e)
        {
            if (txtGenre.Text.Equals(Constants.MultipleValues))
            {
                return;
            }

            foreach (DataGridViewRow row in dgFilesSelected.SelectedRows)
            {
                var tags = MetatagsHelpers.GetMetatags(Files[row.Index].Tags);
                tags[3] = txtGenre.Text;
                Files[row.Index].Genre = txtGenre.Text;
                Files[row.Index].Tags  = string.Join("|", tags);
            }
        }
コード例 #4
0
        private void ShowFileInfo(SearchResultModel model)
        {
            var metaTags = MetatagsHelpers.GetMetatags(model.Tags);
            var sb       = new StringBuilder();

            sb.AppendLine($"Path: {model.Path}");
            sb.AppendLine($"File: {model.FileName}");
            sb.AppendLine($"Artist: {metaTags[0]}");
            sb.AppendLine($"Album: {metaTags[1]}");
            sb.AppendLine($"Year: {metaTags[2]}");
            sb.AppendLine($"Genre: {metaTags[3]}");
            sb.AppendLine($"Title: {metaTags[4]}");
            sb.AppendLine($"Track no: {metaTags[5]}");

            MessageBox.Show(sb.ToString(), "Track info", MessageBoxButtons.OK);
        }
コード例 #5
0
        private void txtTrackNumber_TextChanged(object sender, EventArgs e)
        {
            if (txtTrackNumber.Text.Equals(Constants.MultipleValues))
            {
                return;
            }

            foreach (DataGridViewRow row in dgFilesSelected.SelectedRows)
            {
                var tags = MetatagsHelpers.GetMetatags(Files[row.Index].Tags);
                tags[5] = txtTrackNumber.Text;
                Files[row.Index].TrackNumber = int.Parse(txtTrackNumber.Text);
                Files[row.Index].Tags        = string.Join("|", tags);
            }

            dgFilesSelected.Refresh();
        }
コード例 #6
0
        private void dgFilesSelected_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            //Title
            if (e.ColumnIndex == 4)
            {
                var tags = MetatagsHelpers.GetMetatags(Files[e.RowIndex].Tags);
                tags[4] = (string)dgFilesSelected[e.ColumnIndex, e.RowIndex].Value;
                Files[e.RowIndex].Tags = string.Join("|", tags);
            }

            //Track no
            if (e.ColumnIndex == 5)
            {
                var tags = MetatagsHelpers.GetMetatags(Files[e.RowIndex].Tags);
                tags[5] = ((int)dgFilesSelected[e.ColumnIndex, e.RowIndex].Value).ToString();
                Files[e.RowIndex].Tags = string.Join("|", tags);
            }
        }