2008-10-13 19:25:11 +00:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
2009-03-23 15:46:26 +00:00
|
|
|
using System.Globalization;
|
2009-05-01 15:16:26 +00:00
|
|
|
using System.IO;
|
2009-03-23 15:46:26 +00:00
|
|
|
using System.Threading;
|
2008-11-28 22:20:17 +00:00
|
|
|
using CUETools.Processor;
|
2009-05-01 15:16:26 +00:00
|
|
|
using CUEControls;
|
2008-10-13 19:25:11 +00:00
|
|
|
|
|
|
|
|
namespace JDP {
|
|
|
|
|
public partial class frmSettings : Form {
|
2008-11-18 14:48:26 +00:00
|
|
|
bool _reducePriority;
|
2008-10-13 19:25:11 +00:00
|
|
|
CUEConfig _config;
|
2009-05-01 15:16:26 +00:00
|
|
|
private ShellIconMgr m_icon_mgr;
|
2008-10-13 19:25:11 +00:00
|
|
|
|
|
|
|
|
public frmSettings() {
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-01 15:16:26 +00:00
|
|
|
public ShellIconMgr IconMgr
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return m_icon_mgr;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
m_icon_mgr = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-13 19:25:11 +00:00
|
|
|
private void frmSettings_Load(object sender, EventArgs e) {
|
2008-11-18 14:48:26 +00:00
|
|
|
chkReducePriority.Checked = _reducePriority;
|
2008-10-13 19:25:11 +00:00
|
|
|
chkPreserveHTOA.Checked = _config.preserveHTOA;
|
|
|
|
|
chkAutoCorrectFilenames.Checked = _config.autoCorrectFilenames;
|
|
|
|
|
numericFLACCompressionLevel.Value = _config.flacCompressionLevel;
|
2009-05-01 15:16:26 +00:00
|
|
|
numFixWhenConfidence.Value = _config.fixOffsetMinimumConfidence;
|
|
|
|
|
numFixWhenPercent.Value = _config.fixOffsetMinimumTracksPercent;
|
2008-10-13 19:25:11 +00:00
|
|
|
numEncodeWhenConfidence.Value = _config.encodeWhenConfidence;
|
|
|
|
|
numEncodeWhenPercent.Value = _config.encodeWhenPercent;
|
2008-10-26 11:25:14 +00:00
|
|
|
chkEncodeWhenZeroOffset.Checked = _config.encodeWhenZeroOffset;
|
2008-10-13 19:25:11 +00:00
|
|
|
chkFLACVerify.Checked = _config.flacVerify;
|
2008-10-26 11:25:14 +00:00
|
|
|
chkWriteArTagsOnConvert.Checked = _config.writeArTagsOnConvert;
|
|
|
|
|
chkWriteARTagsOnVerify.Checked = _config.writeArTagsOnVerify;
|
2008-10-13 19:25:11 +00:00
|
|
|
if (_config.wvCompressionMode == 0) rbWVFast.Checked = true;
|
|
|
|
|
if (_config.wvCompressionMode == 1) rbWVNormal.Checked = true;
|
|
|
|
|
if (_config.wvCompressionMode == 2) rbWVHigh.Checked = true;
|
|
|
|
|
if (_config.wvCompressionMode == 3) rbWVVeryHigh.Checked = true;
|
|
|
|
|
chkWVExtraMode.Checked = (_config.wvExtraMode != 0);
|
|
|
|
|
if (_config.wvExtraMode != 0) numWVExtraMode.Value = _config.wvExtraMode;
|
2008-11-04 01:23:30 +00:00
|
|
|
chkWVStoreMD5.Checked = _config.wvStoreMD5;
|
2008-10-22 11:45:53 +00:00
|
|
|
switch (_config.apeCompressionLevel)
|
|
|
|
|
{
|
|
|
|
|
case 1: rbAPEfast.Checked = true; break;
|
|
|
|
|
case 2: rbAPEnormal.Checked = true; break;
|
|
|
|
|
case 3: rbAPEhigh.Checked = true; break;
|
|
|
|
|
case 4: rbAPEextrahigh.Checked = true; break;
|
|
|
|
|
case 5: rbAPEinsane.Checked = true; break;
|
|
|
|
|
}
|
2008-10-13 19:25:11 +00:00
|
|
|
chkKeepOriginalFilenames.Checked = _config.keepOriginalFilenames;
|
|
|
|
|
txtSingleFilenameFormat.Text = _config.singleFilenameFormat;
|
|
|
|
|
txtTrackFilenameFormat.Text = _config.trackFilenameFormat;
|
|
|
|
|
chkRemoveSpecial.Checked = _config.removeSpecial;
|
|
|
|
|
txtSpecialExceptions.Text = _config.specialExceptions;
|
|
|
|
|
chkReplaceSpaces.Checked = _config.replaceSpaces;
|
2008-10-26 11:25:14 +00:00
|
|
|
chkWriteArLogOnConvert.Checked = _config.writeArLogOnConvert;
|
|
|
|
|
chkWriteARLogOnVerify.Checked = _config.writeArLogOnVerify;
|
2008-10-14 04:48:52 +00:00
|
|
|
chkEmbedLog.Checked = _config.embedLog;
|
2009-01-17 04:09:38 +00:00
|
|
|
chkExtractLog.Checked = _config.extractLog;
|
2008-10-17 18:21:59 +00:00
|
|
|
chkFillUpCUE.Checked = _config.fillUpCUE;
|
2008-10-22 11:45:53 +00:00
|
|
|
chkFilenamesANSISafe.Checked = _config.filenamesANSISafe;
|
2008-11-04 01:23:30 +00:00
|
|
|
chkHDCDDetect.Checked = _config.detectHDCD;
|
|
|
|
|
chkHDCDDecode.Checked = _config.decodeHDCD;
|
|
|
|
|
chkHDCDStopLooking.Checked = _config.wait750FramesForHDCD;
|
|
|
|
|
chkCreateM3U.Checked = _config.createM3U;
|
|
|
|
|
chkCreateCUEFileWhenEmbedded.Checked = _config.createCUEFileWhenEmbedded;
|
2008-11-08 14:59:50 +00:00
|
|
|
chkTruncateExtra4206Samples.Checked = _config.truncate4608ExtraSamples;
|
2008-11-21 20:06:11 +00:00
|
|
|
numericLossyWAVQuality.Value = _config.lossyWAVQuality;
|
2008-11-22 15:10:33 +00:00
|
|
|
chkHDCDLW16.Checked = _config.decodeHDCDtoLW16;
|
|
|
|
|
chkHDCD24bit.Checked = _config.decodeHDCDto24bit;
|
2009-01-17 04:09:38 +00:00
|
|
|
chkOverwriteTags.Checked = _config.overwriteCUEData;
|
2009-05-01 15:16:26 +00:00
|
|
|
chkAllowMultipleInstances.Checked = !_config.oneInstance;
|
|
|
|
|
checkBoxWriteCUETags.Checked = _config.writeBasicTagsFromCUEData;
|
|
|
|
|
checkBoxCopyBasicTags.Checked = _config.copyBasicTags;
|
|
|
|
|
checkBoxCopyUnknownTags.Checked = _config.copyUnknownTags;
|
|
|
|
|
checkBoxCopyAlbumArt.Checked = _config.copyAlbumArt;
|
|
|
|
|
checkBoxEmbedAlbumArt.Checked = _config.embedAlbumArt;
|
|
|
|
|
checkBoxARVerifyUseSourceFolder.Checked = _config.arLogToSourceFolder;
|
|
|
|
|
checkBoxARLogVerbose.Checked = _config.arLogVerbose;
|
|
|
|
|
checkBoxFixToNearest.Checked = _config.fixOffsetToNearest;
|
|
|
|
|
textBoxARLogExtension.Text = _config.arLogExtension;
|
|
|
|
|
numericUpDownMaxResolution.Value = _config.maxAlbumArtSize;
|
2009-03-23 15:46:26 +00:00
|
|
|
|
2009-03-28 03:57:49 +00:00
|
|
|
string[] cultures = { "en-US", "de-DE", "ru-RU" };
|
2009-03-23 15:46:26 +00:00
|
|
|
foreach (string culture in cultures)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
CultureInfo info = CultureInfo.GetCultureInfo(culture);
|
|
|
|
|
comboLanguage.Items.Add(info);
|
|
|
|
|
if (culture == _config.language)
|
|
|
|
|
comboLanguage.SelectedItem = info;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (comboLanguage.SelectedItem == null)
|
|
|
|
|
comboLanguage.SelectedItem = comboLanguage.Items[0];
|
|
|
|
|
|
2009-05-01 15:16:26 +00:00
|
|
|
foreach (KeyValuePair<string, CUEToolsUDC> encoder in _config.encoders)
|
|
|
|
|
{
|
|
|
|
|
ListViewItem item = new ListViewItem(encoder.Key);
|
|
|
|
|
item.Tag = encoder.Value;
|
|
|
|
|
listViewEncoders.Items.Add(item);
|
|
|
|
|
}
|
|
|
|
|
//listViewEncoders.Items[0].Selected = true;
|
|
|
|
|
foreach (KeyValuePair<string, CUEToolsUDC> decoder in _config.decoders)
|
|
|
|
|
if (decoder.Value.path != null)
|
|
|
|
|
{
|
|
|
|
|
ListViewItem item = new ListViewItem(decoder.Key);
|
|
|
|
|
item.Tag = decoder.Value;
|
|
|
|
|
listViewDecoders.Items.Add(item);
|
|
|
|
|
}
|
|
|
|
|
//listViewDecoders.Items[0].Selected = true;
|
|
|
|
|
listViewFormats.SmallImageList = m_icon_mgr.ImageList;
|
|
|
|
|
labelEncoderExtension.ImageList = m_icon_mgr.ImageList;
|
|
|
|
|
labelDecoderExtension.ImageList = m_icon_mgr.ImageList;
|
|
|
|
|
foreach (KeyValuePair<string, CUEToolsFormat> format in _config.formats)
|
|
|
|
|
{
|
|
|
|
|
ListViewItem item = new ListViewItem(format.Key, "." + format.Key);
|
|
|
|
|
item.Tag = format.Value;
|
|
|
|
|
listViewFormats.Items.Add(item);
|
|
|
|
|
comboBoxEncoderExtension.Items.Add(format.Key);
|
|
|
|
|
comboBoxDecoderExtension.Items.Add(format.Key);
|
|
|
|
|
}
|
|
|
|
|
//listViewFormats.Items[0].Selected = true;
|
|
|
|
|
comboBoxFormatTagger.Items.Add(CUEToolsTagger.TagLibSharp);
|
|
|
|
|
comboBoxFormatTagger.Items.Add(CUEToolsTagger.APEv2);
|
|
|
|
|
comboBoxFormatTagger.Items.Add(CUEToolsTagger.ID3v2);
|
|
|
|
|
foreach (KeyValuePair<string, CUEToolsScript> script in _config.scripts)
|
|
|
|
|
{
|
|
|
|
|
ListViewItem item = new ListViewItem(script.Key);
|
|
|
|
|
item.Tag = script.Value;
|
|
|
|
|
listViewScripts.Items.Add(item);
|
|
|
|
|
}
|
|
|
|
|
listViewScriptConditions.Items[0].Tag = CUEAction.Verify;
|
|
|
|
|
listViewScriptConditions.Items[1].Tag = CUEAction.VerifyAndConvert;
|
|
|
|
|
listViewScriptConditions.Items[2].Tag = CUEAction.Convert;
|
|
|
|
|
|
2008-12-02 03:03:08 +00:00
|
|
|
EnableDisable();
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
|
2009-05-01 15:16:26 +00:00
|
|
|
//private void DictionaryToListView(IDictionary<> dict, ListView view)
|
|
|
|
|
//{
|
|
|
|
|
// foreach (KeyValuePair<string, object> format in dict)
|
|
|
|
|
// {
|
|
|
|
|
// ListViewItem item = new ListViewItem(format.Key, format.Key);
|
|
|
|
|
// item.Tag = format.Value;
|
|
|
|
|
// listViewFormats.Items.Add(item);
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
2008-10-13 19:25:11 +00:00
|
|
|
private void frmSettings_FormClosing(object sender, FormClosingEventArgs e) {
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-18 14:48:26 +00:00
|
|
|
public bool ReducePriority
|
|
|
|
|
{
|
|
|
|
|
get { return _reducePriority; }
|
|
|
|
|
set { _reducePriority = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-13 19:25:11 +00:00
|
|
|
public CUEConfig Config {
|
|
|
|
|
get { return _config; }
|
|
|
|
|
set { _config = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void chkWVExtraMode_CheckedChanged(object sender, EventArgs e) {
|
2008-12-02 03:03:08 +00:00
|
|
|
EnableDisable();
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnOK_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2009-05-01 15:16:26 +00:00
|
|
|
if (listViewFormats.SelectedIndices.Count > 0)
|
|
|
|
|
listViewFormats.Items[listViewFormats.SelectedIndices[0]].Selected = false;
|
|
|
|
|
if (listViewEncoders.SelectedIndices.Count > 0)
|
|
|
|
|
listViewEncoders.Items[listViewEncoders.SelectedIndices[0]].Selected = false;
|
|
|
|
|
if (listViewDecoders.SelectedIndices.Count > 0)
|
|
|
|
|
listViewDecoders.Items[listViewDecoders.SelectedIndices[0]].Selected = false;
|
|
|
|
|
if (listViewScripts.SelectedItems.Count > 0)
|
|
|
|
|
listViewScripts.SelectedItems[0].Selected = false;
|
|
|
|
|
|
2008-11-18 14:48:26 +00:00
|
|
|
_reducePriority = chkReducePriority.Checked;
|
2008-10-13 19:25:11 +00:00
|
|
|
_config.preserveHTOA = chkPreserveHTOA.Checked;
|
|
|
|
|
_config.autoCorrectFilenames = chkAutoCorrectFilenames.Checked;
|
|
|
|
|
_config.flacCompressionLevel = (uint)numericFLACCompressionLevel.Value;
|
2008-11-21 20:06:11 +00:00
|
|
|
_config.lossyWAVQuality = (int)numericLossyWAVQuality.Value;
|
2009-05-01 15:16:26 +00:00
|
|
|
_config.fixOffsetMinimumTracksPercent = (uint)numFixWhenPercent.Value;
|
|
|
|
|
_config.fixOffsetMinimumConfidence = (uint)numFixWhenConfidence.Value;
|
2008-10-13 19:25:11 +00:00
|
|
|
_config.encodeWhenPercent = (uint)numEncodeWhenPercent.Value;
|
|
|
|
|
_config.encodeWhenConfidence = (uint)numEncodeWhenConfidence.Value;
|
2008-10-26 11:25:14 +00:00
|
|
|
_config.encodeWhenZeroOffset = chkEncodeWhenZeroOffset.Checked;
|
2008-10-13 19:25:11 +00:00
|
|
|
_config.flacVerify = chkFLACVerify.Checked;
|
2008-10-26 11:25:14 +00:00
|
|
|
_config.writeArTagsOnConvert = chkWriteArTagsOnConvert.Checked;
|
|
|
|
|
_config.writeArTagsOnVerify = chkWriteARTagsOnVerify.Checked;
|
2008-10-13 19:25:11 +00:00
|
|
|
if (rbWVFast.Checked) _config.wvCompressionMode = 0;
|
|
|
|
|
else if (rbWVHigh.Checked) _config.wvCompressionMode = 2;
|
|
|
|
|
else if (rbWVVeryHigh.Checked) _config.wvCompressionMode = 3;
|
|
|
|
|
else _config.wvCompressionMode = 1;
|
|
|
|
|
if (!chkWVExtraMode.Checked) _config.wvExtraMode = 0;
|
|
|
|
|
else _config.wvExtraMode = (int) numWVExtraMode.Value;
|
2008-11-04 01:23:30 +00:00
|
|
|
_config.wvStoreMD5 = chkWVStoreMD5.Checked;
|
2008-10-22 11:45:53 +00:00
|
|
|
_config.apeCompressionLevel = (uint) (rbAPEfast.Checked ? 1 :
|
|
|
|
|
rbAPEnormal.Checked ? 2 :
|
|
|
|
|
rbAPEhigh.Checked ? 3 :
|
|
|
|
|
rbAPEextrahigh.Checked ? 4 :
|
|
|
|
|
rbAPEinsane.Checked ? 5 : 2);
|
2008-10-13 19:25:11 +00:00
|
|
|
_config.keepOriginalFilenames = chkKeepOriginalFilenames.Checked;
|
|
|
|
|
_config.singleFilenameFormat = txtSingleFilenameFormat.Text;
|
|
|
|
|
_config.trackFilenameFormat = txtTrackFilenameFormat.Text;
|
|
|
|
|
_config.removeSpecial = chkRemoveSpecial.Checked;
|
|
|
|
|
_config.specialExceptions = txtSpecialExceptions.Text;
|
|
|
|
|
_config.replaceSpaces = chkReplaceSpaces.Checked;
|
2008-10-26 11:25:14 +00:00
|
|
|
_config.writeArLogOnConvert = chkWriteArLogOnConvert.Checked;
|
|
|
|
|
_config.writeArLogOnVerify = chkWriteARLogOnVerify.Checked;
|
2008-10-14 04:48:52 +00:00
|
|
|
_config.embedLog = chkEmbedLog.Checked;
|
2009-01-17 04:09:38 +00:00
|
|
|
_config.extractLog = chkExtractLog.Checked;
|
2008-10-17 18:21:59 +00:00
|
|
|
_config.fillUpCUE = chkFillUpCUE.Checked;
|
2008-10-22 11:45:53 +00:00
|
|
|
_config.filenamesANSISafe = chkFilenamesANSISafe.Checked;
|
2008-11-04 01:23:30 +00:00
|
|
|
_config.detectHDCD = chkHDCDDetect.Checked;
|
|
|
|
|
_config.wait750FramesForHDCD = chkHDCDStopLooking.Checked;
|
|
|
|
|
_config.decodeHDCD = chkHDCDDecode.Checked;
|
|
|
|
|
_config.createM3U = chkCreateM3U.Checked;
|
|
|
|
|
_config.createCUEFileWhenEmbedded = chkCreateCUEFileWhenEmbedded.Checked;
|
2008-11-08 14:59:50 +00:00
|
|
|
_config.truncate4608ExtraSamples = chkTruncateExtra4206Samples.Checked;
|
2008-11-22 15:10:33 +00:00
|
|
|
_config.decodeHDCDtoLW16 = chkHDCDLW16.Checked;
|
|
|
|
|
_config.decodeHDCDto24bit = chkHDCD24bit.Checked;
|
2009-01-17 04:09:38 +00:00
|
|
|
_config.overwriteCUEData = chkOverwriteTags.Checked;
|
2009-05-01 15:16:26 +00:00
|
|
|
_config.oneInstance = !chkAllowMultipleInstances.Checked;
|
|
|
|
|
_config.writeBasicTagsFromCUEData = checkBoxWriteCUETags.Checked ;
|
|
|
|
|
_config.copyBasicTags = checkBoxCopyBasicTags.Checked;
|
|
|
|
|
_config.copyUnknownTags = checkBoxCopyUnknownTags.Checked;
|
|
|
|
|
_config.copyAlbumArt = checkBoxCopyAlbumArt.Checked;
|
|
|
|
|
_config.embedAlbumArt = checkBoxEmbedAlbumArt.Checked;
|
2009-02-19 04:09:59 +00:00
|
|
|
|
2009-05-01 15:16:26 +00:00
|
|
|
_config.arLogToSourceFolder = checkBoxARVerifyUseSourceFolder.Checked;
|
|
|
|
|
_config.arLogVerbose = checkBoxARLogVerbose.Checked;
|
|
|
|
|
_config.fixOffsetToNearest = checkBoxFixToNearest.Checked;
|
|
|
|
|
_config.arLogExtension = textBoxARLogExtension.Text;
|
|
|
|
|
_config.maxAlbumArtSize = (int) numericUpDownMaxResolution.Value;
|
2009-03-23 15:46:26 +00:00
|
|
|
|
|
|
|
|
_config.language = ((CultureInfo)comboLanguage.SelectedItem).Name;
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 03:03:08 +00:00
|
|
|
private void EnableDisable()
|
2008-10-13 19:25:11 +00:00
|
|
|
{
|
2008-12-02 03:03:08 +00:00
|
|
|
grpHDCD.Enabled = chkHDCDDetect.Checked;
|
|
|
|
|
chkHDCDLW16.Enabled = chkHDCDDetect.Checked && chkHDCDDecode.Checked;
|
|
|
|
|
chkHDCD24bit.Enabled = chkHDCDDetect.Checked && chkHDCDDecode.Checked;
|
|
|
|
|
|
|
|
|
|
chkRemoveSpecial.Enabled = chkFilenamesANSISafe.Checked;
|
|
|
|
|
txtSpecialExceptions.Enabled = chkRemoveSpecial.Checked && chkFilenamesANSISafe.Checked;
|
|
|
|
|
|
|
|
|
|
txtSpecialExceptions.Enabled = chkRemoveSpecial.Checked;
|
|
|
|
|
|
|
|
|
|
numWVExtraMode.Enabled = chkWVExtraMode.Checked;
|
2009-01-17 04:09:38 +00:00
|
|
|
|
|
|
|
|
chkOverwriteTags.Enabled = chkFillUpCUE.Checked;
|
2008-12-02 03:03:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void chkArFixOffset_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
EnableDisable();
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void chkArNoUnverifiedAudio_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2008-12-02 03:03:08 +00:00
|
|
|
EnableDisable();
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
2008-11-04 01:23:30 +00:00
|
|
|
|
|
|
|
|
private void chkHDCDDetect_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2008-12-02 03:03:08 +00:00
|
|
|
EnableDisable();
|
2008-11-04 01:23:30 +00:00
|
|
|
}
|
2008-11-18 14:48:26 +00:00
|
|
|
|
|
|
|
|
private void chkFilenamesANSISafe_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2008-12-02 03:03:08 +00:00
|
|
|
EnableDisable();
|
2008-11-18 14:48:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void chkRemoveSpecial_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2008-12-02 03:03:08 +00:00
|
|
|
EnableDisable();
|
2008-11-18 14:48:26 +00:00
|
|
|
}
|
2008-11-22 15:10:33 +00:00
|
|
|
|
|
|
|
|
private void chkHDCDDecode_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2008-12-02 03:03:08 +00:00
|
|
|
EnableDisable();
|
2008-11-22 15:10:33 +00:00
|
|
|
}
|
2009-01-17 04:09:38 +00:00
|
|
|
|
|
|
|
|
private void chkFillUpCUE_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
EnableDisable();
|
|
|
|
|
}
|
2009-05-01 15:16:26 +00:00
|
|
|
|
|
|
|
|
private void tabControl1_Deselecting(object sender, TabControlCancelEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (listViewFormats.SelectedItems.Count > 0)
|
|
|
|
|
listViewFormats.SelectedItems[0].Selected = false;
|
|
|
|
|
if (listViewEncoders.SelectedItems.Count > 0)
|
|
|
|
|
listViewEncoders.SelectedItems[0].Selected = false;
|
|
|
|
|
if (listViewDecoders.SelectedItems.Count > 0)
|
|
|
|
|
listViewDecoders.SelectedItems[0].Selected = false;
|
|
|
|
|
if (listViewScripts.SelectedItems.Count > 0)
|
|
|
|
|
listViewScripts.SelectedItems[0].Selected = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listViewFormats_BeforeLabelEdit(object sender, LabelEditEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CUEToolsFormat format = (CUEToolsFormat)listViewFormats.Items[e.Item].Tag;
|
|
|
|
|
if (format.builtin)
|
|
|
|
|
e.CancelEdit = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listViewFormats_AfterLabelEdit(object sender, LabelEditEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CUEToolsFormat format;
|
|
|
|
|
if (e.Label == null || _config.formats.TryGetValue(e.Label, out format))
|
|
|
|
|
{
|
|
|
|
|
e.CancelEdit = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
format = (CUEToolsFormat)listViewFormats.Items[e.Item].Tag;
|
|
|
|
|
if (format.builtin)
|
|
|
|
|
{
|
|
|
|
|
e.CancelEdit = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (KeyValuePair<string, CUEToolsUDC> encoder in _config.encoders)
|
|
|
|
|
if (encoder.Value.extension == format.extension)
|
|
|
|
|
encoder.Value.extension = e.Label;
|
|
|
|
|
|
|
|
|
|
foreach (KeyValuePair<string, CUEToolsUDC> decoder in _config.decoders)
|
|
|
|
|
if (decoder.Value.extension == format.extension)
|
|
|
|
|
decoder.Value.extension = e.Label;
|
|
|
|
|
|
|
|
|
|
comboBoxEncoderExtension.Items.Remove(format.extension);
|
|
|
|
|
comboBoxEncoderExtension.Items.Add(e.Label);
|
|
|
|
|
comboBoxDecoderExtension.Items.Remove(format.extension);
|
|
|
|
|
comboBoxDecoderExtension.Items.Add(e.Label);
|
|
|
|
|
|
|
|
|
|
_config.formats.Remove(format.extension);
|
|
|
|
|
format.extension = e.Label;
|
|
|
|
|
_config.formats.Add(format.extension, format);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listViewFormats_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
switch (e.KeyCode)
|
|
|
|
|
{
|
|
|
|
|
case Keys.Insert:
|
|
|
|
|
{
|
|
|
|
|
CUEToolsFormat format;
|
|
|
|
|
if (_config.formats.TryGetValue("new", out format))
|
|
|
|
|
return;
|
|
|
|
|
format = new CUEToolsFormat("new", CUEToolsTagger.TagLibSharp, true, true, false, false, false, null, null, null);
|
|
|
|
|
_config.formats.Add("new", format);
|
|
|
|
|
ListViewItem item = new ListViewItem(format.extension, "." + format.extension);
|
|
|
|
|
item.Tag = format;
|
|
|
|
|
listViewFormats.Items.Add(item);
|
|
|
|
|
comboBoxEncoderExtension.Items.Add(format.extension);
|
|
|
|
|
comboBoxDecoderExtension.Items.Add(format.extension);
|
|
|
|
|
item.BeginEdit();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.Delete:
|
|
|
|
|
{
|
|
|
|
|
if (listViewFormats.SelectedItems.Count <= 0)
|
|
|
|
|
return;
|
|
|
|
|
CUEToolsFormat format = (CUEToolsFormat)listViewFormats.SelectedItems[0].Tag;
|
|
|
|
|
if (format.builtin)
|
|
|
|
|
return;
|
|
|
|
|
List<string> decodersToRemove = new List<string>();
|
|
|
|
|
foreach (KeyValuePair<string, CUEToolsUDC> decoder in _config.decoders)
|
|
|
|
|
if (decoder.Value.extension == format.extension)
|
|
|
|
|
decodersToRemove.Add(decoder.Key);
|
|
|
|
|
foreach (string decoder in decodersToRemove)
|
|
|
|
|
{
|
|
|
|
|
_config.decoders.Remove(decoder);
|
|
|
|
|
foreach (ListViewItem item in listViewDecoders.Items)
|
|
|
|
|
if (item.Text == decoder)
|
|
|
|
|
{
|
|
|
|
|
item.Remove();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<string> encodersToRemove = new List<string>();
|
|
|
|
|
foreach (KeyValuePair<string, CUEToolsUDC> encoder in _config.encoders)
|
|
|
|
|
if (encoder.Value.extension == format.extension)
|
|
|
|
|
encodersToRemove.Add(encoder.Key);
|
|
|
|
|
foreach (string encoder in encodersToRemove)
|
|
|
|
|
{
|
|
|
|
|
_config.encoders.Remove(encoder);
|
|
|
|
|
foreach (ListViewItem item in listViewEncoders.Items)
|
|
|
|
|
if (item.Text == encoder)
|
|
|
|
|
{
|
|
|
|
|
item.Remove();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_config.formats.Remove(format.extension);
|
|
|
|
|
listViewFormats.SelectedItems[0].Remove();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listViewFormats_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.IsSelected)
|
|
|
|
|
{
|
|
|
|
|
CUEToolsFormat format = (CUEToolsFormat)e.Item.Tag;
|
|
|
|
|
if (format == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
comboFormatLosslessEncoder.Items.Clear();
|
|
|
|
|
foreach (KeyValuePair<string, CUEToolsUDC> encoder in _config.encoders)
|
|
|
|
|
if (encoder.Value.extension == format.extension && encoder.Value.lossless)
|
|
|
|
|
comboFormatLosslessEncoder.Items.Add(encoder.Key);
|
|
|
|
|
comboFormatLosslessEncoder.SelectedItem = format.encoderLossless;
|
|
|
|
|
comboFormatLosslessEncoder.Enabled = format.allowLossless;
|
|
|
|
|
|
|
|
|
|
comboFormatLossyEncoder.Items.Clear();
|
|
|
|
|
foreach (KeyValuePair<string, CUEToolsUDC> encoder in _config.encoders)
|
|
|
|
|
if (encoder.Value.extension == format.extension && !encoder.Value.lossless)
|
|
|
|
|
comboFormatLossyEncoder.Items.Add(encoder.Key);
|
|
|
|
|
comboFormatLossyEncoder.SelectedItem = format.encoderLossy;
|
|
|
|
|
comboFormatLossyEncoder.Enabled = format.allowLossy;
|
|
|
|
|
|
|
|
|
|
comboFormatDecoder.Items.Clear();
|
|
|
|
|
foreach (KeyValuePair<string, CUEToolsUDC> decoder in _config.decoders)
|
|
|
|
|
if (decoder.Value.extension == format.extension)
|
|
|
|
|
comboFormatDecoder.Items.Add(decoder.Key);
|
|
|
|
|
comboFormatDecoder.SelectedItem = format.decoder;
|
|
|
|
|
comboFormatDecoder.Enabled = format.allowLossless;
|
|
|
|
|
|
|
|
|
|
comboBoxFormatTagger.SelectedItem = format.tagger;
|
|
|
|
|
|
|
|
|
|
checkBoxFormatEmbedCUESheet.Checked = format.allowEmbed;
|
|
|
|
|
checkBoxFormatAllowLossless.Checked = format.allowLossless;
|
|
|
|
|
checkBoxFormatAllowLossy.Checked = format.allowLossy;
|
|
|
|
|
checkBoxFormatSupportsLossyWAV.Checked = format.allowLossyWAV;
|
|
|
|
|
|
|
|
|
|
comboBoxFormatTagger.Enabled =
|
|
|
|
|
checkBoxFormatEmbedCUESheet.Enabled =
|
|
|
|
|
checkBoxFormatSupportsLossyWAV.Enabled =
|
|
|
|
|
checkBoxFormatAllowLossless.Enabled =
|
|
|
|
|
checkBoxFormatAllowLossy.Enabled =
|
|
|
|
|
!format.builtin;
|
|
|
|
|
|
|
|
|
|
groupBoxFormat.Visible = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
groupBoxFormat.Visible = false;
|
|
|
|
|
|
|
|
|
|
CUEToolsFormat format = (CUEToolsFormat)e.Item.Tag;
|
|
|
|
|
if (format == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
format.encoderLossless = (string)comboFormatLosslessEncoder.SelectedItem;
|
|
|
|
|
format.encoderLossy = (string)comboFormatLossyEncoder.SelectedItem;
|
|
|
|
|
format.decoder = (string)comboFormatDecoder.SelectedItem;
|
|
|
|
|
if (!format.builtin)
|
|
|
|
|
{
|
|
|
|
|
format.tagger = (CUEToolsTagger)comboBoxFormatTagger.SelectedItem;
|
|
|
|
|
format.allowEmbed = checkBoxFormatEmbedCUESheet.Checked;
|
|
|
|
|
format.allowLossyWAV = checkBoxFormatSupportsLossyWAV.Checked;
|
|
|
|
|
format.allowLossless = checkBoxFormatAllowLossless.Checked;
|
|
|
|
|
format.allowLossy = checkBoxFormatAllowLossy.Checked;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void comboBoxEncoderExtension_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
labelEncoderExtension.ImageKey = "." + (string)comboBoxEncoderExtension.SelectedItem;
|
|
|
|
|
CUEToolsFormat format;
|
|
|
|
|
if (_config.formats.TryGetValue((string)comboBoxEncoderExtension.SelectedItem, out format))
|
|
|
|
|
{
|
|
|
|
|
checkBoxEncoderLossless.Enabled = format.allowLossless && format.allowLossy;
|
|
|
|
|
if (!checkBoxEncoderLossless.Enabled)
|
|
|
|
|
checkBoxEncoderLossless.Checked = format.allowLossless;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listViewEncoders_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.IsSelected)
|
|
|
|
|
{
|
|
|
|
|
CUEToolsUDC encoder = (CUEToolsUDC)e.Item.Tag;
|
|
|
|
|
if (encoder == null) return;
|
|
|
|
|
|
|
|
|
|
comboBoxEncoderExtension.Visible = true;
|
|
|
|
|
comboBoxEncoderExtension.SelectedItem = encoder.extension;
|
|
|
|
|
labelEncoderExtension.Visible = true;
|
|
|
|
|
if (encoder.path != null)
|
|
|
|
|
{
|
|
|
|
|
CUEToolsFormat format;
|
|
|
|
|
comboBoxEncoderExtension.Enabled = true;
|
|
|
|
|
groupBoxExternalEncoder.Visible = true;
|
|
|
|
|
textBoxEncoderPath.Text = encoder.path;
|
|
|
|
|
textBoxEncoderParameters.Text = encoder.parameters;
|
|
|
|
|
checkBoxEncoderLossless.Checked = encoder.lossless;
|
|
|
|
|
checkBoxEncoderLossless.Enabled = _config.formats.TryGetValue(encoder.extension, out format) && format.allowLossless && format.allowLossy;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
comboBoxEncoderExtension.Enabled = false;
|
|
|
|
|
switch (encoder.className)
|
|
|
|
|
{
|
|
|
|
|
case "FLACWriter":
|
|
|
|
|
groupBoxLibFLAC.Visible = true;
|
|
|
|
|
break;
|
|
|
|
|
case "WavPackWriter":
|
|
|
|
|
groupBoxLibWavpack.Visible = true;
|
|
|
|
|
break;
|
|
|
|
|
case "APEWriter":
|
|
|
|
|
groupBoxLibMAC_SDK.Visible = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CUEToolsUDC encoder = (CUEToolsUDC)e.Item.Tag;
|
|
|
|
|
if (encoder == null) return;
|
|
|
|
|
|
|
|
|
|
if (encoder.path != null)
|
|
|
|
|
{
|
|
|
|
|
if (encoder.extension != (string)comboBoxEncoderExtension.SelectedItem || encoder.lossless != checkBoxEncoderLossless.Checked)
|
|
|
|
|
{
|
|
|
|
|
if (listViewFormats.SelectedItems.Count > 0)
|
|
|
|
|
listViewFormats.SelectedItems[0].Selected = false;
|
|
|
|
|
CUEToolsFormat format;
|
|
|
|
|
if (_config.formats.TryGetValue(encoder.extension, out format))
|
|
|
|
|
{
|
|
|
|
|
if (format.encoderLossless == encoder.name)
|
|
|
|
|
format.encoderLossless = null;
|
|
|
|
|
if (format.encoderLossy == encoder.name)
|
|
|
|
|
format.encoderLossy = null;
|
|
|
|
|
}
|
|
|
|
|
encoder.extension = (string)comboBoxEncoderExtension.SelectedItem;
|
|
|
|
|
}
|
|
|
|
|
encoder.path = textBoxEncoderPath.Text;
|
|
|
|
|
encoder.parameters = textBoxEncoderParameters.Text;
|
|
|
|
|
encoder.lossless = checkBoxEncoderLossless.Checked;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
comboBoxEncoderExtension.Visible = false;
|
|
|
|
|
labelEncoderExtension.Visible = false;
|
|
|
|
|
groupBoxExternalEncoder.Visible = false;
|
|
|
|
|
groupBoxLibFLAC.Visible = false;
|
|
|
|
|
groupBoxLibWavpack.Visible = false;
|
|
|
|
|
groupBoxLibMAC_SDK.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listViewEncoders_BeforeLabelEdit(object sender, LabelEditEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CUEToolsUDC encoder = (CUEToolsUDC)listViewEncoders.Items[e.Item].Tag;
|
|
|
|
|
if (encoder.path == null)
|
|
|
|
|
e.CancelEdit = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listViewEncoders_AfterLabelEdit(object sender, LabelEditEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CUEToolsUDC encoder;
|
|
|
|
|
if (e.Label == null || _config.encoders.TryGetValue(e.Label, out encoder))
|
|
|
|
|
{
|
|
|
|
|
e.CancelEdit = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
encoder = (CUEToolsUDC) listViewEncoders.Items[e.Item].Tag;
|
|
|
|
|
if (listViewFormats.SelectedItems.Count > 0)
|
|
|
|
|
listViewFormats.SelectedItems[0].Selected = false;
|
|
|
|
|
if (_config.formats[encoder.extension].encoderLossless == encoder.name)
|
|
|
|
|
_config.formats[encoder.extension].encoderLossless = e.Label;
|
|
|
|
|
if (_config.formats[encoder.extension].encoderLossy == encoder.name)
|
|
|
|
|
_config.formats[encoder.extension].encoderLossy = e.Label;
|
|
|
|
|
_config.encoders.Remove(encoder.name);
|
|
|
|
|
encoder.name = e.Label;
|
|
|
|
|
_config.encoders.Add(encoder.name, encoder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listViewEncoders_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
switch (e.KeyCode)
|
|
|
|
|
{
|
|
|
|
|
case Keys.Insert:
|
|
|
|
|
{
|
|
|
|
|
CUEToolsUDC encoder;
|
|
|
|
|
if (_config.encoders.TryGetValue("new", out encoder))
|
|
|
|
|
return;
|
|
|
|
|
encoder = new CUEToolsUDC("new", "wav", true, "", "");
|
|
|
|
|
_config.encoders.Add("new", encoder);
|
|
|
|
|
ListViewItem item = new ListViewItem(encoder.name);
|
|
|
|
|
item.Tag = encoder;
|
|
|
|
|
listViewEncoders.Items.Add(item);
|
|
|
|
|
item.BeginEdit();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.Delete:
|
|
|
|
|
{
|
|
|
|
|
if (listViewEncoders.SelectedItems.Count <= 0)
|
|
|
|
|
return;
|
|
|
|
|
CUEToolsUDC encoder = (CUEToolsUDC)listViewEncoders.SelectedItems[0].Tag;
|
|
|
|
|
if (encoder.path == null)
|
|
|
|
|
return;
|
|
|
|
|
if (_config.formats[encoder.extension].encoderLossless == encoder.name)
|
|
|
|
|
_config.formats[encoder.extension].encoderLossless = null;
|
|
|
|
|
if (_config.formats[encoder.extension].encoderLossy == encoder.name)
|
|
|
|
|
_config.formats[encoder.extension].encoderLossy = null;
|
|
|
|
|
_config.encoders.Remove(encoder.name);
|
|
|
|
|
listViewEncoders.Items.Remove(listViewEncoders.SelectedItems[0]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listViewDecoders_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.IsSelected)
|
|
|
|
|
{
|
|
|
|
|
CUEToolsUDC decoder = (CUEToolsUDC)e.Item.Tag;
|
|
|
|
|
if (decoder == null) return;
|
|
|
|
|
comboBoxDecoderExtension.SelectedItem = decoder.extension;
|
|
|
|
|
comboBoxDecoderExtension.Visible = true;
|
|
|
|
|
labelDecoderExtension.Visible = true;
|
|
|
|
|
if (decoder.path != null)
|
|
|
|
|
{
|
|
|
|
|
comboBoxDecoderExtension.Enabled = true;
|
|
|
|
|
groupBoxExternalDecoder.Visible = true;
|
|
|
|
|
textBoxDecoderPath.Text = decoder.path;
|
|
|
|
|
textBoxDecoderParameters.Text = decoder.parameters;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
comboBoxDecoderExtension.Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CUEToolsUDC decoder = (CUEToolsUDC)e.Item.Tag;
|
|
|
|
|
if (decoder == null) return;
|
|
|
|
|
|
|
|
|
|
if (decoder.path != null)
|
|
|
|
|
{
|
|
|
|
|
decoder.path = textBoxDecoderPath.Text;
|
|
|
|
|
decoder.parameters = textBoxDecoderParameters.Text;
|
|
|
|
|
if (decoder.extension != (string)comboBoxDecoderExtension.SelectedItem)
|
|
|
|
|
{
|
|
|
|
|
if (listViewFormats.SelectedItems.Count > 0)
|
|
|
|
|
listViewFormats.SelectedItems[0].Selected = false;
|
|
|
|
|
CUEToolsFormat format;
|
|
|
|
|
if (_config.formats.TryGetValue(decoder.extension, out format) && format.decoder == decoder.name)
|
|
|
|
|
format.decoder = null;
|
|
|
|
|
decoder.extension = (string)comboBoxDecoderExtension.SelectedItem;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
comboBoxDecoderExtension.Visible = false;
|
|
|
|
|
labelDecoderExtension.Visible = false;
|
|
|
|
|
groupBoxExternalDecoder.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listViewDecoders_AfterLabelEdit(object sender, LabelEditEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CUEToolsUDC decoder;
|
|
|
|
|
if (e.Label == null || _config.decoders.TryGetValue(e.Label, out decoder))
|
|
|
|
|
{
|
|
|
|
|
e.CancelEdit = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
decoder = (CUEToolsUDC)listViewDecoders.Items[e.Item].Tag;
|
|
|
|
|
if (listViewFormats.SelectedItems.Count > 0)
|
|
|
|
|
listViewFormats.SelectedItems[0].Selected = false;
|
|
|
|
|
if (_config.formats[decoder.extension].decoder == decoder.name)
|
|
|
|
|
_config.formats[decoder.extension].decoder = e.Label;
|
|
|
|
|
_config.decoders.Remove(decoder.name);
|
|
|
|
|
decoder.name = e.Label;
|
|
|
|
|
_config.decoders.Add(decoder.name, decoder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listViewDecoders_BeforeLabelEdit(object sender, LabelEditEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CUEToolsUDC decoder = (CUEToolsUDC)listViewDecoders.Items[e.Item].Tag;
|
|
|
|
|
if (decoder.path == null)
|
|
|
|
|
e.CancelEdit = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listViewDecoders_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
switch (e.KeyCode)
|
|
|
|
|
{
|
|
|
|
|
case Keys.Insert:
|
|
|
|
|
{
|
|
|
|
|
CUEToolsUDC decoder;
|
|
|
|
|
if (_config.decoders.TryGetValue("new", out decoder))
|
|
|
|
|
return;
|
|
|
|
|
decoder = new CUEToolsUDC("new", "wav", true, "", "");
|
|
|
|
|
_config.decoders.Add("new", decoder);
|
|
|
|
|
ListViewItem item = new ListViewItem(decoder.name);
|
|
|
|
|
item.Tag = decoder;
|
|
|
|
|
listViewDecoders.Items.Add(item);
|
|
|
|
|
item.BeginEdit();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.Delete:
|
|
|
|
|
{
|
|
|
|
|
if (listViewDecoders.SelectedItems.Count <= 0)
|
|
|
|
|
return;
|
|
|
|
|
CUEToolsUDC decoder = (CUEToolsUDC)listViewDecoders.SelectedItems[0].Tag;
|
|
|
|
|
if (decoder.path == null)
|
|
|
|
|
return;
|
|
|
|
|
if (_config.formats[decoder.extension].decoder == decoder.name)
|
|
|
|
|
_config.formats[decoder.extension].decoder = null;
|
|
|
|
|
_config.decoders.Remove(decoder.name);
|
|
|
|
|
listViewDecoders.Items.Remove(listViewDecoders.SelectedItems[0]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void comboBoxDecoderExtension_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
labelDecoderExtension.ImageKey = "." + (string)comboBoxDecoderExtension.SelectedItem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listViewScripts_BeforeLabelEdit(object sender, LabelEditEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CUEToolsScript script = (CUEToolsScript)listViewScripts.Items[e.Item].Tag;
|
|
|
|
|
if (script.builtin)
|
|
|
|
|
e.CancelEdit = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listViewScripts_AfterLabelEdit(object sender, LabelEditEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CUEToolsScript script;
|
|
|
|
|
if (e.Label == null || _config.scripts.TryGetValue(e.Label, out script))
|
|
|
|
|
{
|
|
|
|
|
e.CancelEdit = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
script = (CUEToolsScript)listViewScripts.Items[e.Item].Tag;
|
|
|
|
|
if (script.builtin)
|
|
|
|
|
{
|
|
|
|
|
e.CancelEdit = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_config.scripts.Remove(script.name);
|
|
|
|
|
script.name = e.Label;
|
|
|
|
|
_config.scripts.Add(script.name, script);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listViewScripts_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
switch (e.KeyCode)
|
|
|
|
|
{
|
|
|
|
|
case Keys.Insert:
|
|
|
|
|
{
|
|
|
|
|
CUEToolsScript script;
|
|
|
|
|
if (_config.scripts.TryGetValue("new", out script))
|
|
|
|
|
return;
|
|
|
|
|
script = new CUEToolsScript("new", false, new CUEAction[] {}, "");
|
|
|
|
|
_config.scripts.Add("new", script);
|
|
|
|
|
ListViewItem item = new ListViewItem(script.name);
|
|
|
|
|
item.Tag = script;
|
|
|
|
|
listViewScripts.Items.Add(item);
|
|
|
|
|
item.BeginEdit();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case Keys.Delete:
|
|
|
|
|
{
|
|
|
|
|
if (listViewScripts.SelectedItems.Count <= 0)
|
|
|
|
|
return;
|
|
|
|
|
CUEToolsScript script = (CUEToolsScript)listViewScripts.SelectedItems[0].Tag;
|
|
|
|
|
if (script.builtin)
|
|
|
|
|
return;
|
|
|
|
|
_config.scripts.Remove(script.name);
|
|
|
|
|
listViewScripts.Items.Remove(listViewScripts.SelectedItems[0]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listViewScripts_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.IsSelected)
|
|
|
|
|
{
|
|
|
|
|
CUEToolsScript script = (CUEToolsScript)e.Item.Tag;
|
|
|
|
|
if (script == null) return;
|
|
|
|
|
foreach (ListViewItem item in listViewScriptConditions.Items)
|
|
|
|
|
item.Checked = script.conditions.Contains((CUEAction)item.Tag);
|
|
|
|
|
groupBoxScriptConditions.Visible = true;
|
|
|
|
|
richTextBoxScript.Text = script.code;
|
|
|
|
|
richTextBoxScript.Visible = true;
|
|
|
|
|
buttonScriptCompile.Visible = true;
|
|
|
|
|
|
|
|
|
|
groupBoxScriptConditions.Enabled =
|
|
|
|
|
buttonScriptCompile.Enabled =
|
|
|
|
|
!script.builtin;
|
|
|
|
|
richTextBoxScript.ReadOnly = script.builtin;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CUEToolsScript script = (CUEToolsScript)e.Item.Tag;
|
|
|
|
|
if (script == null) return;
|
|
|
|
|
if (!script.builtin)
|
|
|
|
|
{
|
|
|
|
|
script.conditions.Clear();
|
|
|
|
|
foreach (ListViewItem item in listViewScriptConditions.Items)
|
|
|
|
|
if (item.Checked)
|
|
|
|
|
script.conditions.Add((CUEAction)item.Tag);
|
|
|
|
|
script.code = richTextBoxScript.Text;
|
|
|
|
|
}
|
|
|
|
|
groupBoxScriptConditions.Visible = false;
|
|
|
|
|
richTextBoxScript.Visible = false;
|
|
|
|
|
buttonScriptCompile.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static int WordLength(string text, int pos)
|
|
|
|
|
{
|
2009-05-10 18:34:49 +00:00
|
|
|
if (pos >= text.Length)
|
|
|
|
|
return 1;
|
2009-05-01 15:16:26 +00:00
|
|
|
if ((text[pos] >= 'a' && text[pos] <= 'z') ||
|
|
|
|
|
(text[pos] >= 'A' && text[pos] <= 'Z') ||
|
|
|
|
|
(text[pos] == '_'))
|
|
|
|
|
{
|
|
|
|
|
for (int len = 1; len < text.Length - pos; len++)
|
|
|
|
|
{
|
|
|
|
|
bool ok = (text[pos + len] >= 'a' && text[pos + len] <= 'z') ||
|
|
|
|
|
(text[pos + len] >= 'A' && text[pos + len] <= 'Z') ||
|
|
|
|
|
(text[pos + len] == '_');
|
|
|
|
|
if (!ok)
|
|
|
|
|
return len;
|
|
|
|
|
}
|
|
|
|
|
return text.Length - pos;
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonScriptCompile_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
richTextBoxScript.SelectAll();
|
|
|
|
|
richTextBoxScript.SelectionColor = richTextBoxScript.ForeColor;
|
|
|
|
|
richTextBoxScript.DeselectAll();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
CUESheet.TryCompileScript(richTextBoxScript.Text);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
using (StringWriter sw = new StringWriter())
|
|
|
|
|
{
|
|
|
|
|
using (StringReader sr = new StringReader(ex.Message))
|
|
|
|
|
{
|
|
|
|
|
string lineStr;
|
|
|
|
|
while ((lineStr = sr.ReadLine()) != null)
|
|
|
|
|
{
|
|
|
|
|
string[] s = { ".tmp(" };
|
|
|
|
|
string[] n = lineStr.Split(s, 2, StringSplitOptions.None);
|
|
|
|
|
if (n.Length == 2)
|
|
|
|
|
{
|
|
|
|
|
string[] n2 = n[1].Split(")".ToCharArray(), 2);
|
|
|
|
|
if (n2.Length == 2)
|
|
|
|
|
{
|
|
|
|
|
string[] n3 = n2[0].Split(",".ToCharArray(), 2);
|
|
|
|
|
int row, col;
|
|
|
|
|
if (n3.Length == 2 && int.TryParse(n3[0], out row) && int.TryParse(n3[1], out col) && row > 1)
|
|
|
|
|
{
|
|
|
|
|
int pos = richTextBoxScript.GetFirstCharIndexFromLine(row - 2);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
{
|
|
|
|
|
pos += col - 1;
|
|
|
|
|
richTextBoxScript.Select(pos, WordLength(richTextBoxScript.Text, pos));
|
|
|
|
|
richTextBoxScript.SelectionColor = Color.Red;
|
|
|
|
|
richTextBoxScript.DeselectAll();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sw.WriteLine("({0}", n[1]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
sw.WriteLine("{0}", lineStr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MessageBox.Show(this, sw.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
MessageBox.Show(this, "Script compiled successfully.", "Ok", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
}
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
}
|