2008-10-13 19:25:11 +00:00
|
|
|
// ****************************************************************************
|
|
|
|
|
//
|
|
|
|
|
// CUE Tools
|
|
|
|
|
// Copyright (C) 2006-2007 Moitah (moitah@yahoo.com)
|
|
|
|
|
//
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
//
|
|
|
|
|
// ****************************************************************************
|
|
|
|
|
|
|
|
|
|
// ****************************************************************************
|
|
|
|
|
// Access to AccurateRip is regulated, see
|
|
|
|
|
// http://www.accuraterip.com/3rdparty-access.htm for details.
|
|
|
|
|
// ****************************************************************************
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2009-03-22 16:59:05 +00:00
|
|
|
using System.Collections.Specialized;
|
2008-10-13 19:25:11 +00:00
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Threading;
|
2008-11-08 16:47:23 +00:00
|
|
|
using System.Diagnostics;
|
2008-11-28 22:20:17 +00:00
|
|
|
using CUETools.Processor;
|
2008-10-13 19:25:11 +00:00
|
|
|
|
|
|
|
|
namespace JDP {
|
|
|
|
|
public partial class frmCUETools : Form {
|
|
|
|
|
public frmCUETools() {
|
|
|
|
|
_config = new CUEConfig();
|
|
|
|
|
InitializeComponent();
|
2009-03-22 16:59:05 +00:00
|
|
|
m_icon_mgr = new CUEControls.ShellIconMgr();
|
|
|
|
|
m_icon_mgr.SetExtensionIcon(".flac", global::JDP.Properties.Resources.flac);
|
|
|
|
|
m_icon_mgr.SetExtensionIcon(".wv", global::JDP.Properties.Resources.wv);
|
|
|
|
|
m_icon_mgr.SetExtensionIcon(".cue", global::JDP.Properties.Resources.cue);
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnBrowseOutput_Click(object sender, EventArgs e) {
|
|
|
|
|
SaveFileDialog fileDlg = new SaveFileDialog();
|
|
|
|
|
DialogResult dlgRes;
|
|
|
|
|
|
|
|
|
|
fileDlg.Title = "Output CUE Sheet";
|
|
|
|
|
fileDlg.Filter = "CUE Sheets (*.cue)|*.cue";
|
|
|
|
|
|
|
|
|
|
dlgRes = fileDlg.ShowDialog();
|
|
|
|
|
if (dlgRes == DialogResult.OK) {
|
|
|
|
|
txtOutputPath.Text = fileDlg.FileName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-22 16:59:05 +00:00
|
|
|
private void AddNodesToBatch(TreeNodeCollection nodes)
|
|
|
|
|
{
|
|
|
|
|
foreach (TreeNode node in nodes)
|
|
|
|
|
{
|
|
|
|
|
if (node.Checked && node.Tag is FileSystemInfo)
|
|
|
|
|
{
|
|
|
|
|
_batchPaths.Add(((FileSystemInfo)node.Tag).FullName);
|
|
|
|
|
if (!chkRecursive.Checked)
|
|
|
|
|
AddNodesToBatch(node.Nodes);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
AddNodesToBatch(node.Nodes);
|
|
|
|
|
node.Checked = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-13 19:25:11 +00:00
|
|
|
private void btnConvert_Click(object sender, EventArgs e) {
|
2008-10-20 06:38:33 +00:00
|
|
|
if ((_workThread != null) && (_workThread.IsAlive))
|
|
|
|
|
return;
|
|
|
|
|
if (!CheckWriteOffset()) return;
|
2009-03-22 16:59:05 +00:00
|
|
|
_batchReport = new StringBuilder();
|
|
|
|
|
_batchRoot = null;
|
|
|
|
|
_batchProcessed = 0;
|
|
|
|
|
if (!chkMulti.Checked && !chkRecursive.Checked)
|
|
|
|
|
{
|
|
|
|
|
StartConvert();
|
2008-10-13 19:25:11 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2009-03-22 16:59:05 +00:00
|
|
|
if (rbDontGenerate.Checked)
|
2008-10-19 11:20:48 +00:00
|
|
|
{
|
2009-03-22 16:59:05 +00:00
|
|
|
MessageBox.Show(this, "Batch mode cannot be used with the output path set manually.",
|
|
|
|
|
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
return;
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
2009-03-22 16:59:05 +00:00
|
|
|
if (chkMulti.Checked)
|
|
|
|
|
AddNodesToBatch(fileSystemTreeView1.Nodes);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_batchPaths.Add(txtInputPath.Text);
|
|
|
|
|
_batchRoot = txtInputPath.Text;
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
2009-03-22 16:59:05 +00:00
|
|
|
if (_batchPaths.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(this, "Nothing selected!", "Done", MessageBoxButtons.OK,
|
|
|
|
|
MessageBoxIcon.Information);
|
|
|
|
|
return;
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
2009-03-22 16:59:05 +00:00
|
|
|
StartConvert();
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnSettings_Click(object sender, EventArgs e) {
|
|
|
|
|
using (frmSettings settingsForm = new frmSettings()) {
|
2008-11-18 14:48:26 +00:00
|
|
|
settingsForm.ReducePriority = _reducePriority;
|
2008-10-13 19:25:11 +00:00
|
|
|
settingsForm.Config = _config;
|
|
|
|
|
|
|
|
|
|
settingsForm.ShowDialog();
|
|
|
|
|
|
2008-11-18 14:48:26 +00:00
|
|
|
_reducePriority = settingsForm.ReducePriority;
|
2008-10-13 19:25:11 +00:00
|
|
|
_config = settingsForm.Config;
|
2009-02-19 04:09:59 +00:00
|
|
|
updateOutputStyles();
|
2008-10-13 19:25:11 +00:00
|
|
|
UpdateOutputPath();
|
2009-03-22 16:59:05 +00:00
|
|
|
SaveSettings();
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnAbout_Click(object sender, EventArgs e) {
|
2008-10-22 11:45:53 +00:00
|
|
|
using (frmAbout aboutForm = new frmAbout())
|
2008-10-13 19:25:11 +00:00
|
|
|
{
|
2008-10-22 11:45:53 +00:00
|
|
|
aboutForm.ShowDialog(this);
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PathTextBox_DragEnter(object sender, DragEventArgs e) {
|
|
|
|
|
if (e.Data.GetDataPresent(DataFormats.FileDrop) && !((TextBox)sender).ReadOnly) {
|
|
|
|
|
e.Effect = DragDropEffects.Copy;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PathTextBox_DragDrop(object sender, DragEventArgs e) {
|
|
|
|
|
if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
|
|
|
|
|
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
|
|
|
|
|
if (files.Length == 1) {
|
|
|
|
|
((TextBox)sender).Text = files[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string InputPath {
|
|
|
|
|
get {
|
|
|
|
|
return txtInputPath.Text;
|
|
|
|
|
}
|
|
|
|
|
set {
|
|
|
|
|
txtInputPath.Text = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void txtInputPath_TextChanged(object sender, EventArgs e) {
|
|
|
|
|
UpdateOutputPath();
|
2009-03-22 16:59:05 +00:00
|
|
|
UpdateActions();
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void rbCreateSubdirectory_CheckedChanged(object sender, EventArgs e) {
|
|
|
|
|
UpdateOutputPath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void rbAppendFilename_CheckedChanged(object sender, EventArgs e) {
|
|
|
|
|
UpdateOutputPath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void rbCustomFormat_CheckedChanged(object sender, EventArgs e) {
|
|
|
|
|
UpdateOutputPath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void txtCreateSubdirectory_TextChanged(object sender, EventArgs e) {
|
|
|
|
|
UpdateOutputPath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void txtAppendFilename_TextChanged(object sender, EventArgs e) {
|
|
|
|
|
UpdateOutputPath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void txtCustomFormat_TextChanged(object sender, EventArgs e) {
|
|
|
|
|
UpdateOutputPath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void frmCUETools_Load(object sender, EventArgs e) {
|
|
|
|
|
_batchPaths = new List<string>();
|
|
|
|
|
LoadSettings();
|
2008-11-18 14:48:26 +00:00
|
|
|
if (_reducePriority)
|
2008-11-08 16:47:23 +00:00
|
|
|
Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.Idle;
|
2009-03-22 16:59:05 +00:00
|
|
|
|
|
|
|
|
fileSystemTreeView1.CheckBoxes = chkMulti.Checked;
|
|
|
|
|
fileSystemTreeView1.IconManager = m_icon_mgr;
|
|
|
|
|
if (InputPath != "")
|
|
|
|
|
{
|
|
|
|
|
TreeNode node = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
node = fileSystemTreeView1.LookupNode(InputPath) ??
|
|
|
|
|
fileSystemTreeView1.LookupNode(Path.GetDirectoryName(InputPath));
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
if (node != null)
|
|
|
|
|
{
|
|
|
|
|
fileSystemTreeView1.SelectedNode = node;
|
|
|
|
|
node.Expand();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-13 19:25:11 +00:00
|
|
|
SetupControls(false);
|
|
|
|
|
UpdateOutputPath();
|
|
|
|
|
updateOutputStyles();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void frmCUETools_FormClosed(object sender, FormClosedEventArgs e) {
|
|
|
|
|
SaveSettings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ********************************************************************************
|
|
|
|
|
|
2009-03-22 16:59:05 +00:00
|
|
|
private CUEControls.ShellIconMgr m_icon_mgr;
|
2008-10-13 19:25:11 +00:00
|
|
|
List<string> _batchPaths;
|
2009-03-22 16:59:05 +00:00
|
|
|
StringBuilder _batchReport;
|
|
|
|
|
string _batchRoot;
|
|
|
|
|
int _batchProcessed;
|
2008-10-13 19:25:11 +00:00
|
|
|
bool _usePregapForFirstTrackInSingleFile;
|
2008-11-18 14:48:26 +00:00
|
|
|
bool _reducePriority;
|
2008-10-13 19:25:11 +00:00
|
|
|
Thread _workThread;
|
|
|
|
|
CUESheet _workClass;
|
|
|
|
|
CUEConfig _config;
|
|
|
|
|
|
2009-03-22 16:59:05 +00:00
|
|
|
private bool IsCDROM(string pathIn)
|
|
|
|
|
{
|
|
|
|
|
return pathIn.Length == 3 && pathIn.Substring(1) == ":\\" && new DriveInfo(pathIn).DriveType == DriveType.CDRom;
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-13 19:25:11 +00:00
|
|
|
private void StartConvert() {
|
2008-12-02 00:06:16 +00:00
|
|
|
try
|
|
|
|
|
{
|
2008-10-13 19:25:11 +00:00
|
|
|
_workThread = null;
|
2008-12-02 00:06:16 +00:00
|
|
|
if (_batchPaths.Count != 0)
|
|
|
|
|
{
|
2008-10-13 19:25:11 +00:00
|
|
|
txtInputPath.Text = _batchPaths[0];
|
2009-03-22 16:59:05 +00:00
|
|
|
txtInputPath.SelectAll();
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 00:06:16 +00:00
|
|
|
string pathIn = txtInputPath.Text;
|
2008-11-08 16:47:23 +00:00
|
|
|
if (!File.Exists(pathIn))
|
|
|
|
|
{
|
2009-03-22 16:59:05 +00:00
|
|
|
if (!Directory.Exists(pathIn) && !IsCDROM(pathIn))
|
2008-11-08 16:47:23 +00:00
|
|
|
throw new Exception("Input CUE Sheet not found.");
|
|
|
|
|
if (!pathIn.EndsWith(new string(Path.DirectorySeparatorChar, 1)))
|
|
|
|
|
{
|
|
|
|
|
pathIn = pathIn + Path.DirectorySeparatorChar;
|
|
|
|
|
txtInputPath.Text = pathIn;
|
|
|
|
|
}
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 00:06:16 +00:00
|
|
|
CUESheet cueSheet = new CUESheet(_config);
|
2008-11-12 05:45:48 +00:00
|
|
|
cueSheet.PasswordRequired += new ArchivePasswordRequiredHandler(PasswordRequired);
|
2008-12-02 00:06:16 +00:00
|
|
|
cueSheet.CUEToolsProgress += new CUEToolsProgressHandler(SetStatus);
|
2009-01-17 04:09:38 +00:00
|
|
|
cueSheet.CUEToolsSelection += new CUEToolsSelectionHandler(MakeSelection);
|
2009-03-22 16:59:05 +00:00
|
|
|
cueSheet.WriteOffset = (int)numericWriteOffset.Value;
|
2008-10-13 19:25:11 +00:00
|
|
|
|
2009-03-22 16:59:05 +00:00
|
|
|
object[] p = new object[7];
|
2008-10-13 19:25:11 +00:00
|
|
|
|
2008-12-02 00:06:16 +00:00
|
|
|
_workThread = new Thread(WriteAudioFilesThread);
|
|
|
|
|
_workClass = cueSheet;
|
2008-10-13 19:25:11 +00:00
|
|
|
|
2008-12-02 00:06:16 +00:00
|
|
|
p[0] = cueSheet;
|
|
|
|
|
p[1] = pathIn;
|
|
|
|
|
p[2] = SelectedCUEStyle;
|
2009-03-22 16:59:05 +00:00
|
|
|
p[3] = SelectedAction;
|
2008-12-02 00:06:16 +00:00
|
|
|
p[4] = SelectedOutputAudioFormat;
|
|
|
|
|
p[5] = chkLossyWAV.Checked;
|
2009-03-22 16:59:05 +00:00
|
|
|
p[6] = chkRecursive.Checked;
|
2008-10-13 19:25:11 +00:00
|
|
|
|
2008-12-02 00:06:16 +00:00
|
|
|
SetupControls(true);
|
|
|
|
|
_workThread.Priority = ThreadPriority.BelowNormal;
|
|
|
|
|
_workThread.IsBackground = true;
|
|
|
|
|
_workThread.Start(p);
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
2008-12-02 00:06:16 +00:00
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
if (!ShowErrorMessage(ex))
|
2008-10-13 19:25:11 +00:00
|
|
|
_batchPaths.Clear();
|
2008-12-02 00:06:16 +00:00
|
|
|
if ((_workThread == null) && (_batchPaths.Count != 0))
|
|
|
|
|
{
|
|
|
|
|
_batchPaths.RemoveAt(0);
|
|
|
|
|
if (_batchPaths.Count == 0)
|
2009-03-22 16:59:05 +00:00
|
|
|
{
|
|
|
|
|
frmReport reportForm = new frmReport();
|
|
|
|
|
reportForm.Message = _batchReport.ToString();
|
|
|
|
|
reportForm.ShowDialog(this);
|
|
|
|
|
//ShowBatchDoneMessage();
|
|
|
|
|
}
|
2008-12-02 00:06:16 +00:00
|
|
|
else
|
|
|
|
|
StartConvert();
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-12 05:45:48 +00:00
|
|
|
private void PasswordRequired(object sender, ArchivePasswordRequiredEventArgs e)
|
|
|
|
|
{
|
2008-12-02 00:06:16 +00:00
|
|
|
this.Invoke((MethodInvoker)delegate()
|
|
|
|
|
{
|
2008-11-12 05:45:48 +00:00
|
|
|
frmPassword dlg = new frmPassword();
|
|
|
|
|
if (dlg.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
e.Password = dlg.txtPassword.Text;
|
|
|
|
|
e.ContinueOperation = true;
|
|
|
|
|
} else
|
|
|
|
|
e.ContinueOperation = false;
|
2008-12-02 00:06:16 +00:00
|
|
|
});
|
2008-11-12 05:45:48 +00:00
|
|
|
}
|
|
|
|
|
|
2009-01-17 04:09:38 +00:00
|
|
|
private void MakeSelection(object sender, CUEToolsSelectionEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (_batchPaths.Count != 0)
|
|
|
|
|
return;
|
|
|
|
|
this.Invoke((MethodInvoker)delegate()
|
|
|
|
|
{
|
|
|
|
|
frmChoice dlg = new frmChoice();
|
2009-02-22 07:47:56 +00:00
|
|
|
dlg.Choices = e.choices;
|
2009-01-17 04:09:38 +00:00
|
|
|
if (dlg.ShowDialog(this) == DialogResult.OK)
|
2009-02-22 07:47:56 +00:00
|
|
|
e.selection = dlg.ChosenIndex;
|
2009-01-17 04:09:38 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-22 16:59:05 +00:00
|
|
|
private bool TryDummyCUE(string pathIn, out string cueSheetContents, out string ext)
|
|
|
|
|
{
|
|
|
|
|
string[] audioExts = new string[] { "*.wav", "*.flac", "*.wv", "*.ape", "*.m4a", "*.tta", "*.tak" };
|
|
|
|
|
for (int i = 0; i < audioExts.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
cueSheetContents = CUESheet.CreateDummyCUESheet(pathIn, audioExts[i]);
|
|
|
|
|
if (cueSheetContents != null)
|
|
|
|
|
{
|
|
|
|
|
ext = audioExts[i].Substring(1);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cueSheetContents = null;
|
|
|
|
|
ext = null;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BatchLog(string format, string pathIn, params object[] args)
|
|
|
|
|
{
|
|
|
|
|
if (_batchRoot == null || !pathIn.StartsWith(_batchRoot))
|
|
|
|
|
_batchReport.Append(pathIn);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_batchReport.Append(".");
|
|
|
|
|
_batchReport.Append(pathIn, _batchRoot.Length, pathIn.Length - _batchRoot.Length);
|
|
|
|
|
}
|
|
|
|
|
_batchReport.Append(": ");
|
|
|
|
|
_batchReport.AppendFormat(format, args);
|
|
|
|
|
_batchReport.Append("\r\n");
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-13 19:25:11 +00:00
|
|
|
private void WriteAudioFilesThread(object o) {
|
|
|
|
|
object[] p = (object[])o;
|
|
|
|
|
|
|
|
|
|
CUESheet cueSheet = (CUESheet)p[0];
|
2008-12-02 00:06:16 +00:00
|
|
|
string pathIn = (string)p[1];
|
2008-10-13 19:25:11 +00:00
|
|
|
CUEStyle cueStyle = (CUEStyle)p[2];
|
2009-03-22 16:59:05 +00:00
|
|
|
CUEAction action = (CUEAction)p[3];
|
2008-12-02 00:06:16 +00:00
|
|
|
OutputAudioFormat outputFormat = (OutputAudioFormat)p[4];
|
|
|
|
|
bool lossyWAV = (bool)p[5];
|
2009-03-22 16:59:05 +00:00
|
|
|
bool recursive = (bool)p[6];
|
2009-01-17 04:09:38 +00:00
|
|
|
DialogResult dlgRes = DialogResult.OK;
|
2008-10-13 19:25:11 +00:00
|
|
|
|
2008-12-02 00:06:16 +00:00
|
|
|
try
|
|
|
|
|
{
|
2009-03-22 16:59:05 +00:00
|
|
|
if (action == CUEAction.CreateDummyCUE)
|
2009-01-17 04:09:38 +00:00
|
|
|
{
|
2009-03-22 16:59:05 +00:00
|
|
|
if (_batchPaths.Count > 0 && Directory.Exists(pathIn))
|
2009-01-17 04:09:38 +00:00
|
|
|
{
|
2009-03-22 16:59:05 +00:00
|
|
|
if (recursive)
|
|
|
|
|
_batchPaths.InsertRange(1, Directory.GetDirectories(pathIn));
|
2009-01-17 04:09:38 +00:00
|
|
|
}
|
2009-03-22 16:59:05 +00:00
|
|
|
if (!Directory.Exists(pathIn))
|
|
|
|
|
BatchLog("no such directory.", pathIn);
|
2008-12-02 00:06:16 +00:00
|
|
|
else
|
|
|
|
|
{
|
2009-03-22 16:59:05 +00:00
|
|
|
if (Directory.GetFiles(pathIn, "*.cue").Length != 0)
|
|
|
|
|
BatchLog("already contains a cue sheet.", pathIn);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string cueSheetContents, ext;
|
|
|
|
|
if (TryDummyCUE(pathIn, out cueSheetContents, out ext))
|
|
|
|
|
{
|
|
|
|
|
string cueName = Path.GetFileName(Path.GetDirectoryName(pathIn)) + ".cuetools" + ext + ".cue";
|
|
|
|
|
string fullCueName = Path.Combine(pathIn, cueName);
|
|
|
|
|
bool utf8Required = CUESheet.Encoding.GetString(CUESheet.Encoding.GetBytes(cueSheetContents)) != cueSheetContents;
|
|
|
|
|
StreamWriter sw1 = new StreamWriter(fullCueName, false, utf8Required ? Encoding.UTF8 : CUESheet.Encoding);
|
|
|
|
|
sw1.Write(cueSheetContents);
|
|
|
|
|
sw1.Close();
|
|
|
|
|
BatchLog("created ok.", fullCueName);
|
|
|
|
|
} else
|
|
|
|
|
BatchLog("no audio files.", pathIn);
|
|
|
|
|
}
|
2008-12-02 00:06:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-03-22 16:59:05 +00:00
|
|
|
else if (action == CUEAction.CorrectFilenames)
|
2008-12-02 00:06:16 +00:00
|
|
|
{
|
2009-03-22 16:59:05 +00:00
|
|
|
if (_batchPaths.Count > 0 && Directory.Exists(pathIn))
|
2008-12-02 00:06:16 +00:00
|
|
|
{
|
2009-03-22 16:59:05 +00:00
|
|
|
string [] cues = Directory.GetFiles(pathIn, "*.cue", recursive ?
|
|
|
|
|
SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
|
|
|
|
|
if (cues.Length == 0)
|
|
|
|
|
BatchLog("no cue files.", pathIn);
|
|
|
|
|
else
|
|
|
|
|
_batchPaths.InsertRange(1, cues);
|
|
|
|
|
}
|
|
|
|
|
try
|
2008-12-02 00:06:16 +00:00
|
|
|
{
|
2009-03-22 16:59:05 +00:00
|
|
|
if (Directory.Exists(pathIn))
|
|
|
|
|
{
|
|
|
|
|
if (_batchPaths.Count == 0)
|
|
|
|
|
throw new Exception ("is a directory");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (Path.GetExtension(pathIn).ToLower() != ".cue")
|
|
|
|
|
throw new Exception("is not a .cue file");
|
|
|
|
|
string cue = null;
|
|
|
|
|
using (StreamReader sr = new StreamReader(pathIn, CUESheet.Encoding))
|
|
|
|
|
cue = sr.ReadToEnd();
|
|
|
|
|
string fixedCue = CUESheet.CorrectAudioFilenames(Path.GetDirectoryName(pathIn), cue, true, null);
|
|
|
|
|
if (fixedCue != cue)
|
|
|
|
|
{
|
|
|
|
|
using (StreamWriter sw = new StreamWriter(pathIn, false, CUESheet.Encoding))
|
|
|
|
|
sw.Write(fixedCue);
|
|
|
|
|
BatchLog("corrected.", pathIn);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
BatchLog("no changes.", pathIn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
BatchLog("{0}.", pathIn, ex.Message);
|
2008-12-02 00:06:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-03-22 16:59:05 +00:00
|
|
|
else
|
2008-12-02 00:06:16 +00:00
|
|
|
{
|
2009-03-22 16:59:05 +00:00
|
|
|
bool foundImages = false;
|
|
|
|
|
bool foundAudio = false;
|
|
|
|
|
bool processThis = true;
|
|
|
|
|
|
|
|
|
|
if (_batchPaths.Count > 0 && Directory.Exists(pathIn))
|
|
|
|
|
{
|
|
|
|
|
if (recursive)
|
|
|
|
|
_batchPaths.InsertRange(1, Directory.GetDirectories(pathIn));
|
|
|
|
|
string[] cueFiles = Directory.GetFiles(pathIn, "*.cue");
|
|
|
|
|
if (cueFiles.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
_batchPaths.InsertRange(1, cueFiles);
|
|
|
|
|
foundImages = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string cueSheetContents, ext1;
|
|
|
|
|
foundAudio = TryDummyCUE(pathIn, out cueSheetContents, out ext1);
|
|
|
|
|
string[] audioExts = new string[] { "*.flac", "*.wv", "*.ape" };
|
|
|
|
|
foreach (string ext in audioExts)
|
|
|
|
|
foreach (string audioFile in Directory.GetFiles(pathIn, ext))
|
|
|
|
|
{
|
|
|
|
|
TagLib.UserDefined.AdditionalFileTypes.Config = _config;
|
|
|
|
|
TagLib.File.IFileAbstraction file = new TagLib.File.LocalFileAbstraction(audioFile);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
TagLib.File fileInfo = TagLib.File.Create(file);
|
|
|
|
|
NameValueCollection tags = Tagging.Analyze(fileInfo);
|
|
|
|
|
if (tags.Get("CUESHEET") != null)
|
|
|
|
|
{
|
|
|
|
|
_batchPaths.Insert(1, audioFile);
|
|
|
|
|
foundImages = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
processThis = !foundImages && foundAudio;
|
|
|
|
|
}
|
2008-12-02 00:06:16 +00:00
|
|
|
|
2009-03-22 16:59:05 +00:00
|
|
|
if (processThis)
|
|
|
|
|
{
|
|
|
|
|
bool convertAction = action == CUEAction.Convert || action == CUEAction.VerifyAndConvert || action == CUEAction.VerifyThenConvert;
|
|
|
|
|
string pathOut = null;
|
|
|
|
|
List<object> releases = null;
|
|
|
|
|
|
|
|
|
|
cueSheet.Action = action;
|
|
|
|
|
cueSheet.Open(pathIn);
|
|
|
|
|
if (action != CUEAction.Convert)
|
|
|
|
|
cueSheet.DataTrackLengthMSF = txtDataTrackLength.Text;
|
|
|
|
|
cueSheet.PreGapLengthMSF = txtPreGapLength.Text;
|
|
|
|
|
cueSheet.Lookup();
|
|
|
|
|
|
|
|
|
|
if (_batchPaths.Count == 0 && convertAction)
|
|
|
|
|
{
|
|
|
|
|
if (rbFreedbAlways.Checked || (rbFreedbIf.Checked &&
|
|
|
|
|
(cueSheet.Artist == "" || cueSheet.Title == "" || cueSheet.Year == "")))
|
|
|
|
|
releases = cueSheet.LookupAlbumInfo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.Invoke((MethodInvoker)delegate()
|
|
|
|
|
{
|
|
|
|
|
toolStripStatusLabelAR.Visible = action != CUEAction.Convert;// && cueSheet.ArVerify.ARStatus == null;
|
|
|
|
|
toolStripStatusLabelAR.Text = cueSheet.ArVerify.ARStatus == null ? cueSheet.ArVerify.Total(0).ToString() : "?";
|
|
|
|
|
toolStripStatusLabelAR.ToolTipText = "AccurateRip: " + (cueSheet.ArVerify.ARStatus ?? "found") + ".";
|
|
|
|
|
if (releases != null)
|
|
|
|
|
{
|
|
|
|
|
frmChoice dlg = new frmChoice();
|
|
|
|
|
dlg.CUE = cueSheet;
|
|
|
|
|
dlg.Choices = releases;
|
|
|
|
|
dlgRes = dlg.ShowDialog(this);
|
|
|
|
|
if (dlgRes == DialogResult.Cancel)
|
|
|
|
|
{
|
|
|
|
|
cueSheet.Close();
|
|
|
|
|
SetupControls(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
UpdateOutputPath(
|
|
|
|
|
cueSheet.Year != "" ? cueSheet.Year : "YYYY",
|
|
|
|
|
cueSheet.Artist != "" ? cueSheet.Artist : "Unknown Artist",
|
|
|
|
|
cueSheet.Title != "" ? cueSheet.Title : "Unknown Title");
|
|
|
|
|
pathOut = txtOutputPath.Text;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (dlgRes == DialogResult.Cancel)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
bool outputAudio = convertAction && outputFormat != OutputAudioFormat.NoAudio;
|
|
|
|
|
bool outputCUE = convertAction && (cueStyle == CUEStyle.SingleFile || (cueStyle == CUEStyle.SingleFileWithCUE && _config.createCUEFileWhenEmbedded));
|
|
|
|
|
|
|
|
|
|
cueSheet.GenerateFilenames(outputFormat, lossyWAV, pathOut);
|
|
|
|
|
string outDir = Path.GetDirectoryName(pathOut);
|
|
|
|
|
if (cueStyle == CUEStyle.SingleFileWithCUE)
|
|
|
|
|
cueSheet.SingleFilename = Path.GetFileName(pathOut);
|
|
|
|
|
if (outDir == "")
|
|
|
|
|
outDir = ".";
|
|
|
|
|
|
|
|
|
|
bool outputExists = false;
|
|
|
|
|
if (outputCUE)
|
|
|
|
|
outputExists = File.Exists(pathOut);
|
|
|
|
|
if (outputAudio)
|
|
|
|
|
{
|
|
|
|
|
if (cueStyle == CUEStyle.SingleFile || cueStyle == CUEStyle.SingleFileWithCUE)
|
|
|
|
|
outputExists |= File.Exists(Path.Combine(outDir, cueSheet.SingleFilename));
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (cueStyle == CUEStyle.GapsAppended && _config.preserveHTOA)
|
|
|
|
|
outputExists |= File.Exists(Path.Combine(outDir, cueSheet.HTOAFilename));
|
|
|
|
|
for (int i = 0; i < cueSheet.TrackCount; i++)
|
|
|
|
|
outputExists |= File.Exists(Path.Combine(outDir, cueSheet.TrackFilenames[i]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dlgRes = DialogResult.Cancel;
|
|
|
|
|
if (outputExists)
|
|
|
|
|
{
|
|
|
|
|
this.Invoke((MethodInvoker)delegate()
|
|
|
|
|
{
|
|
|
|
|
dlgRes = MessageBox.Show(this, "One or more output file already exists, " +
|
|
|
|
|
"do you want to overwrite?", "Overwrite?", (_batchPaths.Count == 0) ?
|
|
|
|
|
MessageBoxButtons.YesNo : MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
|
|
|
|
|
if (dlgRes == DialogResult.Yes)
|
|
|
|
|
outputExists = false;
|
|
|
|
|
else if (_batchPaths.Count == 0)
|
|
|
|
|
SetupControls(false);
|
|
|
|
|
});
|
|
|
|
|
if (outputExists && _batchPaths.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
cueSheet.Close();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!outputExists)
|
|
|
|
|
{
|
|
|
|
|
cueSheet.UsePregapForFirstTrackInSingleFile = _usePregapForFirstTrackInSingleFile && !outputAudio;
|
|
|
|
|
string status = cueSheet.WriteAudioFiles(outDir, cueStyle);
|
|
|
|
|
if (_batchPaths.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
_batchProcessed++;
|
|
|
|
|
BatchLog("{0}.", pathIn, status);
|
|
|
|
|
}
|
|
|
|
|
cueSheet.CheckStop();
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-02 00:06:16 +00:00
|
|
|
}
|
|
|
|
|
this.Invoke((MethodInvoker)delegate()
|
|
|
|
|
{
|
2008-10-13 19:25:11 +00:00
|
|
|
if (_batchPaths.Count == 0)
|
|
|
|
|
{
|
2008-12-02 03:03:08 +00:00
|
|
|
if (cueSheet.IsCD)
|
|
|
|
|
{
|
|
|
|
|
frmReport reportForm = new frmReport();
|
2009-03-04 21:30:56 +00:00
|
|
|
reportForm.Message = cueSheet.LOGContents;
|
2008-12-02 03:03:08 +00:00
|
|
|
reportForm.ShowDialog(this);
|
|
|
|
|
}
|
2009-03-22 16:59:05 +00:00
|
|
|
else if (action == CUEAction.CreateDummyCUE || action == CUEAction.CorrectFilenames)
|
|
|
|
|
{
|
|
|
|
|
frmReport reportForm = new frmReport();
|
|
|
|
|
reportForm.Message = _batchReport.ToString();
|
|
|
|
|
reportForm.ShowDialog(this);
|
|
|
|
|
}
|
|
|
|
|
else if (cueSheet.Action == CUEAction.Verify ||
|
|
|
|
|
cueSheet.Action == CUEAction.VerifyPlusCRCs ||
|
|
|
|
|
(cueSheet.Action != CUEAction.Convert && outputFormat != OutputAudioFormat.NoAudio))
|
2008-10-13 19:25:11 +00:00
|
|
|
{
|
2008-12-02 00:06:16 +00:00
|
|
|
frmReport reportForm = new frmReport();
|
|
|
|
|
StringWriter sw = new StringWriter();
|
|
|
|
|
cueSheet.GenerateAccurateRipLog(sw);
|
|
|
|
|
reportForm.Message = sw.ToString();
|
|
|
|
|
sw.Close();
|
|
|
|
|
reportForm.ShowDialog(this);
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ShowFinishedMessage(cueSheet.PaddedToFrame);
|
|
|
|
|
SetupControls(false);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2008-12-02 00:06:16 +00:00
|
|
|
catch (StopException)
|
|
|
|
|
{
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
2008-11-05 03:58:08 +00:00
|
|
|
#if !DEBUG
|
2008-12-02 00:06:16 +00:00
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2009-03-22 16:59:05 +00:00
|
|
|
if (_batchPaths.Count == 0)
|
2008-12-02 00:06:16 +00:00
|
|
|
{
|
2009-03-22 16:59:05 +00:00
|
|
|
this.Invoke((MethodInvoker)delegate()
|
2008-12-02 00:06:16 +00:00
|
|
|
{
|
2008-10-13 19:25:11 +00:00
|
|
|
SetupControls(false);
|
2009-03-22 16:59:05 +00:00
|
|
|
ShowErrorMessage(ex);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_batchProcessed++;
|
|
|
|
|
BatchLog("{0}.", pathIn, ex.Message);
|
|
|
|
|
}
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
2008-11-05 03:58:08 +00:00
|
|
|
#endif
|
2009-03-22 16:59:05 +00:00
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
cueSheet.CheckStop();
|
|
|
|
|
}
|
|
|
|
|
catch (StopException)
|
|
|
|
|
{
|
|
|
|
|
_batchPaths.Clear();
|
|
|
|
|
this.Invoke((MethodInvoker)delegate()
|
|
|
|
|
{
|
|
|
|
|
SetupControls(false);
|
|
|
|
|
MessageBox.Show(this, "Conversion was stopped.", "Stopped", MessageBoxButtons.OK,
|
|
|
|
|
MessageBoxIcon.Exclamation);
|
|
|
|
|
});
|
|
|
|
|
}
|
2008-12-10 06:48:38 +00:00
|
|
|
cueSheet.Close();
|
2008-10-13 19:25:11 +00:00
|
|
|
|
|
|
|
|
if (_batchPaths.Count != 0) {
|
|
|
|
|
_batchPaths.RemoveAt(0);
|
|
|
|
|
this.BeginInvoke((MethodInvoker)delegate() {
|
|
|
|
|
if (_batchPaths.Count == 0) {
|
|
|
|
|
SetupControls(false);
|
2009-03-22 16:59:05 +00:00
|
|
|
frmReport reportForm = new frmReport();
|
|
|
|
|
reportForm.Message = _batchReport.ToString();
|
|
|
|
|
reportForm.ShowDialog(this);
|
|
|
|
|
//ShowBatchDoneMessage();
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
StartConvert();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-12 05:45:48 +00:00
|
|
|
public void SetStatus(object sender, CUEToolsProgressEventArgs e)
|
|
|
|
|
{
|
2008-10-13 19:25:11 +00:00
|
|
|
this.BeginInvoke((MethodInvoker)delegate() {
|
2008-11-12 05:45:48 +00:00
|
|
|
toolStripStatusLabel1.Text = e.status;
|
2008-12-07 23:12:01 +00:00
|
|
|
toolStripProgressBar1.Value = Math.Max(0,Math.Min(100,(int)(e.percentTrck*100)));
|
|
|
|
|
toolStripProgressBar2.Value = Math.Max(0,Math.Min(100,(int)(e.percentDisk*100)));
|
2008-10-13 19:25:11 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetupControls(bool running) {
|
2009-03-22 16:59:05 +00:00
|
|
|
bool converting = (SelectedAction == CUEAction.Convert || SelectedAction == CUEAction.VerifyAndConvert || SelectedAction == CUEAction.VerifyThenConvert);
|
|
|
|
|
bool verifying = (SelectedAction == CUEAction.Verify || SelectedAction == CUEAction.VerifyPlusCRCs || SelectedAction == CUEAction.VerifyAndConvert || SelectedAction == CUEAction.VerifyThenConvert);
|
|
|
|
|
//grpInput.Enabled = !running;
|
|
|
|
|
txtInputPath.Enabled = !running;
|
|
|
|
|
grpExtra.Enabled = !running;
|
2008-10-13 19:25:11 +00:00
|
|
|
grpOutputPathGeneration.Enabled = !running;
|
2009-03-22 16:59:05 +00:00
|
|
|
grpAudioOutput.Enabled = !running && converting;
|
|
|
|
|
grpAction.Enabled = !running;
|
|
|
|
|
grpOutputStyle.Enabled = !running && converting;
|
|
|
|
|
grpFreedb.Enabled = !running && converting;
|
|
|
|
|
txtDataTrackLength.Enabled = !running && verifying;
|
2009-02-27 14:41:55 +00:00
|
|
|
txtPreGapLength.Enabled = !running;
|
2008-10-13 19:25:11 +00:00
|
|
|
btnAbout.Enabled = !running;
|
|
|
|
|
btnSettings.Enabled = !running;
|
2008-10-20 06:38:33 +00:00
|
|
|
btnConvert.Visible = !running;
|
2008-11-04 01:23:30 +00:00
|
|
|
btnStop.Enabled = btnPause.Enabled = btnResume.Enabled = running;
|
2008-10-20 06:38:33 +00:00
|
|
|
btnStop.Visible = btnPause.Visible = running;
|
2008-11-04 01:23:30 +00:00
|
|
|
btnResume.Visible = false;
|
2008-10-13 19:25:11 +00:00
|
|
|
toolStripStatusLabel1.Text = String.Empty;
|
|
|
|
|
toolStripProgressBar1.Value = 0;
|
|
|
|
|
toolStripProgressBar2.Value = 0;
|
2009-03-22 16:59:05 +00:00
|
|
|
toolStripStatusLabelAR.Visible = false;
|
|
|
|
|
if (_batchPaths.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
fileSystemTreeView1.Visible = false;
|
|
|
|
|
textBatchReport.Visible = true;
|
|
|
|
|
textBatchReport.Text = _batchReport.ToString();
|
|
|
|
|
textBatchReport.SelectAll();
|
|
|
|
|
textBatchReport.ScrollToCaret();
|
|
|
|
|
//toolStripStatusLabelProcessed.Visible = true;
|
|
|
|
|
//toolStripStatusLabelProcessed.Text = "Processed: " + _batchProcessed.ToString();
|
|
|
|
|
//toolStripStatusLabelProcessed.ToolTipText = _batchReport.ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bool wasHidden = !fileSystemTreeView1.Visible;
|
|
|
|
|
fileSystemTreeView1.Visible = true;
|
|
|
|
|
toolStripStatusLabelProcessed.Visible = false;
|
|
|
|
|
textBatchReport.Visible = false;
|
|
|
|
|
if (wasHidden && fileSystemTreeView1.SelectedPath != null)
|
|
|
|
|
{
|
|
|
|
|
txtInputPath.Text = fileSystemTreeView1.SelectedPath;
|
|
|
|
|
txtInputPath.SelectAll();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
UpdateActions();
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool ShowErrorMessage(Exception ex) {
|
2008-11-18 14:48:26 +00:00
|
|
|
string message = "Exception";
|
|
|
|
|
for (Exception e = ex; e != null; e = e.InnerException)
|
|
|
|
|
message += ": " + e.Message;
|
|
|
|
|
DialogResult dlgRes = MessageBox.Show(this, message, "Error", (_batchPaths.Count == 0) ?
|
2008-10-13 19:25:11 +00:00
|
|
|
MessageBoxButtons.OK : MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
|
|
|
|
|
return (dlgRes == DialogResult.OK);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ShowFinishedMessage(bool warnAboutPadding) {
|
|
|
|
|
if (_batchPaths.Count != 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (warnAboutPadding) {
|
2009-01-17 04:09:38 +00:00
|
|
|
MessageBox.Show(this, "One or more input file doesn't end on a CD frame boundary. " +
|
2008-10-13 19:25:11 +00:00
|
|
|
"The output has been padded where necessary to fix this. If your input " +
|
|
|
|
|
"files are from a CD source, this may indicate a problem with your files.",
|
|
|
|
|
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
}
|
2009-01-17 04:09:38 +00:00
|
|
|
MessageBox.Show(this, "Conversion was successful!", "Done", MessageBoxButtons.OK,
|
2008-10-13 19:25:11 +00:00
|
|
|
MessageBoxIcon.Information);
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-22 16:59:05 +00:00
|
|
|
//private void ShowBatchDoneMessage() {
|
|
|
|
|
// MessageBox.Show(this, "Batch conversion is complete!", "Done", MessageBoxButtons.OK,
|
|
|
|
|
// MessageBoxIcon.Information);
|
|
|
|
|
//}
|
2008-10-13 19:25:11 +00:00
|
|
|
|
|
|
|
|
private bool CheckWriteOffset() {
|
2009-03-22 16:59:05 +00:00
|
|
|
if (numericWriteOffset.Value == 0 || rbNoAudio.Checked || rbActionVerify.Checked || rbActionVerifyAndCRCs.Checked)
|
2009-02-22 07:47:56 +00:00
|
|
|
{
|
2008-10-13 19:25:11 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-17 04:09:38 +00:00
|
|
|
DialogResult dlgRes = MessageBox.Show(this, "Write offset setting is non-zero which " +
|
2008-10-13 19:25:11 +00:00
|
|
|
"will cause some samples to be discarded. You should only use this setting " +
|
|
|
|
|
"to make temporary files for burning. Are you sure you want to continue?",
|
|
|
|
|
"Write offset is enabled", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
|
|
|
|
return (dlgRes == DialogResult.Yes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadSettings() {
|
|
|
|
|
SettingsReader sr = new SettingsReader("CUE Tools", "settings.txt");
|
2008-11-18 14:48:26 +00:00
|
|
|
txtCreateSubdirectory.Text = sr.Load("OutputSubdirectory") ?? "New";
|
|
|
|
|
txtAppendFilename.Text = sr.Load("OutputFilenameSuffix") ?? "-New";
|
2009-03-22 16:59:05 +00:00
|
|
|
txtCustomFormat.Text = sr.Load("OutputCustomFormat") ?? "%music%\\Converted\\%artist%\\%year% - %album%\\%artist% - %album%.cue";
|
2008-11-18 14:48:26 +00:00
|
|
|
SelectedOutputPathGeneration = (OutputPathGeneration?)sr.LoadInt32("OutputPathGeneration", null, null) ?? OutputPathGeneration.CreateSubdirectory;
|
|
|
|
|
SelectedOutputAudioFormat = (OutputAudioFormat?)sr.LoadInt32("OutputAudioFormat", null, null) ?? OutputAudioFormat.WAV;
|
2009-03-22 16:59:05 +00:00
|
|
|
SelectedAction = (CUEAction?)sr.LoadInt32("AccurateRipMode", null, null) ?? CUEAction.Convert;
|
2008-11-18 14:48:26 +00:00
|
|
|
SelectedCUEStyle = (CUEStyle?)sr.LoadInt32("CUEStyle", null, null) ?? CUEStyle.SingleFileWithCUE;
|
2009-03-22 16:59:05 +00:00
|
|
|
numericWriteOffset.Value = sr.LoadInt32("WriteOffset", null, null) ?? 0;
|
2008-11-18 14:48:26 +00:00
|
|
|
_usePregapForFirstTrackInSingleFile = sr.LoadBoolean("UsePregapForFirstTrackInSingleFile") ?? false;
|
|
|
|
|
_reducePriority = sr.LoadBoolean("ReducePriority") ?? true;
|
2009-03-22 16:59:05 +00:00
|
|
|
chkMulti.Checked = sr.LoadBoolean("BatchProcessing") ?? false;
|
|
|
|
|
chkRecursive.Checked = sr.LoadBoolean("RecursiveProcessing") ?? true;
|
2008-11-21 20:06:11 +00:00
|
|
|
chkLossyWAV.Checked = sr.LoadBoolean("LossyWav") ?? false;
|
2009-01-17 04:09:38 +00:00
|
|
|
switch (sr.LoadInt32("FreedbLookup", null, null) ?? 2)
|
|
|
|
|
{
|
|
|
|
|
case 0: rbFreedbNever.Checked = true; break;
|
|
|
|
|
case 1: rbFreedbIf.Checked = true; break;
|
|
|
|
|
case 2: rbFreedbAlways.Checked = true; break;
|
|
|
|
|
}
|
2008-10-13 19:25:11 +00:00
|
|
|
_config.Load(sr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SaveSettings() {
|
|
|
|
|
SettingsWriter sw = new SettingsWriter("CUE Tools", "settings.txt");
|
2008-11-18 14:48:26 +00:00
|
|
|
sw.Save("OutputPathGeneration", (int)SelectedOutputPathGeneration);
|
2008-10-13 19:25:11 +00:00
|
|
|
sw.Save("OutputSubdirectory", txtCreateSubdirectory.Text);
|
|
|
|
|
sw.Save("OutputFilenameSuffix", txtAppendFilename.Text);
|
|
|
|
|
sw.Save("OutputCustomFormat", txtCustomFormat.Text);
|
2008-11-18 14:48:26 +00:00
|
|
|
sw.Save("OutputAudioFormat", (int)SelectedOutputAudioFormat);
|
2009-03-22 16:59:05 +00:00
|
|
|
sw.Save("AccurateRipMode", (int)SelectedAction);
|
2008-11-18 14:48:26 +00:00
|
|
|
sw.Save("CUEStyle", (int)SelectedCUEStyle);
|
2009-03-22 16:59:05 +00:00
|
|
|
sw.Save("WriteOffset", (int)numericWriteOffset.Value);
|
2008-11-18 14:48:26 +00:00
|
|
|
sw.Save("UsePregapForFirstTrackInSingleFile", _usePregapForFirstTrackInSingleFile);
|
|
|
|
|
sw.Save("ReducePriority", _reducePriority);
|
2009-03-22 16:59:05 +00:00
|
|
|
sw.Save("BatchProcessing", chkMulti.Checked);
|
|
|
|
|
sw.Save("RecursiveProcessing", chkRecursive.Checked);
|
2008-11-21 20:06:11 +00:00
|
|
|
sw.Save("LossyWav", chkLossyWAV.Checked);
|
2009-01-17 04:09:38 +00:00
|
|
|
sw.Save("FreedbLookup", rbFreedbNever.Checked ? 0 : rbFreedbIf.Checked ? 1 : 2);
|
2008-10-13 19:25:11 +00:00
|
|
|
_config.Save(sw);
|
|
|
|
|
sw.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BuildOutputPathFindReplace(string inputPath, string format, List<string> find, List<string> replace) {
|
|
|
|
|
int i, j, first, last, maxFindLen;
|
|
|
|
|
string range;
|
|
|
|
|
string[] rangeSplit;
|
|
|
|
|
List<string> tmpFind = new List<string>();
|
|
|
|
|
List<string> tmpReplace = new List<string>();
|
|
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
last = 0;
|
|
|
|
|
while (i < format.Length) {
|
|
|
|
|
if (format[i++] == '%') {
|
|
|
|
|
j = i;
|
|
|
|
|
while (j < format.Length) {
|
|
|
|
|
char c = format[j];
|
|
|
|
|
if (((c < '0') || (c > '9')) && (c != '-') && (c != ':')) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
j++;
|
|
|
|
|
}
|
|
|
|
|
range = format.Substring(i, j - i);
|
|
|
|
|
if (range.Length != 0) {
|
|
|
|
|
rangeSplit = range.Split(new char[] { ':' }, 2);
|
|
|
|
|
if (Int32.TryParse(rangeSplit[0], out first)) {
|
|
|
|
|
if (rangeSplit.Length == 1) {
|
|
|
|
|
last = first;
|
|
|
|
|
}
|
|
|
|
|
if ((rangeSplit.Length == 1) || Int32.TryParse(rangeSplit[1], out last)) {
|
|
|
|
|
tmpFind.Add("%" + range);
|
|
|
|
|
tmpReplace.Add(General.EmptyStringToNull(GetDirectoryElements(Path.GetDirectoryName(inputPath), first, last)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
i = j;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Sort so that longest find strings are first, so when the replacing is done the
|
|
|
|
|
// longer strings are checked first. This avoids problems with overlapping find
|
|
|
|
|
// strings, for example if one of the strings is "%1" and another is "%1:3".
|
|
|
|
|
maxFindLen = 0;
|
|
|
|
|
for (i = 0; i < tmpFind.Count; i++) {
|
|
|
|
|
if (tmpFind[i].Length > maxFindLen) {
|
|
|
|
|
maxFindLen = tmpFind[i].Length;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (j = maxFindLen; j >= 1; j--) {
|
|
|
|
|
for (i = 0; i < tmpFind.Count; i++) {
|
|
|
|
|
if (tmpFind[i].Length == j) {
|
|
|
|
|
find.Add(tmpFind[i]);
|
|
|
|
|
replace.Add(tmpReplace[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
find.Add("%F");
|
|
|
|
|
replace.Add(Path.GetFileNameWithoutExtension(inputPath));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string GetDirectoryElements(string dir, int first, int last) {
|
2009-03-22 16:59:05 +00:00
|
|
|
if (dir == null)
|
|
|
|
|
return "";
|
2008-10-13 19:25:11 +00:00
|
|
|
string[] dirSplit = dir.Split(Path.DirectorySeparatorChar,
|
|
|
|
|
Path.AltDirectorySeparatorChar);
|
|
|
|
|
int count = dirSplit.Length;
|
|
|
|
|
|
|
|
|
|
if ((first == 0) && (last == 0)) {
|
|
|
|
|
first = 1;
|
|
|
|
|
last = count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (first < 0) first = (count + 1) + first;
|
|
|
|
|
if (last < 0) last = (count + 1) + last;
|
|
|
|
|
|
|
|
|
|
if ((first < 1) && (last < 1)) {
|
|
|
|
|
return String.Empty;
|
|
|
|
|
}
|
|
|
|
|
else if ((first > count) && (last > count)) {
|
|
|
|
|
return String.Empty;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
int i;
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
if (first < 1) first = 1;
|
|
|
|
|
if (first > count) first = count;
|
|
|
|
|
if (last < 1) last = 1;
|
|
|
|
|
if (last > count) last = count;
|
|
|
|
|
|
|
|
|
|
if (last >= first) {
|
|
|
|
|
for (i = first; i <= last; i++) {
|
|
|
|
|
sb.Append(dirSplit[i - 1]);
|
|
|
|
|
sb.Append(Path.DirectorySeparatorChar);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (i = first; i >= last; i--) {
|
|
|
|
|
sb.Append(dirSplit[i - 1]);
|
|
|
|
|
sb.Append(Path.DirectorySeparatorChar);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sb.ToString(0, sb.Length - 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private CUEStyle SelectedCUEStyle {
|
|
|
|
|
get {
|
|
|
|
|
if (rbGapsAppended.Checked) return CUEStyle.GapsAppended;
|
|
|
|
|
if (rbGapsPrepended.Checked) return CUEStyle.GapsPrepended;
|
|
|
|
|
if (rbGapsLeftOut.Checked) return CUEStyle.GapsLeftOut;
|
|
|
|
|
if (rbEmbedCUE.Checked) return CUEStyle.SingleFileWithCUE;
|
|
|
|
|
return CUEStyle.SingleFile;
|
|
|
|
|
}
|
|
|
|
|
set {
|
|
|
|
|
switch (value) {
|
|
|
|
|
case CUEStyle.SingleFileWithCUE: rbEmbedCUE.Checked = true; break;
|
|
|
|
|
case CUEStyle.SingleFile: rbSingleFile.Checked = true; break;
|
|
|
|
|
case CUEStyle.GapsAppended: rbGapsAppended.Checked = true; break;
|
|
|
|
|
case CUEStyle.GapsPrepended: rbGapsPrepended.Checked = true; break;
|
|
|
|
|
case CUEStyle.GapsLeftOut: rbGapsLeftOut.Checked = true; break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private OutputPathGeneration SelectedOutputPathGeneration {
|
|
|
|
|
get {
|
|
|
|
|
if (rbCreateSubdirectory.Checked) return OutputPathGeneration.CreateSubdirectory;
|
|
|
|
|
if (rbAppendFilename.Checked) return OutputPathGeneration.AppendFilename;
|
|
|
|
|
if (rbCustomFormat.Checked) return OutputPathGeneration.CustomFormat;
|
|
|
|
|
return OutputPathGeneration.Disabled;
|
|
|
|
|
}
|
|
|
|
|
set {
|
|
|
|
|
switch (value) {
|
|
|
|
|
case OutputPathGeneration.CreateSubdirectory: rbCreateSubdirectory.Checked = true; break;
|
|
|
|
|
case OutputPathGeneration.AppendFilename: rbAppendFilename.Checked = true; break;
|
|
|
|
|
case OutputPathGeneration.CustomFormat: rbCustomFormat.Checked = true; break;
|
|
|
|
|
case OutputPathGeneration.Disabled: rbDontGenerate.Checked = true; break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private OutputAudioFormat SelectedOutputAudioFormat {
|
|
|
|
|
get {
|
|
|
|
|
if (rbFLAC.Checked) return OutputAudioFormat.FLAC;
|
|
|
|
|
if (rbWavPack.Checked) return OutputAudioFormat.WavPack;
|
2008-10-17 18:21:59 +00:00
|
|
|
if (rbAPE.Checked) return OutputAudioFormat.APE;
|
2009-01-17 04:09:38 +00:00
|
|
|
if (rbTTA.Checked) return OutputAudioFormat.TTA;
|
2008-10-13 19:25:11 +00:00
|
|
|
if (rbNoAudio.Checked) return OutputAudioFormat.NoAudio;
|
2009-02-19 04:09:59 +00:00
|
|
|
if (rbWAV.Checked) return OutputAudioFormat.WAV;
|
|
|
|
|
if (rbUDC1.Checked) return OutputAudioFormat.UDC1;
|
|
|
|
|
return OutputAudioFormat.NoAudio;
|
|
|
|
|
//throw new Exception("output format invalid");
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
set {
|
|
|
|
|
switch (value) {
|
|
|
|
|
case OutputAudioFormat.FLAC: rbFLAC.Checked = true; break;
|
|
|
|
|
case OutputAudioFormat.WavPack: rbWavPack.Checked = true; break;
|
2008-10-17 18:21:59 +00:00
|
|
|
case OutputAudioFormat.APE: rbAPE.Checked = true; break;
|
2009-01-17 04:09:38 +00:00
|
|
|
case OutputAudioFormat.TTA: rbTTA.Checked = true; break;
|
2008-10-17 18:21:59 +00:00
|
|
|
case OutputAudioFormat.WAV: rbWAV.Checked = true; break;
|
2008-10-13 19:25:11 +00:00
|
|
|
case OutputAudioFormat.NoAudio: rbNoAudio.Checked = true; break;
|
2009-02-19 04:09:59 +00:00
|
|
|
case OutputAudioFormat.UDC1: rbUDC1.Checked = true; break;
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-22 16:59:05 +00:00
|
|
|
private CUEAction SelectedAction
|
2008-12-01 20:24:16 +00:00
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return
|
2009-03-22 16:59:05 +00:00
|
|
|
rbActionVerifyAndCRCs.Checked ? CUEAction.VerifyPlusCRCs :
|
|
|
|
|
rbActionVerify.Checked ? CUEAction.Verify :
|
|
|
|
|
rbActionVerifyThenEncode.Checked ? CUEAction.VerifyThenConvert :
|
|
|
|
|
rbActionVerifyAndEncode.Checked ? CUEAction.VerifyAndConvert :
|
|
|
|
|
rbActionCorrectFilenames.Checked ? CUEAction.CorrectFilenames :
|
|
|
|
|
rbActionCreateCUESheet.Checked ? CUEAction.CreateDummyCUE :
|
|
|
|
|
CUEAction.Convert;
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
2008-12-01 20:24:16 +00:00
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
switch (value)
|
|
|
|
|
{
|
2009-03-22 16:59:05 +00:00
|
|
|
case CUEAction.VerifyPlusCRCs:
|
|
|
|
|
rbActionVerifyAndCRCs.Checked = true;
|
|
|
|
|
break;
|
|
|
|
|
case CUEAction.Verify:
|
|
|
|
|
rbActionVerify.Checked = true;
|
|
|
|
|
break;
|
|
|
|
|
case CUEAction.VerifyThenConvert:
|
|
|
|
|
rbActionVerifyThenEncode.Checked = true;
|
2009-02-22 07:47:56 +00:00
|
|
|
break;
|
2009-03-22 16:59:05 +00:00
|
|
|
case CUEAction.VerifyAndConvert:
|
|
|
|
|
rbActionVerifyAndEncode.Checked = true;
|
2008-12-01 20:24:16 +00:00
|
|
|
break;
|
2009-03-22 16:59:05 +00:00
|
|
|
case CUEAction.CorrectFilenames:
|
|
|
|
|
rbActionCorrectFilenames.Checked = true;
|
2008-12-01 20:24:16 +00:00
|
|
|
break;
|
2009-03-22 16:59:05 +00:00
|
|
|
case CUEAction.CreateDummyCUE:
|
|
|
|
|
rbActionCreateCUESheet.Checked = true;
|
2008-12-01 20:24:16 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
2009-03-22 16:59:05 +00:00
|
|
|
rbActionEncode.Checked = true;
|
2008-12-01 20:24:16 +00:00
|
|
|
break;
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateOutputPath() {
|
2009-01-17 04:09:38 +00:00
|
|
|
UpdateOutputPath("YYYY", "Artist", "Album");
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
|
2009-01-17 04:09:38 +00:00
|
|
|
private void UpdateOutputPath(string year, string artist, string album) {
|
2008-10-13 19:25:11 +00:00
|
|
|
/* if (rbArVerify.Checked)
|
|
|
|
|
{
|
|
|
|
|
txtOutputPath.Text = txtInputPath.Text;
|
|
|
|
|
txtOutputPath.ReadOnly = true;
|
|
|
|
|
btnBrowseOutput.Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
else */ if (rbDontGenerate.Checked)
|
|
|
|
|
{
|
|
|
|
|
txtOutputPath.ReadOnly = false;
|
|
|
|
|
btnBrowseOutput.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
txtOutputPath.ReadOnly = true;
|
|
|
|
|
btnBrowseOutput.Enabled = false;
|
2009-01-17 04:09:38 +00:00
|
|
|
txtOutputPath.Text = GenerateOutputPath(year, artist, album);
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-17 04:09:38 +00:00
|
|
|
private string GenerateOutputPath(string year, string artist, string album) {
|
2008-10-13 19:25:11 +00:00
|
|
|
string pathIn, pathOut, dir, file, ext;
|
|
|
|
|
|
|
|
|
|
pathIn = txtInputPath.Text;
|
|
|
|
|
pathOut = String.Empty;
|
|
|
|
|
|
2008-11-08 16:47:23 +00:00
|
|
|
if ((pathIn.Length != 0) && (File.Exists(pathIn) || Directory.Exists(pathIn)))
|
|
|
|
|
{
|
|
|
|
|
if (Directory.Exists(pathIn))
|
|
|
|
|
{
|
|
|
|
|
if (!pathIn.EndsWith(new string(Path.DirectorySeparatorChar, 1)))
|
|
|
|
|
pathIn = pathIn + Path.DirectorySeparatorChar;
|
2008-11-30 23:47:13 +00:00
|
|
|
dir = Path.GetDirectoryName(pathIn) ?? pathIn;
|
2008-11-08 16:47:23 +00:00
|
|
|
file = Path.GetFileNameWithoutExtension(dir);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dir = Path.GetDirectoryName(pathIn);
|
|
|
|
|
file = Path.GetFileNameWithoutExtension(pathIn);
|
|
|
|
|
}
|
2008-10-13 19:25:11 +00:00
|
|
|
ext = ".cue";
|
|
|
|
|
if (rbEmbedCUE.Checked)
|
2009-02-19 04:09:59 +00:00
|
|
|
ext = General.FormatExtension (SelectedOutputAudioFormat, _config);
|
2008-11-21 20:06:11 +00:00
|
|
|
if (chkLossyWAV.Checked)
|
|
|
|
|
ext = ".lossy" + ext;
|
2008-11-22 15:10:33 +00:00
|
|
|
if (_config.detectHDCD && _config.decodeHDCD && (!chkLossyWAV.Checked || !_config.decodeHDCDtoLW16))
|
|
|
|
|
{
|
|
|
|
|
if (_config.decodeHDCDto24bit)
|
|
|
|
|
ext = ".24bit" + ext;
|
|
|
|
|
else
|
|
|
|
|
ext = ".20bit" + ext;
|
|
|
|
|
}
|
2008-10-13 19:25:11 +00:00
|
|
|
|
|
|
|
|
if (rbCreateSubdirectory.Checked) {
|
|
|
|
|
pathOut = Path.Combine(Path.Combine(dir, txtCreateSubdirectory.Text), file + ext);
|
|
|
|
|
}
|
|
|
|
|
else if (rbAppendFilename.Checked) {
|
|
|
|
|
pathOut = Path.Combine(dir, file + txtAppendFilename.Text + ext);
|
|
|
|
|
}
|
|
|
|
|
else if (rbCustomFormat.Checked) {
|
|
|
|
|
string format = txtCustomFormat.Text;
|
|
|
|
|
List<string> find = new List<string>();
|
|
|
|
|
List<string> replace = new List<string>();
|
|
|
|
|
bool rs = _config.replaceSpaces;
|
|
|
|
|
|
2009-03-22 16:59:05 +00:00
|
|
|
find.Add("%music%");
|
|
|
|
|
find.Add("%artist%");
|
2008-10-13 19:25:11 +00:00
|
|
|
find.Add("%D");
|
2009-03-22 16:59:05 +00:00
|
|
|
find.Add("%album%");
|
2008-10-13 19:25:11 +00:00
|
|
|
find.Add("%C");
|
2009-03-22 16:59:05 +00:00
|
|
|
find.Add("%year%");
|
2009-01-17 04:09:38 +00:00
|
|
|
find.Add("%Y");
|
2009-03-22 16:59:05 +00:00
|
|
|
replace.Add(m_icon_mgr.GetFolderPath(CUEControls.ExtraSpecialFolder.MyMusic));
|
|
|
|
|
replace.Add(General.EmptyStringToNull(_config.CleanseString(rs ? artist.Replace(' ', '_') : artist)));
|
2008-10-13 19:25:11 +00:00
|
|
|
replace.Add(General.EmptyStringToNull(_config.CleanseString(rs ? artist.Replace(' ', '_') : artist)));
|
|
|
|
|
replace.Add(General.EmptyStringToNull(_config.CleanseString(rs ? album.Replace(' ', '_') : album)));
|
2009-03-22 16:59:05 +00:00
|
|
|
replace.Add(General.EmptyStringToNull(_config.CleanseString(rs ? album.Replace(' ', '_') : album)));
|
|
|
|
|
replace.Add(year);
|
2009-01-17 04:09:38 +00:00
|
|
|
replace.Add(year);
|
2008-10-13 19:25:11 +00:00
|
|
|
BuildOutputPathFindReplace(pathIn, format, find, replace);
|
|
|
|
|
|
|
|
|
|
pathOut = General.ReplaceMultiple(format, find, replace);
|
|
|
|
|
if (pathOut == null) pathOut = String.Empty;
|
|
|
|
|
pathOut = Path.ChangeExtension(pathOut, ext);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pathOut;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateOutputStyles()
|
|
|
|
|
{
|
2009-02-19 04:09:59 +00:00
|
|
|
rbEmbedCUE.Enabled = rbFLAC.Checked || rbWavPack.Checked || rbAPE.Checked || (rbUDC1.Checked && _config.udc1APEv2);
|
2008-11-21 20:06:11 +00:00
|
|
|
chkLossyWAV.Enabled = rbFLAC.Checked || rbWavPack.Checked || rbWAV.Checked;
|
|
|
|
|
rbNoAudio.Enabled = !rbEmbedCUE.Checked && !chkLossyWAV.Checked;
|
|
|
|
|
rbWAV.Enabled = !rbEmbedCUE.Checked;
|
2009-01-17 04:09:38 +00:00
|
|
|
rbTTA.Enabled = rbAPE.Enabled = !chkLossyWAV.Checked;
|
2009-02-19 04:09:59 +00:00
|
|
|
rbUDC1.Enabled = _config.udc1Extension != "" && _config.udc1Encoder != "" && (_config.udc1APEv2 || !rbEmbedCUE.Checked) && !chkLossyWAV.Checked;
|
|
|
|
|
rbUDC1.Text = _config.udc1Extension == "" ? "User" : _config.udc1Extension.ToUpper();
|
|
|
|
|
// _config.udc1Extension.Substring(0, 1).ToUpper() + _config.udc1Extension.Substring(1);
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void rbWAV_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
updateOutputStyles();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void rbFLAC_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
updateOutputStyles();
|
2008-11-21 20:06:11 +00:00
|
|
|
UpdateOutputPath();
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void rbWavPack_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
updateOutputStyles();
|
2008-11-21 20:06:11 +00:00
|
|
|
UpdateOutputPath();
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void rbEmbedCUE_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
updateOutputStyles();
|
|
|
|
|
UpdateOutputPath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void rbNoAudio_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
updateOutputStyles();
|
|
|
|
|
UpdateOutputPath();
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-17 18:21:59 +00:00
|
|
|
private void rbAPE_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
updateOutputStyles();
|
2008-11-21 20:06:11 +00:00
|
|
|
UpdateOutputPath();
|
2008-10-17 18:21:59 +00:00
|
|
|
}
|
2008-10-20 06:38:33 +00:00
|
|
|
|
|
|
|
|
private void btnStop_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if ((_workThread != null) && (_workThread.IsAlive))
|
|
|
|
|
_workClass.Stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnPause_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if ((_workThread != null) && (_workThread.IsAlive))
|
2008-11-04 01:23:30 +00:00
|
|
|
{
|
2008-10-20 06:38:33 +00:00
|
|
|
_workClass.Pause();
|
2008-11-04 01:23:30 +00:00
|
|
|
btnPause.Visible = !btnPause.Visible;
|
|
|
|
|
btnResume.Visible = !btnResume.Visible;
|
|
|
|
|
}
|
2008-10-20 06:38:33 +00:00
|
|
|
}
|
2008-11-21 20:06:11 +00:00
|
|
|
|
|
|
|
|
private void chkLossyWAV_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
updateOutputStyles();
|
|
|
|
|
UpdateOutputPath();
|
|
|
|
|
}
|
2008-11-22 15:10:33 +00:00
|
|
|
|
2009-01-17 04:09:38 +00:00
|
|
|
private void rbTTA_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
updateOutputStyles();
|
|
|
|
|
UpdateOutputPath();
|
|
|
|
|
}
|
2009-02-19 04:09:59 +00:00
|
|
|
|
|
|
|
|
private void rbUDC1_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
updateOutputStyles();
|
|
|
|
|
UpdateOutputPath();
|
|
|
|
|
}
|
2009-02-19 06:26:56 +00:00
|
|
|
|
|
|
|
|
private void btnCodec_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
contextMenuStripUDC.Show(btnCodec, btnCodec.Width, btnCodec.Height);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void contextMenuStripUDC_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
contextMenuStripUDC.Hide();
|
|
|
|
|
string executable = null, extension = null, decParams = null, encParams = null;
|
|
|
|
|
bool apev2 = false, id3v2 = false;
|
|
|
|
|
switch (e.ClickedItem.Text)
|
|
|
|
|
{
|
|
|
|
|
case "TAK":
|
|
|
|
|
extension = "tak";
|
|
|
|
|
executable = "takc.exe";
|
|
|
|
|
decParams = "-d %I -";
|
|
|
|
|
encParams = "-e -p4m -overwrite - %O";
|
|
|
|
|
apev2 = true;
|
|
|
|
|
id3v2 = false;
|
|
|
|
|
break;
|
2009-02-22 07:47:56 +00:00
|
|
|
case "ALAC":
|
|
|
|
|
extension = "m4a";
|
|
|
|
|
executable = "ffmpeg.exe";
|
|
|
|
|
decParams = "%I -f wav -";
|
|
|
|
|
encParams = "-i - -f ipod -acodec alac -y %O";
|
|
|
|
|
apev2 = false;
|
|
|
|
|
id3v2 = false;
|
|
|
|
|
break;
|
2009-02-19 06:26:56 +00:00
|
|
|
case "MP3":
|
|
|
|
|
extension = "mp3";
|
|
|
|
|
executable = "lame.exe";
|
|
|
|
|
decParams = "--decode %I -";
|
|
|
|
|
encParams = "--vbr-new -V2 - %O";
|
|
|
|
|
apev2 = false;
|
|
|
|
|
id3v2 = true;
|
|
|
|
|
break;
|
|
|
|
|
case "OGG":
|
|
|
|
|
extension = "ogg";
|
|
|
|
|
executable = "oggenc.exe";
|
|
|
|
|
encParams = "- -o %O";
|
|
|
|
|
decParams = "";
|
|
|
|
|
apev2 = false;
|
|
|
|
|
id3v2 = false;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string path = Path.Combine(Application.StartupPath, executable);
|
|
|
|
|
if (!File.Exists(path))
|
|
|
|
|
{
|
|
|
|
|
OpenFileDialog fileDlg = new OpenFileDialog();
|
|
|
|
|
DialogResult dlgRes;
|
|
|
|
|
fileDlg.Title = "Select the path to encoder";
|
|
|
|
|
fileDlg.Filter = executable + "|" + executable;
|
|
|
|
|
if (Directory.Exists(Application.StartupPath))
|
|
|
|
|
fileDlg.InitialDirectory = Application.StartupPath;
|
|
|
|
|
dlgRes = fileDlg.ShowDialog();
|
|
|
|
|
if (dlgRes != DialogResult.OK)
|
|
|
|
|
return;
|
|
|
|
|
path = fileDlg.FileName;
|
|
|
|
|
}
|
|
|
|
|
_config.udc1Extension = extension;
|
|
|
|
|
_config.udc1Decoder = path;
|
|
|
|
|
_config.udc1Params = decParams;
|
|
|
|
|
_config.udc1Encoder = path;
|
|
|
|
|
_config.udc1EncParams = encParams;
|
|
|
|
|
_config.udc1APEv2 = apev2;
|
|
|
|
|
_config.udc1ID3v2 = id3v2;
|
|
|
|
|
updateOutputStyles();
|
|
|
|
|
UpdateOutputPath();
|
|
|
|
|
}
|
2009-02-22 07:47:56 +00:00
|
|
|
|
2009-03-22 16:59:05 +00:00
|
|
|
private void fileSystemTreeView1_NodeAttributes(object sender, CUEControls.FileSystemTreeViewNodeAttributesEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if ((e.file.Attributes & FileAttributes.Hidden) != 0)
|
|
|
|
|
{
|
|
|
|
|
e.isVisible = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ((e.file.Attributes & FileAttributes.Directory) != 0)
|
|
|
|
|
{
|
|
|
|
|
e.isVisible = true;
|
|
|
|
|
e.isExpandable = true;
|
|
|
|
|
// e.isExpandable = false;
|
|
|
|
|
// foreach (FileSystemInfo subfile in ((DirectoryInfo)e.file).GetFileSystemInfos())
|
|
|
|
|
// if (IsVisible(subfile))
|
|
|
|
|
// {
|
|
|
|
|
// e.isExpandable = true;
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string ext = e.file.Extension.ToLower();
|
|
|
|
|
if (ext == ".cue")
|
|
|
|
|
{
|
|
|
|
|
e.isVisible = true;
|
|
|
|
|
e.isExpandable = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (ext == ".zip")
|
|
|
|
|
{
|
|
|
|
|
e.isVisible = false;
|
|
|
|
|
e.isExpandable = false;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (ICSharpCode.SharpZipLib.Zip.ZipFile unzip = new ICSharpCode.SharpZipLib.Zip.ZipFile(e.file.FullName))
|
|
|
|
|
{
|
|
|
|
|
foreach (ICSharpCode.SharpZipLib.Zip.ZipEntry entry in unzip)
|
|
|
|
|
{
|
|
|
|
|
if (entry.IsFile && Path.GetExtension(entry.Name).ToLower() == ".cue")
|
|
|
|
|
{
|
|
|
|
|
e.isVisible = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
unzip.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (ext == ".rar")
|
|
|
|
|
{
|
|
|
|
|
e.isVisible = true;
|
|
|
|
|
e.isExpandable = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (ext != "" && ".flac;.ape;.wv;".Contains(ext))
|
|
|
|
|
{
|
|
|
|
|
TagLib.UserDefined.AdditionalFileTypes.Config = _config;
|
|
|
|
|
TagLib.File.IFileAbstraction file = new TagLib.File.LocalFileAbstraction(e.file.FullName);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
TagLib.File fileInfo = TagLib.File.Create(file);
|
|
|
|
|
NameValueCollection tags = Tagging.Analyze(fileInfo);
|
|
|
|
|
e.isVisible = tags.Get("CUESHEET") != null;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
e.isVisible = false;
|
|
|
|
|
}
|
|
|
|
|
e.isExpandable = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateActions()
|
|
|
|
|
{
|
|
|
|
|
if (chkMulti.Checked)
|
|
|
|
|
{
|
|
|
|
|
rbActionCorrectFilenames.Enabled = true;
|
|
|
|
|
rbActionCreateCUESheet.Enabled = true;
|
|
|
|
|
rbActionEncode.Enabled = true;
|
|
|
|
|
rbActionVerifyAndCRCs.Enabled = true;
|
|
|
|
|
rbActionVerify.Enabled = true;
|
|
|
|
|
rbActionVerifyThenEncode.Enabled = true;
|
|
|
|
|
rbActionVerifyAndEncode.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
else if (chkRecursive.Checked)
|
|
|
|
|
{
|
|
|
|
|
string pathIn = txtInputPath.Text;
|
|
|
|
|
rbActionCorrectFilenames.Enabled =
|
|
|
|
|
rbActionCreateCUESheet.Enabled =
|
|
|
|
|
rbActionVerifyAndEncode.Enabled =
|
|
|
|
|
rbActionVerifyThenEncode.Enabled =
|
|
|
|
|
rbActionVerify.Enabled =
|
|
|
|
|
rbActionVerifyAndCRCs.Enabled =
|
|
|
|
|
rbActionEncode.Enabled = pathIn.Length != 0 && Directory.Exists(pathIn);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string pathIn = txtInputPath.Text;
|
|
|
|
|
string cueSheetContents, ext;
|
|
|
|
|
rbActionCorrectFilenames.Enabled = pathIn.Length != 0
|
|
|
|
|
&& File.Exists(pathIn)
|
|
|
|
|
&& Path.GetExtension(pathIn).ToLower() == ".cue";
|
|
|
|
|
rbActionCreateCUESheet.Enabled = pathIn.Length != 0
|
|
|
|
|
&& Directory.Exists(pathIn)
|
|
|
|
|
&& Directory.GetFiles(pathIn, "*.cue").Length == 0
|
|
|
|
|
&& TryDummyCUE(pathIn, out cueSheetContents, out ext);
|
|
|
|
|
rbActionVerifyAndEncode.Enabled =
|
|
|
|
|
rbActionVerifyThenEncode.Enabled =
|
|
|
|
|
rbActionVerify.Enabled =
|
|
|
|
|
rbActionVerifyAndCRCs.Enabled =
|
|
|
|
|
rbActionEncode.Enabled = pathIn.Length != 0
|
|
|
|
|
&& (File.Exists(pathIn) || IsCDROM(pathIn) || rbActionCreateCUESheet.Enabled);
|
|
|
|
|
}
|
|
|
|
|
btnConvert.Enabled = btnConvert.Visible &&
|
|
|
|
|
((rbActionCorrectFilenames.Enabled && rbActionCorrectFilenames.Checked)
|
|
|
|
|
|| (rbActionCreateCUESheet.Enabled && rbActionCreateCUESheet.Checked)
|
|
|
|
|
|| (rbActionEncode.Enabled && rbActionEncode.Checked)
|
|
|
|
|
|| (rbActionVerifyAndCRCs.Enabled && rbActionVerifyAndCRCs.Checked)
|
|
|
|
|
|| (rbActionVerify.Enabled && rbActionVerify.Checked)
|
|
|
|
|
|| (rbActionVerifyThenEncode.Enabled && rbActionVerifyThenEncode.Checked)
|
|
|
|
|
|| (rbActionVerifyAndEncode.Enabled && rbActionVerifyAndEncode.Checked));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fileSystemTreeView1_AfterSelect(object sender, TreeViewEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (fileSystemTreeView1.SelectedPath != null)
|
|
|
|
|
{
|
|
|
|
|
txtInputPath.Text = fileSystemTreeView1.SelectedPath;
|
|
|
|
|
txtInputPath.SelectAll();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void chkMulti_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
fileSystemTreeView1.CheckBoxes = chkMulti.Checked;
|
|
|
|
|
if (fileSystemTreeView1.SelectedNode != null)
|
|
|
|
|
{
|
|
|
|
|
if (chkMulti.Checked)
|
|
|
|
|
fileSystemTreeView1.SelectedNode.Checked = true;
|
|
|
|
|
fileSystemTreeView1.SelectedNode.Expand();
|
|
|
|
|
}
|
|
|
|
|
UpdateActions();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void chkRecursive_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UpdateActions();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fileSystemTreeView1_AfterExpand(object sender, TreeViewEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
fileSystemTreeView1_AfterCheck(sender, e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fileSystemTreeView1_AfterCheck(object sender, TreeViewEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (chkMulti.Checked && chkRecursive.Checked)
|
|
|
|
|
foreach (TreeNode node in e.Node.Nodes)
|
|
|
|
|
node.Checked = e.Node.Checked;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fileSystemTreeView1_DragEnter(object sender, DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
|
|
|
|
{
|
|
|
|
|
e.Effect = DragDropEffects.Copy;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fileSystemTreeView1_DragDrop(object sender, DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
|
|
|
|
{
|
|
|
|
|
string[] folders = e.Data.GetData(DataFormats.FileDrop) as string[];
|
|
|
|
|
if (folders != null)
|
|
|
|
|
{
|
|
|
|
|
if (folders.Length > 1 && !chkMulti.Checked)
|
|
|
|
|
{
|
|
|
|
|
chkMulti.Checked = true;
|
|
|
|
|
if (fileSystemTreeView1.SelectedNode != null && fileSystemTreeView1.SelectedNode.Checked)
|
|
|
|
|
fileSystemTreeView1.SelectedNode.Checked = false;
|
|
|
|
|
}
|
|
|
|
|
if (chkMulti.Checked)
|
|
|
|
|
foreach (string folder in folders)
|
|
|
|
|
{
|
|
|
|
|
TreeNode node = fileSystemTreeView1.LookupNode(folder);
|
|
|
|
|
if (node != null) node.Checked = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
fileSystemTreeView1.SelectedPath = folders[0];
|
|
|
|
|
fileSystemTreeView1.Focus();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void rbAction_CheckedChanged(object sender, EventArgs e)
|
2009-02-22 07:47:56 +00:00
|
|
|
{
|
|
|
|
|
UpdateOutputPath();
|
|
|
|
|
SetupControls(false);
|
|
|
|
|
}
|
2009-03-22 16:59:05 +00:00
|
|
|
|
|
|
|
|
public void OnSecondCall(string[] args)
|
|
|
|
|
{
|
|
|
|
|
this.Invoke((MethodInvoker)delegate()
|
|
|
|
|
{
|
|
|
|
|
if (args.Length == 1)
|
|
|
|
|
{
|
|
|
|
|
TreeNode node = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
node = fileSystemTreeView1.LookupNode(args[0]) ??
|
|
|
|
|
fileSystemTreeView1.LookupNode(Path.GetDirectoryName(args[0]));
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
if (node != null)
|
|
|
|
|
{
|
|
|
|
|
fileSystemTreeView1.SelectedNode = node;
|
|
|
|
|
node.Expand();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (WindowState == FormWindowState.Minimized)
|
|
|
|
|
WindowState = FormWindowState.Normal;
|
|
|
|
|
fileSystemTreeView1.Select();
|
|
|
|
|
Activate();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setAsMyMusicFolderToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DirectoryInfo dir = (DirectoryInfo)contextMenuStripFileTree.Tag;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
fileSystemTreeView1.IconManager.SetFolderPath(CUEControls.ExtraSpecialFolder.MyMusic, dir.FullName);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
fileSystemTreeView1.Nodes[0].Collapse();
|
|
|
|
|
fileSystemTreeView1.SelectedFolder = CUEControls.ExtraSpecialFolder.MyMusic;
|
|
|
|
|
fileSystemTreeView1.SelectedNode.Expand();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void resetToOriginalLocationToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CUEControls.ExtraSpecialFolder dir = (CUEControls.ExtraSpecialFolder)contextMenuStripFileTree.Tag;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
fileSystemTreeView1.IconManager.SetFolderPath(dir, null);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
fileSystemTreeView1.Nodes[0].Collapse();
|
|
|
|
|
fileSystemTreeView1.SelectedFolder = CUEControls.ExtraSpecialFolder.MyMusic;
|
|
|
|
|
fileSystemTreeView1.SelectedNode.Expand();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fileSystemTreeView1_MouseDown(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button == MouseButtons.Right)
|
|
|
|
|
{
|
|
|
|
|
TreeViewHitTestInfo info = fileSystemTreeView1.HitTest(e.Location);
|
|
|
|
|
if (info.Node != null)
|
|
|
|
|
{
|
|
|
|
|
contextMenuStripFileTree.Tag = info.Node.Tag;
|
|
|
|
|
SelectedNodeName.Text = info.Node.Text;
|
|
|
|
|
SelectedNodeName.Image = m_icon_mgr.ImageList.Images[info.Node.ImageIndex];
|
|
|
|
|
if (info.Node.Tag is DirectoryInfo)
|
|
|
|
|
{
|
|
|
|
|
resetToOriginalLocationToolStripMenuItem.Visible = false;
|
|
|
|
|
setAsMyMusicFolderToolStripMenuItem.Visible = true;
|
|
|
|
|
setAsMyMusicFolderToolStripMenuItem.Image = m_icon_mgr.ImageList.Images[m_icon_mgr.GetIconIndex(CUEControls.ExtraSpecialFolder.MyMusic, true)];
|
|
|
|
|
}
|
|
|
|
|
else if (info.Node.Tag is CUEControls.ExtraSpecialFolder && ((CUEControls.ExtraSpecialFolder)info.Node.Tag) == CUEControls.ExtraSpecialFolder.MyMusic)
|
|
|
|
|
{
|
|
|
|
|
resetToOriginalLocationToolStripMenuItem.Visible = true;
|
|
|
|
|
setAsMyMusicFolderToolStripMenuItem.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return;
|
|
|
|
|
fileSystemTreeView1.SelectedNode = info.Node;
|
|
|
|
|
contextMenuStripFileTree.Show(fileSystemTreeView1, e.Location);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum OutputPathGeneration {
|
|
|
|
|
CreateSubdirectory,
|
|
|
|
|
AppendFilename,
|
|
|
|
|
CustomFormat,
|
|
|
|
|
Disabled
|
|
|
|
|
}
|
|
|
|
|
}
|