diff --git a/CUERipper/CUERipper.csproj b/CUERipper/CUERipper.csproj new file mode 100644 index 0000000..a35354e --- /dev/null +++ b/CUERipper/CUERipper.csproj @@ -0,0 +1,145 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {39B43BBB-BAFC-4D85-9BEA-3BCB7EFED89C} + WinExe + Properties + CUERipper + CUERipper + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + ..\bin\x64\Debug\ + DEBUG;TRACE + full + x64 + C:\Program Files (x86)\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\rules + true + GlobalSuppressions.cs + prompt + + + ..\bin\x64\Release\ + TRACE + true + pdbonly + x64 + C:\Program Files (x86)\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\rules + true + GlobalSuppressions.cs + prompt + + + true + ..\bin\win32\Debug\ + DEBUG;TRACE + full + x86 + C:\Program Files (x86)\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\rules + true + GlobalSuppressions.cs + prompt + + + ..\bin\win32\Release\ + TRACE + true + pdbonly + x86 + C:\Program Files (x86)\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\rules + true + GlobalSuppressions.cs + prompt + + + + + + + + + + + + Form + + + frmCUERipper.cs + + + + + Designer + frmCUERipper.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + {5802C7E9-157E-4124-946D-70B5AE48A5A1} + CUETools.AccurateRip + + + {1DD41038-D885-46C5-8DDE-E0B82F066584} + CUETools.CDImage + + + {6458A13A-30EF-45A9-9D58-E5031B17BEE2} + CUETools.Codecs + + + {8CF07381-BEA2-4AFC-B3DD-9B2F21C65A3A} + CUETools.Ripper.SCSI + + + {74C2036B-2C9B-4FC8-B7BD-AE81A8DCE533} + MusicBrainz + + + + + \ No newline at end of file diff --git a/CUERipper/Program.cs b/CUERipper/Program.cs new file mode 100644 index 0000000..d794d23 --- /dev/null +++ b/CUERipper/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace CUERipper +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new frmCUERipper()); + } + } +} \ No newline at end of file diff --git a/CUERipper/Properties/AssemblyInfo.cs b/CUERipper/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f40035e --- /dev/null +++ b/CUERipper/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("CUERipper")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("CUERipper")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ca7d1e64-3d22-410c-bfb3-ececa7aaeb90")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/CUERipper/Properties/DataSources/MusicBrainz.Release.datasource b/CUERipper/Properties/DataSources/MusicBrainz.Release.datasource new file mode 100644 index 0000000..b03bffb --- /dev/null +++ b/CUERipper/Properties/DataSources/MusicBrainz.Release.datasource @@ -0,0 +1,10 @@ + + + + MusicBrainz.Release, MusicBrainz, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/CUERipper/Properties/Resources.Designer.cs b/CUERipper/Properties/Resources.Designer.cs new file mode 100644 index 0000000..d9959d6 --- /dev/null +++ b/CUERipper/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.1434 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace CUERipper.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CUERipper.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/CUERipper/Properties/Resources.resx b/CUERipper/Properties/Resources.resx new file mode 100644 index 0000000..ffecec8 --- /dev/null +++ b/CUERipper/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/CUERipper/Properties/Settings.Designer.cs b/CUERipper/Properties/Settings.Designer.cs new file mode 100644 index 0000000..e4cc54b --- /dev/null +++ b/CUERipper/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.1434 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace CUERipper.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/CUERipper/Properties/Settings.settings b/CUERipper/Properties/Settings.settings new file mode 100644 index 0000000..abf36c5 --- /dev/null +++ b/CUERipper/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/CUERipper/frmCUERipper.Designer.cs b/CUERipper/frmCUERipper.Designer.cs new file mode 100644 index 0000000..bb139f9 --- /dev/null +++ b/CUERipper/frmCUERipper.Designer.cs @@ -0,0 +1,241 @@ +namespace CUERipper +{ + partial class frmCUERipper + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmCUERipper)); + this.comboDrives = new System.Windows.Forms.ComboBox(); + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar(); + this.toolStripProgressBar2 = new System.Windows.Forms.ToolStripProgressBar(); + this.listTracks = new System.Windows.Forms.ListView(); + this.TrackNo = new System.Windows.Forms.ColumnHeader(); + this.Title = new System.Windows.Forms.ColumnHeader(); + this.Start = new System.Windows.Forms.ColumnHeader(); + this.Length = new System.Windows.Forms.ColumnHeader(); + this.buttonGo = new System.Windows.Forms.Button(); + this.comboLossless = new System.Windows.Forms.ComboBox(); + this.comboCodec = new System.Windows.Forms.ComboBox(); + this.comboImage = new System.Windows.Forms.ComboBox(); + this.buttonAbort = new System.Windows.Forms.Button(); + this.buttonPause = new System.Windows.Forms.Button(); + this.comboRelease = new System.Windows.Forms.ComboBox(); + this.releaseBindingSource = new System.Windows.Forms.BindingSource(this.components); + this.statusStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.releaseBindingSource)).BeginInit(); + this.SuspendLayout(); + // + // comboDrives + // + resources.ApplyResources(this.comboDrives, "comboDrives"); + this.comboDrives.DisplayMember = "Path"; + this.comboDrives.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboDrives.FormattingEnabled = true; + this.comboDrives.Name = "comboDrives"; + this.comboDrives.ValueMember = "Path"; + this.comboDrives.SelectedIndexChanged += new System.EventHandler(this.comboDrives_SelectedIndexChanged); + // + // statusStrip1 + // + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripStatusLabel1, + this.toolStripProgressBar1, + this.toolStripProgressBar2}); + resources.ApplyResources(this.statusStrip1, "statusStrip1"); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.SizingGrip = false; + // + // toolStripStatusLabel1 + // + this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; + resources.ApplyResources(this.toolStripStatusLabel1, "toolStripStatusLabel1"); + this.toolStripStatusLabel1.Spring = true; + // + // toolStripProgressBar1 + // + this.toolStripProgressBar1.AutoToolTip = true; + this.toolStripProgressBar1.Name = "toolStripProgressBar1"; + resources.ApplyResources(this.toolStripProgressBar1, "toolStripProgressBar1"); + this.toolStripProgressBar1.Style = System.Windows.Forms.ProgressBarStyle.Continuous; + // + // toolStripProgressBar2 + // + this.toolStripProgressBar2.AutoToolTip = true; + this.toolStripProgressBar2.Name = "toolStripProgressBar2"; + resources.ApplyResources(this.toolStripProgressBar2, "toolStripProgressBar2"); + this.toolStripProgressBar2.Style = System.Windows.Forms.ProgressBarStyle.Continuous; + // + // listTracks + // + resources.ApplyResources(this.listTracks, "listTracks"); + this.listTracks.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.TrackNo, + this.Title, + this.Start, + this.Length}); + this.listTracks.FullRowSelect = true; + this.listTracks.GridLines = true; + this.listTracks.Name = "listTracks"; + this.listTracks.UseCompatibleStateImageBehavior = false; + this.listTracks.View = System.Windows.Forms.View.Details; + // + // TrackNo + // + resources.ApplyResources(this.TrackNo, "TrackNo"); + // + // Title + // + resources.ApplyResources(this.Title, "Title"); + // + // Start + // + resources.ApplyResources(this.Start, "Start"); + // + // Length + // + resources.ApplyResources(this.Length, "Length"); + // + // buttonGo + // + resources.ApplyResources(this.buttonGo, "buttonGo"); + this.buttonGo.Name = "buttonGo"; + this.buttonGo.UseVisualStyleBackColor = true; + this.buttonGo.Click += new System.EventHandler(this.buttonGo_Click); + // + // comboLossless + // + this.comboLossless.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + resources.ApplyResources(this.comboLossless, "comboLossless"); + this.comboLossless.FormattingEnabled = true; + this.comboLossless.Items.AddRange(new object[] { + resources.GetString("comboLossless.Items"), + resources.GetString("comboLossless.Items1"), + resources.GetString("comboLossless.Items2")}); + this.comboLossless.Name = "comboLossless"; + // + // comboCodec + // + this.comboCodec.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + resources.ApplyResources(this.comboCodec, "comboCodec"); + this.comboCodec.FormattingEnabled = true; + this.comboCodec.Items.AddRange(new object[] { + resources.GetString("comboCodec.Items"), + resources.GetString("comboCodec.Items1"), + resources.GetString("comboCodec.Items2"), + resources.GetString("comboCodec.Items3")}); + this.comboCodec.Name = "comboCodec"; + // + // comboImage + // + this.comboImage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + resources.ApplyResources(this.comboImage, "comboImage"); + this.comboImage.FormattingEnabled = true; + this.comboImage.Items.AddRange(new object[] { + resources.GetString("comboImage.Items"), + resources.GetString("comboImage.Items1")}); + this.comboImage.Name = "comboImage"; + // + // buttonAbort + // + resources.ApplyResources(this.buttonAbort, "buttonAbort"); + this.buttonAbort.Name = "buttonAbort"; + this.buttonAbort.UseVisualStyleBackColor = true; + this.buttonAbort.Click += new System.EventHandler(this.buttonAbort_Click); + // + // buttonPause + // + resources.ApplyResources(this.buttonPause, "buttonPause"); + this.buttonPause.Name = "buttonPause"; + this.buttonPause.UseVisualStyleBackColor = true; + this.buttonPause.Click += new System.EventHandler(this.buttonPause_Click); + // + // comboRelease + // + resources.ApplyResources(this.comboRelease, "comboRelease"); + this.comboRelease.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboRelease.FormattingEnabled = true; + this.comboRelease.Name = "comboRelease"; + this.comboRelease.SelectedIndexChanged += new System.EventHandler(this.comboRelease_SelectedIndexChanged); + this.comboRelease.Format += new System.Windows.Forms.ListControlConvertEventHandler(this.comboRelease_Format); + // + // releaseBindingSource + // + this.releaseBindingSource.DataSource = typeof(MusicBrainz.Release); + // + // frmCUERipper + // + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.comboRelease); + this.Controls.Add(this.buttonPause); + this.Controls.Add(this.buttonAbort); + this.Controls.Add(this.comboImage); + this.Controls.Add(this.comboCodec); + this.Controls.Add(this.comboLossless); + this.Controls.Add(this.buttonGo); + this.Controls.Add(this.listTracks); + this.Controls.Add(this.statusStrip1); + this.Controls.Add(this.comboDrives); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.Name = "frmCUERipper"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.Load += new System.EventHandler(this.frmCUERipper_Load); + this.statusStrip1.ResumeLayout(false); + this.statusStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.releaseBindingSource)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ComboBox comboDrives; + private System.Windows.Forms.StatusStrip statusStrip1; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; + private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar1; + private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar2; + private System.Windows.Forms.ListView listTracks; + private System.Windows.Forms.ColumnHeader TrackNo; + private System.Windows.Forms.ColumnHeader Title; + private System.Windows.Forms.ColumnHeader Start; + private System.Windows.Forms.ColumnHeader Length; + private System.Windows.Forms.Button buttonGo; + private System.Windows.Forms.ComboBox comboLossless; + private System.Windows.Forms.ComboBox comboCodec; + private System.Windows.Forms.ComboBox comboImage; + private System.Windows.Forms.Button buttonAbort; + private System.Windows.Forms.Button buttonPause; + private System.Windows.Forms.ComboBox comboRelease; + private System.Windows.Forms.BindingSource releaseBindingSource; + } +} + diff --git a/CUERipper/frmCUERipper.cs b/CUERipper/frmCUERipper.cs new file mode 100644 index 0000000..ca0edea --- /dev/null +++ b/CUERipper/frmCUERipper.cs @@ -0,0 +1,294 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Threading; +using System.Windows.Forms; +using CUETools.Ripper.SCSI; +using CUETools.CDImage; +using MusicBrainz; + +namespace CUERipper +{ + public partial class frmCUERipper : Form + { + private CDDriveReader _reader = null; + private Thread _workThread = null; + private StartStop _startStop; + + public frmCUERipper() + { + InitializeComponent(); + _startStop = new StartStop(); + } + + private void frmCUERipper_Load(object sender, EventArgs e) + { + foreach(char drive in CDDriveReader.DrivesAvailable()) + { + CDDriveReader reader = new CDDriveReader(); + if (reader.Open(drive)) + comboDrives.Items.Add(reader); + } + if (comboDrives.Items.Count == 0) + comboDrives.Items.Add("No CD drives found"); + comboDrives.SelectedIndex = 0; + comboLossless.SelectedIndex = 0; + comboCodec.SelectedIndex = 0; + comboImage.SelectedIndex = 0; + } + + private void SetupControls () + { + bool running = _workThread != null; + listTracks.Enabled = !running; + comboDrives.Enabled = !running; + comboRelease.Enabled = !running; + buttonPause.Visible = buttonPause.Enabled = buttonAbort.Visible = buttonAbort.Enabled = running; + buttonGo.Visible = buttonGo.Enabled = !running; + toolStripStatusLabel1.Text = String.Empty; + toolStripProgressBar1.Value = 0; + toolStripProgressBar2.Value = 0; + } + + private void CDReadProgress(object sender, ReadProgressArgs e) + { + CDDriveReader audioSource = (CDDriveReader)sender; + lock (_startStop) + { + if (_startStop._stop) + { + _startStop._stop = false; + _startStop._pause = false; + throw new StopException(); + } + if (_startStop._pause) + { + this.BeginInvoke((MethodInvoker)delegate() + { + toolStripStatusLabel1.Text = "Paused..."; + }); + Monitor.Wait(_startStop); + } + } + int processed = e.Position - e.PassStart; + TimeSpan elapsed = DateTime.Now - e.PassTime; + double speed = elapsed.TotalSeconds > 0 ? processed / elapsed.TotalSeconds / 75 : 1.0; + + double percentDisk = (double)(e.PassStart + (processed + e.Pass * (e.PassEnd - e.PassStart)) / (audioSource.CorrectionQuality + 1)) / audioSource.TOC.AudioLength; + double percentTrck = (double)(e.Position - e.PassStart) / (e.PassEnd - e.PassStart); + string status = string.Format("Ripping @{0:00.00}x {1}", speed, e.Pass > 0 ? " (Retry " + e.Pass.ToString() + ")" : ""); + + this.BeginInvoke((MethodInvoker)delegate() + { + toolStripStatusLabel1.Text = status; + toolStripProgressBar1.Value = Math.Max(0, Math.Min(100, (int)(percentTrck * 100))); + toolStripProgressBar2.Value = Math.Max(0, Math.Min(100, (int)(percentDisk * 100))); + }); + } + + private void Rip(object o) + { + CDDriveReader audioSource = (CDDriveReader)o; + audioSource.ReadProgress += new EventHandler(CDReadProgress); + int[,] buff = new int[audioSource.BestBlockSize, audioSource.ChannelCount]; + + try + { + audioSource.Position = 0; + do + { + uint toRead = Math.Min((uint)buff.GetLength(0), (uint)audioSource.Remaining); + uint samplesRead = audioSource.Read(buff, toRead); + if (samplesRead == 0) break; + if (samplesRead != toRead) + throw new Exception("samples read != samples requested"); + //arVerify.Write(buff, samplesRead); + //audioDest.Write(buff, samplesRead); + } while (true); + } + catch (StopException) + { + } + catch (Exception ex) + { + this.Invoke((MethodInvoker)delegate() + { + string message = "Exception"; + for (Exception e = ex; e != null; e = e.InnerException) + message += ": " + e.Message; + DialogResult dlgRes = MessageBox.Show(this, message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + }); + } + _workThread = null; + SetupControls(); + } + + private void buttonGo_Click(object sender, EventArgs e) + { + if (_reader == null) + return; + _workThread = new Thread(Rip); + _workThread.Priority = ThreadPriority.BelowNormal; + _workThread.IsBackground = true; + SetupControls(); + _workThread.Start(_reader); + } + + private void buttonAbort_Click(object sender, EventArgs e) + { + lock (_startStop) + { + if (_startStop._pause) + { + _startStop._pause = false; + Monitor.Pulse(_startStop); + } + _startStop._stop = true; + } + } + + private void buttonPause_Click(object sender, EventArgs e) + { + lock (_startStop) + { + if (_startStop._pause) + { + _startStop._pause = false; + Monitor.Pulse(_startStop); + } + else + { + _startStop._pause = true; + } + } + } + + private void comboRelease_Format(object sender, ListControlConvertEventArgs e) + { + if (e.ListItem is string) + return; + ReadOnlyCollection events = ((Release)e.ListItem).GetEvents(); + string year = events.Count > 0 ? events[0].Date.Substring(0, 4) + ": " : ""; + e.Value = string.Format("{0}{1} - {2}", year, ((Release)e.ListItem).GetArtist(), ((Release)e.ListItem).GetTitle()); + } + + private void comboRelease_SelectedIndexChanged(object sender, EventArgs e) + { + listTracks.Items.Clear(); + if (comboRelease.SelectedItem == null || comboRelease.SelectedItem is string) + { + for (int i = 1; i <= _reader.TOC.AudioTracks; i++) + listTracks.Items.Add(new ListViewItem(new string[] { _reader.TOC[i].Number.ToString(), "Track " + _reader.TOC[i].Number.ToString(), _reader.TOC[i].StartMSF, _reader.TOC[i].LengthMSF })); + return; + } + Release release = (Release) comboRelease.SelectedItem; + for (int i = 1; i <= _reader.TOC.AudioTracks; i++) + { + Track track = release.GetTracks()[(int)_reader.TOC[i].Number - 1]; + listTracks.Items.Add(new ListViewItem(new string[] { _reader.TOC[i].Number.ToString(), track.GetTitle(), _reader.TOC[i].StartMSF, _reader.TOC[i].LengthMSF })); + } + } + + private void MusicBrainz_LookupProgress(object sender, XmlRequestEventArgs e) + { + //_progress.percentDisk = (1.0 + _progress.percentDisk) / 2; + //_progress.input = e.Uri.ToString(); + lock (_startStop) + { + if (_startStop._stop) + { + _startStop._stop = false; + _startStop._pause = false; + throw new StopException(); + } + if (_startStop._pause) + { + this.BeginInvoke((MethodInvoker)delegate() + { + toolStripStatusLabel1.Text = "Paused..."; + }); + Monitor.Wait(_startStop); + } + } + this.BeginInvoke((MethodInvoker)delegate() + { + toolStripStatusLabel1.Text = "Looking up album via MusicBrainz"; + toolStripProgressBar1.Value = 0; + toolStripProgressBar2.Value = (100 + toolStripProgressBar2.Value) / 2; + }); + } + + private void Lookup(object o) + { + CDDriveReader audioSource = (CDDriveReader)o; + + ReleaseQueryParameters p = new ReleaseQueryParameters(); + p.DiscId = _reader.TOC.MusicBrainzId; + Query results = Release.Query(p); + MusicBrainzService.XmlRequest += new EventHandler(MusicBrainz_LookupProgress); + foreach (Release release in results) + { + release.GetEvents(); + release.GetTracks(); + this.BeginInvoke((MethodInvoker)delegate() + { + comboRelease.Items.Add(release); + }); + } + MusicBrainzService.XmlRequest -= new EventHandler(MusicBrainz_LookupProgress); + this.BeginInvoke((MethodInvoker)delegate() + { + if (comboRelease.Items.Count == 0) + comboRelease.Items.Add("MusicBrainz: not found"); + }); + _workThread = null; + SetupControls(); + this.BeginInvoke((MethodInvoker)delegate() + { + comboRelease.SelectedIndex = 0; + }); + } + + private void comboDrives_SelectedIndexChanged(object sender, EventArgs e) + { + comboRelease.Items.Clear(); + listTracks.Items.Clear(); + if (comboDrives.SelectedItem is string) + return; + _reader = (CDDriveReader)comboDrives.SelectedItem; + if (_reader.TOC.AudioTracks == 0) + { + comboRelease.Items.Add("No audio tracks"); + return; + } + comboRelease_SelectedIndexChanged(sender, e); + _workThread = new Thread(Lookup); + _workThread.Priority = ThreadPriority.BelowNormal; + _workThread.IsBackground = true; + SetupControls(); + _workThread.Start(_reader); + } + } + + public class StopException : Exception + { + public StopException() + : base() + { + } + } + + public class StartStop + { + public bool _stop, _pause; + public StartStop() + { + _stop = false; + _pause = false; + } + } +} diff --git a/CUERipper/frmCUERipper.resx b/CUERipper/frmCUERipper.resx new file mode 100644 index 0000000..3cf4b51 --- /dev/null +++ b/CUERipper/frmCUERipper.resx @@ -0,0 +1,528 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + Top, Left, Right + + + + 6, 6 + + + 481, 21 + + + + 1 + + + comboDrives + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 9 + + + 0, 371 + + + 200, 17 + + + MiddleLeft + + + 140, 16 + + + Track progress + + + 140, 16 + + + Disk progress + + + 0, 371 + + + 499, 22 + + + 12 + + + statusStrip1 + + + statusStrip1 + + + System.Windows.Forms.StatusStrip, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 8 + + + Top, Left, Right + + + # + + + 30 + + + Title + + + 307 + + + Start + + + 70 + + + Length + + + 70 + + + 6, 60 + + + 481, 269 + + + 0 + + + listTracks + + + System.Windows.Forms.ListView, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 7 + + + Top, Left, Right + + + 396, 335 + + + 91, 33 + + + 13 + + + Go + + + buttonGo + + + System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 6 + + + False + + + lossless + + + hybrid + + + lossy + + + 6, 335 + + + 70, 21 + + + 16 + + + comboLossless + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 5 + + + False + + + flac + + + WavPack + + + wav + + + ape + + + 82, 335 + + + 70, 21 + + + 17 + + + comboCodec + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 4 + + + False + + + image + + + tracks + + + 158, 335 + + + 70, 21 + + + 18 + + + comboImage + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 3 + + + Top, Left, Right + + + NoControl + + + 396, 335 + + + 91, 33 + + + 19 + + + Abort + + + False + + + buttonAbort + + + System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + + + Top, Left, Right + + + NoControl + + + 299, 335 + + + 91, 33 + + + 20 + + + Pause + + + False + + + buttonPause + + + System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + Top, Left, Right + + + 6, 33 + + + 481, 21 + + + 21 + + + comboRelease + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + + + 116, 371 + + + True + + + 6, 13 + + + 499, 393 + + + CenterScreen + + + CUERipper + + + toolStripStatusLabel1 + + + System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + toolStripProgressBar1 + + + System.Windows.Forms.ToolStripProgressBar, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + toolStripProgressBar2 + + + System.Windows.Forms.ToolStripProgressBar, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + TrackNo + + + System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Title + + + System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Start + + + System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Length + + + System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + releaseBindingSource + + + System.Windows.Forms.BindingSource, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + frmCUERipper + + + System.Windows.Forms.Form, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file