private void loadSelectedTrack() { string selectedFilePath; ListBoxFileInfoObject listBoxFile; if (lbFiles.SelectedIndices.Count == 1) { listBoxFile = (ListBoxFileInfoObject)(this.lbFiles.Items[this.lbFiles.SelectedIndex]); selectedFilePath = listBoxFile.FilePath; using (FileStream fs = File.Open(selectedFilePath, FileMode.Open, FileAccess.Read)) { Type formatType = FormatUtil.getObjectType(fs); if (formatType != null) { this.vgmData = (IXsfTagFormat)Activator.CreateInstance(formatType); this.vgmData.Initialize(fs, selectedFilePath); this.tbGame.Text = this.vgmData.GetGameTag(); this.tbArtist.Text = this.vgmData.GetArtistTag(); this.tbCopyright.Text = this.vgmData.GetCopyrightTag(); this.tbGenre.Text = this.vgmData.GetGenreTag(); this.tbYear.Text = this.vgmData.GetYearTag(); this.tbXsfBy.Text = this.vgmData.GetXsfByTag(); this.tbTagger.Text = this.vgmData.GetTaggerTag(); if (this.cbGenerateTitleFromFilename.Checked) { this.tbTitle.Text = XsfUtil.GetTitleForFileName(selectedFilePath, this.cbRemoveBrackets.Checked); } else { this.tbTitle.Text = this.vgmData.GetTitleTag(); } this.tbLength.Text = this.vgmData.GetLengthTag(); this.tbFade.Text = this.vgmData.GetFadeTag(); this.tbVolume.Text = this.vgmData.GetVolumeTag(); this.tbComments.Text = this.vgmData.GetCommentTag(); } } this.setTitleTagEnable(); } }
protected override void DoTaskForFile(string pPath, IVgmtWorkerStruct pXsfTagUpdaterStruct, DoWorkEventArgs e) { XsfTagUpdaterStruct xsfTagUpdaterStruct = (XsfTagUpdaterStruct)pXsfTagUpdaterStruct; Type formatType = null; IXsfTagFormat vgmData = null; using (FileStream fs = File.OpenRead(pPath)) { formatType = FormatUtil.getObjectType(fs); if (formatType != null) { vgmData = (IXsfTagFormat)Activator.CreateInstance(formatType); vgmData.Initialize(fs, pPath); } } if (vgmData != null) { XsfTagSetter xts; xts = new XsfTagSetter(vgmData.SetArtistTag); updateXsfTag(xts, xsfTagUpdaterStruct.ArtistTag, xsfTagUpdaterStruct.RemoveEmptyTags, xsfTagUpdaterStruct.AddToBatchFile); xts = new XsfTagSetter(vgmData.SetGameTag); updateXsfTag(xts, xsfTagUpdaterStruct.GameTag, xsfTagUpdaterStruct.RemoveEmptyTags, xsfTagUpdaterStruct.AddToBatchFile); xts = new XsfTagSetter(vgmData.SetYearTag); updateXsfTag(xts, xsfTagUpdaterStruct.YearTag, xsfTagUpdaterStruct.RemoveEmptyTags, xsfTagUpdaterStruct.AddToBatchFile); xts = new XsfTagSetter(vgmData.SetGenreTag); updateXsfTag(xts, xsfTagUpdaterStruct.GenreTag, xsfTagUpdaterStruct.RemoveEmptyTags, xsfTagUpdaterStruct.AddToBatchFile); xts = new XsfTagSetter(vgmData.SetCommentTag); updateXsfTag(xts, xsfTagUpdaterStruct.CommentTag, xsfTagUpdaterStruct.RemoveEmptyTags, xsfTagUpdaterStruct.AddToBatchFile); xts = new XsfTagSetter(vgmData.SetCopyrightTag); updateXsfTag(xts, xsfTagUpdaterStruct.CopyrightTag, xsfTagUpdaterStruct.RemoveEmptyTags, xsfTagUpdaterStruct.AddToBatchFile); xts = new XsfTagSetter(vgmData.SetXsfByTag); updateXsfTag(xts, xsfTagUpdaterStruct.XsfByTag, xsfTagUpdaterStruct.RemoveEmptyTags, xsfTagUpdaterStruct.AddToBatchFile); xts = new XsfTagSetter(vgmData.SetTaggerTag); updateXsfTag(xts, xsfTagUpdaterStruct.TaggerTag, xsfTagUpdaterStruct.RemoveEmptyTags, xsfTagUpdaterStruct.AddToBatchFile); xts = new XsfTagSetter(vgmData.SetSystemTag); updateXsfTag(xts, xsfTagUpdaterStruct.SystemTag, xsfTagUpdaterStruct.RemoveEmptyTags, xsfTagUpdaterStruct.AddToBatchFile); if (xsfTagUpdaterStruct.GenerateTitleFromFilename) { xsfTagUpdaterStruct.TitleTag = XsfUtil.GetTitleForFileName(pPath, xsfTagUpdaterStruct.RemoveBracketInfoFromTitle); xts = new XsfTagSetter(vgmData.SetTitleTag); updateXsfTag(xts, xsfTagUpdaterStruct.TitleTag, xsfTagUpdaterStruct.RemoveEmptyTags, xsfTagUpdaterStruct.AddToBatchFile); } if (!xsfTagUpdaterStruct.IsBatchMode) { xts = new XsfTagSetter(vgmData.SetVolumeTag); updateXsfTag(xts, xsfTagUpdaterStruct.VolumeTag, xsfTagUpdaterStruct.RemoveEmptyTags, xsfTagUpdaterStruct.AddToBatchFile); xts = new XsfTagSetter(vgmData.SetLengthTag); updateXsfTag(xts, xsfTagUpdaterStruct.LengthTag, xsfTagUpdaterStruct.RemoveEmptyTags, xsfTagUpdaterStruct.AddToBatchFile); xts = new XsfTagSetter(vgmData.SetFadeTag); updateXsfTag(xts, xsfTagUpdaterStruct.FadeTag, xsfTagUpdaterStruct.RemoveEmptyTags, xsfTagUpdaterStruct.AddToBatchFile); xts = new XsfTagSetter(vgmData.SetTitleTag); updateXsfTag(xts, xsfTagUpdaterStruct.TitleTag, xsfTagUpdaterStruct.RemoveEmptyTags, xsfTagUpdaterStruct.AddToBatchFile); } else if (xsfTagUpdaterStruct.AddToBatchFile) { // reset tags with existing values to add to batch script xts = new XsfTagSetter(vgmData.SetVolumeTag); updateXsfTag(xts, vgmData.GetVolumeTag(), xsfTagUpdaterStruct.RemoveEmptyTags, xsfTagUpdaterStruct.AddToBatchFile); xts = new XsfTagSetter(vgmData.SetLengthTag); updateXsfTag(xts, vgmData.GetLengthTag(), xsfTagUpdaterStruct.RemoveEmptyTags, xsfTagUpdaterStruct.AddToBatchFile); xts = new XsfTagSetter(vgmData.SetFadeTag); updateXsfTag(xts, vgmData.GetFadeTag(), xsfTagUpdaterStruct.RemoveEmptyTags, xsfTagUpdaterStruct.AddToBatchFile); xts = new XsfTagSetter(vgmData.SetTitleTag); updateXsfTag(xts, vgmData.GetTitleTag(), xsfTagUpdaterStruct.RemoveEmptyTags, xsfTagUpdaterStruct.AddToBatchFile); } vgmData.UpdateTags(); } }