mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
CTDB2.0: coverart search
This commit is contained in:
@@ -76,6 +76,13 @@
|
||||
<Compile Include="FormMetadata.Designer.cs">
|
||||
<DependentUpon>FormMetadata.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ImagePreview.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ImagePreview.designer.cs">
|
||||
<DependentUpon>ImagePreview.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="InternetImage.cs" />
|
||||
<Compile Include="Metadata.cs" />
|
||||
<Compile Include="Plugin.cs" />
|
||||
<Compile Include="Options.cs">
|
||||
@@ -98,6 +105,9 @@
|
||||
<EmbeddedResource Include="FormMetadata.resx">
|
||||
<DependentUpon>FormMetadata.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ImagePreview.resx">
|
||||
<DependentUpon>ImagePreview.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Options.resx">
|
||||
<DependentUpon>Options.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
@@ -150,6 +160,9 @@
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\document-save_12.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
244
CUETools.CTDB.EACPlugin/FormMetadata.Designer.cs
generated
244
CUETools.CTDB.EACPlugin/FormMetadata.Designer.cs
generated
@@ -28,124 +28,131 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMetadata));
|
||||
this.progressBar1 = new System.Windows.Forms.ProgressBar();
|
||||
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
|
||||
this.listView1 = new System.Windows.Forms.ListView();
|
||||
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
|
||||
this.panel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// progressBar1
|
||||
//
|
||||
this.progressBar1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.progressBar1.Location = new System.Drawing.Point(7, 6);
|
||||
this.progressBar1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.progressBar1.Name = "progressBar1";
|
||||
this.progressBar1.Size = new System.Drawing.Size(783, 31);
|
||||
this.progressBar1.Style = System.Windows.Forms.ProgressBarStyle.Marquee;
|
||||
this.progressBar1.TabIndex = 0;
|
||||
//
|
||||
// backgroundWorker1
|
||||
//
|
||||
this.backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork);
|
||||
this.backgroundWorker1.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker1_RunWorkerCompleted);
|
||||
//
|
||||
// listView1
|
||||
//
|
||||
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMetadata));
|
||||
this.progressBar1 = new System.Windows.Forms.ProgressBar();
|
||||
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
|
||||
this.listView1 = new System.Windows.Forms.ListView();
|
||||
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.panel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// progressBar1
|
||||
//
|
||||
this.progressBar1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.progressBar1.Location = new System.Drawing.Point(5, 5);
|
||||
this.progressBar1.Name = "progressBar1";
|
||||
this.progressBar1.Size = new System.Drawing.Size(587, 25);
|
||||
this.progressBar1.Style = System.Windows.Forms.ProgressBarStyle.Marquee;
|
||||
this.progressBar1.TabIndex = 0;
|
||||
//
|
||||
// backgroundWorker1
|
||||
//
|
||||
this.backgroundWorker1.WorkerReportsProgress = true;
|
||||
this.backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork);
|
||||
this.backgroundWorker1.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.backgroundWorker1_ProgressChanged);
|
||||
this.backgroundWorker1.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker1_RunWorkerCompleted);
|
||||
//
|
||||
// listView1
|
||||
//
|
||||
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.columnHeader1});
|
||||
this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.listView1.FullRowSelect = true;
|
||||
this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
|
||||
this.listView1.HideSelection = false;
|
||||
this.listView1.Location = new System.Drawing.Point(13, 12);
|
||||
this.listView1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.listView1.MultiSelect = false;
|
||||
this.listView1.Name = "listView1";
|
||||
this.listView1.ShowItemToolTips = true;
|
||||
this.listView1.Size = new System.Drawing.Size(797, 263);
|
||||
this.listView1.SmallImageList = this.imageList1;
|
||||
this.listView1.TabIndex = 1;
|
||||
this.listView1.UseCompatibleStateImageBehavior = false;
|
||||
this.listView1.View = System.Windows.Forms.View.Details;
|
||||
this.listView1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseDoubleClick);
|
||||
//
|
||||
// columnHeader1
|
||||
//
|
||||
this.columnHeader1.Text = "Album";
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.button1.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.button1.Location = new System.Drawing.Point(590, 6);
|
||||
this.button1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(100, 31);
|
||||
this.button1.TabIndex = 2;
|
||||
this.button1.Text = "Cancel";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Visible = false;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.button2.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.button2.Location = new System.Drawing.Point(690, 6);
|
||||
this.button2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(100, 31);
|
||||
this.button2.TabIndex = 3;
|
||||
this.button2.Text = "OK";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Visible = false;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Controls.Add(this.button1);
|
||||
this.panel1.Controls.Add(this.button2);
|
||||
this.panel1.Controls.Add(this.progressBar1);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.panel1.Location = new System.Drawing.Point(13, 275);
|
||||
this.panel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Padding = new System.Windows.Forms.Padding(7, 6, 7, 6);
|
||||
this.panel1.Size = new System.Drawing.Size(797, 43);
|
||||
this.panel1.TabIndex = 4;
|
||||
//
|
||||
// imageList1
|
||||
//
|
||||
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
|
||||
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
|
||||
this.imageList1.Images.SetKeyName(0, "freedb");
|
||||
this.imageList1.Images.SetKeyName(1, "musicbrainz");
|
||||
this.imageList1.Images.SetKeyName(2, "discogs");
|
||||
//
|
||||
// FormMetadata
|
||||
//
|
||||
this.AcceptButton = this.button2;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.button1;
|
||||
this.ClientSize = new System.Drawing.Size(823, 330);
|
||||
this.Controls.Add(this.listView1);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
|
||||
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.MinimumSize = new System.Drawing.Size(661, 360);
|
||||
this.Name = "FormMetadata";
|
||||
this.Padding = new System.Windows.Forms.Padding(13, 12, 13, 12);
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "CTDB Metadata Lookup";
|
||||
this.Load += new System.EventHandler(this.FormMetadata_Load);
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.listView1.FullRowSelect = true;
|
||||
this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
|
||||
this.listView1.HideSelection = false;
|
||||
this.listView1.Location = new System.Drawing.Point(10, 10);
|
||||
this.listView1.MultiSelect = false;
|
||||
this.listView1.Name = "listView1";
|
||||
this.listView1.ShowItemToolTips = true;
|
||||
this.listView1.Size = new System.Drawing.Size(597, 243);
|
||||
this.listView1.SmallImageList = this.imageList1;
|
||||
this.listView1.TabIndex = 1;
|
||||
this.listView1.UseCompatibleStateImageBehavior = false;
|
||||
this.listView1.View = System.Windows.Forms.View.Details;
|
||||
this.listView1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseDoubleClick);
|
||||
//
|
||||
// columnHeader1
|
||||
//
|
||||
this.columnHeader1.Text = "Album";
|
||||
//
|
||||
// imageList1
|
||||
//
|
||||
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
|
||||
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
|
||||
this.imageList1.Images.SetKeyName(0, "freedb");
|
||||
this.imageList1.Images.SetKeyName(1, "musicbrainz");
|
||||
this.imageList1.Images.SetKeyName(2, "discogs");
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.button1.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.button1.Location = new System.Drawing.Point(442, 5);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(75, 25);
|
||||
this.button1.TabIndex = 2;
|
||||
this.button1.Text = "Cancel";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Visible = false;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.button2.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.button2.Location = new System.Drawing.Point(517, 5);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(75, 25);
|
||||
this.button2.TabIndex = 3;
|
||||
this.button2.Text = "OK";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Visible = false;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Controls.Add(this.button1);
|
||||
this.panel1.Controls.Add(this.button2);
|
||||
this.panel1.Controls.Add(this.progressBar1);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.panel1.Location = new System.Drawing.Point(10, 254);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.panel1.Size = new System.Drawing.Size(597, 35);
|
||||
this.panel1.TabIndex = 4;
|
||||
//
|
||||
// flowLayoutPanel1
|
||||
//
|
||||
this.flowLayoutPanel1.AutoScroll = true;
|
||||
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.flowLayoutPanel1.Location = new System.Drawing.Point(10, 253);
|
||||
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(597, 1);
|
||||
this.flowLayoutPanel1.TabIndex = 6;
|
||||
//
|
||||
// FormMetadata
|
||||
//
|
||||
this.AcceptButton = this.button2;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.button1;
|
||||
this.ClientSize = new System.Drawing.Size(617, 299);
|
||||
this.Controls.Add(this.listView1);
|
||||
this.Controls.Add(this.flowLayoutPanel1);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
|
||||
this.MinimumSize = new System.Drawing.Size(500, 299);
|
||||
this.Name = "FormMetadata";
|
||||
this.Padding = new System.Windows.Forms.Padding(10);
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "CTDB Metadata Lookup";
|
||||
this.Load += new System.EventHandler(this.FormMetadata_Load);
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
@@ -158,6 +165,7 @@
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.Button button2;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.ImageList imageList1;
|
||||
private System.Windows.Forms.ImageList imageList1;
|
||||
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
|
||||
}
|
||||
}
|
||||
@@ -6,93 +6,271 @@ using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using CUETools.CTDB.EACPlugin.Properties;
|
||||
using System.Net;
|
||||
using System.IO;
|
||||
|
||||
namespace CUETools.CTDB.EACPlugin
|
||||
{
|
||||
public partial class FormMetadata : Form
|
||||
{
|
||||
private CUEToolsDB ctdb;
|
||||
private string agent;
|
||||
public partial class FormMetadata : Form
|
||||
{
|
||||
private CUEToolsDB ctdb;
|
||||
private string agent;
|
||||
private bool cdinfo, cover;
|
||||
private ImagePreview m_currently_selected;
|
||||
|
||||
public FormMetadata(CUEToolsDB ctdb, string agent)
|
||||
{
|
||||
this.ctdb = ctdb;
|
||||
this.agent = agent;
|
||||
this.InitializeComponent();
|
||||
}
|
||||
public FormMetadata(CUEToolsDB ctdb, string agent, bool cdinfo, bool cover)
|
||||
{
|
||||
this.ctdb = ctdb;
|
||||
this.agent = agent;
|
||||
this.cdinfo = cdinfo;
|
||||
this.cover = cover;
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
public CTDBResponseMeta Meta
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.DialogResult != DialogResult.Cancel &&
|
||||
listView1.SelectedItems.Count > 0 ?
|
||||
listView1.SelectedItems[0].Tag as CTDBResponseMeta : null;
|
||||
}
|
||||
}
|
||||
public CTDBResponseMeta Meta
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.DialogResult != DialogResult.Cancel &&
|
||||
listView1.SelectedItems.Count > 0 ?
|
||||
listView1.SelectedItems[0].Tag as CTDBResponseMeta : null;
|
||||
}
|
||||
}
|
||||
|
||||
private void FormMetadata_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.Icon = Resources.ctdb;
|
||||
this.backgroundWorker1.RunWorkerAsync();
|
||||
}
|
||||
public InternetImage Image
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.DialogResult != DialogResult.Cancel &&
|
||||
m_currently_selected != null ?
|
||||
m_currently_selected.Image : null;
|
||||
}
|
||||
}
|
||||
|
||||
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
|
||||
this.ctdb.ContactDB(null, this.agent, null, false, false,
|
||||
AudioDataPlugIn.Options.MetadataSearch);
|
||||
}
|
||||
private void FormMetadata_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.Icon = Resources.ctdb;
|
||||
this.backgroundWorker1.RunWorkerAsync();
|
||||
}
|
||||
|
||||
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
||||
{
|
||||
this.progressBar1.Visible = false;
|
||||
this.button1.Visible = true;
|
||||
this.button2.Visible = true;
|
||||
foreach (var metadata in ctdb.Metadata)
|
||||
{
|
||||
uint td = 0, dn = 0;
|
||||
var disccount = metadata.disccount ?? "1";
|
||||
var discnumber = metadata.discnumber ?? "1";
|
||||
var discnumber01 = (uint.TryParse(disccount, out td) && uint.TryParse(discnumber, out dn) && td > 9 && dn > 0) ?
|
||||
string.Format("{0:00}", dn) : discnumber;
|
||||
var discnumberandtotal = disccount != "1" ? discnumber01 + "/" + disccount : (discnumber != "1" ? discnumber01 : "");
|
||||
var label = metadata.country ?? "";
|
||||
if (metadata.label != null)
|
||||
foreach (var l in metadata.label)
|
||||
label = (label == "" ? "" : label + ": ") + (l.name ?? "") + (l.name != null && l.catno != null ? " " : "") + (l.catno ?? "");
|
||||
if (metadata.releasedate != null)
|
||||
label = (label == "" ? "" : label + ": ") + metadata.releasedate;
|
||||
var text = string.Format("{0}{1} - {2}{3}{4}", metadata.year != null ? metadata.year + ": " : "",
|
||||
metadata.artist == null ? "Unknown Artist" : metadata.artist,
|
||||
metadata.album == "" ? "Unknown Title" : metadata.album,
|
||||
discnumberandtotal != "" ? " (disc " + discnumberandtotal + (metadata.discname != null ? ": " + metadata.discname : "") + ")" : "",
|
||||
label == "" ? "" : " (" + label + ")");
|
||||
var tip = new StringBuilder();
|
||||
var i = 0;
|
||||
if (metadata.track != null)
|
||||
{
|
||||
foreach (var tr in metadata.track)
|
||||
tip.AppendFormat("{0}. {2}{1}\n", ++i, tr.name, ((tr.artist ?? metadata.artist) == metadata.artist) ? "" : tr.artist + " / ");
|
||||
}
|
||||
listView1.Items.Add(new ListViewItem(text) { Tag = metadata, ImageKey = metadata.source, ToolTipText = tip.ToString() });
|
||||
}
|
||||
this.listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
|
||||
if (listView1.Items.Count == 0)
|
||||
{
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
return;
|
||||
}
|
||||
listView1.Items[0].Selected = true;
|
||||
if (listView1.Items.Count == 1)
|
||||
this.DialogResult = DialogResult.OK;
|
||||
}
|
||||
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
#if DEBUG
|
||||
string server = "hq.cuetools.net";
|
||||
#else
|
||||
string server = null;
|
||||
#endif
|
||||
this.ctdb.ContactDB(server, this.agent, null, false, false,
|
||||
AudioDataPlugIn.Options.MetadataSearch);
|
||||
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;
|
||||
foreach (var coverart in metadata.coverart)
|
||||
{
|
||||
if (knownUrls.Contains(coverart.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
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
var ht = listView1.HitTest(e.Location);
|
||||
if (ht.Item != null)
|
||||
this.DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
public void Form1_DoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (this.m_currently_selected != null && !this.cdinfo)
|
||||
{
|
||||
this.DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
|
||||
public void Form1_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
ImagePreview ssp = null;
|
||||
|
||||
if (sender is ImagePreview)
|
||||
{
|
||||
ssp = sender as ImagePreview;
|
||||
}
|
||||
//else if (sender is LargeImage)
|
||||
//{
|
||||
// if (m_current_control is ImagePreview)
|
||||
// {
|
||||
// ssp = m_current_control as ImagePreview;
|
||||
// }
|
||||
//}
|
||||
else if (sender is Control)
|
||||
{
|
||||
Control cp = (sender as Control).Parent;
|
||||
if (cp != null)
|
||||
{
|
||||
if (cp is ImagePreview)
|
||||
{
|
||||
ssp = cp as ImagePreview;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ssp != null)
|
||||
{
|
||||
if (m_currently_selected != null)
|
||||
{
|
||||
m_currently_selected.Selected = false;
|
||||
}
|
||||
ssp.Selected = true;
|
||||
m_currently_selected = ssp;
|
||||
//AcceptImage.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Form1_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
//if (sender is Control)
|
||||
//{
|
||||
// bool ison = false;
|
||||
// Point screencoord = (sender as Control).PointToScreen(e.Location);
|
||||
// Point clientcoord = ImagesPanel.PointToClient(screencoord);
|
||||
// Control cp = ImagesPanel.GetChildAtPoint(clientcoord);
|
||||
// ImagePreview ssp = null;
|
||||
// if (cp is ImagePreview)
|
||||
// {
|
||||
// ssp = cp as ImagePreview;
|
||||
|
||||
// if (!ssp.IsMouseOverPanel(screencoord))
|
||||
// {
|
||||
// cp = null;
|
||||
// ssp = null;
|
||||
// }
|
||||
// }
|
||||
// label1.Text = "(" + (ison) + "/" + (cp != null) + "/" + cp + "-" + m_current_control + ")";
|
||||
// if (cp != m_current_control)
|
||||
// {
|
||||
// m_current_control = cp;
|
||||
// if (cp == null)
|
||||
// {
|
||||
// Capture = false;
|
||||
// li.UnshowImage();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Point np = new Point(cp.Left + cp.Width / 2, cp.Top + cp.Height / 2);
|
||||
// if (ssp != null)
|
||||
// {
|
||||
// if (ssp.Image != null)
|
||||
// {
|
||||
// //Capture = true;
|
||||
// li.ShowImage(ssp.Image, ImagesPanel.PointToScreen(np));
|
||||
// //System.Threading.Thread.Sleep(5000);
|
||||
// li.Activate();
|
||||
// li.Focus();
|
||||
// //label2.Text = "" + li.ContainsFocus;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//}
|
||||
}
|
||||
|
||||
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
||||
{
|
||||
this.progressBar1.Visible = false;
|
||||
this.button1.Visible = true;
|
||||
this.button2.Visible = true;
|
||||
if (listView1.Items.Count == 0)
|
||||
{
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
return;
|
||||
}
|
||||
listView1.Items[0].Selected = true;
|
||||
if (listView1.Items.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;
|
||||
}
|
||||
|
||||
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
|
||||
{
|
||||
if (e.UserState is InternetImage)
|
||||
{
|
||||
var img = e.UserState as InternetImage;
|
||||
var preview = new ImagePreview(flowLayoutPanel1, Form1_MouseMove, Form1_MouseClick, Form1_DoubleClick, img);
|
||||
flowLayoutPanel1.Height = preview.Height + preview.Margin.Vertical;
|
||||
//flowLayoutPanel1.DoubleBuffered = true;
|
||||
}
|
||||
|
||||
if (e.UserState is CTDBResponseMeta)
|
||||
{
|
||||
var metadata = e.UserState as CTDBResponseMeta;
|
||||
uint td = 0, dn = 0;
|
||||
var disccount = metadata.disccount ?? "1";
|
||||
var discnumber = metadata.discnumber ?? "1";
|
||||
var discnumber01 = (uint.TryParse(disccount, out td) && uint.TryParse(discnumber, out dn) && td > 9 && dn > 0) ?
|
||||
string.Format("{0:00}", dn) : discnumber;
|
||||
var discnumberandtotal = disccount != "1" ? discnumber01 + "/" + disccount : (discnumber != "1" ? discnumber01 : "");
|
||||
var label = metadata.country ?? "";
|
||||
if (metadata.label != null)
|
||||
foreach (var l in metadata.label)
|
||||
label = (label == "" ? "" : label + ": ") + (l.name ?? "") + (l.name != null && l.catno != null ? " " : "") + (l.catno ?? "");
|
||||
if (metadata.releasedate != null)
|
||||
label = (label == "" ? "" : label + ": ") + metadata.releasedate;
|
||||
var text = string.Format("{0}{1} - {2}{3}{4}", metadata.year != null ? metadata.year + ": " : "",
|
||||
metadata.artist == null ? "Unknown Artist" : metadata.artist,
|
||||
metadata.album == "" ? "Unknown Title" : metadata.album,
|
||||
discnumberandtotal != "" ? " (disc " + discnumberandtotal + (metadata.discname != null ? ": " + metadata.discname : "") + ")" : "",
|
||||
label == "" ? "" : " (" + label + ")");
|
||||
var tip = new StringBuilder();
|
||||
var i = 0;
|
||||
if (metadata.track != null)
|
||||
{
|
||||
foreach (var tr in metadata.track)
|
||||
tip.AppendFormat("{0}. {2}{1}\n", ++i, tr.name, ((tr.artist ?? metadata.artist) == metadata.artist) ? "" : tr.artist + " / ");
|
||||
}
|
||||
listView1.Items.Add(new ListViewItem(text) { Tag = metadata, ImageKey = metadata.source, ToolTipText = tip.ToString() });
|
||||
this.listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,10 +125,10 @@
|
||||
</metadata>
|
||||
<data name="imageList1.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>
|
||||
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
|
||||
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
|
||||
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
|
||||
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABQ
|
||||
CgAAAk1TRnQBSQFMAgEBAwEAAQgBAAEIAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
|
||||
CgAAAk1TRnQBSQFMAgEBAwEAARgBAAEYAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
|
||||
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
|
||||
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
|
||||
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
|
||||
@@ -163,9 +163,9 @@
|
||||
AQ8B6wIHAbwBAAERBAABEQN6AQABEQEVAhQC6wEVAREBDgQAARERAAG1AaIFBAH/AQQB/wUEAQoBegFR
|
||||
AQ8CAAH/AQABDwH3Av8BkgIRAnoBAAEOAhECFQEOAkoCDhUAAbUBogUEAf8BBAH/BQQBCgR6AQAB/wEA
|
||||
AREE/wG8AQACegHrAQAEDgQ3AQ4EAAHrEAABtQGiDQQBCgSuAQAB/wIAARMBvAP/AQACrgHrBAABSgQ3
|
||||
AUoEAAHrEAAN/wH0AfMB+ASuAQAB/wEAARIBDwMAAf8BAAKuAesEAAFKBDcBSgQOAesQAAH/AaIC/wEE
|
||||
A/8CBAP/AgQB+ASuAQAB/wEPAQABEQISAQAB/wEAAq4B6wQAAQ4ENwEOAhECDgHrEAAB/wGiAv8BBAL/
|
||||
AQQE/wEEAfQB8wH4BK4BAAL/AZIBEQEAAQ8BAAH/AQACrgEAAQ4EAAEOAkoBDgIUAxERAAH/AaIC/wEE
|
||||
AUoEAAHrEAAN/wH0AfMB7ASuAQAB/wEAARIBDwMAAf8BAAKuAesEAAFKBDcBSgQOAesQAAH/AaIC/wEE
|
||||
A/8CBAP/AgQB7ASuAQAB/wEPAQABEQISAQAB/wEAAq4B6wQAAQ4ENwEOAhECDgHrEAAB/wGiAv8BBAL/
|
||||
AQQE/wEEAfQB8wHsBK4BAAL/AZIBEQEAAQ8BAAH/AQACrgEAAQ4EAAEOAkoBDgIUAxERAAH/AaIC/wEE
|
||||
Av8EBAH/AwQBCgSuAQABBwP/AbwB6gEAAf8BAAKuAQABFAMAAg4BEQEUAesBcwIUAREBFBEAAf8BogEE
|
||||
Af8BBAL/AQQC/wEEAf8BBAH0AfMBCgSuAREBEwEHBv8BAAKuAgABEQIAAg4BEQEVAesBBwHrARUBFBIA
|
||||
Af8BhgL/AgQC/wIEA/8CBAHsBa4BEQEAAREBkgT/AQACrgMAARQBAAIOAREBFQEUA+sTAAH/AYYL/wH0
|
||||
|
||||
86
CUETools.CTDB.EACPlugin/FormSubmitParity.Designer.cs
generated
86
CUETools.CTDB.EACPlugin/FormSubmitParity.Designer.cs
generated
@@ -28,43 +28,54 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.progressBar1 = new System.Windows.Forms.ProgressBar();
|
||||
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// progressBar1
|
||||
//
|
||||
this.progressBar1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.progressBar1.Location = new System.Drawing.Point(10, 10);
|
||||
this.progressBar1.Name = "progressBar1";
|
||||
this.progressBar1.Size = new System.Drawing.Size(329, 23);
|
||||
this.progressBar1.Style = System.Windows.Forms.ProgressBarStyle.Marquee;
|
||||
this.progressBar1.TabIndex = 0;
|
||||
//
|
||||
// backgroundWorker1
|
||||
//
|
||||
this.backgroundWorker1.WorkerReportsProgress = true;
|
||||
this.backgroundWorker1.WorkerSupportsCancellation = true;
|
||||
this.backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork);
|
||||
this.backgroundWorker1.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker1_RunWorkerCompleted);
|
||||
this.backgroundWorker1.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.backgroundWorker1_ProgressChanged);
|
||||
//
|
||||
// FormSubmitParity
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(349, 49);
|
||||
this.Controls.Add(this.progressBar1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "FormSubmitParity";
|
||||
this.Padding = new System.Windows.Forms.Padding(10);
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Contacting CTDB...";
|
||||
this.Load += new System.EventHandler(this.FormMetadata_Load);
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormSubmitParity_FormClosing);
|
||||
this.ResumeLayout(false);
|
||||
this.progressBar1 = new System.Windows.Forms.ProgressBar();
|
||||
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
|
||||
this.labelStatus = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// progressBar1
|
||||
//
|
||||
this.progressBar1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.progressBar1.Location = new System.Drawing.Point(10, 10);
|
||||
this.progressBar1.Name = "progressBar1";
|
||||
this.progressBar1.Size = new System.Drawing.Size(329, 23);
|
||||
this.progressBar1.Style = System.Windows.Forms.ProgressBarStyle.Marquee;
|
||||
this.progressBar1.TabIndex = 0;
|
||||
//
|
||||
// backgroundWorker1
|
||||
//
|
||||
this.backgroundWorker1.WorkerReportsProgress = true;
|
||||
this.backgroundWorker1.WorkerSupportsCancellation = true;
|
||||
this.backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork);
|
||||
this.backgroundWorker1.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.backgroundWorker1_ProgressChanged);
|
||||
this.backgroundWorker1.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker1_RunWorkerCompleted);
|
||||
//
|
||||
// labelStatus
|
||||
//
|
||||
this.labelStatus.AutoSize = true;
|
||||
this.labelStatus.Location = new System.Drawing.Point(10, 40);
|
||||
this.labelStatus.Name = "labelStatus";
|
||||
this.labelStatus.Size = new System.Drawing.Size(0, 13);
|
||||
this.labelStatus.TabIndex = 1;
|
||||
//
|
||||
// FormSubmitParity
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(349, 66);
|
||||
this.Controls.Add(this.labelStatus);
|
||||
this.Controls.Add(this.progressBar1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "FormSubmitParity";
|
||||
this.Padding = new System.Windows.Forms.Padding(10);
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Contacting CTDB...";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormSubmitParity_FormClosing);
|
||||
this.Load += new System.EventHandler(this.FormMetadata_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
@@ -72,5 +83,6 @@
|
||||
|
||||
private System.Windows.Forms.ProgressBar progressBar1;
|
||||
private System.ComponentModel.BackgroundWorker backgroundWorker1;
|
||||
private System.Windows.Forms.Label labelStatus;
|
||||
}
|
||||
}
|
||||
@@ -61,6 +61,7 @@ namespace CUETools.CTDB.EACPlugin
|
||||
{
|
||||
this.progressBar1.Style = e.ProgressPercentage != 0 ? ProgressBarStyle.Continuous : ProgressBarStyle.Marquee;
|
||||
this.progressBar1.Value = Math.Max(0, Math.Min(100, e.ProgressPercentage));
|
||||
this.labelStatus.Text = e.UserState is string ? e.UserState as string : string.Empty;
|
||||
}
|
||||
|
||||
private void FormSubmitParity_FormClosing(object sender, FormClosingEventArgs e)
|
||||
|
||||
105
CUETools.CTDB.EACPlugin/ImagePreview.Designer.cs
generated
Normal file
105
CUETools.CTDB.EACPlugin/ImagePreview.Designer.cs
generated
Normal file
@@ -0,0 +1,105 @@
|
||||
namespace CUETools.CTDB.EACPlugin
|
||||
{
|
||||
partial class ImagePreview
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.Description = new System.Windows.Forms.Label();
|
||||
this.Description2 = new System.Windows.Forms.Label();
|
||||
this.ImagePanel = new System.Windows.Forms.Panel();
|
||||
this.MouseOverPanel = new System.Windows.Forms.Panel();
|
||||
this.SaveFile = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// Description
|
||||
//
|
||||
this.Description.Location = new System.Drawing.Point(4, 4+ImageSize+4);
|
||||
this.Description.Name = "Description";
|
||||
this.Description.Size = new System.Drawing.Size(ImageSize - 16, 8);
|
||||
this.Description.TabIndex = 1;
|
||||
this.Description.TextAlign = System.Drawing.ContentAlignment.TopLeft;
|
||||
this.Description.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
//
|
||||
// Description2
|
||||
//
|
||||
this.Description2.Location = new System.Drawing.Point(4, 4 + ImageSize + 4 + 8);
|
||||
this.Description2.Name = "Description2";
|
||||
this.Description2.Size = new System.Drawing.Size(ImageSize - 16, 8);
|
||||
this.Description2.TabIndex = 3;
|
||||
this.Description2.TextAlign = System.Drawing.ContentAlignment.TopLeft;
|
||||
this.Description2.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
//
|
||||
// ImagePanel
|
||||
//
|
||||
this.ImagePanel.BackColor = System.Drawing.Color.Transparent;
|
||||
this.ImagePanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.ImagePanel.Location = new System.Drawing.Point(4, 4);
|
||||
this.ImagePanel.Name = "ImagePanel";
|
||||
this.ImagePanel.Size = new System.Drawing.Size(ImageSize, ImageSize);
|
||||
this.ImagePanel.TabIndex = 0;
|
||||
//
|
||||
// MouseOverPanel
|
||||
//
|
||||
this.MouseOverPanel.BackColor = System.Drawing.Color.Transparent;
|
||||
this.MouseOverPanel.Location = new System.Drawing.Point(ImageSize/2-16, ImageSize/2-16);
|
||||
this.MouseOverPanel.Name = "MouseOverPanel";
|
||||
this.MouseOverPanel.Size = new System.Drawing.Size(32, 32);
|
||||
this.MouseOverPanel.TabIndex = 2;
|
||||
//
|
||||
// SaveFile
|
||||
//
|
||||
this.SaveFile.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
this.SaveFile.FlatAppearance.BorderSize = 0;
|
||||
this.SaveFile.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.SaveFile.Image = global::CUETools.CTDB.EACPlugin.Properties.Resources.document_save_12;
|
||||
this.SaveFile.Location = new System.Drawing.Point(4+ImageSize-16, 4+ImageSize+4);
|
||||
this.SaveFile.Name = "SaveFile";
|
||||
this.SaveFile.Size = new System.Drawing.Size(16, 16);
|
||||
this.SaveFile.TabIndex = 0;
|
||||
this.SaveFile.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ImagePreview
|
||||
//
|
||||
this.BackColor = System.Drawing.Color.Transparent;
|
||||
this.Controls.Add(this.ImagePanel);
|
||||
this.Controls.Add(this.Description);
|
||||
this.Controls.Add(this.Description2);
|
||||
this.Controls.Add(this.MouseOverPanel);
|
||||
this.Controls.Add(this.SaveFile);
|
||||
this.Size = new System.Drawing.Size(4+ImageSize+4, 4+ImageSize+4+16+4);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
private System.Windows.Forms.Label Description;
|
||||
private System.Windows.Forms.Label Description2;
|
||||
private System.Windows.Forms.Panel ImagePanel;
|
||||
private System.Windows.Forms.Panel MouseOverPanel;
|
||||
private System.Windows.Forms.Button SaveFile;
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
199
CUETools.CTDB.EACPlugin/ImagePreview.cs
Normal file
199
CUETools.CTDB.EACPlugin/ImagePreview.cs
Normal file
@@ -0,0 +1,199 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using MetadataPlugIn;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace CUETools.CTDB.EACPlugin
|
||||
{
|
||||
public partial class ImagePreview : Panel
|
||||
{
|
||||
const int ImageSize = 80;
|
||||
protected InternetImage m_image = null;
|
||||
protected bool m_selected;
|
||||
protected int m_random;
|
||||
|
||||
public ImagePreview(Control parent, MouseEventHandler parentmouse, MouseEventHandler parentclick, MouseEventHandler parentdoubleclick, InternetImage img)
|
||||
{
|
||||
InitializeComponent();
|
||||
m_random = new Random().Next(256);
|
||||
|
||||
//this.BackColor = System.Drawing.Color.Black;
|
||||
//this.Location = new System.Drawing.Point(positionx*(128+8)+4, positiony*(128+16+4+8)+4);
|
||||
//this.Bounds = new Rectangle(new System.Drawing.Point(positionx * (128 + 8) + 4, positiony * (128 + 16 + 4 + 8) + 4), Size);
|
||||
this.MouseMove += new MouseEventHandler(parentmouse);
|
||||
this.MouseClick += new MouseEventHandler(parentclick);
|
||||
this.MouseDoubleClick += new MouseEventHandler(parentdoubleclick);
|
||||
this.MouseOverPanel.MouseMove += new System.Windows.Forms.MouseEventHandler(parentmouse);
|
||||
this.ImagePanel.MouseMove += new System.Windows.Forms.MouseEventHandler(parentmouse);
|
||||
this.ImagePanel.MouseClick += new MouseEventHandler(parentclick);
|
||||
this.ImagePanel.MouseDoubleClick += new MouseEventHandler(parentdoubleclick);
|
||||
this.Description.MouseClick +=new MouseEventHandler(parentclick);
|
||||
this.Description.MouseDoubleClick += new MouseEventHandler(parentdoubleclick);
|
||||
this.Description2.MouseClick += new MouseEventHandler(parentclick);
|
||||
this.Description2.MouseDoubleClick += new MouseEventHandler(parentdoubleclick);
|
||||
this.SaveFile.Click += new EventHandler(SaveFile_Click);
|
||||
this.DoubleBuffered = true;
|
||||
|
||||
Image = img;
|
||||
Selected = false;
|
||||
|
||||
parent.Controls.Add(this);
|
||||
}
|
||||
|
||||
public void SaveFile_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
SaveFileDialog fd = new SaveFileDialog();
|
||||
string[] URL = m_image.URL.Split('/');
|
||||
if (URL.Length > 0)
|
||||
{
|
||||
string filename = URL[URL.Length - 1];
|
||||
filename = filename.Replace('\\', '-');
|
||||
filename = filename.Replace('\"', '\'');
|
||||
filename = filename.Replace('*', '.');
|
||||
filename = filename.Replace(':', '.');
|
||||
filename = filename.Replace('<', '(');
|
||||
filename = filename.Replace('>', ')');
|
||||
filename = filename.Replace('|', 'I');
|
||||
filename = filename.Replace('/', '-');
|
||||
filename = filename.Replace('?', ' ');
|
||||
fd.FileName = filename;
|
||||
fd.Title = "Save Image File";
|
||||
var DialogResult = fd.ShowDialog();
|
||||
if(DialogResult == DialogResult.OK)
|
||||
{
|
||||
FileStream fs = File.Create(fd.FileName);
|
||||
BinaryWriter bw = new BinaryWriter(fs);
|
||||
bw.Write(m_image.Data);
|
||||
bw.Close();
|
||||
fs.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool Selected
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_selected;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_selected = value;
|
||||
if (m_selected)
|
||||
{
|
||||
BackColor = System.Drawing.SystemColors.MenuHighlight;
|
||||
}
|
||||
else
|
||||
{
|
||||
BackColor = System.Drawing.Color.Transparent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool IsMouseOverPanel(Point pnt)
|
||||
{
|
||||
Point p2 = PointToClient(pnt);
|
||||
return MouseOverPanel.Bounds.Contains(p2);
|
||||
}
|
||||
|
||||
|
||||
public InternetImage Image
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_image;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_image = value;
|
||||
|
||||
var imgToResize = m_image.Image;
|
||||
int sourceWidth = imgToResize.Width;
|
||||
int sourceHeight = imgToResize.Height;
|
||||
|
||||
float nPercent = 0;
|
||||
float nPercentW = 0;
|
||||
float nPercentH = 0;
|
||||
|
||||
nPercentW = ((float)this.ImagePanel.Width / (float)sourceWidth);
|
||||
nPercentH = ((float)this.ImagePanel.Height / (float)sourceHeight);
|
||||
|
||||
if (nPercentH < nPercentW)
|
||||
nPercent = nPercentH;
|
||||
else
|
||||
nPercent = nPercentW;
|
||||
|
||||
int destWidth = (int)(sourceWidth * nPercent);
|
||||
int destHeight = (int)(sourceHeight * nPercent);
|
||||
|
||||
try
|
||||
{
|
||||
var b = new Bitmap(this.ImagePanel.Width, this.ImagePanel.Height);
|
||||
using (Graphics g = Graphics.FromImage((Image)b))
|
||||
{
|
||||
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
g.DrawImage(imgToResize, 0, 0, destWidth, destHeight);
|
||||
}
|
||||
this.ImagePanel.BackgroundImage = b;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
this.Description.Text = m_image.Image.Width + "x" + m_image.Image.Height;
|
||||
this.Description2.Text = (m_image.Data.Length / 1024) + " kb";
|
||||
}
|
||||
}
|
||||
|
||||
public string URL
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_image.URL;
|
||||
}
|
||||
}
|
||||
|
||||
public long FileSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((long)m_image.Data.Length) * 256 + ((long)m_random);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public long PictureSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((long)m_image.Image.Width) * ((long)m_image.Image.Height) * 256 + ((long)m_random);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ImagePreview_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
Parent.PointToClient(PointToScreen(e.Location));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
135
CUETools.CTDB.EACPlugin/ImagePreview.resx
Normal file
135
CUETools.CTDB.EACPlugin/ImagePreview.resx
Normal file
@@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="Description.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>276, 17</value>
|
||||
</metadata>
|
||||
<metadata name="ImagePanel.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>161, 17</value>
|
||||
</metadata>
|
||||
<metadata name="MouseOverPanel.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="SaveFile.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>390, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
</root>
|
||||
53
CUETools.CTDB.EACPlugin/InternetImage.cs
Normal file
53
CUETools.CTDB.EACPlugin/InternetImage.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
|
||||
namespace CUETools.CTDB.EACPlugin
|
||||
{
|
||||
public class InternetImage
|
||||
{
|
||||
protected string m_URL = null;
|
||||
protected Bitmap m_bitmap = null;
|
||||
protected byte[] m_data = null;
|
||||
|
||||
public string URL
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_URL;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_URL = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public byte[] Data
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_data = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Bitmap Image
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_bitmap;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_bitmap = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,177 +15,192 @@ using System.Drawing.Imaging;
|
||||
|
||||
namespace MetadataPlugIn
|
||||
{
|
||||
[Guid("8271734A-126F-44e9-AC9C-836449B39E51"),
|
||||
[Guid("8271734A-126F-44e9-AC9C-836449B39E51"),
|
||||
ClassInterface(ClassInterfaceType.None),
|
||||
ComSourceInterfaces(typeof(IMetadataRetriever)),
|
||||
ComSourceInterfaces(typeof(IMetadataRetriever)),
|
||||
]
|
||||
|
||||
public class MetadataRetriever : IMetadataRetriever
|
||||
{
|
||||
public bool GetCDInformation(CCDMetadata data, bool cdinfo, bool cover, bool lyrics)
|
||||
{
|
||||
if (!cdinfo)
|
||||
return false;
|
||||
public class MetadataRetriever : IMetadataRetriever
|
||||
{
|
||||
public bool GetCDInformation(CCDMetadata data, bool cdinfo, bool cover, bool lyrics)
|
||||
{
|
||||
if (!cdinfo && !cover)
|
||||
return false;
|
||||
|
||||
var TOC = new CDImageLayout();
|
||||
for (int i = 0; i < data.NumberOfTracks; i++)
|
||||
{
|
||||
uint start = data.GetTrackStartPosition(i);
|
||||
uint next = data.GetTrackEndPosition(i);
|
||||
TOC.AddTrack(new CDTrack(
|
||||
(uint)i + 1,
|
||||
start,
|
||||
next - start,
|
||||
!data.GetTrackDataTrack(i),
|
||||
data.GetTrackPreemphasis(i)));
|
||||
}
|
||||
TOC[1][0].Start = 0U;
|
||||
var TOC = new CDImageLayout();
|
||||
for (int i = 0; i < data.NumberOfTracks; i++)
|
||||
{
|
||||
uint start = data.GetTrackStartPosition(i);
|
||||
uint next = data.GetTrackEndPosition(i);
|
||||
TOC.AddTrack(new CDTrack(
|
||||
(uint)i + 1,
|
||||
start,
|
||||
next - start,
|
||||
!data.GetTrackDataTrack(i),
|
||||
data.GetTrackPreemphasis(i)));
|
||||
}
|
||||
TOC[1][0].Start = 0U;
|
||||
|
||||
var ctdb = new CUEToolsDB(TOC, null);
|
||||
var form = new CUETools.CTDB.EACPlugin.FormMetadata(ctdb, "EAC" + data.HostVersion + " CTDB 2.1.4");
|
||||
form.ShowDialog();
|
||||
var meta = form.Meta;
|
||||
if (meta == null)
|
||||
return false;
|
||||
var ctdb = new CUEToolsDB(TOC, null);
|
||||
var form = new CUETools.CTDB.EACPlugin.FormMetadata(ctdb, "EAC" + data.HostVersion + " CTDB 2.1.4", cdinfo, cover);
|
||||
form.ShowDialog();
|
||||
var meta = form.Meta;
|
||||
if (meta == null)
|
||||
return false;
|
||||
|
||||
int year, disccount, discnumber;
|
||||
string extra = meta.extra ?? "";
|
||||
if (!string.IsNullOrEmpty(meta.discname))
|
||||
extra += "Disc name: " + meta.discname + "\r\n";
|
||||
if (!string.IsNullOrEmpty(meta.infourl))
|
||||
extra += "Info URL: " + meta.infourl + "\r\n";
|
||||
if (!string.IsNullOrEmpty(meta.barcode))
|
||||
extra += "Barcode: " + meta.barcode + "\r\n";
|
||||
if (!string.IsNullOrEmpty(meta.releasedate))
|
||||
extra += "Release date: " + meta.releasedate + "\r\n";
|
||||
if (!string.IsNullOrEmpty(meta.country))
|
||||
extra += "Release country: " + meta.country + "\r\n";
|
||||
if (meta.label != null)
|
||||
foreach (var label in meta.label)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(label.name))
|
||||
extra += "Release label: " + label.name + "\r\n";
|
||||
if (!string.IsNullOrEmpty(label.catno))
|
||||
extra += "Release catalog#: " + label.catno + "\r\n";
|
||||
}
|
||||
data.Year = meta.year != null && int.TryParse(meta.year, out year) ? year : -1;
|
||||
data.TotalNumberOfCDs = meta.disccount != null && int.TryParse(meta.disccount, out disccount) ? disccount : 1;
|
||||
data.CDNumber = meta.discnumber != null && int.TryParse(meta.discnumber, out discnumber) ? discnumber : 1;
|
||||
data.FirstTrackNumber = 1;
|
||||
data.AlbumTitle = meta.album ?? "";
|
||||
data.AlbumArtist = meta.artist ?? "";
|
||||
data.MP3V2Type = meta.genre ?? "";
|
||||
data.CDDBMusicType = GetFreeDBMusicType(meta);
|
||||
data.MP3Type = GetMP3MusicType(data.CDDBMusicType);
|
||||
data.ExtendedDiscInformation = extra;
|
||||
data.Revision = -1; // TODO: meta.id? rock/ffffffff/16?
|
||||
if (meta.track != null)
|
||||
for (int track = 0; track < data.NumberOfTracks; track++)
|
||||
{
|
||||
if (track < meta.track.Length)
|
||||
{
|
||||
data.SetTrackTitle(track, meta.track[track].name ?? "");
|
||||
data.SetTrackArtist(track, meta.track[track].artist ?? meta.artist ?? "");
|
||||
data.SetExtendedTrackInformation(track, meta.track[track].extra ?? "");
|
||||
}
|
||||
else
|
||||
{
|
||||
data.SetTrackTitle(track, "");
|
||||
data.SetTrackArtist(track, meta.artist ?? "");
|
||||
data.SetExtendedTrackInformation(track, "");
|
||||
}
|
||||
data.SetTrackComposer(track, "");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (cdinfo)
|
||||
{
|
||||
int year, disccount, discnumber;
|
||||
string extra = meta.extra ?? "";
|
||||
if (!string.IsNullOrEmpty(meta.discname))
|
||||
extra += "Disc name: " + meta.discname + "\r\n";
|
||||
if (!string.IsNullOrEmpty(meta.infourl))
|
||||
extra += "Info URL: " + meta.infourl + "\r\n";
|
||||
if (!string.IsNullOrEmpty(meta.barcode))
|
||||
extra += "Barcode: " + meta.barcode + "\r\n";
|
||||
if (!string.IsNullOrEmpty(meta.releasedate))
|
||||
extra += "Release date: " + meta.releasedate + "\r\n";
|
||||
if (!string.IsNullOrEmpty(meta.country))
|
||||
extra += "Release country: " + meta.country + "\r\n";
|
||||
if (meta.label != null)
|
||||
foreach (var label in meta.label)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(label.name))
|
||||
extra += "Release label: " + label.name + "\r\n";
|
||||
if (!string.IsNullOrEmpty(label.catno))
|
||||
extra += "Release catalog#: " + label.catno + "\r\n";
|
||||
}
|
||||
data.Year = meta.year != null && int.TryParse(meta.year, out year) ? year : -1;
|
||||
data.TotalNumberOfCDs = meta.disccount != null && int.TryParse(meta.disccount, out disccount) ? disccount : 1;
|
||||
data.CDNumber = meta.discnumber != null && int.TryParse(meta.discnumber, out discnumber) ? discnumber : 1;
|
||||
data.FirstTrackNumber = 1;
|
||||
data.AlbumTitle = meta.album ?? "";
|
||||
data.AlbumArtist = meta.artist ?? "";
|
||||
data.MP3V2Type = meta.genre ?? "";
|
||||
data.CDDBMusicType = GetFreeDBMusicType(meta);
|
||||
data.MP3Type = GetMP3MusicType(data.CDDBMusicType);
|
||||
data.ExtendedDiscInformation = extra;
|
||||
data.Revision = -1; // TODO: meta.id? rock/ffffffff/16?
|
||||
if (meta.track != null)
|
||||
for (int track = 0; track < data.NumberOfTracks; track++)
|
||||
{
|
||||
if (track < meta.track.Length)
|
||||
{
|
||||
data.SetTrackTitle(track, meta.track[track].name ?? "");
|
||||
data.SetTrackArtist(track, meta.track[track].artist ?? meta.artist ?? "");
|
||||
data.SetExtendedTrackInformation(track, meta.track[track].extra ?? "");
|
||||
}
|
||||
else
|
||||
{
|
||||
data.SetTrackTitle(track, "");
|
||||
data.SetTrackArtist(track, meta.artist ?? "");
|
||||
data.SetExtendedTrackInformation(track, "");
|
||||
}
|
||||
data.SetTrackComposer(track, "");
|
||||
}
|
||||
}
|
||||
|
||||
public int GetMP3MusicType(int freedbtype)
|
||||
{
|
||||
int[] list = { 17, 29, 34, 95, 53, 77, 90, 113, 117, 129, 95 };
|
||||
return (freedbtype <= 0 || freedbtype >= list.Length) ? -1 : list[freedbtype];
|
||||
}
|
||||
if (cover)
|
||||
{
|
||||
data.CoverImage = null;
|
||||
data.CoverImageURL = "";
|
||||
if (form.Image != null)
|
||||
{
|
||||
data.CoverImage = form.Image.Data;
|
||||
data.CoverImageURL = form.Image.URL;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetFreeDBMusicType(CTDBResponseMeta meta)
|
||||
{
|
||||
int pos = meta.id.IndexOf('/');
|
||||
if (meta.source != "freedb" || pos < 0)
|
||||
return -1;
|
||||
string freedbtype = meta.id.Substring(0, pos);
|
||||
switch (freedbtype.ToUpper())
|
||||
{
|
||||
case "BLUES":
|
||||
return 0;
|
||||
case "CLASSICAL":
|
||||
return 1;
|
||||
case "COUNTRY":
|
||||
return 2;
|
||||
case "DATA":
|
||||
return 3;
|
||||
case "FOLK":
|
||||
return 4;
|
||||
case "JAZZ":
|
||||
return 5;
|
||||
case "NEWAGE":
|
||||
return 6;
|
||||
case "REGGAE":
|
||||
return 7;
|
||||
case "ROCK":
|
||||
return 8;
|
||||
case "SOUNDTRACK":
|
||||
return 9;
|
||||
case "MISC":
|
||||
return 10;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public string GetPluginGuid()
|
||||
{
|
||||
return ((GuidAttribute)Attribute.GetCustomAttribute(GetType(), typeof(GuidAttribute))).Value;
|
||||
}
|
||||
public int GetMP3MusicType(int freedbtype)
|
||||
{
|
||||
int[] list = { 17, 29, 34, 95, 53, 77, 90, 113, 117, 129, 95 };
|
||||
return (freedbtype <= 0 || freedbtype >= list.Length) ? -1 : list[freedbtype];
|
||||
}
|
||||
|
||||
public Array GetPluginLogo()
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
Resources.ctdb64.Save(ms, ImageFormat.Png);
|
||||
return ms.ToArray();
|
||||
}
|
||||
public int GetFreeDBMusicType(CTDBResponseMeta meta)
|
||||
{
|
||||
int pos = meta.id.IndexOf('/');
|
||||
if (meta.source != "freedb" || pos < 0)
|
||||
return -1;
|
||||
string freedbtype = meta.id.Substring(0, pos);
|
||||
switch (freedbtype.ToUpper())
|
||||
{
|
||||
case "BLUES":
|
||||
return 0;
|
||||
case "CLASSICAL":
|
||||
return 1;
|
||||
case "COUNTRY":
|
||||
return 2;
|
||||
case "DATA":
|
||||
return 3;
|
||||
case "FOLK":
|
||||
return 4;
|
||||
case "JAZZ":
|
||||
return 5;
|
||||
case "NEWAGE":
|
||||
return 6;
|
||||
case "REGGAE":
|
||||
return 7;
|
||||
case "ROCK":
|
||||
return 8;
|
||||
case "SOUNDTRACK":
|
||||
return 9;
|
||||
case "MISC":
|
||||
return 10;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public string GetPluginName()
|
||||
{
|
||||
return "CUETools DB Metadata Plugin V2.1.4";
|
||||
}
|
||||
public string GetPluginGuid()
|
||||
{
|
||||
return ((GuidAttribute)Attribute.GetCustomAttribute(GetType(), typeof(GuidAttribute))).Value;
|
||||
}
|
||||
|
||||
public void ShowOptions()
|
||||
{
|
||||
AudioDataPlugIn.Options opt = new AudioDataPlugIn.Options();
|
||||
opt.ShowDialog();
|
||||
}
|
||||
public Array GetPluginLogo()
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
Resources.ctdb64.Save(ms, ImageFormat.Png);
|
||||
return ms.ToArray();
|
||||
}
|
||||
|
||||
public bool SubmitCDInformation(IMetadataLookup data)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
public string GetPluginName()
|
||||
{
|
||||
return "CUETools DB Metadata Plugin V2.1.4";
|
||||
}
|
||||
|
||||
public bool SupportsCoverRetrieval()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public void ShowOptions()
|
||||
{
|
||||
AudioDataPlugIn.Options opt = new AudioDataPlugIn.Options();
|
||||
opt.ShowDialog();
|
||||
}
|
||||
|
||||
public bool SupportsLyricsRetrieval()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public bool SubmitCDInformation(IMetadataLookup data)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public bool SupportsMetadataRetrieval()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public bool SupportsCoverRetrieval()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool SupportsMetadataSubmission()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public bool SupportsLyricsRetrieval()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool SupportsMetadataRetrieval()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool SupportsMetadataSubmission()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,4 +302,26 @@ namespace AudioDataPlugIn
|
||||
return sw.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
//private NativeWindow GetWindowFromHost(int hwnd)
|
||||
//{
|
||||
// IntPtr handle = new IntPtr(hwnd);
|
||||
// NativeWindow nativeWindow = new NativeWindow();
|
||||
// nativeWindow.AssignHandle(handle);
|
||||
// return window;
|
||||
//}
|
||||
//NativeWindow parentWindow = GetWindowFromHwnd(hwnd);
|
||||
//try
|
||||
//{
|
||||
// launchTarget.ShowDialog(parentWindow);
|
||||
//}
|
||||
//finally
|
||||
//{
|
||||
// parentWindow.ReleaseHandle();
|
||||
//}
|
||||
//internal class WindowWrapper : System.Windows.Forms.IWin32Window
|
||||
//{
|
||||
// public IntPtr Handle { get; private set; }
|
||||
// public WindowWrapper(IntPtr hwnd) { Handle = hwnd; }
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -73,5 +73,12 @@ namespace CUETools.CTDB.EACPlugin.Properties {
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap document_save_12 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("document_save_12", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,11 +117,15 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="ctdb" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\favicon.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ctdb64" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ctdb64.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="document_save_12" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\document-save_12.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
||||
BIN
CUETools.CTDB.EACPlugin/Resources/document-save_12.png
Normal file
BIN
CUETools.CTDB.EACPlugin/Resources/document-save_12.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
@@ -10,6 +10,6 @@ namespace CUETools.CTDB
|
||||
[XmlElement]
|
||||
public CTDBResponseEntry[] entry;
|
||||
[XmlElement]
|
||||
public CTDBResponseMeta[] musicbrainz;
|
||||
public CTDBResponseMeta[] metadata;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,12 +31,12 @@ namespace CUETools.CTDB
|
||||
[XmlAttribute]
|
||||
public string discname { get; set; }
|
||||
[XmlAttribute]
|
||||
public string coverarturl { get; set; }
|
||||
[XmlAttribute]
|
||||
public string infourl { get; set; }
|
||||
[XmlAttribute]
|
||||
public string barcode { get; set; }
|
||||
[XmlElement]
|
||||
public CTDBResponseMetaImage[] coverart;
|
||||
[XmlElement]
|
||||
public CTDBResponseMetaTrack[] track;
|
||||
[XmlElement]
|
||||
public CTDBResponseMetaLabel[] label;
|
||||
|
||||
20
CUETools.CTDB/CTDBResponseMetaImage.cs
Normal file
20
CUETools.CTDB/CTDBResponseMetaImage.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace CUETools.CTDB
|
||||
{
|
||||
[Serializable]
|
||||
public class CTDBResponseMetaImage
|
||||
{
|
||||
[XmlAttribute]
|
||||
public string uri { get; set; }
|
||||
[XmlAttribute]
|
||||
public string uri150 { get; set; }
|
||||
[XmlAttribute]
|
||||
public int height { get; set; }
|
||||
[XmlAttribute]
|
||||
public int width { get; set; }
|
||||
[XmlAttribute]
|
||||
public bool primary { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CTDBResponseMetaImage.cs" />
|
||||
<Compile Include="CTDBSubmitResponse.cs" />
|
||||
<Compile Include="CTDBMetadataSearch.cs" />
|
||||
<Compile Include="CTDBResponse.cs" />
|
||||
|
||||
@@ -65,8 +65,9 @@ namespace CUETools.CTDB
|
||||
|
||||
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(urlbase
|
||||
+ "/lookup2.php"
|
||||
+ "?ctdb=" + (ctdb ? "2" : "0")
|
||||
+ "&fuzzy=" + (fuzzy ? 1 : 0)
|
||||
+ "?version=2"
|
||||
+ "&ctdb=" + (ctdb ? 1 : 0)
|
||||
+ "&fuzzy=" + (fuzzy ? 1 : 0)
|
||||
+ "&metadata=" + (metadataSearch == CTDBMetadataSearch.None ? "none" : metadataSearch == CTDBMetadataSearch.Fast ? "fast" : metadataSearch == CTDBMetadataSearch.Default ? "default" : "extensive")
|
||||
+ "&toc=" + toc.ToString());
|
||||
req.Method = "GET";
|
||||
@@ -102,8 +103,8 @@ namespace CUETools.CTDB
|
||||
var entry = new DBEntry(ctdbRespEntry);
|
||||
entries.Add(entry);
|
||||
}
|
||||
if (ctdbResp.musicbrainz != null && ctdbResp.musicbrainz.Length != 0)
|
||||
metadata.AddRange(ctdbResp.musicbrainz);
|
||||
if (ctdbResp.metadata != null && ctdbResp.metadata.Length != 0)
|
||||
metadata.AddRange(ctdbResp.metadata);
|
||||
}
|
||||
if (entries.Count == 0)
|
||||
this.QueryResponseStatus = HttpStatusCode.NotFound;
|
||||
|
||||
Reference in New Issue
Block a user