private void updateSample() { renameFormat = TrackWriter.GetRenameFormat(cboRename.Text); dirFormat = TrackWriter.GetDirFormat(cboSubdirectory.Text); if (pathIsValid(complexify(root()))) { btnOK.Enabled = true; sampleText = Path.Combine((root()), TrackWriter.GetPath(sampleTrack, dirFormat, renameFormat));// +sampleTrack.DefaultExtension; } else { sampleText = invalidPath; btnOK.Enabled = false; } this.Invalidate(); }
private void writeTracks() { if (Dirty) { bool writeArtist = write(txtArtist); bool writeAlbum = write(txtAlbum); bool writeAlbumArtist = write(txtAlbumArtist); bool writeGenre = write(cboGenre); bool writeGrouping = write(cboGrouping); bool writeComposer = write(txtComposer); bool writeYear = write(txtYear); bool writeTrackNum = write(txtTrackNum); bool writeDiskNum = write(txtDiskNum); bool?writeCompilation = write(cboCompilation) ? (cboCompilation.Text == Localization.YES) : (bool?)null; string title; if (!isMultiple) { title = txtTitle.Text.Trim(); } string artist = txtArtist.Text.Trim(); string album = txtAlbum.Text.Trim(); string albumArtist = txtAlbumArtist.Text.Trim(); string genre = cboGenre.Text.Trim(); string grouping = cboGrouping.Text.Trim(); string composer = txtComposer.Text.Trim(); int year = 0; Int32.TryParse(txtYear.Text.Trim(), out year); int trackNum = 0; Int32.TryParse(txtTrackNum.Text.Trim(), out trackNum); int diskNum = 0; Int32.TryParse(txtDiskNum.Text.Trim(), out diskNum); TrackWriter.RenameFormat rf = TrackWriter.RenameFormat.None; if (cboRename.SelectedIndex > 0 && (!isMultiple || checkboxes[cboRename].Checked)) { if (isMultiple) { rf = TrackWriter.GetRenameFormat(cboRename.Text); } else { rf = TrackWriter.GetRenameFormat(template, cboRename.Text); } } bool writeImage = chkArt.Checked && ImageDirty; foreach (Track t in tracks) { if (!isMultiple) { string s; if (t.Title != (s = txtTitle.Text.Trim())) { t.Title = s; t.ChangeType |= ChangeType.WriteTags; } } if (writeArtist) { t.ChangeType |= ChangeType.WriteTags; t.Artist = artist; } if (writeAlbum) { t.ChangeType |= ChangeType.WriteTags; t.Album = album; } if (writeAlbumArtist) { t.ChangeType |= ChangeType.WriteTags; t.AlbumArtist = albumArtist; } if (writeComposer) { t.ChangeType |= ChangeType.WriteTags; t.Composer = composer; } if (writeGenre) { t.ChangeType |= ChangeType.WriteTags; t.Genre = genre; } if (writeGrouping) { t.ChangeType |= ChangeType.WriteTags; t.Grouping = grouping; } if (writeYear) { t.ChangeType |= ChangeType.WriteTags; t.Year = year; } if (writeTrackNum) { t.ChangeType |= ChangeType.WriteTags; t.TrackNum = trackNum; } if (writeDiskNum) { t.ChangeType |= ChangeType.WriteTags; t.DiskNum = diskNum; } if (writeCompilation.HasValue) { t.ChangeType |= ChangeType.WriteTags; t.Compilation = writeCompilation.Value; } t.UpdateMainGroup(); Database.IncrementDatabaseVersion(true); if (writeImage) { t.SetCover(Image); t.ChangeType |= ChangeType.EmbedImage; this.Parent.Invalidate(); } else { t.AllowCoverLoad(); // tags might make it accessible now } if (rf != TrackWriter.RenameFormat.None) { t.RenameFormat = rf; t.ChangeType |= (ChangeType.Rename | ChangeType.IgnoreContainment); } if (Setting.KeepOrganized) { t.ChangeType |= ChangeType.Move; } } TrackWriter.AddToUnsavedTracks(tracks); } }