123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Runtime.InteropServices;
- using NEROLib;
- namespace LYFZ.NeroDiscBurn.NET
- {
- /// <summary>
- /// Summary description for Erase.
- /// </summary>
- 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;
- /// <summary>
- /// Required designer variable.
- /// </summary>
- 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;
- }
- /// <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.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(10, 43);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(86, 17);
- 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(10, 60);
- this.c_EraseMode.Name = "c_EraseMode";
- this.c_EraseMode.Size = new System.Drawing.Size(145, 20);
- 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(77, 9);
- this.c_Device.Name = "c_Device";
- this.c_Device.ReadOnly = true;
- this.c_Device.Size = new System.Drawing.Size(249, 21);
- this.c_Device.TabIndex = 7;
- //
- // label8
- //
- this.label8.Location = new System.Drawing.Point(10, 9);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(67, 17);
- 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(144, 103);
- this.c_Erase.Name = "c_Erase";
- this.c_Erase.Size = new System.Drawing.Size(90, 25);
- 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(240, 103);
- this.c_Cancel.Name = "c_Cancel";
- this.c_Cancel.Size = new System.Drawing.Size(90, 25);
- this.c_Cancel.TabIndex = 5;
- this.c_Cancel.Text = "Cancel";
- //
- // label2
- //
- this.label2.Location = new System.Drawing.Point(173, 43);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(86, 17);
- this.label2.TabIndex = 2;
- this.label2.Text = "Erasing time:";
- //
- // c_ErasingTime
- //
- this.c_ErasingTime.Location = new System.Drawing.Point(173, 60);
- this.c_ErasingTime.Name = "c_ErasingTime";
- this.c_ErasingTime.ReadOnly = true;
- this.c_ErasingTime.Size = new System.Drawing.Size(77, 21);
- this.c_ErasingTime.TabIndex = 3;
- this.c_ErasingTime.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
- //
- // EraseForm
- //
- this.AcceptButton = this.c_Erase;
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.CancelButton = this.c_Cancel;
- this.ClientSize = new System.Drawing.Size(419, 150);
- 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);
- this.PerformLayout();
- }
- #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);
- }
- }
- }
|