using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using NEROLib;
namespace NeroFiddlesCOM.NET
{
///
/// Summary description for BurnImage.
///
public class BurnImageForm : System.Windows.Forms.Form
{
private NeroDrive m_drive;
private Nero m_nero;
private ChooseBurnFlagsForm m_frmChooseBurnFlags;
private ChooseMediaForm m_frmChooseMedia;
private ChooseSpeedForm m_frmChooseWriteSpeed;
private System.Windows.Forms.TextBox c_ImageFilename;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button c_Browse;
private System.Windows.Forms.TextBox c_Device;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Button c_Burn;
private System.Windows.Forms.Button c_Cancel;
private System.Windows.Forms.Button c_ChooseBurnFlags;
private System.Windows.Forms.Button c_ChooseWriteSpeed;
private System.Windows.Forms.Button c_MediaType;
private System.Windows.Forms.TextBox c_Settings;
private System.Windows.Forms.Label label2;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public BurnImageForm(NeroDrive drive, Nero nero)
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
m_drive = drive;
m_nero = nero;
m_frmChooseBurnFlags = new ChooseBurnFlagsForm ();
m_frmChooseMedia = new ChooseMediaForm (m_nero);
m_frmChooseWriteSpeed = new ChooseSpeedForm (m_drive, true);
}
///
/// 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_ImageFilename = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.c_Browse = new System.Windows.Forms.Button();
this.c_Device = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.c_Burn = new System.Windows.Forms.Button();
this.c_Cancel = new System.Windows.Forms.Button();
this.c_ChooseBurnFlags = new System.Windows.Forms.Button();
this.c_ChooseWriteSpeed = new System.Windows.Forms.Button();
this.c_MediaType = new System.Windows.Forms.Button();
this.c_Settings = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// c_ImageFilename
//
this.c_ImageFilename.Location = new System.Drawing.Point(8, 88);
this.c_ImageFilename.Name = "c_ImageFilename";
this.c_ImageFilename.Size = new System.Drawing.Size(288, 20);
this.c_ImageFilename.TabIndex = 1;
this.c_ImageFilename.Text = "";
this.c_ImageFilename.TextChanged += new System.EventHandler(this.c_ImageFilename_TextChanged);
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 72);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(88, 16);
this.label1.TabIndex = 0;
this.label1.Text = "Image filename:";
//
// c_Browse
//
this.c_Browse.Location = new System.Drawing.Point(304, 88);
this.c_Browse.Name = "c_Browse";
this.c_Browse.TabIndex = 2;
this.c_Browse.Text = "Browse";
this.c_Browse.Click += new System.EventHandler(this.c_Browse_Click);
//
// c_Device
//
this.c_Device.Location = new System.Drawing.Point(8, 24);
this.c_Device.Name = "c_Device";
this.c_Device.ReadOnly = true;
this.c_Device.Size = new System.Drawing.Size(208, 20);
this.c_Device.TabIndex = 9;
this.c_Device.Text = "";
//
// label8
//
this.label8.Location = new System.Drawing.Point(8, 8);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(56, 16);
this.label8.TabIndex = 8;
this.label8.Text = "Device:";
//
// c_Burn
//
this.c_Burn.DialogResult = System.Windows.Forms.DialogResult.OK;
this.c_Burn.Location = new System.Drawing.Point(304, 8);
this.c_Burn.Name = "c_Burn";
this.c_Burn.TabIndex = 10;
this.c_Burn.Text = "Burn";
this.c_Burn.Click += new System.EventHandler(this.c_Burn_Click);
//
// c_Cancel
//
this.c_Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.c_Cancel.Location = new System.Drawing.Point(304, 40);
this.c_Cancel.Name = "c_Cancel";
this.c_Cancel.TabIndex = 11;
this.c_Cancel.Text = "Cancel";
//
// c_ChooseBurnFlags
//
this.c_ChooseBurnFlags.Location = new System.Drawing.Point(304, 136);
this.c_ChooseBurnFlags.Name = "c_ChooseBurnFlags";
this.c_ChooseBurnFlags.TabIndex = 5;
this.c_ChooseBurnFlags.Text = "Burn Flags";
this.c_ChooseBurnFlags.Click += new System.EventHandler(this.c_ChooseBurnFlags_Click);
//
// c_ChooseWriteSpeed
//
this.c_ChooseWriteSpeed.Location = new System.Drawing.Point(304, 168);
this.c_ChooseWriteSpeed.Name = "c_ChooseWriteSpeed";
this.c_ChooseWriteSpeed.TabIndex = 6;
this.c_ChooseWriteSpeed.Text = "Write Speed";
this.c_ChooseWriteSpeed.Click += new System.EventHandler(this.c_ChooseWriteSpeed_Click);
//
// c_MediaType
//
this.c_MediaType.Location = new System.Drawing.Point(304, 200);
this.c_MediaType.Name = "c_MediaType";
this.c_MediaType.TabIndex = 7;
this.c_MediaType.Text = "Media Type";
this.c_MediaType.Click += new System.EventHandler(this.c_MediaType_Click);
//
// c_Settings
//
this.c_Settings.Location = new System.Drawing.Point(8, 128);
this.c_Settings.Multiline = true;
this.c_Settings.Name = "c_Settings";
this.c_Settings.ReadOnly = true;
this.c_Settings.Size = new System.Drawing.Size(288, 96);
this.c_Settings.TabIndex = 4;
this.c_Settings.Text = "";
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 112);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(88, 16);
this.label2.TabIndex = 3;
this.label2.Text = "Settings:";
//
// BurnImageForm
//
this.AcceptButton = this.c_Burn;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.CancelButton = this.c_Cancel;
this.ClientSize = new System.Drawing.Size(386, 232);
this.Controls.Add(this.c_Settings);
this.Controls.Add(this.c_Cancel);
this.Controls.Add(this.c_Burn);
this.Controls.Add(this.c_Device);
this.Controls.Add(this.c_ImageFilename);
this.Controls.Add(this.label8);
this.Controls.Add(this.c_Browse);
this.Controls.Add(this.label1);
this.Controls.Add(this.c_ChooseBurnFlags);
this.Controls.Add(this.c_ChooseWriteSpeed);
this.Controls.Add(this.c_MediaType);
this.Controls.Add(this.label2);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "BurnImageForm";
this.ShowInTaskbar = false;
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "BurnImage";
this.ResumeLayout(false);
}
#endregion
protected override void OnLoad(EventArgs e)
{
base.OnLoad (e);
// Update GUI on load.
//
c_Device.Text = m_drive.DeviceName;
UpdateBurnButton ();
UpdateSettings ();
}
private void c_Browse_Click(object sender, System.EventArgs e)
{
// Open the file dialog asking for an image filename.
//
OpenFileDialog dlg = new OpenFileDialog ();
dlg.CheckFileExists = true;
dlg.CheckPathExists = true;
dlg.DefaultExt = ".nrg";
dlg.FileName = c_ImageFilename.Text;
dlg.Filter = "All image files|*.nrg;*.iso|NRG files (*.nrg)|*.nrg|ISO files (*.iso)|*.iso|All files (*.*)|*.*";
if (DialogResult.OK == dlg.ShowDialog (this))
{
c_ImageFilename.Text = dlg.FileName;
UpdateBurnButton ();
}
}
private void UpdateBurnButton ()
{
// Enable the burn button if image filename is not
// empty.
//
bool bEnable = c_ImageFilename.Text != "";
c_Burn.Enabled = bEnable;
}
private void c_ImageFilename_TextChanged(object sender, System.EventArgs e)
{
// When image filename is chaned by typing, update
// the burn button as well.
//
UpdateBurnButton ();
}
private void c_Burn_Click(object sender, System.EventArgs e)
{
// When burning is requested, just do it. Pass all
// the params.
//
BurnProgressForm frm = new BurnProgressForm (m_drive, m_nero);
frm.BurnImage (c_ImageFilename.Text,
m_frmChooseBurnFlags.GetBurnFlags (),
m_frmChooseWriteSpeed.GetSpeed (),
m_frmChooseMedia.GetMediaType (),
this);
}
private void UpdateSettings ()
{
c_Settings.Text = "Burn flags: " + m_frmChooseBurnFlags.ToString () + "\r\n\r\n"
+ "Write speed: " + m_frmChooseWriteSpeed.ToString () + "\r\n\r\n"
+ "Media types: " + m_frmChooseMedia.ToString ();
}
private void c_ChooseBurnFlags_Click(object sender, System.EventArgs e)
{
if (DialogResult.OK == m_frmChooseBurnFlags.ShowDialog (this))
{
UpdateSettings ();
}
}
private void c_ChooseWriteSpeed_Click(object sender, System.EventArgs e)
{
if (DialogResult.OK == m_frmChooseWriteSpeed.ShowDialog (this))
{
UpdateSettings ();
}
}
private void c_MediaType_Click(object sender, System.EventArgs e)
{
if (DialogResult.OK == m_frmChooseMedia.ShowDialog (this))
{
UpdateSettings ();
}
}
}
}