2008-12-08 05:09:35 +00:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2010-05-09 07:01:47 +00:00
|
|
|
using System.Collections.Specialized;
|
2008-12-08 05:09:35 +00:00
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
2008-12-10 06:48:38 +00:00
|
|
|
using System.IO;
|
2010-02-28 21:04:34 +00:00
|
|
|
using System.Net;
|
2008-12-08 05:09:35 +00:00
|
|
|
using System.Threading;
|
|
|
|
|
using System.Windows.Forms;
|
2011-10-24 11:38:10 +00:00
|
|
|
using CUEControls;
|
2008-12-09 07:25:48 +00:00
|
|
|
using CUETools.AccurateRip;
|
2010-02-28 21:04:34 +00:00
|
|
|
using CUETools.CTDB;
|
2008-12-09 07:25:48 +00:00
|
|
|
using CUETools.Processor;
|
2011-10-24 11:38:10 +00:00
|
|
|
using CUETools.Processor.Settings;
|
2010-02-08 01:29:31 +00:00
|
|
|
using CUETools.Ripper;
|
2008-12-10 19:44:09 +00:00
|
|
|
using Freedb;
|
2012-02-15 00:18:58 +00:00
|
|
|
using CUETools.Codecs;
|
2013-02-24 19:10:39 -05:00
|
|
|
using System.Xml;
|
|
|
|
|
using System.Xml.Serialization;
|
2008-12-08 05:09:35 +00:00
|
|
|
|
|
|
|
|
namespace CUERipper
|
|
|
|
|
{
|
|
|
|
|
public partial class frmCUERipper : Form
|
|
|
|
|
{
|
|
|
|
|
private Thread _workThread = null;
|
|
|
|
|
private StartStop _startStop;
|
2008-12-09 07:25:48 +00:00
|
|
|
private CUEConfig _config;
|
2013-02-24 19:10:39 -05:00
|
|
|
private CUERipperConfig cueRipperConfig;
|
2010-03-22 06:36:42 +00:00
|
|
|
private CUESheet cueSheet;
|
2010-03-25 01:05:26 +00:00
|
|
|
private DriveInfo selectedDriveInfo;
|
2008-12-10 06:48:38 +00:00
|
|
|
private string _pathOut;
|
2009-05-01 15:16:26 +00:00
|
|
|
private CUEControls.ShellIconMgr m_icon_mgr;
|
2012-02-15 00:18:58 +00:00
|
|
|
private bool testAndCopy = false;
|
2010-05-02 17:04:51 +00:00
|
|
|
internal CUERipperData data = new CUERipperData();
|
2013-04-15 00:10:05 -04:00
|
|
|
private bool initDone = false;
|
2013-02-24 19:10:39 -05:00
|
|
|
public readonly static XmlSerializerNamespaces xmlEmptyNamespaces = new XmlSerializerNamespaces(new XmlQualifiedName[] { XmlQualifiedName.Empty });
|
|
|
|
|
public readonly static XmlWriterSettings xmlEmptySettings = new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true };
|
2008-12-08 05:09:35 +00:00
|
|
|
|
|
|
|
|
public frmCUERipper()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2008-12-09 07:25:48 +00:00
|
|
|
_config = new CUEConfig();
|
2008-12-08 05:09:35 +00:00
|
|
|
_startStop = new StartStop();
|
2013-02-24 19:10:39 -05:00
|
|
|
cueRipperConfig = new CUERipperConfig();
|
|
|
|
|
m_icon_mgr = new CUEControls.ShellIconMgr();
|
2010-03-22 06:36:42 +00:00
|
|
|
m_icon_mgr.SetExtensionIcon(".flac", Properties.Resources.flac);
|
|
|
|
|
m_icon_mgr.SetExtensionIcon(".wv", Properties.Resources.wv);
|
|
|
|
|
m_icon_mgr.SetExtensionIcon(".ape", Properties.Resources.ape);
|
|
|
|
|
m_icon_mgr.SetExtensionIcon(".tta", Properties.Resources.tta);
|
|
|
|
|
m_icon_mgr.SetExtensionIcon(".wav", Properties.Resources.wave);
|
|
|
|
|
m_icon_mgr.SetExtensionIcon(".mp3", Properties.Resources.mp3);
|
|
|
|
|
m_icon_mgr.SetExtensionIcon(".m4a", Properties.Resources.ipod_sound);
|
|
|
|
|
m_icon_mgr.SetExtensionIcon(".ogg", Properties.Resources.ogg);
|
2013-03-31 16:21:47 -04:00
|
|
|
m_icon_mgr.SetExtensionIcon(".wma", Properties.Resources.wma);
|
2008-12-08 05:09:35 +00:00
|
|
|
}
|
|
|
|
|
|
2010-03-20 07:09:07 +00:00
|
|
|
string[] OutputPathUseTemplates = {
|
2011-06-11 19:26:25 +00:00
|
|
|
"%music%\\%artist%\\[%year% - ]%album%\\%artist% - %album%[ '('disc %discnumberandname%')'].cue",
|
|
|
|
|
"%music%\\%artist%\\[%year% - ]%album%[ '('disc %discnumberandname%')'][' ('%releasedateandlabel%')'][' ('%unique%')']\\%artist% - %album%.cue"
|
2010-03-20 07:09:07 +00:00
|
|
|
};
|
|
|
|
|
|
2010-05-06 01:31:23 +00:00
|
|
|
//// Calculate the graphics path that representing the figure in the bitmap
|
|
|
|
|
//// excluding the transparent color which is the top left pixel.
|
|
|
|
|
//private static GraphicsPath CalculateControlGraphicsPath(Bitmap bitmap, Color colorTransparent)
|
|
|
|
|
//{
|
|
|
|
|
// // Create GraphicsPath for our bitmap calculation
|
|
|
|
|
// GraphicsPath graphicsPath = new GraphicsPath();
|
|
|
|
|
|
|
|
|
|
// // Use the top left pixel as our transparent color
|
|
|
|
|
// colorTransparent = bitmap.GetPixel(0, 0);
|
|
|
|
|
|
|
|
|
|
// // This is to store the column value where an opaque pixel is first found.
|
|
|
|
|
// // This value will determine where we start scanning for trailing
|
|
|
|
|
// // opaque pixels.
|
|
|
|
|
// int colOpaquePixel = 0;
|
|
|
|
|
|
|
|
|
|
// // Go through all rows (Y axis)
|
|
|
|
|
// for (int row = 0; row < bitmap.Height; row++)
|
|
|
|
|
// {
|
|
|
|
|
// // Reset value
|
|
|
|
|
// colOpaquePixel = 0;
|
|
|
|
|
|
|
|
|
|
// // Go through all columns (X axis)
|
|
|
|
|
// for (int col = 0; col < bitmap.Width; col++)
|
|
|
|
|
// {
|
|
|
|
|
// // If this is an opaque pixel, mark it and search
|
|
|
|
|
// // for anymore trailing behind
|
|
|
|
|
// if (bitmap.GetPixel(col, row) != colorTransparent)
|
|
|
|
|
// {
|
|
|
|
|
// // Opaque pixel found, mark current position
|
|
|
|
|
// colOpaquePixel = col;
|
|
|
|
|
// // Create another variable to set the current pixel position
|
|
|
|
|
// int colNext = col;
|
|
|
|
|
// // Starting from current found opaque pixel, search for
|
|
|
|
|
// // anymore opaque pixels trailing behind, until a transparent
|
|
|
|
|
// // pixel is found or minimum width is reached
|
|
|
|
|
// for (colNext = colOpaquePixel; colNext < bitmap.Width; colNext++)
|
|
|
|
|
// if (bitmap.GetPixel(colNext, row) == colorTransparent)
|
|
|
|
|
// break;
|
|
|
|
|
// // Form a rectangle for line of opaque pixels found and
|
|
|
|
|
// // add it to our graphics path
|
|
|
|
|
// graphicsPath.AddRectangle(new Rectangle(colOpaquePixel,
|
|
|
|
|
// row, colNext - colOpaquePixel, 1));
|
|
|
|
|
// // No need to scan the line of opaque pixels just found
|
|
|
|
|
// col = colNext;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// // Return calculated graphics path
|
|
|
|
|
// return graphicsPath;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//private static void CreateControlRegion(Button button, Bitmap bitmap, Color colorTransparent)
|
|
|
|
|
//{
|
|
|
|
|
// // Return if control and bitmap are null
|
|
|
|
|
// if (button == null || bitmap == null)
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
|
|
// // Set our control's size to be the same as the bitmap
|
|
|
|
|
// button.Width = bitmap.Width;
|
|
|
|
|
// button.Height = bitmap.Height;
|
|
|
|
|
|
|
|
|
|
// // Do not show button text
|
|
|
|
|
// button.Text = "";
|
|
|
|
|
|
|
|
|
|
// // Change cursor to hand when over button
|
|
|
|
|
// button.Cursor = Cursors.Hand;
|
|
|
|
|
|
|
|
|
|
// // Set background image of button
|
|
|
|
|
// button.BackgroundImage = bitmap;
|
|
|
|
|
|
|
|
|
|
// // Calculate the graphics path based on the bitmap supplied
|
|
|
|
|
// GraphicsPath graphicsPath = CalculateControlGraphicsPath(bitmap, colorTransparent);
|
|
|
|
|
|
|
|
|
|
// // Apply new region
|
|
|
|
|
|
|
|
|
|
// button.Region = new Region(graphicsPath);
|
|
|
|
|
//}
|
|
|
|
|
|
2008-12-08 05:09:35 +00:00
|
|
|
private void frmCUERipper_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
2010-05-06 01:31:23 +00:00
|
|
|
//buttonTrackMetadata.Parent = listTracks;
|
|
|
|
|
//buttonTrackMetadata.ImageList = null;
|
|
|
|
|
//CreateControlRegion(buttonTrackMetadata, new Bitmap(imageListChecked.Images[0]), imageListChecked.TransparentColor);
|
|
|
|
|
//CreateControlRegion(buttonTrackMetadata, Properties.Resources.cdrepair, Color.White);
|
|
|
|
|
|
2009-05-01 15:16:26 +00:00
|
|
|
SettingsReader sr = new SettingsReader("CUERipper", "settings.txt", Application.ExecutablePath);
|
2010-02-28 21:04:34 +00:00
|
|
|
_config.Load(sr);
|
2013-04-17 21:36:46 -04:00
|
|
|
_config.CopyAlbumArt = false;
|
2010-02-28 21:04:34 +00:00
|
|
|
//_config.createEACLOG = sr.LoadBoolean("CreateEACLOG") ?? true;
|
|
|
|
|
//_config.preserveHTOA = sr.LoadBoolean("PreserveHTOA") ?? false;
|
|
|
|
|
//_config.createM3U = sr.LoadBoolean("CreateM3U") ?? true;
|
2010-03-20 07:09:07 +00:00
|
|
|
|
2013-02-24 19:10:39 -05:00
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (TextReader reader = new StringReader(sr.Load("CUERipper")))
|
|
|
|
|
cueRipperConfig = CUERipperConfig.serializer.Deserialize(reader) as CUERipperConfig;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
System.Diagnostics.Trace.WriteLine(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-15 00:10:05 -04:00
|
|
|
bindingSourceCR.DataSource = data;
|
|
|
|
|
initDone = true;
|
|
|
|
|
bnComboBoxDrives.ImageList = m_icon_mgr.ImageList;
|
|
|
|
|
bnComboBoxFormat.ImageList = m_icon_mgr.ImageList;
|
2013-02-24 19:10:39 -05:00
|
|
|
|
|
|
|
|
SetupControls();
|
2010-03-25 01:05:26 +00:00
|
|
|
|
2010-03-20 07:09:07 +00:00
|
|
|
int iFormat, nFormats = sr.LoadInt32("OutputPathUseTemplates", 0, 10) ?? 0;
|
2010-03-25 01:05:26 +00:00
|
|
|
for (iFormat = 0; iFormat < OutputPathUseTemplates.Length; iFormat++)
|
|
|
|
|
bnComboBoxOutputFormat.Items.Add(OutputPathUseTemplates[iFormat]);
|
|
|
|
|
for (iFormat = nFormats - 1; iFormat >= 0; iFormat--)
|
|
|
|
|
bnComboBoxOutputFormat.Items.Add(sr.Load(string.Format("OutputPathUseTemplate{0}", iFormat)) ?? "");
|
2010-03-20 07:09:07 +00:00
|
|
|
|
2010-03-25 01:05:26 +00:00
|
|
|
bnComboBoxOutputFormat.Text = sr.Load("PathFormat") ?? "%music%\\%artist%\\[%year% - ]%album%\\%artist% - %album%.cue";
|
2009-05-01 15:16:26 +00:00
|
|
|
SelectedOutputAudioType = (AudioEncoderType?)sr.LoadInt32("OutputAudioType", null, null) ?? AudioEncoderType.Lossless;
|
2010-03-22 06:36:42 +00:00
|
|
|
bnComboBoxImage.SelectedIndex = sr.LoadInt32("ComboImage", 0, bnComboBoxImage.Items.Count - 1) ?? 0;
|
2010-02-28 21:04:34 +00:00
|
|
|
trackBarSecureMode.Value = sr.LoadInt32("SecureMode", 0, trackBarSecureMode.Maximum - 1) ?? 1;
|
|
|
|
|
trackBarSecureMode_Scroll(this, new EventArgs());
|
2012-02-15 00:18:58 +00:00
|
|
|
this.checkBoxTestAndCopy.Checked = this.testAndCopy = sr.LoadBoolean("TestAndCopy") ?? this.testAndCopy;
|
2012-04-16 07:19:57 +00:00
|
|
|
|
|
|
|
|
Size SizeIncrement = new Size(sr.LoadInt32("WidthIncrement", 0, null) ?? 0, sr.LoadInt32("HeightIncrement", 0, null) ?? 0);
|
|
|
|
|
Size = MinimumSize + SizeIncrement;
|
|
|
|
|
Left -= SizeIncrement.Width / 2;
|
|
|
|
|
Top -= SizeIncrement.Height / 2;
|
2009-02-23 03:59:50 +00:00
|
|
|
UpdateDrives();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region private constants
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The window message of interest, device change
|
|
|
|
|
/// </summary>
|
|
|
|
|
const int WM_DEVICECHANGE = 0x0219;
|
|
|
|
|
const ushort DBT_DEVICEARRIVAL = 0x8000;
|
|
|
|
|
const ushort DBT_DEVICEREMOVECOMPLETE = 0x8004;
|
|
|
|
|
const ushort DBT_DEVNODES_CHANGED = 0x0007;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This method is called when a window message is processed by the dotnet application
|
|
|
|
|
/// framework. We override this method and look for the WM_DEVICECHANGE message. All
|
|
|
|
|
/// messages are delivered to the base class for processing, but if the WM_DEVICECHANGE
|
|
|
|
|
/// method is seen, we also alert any BWGBURN programs that the media in the drive may
|
|
|
|
|
/// have changed.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="m">the windows message being processed</param>
|
|
|
|
|
protected override void WndProc(ref Message m)
|
|
|
|
|
{
|
2010-03-20 07:09:07 +00:00
|
|
|
if (m.Msg == WM_DEVICECHANGE && _workThread == null)
|
2009-02-23 03:59:50 +00:00
|
|
|
{
|
|
|
|
|
int val = m.WParam.ToInt32();
|
|
|
|
|
if (val == DBT_DEVICEARRIVAL || val == DBT_DEVICEREMOVECOMPLETE)
|
|
|
|
|
UpdateDrive();
|
|
|
|
|
else if (val == DBT_DEVNODES_CHANGED)
|
2010-05-02 17:04:51 +00:00
|
|
|
{
|
|
|
|
|
if (_workThread == null)
|
|
|
|
|
UpdateDrives();
|
|
|
|
|
}
|
2009-02-23 03:59:50 +00:00
|
|
|
}
|
|
|
|
|
base.WndProc(ref m);
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-30 02:41:43 +00:00
|
|
|
private void DrivesLookup(object o)
|
2009-02-23 03:59:50 +00:00
|
|
|
{
|
2010-03-30 02:41:43 +00:00
|
|
|
// Lookup
|
2010-05-02 17:04:51 +00:00
|
|
|
data.Drives.RaiseListChangedEvents = false;
|
2010-02-28 21:04:34 +00:00
|
|
|
foreach (char drive in CDDrivesList.DrivesAvailable())
|
2008-12-08 05:09:35 +00:00
|
|
|
{
|
2010-06-11 17:54:37 +00:00
|
|
|
this.BeginInvoke((MethodInvoker)(() =>
|
|
|
|
|
toolStripStatusLabel1.Text = Properties.Resources.DetectingDrives + ": " + drive + ":\\..."));
|
|
|
|
|
ICDRipper reader = Activator.CreateInstance(CUEProcessorPlugins.ripper) as ICDRipper;
|
2009-01-17 04:09:38 +00:00
|
|
|
try
|
2008-12-10 06:48:38 +00:00
|
|
|
{
|
2009-01-17 04:09:38 +00:00
|
|
|
reader.Open(drive);
|
2009-02-23 03:59:50 +00:00
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2010-06-11 17:54:37 +00:00
|
|
|
System.Diagnostics.Trace.WriteLine(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
if (reader.ARName != null)
|
|
|
|
|
{
|
2013-02-24 19:10:39 -05:00
|
|
|
int driveOffset;
|
|
|
|
|
if (cueRipperConfig.DriveOffsets.ContainsKey(reader.ARName))
|
|
|
|
|
reader.DriveOffset = cueRipperConfig.DriveOffsets[reader.ARName];
|
|
|
|
|
else if (AccurateRipVerify.FindDriveReadOffset(reader.ARName, out driveOffset))
|
2010-06-11 17:54:37 +00:00
|
|
|
reader.DriveOffset = driveOffset;
|
|
|
|
|
else
|
|
|
|
|
reader.DriveOffset = 0;
|
2009-02-23 03:59:50 +00:00
|
|
|
}
|
2010-05-02 17:04:51 +00:00
|
|
|
data.Drives.Add(new DriveInfo(m_icon_mgr, drive + ":\\", reader));
|
2010-03-22 06:36:42 +00:00
|
|
|
}
|
2010-03-30 02:41:43 +00:00
|
|
|
this.BeginInvoke((MethodInvoker)delegate()
|
2010-03-22 06:36:42 +00:00
|
|
|
{
|
2010-05-02 17:04:51 +00:00
|
|
|
data.Drives.RaiseListChangedEvents = true;
|
|
|
|
|
data.Drives.ResetBindings();
|
|
|
|
|
for(int i = 0; i < bnComboBoxDrives.Items.Count; i++)
|
2013-02-24 19:10:39 -05:00
|
|
|
if ((bnComboBoxDrives.Items[i] as DriveInfo).Path == cueRipperConfig.DefaultDrive)
|
2010-05-02 17:04:51 +00:00
|
|
|
bnComboBoxDrives.SelectedIndex = i;
|
|
|
|
|
_workThread = null;
|
2010-03-30 02:41:43 +00:00
|
|
|
SetupControls();
|
2010-05-02 17:04:51 +00:00
|
|
|
if (data.Drives.Count == 0)
|
2010-03-30 02:41:43 +00:00
|
|
|
bnComboBoxDrives.Text = Properties.Resources.NoDrives;
|
2010-05-02 17:04:51 +00:00
|
|
|
else
|
|
|
|
|
UpdateDrive();
|
2010-03-30 02:41:43 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateDrives()
|
|
|
|
|
{
|
|
|
|
|
buttonGo.Enabled = false;
|
2010-05-02 17:04:51 +00:00
|
|
|
foreach (DriveInfo driveInfo in data.Drives)
|
2010-03-30 02:41:43 +00:00
|
|
|
if (driveInfo.drive != null)
|
|
|
|
|
driveInfo.drive.Close();
|
2010-05-02 17:04:51 +00:00
|
|
|
data.Drives.Clear();
|
2010-03-30 02:41:43 +00:00
|
|
|
listTracks.Items.Clear();
|
2010-05-02 17:04:51 +00:00
|
|
|
data.Releases.Clear();
|
2010-05-06 01:31:23 +00:00
|
|
|
data.selectedRelease = null;
|
2012-02-13 07:24:25 +00:00
|
|
|
ResetAlbumArt();
|
|
|
|
|
selectedDriveInfo = null;
|
2010-03-30 02:41:43 +00:00
|
|
|
bnComboBoxRelease.Text = "";
|
|
|
|
|
|
|
|
|
|
if (CUEProcessorPlugins.ripper == null)
|
|
|
|
|
{
|
|
|
|
|
bnComboBoxDrives.Text = Properties.Resources.FailedToLoadRipperModule;
|
|
|
|
|
return;
|
2008-12-08 05:09:35 +00:00
|
|
|
}
|
2010-03-30 02:41:43 +00:00
|
|
|
|
|
|
|
|
_workThread = new Thread(DrivesLookup);
|
|
|
|
|
_workThread.Priority = ThreadPriority.BelowNormal;
|
|
|
|
|
_workThread.IsBackground = true;
|
|
|
|
|
SetupControls();
|
|
|
|
|
_workThread.Start(this);
|
2008-12-08 05:09:35 +00:00
|
|
|
}
|
|
|
|
|
|
2010-03-20 07:09:07 +00:00
|
|
|
bool outputFormatVisible = false;
|
|
|
|
|
|
2010-05-06 01:31:23 +00:00
|
|
|
private void SetupControls()
|
2008-12-08 05:09:35 +00:00
|
|
|
{
|
|
|
|
|
bool running = _workThread != null;
|
2010-03-20 07:09:07 +00:00
|
|
|
|
2010-03-30 02:41:43 +00:00
|
|
|
bnComboBoxOutputFormat.Visible = outputFormatVisible;
|
2010-03-20 07:09:07 +00:00
|
|
|
txtOutputPath.Visible = !outputFormatVisible;
|
|
|
|
|
txtOutputPath.Enabled = !running && !outputFormatVisible;
|
2010-05-02 17:04:51 +00:00
|
|
|
bnComboBoxRelease.Enabled = !running && data.Releases.Count > 0;
|
|
|
|
|
bnComboBoxDrives.Enabled = !running && data.Drives.Count > 0;
|
2010-05-06 01:31:23 +00:00
|
|
|
bnComboBoxOutputFormat.Enabled =
|
2008-12-09 07:25:48 +00:00
|
|
|
listTracks.Enabled =
|
2010-05-06 01:31:23 +00:00
|
|
|
listMetadata.Enabled =
|
2009-05-01 15:16:26 +00:00
|
|
|
groupBoxSettings.Enabled = !running;
|
2010-05-06 01:31:23 +00:00
|
|
|
buttonGo.Enabled = !running && data.selectedRelease != null;
|
2008-12-08 05:09:35 +00:00
|
|
|
buttonPause.Visible = buttonPause.Enabled = buttonAbort.Visible = buttonAbort.Enabled = running;
|
2010-05-06 01:31:23 +00:00
|
|
|
buttonGo.Visible = !running;
|
2008-12-08 05:09:35 +00:00
|
|
|
toolStripStatusLabel1.Text = String.Empty;
|
|
|
|
|
toolStripProgressBar1.Value = 0;
|
2010-02-28 21:04:34 +00:00
|
|
|
progressBarErrors.Value = 0;
|
|
|
|
|
progressBarCD.Value = 0;
|
2010-05-06 01:31:23 +00:00
|
|
|
|
|
|
|
|
buttonTracks.Enabled = data.selectedRelease != null && !running;
|
|
|
|
|
buttonMetadata.Enabled = data.selectedRelease != null && !running;
|
2010-05-09 07:01:47 +00:00
|
|
|
buttonFreedbSubmit.Enabled = data.selectedRelease != null && !running;
|
2010-05-06 01:31:23 +00:00
|
|
|
buttonVA.Enabled = data.selectedRelease != null && !running &&
|
2010-05-09 07:01:47 +00:00
|
|
|
data.selectedRelease.ImageKey == "freedb" && !data.selectedRelease.metadata.IsVarious() && (new CUEMetadata(data.selectedRelease.metadata)).FreedbToVarious();
|
2010-05-06 01:31:23 +00:00
|
|
|
buttonEncoding.Enabled = data.selectedRelease != null && !running &&
|
|
|
|
|
data.selectedRelease.ImageKey == "freedb" && (new CUEMetadata(data.selectedRelease.metadata)).FreedbToEncoding();
|
|
|
|
|
buttonReload.Enabled = data.selectedRelease != null && !running;
|
2013-04-28 16:14:58 -04:00
|
|
|
buttonEjectDisk.Enabled = selectedDriveInfo !=null && !running;
|
2012-02-13 21:00:30 +00:00
|
|
|
buttonSettings.Enabled = !running;
|
2008-12-08 05:09:35 +00:00
|
|
|
}
|
|
|
|
|
|
2010-02-28 21:04:34 +00:00
|
|
|
private void CheckStop()
|
2008-12-08 05:09:35 +00:00
|
|
|
{
|
|
|
|
|
lock (_startStop)
|
|
|
|
|
{
|
|
|
|
|
if (_startStop._stop)
|
|
|
|
|
{
|
|
|
|
|
_startStop._stop = false;
|
|
|
|
|
_startStop._pause = false;
|
|
|
|
|
throw new StopException();
|
|
|
|
|
}
|
|
|
|
|
if (_startStop._pause)
|
|
|
|
|
{
|
2010-06-11 17:54:37 +00:00
|
|
|
this.BeginInvoke((MethodInvoker)(()=> toolStripStatusLabel1.Text = Properties.Resources.PausedMessage + "..."));
|
2008-12-08 05:09:35 +00:00
|
|
|
Monitor.Wait(_startStop);
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-02-13 07:24:25 +00:00
|
|
|
if (backgroundWorkerArtwork.IsBusy && backgroundWorkerArtwork.CancellationPending)
|
|
|
|
|
{
|
|
|
|
|
throw new StopException();
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-02-28 21:04:34 +00:00
|
|
|
|
|
|
|
|
private void UploadProgress(object sender, Krystalware.UploadHelper.UploadProgressEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CheckStop();
|
|
|
|
|
this.BeginInvoke((MethodInvoker)delegate()
|
|
|
|
|
{
|
|
|
|
|
toolStripStatusLabel1.Text = e.uri;
|
|
|
|
|
toolStripProgressBar1.Value = Math.Max(0, Math.Min(100, (int)(e.percent * 100)));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CDReadProgress(object sender, ReadProgressArgs e)
|
|
|
|
|
{
|
|
|
|
|
CheckStop();
|
|
|
|
|
|
|
|
|
|
ICDRipper audioSource = sender as ICDRipper;
|
2008-12-08 05:09:35 +00:00
|
|
|
int processed = e.Position - e.PassStart;
|
|
|
|
|
TimeSpan elapsed = DateTime.Now - e.PassTime;
|
|
|
|
|
double speed = elapsed.TotalSeconds > 0 ? processed / elapsed.TotalSeconds / 75 : 1.0;
|
|
|
|
|
|
|
|
|
|
double percentTrck = (double)(e.Position - e.PassStart) / (e.PassEnd - e.PassStart);
|
2010-03-30 02:41:43 +00:00
|
|
|
string retry = e.Pass > 0 ? " (" + Properties.Resources.Retry + " " + e.Pass.ToString() + ")" : "";
|
2010-03-20 07:09:07 +00:00
|
|
|
string status = (elapsed.TotalSeconds > 0 && e.Pass >= 0) ?
|
2010-03-30 02:41:43 +00:00
|
|
|
string.Format("{0} @{1:00.00}x{2}...", e.Action, speed, retry) :
|
|
|
|
|
string.Format("{0}{1}...", e.Action, retry);
|
2008-12-08 05:09:35 +00:00
|
|
|
this.BeginInvoke((MethodInvoker)delegate()
|
|
|
|
|
{
|
|
|
|
|
toolStripStatusLabel1.Text = status;
|
|
|
|
|
toolStripProgressBar1.Value = Math.Max(0, Math.Min(100, (int)(percentTrck * 100)));
|
2010-02-28 21:04:34 +00:00
|
|
|
|
2013-04-20 20:16:23 -04:00
|
|
|
progressBarErrors.Value = Math.Min(progressBarErrors.Maximum, (int)(100 * Math.Log(e.ErrorsCount / 10.0 + 1) / Math.Log((e.PassEnd - e.PassStart) / 10.0 + 1)));
|
2010-02-28 21:04:34 +00:00
|
|
|
progressBarErrors.Enabled = e.Pass >= audioSource.CorrectionQuality;
|
|
|
|
|
|
|
|
|
|
progressBarCD.Maximum = (int) audioSource.TOC.AudioLength;
|
|
|
|
|
progressBarCD.Value = Math.Max(0, Math.Min(progressBarCD.Maximum, (int)e.PassStart + (e.PassEnd - e.PassStart) * (Math.Min(e.Pass, audioSource.CorrectionQuality) + 1) / (audioSource.CorrectionQuality + 1)));
|
2008-12-08 05:09:35 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Rip(object o)
|
|
|
|
|
{
|
2010-02-28 21:04:34 +00:00
|
|
|
ICDRipper audioSource = o as ICDRipper;
|
2012-04-16 07:19:57 +00:00
|
|
|
|
2008-12-08 05:09:35 +00:00
|
|
|
audioSource.ReadProgress += new EventHandler<ReadProgressArgs>(CDReadProgress);
|
2009-05-01 15:16:26 +00:00
|
|
|
audioSource.DriveOffset = (int)numericWriteOffset.Value;
|
2008-12-08 05:09:35 +00:00
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2012-02-15 00:18:58 +00:00
|
|
|
if (this.testAndCopy)
|
|
|
|
|
cueSheet.TestBeforeCopy();
|
|
|
|
|
else
|
|
|
|
|
cueSheet.ArTestVerify = null;
|
|
|
|
|
|
|
|
|
|
cueSheet.Go();
|
2012-04-08 23:54:36 +00:00
|
|
|
cueSheet.CTDB.Submit(
|
2011-05-06 20:22:21 +00:00
|
|
|
(int)cueSheet.ArVerify.WorstConfidence() + 1,
|
|
|
|
|
audioSource.CorrectionQuality == 0 ? 0 :
|
2013-05-07 00:13:50 -04:00
|
|
|
(int)(100 * (1.0 - Math.Log(audioSource.FailedSectors.PopulationCount() + 1) / Math.Log(audioSource.TOC.AudioLength + 1))),
|
2011-06-11 19:26:25 +00:00
|
|
|
cueSheet.Metadata.Artist,
|
|
|
|
|
cueSheet.Metadata.Title,
|
|
|
|
|
cueSheet.TOC.Barcode);
|
2010-03-30 02:41:43 +00:00
|
|
|
bool canFix = false;
|
2013-05-07 00:13:50 -04:00
|
|
|
if (cueSheet.CTDB.QueryExceptionStatus == WebExceptionStatus.Success && audioSource.FailedSectors.PopulationCount() != 0)
|
2010-03-30 02:41:43 +00:00
|
|
|
{
|
|
|
|
|
foreach (DBEntry entry in cueSheet.CTDB.Entries)
|
|
|
|
|
if (entry.hasErrors && entry.canRecover)
|
|
|
|
|
canFix = true;
|
|
|
|
|
}
|
|
|
|
|
this.Invoke((MethodInvoker)delegate()
|
2013-05-07 00:13:50 -04:00
|
|
|
{
|
|
|
|
|
DialogResult dlgRes = audioSource.FailedSectors.PopulationCount() != 0 ?
|
2013-06-04 00:10:33 -04:00
|
|
|
MessageBox.Show(this, cueSheet.GenerateVerifyStatus() + (canFix ? "\n" + Properties.Resources.DoneRippingRepair : "") + ".", Properties.Resources.DoneRippingErrors, MessageBoxButtons.OK, MessageBoxIcon.Error) :
|
|
|
|
|
MessageBox.Show(this, cueSheet.GenerateVerifyStatus() + ".", Properties.Resources.DoneRipping, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2010-03-30 02:41:43 +00:00
|
|
|
});
|
2008-12-08 05:09:35 +00:00
|
|
|
}
|
|
|
|
|
catch (StopException)
|
|
|
|
|
{
|
|
|
|
|
}
|
2009-03-04 21:30:56 +00:00
|
|
|
#if !DEBUG
|
2008-12-08 05:09:35 +00:00
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
this.Invoke((MethodInvoker)delegate()
|
|
|
|
|
{
|
2010-03-30 02:41:43 +00:00
|
|
|
string message = Properties.Resources.ExceptionMessage;
|
2008-12-08 05:09:35 +00:00
|
|
|
for (Exception e = ex; e != null; e = e.InnerException)
|
|
|
|
|
message += ": " + e.Message;
|
2010-03-30 02:41:43 +00:00
|
|
|
DialogResult dlgRes = MessageBox.Show(this, message, Properties.Resources.ExceptionMessage, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2008-12-08 05:09:35 +00:00
|
|
|
});
|
|
|
|
|
}
|
2009-03-04 21:30:56 +00:00
|
|
|
#endif
|
2010-03-25 05:04:45 +00:00
|
|
|
|
2008-12-10 06:48:38 +00:00
|
|
|
audioSource.ReadProgress -= new EventHandler<ReadProgressArgs>(CDReadProgress);
|
2010-03-25 05:04:45 +00:00
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
audioSource.Close();
|
|
|
|
|
audioSource.Open(audioSource.Path[0]);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
this.BeginInvoke((MethodInvoker)delegate()
|
|
|
|
|
{
|
2010-05-02 17:04:51 +00:00
|
|
|
data.Releases.Clear();
|
2010-05-06 01:31:23 +00:00
|
|
|
data.selectedRelease = null;
|
2010-03-25 05:04:45 +00:00
|
|
|
bnComboBoxRelease.Text = ex.Message;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-08 05:09:35 +00:00
|
|
|
_workThread = null;
|
2008-12-08 11:18:15 +00:00
|
|
|
this.BeginInvoke((MethodInvoker)delegate()
|
|
|
|
|
{
|
|
|
|
|
SetupControls();
|
2012-04-16 07:19:57 +00:00
|
|
|
UpdateOutputPath();
|
2008-12-08 11:18:15 +00:00
|
|
|
});
|
2008-12-08 05:09:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonGo_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2010-03-25 01:05:26 +00:00
|
|
|
if (selectedDriveInfo == null)
|
2008-12-08 05:09:35 +00:00
|
|
|
return;
|
2008-12-10 06:48:38 +00:00
|
|
|
|
2010-03-25 01:05:26 +00:00
|
|
|
if (!bnComboBoxOutputFormat.Items.Contains(bnComboBoxOutputFormat.Text) && bnComboBoxOutputFormat.Text.Contains("%"))
|
|
|
|
|
{
|
|
|
|
|
bnComboBoxOutputFormat.Items.Insert(OutputPathUseTemplates.Length, bnComboBoxOutputFormat.Text);
|
|
|
|
|
if (bnComboBoxOutputFormat.Items.Count > OutputPathUseTemplates.Length + 10)
|
|
|
|
|
bnComboBoxOutputFormat.Items.RemoveAt(OutputPathUseTemplates.Length + 10);
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-28 12:35:07 -04:00
|
|
|
cueSheet.AlbumArt.Clear();
|
2013-04-21 13:40:34 -04:00
|
|
|
if (currentAlbumArt >= 0 && currentAlbumArt < albumArt.Count)
|
2012-02-13 07:24:25 +00:00
|
|
|
{
|
|
|
|
|
data.selectedRelease.metadata.AlbumArt.Clear();
|
|
|
|
|
data.selectedRelease.metadata.AlbumArt.Add(albumArt[currentAlbumArt].meta);
|
2013-04-28 12:35:07 -04:00
|
|
|
var blob = new TagLib.ByteVector(albumArt[currentAlbumArt].contents);
|
|
|
|
|
cueSheet.AlbumArt.Add(new TagLib.Picture(blob) { Type = TagLib.PictureType.FrontCover });
|
2012-02-13 07:24:25 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-06 01:31:23 +00:00
|
|
|
data.selectedRelease.metadata.Save();
|
2010-05-02 17:04:51 +00:00
|
|
|
|
2010-05-06 01:31:23 +00:00
|
|
|
cueSheet.CopyMetadata(data.selectedRelease.metadata);
|
2010-03-22 06:36:42 +00:00
|
|
|
cueSheet.OutputStyle = bnComboBoxImage.SelectedIndex == 0 ? CUEStyle.SingleFileWithCUE :
|
2008-12-10 06:48:38 +00:00
|
|
|
CUEStyle.GapsAppended;
|
2010-03-25 01:05:26 +00:00
|
|
|
_pathOut = cueSheet.GenerateUniqueOutputPath(bnComboBoxOutputFormat.Text,
|
|
|
|
|
cueSheet.OutputStyle == CUEStyle.SingleFileWithCUE ? "." + selectedFormat.ToString() : ".cue",
|
2009-08-08 16:14:06 +00:00
|
|
|
CUEAction.Encode, null);
|
|
|
|
|
if (_pathOut == "")
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(this, "Output path generation failed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2012-04-16 07:19:57 +00:00
|
|
|
if (cueSheet.Metadata.Comment == "")
|
|
|
|
|
cueSheet.Metadata.Comment = selectedDriveInfo.drive.RipperVersion;
|
|
|
|
|
cueSheet.GenerateFilenames(SelectedOutputAudioType, selectedFormat.ToString(), _pathOut);
|
2010-03-25 01:05:26 +00:00
|
|
|
selectedDriveInfo.drive.CorrectionQuality = trackBarSecureMode.Value;
|
2008-12-09 07:25:48 +00:00
|
|
|
|
2008-12-08 05:09:35 +00:00
|
|
|
_workThread = new Thread(Rip);
|
|
|
|
|
_workThread.Priority = ThreadPriority.BelowNormal;
|
|
|
|
|
_workThread.IsBackground = true;
|
|
|
|
|
SetupControls();
|
2012-04-16 07:19:57 +00:00
|
|
|
_workThread.Start(selectedDriveInfo.drive);
|
2008-12-08 05:09:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonAbort_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2008-12-10 06:48:38 +00:00
|
|
|
_startStop.Stop();
|
2008-12-08 05:09:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonPause_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2008-12-10 06:48:38 +00:00
|
|
|
_startStop.Pause();
|
2008-12-08 05:09:35 +00:00
|
|
|
}
|
|
|
|
|
|
2012-04-16 07:19:57 +00:00
|
|
|
private void ResizeList(ListView list, ColumnHeader title)
|
|
|
|
|
{
|
|
|
|
|
int colSum = 0;
|
|
|
|
|
foreach (ColumnHeader col in list.Columns)
|
|
|
|
|
{
|
|
|
|
|
colSum += col.Width + SystemInformation.BorderSize.Width;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
title.Width += list.Width - colSum - 2 * SystemInformation.BorderSize.Width - SystemInformation.VerticalScrollBarWidth;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-23 03:59:50 +00:00
|
|
|
private void UpdateRelease()
|
2008-12-08 05:09:35 +00:00
|
|
|
{
|
2010-05-06 01:31:23 +00:00
|
|
|
data.selectedRelease = bnComboBoxRelease.SelectedItem as CUEMetadataEntry;
|
2012-04-16 07:19:57 +00:00
|
|
|
UpdateOutputPath();
|
2010-05-06 01:31:23 +00:00
|
|
|
listTracks.BeginUpdate();
|
|
|
|
|
listMetadata.BeginUpdate();
|
|
|
|
|
listTracks.Items.Clear();
|
|
|
|
|
listMetadata.Items.Clear();
|
|
|
|
|
if (!data.metadataMode)
|
|
|
|
|
{
|
|
|
|
|
listTracks.Visible = true;
|
|
|
|
|
listMetadata.Visible = false;
|
|
|
|
|
if (data.selectedRelease != null)
|
2010-05-09 07:01:47 +00:00
|
|
|
{
|
2012-04-16 07:19:57 +00:00
|
|
|
columnHeaderArtist.Width = data.selectedRelease.metadata.IsVarious() ? 120 : 0;
|
2010-05-06 01:31:23 +00:00
|
|
|
for (int i = 1; i <= selectedDriveInfo.drive.TOC.TrackCount; i++)
|
|
|
|
|
{
|
2010-05-09 07:01:47 +00:00
|
|
|
string title = "Data track";
|
|
|
|
|
string artist = "";
|
|
|
|
|
if (selectedDriveInfo.drive.TOC[i].IsAudio)
|
|
|
|
|
{
|
2010-05-06 01:31:23 +00:00
|
|
|
title = data.selectedRelease.metadata.Tracks[i - selectedDriveInfo.drive.TOC.FirstAudio].Title;
|
2010-05-09 07:01:47 +00:00
|
|
|
artist = data.selectedRelease.metadata.Tracks[i - selectedDriveInfo.drive.TOC.FirstAudio].Artist;
|
|
|
|
|
}
|
2010-05-06 01:31:23 +00:00
|
|
|
listTracks.Items.Add(new ListViewItem(new string[] {
|
2010-05-09 07:01:47 +00:00
|
|
|
title,
|
|
|
|
|
selectedDriveInfo.drive.TOC[i].Number.ToString(),
|
|
|
|
|
artist,
|
|
|
|
|
selectedDriveInfo.drive.TOC[i].StartMSF,
|
|
|
|
|
selectedDriveInfo.drive.TOC[i].LengthMSF }));
|
2010-05-06 01:31:23 +00:00
|
|
|
}
|
2010-05-09 07:01:47 +00:00
|
|
|
}
|
2010-05-06 01:31:23 +00:00
|
|
|
}
|
2010-05-09 07:01:47 +00:00
|
|
|
else if (data.metadataTrack < 0)
|
2009-03-04 21:30:56 +00:00
|
|
|
{
|
2010-05-06 01:31:23 +00:00
|
|
|
listTracks.Visible = false;
|
|
|
|
|
listMetadata.Visible = true;
|
|
|
|
|
if (data.selectedRelease != null)
|
|
|
|
|
{
|
|
|
|
|
PropertyDescriptorCollection props = TypeDescriptor.GetProperties(data.selectedRelease.metadata);
|
2012-04-16 07:19:57 +00:00
|
|
|
PropertyDescriptorCollection sortedprops = props.Sort(new string[] { "Artist", "Title", "Genre", "Year", "DiscNumber", "TotalDiscs", "DiscName", "Label", "LabelNo", "Country", "ReleaseDate" });
|
2010-05-06 01:31:23 +00:00
|
|
|
foreach (PropertyDescriptor p in sortedprops)
|
2012-02-13 07:24:25 +00:00
|
|
|
if (p.Name != "Tracks" && p.Name != "AlbumArt" && p.Name != "Id" && !p.Attributes.Contains(new System.Xml.Serialization.XmlIgnoreAttribute()))
|
2010-05-06 01:31:23 +00:00
|
|
|
listMetadata.Items.Add(new ListViewItem(new string[] { p.GetValue(data.selectedRelease.metadata).ToString(), p.Name }));
|
|
|
|
|
}
|
2009-03-04 21:30:56 +00:00
|
|
|
}
|
2010-05-09 07:01:47 +00:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
listTracks.Visible = false;
|
|
|
|
|
listMetadata.Visible = true;
|
|
|
|
|
if (data.selectedRelease != null)
|
|
|
|
|
{
|
|
|
|
|
CUETrackMetadata track = data.selectedRelease.metadata.Tracks[data.metadataTrack];
|
|
|
|
|
PropertyDescriptorCollection props = TypeDescriptor.GetProperties(track);
|
|
|
|
|
props = props.Sort(new string[] { "ISRC", "Title", "Artist" });
|
|
|
|
|
ListViewItem lvItem = new ListViewItem(new string[] { (data.metadataTrack + 1).ToString(), "Number" });
|
|
|
|
|
lvItem.ForeColor = SystemColors.GrayText;
|
|
|
|
|
listMetadata.Items.Add(lvItem);
|
|
|
|
|
foreach (PropertyDescriptor p in props)
|
|
|
|
|
{
|
|
|
|
|
lvItem = new ListViewItem(new string[] { p.GetValue(track).ToString(), p.Name });
|
|
|
|
|
if (p.Name == "ISRC")
|
|
|
|
|
lvItem.ForeColor = SystemColors.GrayText;
|
|
|
|
|
listMetadata.Items.Add(lvItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-04-16 07:19:57 +00:00
|
|
|
ResizeList(listTracks, Title);
|
|
|
|
|
ResizeList(listMetadata, columnHeaderValue);
|
2010-05-06 01:31:23 +00:00
|
|
|
listTracks.EndUpdate();
|
|
|
|
|
listMetadata.EndUpdate();
|
2012-02-13 07:24:25 +00:00
|
|
|
|
2013-04-21 13:40:34 -04:00
|
|
|
SelectAlbumArt();
|
2010-05-06 01:31:23 +00:00
|
|
|
SetupControls();
|
2009-02-23 03:59:50 +00:00
|
|
|
}
|
|
|
|
|
|
2011-05-26 18:18:26 +00:00
|
|
|
//private void MusicBrainz_LookupProgress(object sender, XmlRequestEventArgs e)
|
|
|
|
|
//{
|
|
|
|
|
// CheckStop();
|
|
|
|
|
// //_progress.percentDisk = (1.0 + _progress.percentDisk) / 2;
|
|
|
|
|
// //_progress.input = e.Uri.ToString();
|
|
|
|
|
// this.BeginInvoke((MethodInvoker)delegate()
|
|
|
|
|
// {
|
|
|
|
|
// toolStripStatusLabel1.Text = Properties.Resources.LookingUpVia + " " + (e == null ? "FreeDB" : "MusicBrainz") + "...";
|
|
|
|
|
// toolStripProgressBar1.Value = (100 + 2 * toolStripProgressBar1.Value) / 3;
|
|
|
|
|
// });
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
private void FreeDB_LookupProgress(object sender)
|
2008-12-08 05:09:35 +00:00
|
|
|
{
|
2010-02-28 21:04:34 +00:00
|
|
|
CheckStop();
|
2008-12-08 05:09:35 +00:00
|
|
|
//_progress.percentDisk = (1.0 + _progress.percentDisk) / 2;
|
|
|
|
|
//_progress.input = e.Uri.ToString();
|
2012-02-13 21:00:30 +00:00
|
|
|
string text = Properties.Resources.LookingUpVia + " FreeDB..." + (sender is string ? " " + (sender as string) : "");
|
2008-12-08 05:09:35 +00:00
|
|
|
this.BeginInvoke((MethodInvoker)delegate()
|
|
|
|
|
{
|
2012-02-13 21:00:30 +00:00
|
|
|
toolStripStatusLabel1.Text = text;
|
2010-02-28 21:04:34 +00:00
|
|
|
toolStripProgressBar1.Value = (100 + 2 * toolStripProgressBar1.Value) / 3;
|
2008-12-08 05:09:35 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-15 17:41:14 +00:00
|
|
|
private CUEMetadataEntry CreateCUESheet(ICDRipper audioSource, CTDBResponseMeta release)
|
|
|
|
|
{
|
2011-06-26 00:02:29 +00:00
|
|
|
CUEMetadataEntry entry = new CUEMetadataEntry(audioSource.TOC, release.source);
|
2011-05-15 17:41:14 +00:00
|
|
|
entry.metadata.FillFromCtdb(release, entry.TOC.FirstAudio - 1);
|
|
|
|
|
return entry;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-26 18:18:26 +00:00
|
|
|
//private CUEMetadataEntry CreateCUESheet(ICDRipper audioSource, Release release)
|
|
|
|
|
//{
|
|
|
|
|
// CUEMetadataEntry entry = new CUEMetadataEntry(audioSource.TOC, "musicbrainz");
|
|
|
|
|
// entry.metadata.FillFromMusicBrainz(release, entry.TOC.FirstAudio - 1);
|
|
|
|
|
// return entry;
|
|
|
|
|
//}
|
2010-05-02 17:04:51 +00:00
|
|
|
|
|
|
|
|
private CUEMetadataEntry CreateCUESheet(ICDRipper audioSource, CDEntry cdEntry)
|
|
|
|
|
{
|
|
|
|
|
CUEMetadataEntry entry = new CUEMetadataEntry(audioSource.TOC, "freedb");
|
|
|
|
|
entry.metadata.FillFromFreedb(cdEntry, entry.TOC.FirstAudio - 1);
|
|
|
|
|
return entry;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private CUEMetadataEntry CreateCUESheet(ICDRipper audioSource)
|
|
|
|
|
{
|
|
|
|
|
CUEMetadataEntry entry = new CUEMetadataEntry(audioSource.TOC, "local");
|
|
|
|
|
entry.metadata.Artist = "Unknown Artist";
|
|
|
|
|
entry.metadata.Title = "Unknown Title";
|
|
|
|
|
for (int i = 0; i < entry.TOC.AudioTracks; i++)
|
2008-12-10 19:44:09 +00:00
|
|
|
{
|
2010-05-02 17:04:51 +00:00
|
|
|
entry.metadata.Tracks[i].Title = string.Format("Track {0:00}", i + 1);
|
|
|
|
|
entry.metadata.Tracks[i].Artist = entry.metadata.Artist;
|
2008-12-10 19:44:09 +00:00
|
|
|
}
|
2010-05-02 17:04:51 +00:00
|
|
|
return entry;
|
2008-12-10 19:44:09 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-02 17:04:51 +00:00
|
|
|
private bool loadAllMetadata = false;
|
|
|
|
|
|
2012-02-13 07:24:25 +00:00
|
|
|
private void Lookup(object o)
|
|
|
|
|
{
|
|
|
|
|
ICDRipper audioSource = o as ICDRipper;
|
|
|
|
|
int mbresults_count = 0; // have to cache results.Count, because it sometimes hangs in it, and we don't want UI thread to hang.
|
|
|
|
|
string musicbrainzError = "";
|
|
|
|
|
|
|
|
|
|
data.Releases.RaiseListChangedEvents = false;
|
|
|
|
|
|
|
|
|
|
cueSheet = new CUESheet(_config);
|
|
|
|
|
cueSheet.OpenCD(audioSource);
|
|
|
|
|
cueSheet.Action = CUEAction.Encode;
|
|
|
|
|
|
|
|
|
|
this.BeginInvoke((MethodInvoker)delegate() { toolStripStatusLabel1.Text = Properties.Resources.LookingUpVia + " CTDB..."; });
|
2012-02-13 21:00:30 +00:00
|
|
|
cueSheet.UseCUEToolsDB("CUERipper " + CUESheet.CUEToolsVersion, selectedDriveInfo.drive.ARName, false, loadAllMetadata ? CTDBMetadataSearch.Extensive : _config.advanced.metadataSearch);
|
2012-02-13 07:24:25 +00:00
|
|
|
cueSheet.CTDB.UploadHelper.onProgress += new EventHandler<Krystalware.UploadHelper.UploadProgressEventArgs>(UploadProgress);
|
|
|
|
|
this.BeginInvoke((MethodInvoker)delegate() { toolStripStatusLabel1.Text = Properties.Resources.LookingUpVia + " AccurateRip..."; });
|
|
|
|
|
cueSheet.UseAccurateRip();
|
|
|
|
|
|
|
|
|
|
General.SetCUELine(cueSheet.Attributes, "REM", "DISCID", AccurateRipVerify.CalculateCDDBId(audioSource.TOC), false);
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
CUEMetadata cache = CUEMetadata.Load(audioSource.TOC.TOCID);
|
|
|
|
|
if (cache != null)
|
|
|
|
|
data.Releases.Add(new CUEMetadataEntry(cache, audioSource.TOC, "local"));
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
System.Diagnostics.Trace.WriteLine(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var ctdbMeta in cueSheet.CTDB.Metadata)
|
|
|
|
|
{
|
|
|
|
|
data.Releases.Add(CreateCUESheet(audioSource, ctdbMeta));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (data.Releases.Count == 0 || loadAllMetadata)
|
|
|
|
|
{
|
|
|
|
|
loadAllMetadata = false;
|
|
|
|
|
|
|
|
|
|
//this.BeginInvoke((MethodInvoker)delegate() { toolStripStatusLabel1.Text = Properties.Resources.LookingUpVia + " MusicBrainz..."; });
|
|
|
|
|
|
|
|
|
|
//ReleaseQueryParameters p = new ReleaseQueryParameters();
|
|
|
|
|
//p.DiscId = audioSource.TOC.MusicBrainzId;
|
|
|
|
|
//Query<Release> results = Release.Query(p);
|
|
|
|
|
//MusicBrainzService.Proxy = _config.GetProxy();
|
|
|
|
|
//MusicBrainzService.XmlRequest += new EventHandler<XmlRequestEventArgs>(MusicBrainz_LookupProgress);
|
|
|
|
|
|
|
|
|
|
//try
|
|
|
|
|
//{
|
|
|
|
|
// foreach (Release release in results)
|
|
|
|
|
// {
|
|
|
|
|
// release.GetEvents();
|
|
|
|
|
// release.GetTracks();
|
|
|
|
|
// data.Releases.Add(CreateCUESheet(audioSource, release));
|
|
|
|
|
// }
|
|
|
|
|
// mbresults_count = results.Count;
|
|
|
|
|
//}
|
|
|
|
|
//catch (Exception ex)
|
|
|
|
|
//{
|
|
|
|
|
// System.Diagnostics.Trace.WriteLine(ex.Message);
|
|
|
|
|
// if (!(ex is MusicBrainzNotFoundException))
|
|
|
|
|
// musicbrainzError = ex.Message;
|
|
|
|
|
//}
|
|
|
|
|
//MusicBrainzService.Proxy = null;
|
|
|
|
|
//MusicBrainzService.XmlRequest -= new EventHandler<XmlRequestEventArgs>(MusicBrainz_LookupProgress);
|
|
|
|
|
|
|
|
|
|
this.BeginInvoke((MethodInvoker)delegate() { toolStripStatusLabel1.Text = Properties.Resources.LookingUpVia + " Freedb..."; });
|
|
|
|
|
|
|
|
|
|
FreedbHelper m_freedb = new FreedbHelper();
|
|
|
|
|
m_freedb.Proxy = _config.GetProxy();
|
|
|
|
|
m_freedb.UserName = _config.advanced.FreedbUser;
|
|
|
|
|
m_freedb.Hostname = _config.advanced.FreedbDomain;
|
|
|
|
|
m_freedb.ClientName = "CUERipper";
|
|
|
|
|
m_freedb.Version = CUESheet.CUEToolsVersion;
|
|
|
|
|
m_freedb.SetDefaultSiteAddress(Properties.Settings.Default.MAIN_FREEDB_SITEADDRESS);
|
|
|
|
|
|
|
|
|
|
QueryResult queryResult;
|
|
|
|
|
QueryResultCollection coll;
|
|
|
|
|
string code = string.Empty;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
FreeDB_LookupProgress(this);
|
|
|
|
|
code = m_freedb.Query(AccurateRipVerify.CalculateCDDBQuery(audioSource.TOC), out queryResult, out coll);
|
|
|
|
|
if (code == FreedbHelper.ResponseCodes.CODE_200)
|
|
|
|
|
{
|
2012-02-13 21:00:30 +00:00
|
|
|
bool duplicate = false;
|
|
|
|
|
foreach (var ctdbMeta in cueSheet.CTDB.Metadata)
|
|
|
|
|
if (ctdbMeta.source == "freedb" && ctdbMeta.id == queryResult.Category + "/" + queryResult.Discid)
|
|
|
|
|
duplicate = true;
|
|
|
|
|
if (!duplicate)
|
2012-02-13 07:24:25 +00:00
|
|
|
{
|
2012-02-13 21:00:30 +00:00
|
|
|
FreeDB_LookupProgress(queryResult.Category + "/" + queryResult.Discid);
|
|
|
|
|
CDEntry cdEntry;
|
|
|
|
|
code = m_freedb.Read(queryResult, out cdEntry);
|
|
|
|
|
if (code == FreedbHelper.ResponseCodes.CODE_210)
|
|
|
|
|
{
|
|
|
|
|
CUEMetadataEntry r = CreateCUESheet(audioSource, cdEntry);
|
|
|
|
|
data.Releases.Add(r);
|
|
|
|
|
}
|
2012-02-13 07:24:25 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (code == FreedbHelper.ResponseCodes.CODE_210 ||
|
|
|
|
|
code == FreedbHelper.ResponseCodes.CODE_211)
|
|
|
|
|
{
|
|
|
|
|
foreach (QueryResult qr in coll)
|
|
|
|
|
{
|
2012-02-13 21:00:30 +00:00
|
|
|
bool duplicate = false;
|
|
|
|
|
foreach (var ctdbMeta in cueSheet.CTDB.Metadata)
|
|
|
|
|
if (ctdbMeta.source == "freedb" && ctdbMeta.id == qr.Category + "/" + qr.Discid)
|
|
|
|
|
duplicate = true;
|
|
|
|
|
if (!duplicate)
|
2012-02-13 07:24:25 +00:00
|
|
|
{
|
2012-02-13 21:00:30 +00:00
|
|
|
CDEntry cdEntry;
|
|
|
|
|
FreeDB_LookupProgress(qr.Category + "/" + qr.Discid);
|
|
|
|
|
code = m_freedb.Read(qr, out cdEntry);
|
|
|
|
|
if (code == FreedbHelper.ResponseCodes.CODE_210)
|
|
|
|
|
{
|
|
|
|
|
CUEMetadataEntry r = CreateCUESheet(audioSource, cdEntry);
|
|
|
|
|
data.Releases.Add(r);
|
|
|
|
|
}
|
2012-02-13 07:24:25 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
System.Diagnostics.Trace.WriteLine(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (data.Releases.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
data.Releases.Add(CreateCUESheet(audioSource));
|
|
|
|
|
}
|
|
|
|
|
_workThread = null;
|
|
|
|
|
if (musicbrainzError != "")
|
|
|
|
|
musicbrainzError = musicbrainzError + ": ";
|
|
|
|
|
while (backgroundWorkerArtwork.IsBusy)
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(100);
|
|
|
|
|
}
|
|
|
|
|
this.BeginInvoke((MethodInvoker)delegate()
|
|
|
|
|
{
|
|
|
|
|
SetupControls();
|
|
|
|
|
data.Releases.RaiseListChangedEvents = true;
|
|
|
|
|
data.Releases.ResetBindings();
|
|
|
|
|
//bnComboBoxRelease.SelectedIndex = 0;
|
|
|
|
|
toolStripStatusAr.Enabled = cueSheet.ArVerify.ARStatus == null;
|
|
|
|
|
toolStripStatusAr.Text = cueSheet.ArVerify.ARStatus == null ? cueSheet.ArVerify.WorstTotal().ToString() : "";
|
|
|
|
|
toolStripStatusAr.ToolTipText = "AccurateRip: " + (cueSheet.ArVerify.ARStatus ?? "found") + ".";
|
|
|
|
|
toolStripStatusCTDB.Enabled = cueSheet.CTDB.DBStatus == null;
|
|
|
|
|
toolStripStatusCTDB.Text = cueSheet.CTDB.DBStatus == null ? cueSheet.CTDB.Total.ToString() : "";
|
|
|
|
|
toolStripStatusCTDB.ToolTipText = "CUETools DB: " + (cueSheet.CTDB.DBStatus ?? "found") + ".";
|
|
|
|
|
toolStripStatusLabelMusicBrainz.Enabled = true;
|
|
|
|
|
toolStripStatusLabelMusicBrainz.BorderStyle = mbresults_count > 0 ? Border3DStyle.SunkenInner : Border3DStyle.RaisedInner;
|
|
|
|
|
toolStripStatusLabelMusicBrainz.Text = mbresults_count > 0 ? mbresults_count.ToString() : "";
|
|
|
|
|
toolStripStatusLabelMusicBrainz.ToolTipText = "Musicbrainz: " + (mbresults_count > 0 ? mbresults_count.ToString() + " entries found." : (musicbrainzError + "click to submit."));
|
2012-02-13 21:00:30 +00:00
|
|
|
if (_config.advanced.coversSearch != CUEConfigAdvanced.CTDBCoversSearch.None)
|
|
|
|
|
backgroundWorkerArtwork.RunWorkerAsync(new BackgroundWorkerArtworkArgs() { cueSheet = cueSheet, meta = data.selectedRelease });
|
2012-02-13 07:24:25 +00:00
|
|
|
});
|
|
|
|
|
}
|
2008-12-08 05:09:35 +00:00
|
|
|
|
2009-02-23 03:59:50 +00:00
|
|
|
private void UpdateDrive()
|
2008-12-08 05:09:35 +00:00
|
|
|
{
|
2010-05-02 17:04:51 +00:00
|
|
|
if (bnComboBoxDrives.SelectedItem as DriveInfo == null)
|
2010-03-22 06:36:42 +00:00
|
|
|
return;
|
|
|
|
|
|
2010-06-11 17:54:37 +00:00
|
|
|
if (selectedDriveInfo != null)
|
|
|
|
|
selectedDriveInfo.drive.Close();
|
|
|
|
|
|
2010-05-02 17:04:51 +00:00
|
|
|
selectedDriveInfo = bnComboBoxDrives.SelectedItem as DriveInfo;
|
2013-02-24 19:10:39 -05:00
|
|
|
cueRipperConfig.DefaultDrive = selectedDriveInfo.Path;
|
2010-05-02 17:04:51 +00:00
|
|
|
|
2010-03-30 02:41:43 +00:00
|
|
|
toolStripStatusAr.Enabled = false;
|
|
|
|
|
toolStripStatusAr.Text = "";
|
|
|
|
|
toolStripStatusAr.ToolTipText = "";
|
|
|
|
|
toolStripStatusCTDB.Enabled = false;
|
|
|
|
|
toolStripStatusCTDB.Text = "";
|
|
|
|
|
toolStripStatusCTDB.ToolTipText = "";
|
|
|
|
|
toolStripStatusLabelMusicBrainz.Enabled = false;
|
|
|
|
|
toolStripStatusLabelMusicBrainz.Text = "";
|
|
|
|
|
toolStripStatusLabelMusicBrainz.ToolTipText = "";
|
2008-12-08 05:09:35 +00:00
|
|
|
listTracks.Items.Clear();
|
2010-05-02 17:04:51 +00:00
|
|
|
data.Releases.Clear();
|
2010-05-06 01:31:23 +00:00
|
|
|
data.selectedRelease = null;
|
2012-02-13 07:24:25 +00:00
|
|
|
ResetAlbumArt();
|
|
|
|
|
bnComboBoxRelease.Enabled = false;
|
2010-03-22 06:36:42 +00:00
|
|
|
bnComboBoxRelease.Text = "";
|
2010-06-11 17:54:37 +00:00
|
|
|
if (selectedDriveInfo == null)
|
2009-02-23 03:59:50 +00:00
|
|
|
{
|
2010-05-06 01:31:23 +00:00
|
|
|
SetupControls();
|
2008-12-08 05:09:35 +00:00
|
|
|
return;
|
2009-02-23 03:59:50 +00:00
|
|
|
}
|
2010-03-20 07:09:07 +00:00
|
|
|
if (cueSheet != null)
|
|
|
|
|
{
|
|
|
|
|
cueSheet.Close();
|
|
|
|
|
cueSheet = null;
|
|
|
|
|
}
|
2013-02-24 19:10:39 -05:00
|
|
|
|
|
|
|
|
numericWriteOffset.Value = selectedDriveInfo.drive.DriveOffset;
|
2009-01-17 04:09:38 +00:00
|
|
|
try
|
|
|
|
|
{
|
2010-03-25 01:05:26 +00:00
|
|
|
selectedDriveInfo.drive.Open(selectedDriveInfo.drive.Path[0]);
|
2009-01-17 04:09:38 +00:00
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2010-06-11 17:54:37 +00:00
|
|
|
selectedDriveInfo.drive.Close();
|
2010-03-22 06:36:42 +00:00
|
|
|
bnComboBoxRelease.Text = ex.Message;
|
2010-06-11 17:54:37 +00:00
|
|
|
SetupControls();
|
2008-12-08 05:09:35 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2010-06-11 17:54:37 +00:00
|
|
|
// cannot use data.Drives.ResetItem(bnComboBoxDrives.SelectedIndex); - causes recursion
|
2009-02-23 03:59:50 +00:00
|
|
|
UpdateRelease();
|
2008-12-08 05:09:35 +00:00
|
|
|
_workThread = new Thread(Lookup);
|
|
|
|
|
_workThread.Priority = ThreadPriority.BelowNormal;
|
|
|
|
|
_workThread.IsBackground = true;
|
|
|
|
|
SetupControls();
|
2010-03-25 01:05:26 +00:00
|
|
|
_workThread.Start(selectedDriveInfo.drive);
|
2008-12-08 05:09:35 +00:00
|
|
|
}
|
2008-12-08 11:18:15 +00:00
|
|
|
|
|
|
|
|
private void listTracks_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.KeyCode == Keys.F2)
|
|
|
|
|
{
|
|
|
|
|
listTracks.FocusedItem.BeginEdit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listTracks_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.KeyCode == Keys.Enter)
|
|
|
|
|
{
|
2012-02-15 00:18:58 +00:00
|
|
|
if (listTracks.FocusedItem != null && listTracks.FocusedItem.Index + 1 < listTracks.Items.Count)// && e.Label != null)
|
2008-12-08 11:18:15 +00:00
|
|
|
{
|
|
|
|
|
listTracks.FocusedItem.Selected = false;
|
|
|
|
|
listTracks.FocusedItem = listTracks.Items[listTracks.FocusedItem.Index + 1];
|
|
|
|
|
listTracks.FocusedItem.Selected = true;
|
|
|
|
|
listTracks.FocusedItem.BeginEdit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-08 05:09:35 +00:00
|
|
|
|
2008-12-10 06:48:38 +00:00
|
|
|
private void listTracks_AfterLabelEdit(object sender, LabelEditEventArgs e)
|
|
|
|
|
{
|
2010-05-06 01:31:23 +00:00
|
|
|
if (data.selectedRelease == null) return;
|
2010-03-25 01:05:26 +00:00
|
|
|
if (e.Label != null && selectedDriveInfo.drive.TOC[e.Item + 1].IsAudio)
|
2010-05-06 01:31:23 +00:00
|
|
|
data.selectedRelease.metadata.Tracks[e.Item].Title = e.Label;
|
2009-03-04 21:30:56 +00:00
|
|
|
else
|
|
|
|
|
e.CancelEdit = true;
|
2008-12-10 06:48:38 +00:00
|
|
|
}
|
|
|
|
|
|
2009-03-04 21:30:56 +00:00
|
|
|
private void frmCUERipper_FormClosed(object sender, FormClosedEventArgs e)
|
|
|
|
|
{
|
2009-05-01 15:16:26 +00:00
|
|
|
SettingsWriter sw = new SettingsWriter("CUERipper", "settings.txt", Application.ExecutablePath);
|
2010-02-28 21:04:34 +00:00
|
|
|
_config.Save(sw);
|
|
|
|
|
//sw.Save("CreateEACLOG", _config.createEACLOG);
|
|
|
|
|
//sw.Save("PreserveHTOA", _config.preserveHTOA);
|
|
|
|
|
//sw.Save("CreateM3U", _config.createM3U);
|
2009-05-01 15:16:26 +00:00
|
|
|
sw.Save("OutputAudioType", (int)SelectedOutputAudioType);
|
2010-03-22 06:36:42 +00:00
|
|
|
sw.Save("ComboImage", bnComboBoxImage.SelectedIndex);
|
2010-03-30 02:41:43 +00:00
|
|
|
sw.Save("PathFormat", bnComboBoxOutputFormat.Text);
|
2010-02-28 21:04:34 +00:00
|
|
|
sw.Save("SecureMode", trackBarSecureMode.Value);
|
2010-03-30 02:41:43 +00:00
|
|
|
sw.Save("OutputPathUseTemplates", bnComboBoxOutputFormat.Items.Count - OutputPathUseTemplates.Length);
|
2012-02-15 00:18:58 +00:00
|
|
|
sw.Save("TestAndCopy", this.testAndCopy);
|
2012-04-16 07:19:57 +00:00
|
|
|
var SizeIncrement = Size - MinimumSize;
|
|
|
|
|
sw.Save("WidthIncrement", SizeIncrement.Width);
|
|
|
|
|
sw.Save("HeightIncrement", SizeIncrement.Height);
|
|
|
|
|
for (int iFormat = bnComboBoxOutputFormat.Items.Count - 1; iFormat >= OutputPathUseTemplates.Length; iFormat--)
|
2010-03-30 02:41:43 +00:00
|
|
|
sw.Save(string.Format("OutputPathUseTemplate{0}", iFormat - OutputPathUseTemplates.Length), bnComboBoxOutputFormat.Items[iFormat].ToString());
|
2010-03-20 07:09:07 +00:00
|
|
|
|
2013-02-24 19:10:39 -05:00
|
|
|
using (TextWriter tw = new StringWriter())
|
|
|
|
|
using (XmlWriter xw = XmlTextWriter.Create(tw, xmlEmptySettings))
|
|
|
|
|
{
|
|
|
|
|
CUERipperConfig.serializer.Serialize(xw, cueRipperConfig, xmlEmptyNamespaces);
|
|
|
|
|
sw.SaveText("CUERipper", tw.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-04 21:30:56 +00:00
|
|
|
sw.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listTracks_BeforeLabelEdit(object sender, LabelEditEventArgs e)
|
|
|
|
|
{
|
2010-03-25 01:05:26 +00:00
|
|
|
if (!selectedDriveInfo.drive.TOC[e.Item + 1].IsAudio)
|
2009-03-04 21:30:56 +00:00
|
|
|
e.CancelEdit = true;
|
|
|
|
|
}
|
2009-05-01 15:16:26 +00:00
|
|
|
|
|
|
|
|
private string SelectedOutputAudioFormat
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2010-03-22 06:36:42 +00:00
|
|
|
return selectedFormat == null ? "dummy" : selectedFormat.ToString();
|
2009-05-01 15:16:26 +00:00
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
2013-02-24 19:31:04 -05:00
|
|
|
foreach (CUEToolsFormat fmt in data.Formats)
|
2010-03-22 06:36:42 +00:00
|
|
|
if (fmt.ToString() == value)
|
|
|
|
|
bnComboBoxFormat.SelectedItem = fmt;
|
2009-05-01 15:16:26 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private CUEToolsFormat SelectedOutputAudioFmt
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2013-02-24 19:31:04 -05:00
|
|
|
return selectedFormat;
|
2009-05-01 15:16:26 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private AudioEncoderType SelectedOutputAudioType
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2010-05-02 17:04:51 +00:00
|
|
|
return (bnComboBoxLosslessOrNot.SelectedItem as ImgComboBoxItem<AudioEncoderType>).Value;
|
2009-05-01 15:16:26 +00:00
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
2010-05-02 17:04:51 +00:00
|
|
|
foreach (ImgComboBoxItem<AudioEncoderType> item in data.LosslessOrNot)
|
2010-03-30 02:41:43 +00:00
|
|
|
if (value == item.Value)
|
|
|
|
|
{
|
|
|
|
|
bnComboBoxLosslessOrNot.SelectedItem = item;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
throw new Exception("invalid value");
|
2009-05-01 15:16:26 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-08 22:26:42 -04:00
|
|
|
private void resetEncoderModes(CUEToolsUDC encoder)
|
|
|
|
|
{
|
2013-04-10 22:21:19 -04:00
|
|
|
encoder.settings.PCM = AudioPCMConfig.RedBook;
|
|
|
|
|
buttonEncoderSettings.Enabled = encoder.settings.HasBrowsableAttributes();
|
2013-04-08 22:26:42 -04:00
|
|
|
string[] modes = encoder.SupportedModes;
|
|
|
|
|
if (modes == null || modes.Length < 2)
|
|
|
|
|
{
|
|
|
|
|
trackBarEncoderMode.Visible = false;
|
|
|
|
|
labelEncoderMode.Visible = false;
|
|
|
|
|
labelEncoderMinMode.Visible = false;
|
|
|
|
|
labelEncoderMaxMode.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-04-10 22:21:19 -04:00
|
|
|
if (encoder.EncoderModeIndex == -1)
|
2013-04-08 23:11:03 -04:00
|
|
|
{
|
|
|
|
|
string defaultMode;
|
|
|
|
|
encoder.settings.GetSupportedModes(out defaultMode);
|
2013-04-09 20:51:13 -04:00
|
|
|
encoder.settings.EncoderMode = defaultMode;
|
2013-04-08 23:11:03 -04:00
|
|
|
}
|
2013-04-08 22:26:42 -04:00
|
|
|
trackBarEncoderMode.Maximum = modes.Length - 1;
|
2013-04-08 23:11:03 -04:00
|
|
|
trackBarEncoderMode.Value = encoder.EncoderModeIndex == -1 ? modes.Length - 1 : encoder.EncoderModeIndex;
|
2013-04-09 20:51:13 -04:00
|
|
|
labelEncoderMode.Text = encoder.settings.EncoderMode;
|
2013-04-08 22:26:42 -04:00
|
|
|
labelEncoderMinMode.Text = modes[0];
|
|
|
|
|
labelEncoderMaxMode.Text = modes[modes.Length - 1];
|
|
|
|
|
trackBarEncoderMode.Visible = true;
|
|
|
|
|
labelEncoderMode.Visible = true;
|
|
|
|
|
labelEncoderMinMode.Visible = true;
|
|
|
|
|
labelEncoderMaxMode.Visible = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-02 17:04:51 +00:00
|
|
|
private void bnComboBoxEncoder_SelectedValueChanged(object sender, EventArgs e)
|
2009-05-01 15:16:26 +00:00
|
|
|
{
|
|
|
|
|
if (SelectedOutputAudioFormat == null)
|
|
|
|
|
return;
|
2010-03-22 06:36:42 +00:00
|
|
|
CUEToolsUDC encoder = bnComboBoxEncoder.SelectedItem as CUEToolsUDC;
|
|
|
|
|
if (encoder == null)
|
|
|
|
|
return;
|
2013-02-24 19:31:04 -05:00
|
|
|
if (SelectedOutputAudioType == AudioEncoderType.Lossless)
|
2009-08-06 13:03:02 +00:00
|
|
|
SelectedOutputAudioFmt.encoderLossless = encoder;
|
2009-05-01 15:16:26 +00:00
|
|
|
else
|
2009-08-06 13:03:02 +00:00
|
|
|
SelectedOutputAudioFmt.encoderLossy = encoder;
|
2013-04-08 22:26:42 -04:00
|
|
|
resetEncoderModes(encoder);
|
2010-02-28 21:04:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void trackBarEncoderMode_Scroll(object sender, EventArgs e)
|
|
|
|
|
{
|
2010-03-22 06:36:42 +00:00
|
|
|
CUEToolsUDC encoder = bnComboBoxEncoder.SelectedItem as CUEToolsUDC;
|
2010-02-28 21:04:34 +00:00
|
|
|
string[] modes = encoder.SupportedModes;
|
2013-04-09 20:51:13 -04:00
|
|
|
encoder.settings.EncoderMode = modes[trackBarEncoderMode.Value];
|
|
|
|
|
labelEncoderMode.Text = encoder.settings.EncoderMode;
|
2010-02-28 21:04:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void trackBarSecureMode_Scroll(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string[] modes = new string[] { "Burst", "Secure", "Paranoid" };
|
|
|
|
|
labelSecureMode.Text = modes[trackBarSecureMode.Value];
|
2009-05-01 15:16:26 +00:00
|
|
|
}
|
2010-03-20 07:09:07 +00:00
|
|
|
|
|
|
|
|
private void toolStripStatusLabelMusicBrainz_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2010-03-25 01:05:26 +00:00
|
|
|
if (selectedDriveInfo == null)
|
2010-03-20 07:09:07 +00:00
|
|
|
return;
|
2010-03-25 01:05:26 +00:00
|
|
|
System.Diagnostics.Process.Start("http://musicbrainz.org/bare/cdlookup.html?toc=" + selectedDriveInfo.drive.TOC.MusicBrainzTOC);
|
2010-03-20 07:09:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void frmCUERipper_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (_workThread == null && e.KeyCode == Keys.F5)
|
2010-05-02 17:04:51 +00:00
|
|
|
{
|
|
|
|
|
loadAllMetadata = true;
|
2010-03-30 02:41:43 +00:00
|
|
|
UpdateDrives();
|
2010-05-02 17:04:51 +00:00
|
|
|
}
|
2010-03-20 07:09:07 +00:00
|
|
|
}
|
|
|
|
|
|
2012-04-16 07:19:57 +00:00
|
|
|
private void UpdateOutputPath()
|
2010-03-20 07:09:07 +00:00
|
|
|
{
|
2010-03-22 06:36:42 +00:00
|
|
|
if (selectedFormat == null) return;
|
2010-05-06 01:31:23 +00:00
|
|
|
if (data.selectedRelease == null)
|
2010-05-02 17:04:51 +00:00
|
|
|
{
|
|
|
|
|
txtOutputPath.Text = "";
|
|
|
|
|
return;
|
|
|
|
|
}
|
2010-03-22 06:36:42 +00:00
|
|
|
CUEStyle style = bnComboBoxImage.SelectedIndex == 0 ? CUEStyle.SingleFileWithCUE : CUEStyle.GapsAppended;
|
2010-05-02 17:04:51 +00:00
|
|
|
CUESheet sheet = new CUESheet(_config);
|
|
|
|
|
sheet.TOC = selectedDriveInfo.drive.TOC;
|
2010-05-06 01:31:23 +00:00
|
|
|
sheet.CopyMetadata(data.selectedRelease.metadata);
|
2010-05-02 17:04:51 +00:00
|
|
|
txtOutputPath.Text = sheet.GenerateUniqueOutputPath(bnComboBoxOutputFormat.Text,
|
2010-03-22 06:36:42 +00:00
|
|
|
style == CUEStyle.SingleFileWithCUE ? "." + selectedFormat.ToString() : ".cue", CUEAction.Encode, null);
|
2010-03-20 07:09:07 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-02 17:04:51 +00:00
|
|
|
private void bnComboBoxRelease_SelectedValueChanged(object sender, EventArgs e)
|
2010-03-22 06:36:42 +00:00
|
|
|
{
|
|
|
|
|
UpdateRelease();
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-11 17:54:37 +00:00
|
|
|
private void bnComboBoxDrives_SelectedIndexChanged(object sender, EventArgs e)
|
2010-03-22 06:36:42 +00:00
|
|
|
{
|
|
|
|
|
if (_workThread == null)
|
|
|
|
|
UpdateDrive();
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-24 19:31:04 -05:00
|
|
|
private CUEToolsFormat selectedFormat;
|
2010-03-22 06:36:42 +00:00
|
|
|
|
2010-05-02 17:04:51 +00:00
|
|
|
private void bnComboBoxFormat_SelectedValueChanged(object sender, EventArgs e)
|
2010-03-22 06:36:42 +00:00
|
|
|
{
|
2013-02-24 19:31:04 -05:00
|
|
|
selectedFormat = bnComboBoxFormat.SelectedItem as CUEToolsFormat;
|
2010-03-22 06:36:42 +00:00
|
|
|
|
2010-05-02 17:04:51 +00:00
|
|
|
data.Encoders.Clear();
|
2010-03-22 06:36:42 +00:00
|
|
|
if (SelectedOutputAudioFmt == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2013-04-15 00:10:05 -04:00
|
|
|
if (initDone)
|
|
|
|
|
{
|
|
|
|
|
switch (SelectedOutputAudioType)
|
|
|
|
|
{
|
|
|
|
|
case AudioEncoderType.Lossless:
|
|
|
|
|
cueRipperConfig.DefaultLosslessFormat = SelectedOutputAudioFormat;
|
|
|
|
|
break;
|
|
|
|
|
case AudioEncoderType.Lossy:
|
|
|
|
|
cueRipperConfig.DefaultLossyFormat = SelectedOutputAudioFormat;
|
|
|
|
|
break;
|
|
|
|
|
case AudioEncoderType.Hybrid:
|
|
|
|
|
cueRipperConfig.DefaultHybridFormat = SelectedOutputAudioFormat;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-03-22 06:36:42 +00:00
|
|
|
|
2010-05-02 17:04:51 +00:00
|
|
|
data.Encoders.RaiseListChangedEvents = false;
|
2010-03-22 06:36:42 +00:00
|
|
|
|
|
|
|
|
foreach (CUEToolsUDC encoder in _config.encoders)
|
|
|
|
|
if (encoder.extension == SelectedOutputAudioFmt.extension)
|
|
|
|
|
{
|
2010-03-25 01:05:26 +00:00
|
|
|
if (SelectedOutputAudioType == AudioEncoderType.Lossless && !encoder.lossless)
|
2010-03-22 06:36:42 +00:00
|
|
|
continue;
|
2013-02-24 19:31:04 -05:00
|
|
|
if (SelectedOutputAudioType == AudioEncoderType.Lossy && encoder.lossless)
|
2010-03-22 06:36:42 +00:00
|
|
|
continue;
|
2010-05-02 17:04:51 +00:00
|
|
|
data.Encoders.Add(encoder);
|
2010-03-22 06:36:42 +00:00
|
|
|
}
|
|
|
|
|
|
2013-02-24 19:31:04 -05:00
|
|
|
CUEToolsUDC select = SelectedOutputAudioType == AudioEncoderType.Lossless ? SelectedOutputAudioFmt.encoderLossless
|
2010-03-22 06:36:42 +00:00
|
|
|
: SelectedOutputAudioFmt.encoderLossy;
|
2010-05-02 17:04:51 +00:00
|
|
|
data.Encoders.RaiseListChangedEvents = true;
|
|
|
|
|
data.Encoders.ResetBindings();
|
2010-03-22 06:36:42 +00:00
|
|
|
bnComboBoxEncoder.SelectedItem = select;
|
|
|
|
|
|
2012-04-16 07:19:57 +00:00
|
|
|
UpdateOutputPath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void bnComboBoxImage_SelectedValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UpdateOutputPath();
|
2010-03-22 06:36:42 +00:00
|
|
|
}
|
2010-03-22 07:02:47 +00:00
|
|
|
|
2010-05-02 17:04:51 +00:00
|
|
|
private void bnComboBoxLosslessOrNot_SelectedValueChanged(object sender, EventArgs e)
|
2010-03-22 07:02:47 +00:00
|
|
|
{
|
|
|
|
|
if (bnComboBoxLosslessOrNot.SelectedItem == null) return;
|
2010-05-02 17:04:51 +00:00
|
|
|
data.Formats.Clear();
|
|
|
|
|
data.Formats.RaiseListChangedEvents = false;
|
2010-03-22 07:02:47 +00:00
|
|
|
foreach (KeyValuePair<string, CUEToolsFormat> format in _config.formats)
|
|
|
|
|
{
|
|
|
|
|
if (SelectedOutputAudioType == AudioEncoderType.Lossless && !format.Value.allowLossless)
|
|
|
|
|
continue;
|
|
|
|
|
if (SelectedOutputAudioType == AudioEncoderType.Hybrid) // && format.Key != "wv") TODO!!!!!
|
|
|
|
|
continue;
|
|
|
|
|
if (SelectedOutputAudioType == AudioEncoderType.Lossy && !format.Value.allowLossy)
|
|
|
|
|
continue;
|
2013-02-24 19:31:04 -05:00
|
|
|
data.Formats.Add(format.Value);
|
2010-03-22 07:02:47 +00:00
|
|
|
}
|
|
|
|
|
string select = null;
|
|
|
|
|
switch (SelectedOutputAudioType)
|
|
|
|
|
{
|
|
|
|
|
case AudioEncoderType.Lossless:
|
2013-02-24 19:10:39 -05:00
|
|
|
select = cueRipperConfig.DefaultLosslessFormat;
|
2010-03-22 07:02:47 +00:00
|
|
|
break;
|
|
|
|
|
case AudioEncoderType.Lossy:
|
2013-02-24 19:10:39 -05:00
|
|
|
select = cueRipperConfig.DefaultLossyFormat;
|
2010-03-22 07:02:47 +00:00
|
|
|
break;
|
|
|
|
|
case AudioEncoderType.Hybrid:
|
2013-02-24 19:10:39 -05:00
|
|
|
select = cueRipperConfig.DefaultHybridFormat;
|
2010-03-22 07:02:47 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2010-05-02 17:04:51 +00:00
|
|
|
data.Formats.RaiseListChangedEvents = true;
|
|
|
|
|
data.Formats.ResetBindings();
|
2010-03-22 07:02:47 +00:00
|
|
|
SelectedOutputAudioFormat = select;
|
|
|
|
|
}
|
2010-03-25 01:05:26 +00:00
|
|
|
|
|
|
|
|
private void bnComboBoxOutputFormat_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2012-04-16 07:19:57 +00:00
|
|
|
UpdateOutputPath();
|
2010-03-25 01:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
2010-03-30 02:41:43 +00:00
|
|
|
private void txtOutputPath_Enter(object sender, EventArgs e)
|
2010-03-25 01:05:26 +00:00
|
|
|
{
|
2010-03-30 02:41:43 +00:00
|
|
|
if (outputFormatVisible)
|
2010-03-25 01:05:26 +00:00
|
|
|
return;
|
2010-05-09 07:01:47 +00:00
|
|
|
txtOutputPath.Enabled = false;
|
|
|
|
|
txtOutputPath.Visible = false;
|
2010-03-30 02:41:43 +00:00
|
|
|
outputFormatVisible = true;
|
|
|
|
|
bnComboBoxOutputFormat.Visible = true;
|
|
|
|
|
bnComboBoxOutputFormat.Focus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void bnComboBoxOutputFormat_MouseLeave(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//if (!outputFormatVisible)
|
|
|
|
|
// return;
|
|
|
|
|
//outputFormatVisible = false;
|
|
|
|
|
//bnComboBoxOutputFormat.Visible = false;
|
|
|
|
|
//txtOutputPath.Enabled = true;
|
|
|
|
|
//txtOutputPath.Visible = true;
|
2010-03-25 01:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void bnComboBoxOutputFormat_DroppedDown(object sender, EventArgs e)
|
|
|
|
|
{
|
2010-05-09 07:01:47 +00:00
|
|
|
if (!outputFormatVisible || bnComboBoxOutputFormat.DroppedDown || ActiveControl == bnComboBoxOutputFormat)
|
2010-03-25 01:05:26 +00:00
|
|
|
return;
|
|
|
|
|
outputFormatVisible = false;
|
|
|
|
|
bnComboBoxOutputFormat.Visible = false;
|
|
|
|
|
txtOutputPath.Enabled = true;
|
|
|
|
|
txtOutputPath.Visible = true;
|
|
|
|
|
}
|
2010-03-30 02:41:43 +00:00
|
|
|
|
|
|
|
|
private void bnComboBoxOutputFormat_Leave(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bnComboBoxOutputFormat_DroppedDown(sender, e);
|
|
|
|
|
}
|
2010-05-06 01:31:23 +00:00
|
|
|
|
|
|
|
|
private void listMetadata_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
listMetadata.FocusedItem.BeginEdit();
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-09 07:01:47 +00:00
|
|
|
private void listMetadata_BeforeLabelEdit(object sender, LabelEditEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (data.selectedRelease == null || !data.metadataMode)
|
|
|
|
|
{
|
|
|
|
|
e.CancelEdit = true;
|
|
|
|
|
}
|
|
|
|
|
else if (data.metadataTrack < 0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (listMetadata.Items[e.Item].SubItems[1].Text == "ISRC" ||
|
|
|
|
|
listMetadata.Items[e.Item].SubItems[1].Text == "Number")
|
|
|
|
|
{
|
|
|
|
|
e.CancelEdit = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-06 01:31:23 +00:00
|
|
|
private void listMetadata_AfterLabelEdit(object sender, LabelEditEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (data.selectedRelease == null || e.Label == null || !data.metadataMode)
|
|
|
|
|
{
|
|
|
|
|
e.CancelEdit = true;
|
|
|
|
|
}
|
2010-05-09 07:01:47 +00:00
|
|
|
else if (data.metadataTrack < 0)
|
2010-05-06 01:31:23 +00:00
|
|
|
{
|
|
|
|
|
PropertyDescriptorCollection props = TypeDescriptor.GetProperties(data.selectedRelease.metadata);
|
|
|
|
|
PropertyDescriptor prop = props[listMetadata.Items[e.Item].SubItems[1].Text];
|
|
|
|
|
if (prop.Name == "Artist")
|
|
|
|
|
data.selectedRelease.metadata.UpdateArtist(e.Label);
|
|
|
|
|
else
|
|
|
|
|
prop.SetValue(data.selectedRelease.metadata, e.Label);
|
|
|
|
|
data.Releases.ResetItem(bnComboBoxRelease.SelectedIndex);
|
|
|
|
|
}
|
2010-05-09 07:01:47 +00:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CUETrackMetadata track = data.selectedRelease.metadata.Tracks[data.metadataTrack];
|
|
|
|
|
PropertyDescriptorCollection props = TypeDescriptor.GetProperties(track);
|
|
|
|
|
props[listMetadata.Items[e.Item].SubItems[1].Text].SetValue(track, e.Label);
|
|
|
|
|
//data.Tracks.ResetItem(data.metadataTrack);
|
|
|
|
|
}
|
2010-05-06 01:31:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonMetadata_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
buttonTracks.Visible = true;
|
|
|
|
|
buttonTracks.Focus();
|
|
|
|
|
buttonMetadata.Visible = false;
|
2010-05-09 07:01:47 +00:00
|
|
|
data.metadataTrack = -1;
|
2010-05-06 01:31:23 +00:00
|
|
|
data.metadataMode = true;
|
|
|
|
|
UpdateRelease();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonTracks_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
buttonMetadata.Visible = true;
|
|
|
|
|
buttonMetadata.Focus();
|
|
|
|
|
buttonTracks.Visible = false;
|
|
|
|
|
data.metadataMode = false;
|
|
|
|
|
UpdateRelease();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonReload_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
loadAllMetadata = true;
|
|
|
|
|
data.Releases.Clear();
|
|
|
|
|
data.selectedRelease = null;
|
2012-02-13 07:24:25 +00:00
|
|
|
ResetAlbumArt();
|
|
|
|
|
UpdateRelease();
|
2010-05-06 01:31:23 +00:00
|
|
|
_workThread = new Thread(Lookup);
|
|
|
|
|
_workThread.Priority = ThreadPriority.BelowNormal;
|
|
|
|
|
_workThread.IsBackground = true;
|
|
|
|
|
SetupControls();
|
|
|
|
|
_workThread.Start(selectedDriveInfo.drive);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonVA_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (data.selectedRelease == null) return;
|
|
|
|
|
data.selectedRelease.metadata.FreedbToVarious();
|
|
|
|
|
UpdateRelease();
|
|
|
|
|
data.Releases.ResetItem(bnComboBoxRelease.SelectedIndex);
|
|
|
|
|
SetupControls();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonEncoding_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (data.selectedRelease == null) return;
|
|
|
|
|
data.selectedRelease.metadata.FreedbToEncoding();
|
|
|
|
|
UpdateRelease();
|
|
|
|
|
data.Releases.ResetItem(bnComboBoxRelease.SelectedIndex);
|
2012-04-16 07:19:57 +00:00
|
|
|
UpdateOutputPath();
|
2010-05-06 01:31:23 +00:00
|
|
|
SetupControls();
|
|
|
|
|
}
|
2010-05-09 07:01:47 +00:00
|
|
|
|
|
|
|
|
private void listTracks_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Point p = listTracks.PointToClient(MousePosition);
|
|
|
|
|
ListViewItem lvItem = listTracks.GetItemAt(p.X, p.Y);
|
|
|
|
|
if (lvItem != null)
|
|
|
|
|
{
|
|
|
|
|
ListViewItem.ListViewSubItem a = lvItem.GetSubItemAt(p.X, p.Y);
|
|
|
|
|
if (a != null)
|
|
|
|
|
{
|
|
|
|
|
int track = lvItem.Index + 1 - selectedDriveInfo.drive.TOC.FirstAudio;
|
|
|
|
|
if (a == lvItem.SubItems[0])
|
|
|
|
|
lvItem.BeginEdit();
|
2012-04-08 23:54:36 +00:00
|
|
|
else if (/*a == lvItem.SubItems[2] &&*/ track >= 0 && track < selectedDriveInfo.drive.TOC.AudioTracks)
|
2010-05-09 07:01:47 +00:00
|
|
|
{
|
|
|
|
|
buttonTracks.Visible = true;
|
|
|
|
|
buttonTracks.Focus();
|
|
|
|
|
buttonMetadata.Visible = false;
|
|
|
|
|
data.metadataTrack = track;
|
|
|
|
|
data.metadataMode = true;
|
|
|
|
|
UpdateRelease();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FreedbSubmit(object o)
|
|
|
|
|
{
|
|
|
|
|
StringCollection tmp = new StringCollection();
|
|
|
|
|
tmp.Add("DTITLE=");
|
|
|
|
|
CDEntry entry = new CDEntry(tmp);
|
|
|
|
|
entry.Artist = data.selectedRelease.metadata.Artist;
|
|
|
|
|
entry.Title = data.selectedRelease.metadata.Title;
|
|
|
|
|
entry.Year = data.selectedRelease.metadata.Year;
|
|
|
|
|
entry.Genre = data.selectedRelease.metadata.Genre;
|
|
|
|
|
int i = 1;
|
2012-04-08 23:54:36 +00:00
|
|
|
for (i = 1; i <= selectedDriveInfo.drive.TOC.TrackCount; i++)
|
|
|
|
|
{
|
|
|
|
|
Freedb.Track tt = new Freedb.Track();
|
|
|
|
|
if (i >= selectedDriveInfo.drive.TOC.FirstAudio && i < selectedDriveInfo.drive.TOC.FirstAudio + selectedDriveInfo.drive.TOC.AudioTracks)
|
|
|
|
|
{
|
|
|
|
|
CUETrackMetadata t = data.selectedRelease.metadata.Tracks[i - selectedDriveInfo.drive.TOC.FirstAudio];
|
|
|
|
|
if (t.Artist != "" && t.Artist != entry.Artist)
|
|
|
|
|
tt.Title = t.Artist + " / " + t.Title;
|
|
|
|
|
else
|
|
|
|
|
tt.Title = t.Title;
|
|
|
|
|
} else
|
|
|
|
|
tt.Title = "Data track";
|
|
|
|
|
tt.FrameOffset = 150 + (int)selectedDriveInfo.drive.TOC[i].Start;
|
|
|
|
|
entry.Tracks.Add(tt);
|
|
|
|
|
}
|
2010-05-09 07:01:47 +00:00
|
|
|
|
|
|
|
|
FreedbHelper m_freedb = new FreedbHelper();
|
|
|
|
|
|
|
|
|
|
frmFreedbSubmit frm = new frmFreedbSubmit();
|
|
|
|
|
foreach (string c in m_freedb.ValidCategories)
|
|
|
|
|
frm.Data.Categories.Add(c);
|
|
|
|
|
frm.Data.User = _config.advanced.FreedbUser;
|
|
|
|
|
frm.Data.Domain = _config.advanced.FreedbDomain;
|
|
|
|
|
frm.Data.Category = "misc";
|
|
|
|
|
|
|
|
|
|
DialogResult dlgRes = DialogResult.Cancel;
|
|
|
|
|
this.Invoke((MethodInvoker)delegate() { dlgRes = frm.ShowDialog(); });
|
|
|
|
|
if (dlgRes == DialogResult.Cancel)
|
|
|
|
|
{
|
|
|
|
|
_workThread = null;
|
|
|
|
|
this.BeginInvoke((MethodInvoker)delegate() { SetupControls(); });
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data.selectedRelease.metadata.Save();
|
|
|
|
|
|
|
|
|
|
_config.advanced.FreedbUser = frm.Data.User;
|
|
|
|
|
_config.advanced.FreedbDomain = frm.Data.Domain;
|
|
|
|
|
|
|
|
|
|
m_freedb.Proxy = _config.GetProxy();
|
|
|
|
|
m_freedb.UserName = _config.advanced.FreedbUser;
|
|
|
|
|
m_freedb.Hostname = _config.advanced.FreedbDomain;
|
|
|
|
|
m_freedb.ClientName = "CUERipper";
|
2010-05-18 17:18:37 +00:00
|
|
|
m_freedb.Version = CUESheet.CUEToolsVersion;
|
2010-05-09 07:01:47 +00:00
|
|
|
//try
|
|
|
|
|
//{
|
|
|
|
|
// string code = m_freedb.GetCategories(out tmp);
|
|
|
|
|
// if (code == FreedbHelper.ResponseCodes.CODE_210)
|
|
|
|
|
// m_freedb.ValidCategories = tmp;
|
|
|
|
|
//}
|
|
|
|
|
//catch
|
|
|
|
|
//{
|
|
|
|
|
//}
|
2011-07-10 16:56:57 +00:00
|
|
|
uint length = selectedDriveInfo.drive.TOC.Length / 75 + 2;
|
2010-05-09 07:01:47 +00:00
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string res = m_freedb.Submit(entry, (int)length, AccurateRipVerify.CalculateCDDBId(selectedDriveInfo.drive.TOC), frm.Data.Category, false);
|
|
|
|
|
this.BeginInvoke((MethodInvoker)delegate()
|
|
|
|
|
{
|
|
|
|
|
dlgRes = MessageBox.Show(this, res, "Submit result", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
this.BeginInvoke((MethodInvoker)delegate()
|
|
|
|
|
{
|
|
|
|
|
dlgRes = MessageBox.Show(this, ex.Message, "Submit result", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
_workThread = null;
|
|
|
|
|
this.BeginInvoke((MethodInvoker)delegate() { SetupControls(); });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonFreedbSubmit_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
_workThread = new Thread(FreedbSubmit);
|
|
|
|
|
_workThread.Priority = ThreadPriority.BelowNormal;
|
|
|
|
|
_workThread.IsBackground = true;
|
|
|
|
|
SetupControls();
|
|
|
|
|
_workThread.Start();
|
|
|
|
|
}
|
2012-02-13 07:24:25 +00:00
|
|
|
|
|
|
|
|
List<AlbumArt> albumArt = new List<AlbumArt>();
|
2018-02-19 12:31:02 -05:00
|
|
|
int currentAlbumArt = 0;//, frontAlbumArt = -1;
|
2012-02-13 07:24:25 +00:00
|
|
|
|
|
|
|
|
private void ResetAlbumArt()
|
|
|
|
|
{
|
|
|
|
|
if (this.cueSheet != null)
|
|
|
|
|
{
|
|
|
|
|
this.cueSheet.CTDB.CancelRequest();
|
|
|
|
|
}
|
|
|
|
|
lock (albumArt)
|
|
|
|
|
{
|
|
|
|
|
if (backgroundWorkerArtwork.IsBusy)
|
|
|
|
|
backgroundWorkerArtwork.CancelAsync();
|
|
|
|
|
albumArt.Clear();
|
|
|
|
|
}
|
2013-04-21 13:40:34 -04:00
|
|
|
currentAlbumArt = 0;
|
|
|
|
|
resetPictureBox(null);
|
2012-02-13 07:24:25 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-21 13:40:34 -04:00
|
|
|
private void SelectAlbumArt()
|
2012-02-13 07:24:25 +00:00
|
|
|
{
|
2013-04-21 13:40:34 -04:00
|
|
|
if (data.selectedRelease != null && data.selectedRelease.metadata.AlbumArt.Count > 0)
|
2012-02-13 07:24:25 +00:00
|
|
|
{
|
|
|
|
|
for (int i = 0; i < albumArt.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
foreach (var aa in data.selectedRelease.metadata.AlbumArt)
|
|
|
|
|
{
|
|
|
|
|
if (aa.uri == albumArt[i].meta.uri)
|
|
|
|
|
{
|
|
|
|
|
currentAlbumArt = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-21 12:59:46 -04:00
|
|
|
resetPictureBox(null);
|
2012-02-13 07:24:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void backgroundWorkerArtwork_DoWork(object sender, DoWorkEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var args = e.Argument as BackgroundWorkerArtworkArgs;
|
|
|
|
|
var cueSheet = args.cueSheet;
|
|
|
|
|
albumArt.Clear();
|
|
|
|
|
currentAlbumArt = 0;
|
2018-02-19 12:31:02 -05:00
|
|
|
//frontAlbumArt = -1;
|
2012-02-13 07:24:25 +00:00
|
|
|
var knownUrls = new List<string>();
|
|
|
|
|
var firstUrls = new List<string>();
|
|
|
|
|
|
|
|
|
|
if (args.meta != null && args.meta.metadata.AlbumArt.Count > 0)
|
|
|
|
|
foreach (var aa in args.meta.metadata.AlbumArt)
|
|
|
|
|
firstUrls.Add(aa.uri);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
|
|
{
|
|
|
|
|
foreach (var metadata in cueSheet.CTDB.Metadata)
|
|
|
|
|
{
|
|
|
|
|
if (metadata.coverart == null)
|
|
|
|
|
continue;
|
|
|
|
|
foreach (var coverart in metadata.coverart)
|
|
|
|
|
{
|
2012-02-13 21:00:30 +00:00
|
|
|
var uri = _config.advanced.coversSearch == CUEConfigAdvanced.CTDBCoversSearch.Large ?
|
2012-02-13 07:24:25 +00:00
|
|
|
coverart.uri : coverart.uri150 ?? coverart.uri;
|
|
|
|
|
if (knownUrls.Contains(uri) || !coverart.primary)
|
|
|
|
|
continue;
|
|
|
|
|
if (i == 0 && !firstUrls.Contains(coverart.uri))
|
|
|
|
|
continue;
|
|
|
|
|
var ms = new MemoryStream();
|
|
|
|
|
if (!cueSheet.CTDB.FetchFile(uri, ms))
|
|
|
|
|
continue;
|
|
|
|
|
lock (this.albumArt)
|
|
|
|
|
{
|
|
|
|
|
if (backgroundWorkerArtwork.CancellationPending)
|
|
|
|
|
{
|
|
|
|
|
e.Cancel = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.albumArt.Add(new AlbumArt(coverart, ms.ToArray()));
|
|
|
|
|
}
|
|
|
|
|
knownUrls.Add(uri);
|
|
|
|
|
backgroundWorkerArtwork.ReportProgress(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void backgroundWorkerArtwork_ProgressChanged(object sender, ProgressChangedEventArgs e)
|
|
|
|
|
{
|
2013-04-21 13:40:34 -04:00
|
|
|
SelectAlbumArt();
|
2012-02-13 07:24:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void backgroundWorkerArtwork_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
toolStripStatusLabel1.Text = "";
|
|
|
|
|
toolStripProgressBar1.Value = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-13 21:00:30 +00:00
|
|
|
private void buttonSettings_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2013-04-08 22:26:42 -04:00
|
|
|
var form = new Options(new CUERipperSettings(this._config));
|
2012-02-13 21:00:30 +00:00
|
|
|
form.ShowDialog(this);
|
|
|
|
|
}
|
2012-02-15 00:18:58 +00:00
|
|
|
|
|
|
|
|
private void checkBoxTestAndCopy_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.testAndCopy = checkBoxTestAndCopy.Checked;
|
|
|
|
|
}
|
2012-04-16 07:19:57 +00:00
|
|
|
|
|
|
|
|
private void frmCUERipper_ClientSizeChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ResizeList(listTracks, Title);
|
|
|
|
|
ResizeList(listMetadata, columnHeaderValue);
|
|
|
|
|
}
|
2013-02-24 19:10:39 -05:00
|
|
|
|
|
|
|
|
private void numericWriteOffset_ValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (selectedDriveInfo != null && selectedDriveInfo.drive.ARName != null)
|
|
|
|
|
{
|
|
|
|
|
cueRipperConfig.DriveOffsets[selectedDriveInfo.drive.ARName] = (int)numericWriteOffset.Value;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-04-08 22:26:42 -04:00
|
|
|
|
|
|
|
|
private void buttonEncoderSettings_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CUEToolsUDC encoder = bnComboBoxEncoder.SelectedItem as CUEToolsUDC;
|
|
|
|
|
if (encoder == null)
|
|
|
|
|
return;
|
|
|
|
|
var form = new Options(encoder.settings);
|
2013-04-18 21:33:08 -04:00
|
|
|
form.propertyGrid1.HelpVisible = true;
|
2013-04-08 22:26:42 -04:00
|
|
|
form.ShowDialog(this);
|
|
|
|
|
resetEncoderModes(encoder);
|
|
|
|
|
}
|
2013-04-21 00:48:48 -04:00
|
|
|
|
|
|
|
|
private static Bitmap cropImage(Image imgToResize, Size boxSize, RectangleF srcRect)
|
|
|
|
|
{
|
|
|
|
|
Bitmap b = new Bitmap(boxSize.Width, boxSize.Height);
|
|
|
|
|
//area.Width / 2 - area.X, area.Height /2 - area.Y, area.Width, area.Height
|
|
|
|
|
Graphics g = Graphics.FromImage((Image)b);
|
|
|
|
|
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
|
|
|
|
|
g.DrawImage(imgToResize, new Rectangle(0, 0, boxSize.Width, boxSize.Height), srcRect, GraphicsUnit.Pixel);
|
|
|
|
|
g.Dispose();
|
|
|
|
|
return b;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-21 12:59:46 -04:00
|
|
|
private void resetPictureBox(MouseEventArgs e)
|
2013-04-21 00:48:48 -04:00
|
|
|
{
|
2013-04-21 12:59:46 -04:00
|
|
|
if (currentAlbumArt < 0 || currentAlbumArt >= albumArt.Count)
|
2013-04-21 13:40:34 -04:00
|
|
|
{
|
|
|
|
|
pictureBox1.Image = null;
|
|
|
|
|
toolStripStatusLabel1.Text = "";
|
2013-04-21 00:48:48 -04:00
|
|
|
return;
|
2013-04-21 13:40:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
toolStripStatusLabel1.Text = albumArt[currentAlbumArt].meta.uri;
|
2013-04-21 00:48:48 -04:00
|
|
|
|
2013-04-21 12:59:46 -04:00
|
|
|
if (e == null || e.Button != System.Windows.Forms.MouseButtons.Right || _config.advanced.coversSearch != CUEConfigAdvanced.CTDBCoversSearch.Large)
|
|
|
|
|
{
|
|
|
|
|
pictureBox1.Image = albumArt[currentAlbumArt].image;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-21 00:48:48 -04:00
|
|
|
var isz = new RectangleF(0.0f, 0.0f, albumArt[currentAlbumArt].image.Width, albumArt[currentAlbumArt].image.Height);
|
2013-04-21 12:59:46 -04:00
|
|
|
//float ratio = Math.Min(isz.Width / pictureBox1.ClientSize.Width, isz.Height / pictureBox1.ClientSize.Height);
|
|
|
|
|
//ratio = Math.Min(ratio, 1.0f);
|
|
|
|
|
float ratio = 1.0f;
|
2013-04-21 00:48:48 -04:00
|
|
|
var rf = new RectangleF(
|
2013-04-21 13:50:58 -04:00
|
|
|
Math.Min(pictureBox1.ClientSize.Width, Math.Max(0, e.Location.X)) * (isz.Width / pictureBox1.ClientSize.Width - ratio),
|
|
|
|
|
Math.Min(pictureBox1.ClientSize.Height, Math.Max(0, e.Location.Y)) * (isz.Height / pictureBox1.ClientSize.Height - ratio),
|
2013-04-21 00:48:48 -04:00
|
|
|
pictureBox1.ClientSize.Width * ratio,
|
|
|
|
|
pictureBox1.ClientSize.Height * ratio);
|
|
|
|
|
pictureBox1.Image = cropImage(albumArt[currentAlbumArt].image, pictureBox1.ClientSize, rf);
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-21 13:40:34 -04:00
|
|
|
private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button == System.Windows.Forms.MouseButtons.Left)
|
|
|
|
|
{
|
|
|
|
|
if (++currentAlbumArt > albumArt.Count)
|
|
|
|
|
currentAlbumArt = 0;
|
|
|
|
|
resetPictureBox(null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-21 12:59:46 -04:00
|
|
|
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
|
2013-04-21 00:48:48 -04:00
|
|
|
{
|
2013-04-21 12:59:46 -04:00
|
|
|
if (e.Button == System.Windows.Forms.MouseButtons.Right)
|
|
|
|
|
resetPictureBox(e);
|
2013-04-21 13:40:34 -04:00
|
|
|
if (currentAlbumArt < 0 || currentAlbumArt >= albumArt.Count)
|
|
|
|
|
{
|
|
|
|
|
toolStripStatusLabel1.Text = "";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
toolStripStatusLabel1.Text = albumArt[currentAlbumArt].meta.uri;
|
2013-04-21 12:59:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2013-04-21 13:40:34 -04:00
|
|
|
if (e.Button == System.Windows.Forms.MouseButtons.Right)
|
|
|
|
|
resetPictureBox(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void pictureBox1_MouseLeave(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
toolStripStatusLabel1.Text = null;
|
2013-04-21 00:48:48 -04:00
|
|
|
}
|
2013-04-28 16:14:58 -04:00
|
|
|
|
|
|
|
|
private void buttonEjectDisk_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (selectedDriveInfo != null)
|
|
|
|
|
selectedDriveInfo.drive.EjectDisk();
|
|
|
|
|
}
|
2008-12-08 05:09:35 +00:00
|
|
|
}
|
|
|
|
|
|
2012-02-13 07:24:25 +00:00
|
|
|
internal class BackgroundWorkerArtworkArgs
|
|
|
|
|
{
|
|
|
|
|
public CUESheet cueSheet;
|
|
|
|
|
public CUEMetadataEntry meta;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal class AlbumArt
|
|
|
|
|
{
|
|
|
|
|
public CTDBResponseMetaImage meta;
|
|
|
|
|
|
|
|
|
|
public byte[] contents;
|
|
|
|
|
|
|
|
|
|
public Image image;
|
|
|
|
|
|
|
|
|
|
public AlbumArt(CTDBResponseMetaImage meta, byte[] contents)
|
|
|
|
|
{
|
|
|
|
|
this.meta = meta;
|
|
|
|
|
this.contents = contents;
|
|
|
|
|
using (MemoryStream imageStream = new MemoryStream(contents))
|
|
|
|
|
try { this.image = Image.FromStream(imageStream); }
|
|
|
|
|
catch { }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-08 05:09:35 +00:00
|
|
|
public class StartStop
|
|
|
|
|
{
|
|
|
|
|
public bool _stop, _pause;
|
|
|
|
|
public StartStop()
|
|
|
|
|
{
|
|
|
|
|
_stop = false;
|
|
|
|
|
_pause = false;
|
|
|
|
|
}
|
2008-12-10 06:48:38 +00:00
|
|
|
|
|
|
|
|
public void Stop()
|
|
|
|
|
{
|
|
|
|
|
lock (this)
|
|
|
|
|
{
|
|
|
|
|
if (_pause)
|
|
|
|
|
{
|
|
|
|
|
_pause = false;
|
|
|
|
|
Monitor.Pulse(this);
|
|
|
|
|
}
|
|
|
|
|
_stop = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Pause()
|
|
|
|
|
{
|
|
|
|
|
lock (this)
|
|
|
|
|
{
|
|
|
|
|
if (_pause)
|
|
|
|
|
{
|
|
|
|
|
_pause = false;
|
|
|
|
|
Monitor.Pulse(this);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_pause = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-08 05:09:35 +00:00
|
|
|
}
|
2009-01-17 04:09:38 +00:00
|
|
|
|
2010-03-22 06:36:42 +00:00
|
|
|
public class DriveInfo
|
|
|
|
|
{
|
|
|
|
|
public ICDRipper drive;
|
|
|
|
|
DirectoryInfo di;
|
|
|
|
|
CUEControls.IIconManager iconMgr;
|
|
|
|
|
|
2010-05-02 17:04:51 +00:00
|
|
|
public string Path
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return di.FullName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-22 06:36:42 +00:00
|
|
|
public int ImageKey
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return iconMgr.GetIconIndex(di, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-25 01:05:26 +00:00
|
|
|
public DriveInfo(CUEControls.IIconManager iconMgr, string path, ICDRipper drive)
|
2010-03-22 06:36:42 +00:00
|
|
|
{
|
|
|
|
|
this.iconMgr = iconMgr;
|
|
|
|
|
this.di = new DirectoryInfo(path);
|
2010-03-25 01:05:26 +00:00
|
|
|
this.drive = drive;
|
2010-03-22 06:36:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
2010-06-11 17:54:37 +00:00
|
|
|
return drive.Path;
|
2010-03-22 06:36:42 +00:00
|
|
|
}
|
2009-01-17 04:09:38 +00:00
|
|
|
}
|
2010-05-02 17:04:51 +00:00
|
|
|
|
|
|
|
|
internal class CUERipperData
|
|
|
|
|
{
|
2010-05-06 01:31:23 +00:00
|
|
|
public CUERipperData()
|
|
|
|
|
{
|
|
|
|
|
}
|
2010-05-02 17:04:51 +00:00
|
|
|
private BindingList<string> cueStyles = new BindingList<string> { "image", "tracks" };
|
|
|
|
|
//private BindingList<string> losslessOrNot = new BindingList<string> { "lossless", "lossy" };
|
|
|
|
|
private BindingList<ImgComboBoxItem<AudioEncoderType>> losslessOrNot = new BindingList<ImgComboBoxItem<AudioEncoderType>> {
|
|
|
|
|
new ImgComboBoxItem<AudioEncoderType>("lossless", "checked", AudioEncoderType.Lossless),
|
|
|
|
|
new ImgComboBoxItem<AudioEncoderType>("lossy", "unchecked", AudioEncoderType.Lossy)
|
|
|
|
|
};
|
|
|
|
|
private BindingList<CUEMetadataEntry> releases = new BindingList<CUEMetadataEntry>();
|
|
|
|
|
private BindingList<DriveInfo> drives = new BindingList<DriveInfo>();
|
2013-02-24 19:31:04 -05:00
|
|
|
private BindingList<CUEToolsFormat> formats = new BindingList<CUEToolsFormat>();
|
2010-05-02 17:04:51 +00:00
|
|
|
private BindingList<CUEToolsUDC> encoders = new BindingList<CUEToolsUDC>();
|
|
|
|
|
|
2010-05-06 01:31:23 +00:00
|
|
|
public CUEMetadataEntry selectedRelease { get; set; }
|
|
|
|
|
public bool metadataMode { get; set; }
|
2010-05-09 07:01:47 +00:00
|
|
|
public int metadataTrack { get; set; }
|
2010-05-06 01:31:23 +00:00
|
|
|
|
2010-05-02 17:04:51 +00:00
|
|
|
public BindingList<string> CUEStyles
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return cueStyles;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BindingList<ImgComboBoxItem<AudioEncoderType>> LosslessOrNot
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return losslessOrNot;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BindingList<CUEMetadataEntry> Releases
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return releases;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BindingList<DriveInfo> Drives
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return drives;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-24 19:31:04 -05:00
|
|
|
public BindingList<CUEToolsFormat> Formats
|
2010-05-02 17:04:51 +00:00
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return formats;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BindingList<CUEToolsUDC> Encoders
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return encoders;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-08 05:09:35 +00:00
|
|
|
}
|