using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Runtime.InteropServices; using NEROLib; namespace NeroFiddlesCOM.NET { /// /// Summary description for Erase. /// public class EraseForm : System.Windows.Forms.Form { private NeroDrive m_drive; private System.Windows.Forms.Label label1; private System.Windows.Forms.ComboBox c_EraseMode; private System.Windows.Forms.TextBox c_Device; private System.Windows.Forms.Label label8; private System.Windows.Forms.Button c_Erase; private System.Windows.Forms.Button c_Cancel; private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox c_ErasingTime; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; private ControlEnabler m_controlEnabler; public EraseForm(NeroDrive drive) { // // Required for Windows Form Designer support // InitializeComponent(); m_controlEnabler = new ControlEnabler (this); m_drive = drive; } /// /// 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.label1 = new System.Windows.Forms.Label(); this.c_EraseMode = new System.Windows.Forms.ComboBox(); this.c_Device = new System.Windows.Forms.TextBox(); this.label8 = new System.Windows.Forms.Label(); this.c_Erase = new System.Windows.Forms.Button(); this.c_Cancel = new System.Windows.Forms.Button(); this.label2 = new System.Windows.Forms.Label(); this.c_ErasingTime = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // label1 // this.label1.Location = new System.Drawing.Point(8, 40); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(72, 16); this.label1.TabIndex = 0; this.label1.Text = "Erase mode:"; // // c_EraseMode // this.c_EraseMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.c_EraseMode.Items.AddRange(new object[] { "Entire", "Quick"}); this.c_EraseMode.Location = new System.Drawing.Point(8, 56); this.c_EraseMode.Name = "c_EraseMode"; this.c_EraseMode.Size = new System.Drawing.Size(121, 21); this.c_EraseMode.TabIndex = 1; this.c_EraseMode.SelectedIndexChanged += new System.EventHandler(this.c_EraseMode_SelectedIndexChanged); // // c_Device // this.c_Device.Location = new System.Drawing.Point(64, 8); 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 = 7; 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 = 6; this.label8.Text = "Device:"; // // c_Erase // this.c_Erase.DialogResult = System.Windows.Forms.DialogResult.OK; this.c_Erase.Location = new System.Drawing.Point(120, 96); this.c_Erase.Name = "c_Erase"; this.c_Erase.TabIndex = 4; this.c_Erase.Text = "Erase"; this.c_Erase.Click += new System.EventHandler(this.c_Erase_Click); // // c_Cancel // this.c_Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.c_Cancel.Location = new System.Drawing.Point(200, 96); this.c_Cancel.Name = "c_Cancel"; this.c_Cancel.TabIndex = 5; this.c_Cancel.Text = "Cancel"; // // label2 // this.label2.Location = new System.Drawing.Point(144, 40); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(72, 16); this.label2.TabIndex = 2; this.label2.Text = "Erasing time:"; // // c_ErasingTime // this.c_ErasingTime.Location = new System.Drawing.Point(144, 56); this.c_ErasingTime.Name = "c_ErasingTime"; this.c_ErasingTime.ReadOnly = true; this.c_ErasingTime.Size = new System.Drawing.Size(64, 20); this.c_ErasingTime.TabIndex = 3; this.c_ErasingTime.Text = ""; this.c_ErasingTime.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // // EraseForm // this.AcceptButton = this.c_Erase; this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.CancelButton = this.c_Cancel; this.ClientSize = new System.Drawing.Size(282, 128); this.Controls.Add(this.c_ErasingTime); this.Controls.Add(this.c_Device); this.Controls.Add(this.c_Erase); this.Controls.Add(this.label8); this.Controls.Add(this.c_EraseMode); this.Controls.Add(this.label1); this.Controls.Add(this.c_Cancel); this.Controls.Add(this.label2); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "EraseForm"; this.ShowInTaskbar = false; this.Text = "Erase"; this.ResumeLayout(false); } #endregion protected override void OnLoad(EventArgs e) { base.OnLoad (e); c_Device.Text = m_drive.DeviceName; // Make quick selected by default. // c_EraseMode.SelectedIndex = 1; } protected void UpdateErasingTime () { // Let's update the erasing time according to the // method chosen. // if (-1 != c_EraseMode.SelectedIndex) { // Quick erase is at index 1, while entire is at 0. // bool bQuick = c_EraseMode.SelectedIndex != 0; try { // Get the erasing time. The value returned is in seconds. // Let's convert it to mm:ss. // int iSeconds = m_drive.get_CDRWErasingTime (bQuick); int iMinutes = iSeconds/60; iSeconds %= 60; // Format the time with leading zeroes as mm:ss // c_ErasingTime.Text = iMinutes.ToString ("00") + ":" + iSeconds.ToString ("00"); c_Erase.Enabled = true; c_EraseMode.Enabled = true; } catch (COMException ex) { // If a COM exception occurs, we could not obtain the // time needed to erase the disc. // c_ErasingTime.Text = ""; c_Erase.Enabled = false; c_EraseMode.Enabled = false; MessageBox.Show (this, ex.Message ); } } else { c_ErasingTime.Text = ""; } } private void c_EraseMode_SelectedIndexChanged(object sender, System.EventArgs e) { // When the erase method is changed, display the new time. // UpdateErasingTime (); } private void c_Erase_Click(object sender, System.EventArgs e) { // When erase is reqested, hide the current form and display // the erase progress form. ShowDialog will start the actual // erase process. // bool bQuick = c_EraseMode.SelectedIndex != 0; EraseProgressForm frm = new EraseProgressForm (m_drive, bQuick); this.Hide (); frm.ShowDialog (this); } } }