123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555 |
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using NEROLib;
- namespace LYFZ.NeroDiscBurn.NET
- {
- /// <summary>
- /// Summary description for BurnDiscCopyForm.
- /// </summary>
- public class BurnDiscCopyForm : System.Windows.Forms.Form
- {
- private Nero m_nero;
- private NeroDrive m_sourceDrive;
- private NeroDrives m_recorders;
- private ChooseBurnFlagsForm m_frmChooseBurnFlags;
- private ChooseMediaForm m_frmChooseMedia;
- private ChooseSpeedForm m_frmChooseWriteSpeed;
- private ChooseSpeedForm m_frmChooseReadSpeed;
- // This is our custom class that represents a single
- // combobox item. We want to store a NeroDrive in it.
- //
- private class CBItem
- {
- public NeroDrive m_drive;
- public CBItem (NeroDrive drive)
- {
- m_drive = drive;
- }
- public override string ToString()
- {
- return ((m_drive.DriveLetter == "")? "?": m_drive.DriveLetter.ToUpper ()) + ": " + m_drive.DeviceName;
- }
- }
- private System.Windows.Forms.Button c_Copy;
- private System.Windows.Forms.Button c_Cancel;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.ComboBox c_Recorders;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.Button c_BrowseImage;
- private System.Windows.Forms.CheckBox c_IgnoreDataErrors;
- private System.Windows.Forms.CheckBox c_IgnoreAudioErrors;
- private System.Windows.Forms.CheckBox c_ReadISRC;
- private System.Windows.Forms.Button c_ReadSpeed;
- private System.Windows.Forms.Button c_WriteSpeed;
- private System.Windows.Forms.Button c_BurnFlags;
- private System.Windows.Forms.Button c_MediaType;
- private System.Windows.Forms.CheckBox c_OnTheFly;
- private System.Windows.Forms.CheckBox c_DeleteImage;
- private System.Windows.Forms.TextBox c_ImageFilepath;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.TextBox c_Settings;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.TextBox c_SourceDrive;
- private System.Windows.Forms.CheckBox c_RAWReadMode;
- private System.Windows.Forms.TextBox c_NumberOfRetries;
- private System.Windows.Forms.Label label5;
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.Container components = null;
- public BurnDiscCopyForm(Nero nero, NeroDrive drive)
- {
- //
- // Required for Windows Form Designer support
- //
- InitializeComponent();
- m_nero = nero;
- m_sourceDrive = drive;
- m_frmChooseBurnFlags = new ChooseBurnFlagsForm ();
- m_frmChooseMedia = new ChooseMediaForm (m_nero);
- m_frmChooseReadSpeed = new ChooseSpeedForm (m_sourceDrive, false);
- m_frmChooseWriteSpeed = new ChooseSpeedForm (null, true);
- }
- /// <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.c_Copy = new System.Windows.Forms.Button();
- this.c_Cancel = new System.Windows.Forms.Button();
- this.label1 = new System.Windows.Forms.Label();
- this.c_Recorders = new System.Windows.Forms.ComboBox();
- this.c_OnTheFly = new System.Windows.Forms.CheckBox();
- this.c_DeleteImage = new System.Windows.Forms.CheckBox();
- this.label2 = new System.Windows.Forms.Label();
- this.c_ImageFilepath = new System.Windows.Forms.TextBox();
- this.c_BrowseImage = new System.Windows.Forms.Button();
- this.c_IgnoreDataErrors = new System.Windows.Forms.CheckBox();
- this.c_IgnoreAudioErrors = new System.Windows.Forms.CheckBox();
- this.c_ReadISRC = new System.Windows.Forms.CheckBox();
- this.c_RAWReadMode = new System.Windows.Forms.CheckBox();
- this.c_ReadSpeed = new System.Windows.Forms.Button();
- this.c_WriteSpeed = new System.Windows.Forms.Button();
- this.c_BurnFlags = new System.Windows.Forms.Button();
- this.c_MediaType = new System.Windows.Forms.Button();
- this.label3 = new System.Windows.Forms.Label();
- this.c_Settings = new System.Windows.Forms.TextBox();
- this.label4 = new System.Windows.Forms.Label();
- this.c_SourceDrive = new System.Windows.Forms.TextBox();
- this.c_NumberOfRetries = new System.Windows.Forms.TextBox();
- this.label5 = new System.Windows.Forms.Label();
- this.SuspendLayout();
- //
- // c_Copy
- //
- this.c_Copy.Location = new System.Drawing.Point(408, 16);
- this.c_Copy.Name = "c_Copy";
- this.c_Copy.TabIndex = 21;
- this.c_Copy.Text = "Copy";
- this.c_Copy.Click += new System.EventHandler(this.c_Copy_Click);
- //
- // c_Cancel
- //
- this.c_Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- this.c_Cancel.Location = new System.Drawing.Point(408, 48);
- this.c_Cancel.Name = "c_Cancel";
- this.c_Cancel.TabIndex = 22;
- this.c_Cancel.Text = "Cancel";
- //
- // label1
- //
- this.label1.Location = new System.Drawing.Point(8, 56);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(136, 16);
- this.label1.TabIndex = 4;
- this.label1.Text = "Choose destination drive:";
- //
- // c_Recorders
- //
- this.c_Recorders.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.c_Recorders.Location = new System.Drawing.Point(8, 72);
- this.c_Recorders.Name = "c_Recorders";
- this.c_Recorders.Size = new System.Drawing.Size(184, 21);
- this.c_Recorders.TabIndex = 5;
- this.c_Recorders.SelectedIndexChanged += new System.EventHandler(this.c_Recorders_SelectedIndexChanged);
- //
- // c_OnTheFly
- //
- this.c_OnTheFly.Checked = true;
- this.c_OnTheFly.CheckState = System.Windows.Forms.CheckState.Checked;
- this.c_OnTheFly.Location = new System.Drawing.Point(8, 104);
- this.c_OnTheFly.Name = "c_OnTheFly";
- this.c_OnTheFly.Size = new System.Drawing.Size(80, 16);
- this.c_OnTheFly.TabIndex = 10;
- this.c_OnTheFly.Text = "On the fly";
- this.c_OnTheFly.CheckedChanged += new System.EventHandler(this.c_OnTheFly_CheckedChanged);
- //
- // c_DeleteImage
- //
- this.c_DeleteImage.Checked = true;
- this.c_DeleteImage.CheckState = System.Windows.Forms.CheckState.Checked;
- this.c_DeleteImage.Location = new System.Drawing.Point(96, 104);
- this.c_DeleteImage.Name = "c_DeleteImage";
- this.c_DeleteImage.Size = new System.Drawing.Size(96, 16);
- this.c_DeleteImage.TabIndex = 11;
- this.c_DeleteImage.Text = "Delete image";
- //
- // label2
- //
- this.label2.Location = new System.Drawing.Point(8, 128);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(100, 16);
- this.label2.TabIndex = 13;
- this.label2.Text = "Image file path:";
- //
- // c_ImageFilepath
- //
- this.c_ImageFilepath.Location = new System.Drawing.Point(8, 144);
- this.c_ImageFilepath.Name = "c_ImageFilepath";
- this.c_ImageFilepath.Size = new System.Drawing.Size(184, 20);
- this.c_ImageFilepath.TabIndex = 12;
- this.c_ImageFilepath.Text = "";
- //
- // c_BrowseImage
- //
- this.c_BrowseImage.Location = new System.Drawing.Point(200, 144);
- this.c_BrowseImage.Name = "c_BrowseImage";
- this.c_BrowseImage.TabIndex = 14;
- this.c_BrowseImage.Text = "Browse";
- this.c_BrowseImage.Click += new System.EventHandler(this.c_BrowseImage_Click);
- //
- // c_IgnoreDataErrors
- //
- this.c_IgnoreDataErrors.Location = new System.Drawing.Point(208, 48);
- this.c_IgnoreDataErrors.Name = "c_IgnoreDataErrors";
- this.c_IgnoreDataErrors.Size = new System.Drawing.Size(144, 16);
- this.c_IgnoreDataErrors.TabIndex = 6;
- this.c_IgnoreDataErrors.Text = "Ignore data read errors";
- //
- // c_IgnoreAudioErrors
- //
- this.c_IgnoreAudioErrors.Checked = true;
- this.c_IgnoreAudioErrors.CheckState = System.Windows.Forms.CheckState.Checked;
- this.c_IgnoreAudioErrors.Location = new System.Drawing.Point(208, 72);
- this.c_IgnoreAudioErrors.Name = "c_IgnoreAudioErrors";
- this.c_IgnoreAudioErrors.Size = new System.Drawing.Size(144, 16);
- this.c_IgnoreAudioErrors.TabIndex = 7;
- this.c_IgnoreAudioErrors.Text = "Ignore audio read errors";
- //
- // c_ReadISRC
- //
- this.c_ReadISRC.Location = new System.Drawing.Point(208, 96);
- this.c_ReadISRC.Name = "c_ReadISRC";
- this.c_ReadISRC.Size = new System.Drawing.Size(192, 16);
- this.c_ReadISRC.TabIndex = 8;
- this.c_ReadISRC.Text = "Read ISRC and media catalog #";
- //
- // c_RAWReadMode
- //
- this.c_RAWReadMode.Location = new System.Drawing.Point(208, 120);
- this.c_RAWReadMode.Name = "c_RAWReadMode";
- this.c_RAWReadMode.Size = new System.Drawing.Size(144, 16);
- this.c_RAWReadMode.TabIndex = 9;
- this.c_RAWReadMode.Text = "RAW read mode";
- //
- // c_ReadSpeed
- //
- this.c_ReadSpeed.Location = new System.Drawing.Point(408, 96);
- this.c_ReadSpeed.Name = "c_ReadSpeed";
- this.c_ReadSpeed.TabIndex = 17;
- this.c_ReadSpeed.Text = "Read speed";
- this.c_ReadSpeed.Click += new System.EventHandler(this.c_ReadSpeed_Click);
- //
- // c_WriteSpeed
- //
- this.c_WriteSpeed.Location = new System.Drawing.Point(408, 128);
- this.c_WriteSpeed.Name = "c_WriteSpeed";
- this.c_WriteSpeed.TabIndex = 18;
- this.c_WriteSpeed.Text = "Write speed";
- this.c_WriteSpeed.Click += new System.EventHandler(this.c_WriteSpeed_Click);
- //
- // c_BurnFlags
- //
- this.c_BurnFlags.Location = new System.Drawing.Point(408, 160);
- this.c_BurnFlags.Name = "c_BurnFlags";
- this.c_BurnFlags.TabIndex = 19;
- this.c_BurnFlags.Text = "Burn flags";
- this.c_BurnFlags.Click += new System.EventHandler(this.c_BurnFlags_Click);
- //
- // c_MediaType
- //
- this.c_MediaType.Location = new System.Drawing.Point(408, 192);
- this.c_MediaType.Name = "c_MediaType";
- this.c_MediaType.TabIndex = 20;
- this.c_MediaType.Text = "Media type";
- this.c_MediaType.Click += new System.EventHandler(this.c_MediaType_Click);
- //
- // label3
- //
- this.label3.Location = new System.Drawing.Point(8, 168);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(100, 16);
- this.label3.TabIndex = 15;
- this.label3.Text = "Settings:";
- //
- // c_Settings
- //
- this.c_Settings.Location = new System.Drawing.Point(8, 184);
- this.c_Settings.Multiline = true;
- this.c_Settings.Name = "c_Settings";
- this.c_Settings.ReadOnly = true;
- this.c_Settings.ScrollBars = System.Windows.Forms.ScrollBars.Both;
- this.c_Settings.Size = new System.Drawing.Size(384, 112);
- this.c_Settings.TabIndex = 16;
- this.c_Settings.Text = "";
- //
- // label4
- //
- this.label4.Location = new System.Drawing.Point(8, 8);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(136, 16);
- this.label4.TabIndex = 0;
- this.label4.Text = "Source drive:";
- //
- // c_SourceDrive
- //
- this.c_SourceDrive.Location = new System.Drawing.Point(8, 24);
- this.c_SourceDrive.Name = "c_SourceDrive";
- this.c_SourceDrive.ReadOnly = true;
- this.c_SourceDrive.Size = new System.Drawing.Size(184, 20);
- this.c_SourceDrive.TabIndex = 1;
- this.c_SourceDrive.Text = "";
- //
- // c_NumberOfRetries
- //
- this.c_NumberOfRetries.Location = new System.Drawing.Point(208, 24);
- this.c_NumberOfRetries.Name = "c_NumberOfRetries";
- this.c_NumberOfRetries.Size = new System.Drawing.Size(48, 20);
- this.c_NumberOfRetries.TabIndex = 3;
- this.c_NumberOfRetries.Text = "1";
- this.c_NumberOfRetries.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
- //
- // label5
- //
- this.label5.Location = new System.Drawing.Point(208, 8);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(64, 16);
- this.label5.TabIndex = 2;
- this.label5.Text = "# of retries:";
- //
- // BurnDiscCopyForm
- //
- this.AcceptButton = this.c_Copy;
- this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
- this.CancelButton = this.c_Cancel;
- this.ClientSize = new System.Drawing.Size(490, 304);
- this.Controls.Add(this.c_SourceDrive);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.c_IgnoreDataErrors);
- this.Controls.Add(this.c_BrowseImage);
- this.Controls.Add(this.c_ImageFilepath);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.c_OnTheFly);
- this.Controls.Add(this.c_Recorders);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.c_Copy);
- this.Controls.Add(this.c_Cancel);
- this.Controls.Add(this.c_DeleteImage);
- this.Controls.Add(this.c_IgnoreAudioErrors);
- this.Controls.Add(this.c_ReadISRC);
- this.Controls.Add(this.c_RAWReadMode);
- this.Controls.Add(this.c_ReadSpeed);
- this.Controls.Add(this.c_WriteSpeed);
- this.Controls.Add(this.c_BurnFlags);
- this.Controls.Add(this.c_MediaType);
- this.Controls.Add(this.c_Settings);
- this.Controls.Add(this.label4);
- this.Controls.Add(this.c_NumberOfRetries);
- this.Controls.Add(this.label5);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "BurnDiscCopyForm";
- this.ShowInTaskbar = false;
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
- this.Text = "BurnDiscCopy";
- this.ResumeLayout(false);
- }
- #endregion
- protected override void OnLoad(EventArgs e)
- {
- base.OnLoad (e);
- c_SourceDrive.Text = m_sourceDrive.DeviceName;
- // Get the available drives.
- //
- m_recorders = m_nero.GetDrives(NERO_MEDIA_TYPE.NERO_MEDIA_CD | NERO_MEDIA_TYPE.NERO_MEDIA_DVD_ANY);
- // Loop through all drives looking for devices that can write
- // and which are allowed to write to.
- //
- int iIndex = 0;
- foreach (NeroDrive drive in m_recorders)
- {
- if (0 != (drive.Capabilities & NERO_CAPABILITIES.NERO_CAP_ALLOWED) &&
- drive.DevType == NERO_SCSI_DEVTYPE.NERO_SCSI_DEVTYPE_WORM)
- {
- c_Recorders.Items.Add (new CBItem (drive));
- // If there is no prior selection, let the currently
- // iterated drive be the current combobox selection
- // if it is not the same drive as the source drive.
- //
- if (c_Recorders.SelectedIndex == -1)
- {
- if (drive.HostAdapterNo != m_sourceDrive.HostAdapterNo &&
- drive.DeviceID != m_sourceDrive.DeviceID)
- {
- c_Recorders.SelectedIndex = iIndex;
- }
- }
- iIndex ++;
- }
- }
- // If nothing was selected until now, try selecting whatever
- // is the first option.
- //
- if (c_Recorders.SelectedIndex == -1)
- {
- c_Recorders.SelectedIndex = 0;
- }
- // Update some GUI elements.
- //
- Update_OnTheFly ();
- UpdateSettings ();
- }
- // This is a helper function to get the currently selected
- // NeroDrive or null for none.
- //
- private NeroDrive GetCurrentlySelectedDrive ()
- {
- return c_Recorders.SelectedIndex != -1? ((CBItem) c_Recorders.SelectedItem).m_drive : null;
- }
- // Update image filepath selection according to the state
- // of the "on the fly" checkbox. If on the fly, no image
- // is either required or accepted. Otherwise, one must be
- // supplied.
- //
- private void Update_OnTheFly ()
- {
- bool bEnabled = !c_OnTheFly.Checked;
- c_DeleteImage.Enabled = bEnabled;
- c_ImageFilepath.Enabled = bEnabled;
- c_BrowseImage.Enabled = bEnabled;
- }
- // This function updates the textbox showing the current state
- // of various settings.
- //
- private void UpdateSettings ()
- {
- string str;
- str = "Burn flags: " + m_frmChooseBurnFlags.ToString () + "\r\n\r\n";
- str += "Media type: " + m_frmChooseMedia.ToString () + "\r\n\r\n";
- str += "Write speed: " + m_frmChooseWriteSpeed.ToString () + "\r\n\r\n";
- str += "Read speed: " + m_frmChooseReadSpeed.ToString ();
- c_Settings.Text = str;
- }
- private void c_OnTheFly_CheckedChanged(object sender, System.EventArgs e)
- {
- Update_OnTheFly ();
- }
- private void c_BurnFlags_Click(object sender, System.EventArgs e)
- {
- if (DialogResult.OK == m_frmChooseBurnFlags.ShowDialog ())
- {
- UpdateSettings ();
- }
- }
- private void c_MediaType_Click(object sender, System.EventArgs e)
- {
- if (DialogResult.OK == m_frmChooseMedia.ShowDialog ())
- {
- UpdateSettings ();
- }
- }
- private void c_BrowseImage_Click(object sender, System.EventArgs e)
- {
- SaveFileDialog dlg = new SaveFileDialog ();
- dlg.DefaultExt = ".nrg";
- dlg.Filter = "NRG files (*.nrg)|*.nrg|All files (*.*)|*.*";
- if (DialogResult.OK == dlg.ShowDialog (this))
- {
- c_ImageFilepath.Text = dlg.FileName;
- }
- }
- private void c_WriteSpeed_Click(object sender, System.EventArgs e)
- {
- if (DialogResult.OK == m_frmChooseWriteSpeed.ShowDialog (this))
- {
- UpdateSettings ();
- }
- }
- private void c_Recorders_SelectedIndexChanged(object sender, System.EventArgs e)
- {
- NeroDrive currDrive = GetCurrentlySelectedDrive ();
- // When the currently selected recorder is changed, we must
- // set the new drive to the choose speed form.
- //
- m_frmChooseWriteSpeed.m_drive = currDrive;
- UpdateSettings ();
- if (currDrive != null &&
- currDrive.HostAdapterNo == m_sourceDrive.HostAdapterNo &&
- currDrive.DeviceID == m_sourceDrive.DeviceID)
- {
- // We cannot allow on the fly copy when the source and destination
- // drives are the same.
- //
- c_OnTheFly.Checked = false;
- }
- }
- private void c_ReadSpeed_Click(object sender, System.EventArgs e)
- {
- if (DialogResult.OK == m_frmChooseReadSpeed.ShowDialog (this))
- {
- UpdateSettings ();
- }
- }
- private void c_Copy_Click(object sender, System.EventArgs e)
- {
- NeroDrive destDrive = GetCurrentlySelectedDrive ();
- if (destDrive != null)
- {
- BurnProgressForm frm = new BurnProgressForm (destDrive, m_nero);
- frm.BurnDiscCopy (m_sourceDrive,
- c_OnTheFly.Checked,
- c_ImageFilepath.Text,
- c_DeleteImage.Checked,
- m_frmChooseReadSpeed.GetSpeed (),
- Convert.ToInt32 (c_NumberOfRetries.Text),
- c_IgnoreDataErrors.Checked,
- c_IgnoreAudioErrors.Checked,
- c_ReadISRC.Checked,
- c_RAWReadMode.Checked,
- m_frmChooseBurnFlags.GetBurnFlags (),
- m_frmChooseWriteSpeed.GetSpeed (),
- m_frmChooseMedia.GetMediaType (),
- this);
- }
- }
- }
- }
|