Click here to Skip to main content
15,886,110 members
Articles / Programming Languages / XML

Retrieving CD Information from a remote Freedb database

Rate me:
Please Sign up or sign in to vote.
4.92/5 (32 votes)
29 Jul 2004CPOL10 min read 220K   4.3K   125  
Describes a library that can be used to retrieve Audio CD information from the CDDB compatible freedb database.
#region COPYRIGHT (c) 2004 by Brian Weeres
/* Copyright (c) 2004 by Brian Weeres
 * 
 * Email: bweeres@protegra.com; bweeres@hotmail.com
 * 
 * Permission to use, copy, modify, and distribute this software for any
 * purpose is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * If you modify it then please indicate so. 
 *
 * The software is provided "AS IS" and there are no warranties or implied warranties.
 * In no event shall Brian Weeres and/or Protegra Technology Group be liable for any special, 
 * direct, indirect, or consequential damages or any damages whatsoever resulting for any reason 
 * out of the use or performance of this software
 * 
 */
#endregion
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Freedb;

namespace FreedbDemo
{
	/// <summary>
	/// Summary description for DLGSelectQueryResult.
	/// </summary>
	public class DLGSelectQueryResult : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button BTNCancel;
		private System.Windows.Forms.Button BTNOkay;
		private System.Windows.Forms.ListBox LBQueryResults;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private QueryResult m_SelectedQueryResult  = null;
		private QueryResultCollection m_results;
		
		/// <summary>
		/// Property SelectedQueryResult (QueryResult)
		/// </summary>
		public QueryResult SelectedQueryResult
		{
			get
			{
				return this.m_SelectedQueryResult;
			}
			set
			{
				this.m_SelectedQueryResult = value;
			}
		}

		public DLGSelectQueryResult(QueryResultCollection results)
		{
			m_results = results;
			InitializeComponent();
			foreach (QueryResult qr in m_results)
			{
				this.LBQueryResults.Items.Add(qr);
			}
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form 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.LBQueryResults = new System.Windows.Forms.ListBox();
			this.label1 = new System.Windows.Forms.Label();
			this.BTNCancel = new System.Windows.Forms.Button();
			this.BTNOkay = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// LBQueryResults
			// 
			this.LBQueryResults.Location = new System.Drawing.Point(36, 64);
			this.LBQueryResults.Name = "LBQueryResults";
			this.LBQueryResults.Size = new System.Drawing.Size(424, 160);
			this.LBQueryResults.TabIndex = 0;
			// 
			// label1
			// 
			this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label1.Location = new System.Drawing.Point(16, 8);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(424, 40);
			this.label1.TabIndex = 1;
			this.label1.Text = "Multiple entries were found. Select the one you want to use and select okay.";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// BTNCancel
			// 
			this.BTNCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.BTNCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.BTNCancel.Location = new System.Drawing.Point(259, 240);
			this.BTNCancel.Name = "BTNCancel";
			this.BTNCancel.TabIndex = 9;
			this.BTNCancel.Text = "Cancel";
			// 
			// BTNOkay
			// 
			this.BTNOkay.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.BTNOkay.Location = new System.Drawing.Point(163, 240);
			this.BTNOkay.Name = "BTNOkay";
			this.BTNOkay.TabIndex = 8;
			this.BTNOkay.Text = "Okay";
			this.BTNOkay.Click += new System.EventHandler(this.BTNOkay_Click);
			// 
			// DLGSelectQueryResult
			// 
			this.AcceptButton = this.BTNOkay;
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.CancelButton = this.BTNCancel;
			this.ClientSize = new System.Drawing.Size(496, 278);
			this.Controls.Add(this.BTNCancel);
			this.Controls.Add(this.BTNOkay);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.LBQueryResults);
			this.Name = "DLGSelectQueryResult";
			this.Text = "DLGSelectQueryResult";
			this.ResumeLayout(false);

		}
		#endregion

		private void BTNOkay_Click(object sender, System.EventArgs e)
		{
			if (this.LBQueryResults.SelectedIndex != -1)
				this.m_SelectedQueryResult = (QueryResult)LBQueryResults.SelectedItem;

			this.DialogResult = DialogResult.OK;
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions