using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using NEROLib;
namespace NeroFiddlesCOM.NET
{
///
/// Summary description for DAE.
///
public class DAEForm : System.Windows.Forms.Form
{
private NeroDrive m_drive;
private _INeroDriveEvents_OnDoneCDInfoEventHandler m_evOnDoneCDInfo;
private ControlEnabler m_controlEnabler;
private System.Windows.Forms.Button c_DAE;
private System.Windows.Forms.Button c_Close;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ColumnHeader columnHeader3;
private System.Windows.Forms.ColumnHeader columnHeader4;
private System.Windows.Forms.Button c_Browse;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button c_Refresh;
private System.Windows.Forms.ListView c_Tracks;
private System.Windows.Forms.TextBox c_Filename;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public DAEForm(NeroDrive drive)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
m_drive = drive;
m_controlEnabler = new ControlEnabler (this);
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.c_DAE = new System.Windows.Forms.Button();
this.c_Close = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.c_Tracks = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
this.c_Filename = new System.Windows.Forms.TextBox();
this.c_Browse = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.c_Refresh = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// c_DAE
//
this.c_DAE.Location = new System.Drawing.Point(408, 64);
this.c_DAE.Name = "c_DAE";
this.c_DAE.TabIndex = 6;
this.c_DAE.Text = "Do DAE";
this.c_DAE.Click += new System.EventHandler(this.c_DAE_Click);
//
// c_Close
//
this.c_Close.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.c_Close.Location = new System.Drawing.Point(408, 8);
this.c_Close.Name = "c_Close";
this.c_Close.TabIndex = 7;
this.c_Close.Text = "Close";
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(100, 16);
this.label1.TabIndex = 0;
this.label1.Text = "Audio Tracks:";
//
// c_Tracks
//
this.c_Tracks.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2,
this.columnHeader3,
this.columnHeader4});
this.c_Tracks.FullRowSelect = true;
this.c_Tracks.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.c_Tracks.HideSelection = false;
this.c_Tracks.Location = new System.Drawing.Point(8, 24);
this.c_Tracks.MultiSelect = false;
this.c_Tracks.Name = "c_Tracks";
this.c_Tracks.Size = new System.Drawing.Size(392, 128);
this.c_Tracks.TabIndex = 1;
this.c_Tracks.View = System.Windows.Forms.View.Details;
this.c_Tracks.SelectedIndexChanged += new System.EventHandler(this.c_Tracks_SelectedIndexChanged);
//
// columnHeader1
//
this.columnHeader1.Text = "T#";
this.columnHeader1.Width = 35;
//
// columnHeader2
//
this.columnHeader2.Text = "Name";
this.columnHeader2.Width = 184;
//
// columnHeader3
//
this.columnHeader3.Text = "Start block";
this.columnHeader3.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.columnHeader3.Width = 76;
//
// columnHeader4
//
this.columnHeader4.Text = "Length";
this.columnHeader4.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.columnHeader4.Width = 73;
//
// c_Filename
//
this.c_Filename.Location = new System.Drawing.Point(8, 176);
this.c_Filename.Name = "c_Filename";
this.c_Filename.Size = new System.Drawing.Size(392, 20);
this.c_Filename.TabIndex = 3;
this.c_Filename.Text = "";
this.c_Filename.TextChanged += new System.EventHandler(this.c_Filename_TextChanged);
//
// c_Browse
//
this.c_Browse.Location = new System.Drawing.Point(408, 176);
this.c_Browse.Name = "c_Browse";
this.c_Browse.TabIndex = 4;
this.c_Browse.Text = "Browse";
this.c_Browse.Click += new System.EventHandler(this.c_Browse_Click);
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 160);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(100, 16);
this.label2.TabIndex = 2;
this.label2.Text = "Save filename:";
//
// c_Refresh
//
this.c_Refresh.Location = new System.Drawing.Point(408, 96);
this.c_Refresh.Name = "c_Refresh";
this.c_Refresh.TabIndex = 5;
this.c_Refresh.Text = "Refresh";
this.c_Refresh.Click += new System.EventHandler(this.c_Refresh_Click);
//
// DAEForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.CancelButton = this.c_Close;
this.ClientSize = new System.Drawing.Size(488, 206);
this.Controls.Add(this.c_Filename);
this.Controls.Add(this.c_Tracks);
this.Controls.Add(this.label1);
this.Controls.Add(this.c_DAE);
this.Controls.Add(this.c_Close);
this.Controls.Add(this.c_Browse);
this.Controls.Add(this.label2);
this.Controls.Add(this.c_Refresh);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "DAEForm";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "DAE";
this.ResumeLayout(false);
}
#endregion
protected override void OnLoad(EventArgs e)
{
base.OnLoad (e);
RefreshTracks ();
}
private void c_Refresh_Click(object sender, System.EventArgs e)
{
RefreshTracks ();
}
private void RefreshTracks ()
{
// Subscribe to OnDoneCDInfo event, disable controls and
// show wait cursor. Then do the disc info.
//
m_evOnDoneCDInfo = new _INeroDriveEvents_OnDoneCDInfoEventHandler(m_drive_OnDoneCDInfo);
m_drive.OnDoneCDInfo += m_evOnDoneCDInfo;
m_controlEnabler.EnableAllControls (false);
this.Cursor = Cursors.WaitCursor;
m_drive.CDInfo (0);
}
private void m_drive_OnDoneCDInfo(INeroCDInfo pCDInfo)
{
// Unsubscribe from event and display disc info information.
//
m_drive.OnDoneCDInfo -= m_evOnDoneCDInfo;
c_Tracks.Items.Clear ();
if (pCDInfo != null)
{
foreach (NeroTrack trk in pCDInfo.Tracks)
{
// Display all audio tracks in a list view.
//
if (trk.TrackType == NERO_TRACK_TYPE.NERO_TT_AUDIO)
{
ListViewItem lvi = c_Tracks.Items.Add (trk.TrackNumber.ToString ());
string sArtist = trk.Artist == ""? "Unknown": trk.Artist;
string sTitle = trk.Title == ""? "Unknown": trk.Title;
lvi.SubItems.Add (sArtist + " - " + sTitle);
lvi.SubItems.Add (trk.TrackStartBlk.ToString ());
lvi.SubItems.Add (trk.TrackLengthInBlks.ToString ());
}
}
}
// Restore controls' values and restore the cursor.
//
m_controlEnabler.EnableAllControls (true);
this.Cursor = Cursors.Default;
// Update the state of DAE button.
//
UpdateDAEButton ();
}
private void UpdateDAEButton ()
{
// Enable DAE button if some audio track is selected and a filename
// exists.
//
c_DAE.Enabled = c_Tracks.SelectedIndices.Count > 0 && c_Filename.Text != "";
}
private void c_Tracks_SelectedIndexChanged(object sender, System.EventArgs e)
{
UpdateDAEButton ();
}
private void c_Browse_Click(object sender, System.EventArgs e)
{
SaveFileDialog dlg = new SaveFileDialog ();
dlg.DefaultExt = ".wav";
dlg.Filter = "All files (*.*)|*.*";
if (DialogResult.OK == dlg.ShowDialog (this))
{
c_Filename.Text = dlg.FileName;
UpdateDAEButton ();
}
}
private void c_DAE_Click(object sender, System.EventArgs e)
{
if (c_Tracks.SelectedIndices.Count > 0 &&
c_Filename.Text != "")
{
// Get the start block and block length of the selected audio
// track.
//
ListViewItem lvi = c_Tracks.SelectedItems[0];
int iStartBlock = Convert.ToInt32 (lvi.SubItems[2].Text);
int iLengthInBlocks = Convert.ToInt32 (lvi.SubItems[3].Text);
// Pass the params to DAE progress form and start the process
// by calling ShowDialog.
//
DAEProgressForm frm = new DAEProgressForm (m_drive, iStartBlock, iLengthInBlocks, c_Filename.Text, 0);
frm.ShowDialog ();
}
}
private void c_Filename_TextChanged(object sender, System.EventArgs e)
{
UpdateDAEButton ();
}
}
}