EAC Plugin: autoupdating, saving window size

This commit is contained in:
chudov
2012-01-19 08:18:10 +00:00
parent bc3c8a1074
commit 2161457451
11 changed files with 586 additions and 338 deletions

View File

@@ -150,6 +150,7 @@
this.Padding = new System.Windows.Forms.Padding(10);
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "CTDB Metadata Lookup";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormMetadata_FormClosing);
this.Load += new System.EventHandler(this.FormMetadata_Load);
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);

View File

@@ -8,6 +8,7 @@ using System.Windows.Forms;
using CUETools.CTDB.EACPlugin.Properties;
using System.Net;
using System.IO;
using AudioDataPlugIn;
namespace CUETools.CTDB.EACPlugin
{
@@ -25,6 +26,7 @@ namespace CUETools.CTDB.EACPlugin
this.cdinfo = cdinfo;
this.cover = cover;
this.InitializeComponent();
this.Size = Options.MetadataWindowSize;
}
public CTDBResponseMeta Meta
@@ -62,54 +64,37 @@ namespace CUETools.CTDB.EACPlugin
#endif
this.ctdb.ContactDB(server, this.agent, null, false, false,
AudioDataPlugIn.Options.MetadataSearch);
foreach (var metadata in ctdb.Metadata)
if (this.cdinfo)
{
backgroundWorker1.ReportProgress(0, metadata);
foreach (var metadata in ctdb.Metadata)
{
backgroundWorker1.ReportProgress(0, metadata);
}
}
var knownUrls = new List<string>();
foreach (var metadata in ctdb.Metadata)
{
if (metadata.coverart == null || !this.cover)
continue;
if (!this.cdinfo)
{
backgroundWorker1.ReportProgress(0, metadata);
}
foreach (var coverart in metadata.coverart)
{
if (knownUrls.Contains(coverart.uri) || !coverart.primary)
var uri = Options.CoversSearch == CTDBCoversSearch.Large ?
coverart.uri : coverart.uri150 ?? coverart.uri;
if (knownUrls.Contains(uri) || !coverart.primary)
continue;
try
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(coverart.uri);
req.Method = "GET";
//req.Proxy = proxy;
//req.UserAgent = this.userAgent;
//req.Timeout = connectTimeout;
//req.ReadWriteTimeout = socketTimeout;
using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse())
{
if (resp.StatusCode != HttpStatusCode.OK)
continue;
using (var responseStream = resp.GetResponseStream())
using (var reader = new BinaryReader(responseStream))
{
MemoryStream ms = new MemoryStream();
var buf = new byte[4096];
do
{
int len = responseStream.Read(buf, 0, buf.Length);
if (len <= 0) break;
ms.Write(buf, 0, len);
} while (true);
var img = new InternetImage();
img.URL = coverart.uri;
img.Data = ms.ToArray();
img.Image = new Bitmap(ms);
knownUrls.Add(coverart.uri);
backgroundWorker1.ReportProgress(0, img);
}
}
}
catch
{
}
var ms = new MemoryStream();
if (!this.ctdb.FetchFile(uri, ms))
continue;
var img = new InternetImage();
img.URL = uri;
img.Data = ms.ToArray();
img.Image = new Bitmap(ms);
knownUrls.Add(uri);
backgroundWorker1.ReportProgress(0, img);
}
}
}
@@ -214,21 +199,32 @@ namespace CUETools.CTDB.EACPlugin
this.progressBar1.Visible = false;
this.button1.Visible = true;
this.button2.Visible = true;
if (listView1.Items.Count == 0)
if (listView1.Items.Count == 0 && flowLayoutPanel1.Controls.Count == 0)
{
this.DialogResult = DialogResult.Cancel;
return;
}
listView1.Items[0].Selected = true;
if (listView1.Items.Count == 1)
if (listView1.Items.Count > 0)
listView1.Items[0].Selected = true;
if (flowLayoutPanel1.Controls.Count > 0 && m_currently_selected == null)
{
m_currently_selected = flowLayoutPanel1.Controls[0] as ImagePreview;
m_currently_selected.Selected = true;
}
if ((!this.cdinfo || listView1.Items.Count == 1) && (!this.cover || flowLayoutPanel1.Controls.Count == 1))
{
this.DialogResult = DialogResult.OK;
}
}
private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
{
var ht = listView1.HitTest(e.Location);
if (ht.Item != null)
this.DialogResult = DialogResult.OK;
if (this.cdinfo)
{
var ht = listView1.HitTest(e.Location);
if (ht.Item != null)
this.DialogResult = DialogResult.OK;
}
}
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
@@ -272,5 +268,10 @@ namespace CUETools.CTDB.EACPlugin
this.listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
}
}
private void FormMetadata_FormClosing(object sender, FormClosingEventArgs e)
{
Options.MetadataWindowSize = this.Size;
}
}
}

View File

@@ -6,6 +6,7 @@ using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CUETools.CTDB.EACPlugin.Properties;
using System.IO;
namespace CUETools.CTDB.EACPlugin
{
@@ -14,6 +15,7 @@ namespace CUETools.CTDB.EACPlugin
private CUEToolsDB ctdb;
private int confidence, quality;
private string artist, title, agent, drivename;
private CTDBResponse resp;
public FormSubmitParity(CUEToolsDB ctdb, string agent, string drivename, int confidence, int quality, string artist, string title)
{
@@ -41,19 +43,41 @@ namespace CUETools.CTDB.EACPlugin
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
this.ctdb.UploadHelper.onProgress += UploadProgress;
if (resp == null)
{
#if DEBUG
string server = "hq.cuetools.net";
string server = "hq.cuetools.net";
#else
string server = null;
string server = null;
#endif
this.ctdb.ContactDB(server, this.agent, this.drivename, true, true, CTDBMetadataSearch.None);
this.ctdb.DoVerify();
this.ctdb.Submit(this.confidence, this.quality, this.artist, this.title, null);
this.ctdb.ContactDB(server, this.agent, this.drivename, true, true, CTDBMetadataSearch.None);
this.ctdb.DoVerify();
resp = this.ctdb.Submit(this.confidence, this.quality, this.artist, this.title, null);
} else
{
var url = resp.updateurl;
resp = null;
var temp = Path.GetTempPath() + Path.GetFileName(url.Substring(url.LastIndexOf('/') + 1));
bool ok = false;
using (var stream = new FileStream(temp, FileMode.Create))
ok = this.ctdb.FetchFile(url, stream);
if (ok)
System.Diagnostics.Process.Start(temp);
}
this.ctdb.UploadHelper.onProgress -= UploadProgress;
}
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (resp != null && resp.updateurl != null)
{
DialogResult mb = MessageBox.Show(this, (resp.updatemsg ?? "") + " Do you wish to download and install it?", "An updated version of CTDB plugin is available", MessageBoxButtons.OKCancel);
if (mb == DialogResult.OK)
{
this.backgroundWorker1.RunWorkerAsync();
return;
}
}
this.DialogResult = DialogResult.OK;
}

View File

@@ -12,6 +12,7 @@ using CUETools.Codecs;
using CUETools.CTDB;
using CUETools.CTDB.EACPlugin.Properties;
using System.Drawing.Imaging;
using AudioDataPlugIn;
namespace MetadataPlugIn
{
@@ -24,6 +25,9 @@ namespace MetadataPlugIn
{
public bool GetCDInformation(CCDMetadata data, bool cdinfo, bool cover, bool lyrics)
{
if (Options.CoversSearch == CTDBCoversSearch.None)
cover = false;
if (!cdinfo && !cover)
return false;

View File

@@ -29,161 +29,202 @@ namespace AudioDataPlugIn
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.radioButtonMBExtensive = new System.Windows.Forms.RadioButton();
this.radioButtonMBFast = new System.Windows.Forms.RadioButton();
this.radioButtonMBDefault = new System.Windows.Forms.RadioButton();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.buttonOk = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(127, 16);
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(182, 17);
this.label1.TabIndex = 0;
this.label1.Text = "CUETools DB Plugin V2.1.4";
//
// label2
//
this.label2.Location = new System.Drawing.Point(127, 82);
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(307, 42);
this.label2.TabIndex = 1;
this.label2.Text = "Copyright (c) 2011-12 Gregory S. Chudov";
//
// linkLabel1
//
this.linkLabel1.AutoSize = true;
this.linkLabel1.Location = new System.Drawing.Point(127, 44);
this.linkLabel1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(209, 17);
this.linkLabel1.TabIndex = 3;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "http://db.cuetools.net/about.php";
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
//
// pictureBox1
//
this.pictureBox1.Image = global::CUETools.CTDB.EACPlugin.Properties.Resources.ctdb64;
this.pictureBox1.Location = new System.Drawing.Point(17, 16);
this.pictureBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(85, 79);
this.pictureBox1.TabIndex = 4;
this.pictureBox1.TabStop = false;
//
// radioButtonMBExtensive
//
this.radioButtonMBExtensive.AutoSize = true;
this.radioButtonMBExtensive.Location = new System.Drawing.Point(8, 20);
this.radioButtonMBExtensive.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.radioButtonMBExtensive.Name = "radioButtonMBExtensive";
this.radioButtonMBExtensive.Size = new System.Drawing.Size(89, 21);
this.radioButtonMBExtensive.TabIndex = 6;
this.radioButtonMBExtensive.TabStop = true;
this.radioButtonMBExtensive.Text = "Extensive";
this.radioButtonMBExtensive.UseVisualStyleBackColor = true;
//
// radioButtonMBFast
//
this.radioButtonMBFast.AutoSize = true;
this.radioButtonMBFast.Location = new System.Drawing.Point(8, 62);
this.radioButtonMBFast.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.radioButtonMBFast.Name = "radioButtonMBFast";
this.radioButtonMBFast.Size = new System.Drawing.Size(56, 21);
this.radioButtonMBFast.TabIndex = 7;
this.radioButtonMBFast.TabStop = true;
this.radioButtonMBFast.Text = "Fast";
this.radioButtonMBFast.UseVisualStyleBackColor = true;
//
// radioButtonMBDefault
//
this.radioButtonMBDefault.AutoSize = true;
this.radioButtonMBDefault.Location = new System.Drawing.Point(8, 41);
this.radioButtonMBDefault.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.radioButtonMBDefault.Name = "radioButtonMBDefault";
this.radioButtonMBDefault.Size = new System.Drawing.Size(74, 21);
this.radioButtonMBDefault.TabIndex = 8;
this.radioButtonMBDefault.TabStop = true;
this.radioButtonMBDefault.Text = "Default";
this.radioButtonMBDefault.UseVisualStyleBackColor = true;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.radioButtonMBDefault);
this.groupBox1.Controls.Add(this.radioButtonMBExtensive);
this.groupBox1.Controls.Add(this.radioButtonMBFast);
this.groupBox1.Location = new System.Drawing.Point(16, 156);
this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.groupBox1.Size = new System.Drawing.Size(191, 107);
this.groupBox1.TabIndex = 15;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Metadata search mode:";
//
// buttonOk
//
this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK;
this.buttonOk.Location = new System.Drawing.Point(404, 233);
this.buttonOk.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.buttonOk.Name = "buttonOk";
this.buttonOk.Size = new System.Drawing.Size(100, 31);
this.buttonOk.TabIndex = 17;
this.buttonOk.Text = "OK";
this.buttonOk.UseVisualStyleBackColor = true;
this.buttonOk.Click += new System.EventHandler(this.button2_Click);
//
// buttonCancel
//
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.Location = new System.Drawing.Point(404, 194);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(100, 31);
this.buttonCancel.TabIndex = 19;
this.buttonCancel.Text = "Cancel";
this.buttonCancel.UseVisualStyleBackColor = true;
//
// Options
//
this.AcceptButton = this.buttonOk;
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.buttonCancel;
this.ClientSize = new System.Drawing.Size(520, 279);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOk);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.linkLabel1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Options";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Options";
this.Load += new System.EventHandler(this.Options_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.radioButtonMBExtensive = new System.Windows.Forms.RadioButton();
this.radioButtonMBFast = new System.Windows.Forms.RadioButton();
this.radioButtonMBDefault = new System.Windows.Forms.RadioButton();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.buttonOk = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.radioButtonCoversNone = new System.Windows.Forms.RadioButton();
this.radioButtonCoversSmall = new System.Windows.Forms.RadioButton();
this.radioButtonCoversLarge = new System.Windows.Forms.RadioButton();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(95, 13);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(139, 13);
this.label1.TabIndex = 0;
this.label1.Text = "CUETools DB Plugin V2.1.4";
//
// label2
//
this.label2.Location = new System.Drawing.Point(95, 67);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(230, 34);
this.label2.TabIndex = 1;
this.label2.Text = "Copyright (c) 2011-12 Gregory S. Chudov";
//
// linkLabel1
//
this.linkLabel1.AutoSize = true;
this.linkLabel1.Location = new System.Drawing.Point(95, 36);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(164, 13);
this.linkLabel1.TabIndex = 3;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "http://db.cuetools.net/about.php";
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
//
// pictureBox1
//
this.pictureBox1.Image = global::CUETools.CTDB.EACPlugin.Properties.Resources.ctdb64;
this.pictureBox1.Location = new System.Drawing.Point(13, 13);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(64, 64);
this.pictureBox1.TabIndex = 4;
this.pictureBox1.TabStop = false;
//
// radioButtonMBExtensive
//
this.radioButtonMBExtensive.AutoSize = true;
this.radioButtonMBExtensive.Location = new System.Drawing.Point(6, 16);
this.radioButtonMBExtensive.Name = "radioButtonMBExtensive";
this.radioButtonMBExtensive.Size = new System.Drawing.Size(71, 17);
this.radioButtonMBExtensive.TabIndex = 6;
this.radioButtonMBExtensive.TabStop = true;
this.radioButtonMBExtensive.Text = "Extensive";
this.radioButtonMBExtensive.UseVisualStyleBackColor = true;
//
// radioButtonMBFast
//
this.radioButtonMBFast.AutoSize = true;
this.radioButtonMBFast.Location = new System.Drawing.Point(6, 50);
this.radioButtonMBFast.Name = "radioButtonMBFast";
this.radioButtonMBFast.Size = new System.Drawing.Size(45, 17);
this.radioButtonMBFast.TabIndex = 7;
this.radioButtonMBFast.TabStop = true;
this.radioButtonMBFast.Text = "Fast";
this.radioButtonMBFast.UseVisualStyleBackColor = true;
//
// radioButtonMBDefault
//
this.radioButtonMBDefault.AutoSize = true;
this.radioButtonMBDefault.Location = new System.Drawing.Point(6, 33);
this.radioButtonMBDefault.Name = "radioButtonMBDefault";
this.radioButtonMBDefault.Size = new System.Drawing.Size(59, 17);
this.radioButtonMBDefault.TabIndex = 8;
this.radioButtonMBDefault.TabStop = true;
this.radioButtonMBDefault.Text = "Default";
this.radioButtonMBDefault.UseVisualStyleBackColor = true;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.radioButtonMBFast);
this.groupBox1.Controls.Add(this.radioButtonMBDefault);
this.groupBox1.Controls.Add(this.radioButtonMBExtensive);
this.groupBox1.Location = new System.Drawing.Point(12, 127);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(136, 87);
this.groupBox1.TabIndex = 15;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Metadata search mode:";
//
// buttonOk
//
this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK;
this.buttonOk.Location = new System.Drawing.Point(303, 189);
this.buttonOk.Name = "buttonOk";
this.buttonOk.Size = new System.Drawing.Size(75, 25);
this.buttonOk.TabIndex = 17;
this.buttonOk.Text = "OK";
this.buttonOk.UseVisualStyleBackColor = true;
this.buttonOk.Click += new System.EventHandler(this.button2_Click);
//
// buttonCancel
//
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.Location = new System.Drawing.Point(303, 158);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 25);
this.buttonCancel.TabIndex = 19;
this.buttonCancel.Text = "Cancel";
this.buttonCancel.UseVisualStyleBackColor = true;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.radioButtonCoversNone);
this.groupBox2.Controls.Add(this.radioButtonCoversSmall);
this.groupBox2.Controls.Add(this.radioButtonCoversLarge);
this.groupBox2.Location = new System.Drawing.Point(154, 127);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(136, 87);
this.groupBox2.TabIndex = 16;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Covers search mode:";
//
// radioButtonCoversNone
//
this.radioButtonCoversNone.AutoSize = true;
this.radioButtonCoversNone.Location = new System.Drawing.Point(6, 50);
this.radioButtonCoversNone.Name = "radioButtonCoversNone";
this.radioButtonCoversNone.Size = new System.Drawing.Size(51, 17);
this.radioButtonCoversNone.TabIndex = 7;
this.radioButtonCoversNone.TabStop = true;
this.radioButtonCoversNone.Text = "None";
this.radioButtonCoversNone.UseVisualStyleBackColor = true;
//
// radioButtonCoversSmall
//
this.radioButtonCoversSmall.AutoSize = true;
this.radioButtonCoversSmall.Location = new System.Drawing.Point(6, 33);
this.radioButtonCoversSmall.Name = "radioButtonCoversSmall";
this.radioButtonCoversSmall.Size = new System.Drawing.Size(50, 17);
this.radioButtonCoversSmall.TabIndex = 8;
this.radioButtonCoversSmall.TabStop = true;
this.radioButtonCoversSmall.Text = "Small";
this.radioButtonCoversSmall.UseVisualStyleBackColor = true;
//
// radioButtonCoversLarge
//
this.radioButtonCoversLarge.AutoSize = true;
this.radioButtonCoversLarge.Location = new System.Drawing.Point(6, 16);
this.radioButtonCoversLarge.Name = "radioButtonCoversLarge";
this.radioButtonCoversLarge.Size = new System.Drawing.Size(52, 17);
this.radioButtonCoversLarge.TabIndex = 6;
this.radioButtonCoversLarge.TabStop = true;
this.radioButtonCoversLarge.Text = "Large";
this.radioButtonCoversLarge.UseVisualStyleBackColor = true;
//
// Options
//
this.AcceptButton = this.buttonOk;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.buttonCancel;
this.ClientSize = new System.Drawing.Size(390, 227);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOk);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.linkLabel1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Options";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Options";
this.Load += new System.EventHandler(this.Options_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
@@ -199,5 +240,9 @@ namespace AudioDataPlugIn
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button buttonOk;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.RadioButton radioButtonCoversNone;
private System.Windows.Forms.RadioButton radioButtonCoversSmall;
private System.Windows.Forms.RadioButton radioButtonCoversLarge;
}
}

View File

@@ -8,12 +8,21 @@ using System.Windows.Forms;
using CUETools.CTDB.EACPlugin.Properties;
using CUETools.CTDB;
using Microsoft.Win32;
using System.Runtime.Serialization.Formatters.Binary;
namespace AudioDataPlugIn
{
public enum CTDBCoversSearch
{
Large,
Small,
None
}
public partial class Options : Form
{
private static CTDBMetadataSearch? metadataSearch = null;
private static CTDBCoversSearch? coversSearch = null;
private static string optionsKey = @"SOFTWARE\CUETools\EACPugin";
public static CTDBMetadataSearch MetadataSearch
{
@@ -26,12 +35,10 @@ namespace AudioDataPlugIn
using (var key = Registry.CurrentUser.OpenSubKey(optionsKey, false))
{
var val = key.GetValue("MetadataSearch") as string;
if (val == "Default") metadataSearch = CTDBMetadataSearch.Default;
if (val == "Fast") metadataSearch = CTDBMetadataSearch.Fast;
if (val == "Extensive") metadataSearch = CTDBMetadataSearch.Extensive;
metadataSearch = (CTDBMetadataSearch)Enum.Parse(typeof(CTDBMetadataSearch), val);
}
}
catch (Exception ex)
catch (Exception)
{
}
}
@@ -50,6 +57,68 @@ namespace AudioDataPlugIn
}
}
public static CTDBCoversSearch CoversSearch
{
get
{
if (!coversSearch.HasValue)
{
try
{
using (var key = Registry.CurrentUser.OpenSubKey(optionsKey, false))
{
var val = key.GetValue("CoversSearch") as string;
coversSearch = (CTDBCoversSearch)Enum.Parse(typeof(CTDBCoversSearch), val);
}
}
catch (Exception)
{
}
}
return coversSearch ?? CTDBCoversSearch.Small;
}
set
{
using (var key = Registry.CurrentUser.CreateSubKey(optionsKey))
{
key.SetValue("CoversSearch", value.ToString());
}
coversSearch = value;
}
}
public static Size MetadataWindowSize
{
get
{
try
{
using (var key = Registry.CurrentUser.OpenSubKey(optionsKey, false))
{
var val = key.GetValue("MetadataWindowSize") as string;
return (Size)TypeDescriptor.GetConverter(typeof(Size)).ConvertFromInvariantString(val);
}
}
catch (Exception)
{
}
return new Size();
}
set
{
using (var key = Registry.CurrentUser.CreateSubKey(optionsKey))
{
var val = TypeDescriptor.GetConverter(value.GetType()).ConvertToInvariantString(value);
key.SetValue("MetadataWindowSize", val);
}
}
}
public Options()
{
this.InitializeComponent();
@@ -66,6 +135,9 @@ namespace AudioDataPlugIn
this.radioButtonMBExtensive.Checked = MetadataSearch == CTDBMetadataSearch.Extensive;
this.radioButtonMBDefault.Checked = MetadataSearch == CTDBMetadataSearch.Default;
this.radioButtonMBFast.Checked = MetadataSearch == CTDBMetadataSearch.Fast;
this.radioButtonCoversLarge.Checked = CoversSearch == CTDBCoversSearch.Large;
this.radioButtonCoversSmall.Checked = CoversSearch == CTDBCoversSearch.Small;
this.radioButtonCoversNone.Checked = CoversSearch == CTDBCoversSearch.None;
}
private void button2_Click(object sender, EventArgs e)
@@ -74,6 +146,9 @@ namespace AudioDataPlugIn
: this.radioButtonMBDefault.Checked ? CTDBMetadataSearch.Default
: this.radioButtonMBFast.Checked ? CTDBMetadataSearch.Fast
: CTDBMetadataSearch.None;
}
Options.CoversSearch = this.radioButtonCoversLarge.Checked ? CTDBCoversSearch.Large
: this.radioButtonCoversSmall.Checked ? CTDBCoversSearch.Small
: CTDBCoversSearch.None;
}
}
}