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-06-24 19:40:23 +00:00
|
|
|
private IIconManager m_icon_mgr;
|
2008-10-13 19:25:11 +00:00
|
|
|
|
|
|
|
|
public frmSettings() {
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-24 19:40:23 +00:00
|
|
|
public IIconManager IconMgr
|
2009-05-01 15:16:26 +00:00
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return m_icon_mgr;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
m_icon_mgr = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-06 13:03:02 +00:00
|
|
|
private void frmSettings_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
cUEConfigBindingSource.DataSource = _config;
|
|
|
|
|
|
2008-11-18 14:48:26 +00:00
|
|
|
chkReducePriority.Checked = _reducePriority;
|
2009-06-24 19:40:23 +00:00
|
|
|
checkBoxCheckForUpdates.Checked = _config.checkForUpdates;
|
2008-10-13 19:25:11 +00:00
|
|
|
chkAutoCorrectFilenames.Checked = _config.autoCorrectFilenames;
|
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;
|
2009-08-08 16:14:06 +00:00
|
|
|
chkWriteArTagsOnConvert.Checked = _config.writeArTagsOnEncode;
|
2008-10-26 11:25:14 +00:00
|
|
|
chkWriteARTagsOnVerify.Checked = _config.writeArTagsOnVerify;
|
2008-10-13 19:25:11 +00:00
|
|
|
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-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;
|
2009-08-06 13:03:02 +00:00
|
|
|
//checkBoxCopyAlbumArt.Checked = _config.copyAlbumArt;
|
2009-05-13 16:07:53 +00:00
|
|
|
checkBoxExtractAlbumArt.Checked = _config.extractAlbumArt;
|
2009-05-01 15:16:26 +00:00
|
|
|
checkBoxEmbedAlbumArt.Checked = _config.embedAlbumArt;
|
|
|
|
|
checkBoxARVerifyUseSourceFolder.Checked = _config.arLogToSourceFolder;
|
|
|
|
|
checkBoxARLogVerbose.Checked = _config.arLogVerbose;
|
|
|
|
|
checkBoxFixToNearest.Checked = _config.fixOffsetToNearest;
|
2009-08-06 13:03:02 +00:00
|
|
|
//textBoxARLogExtension.Text = _config.arLogFilenameFormat;
|
2009-05-01 15:16:26 +00:00
|
|
|
numericUpDownMaxResolution.Value = _config.maxAlbumArtSize;
|
2010-02-23 15:15:08 +00:00
|
|
|
checkBoxSeparateDecodingThread.Checked = _config.separateDecodingThread;
|
|
|
|
|
checkBoxUseSystemProxy.Checked = _config.useSystemProxySettings;
|
2009-03-23 15:46:26 +00:00
|
|
|
|
2009-06-24 19:40:23 +00:00
|
|
|
switch (_config.gapsHandling)
|
|
|
|
|
{
|
|
|
|
|
case CUEStyle.GapsAppended:
|
|
|
|
|
if (_config.preserveHTOA)
|
|
|
|
|
rbGapsPlusHTOA.Checked = true;
|
|
|
|
|
else
|
|
|
|
|
rbGapsAppended.Checked = true;
|
|
|
|
|
break;
|
|
|
|
|
case CUEStyle.GapsPrepended:
|
|
|
|
|
rbGapsPrepended.Checked = true;
|
|
|
|
|
break;
|
|
|
|
|
case CUEStyle.GapsLeftOut:
|
|
|
|
|
rbGapsLeftOut.Checked = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
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> 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);
|
|
|
|
|
}
|
2009-05-13 16:07:53 +00:00
|
|
|
ComponentResourceManager resources = new ComponentResourceManager(typeof(frmCUETools));
|
|
|
|
|
listViewScriptConditions.Items.Add(resources.GetString("rbActionVerify.Text").Replace("&", ""));
|
|
|
|
|
listViewScriptConditions.Items.Add(resources.GetString("rbActionEncode.Text").Replace("&", ""));
|
2009-05-01 15:16:26 +00:00
|
|
|
listViewScriptConditions.Items[0].Tag = CUEAction.Verify;
|
2009-08-08 16:14:06 +00:00
|
|
|
listViewScriptConditions.Items[1].Tag = CUEAction.Encode;
|
2009-05-01 15:16:26 +00:00
|
|
|
|
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 (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;
|
2009-06-24 19:40:23 +00:00
|
|
|
_config.checkForUpdates = checkBoxCheckForUpdates.Checked;
|
|
|
|
|
_config.preserveHTOA = rbGapsPlusHTOA.Checked;
|
|
|
|
|
_config.gapsHandling = rbGapsPrepended.Checked ? CUEStyle.GapsPrepended :
|
|
|
|
|
rbGapsLeftOut.Checked ? CUEStyle.GapsLeftOut :
|
|
|
|
|
CUEStyle.GapsAppended;
|
2008-10-13 19:25:11 +00:00
|
|
|
_config.autoCorrectFilenames = chkAutoCorrectFilenames.Checked;
|
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;
|
2009-08-08 16:14:06 +00:00
|
|
|
_config.writeArTagsOnEncode = chkWriteArTagsOnConvert.Checked;
|
2008-10-26 11:25:14 +00:00
|
|
|
_config.writeArTagsOnVerify = chkWriteARTagsOnVerify.Checked;
|
2008-10-13 19:25:11 +00:00
|
|
|
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-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;
|
2009-08-06 13:03:02 +00:00
|
|
|
//_config.copyAlbumArt = checkBoxCopyAlbumArt.Checked;
|
2009-05-13 16:07:53 +00:00
|
|
|
_config.extractAlbumArt = checkBoxExtractAlbumArt.Checked;
|
2009-05-01 15:16:26 +00:00
|
|
|
_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;
|
2009-08-06 13:03:02 +00:00
|
|
|
//_config.arLogFilenameFormat = textBoxARLogExtension.Text;
|
2009-05-01 15:16:26 +00:00
|
|
|
_config.maxAlbumArtSize = (int) numericUpDownMaxResolution.Value;
|
2010-02-23 15:15:08 +00:00
|
|
|
_config.separateDecodingThread = checkBoxSeparateDecodingThread.Checked;
|
|
|
|
|
_config.useSystemProxySettings = checkBoxUseSystemProxy.Checked;
|
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 (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;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-06 13:03:02 +00:00
|
|
|
foreach (CUEToolsUDC encoder in _config.encoders)
|
|
|
|
|
if (encoder.extension == format.extension)
|
|
|
|
|
encoder.extension = e.Label;
|
2009-05-01 15:16:26 +00:00
|
|
|
|
|
|
|
|
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>();
|
2009-08-06 13:03:02 +00:00
|
|
|
foreach (CUEToolsUDC encoder in _config.encoders)
|
|
|
|
|
if (encoder.extension == format.extension)
|
|
|
|
|
encodersToRemove.Add(encoder.name);
|
2009-05-01 15:16:26 +00:00
|
|
|
foreach (string encoder in encodersToRemove)
|
2009-08-06 13:03:02 +00:00
|
|
|
_config.encoders.Remove(_config.encoders[encoder]);
|
|
|
|
|
comboBoxEncoderExtension.Items.Remove(format.extension);
|
|
|
|
|
comboBoxDecoderExtension.Items.Remove(format.extension);
|
2009-05-01 15:16:26 +00:00
|
|
|
_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();
|
2009-08-06 13:03:02 +00:00
|
|
|
foreach (CUEToolsUDC encoder in _config.encoders)
|
|
|
|
|
if (encoder.extension == format.extension && encoder.lossless)
|
|
|
|
|
comboFormatLosslessEncoder.Items.Add(encoder);
|
2009-05-01 15:16:26 +00:00
|
|
|
comboFormatLosslessEncoder.SelectedItem = format.encoderLossless;
|
|
|
|
|
comboFormatLosslessEncoder.Enabled = format.allowLossless;
|
|
|
|
|
|
|
|
|
|
comboFormatLossyEncoder.Items.Clear();
|
2009-08-06 13:03:02 +00:00
|
|
|
foreach (CUEToolsUDC encoder in _config.encoders)
|
|
|
|
|
if (encoder.extension == format.extension && !encoder.lossless)
|
|
|
|
|
comboFormatLossyEncoder.Items.Add(encoder);
|
2009-05-01 15:16:26 +00:00
|
|
|
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;
|
|
|
|
|
|
2009-08-06 13:03:02 +00:00
|
|
|
format.encoderLossless = (CUEToolsUDC)comboFormatLosslessEncoder.SelectedItem;
|
|
|
|
|
format.encoderLossy = (CUEToolsUDC)comboFormatLossyEncoder.SelectedItem;
|
2009-05-01 15:16:26 +00:00
|
|
|
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)
|
|
|
|
|
{
|
2009-08-06 13:03:02 +00:00
|
|
|
// Setting DataSourceUpdateMode to OnPropertyChanged doesn't seem
|
|
|
|
|
// to do the trick, so updating manually
|
|
|
|
|
comboBoxEncoderExtension.DataBindings["SelectedItem"].WriteValue();
|
2009-05-01 15:16:26 +00:00
|
|
|
}
|
|
|
|
|
|
2009-08-06 13:03:02 +00:00
|
|
|
private void encodersBindingSource_CurrentItemChanged(object sender, EventArgs e)
|
2009-05-01 15:16:26 +00:00
|
|
|
{
|
2009-08-06 13:03:02 +00:00
|
|
|
CUEToolsUDC encoder = encodersBindingSource.Current as CUEToolsUDC;
|
|
|
|
|
CUEToolsFormat format = _config.formats[encoder.extension]; // _config.formats.TryGetValue(encoder.extension, out format)
|
2009-05-01 15:16:26 +00:00
|
|
|
|
2009-08-06 13:03:02 +00:00
|
|
|
labelEncoderExtension.Visible = encoder != null;
|
|
|
|
|
comboBoxEncoderExtension.Visible = encoder != null;
|
|
|
|
|
comboBoxEncoderExtension.Enabled = encoder != null && encoder.path != null;
|
|
|
|
|
groupBoxExternalEncoder.Visible = encoder != null && encoder.path != null;
|
2010-02-06 23:17:07 +00:00
|
|
|
groupBoxFlaCudaOptions.Visible = encoder != null && encoder.path == null && encoder.type.Name == "FlaCudaWriter";
|
|
|
|
|
groupBoxLibFLAC.Visible = encoder != null && encoder.path == null && encoder.type.Name == "FLACWriter";
|
|
|
|
|
groupBoxLibWavpack.Visible = encoder != null && encoder.path == null && encoder.type.Name == "WavPackWriter";
|
|
|
|
|
groupBoxLibMAC_SDK.Visible = encoder != null && encoder.path == null && encoder.type.Name == "APEWriter";
|
2009-08-06 13:03:02 +00:00
|
|
|
checkBoxEncoderLossless.Enabled = encoder != null && format != null && format.allowLossless && format.allowLossy;
|
|
|
|
|
if (!checkBoxEncoderLossless.Enabled && encoder != null && format != null && encoder.Lossless != format.allowLossless)
|
|
|
|
|
encoder.Lossless = format.allowLossless;
|
2009-05-01 15:16:26 +00:00
|
|
|
|
2009-08-06 13:03:02 +00:00
|
|
|
foreach (KeyValuePair<string, CUEToolsFormat> fmtEntry in _config.formats)
|
2009-05-01 15:16:26 +00:00
|
|
|
{
|
2009-08-06 13:03:02 +00:00
|
|
|
CUEToolsFormat fmt = fmtEntry.Value;
|
|
|
|
|
if (fmt.encoderLossless == encoder && (fmt.extension != encoder.extension || !encoder.Lossless))
|
|
|
|
|
fmt.encoderLossless = null;
|
|
|
|
|
if (fmt.encoderLossy == encoder && (fmt.extension != encoder.extension || encoder.Lossless))
|
|
|
|
|
fmt.encoderLossy = null;
|
2009-05-01 15:16:26 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-06 13:03:02 +00:00
|
|
|
private void listBoxEncoders_KeyDown(object sender, KeyEventArgs e)
|
2009-05-01 15:16:26 +00:00
|
|
|
{
|
|
|
|
|
switch (e.KeyCode)
|
|
|
|
|
{
|
|
|
|
|
case Keys.Insert:
|
2009-08-06 13:03:02 +00:00
|
|
|
buttonEncoderAdd_Click(sender, e);
|
|
|
|
|
break;
|
2009-05-01 15:16:26 +00:00
|
|
|
case Keys.Delete:
|
2009-08-06 13:03:02 +00:00
|
|
|
buttonEncoderDelete_Click(sender, e);
|
|
|
|
|
break;
|
2009-05-01 15:16:26 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
2009-06-24 19:40:23 +00:00
|
|
|
decoder = new CUEToolsUDC("new", "wav", true, "", "", "", "");
|
2009-05-01 15:16:26 +00:00
|
|
|
_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);
|
|
|
|
|
}
|
2009-08-06 13:03:02 +00:00
|
|
|
|
|
|
|
|
private void buttonEncoderAdd_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
encodersBindingSource.AddNew();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonEncoderDelete_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CUEToolsUDC encoder = encodersBindingSource.Current as CUEToolsUDC;
|
|
|
|
|
if (encoder == null || !encoder.CanBeDeleted)
|
|
|
|
|
return;
|
|
|
|
|
if (_config.formats[encoder.extension].encoderLossless == encoder)
|
|
|
|
|
_config.formats[encoder.extension].encoderLossless = null;
|
|
|
|
|
if (_config.formats[encoder.extension].encoderLossy == encoder)
|
|
|
|
|
_config.formats[encoder.extension].encoderLossy = null;
|
|
|
|
|
encodersBindingSource.RemoveCurrent();
|
|
|
|
|
}
|
2008-10-13 19:25:11 +00:00
|
|
|
}
|
|
|
|
|
}
|