CTDB2.0: coverart search

This commit is contained in:
chudov
2012-01-17 08:04:16 +00:00
parent c74afdd8f4
commit bc3c8a1074
20 changed files with 1178 additions and 404 deletions

View File

@@ -76,6 +76,13 @@
<Compile Include="FormMetadata.Designer.cs"> <Compile Include="FormMetadata.Designer.cs">
<DependentUpon>FormMetadata.cs</DependentUpon> <DependentUpon>FormMetadata.cs</DependentUpon>
</Compile> </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="Metadata.cs" />
<Compile Include="Plugin.cs" /> <Compile Include="Plugin.cs" />
<Compile Include="Options.cs"> <Compile Include="Options.cs">
@@ -98,6 +105,9 @@
<EmbeddedResource Include="FormMetadata.resx"> <EmbeddedResource Include="FormMetadata.resx">
<DependentUpon>FormMetadata.cs</DependentUpon> <DependentUpon>FormMetadata.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="ImagePreview.resx">
<DependentUpon>ImagePreview.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Options.resx"> <EmbeddedResource Include="Options.resx">
<DependentUpon>Options.cs</DependentUpon> <DependentUpon>Options.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
@@ -150,6 +160,9 @@
<Install>true</Install> <Install>true</Install>
</BootstrapperPackage> </BootstrapperPackage>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="Resources\document-save_12.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- 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. Other similar extension points exist, see Microsoft.Common.targets.

View File

@@ -33,27 +33,29 @@
this.progressBar1 = new System.Windows.Forms.ProgressBar(); this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
this.listView1 = new System.Windows.Forms.ListView(); this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader(); 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.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
this.imageList1 = new System.Windows.Forms.ImageList(this.components); this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// progressBar1 // progressBar1
// //
this.progressBar1.Dock = System.Windows.Forms.DockStyle.Fill; this.progressBar1.Dock = System.Windows.Forms.DockStyle.Fill;
this.progressBar1.Location = new System.Drawing.Point(7, 6); this.progressBar1.Location = new System.Drawing.Point(5, 5);
this.progressBar1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.progressBar1.Name = "progressBar1"; this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(783, 31); this.progressBar1.Size = new System.Drawing.Size(587, 25);
this.progressBar1.Style = System.Windows.Forms.ProgressBarStyle.Marquee; this.progressBar1.Style = System.Windows.Forms.ProgressBarStyle.Marquee;
this.progressBar1.TabIndex = 0; this.progressBar1.TabIndex = 0;
// //
// backgroundWorker1 // backgroundWorker1
// //
this.backgroundWorker1.WorkerReportsProgress = true;
this.backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork); 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); this.backgroundWorker1.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker1_RunWorkerCompleted);
// //
// listView1 // listView1
@@ -64,12 +66,11 @@
this.listView1.FullRowSelect = true; this.listView1.FullRowSelect = true;
this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.listView1.HideSelection = false; this.listView1.HideSelection = false;
this.listView1.Location = new System.Drawing.Point(13, 12); this.listView1.Location = new System.Drawing.Point(10, 10);
this.listView1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.listView1.MultiSelect = false; this.listView1.MultiSelect = false;
this.listView1.Name = "listView1"; this.listView1.Name = "listView1";
this.listView1.ShowItemToolTips = true; this.listView1.ShowItemToolTips = true;
this.listView1.Size = new System.Drawing.Size(797, 263); this.listView1.Size = new System.Drawing.Size(597, 243);
this.listView1.SmallImageList = this.imageList1; this.listView1.SmallImageList = this.imageList1;
this.listView1.TabIndex = 1; this.listView1.TabIndex = 1;
this.listView1.UseCompatibleStateImageBehavior = false; this.listView1.UseCompatibleStateImageBehavior = false;
@@ -80,14 +81,21 @@
// //
this.columnHeader1.Text = "Album"; 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 // button1
// //
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button1.Dock = System.Windows.Forms.DockStyle.Right; this.button1.Dock = System.Windows.Forms.DockStyle.Right;
this.button1.Location = new System.Drawing.Point(590, 6); this.button1.Location = new System.Drawing.Point(442, 5);
this.button1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.button1.Name = "button1"; this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(100, 31); this.button1.Size = new System.Drawing.Size(75, 25);
this.button1.TabIndex = 2; this.button1.TabIndex = 2;
this.button1.Text = "Cancel"; this.button1.Text = "Cancel";
this.button1.UseVisualStyleBackColor = true; this.button1.UseVisualStyleBackColor = true;
@@ -97,10 +105,9 @@
// //
this.button2.DialogResult = System.Windows.Forms.DialogResult.OK; this.button2.DialogResult = System.Windows.Forms.DialogResult.OK;
this.button2.Dock = System.Windows.Forms.DockStyle.Right; this.button2.Dock = System.Windows.Forms.DockStyle.Right;
this.button2.Location = new System.Drawing.Point(690, 6); this.button2.Location = new System.Drawing.Point(517, 5);
this.button2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.button2.Name = "button2"; this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(100, 31); this.button2.Size = new System.Drawing.Size(75, 25);
this.button2.TabIndex = 3; this.button2.TabIndex = 3;
this.button2.Text = "OK"; this.button2.Text = "OK";
this.button2.UseVisualStyleBackColor = true; this.button2.UseVisualStyleBackColor = true;
@@ -112,35 +119,35 @@
this.panel1.Controls.Add(this.button2); this.panel1.Controls.Add(this.button2);
this.panel1.Controls.Add(this.progressBar1); this.panel1.Controls.Add(this.progressBar1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel1.Location = new System.Drawing.Point(13, 275); this.panel1.Location = new System.Drawing.Point(10, 254);
this.panel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.panel1.Name = "panel1"; this.panel1.Name = "panel1";
this.panel1.Padding = new System.Windows.Forms.Padding(7, 6, 7, 6); this.panel1.Padding = new System.Windows.Forms.Padding(5);
this.panel1.Size = new System.Drawing.Size(797, 43); this.panel1.Size = new System.Drawing.Size(597, 35);
this.panel1.TabIndex = 4; this.panel1.TabIndex = 4;
// //
// imageList1 // flowLayoutPanel1
// //
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream"))); this.flowLayoutPanel1.AutoScroll = true;
this.imageList1.TransparentColor = System.Drawing.Color.Transparent; this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.imageList1.Images.SetKeyName(0, "freedb"); this.flowLayoutPanel1.Location = new System.Drawing.Point(10, 253);
this.imageList1.Images.SetKeyName(1, "musicbrainz"); this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.imageList1.Images.SetKeyName(2, "discogs"); this.flowLayoutPanel1.Size = new System.Drawing.Size(597, 1);
this.flowLayoutPanel1.TabIndex = 6;
// //
// FormMetadata // FormMetadata
// //
this.AcceptButton = this.button2; this.AcceptButton = this.button2;
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.button1; this.CancelButton = this.button1;
this.ClientSize = new System.Drawing.Size(823, 330); this.ClientSize = new System.Drawing.Size(617, 299);
this.Controls.Add(this.listView1); this.Controls.Add(this.listView1);
this.Controls.Add(this.flowLayoutPanel1);
this.Controls.Add(this.panel1); this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.MinimumSize = new System.Drawing.Size(500, 299);
this.MinimumSize = new System.Drawing.Size(661, 360);
this.Name = "FormMetadata"; this.Name = "FormMetadata";
this.Padding = new System.Windows.Forms.Padding(13, 12, 13, 12); this.Padding = new System.Windows.Forms.Padding(10);
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "CTDB Metadata Lookup"; this.Text = "CTDB Metadata Lookup";
this.Load += new System.EventHandler(this.FormMetadata_Load); this.Load += new System.EventHandler(this.FormMetadata_Load);
@@ -159,5 +166,6 @@
private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button2;
private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.ImageList imageList1; private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
} }
} }

View File

@@ -6,6 +6,8 @@ using System.Drawing;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using CUETools.CTDB.EACPlugin.Properties; using CUETools.CTDB.EACPlugin.Properties;
using System.Net;
using System.IO;
namespace CUETools.CTDB.EACPlugin namespace CUETools.CTDB.EACPlugin
{ {
@@ -13,11 +15,15 @@ namespace CUETools.CTDB.EACPlugin
{ {
private CUEToolsDB ctdb; private CUEToolsDB ctdb;
private string agent; private string agent;
private bool cdinfo, cover;
private ImagePreview m_currently_selected;
public FormMetadata(CUEToolsDB ctdb, string agent) public FormMetadata(CUEToolsDB ctdb, string agent, bool cdinfo, bool cover)
{ {
this.ctdb = ctdb; this.ctdb = ctdb;
this.agent = agent; this.agent = agent;
this.cdinfo = cdinfo;
this.cover = cover;
this.InitializeComponent(); this.InitializeComponent();
} }
@@ -31,6 +37,16 @@ namespace CUETools.CTDB.EACPlugin
} }
} }
public InternetImage Image
{
get
{
return this.DialogResult != DialogResult.Cancel &&
m_currently_selected != null ?
m_currently_selected.Image : null;
}
}
private void FormMetadata_Load(object sender, EventArgs e) private void FormMetadata_Load(object sender, EventArgs e)
{ {
this.Icon = Resources.ctdb; this.Icon = Resources.ctdb;
@@ -39,9 +55,158 @@ namespace CUETools.CTDB.EACPlugin
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{ {
#if DEBUG
this.ctdb.ContactDB(null, this.agent, null, false, false, string server = "hq.cuetools.net";
#else
string server = null;
#endif
this.ctdb.ContactDB(server, this.agent, null, false, false,
AudioDataPlugIn.Options.MetadataSearch); 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
{
}
}
}
}
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) private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
@@ -49,8 +214,36 @@ namespace CUETools.CTDB.EACPlugin
this.progressBar1.Visible = false; this.progressBar1.Visible = false;
this.button1.Visible = true; this.button1.Visible = true;
this.button2.Visible = true; this.button2.Visible = true;
foreach (var metadata in ctdb.Metadata) 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; uint td = 0, dn = 0;
var disccount = metadata.disccount ?? "1"; var disccount = metadata.disccount ?? "1";
var discnumber = metadata.discnumber ?? "1"; var discnumber = metadata.discnumber ?? "1";
@@ -76,23 +269,8 @@ namespace CUETools.CTDB.EACPlugin
tip.AppendFormat("{0}. {2}{1}\n", ++i, tr.name, ((tr.artist ?? metadata.artist) == metadata.artist) ? "" : tr.artist + " / "); 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() }); listView1.Items.Add(new ListViewItem(text) { Tag = metadata, ImageKey = metadata.source, ToolTipText = tip.ToString() });
}
this.listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); 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 listView1_MouseDoubleClick(object sender, MouseEventArgs e)
{
var ht = listView1.HitTest(e.Location);
if (ht.Item != null)
this.DialogResult = DialogResult.OK;
} }
} }
} }

View File

@@ -125,10 +125,10 @@
</metadata> </metadata>
<data name="imageList1.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64"> <data name="imageList1.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
<value> <value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABQ ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABQ
CgAAAk1TRnQBSQFMAgEBAwEAAQgBAAEIAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo CgAAAk1TRnQBSQFMAgEBAwEAARgBAAEYAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
@@ -163,9 +163,9 @@
AQ8B6wIHAbwBAAERBAABEQN6AQABEQEVAhQC6wEVAREBDgQAARERAAG1AaIFBAH/AQQB/wUEAQoBegFR AQ8B6wIHAbwBAAERBAABEQN6AQABEQEVAhQC6wEVAREBDgQAARERAAG1AaIFBAH/AQQB/wUEAQoBegFR
AQ8CAAH/AQABDwH3Av8BkgIRAnoBAAEOAhECFQEOAkoCDhUAAbUBogUEAf8BBAH/BQQBCgR6AQAB/wEA AQ8CAAH/AQABDwH3Av8BkgIRAnoBAAEOAhECFQEOAkoCDhUAAbUBogUEAf8BBAH/BQQBCgR6AQAB/wEA
AREE/wG8AQACegHrAQAEDgQ3AQ4EAAHrEAABtQGiDQQBCgSuAQAB/wIAARMBvAP/AQACrgHrBAABSgQ3 AREE/wG8AQACegHrAQAEDgQ3AQ4EAAHrEAABtQGiDQQBCgSuAQAB/wIAARMBvAP/AQACrgHrBAABSgQ3
AUoEAAHrEAAN/wH0AfMB+ASuAQAB/wEAARIBDwMAAf8BAAKuAesEAAFKBDcBSgQOAesQAAH/AaIC/wEE AUoEAAHrEAAN/wH0AfMB7ASuAQAB/wEAARIBDwMAAf8BAAKuAesEAAFKBDcBSgQOAesQAAH/AaIC/wEE
A/8CBAP/AgQB+ASuAQAB/wEPAQABEQISAQAB/wEAAq4B6wQAAQ4ENwEOAhECDgHrEAAB/wGiAv8BBAL/ A/8CBAP/AgQB7ASuAQAB/wEPAQABEQISAQAB/wEAAq4B6wQAAQ4ENwEOAhECDgHrEAAB/wGiAv8BBAL/
AQQE/wEEAfQB8wH4BK4BAAL/AZIBEQEAAQ8BAAH/AQACrgEAAQ4EAAEOAkoBDgIUAxERAAH/AaIC/wEE AQQE/wEEAfQB8wHsBK4BAAL/AZIBEQEAAQ8BAAH/AQACrgEAAQ4EAAEOAkoBDgIUAxERAAH/AaIC/wEE
Av8EBAH/AwQBCgSuAQABBwP/AbwB6gEAAf8BAAKuAQABFAMAAg4BEQEUAesBcwIUAREBFBEAAf8BogEE Av8EBAH/AwQBCgSuAQABBwP/AbwB6gEAAf8BAAKuAQABFAMAAg4BEQEUAesBcwIUAREBFBEAAf8BogEE
Af8BBAL/AQQC/wEEAf8BBAH0AfMBCgSuAREBEwEHBv8BAAKuAgABEQIAAg4BEQEVAesBBwHrARUBFBIA Af8BBAL/AQQC/wEEAf8BBAH0AfMBCgSuAREBEwEHBv8BAAKuAgABEQIAAg4BEQEVAesBBwHrARUBFBIA
Af8BhgL/AgQC/wIEA/8CBAHsBa4BEQEAAREBkgT/AQACrgMAARQBAAIOAREBFQEUA+sTAAH/AYYL/wH0 Af8BhgL/AgQC/wIEA/8CBAHsBa4BEQEAAREBkgT/AQACrgMAARQBAAIOAREBFQEUA+sTAAH/AYYL/wH0

View File

@@ -30,6 +30,7 @@
{ {
this.progressBar1 = new System.Windows.Forms.ProgressBar(); this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
this.labelStatus = new System.Windows.Forms.Label();
this.SuspendLayout(); this.SuspendLayout();
// //
// progressBar1 // progressBar1
@@ -46,14 +47,23 @@
this.backgroundWorker1.WorkerReportsProgress = true; this.backgroundWorker1.WorkerReportsProgress = true;
this.backgroundWorker1.WorkerSupportsCancellation = true; this.backgroundWorker1.WorkerSupportsCancellation = true;
this.backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork); 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); 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 // FormSubmitParity
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(349, 49); this.ClientSize = new System.Drawing.Size(349, 66);
this.Controls.Add(this.labelStatus);
this.Controls.Add(this.progressBar1); this.Controls.Add(this.progressBar1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximizeBox = false; this.MaximizeBox = false;
@@ -62,9 +72,10 @@
this.Padding = new System.Windows.Forms.Padding(10); this.Padding = new System.Windows.Forms.Padding(10);
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Contacting CTDB..."; this.Text = "Contacting CTDB...";
this.Load += new System.EventHandler(this.FormMetadata_Load);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormSubmitParity_FormClosing); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormSubmitParity_FormClosing);
this.Load += new System.EventHandler(this.FormMetadata_Load);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout();
} }
@@ -72,5 +83,6 @@
private System.Windows.Forms.ProgressBar progressBar1; private System.Windows.Forms.ProgressBar progressBar1;
private System.ComponentModel.BackgroundWorker backgroundWorker1; private System.ComponentModel.BackgroundWorker backgroundWorker1;
private System.Windows.Forms.Label labelStatus;
} }
} }

View File

@@ -61,6 +61,7 @@ namespace CUETools.CTDB.EACPlugin
{ {
this.progressBar1.Style = e.ProgressPercentage != 0 ? ProgressBarStyle.Continuous : ProgressBarStyle.Marquee; this.progressBar1.Style = e.ProgressPercentage != 0 ? ProgressBarStyle.Continuous : ProgressBarStyle.Marquee;
this.progressBar1.Value = Math.Max(0, Math.Min(100, e.ProgressPercentage)); 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) private void FormSubmitParity_FormClosing(object sender, FormClosingEventArgs e)

View 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
}
}

View 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));
}
}
}

View 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>

View 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;
}
}
}
}

View File

@@ -24,7 +24,7 @@ namespace MetadataPlugIn
{ {
public bool GetCDInformation(CCDMetadata data, bool cdinfo, bool cover, bool lyrics) public bool GetCDInformation(CCDMetadata data, bool cdinfo, bool cover, bool lyrics)
{ {
if (!cdinfo) if (!cdinfo && !cover)
return false; return false;
var TOC = new CDImageLayout(); var TOC = new CDImageLayout();
@@ -42,12 +42,14 @@ namespace MetadataPlugIn
TOC[1][0].Start = 0U; TOC[1][0].Start = 0U;
var ctdb = new CUEToolsDB(TOC, null); var ctdb = new CUEToolsDB(TOC, null);
var form = new CUETools.CTDB.EACPlugin.FormMetadata(ctdb, "EAC" + data.HostVersion + " CTDB 2.1.4"); var form = new CUETools.CTDB.EACPlugin.FormMetadata(ctdb, "EAC" + data.HostVersion + " CTDB 2.1.4", cdinfo, cover);
form.ShowDialog(); form.ShowDialog();
var meta = form.Meta; var meta = form.Meta;
if (meta == null) if (meta == null)
return false; return false;
if (cdinfo)
{
int year, disccount, discnumber; int year, disccount, discnumber;
string extra = meta.extra ?? ""; string extra = meta.extra ?? "";
if (!string.IsNullOrEmpty(meta.discname)) if (!string.IsNullOrEmpty(meta.discname))
@@ -96,6 +98,19 @@ namespace MetadataPlugIn
} }
data.SetTrackComposer(track, ""); data.SetTrackComposer(track, "");
} }
}
if (cover)
{
data.CoverImage = null;
data.CoverImageURL = "";
if (form.Image != null)
{
data.CoverImage = form.Image.Data;
data.CoverImageURL = form.Image.URL;
}
}
return true; return true;
} }
@@ -170,7 +185,7 @@ namespace MetadataPlugIn
public bool SupportsCoverRetrieval() public bool SupportsCoverRetrieval()
{ {
return false; return true;
} }
public bool SupportsLyricsRetrieval() public bool SupportsLyricsRetrieval()

View File

@@ -302,4 +302,26 @@ namespace AudioDataPlugIn
return sw.ToString(); 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; }
//}
} }

View File

@@ -73,5 +73,12 @@ namespace CUETools.CTDB.EACPlugin.Properties {
return ((System.Drawing.Bitmap)(obj)); 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));
}
}
} }
} }

View File

@@ -117,11 +117,15 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </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"> <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> <value>..\Resources\favicon.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="ctdb64" type="System.Resources.ResXFileRef, System.Windows.Forms"> <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> <value>..\Resources\ctdb64.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </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> </root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -10,6 +10,6 @@ namespace CUETools.CTDB
[XmlElement] [XmlElement]
public CTDBResponseEntry[] entry; public CTDBResponseEntry[] entry;
[XmlElement] [XmlElement]
public CTDBResponseMeta[] musicbrainz; public CTDBResponseMeta[] metadata;
} }
} }

View File

@@ -31,12 +31,12 @@ namespace CUETools.CTDB
[XmlAttribute] [XmlAttribute]
public string discname { get; set; } public string discname { get; set; }
[XmlAttribute] [XmlAttribute]
public string coverarturl { get; set; }
[XmlAttribute]
public string infourl { get; set; } public string infourl { get; set; }
[XmlAttribute] [XmlAttribute]
public string barcode { get; set; } public string barcode { get; set; }
[XmlElement] [XmlElement]
public CTDBResponseMetaImage[] coverart;
[XmlElement]
public CTDBResponseMetaTrack[] track; public CTDBResponseMetaTrack[] track;
[XmlElement] [XmlElement]
public CTDBResponseMetaLabel[] label; public CTDBResponseMetaLabel[] label;

View 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; }
}
}

View File

@@ -59,6 +59,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="CTDBResponseMetaImage.cs" />
<Compile Include="CTDBSubmitResponse.cs" /> <Compile Include="CTDBSubmitResponse.cs" />
<Compile Include="CTDBMetadataSearch.cs" /> <Compile Include="CTDBMetadataSearch.cs" />
<Compile Include="CTDBResponse.cs" /> <Compile Include="CTDBResponse.cs" />

View File

@@ -65,7 +65,8 @@ namespace CUETools.CTDB
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(urlbase HttpWebRequest req = (HttpWebRequest)WebRequest.Create(urlbase
+ "/lookup2.php" + "/lookup2.php"
+ "?ctdb=" + (ctdb ? "2" : "0") + "?version=2"
+ "&ctdb=" + (ctdb ? 1 : 0)
+ "&fuzzy=" + (fuzzy ? 1 : 0) + "&fuzzy=" + (fuzzy ? 1 : 0)
+ "&metadata=" + (metadataSearch == CTDBMetadataSearch.None ? "none" : metadataSearch == CTDBMetadataSearch.Fast ? "fast" : metadataSearch == CTDBMetadataSearch.Default ? "default" : "extensive") + "&metadata=" + (metadataSearch == CTDBMetadataSearch.None ? "none" : metadataSearch == CTDBMetadataSearch.Fast ? "fast" : metadataSearch == CTDBMetadataSearch.Default ? "default" : "extensive")
+ "&toc=" + toc.ToString()); + "&toc=" + toc.ToString());
@@ -102,8 +103,8 @@ namespace CUETools.CTDB
var entry = new DBEntry(ctdbRespEntry); var entry = new DBEntry(ctdbRespEntry);
entries.Add(entry); entries.Add(entry);
} }
if (ctdbResp.musicbrainz != null && ctdbResp.musicbrainz.Length != 0) if (ctdbResp.metadata != null && ctdbResp.metadata.Length != 0)
metadata.AddRange(ctdbResp.musicbrainz); metadata.AddRange(ctdbResp.metadata);
} }
if (entries.Count == 0) if (entries.Count == 0)
this.QueryResponseStatus = HttpStatusCode.NotFound; this.QueryResponseStatus = HttpStatusCode.NotFound;