private void btnStart_Click(object sender, RoutedEventArgs e) { if (songs == null || songs.Count <= 0) { return; } Thread th = new Thread(() => { //ConverterLib.CueReader reader = new ConverterLib.CueReader("d:\\abc.cue"); // IList<ConverterLib.CueSongInfo> songs= reader.ReadAllSounds(); txtOutput.Dispatcher.Invoke(new Action(() => { txtOutput.Text = "[√]正在解压缩..."; })); //string audiofile = ""; //foreach (string t in supportType) //{ // string tmpaudio = System.IO.Path.ChangeExtension(cueFile, t); // if (System.IO.File.Exists(tmpaudio)) // { // audiofile = tmpaudio; // break; // } // this.Dispatcher.Invoke(new Action(() => // { // this.btnStart.IsEnabled = true; // this.btnOpen.IsEnabled = true; // })); //} ConverterLib.IWavConverter converter = ConverterLib.WavConverterFactory.GetWavConverter(audioFile); //ConverterLib.ApeWavConverter converter = new ConverterLib.ApeWavConverter(); //converter.OutputUpdated += new System.Diagnostics.DataReceivedEventHandler(converter_OutputUpdated); converter.BeginConvert(audioFile); converter.EndConvert(false); progressBar1.Dispatcher.Invoke(new Action(() => { progressBar1.Value = (++step) * 100 / stepcnt; })); ConverterLib.WavSplitter split = new ConverterLib.WavSplitter(System.IO.Path.ChangeExtension(audioFile, "wav")); //split.OutputUpdated+=new System.Diagnostics.DataReceivedEventHandler(converter_OutputUpdated); foreach (ConverterLib.CueSongInfo info in songs) { txtOutput.Dispatcher.Invoke(new Action(() => { txtOutput.Text = "[√]正在切割...[" + info.Title + "]"; })); split.BeginSplit(info); split.EndSplit(false); ConverterLib.Mp3Converter con = new ConverterLib.Mp3Converter(split.NewFileName, info); con.ProgressChanged += new ConverterLib.ProgressChangedEventHandler(con_ProgressChanged); txtOutput.Dispatcher.Invoke(new Action(() => { txtOutput.Text = "[√]正在转换...[" + info.Title + "]"; })); con.BeginConvert(new ConverterLib.Mp3Config()); con.EndConvert(false); progressBar1.Dispatcher.Invoke(new Action(() => { progressBar1.Value = (++step) * 100 / stepcnt; })); } System.IO.File.Delete(System.IO.Path.ChangeExtension(cueFile, "wav")); this.Dispatcher.Invoke(new Action(() => { this.btnStart.IsEnabled = true; this.btnOpen.IsEnabled = true; txtOutput.Text = "[√]全部完成"; })); }); this.btnOpen.IsEnabled = false; this.btnStart.IsEnabled = false; th.Start(); }
private void btnStart_Click(object sender, RoutedEventArgs e) { if (songs == null || songs.Count <= 0) { return; } Thread th = new Thread(() => { //ConverterLib.CueReader reader = new ConverterLib.CueReader("d:\\abc.cue"); // IList<ConverterLib.CueSongInfo> songs= reader.ReadAllSounds(); txtOutput.Dispatcher.Invoke(new Action(() => { txtOutput.Text = "[√]正在解压缩..."; })); //string audiofile = ""; //foreach (string t in supportType) //{ // string tmpaudio = System.IO.Path.ChangeExtension(cueFile, t); // if (System.IO.File.Exists(tmpaudio)) // { // audiofile = tmpaudio; // break; // } // this.Dispatcher.Invoke(new Action(() => // { // this.btnStart.IsEnabled = true; // this.btnOpen.IsEnabled = true; // })); //} ConverterLib.IWavConverter converter = ConverterLib.WavConverterFactory.GetWavConverter(audioFile); //ConverterLib.ApeWavConverter converter = new ConverterLib.ApeWavConverter(); //converter.OutputUpdated += new System.Diagnostics.DataReceivedEventHandler(converter_OutputUpdated); converter.BeginConvert(audioFile); converter.EndConvert(false); progressBar1.Dispatcher.Invoke(new Action(()=>{progressBar1.Value=(++step)*100/stepcnt;})); ConverterLib.WavSplitter split = new ConverterLib.WavSplitter(System.IO.Path.ChangeExtension(audioFile,"wav")); //split.OutputUpdated+=new System.Diagnostics.DataReceivedEventHandler(converter_OutputUpdated); foreach (ConverterLib.CueSongInfo info in songs) { txtOutput.Dispatcher.Invoke(new Action(() => { txtOutput.Text = "[√]正在切割...[" + info.Title + "]"; })); split.BeginSplit(info); split.EndSplit(false); ConverterLib.Mp3Converter con = new ConverterLib.Mp3Converter(split.NewFileName,info); con.ProgressChanged += new ConverterLib.ProgressChangedEventHandler(con_ProgressChanged); txtOutput.Dispatcher.Invoke(new Action(() => { txtOutput.Text = "[√]正在转换...[" + info.Title + "]"; })); con.BeginConvert(new ConverterLib.Mp3Config()); con.EndConvert(false); progressBar1.Dispatcher.Invoke(new Action(()=>{progressBar1.Value=(++step)*100/stepcnt;})); } System.IO.File.Delete(System.IO.Path.ChangeExtension(cueFile, "wav")); this.Dispatcher.Invoke(new Action(() => { this.btnStart.IsEnabled = true; this.btnOpen.IsEnabled = true; txtOutput.Text = "[√]全部完成"; })); }); this.btnOpen.IsEnabled = false; this.btnStart.IsEnabled = false; th.Start(); }