123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549 |
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data;
- using NEROLib;
- namespace LYFZ.NeroDiscBurn.NET
- {
- /// <summary>
- /// Summary description for MainForm.
- /// </summary>
- public class MainForm : System.Windows.Forms.Form
- {
- private Nero m_nero;
- private NeroDrives m_devices;
- private NeroDrive m_lastDrive;
- private _INeroDriveEvents_OnDriveStatusChangedEventHandler m_evDriveStatusChanged;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.ComboBox c_Devices;
- private System.Windows.Forms.Button c_BurnIsoAudio;
- private System.Windows.Forms.Button c_Erase;
- private System.Windows.Forms.Button c_BurnImage;
- private System.Windows.Forms.Button c_Exit;
- private System.Windows.Forms.Button c_DriveInfo;
- private System.Windows.Forms.Button c_Eject;
- private System.Windows.Forms.Button c_Load;
- private System.Windows.Forms.Button c_DAE;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.Label c_LastDriveStatus;
- private System.Windows.Forms.Button c_BurnCopy;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.Label c_APIVersion;
- private System.Windows.Forms.Button c_ImageInfo;
- private System.Windows.Forms.Button c_DiscInfo;
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.GroupBox groupBox2;
- private System.Windows.Forms.GroupBox groupBox3;
- private System.Windows.Forms.GroupBox groupBox4;
- private System.Windows.Forms.Button c_NVAPI;
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.Container components = null;
- public MainForm()
- {
- //
- // Required for Windows Form Designer support
- //
- InitializeComponent();
- }
- protected override void OnLoad(EventArgs e)
- {
- base.OnLoad (e);
- // When the main form loads, let's create the Nero object first.
- // Then get the available devices and fill the combobox.
- //
- m_nero = new NeroClass();
- m_devices = m_nero.GetDrives(NERO_MEDIA_TYPE.NERO_MEDIA_CD);
- for (int i = 0; i < m_devices.Count; i ++)
- {
- NeroDrive drive = (NeroDrive) m_devices.Item (i);
- string sDriveLetter = (drive.DriveLetter == "")? "?": drive.DriveLetter.ToUpper ();
- c_Devices.Items.Add (sDriveLetter + ": " + drive.DeviceName);
- }
- c_Devices.SelectedIndex = 0;
- // Show the version.
- //
- short v1 = 0, v2 = 0, v3 = 0, v4 = 0;
- m_nero.APIVersion (ref v1, ref v2, ref v3, ref v4);
- c_APIVersion.Text = v1.ToString () + "." + v2.ToString () + "." + v3.ToString () + "." + v4.ToString ();
- }
- /// <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()
- {
- System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
- this.label1 = new System.Windows.Forms.Label();
- this.c_DiscInfo = new System.Windows.Forms.Button();
- this.c_Devices = new System.Windows.Forms.ComboBox();
- this.c_BurnIsoAudio = new System.Windows.Forms.Button();
- this.c_Erase = new System.Windows.Forms.Button();
- this.c_BurnImage = new System.Windows.Forms.Button();
- this.c_Exit = new System.Windows.Forms.Button();
- this.c_DriveInfo = new System.Windows.Forms.Button();
- this.c_Eject = new System.Windows.Forms.Button();
- this.c_Load = new System.Windows.Forms.Button();
- this.c_DAE = new System.Windows.Forms.Button();
- this.label2 = new System.Windows.Forms.Label();
- this.c_LastDriveStatus = new System.Windows.Forms.Label();
- this.c_BurnCopy = new System.Windows.Forms.Button();
- this.label3 = new System.Windows.Forms.Label();
- this.c_APIVersion = new System.Windows.Forms.Label();
- this.c_ImageInfo = new System.Windows.Forms.Button();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.groupBox4 = new System.Windows.Forms.GroupBox();
- this.c_NVAPI = new System.Windows.Forms.Button();
- this.SuspendLayout();
- //
- // label1
- //
- this.label1.Location = new System.Drawing.Point(10, 9);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(144, 17);
- this.label1.TabIndex = 0;
- this.label1.Text = "设备:";
- //
- // c_DiscInfo
- //
- this.c_DiscInfo.Location = new System.Drawing.Point(19, 155);
- this.c_DiscInfo.Name = "c_DiscInfo";
- this.c_DiscInfo.Size = new System.Drawing.Size(96, 25);
- this.c_DiscInfo.TabIndex = 8;
- this.c_DiscInfo.Text = "光盘信息";
- this.c_DiscInfo.Click += new System.EventHandler(this.DiscInfo_Click);
- //
- // c_Devices
- //
- this.c_Devices.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.c_Devices.Location = new System.Drawing.Point(10, 26);
- this.c_Devices.Name = "c_Devices";
- this.c_Devices.Size = new System.Drawing.Size(230, 20);
- this.c_Devices.TabIndex = 1;
- this.c_Devices.SelectedIndexChanged += new System.EventHandler(this.c_Devices_SelectedIndexChanged);
- //
- // c_BurnIsoAudio
- //
- this.c_BurnIsoAudio.Location = new System.Drawing.Point(144, 121);
- this.c_BurnIsoAudio.Name = "c_BurnIsoAudio";
- this.c_BurnIsoAudio.Size = new System.Drawing.Size(96, 24);
- this.c_BurnIsoAudio.TabIndex = 11;
- this.c_BurnIsoAudio.Text = "刻录ISO音频";
- this.c_BurnIsoAudio.Click += new System.EventHandler(this.c_BurnIsoAudio_Click);
- //
- // c_Erase
- //
- this.c_Erase.Location = new System.Drawing.Point(394, 155);
- this.c_Erase.Name = "c_Erase";
- this.c_Erase.Size = new System.Drawing.Size(96, 25);
- this.c_Erase.TabIndex = 20;
- this.c_Erase.Text = "擦写";
- this.c_Erase.Click += new System.EventHandler(this.c_Erase_Click);
- //
- // c_BurnImage
- //
- this.c_BurnImage.Location = new System.Drawing.Point(144, 155);
- this.c_BurnImage.Name = "c_BurnImage";
- this.c_BurnImage.Size = new System.Drawing.Size(96, 25);
- this.c_BurnImage.TabIndex = 12;
- this.c_BurnImage.Text = "刻录映像";
- this.c_BurnImage.Click += new System.EventHandler(this.c_BurnImage_Click);
- //
- // c_Exit
- //
- this.c_Exit.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- this.c_Exit.Location = new System.Drawing.Point(403, 17);
- this.c_Exit.Name = "c_Exit";
- this.c_Exit.Size = new System.Drawing.Size(96, 25);
- this.c_Exit.TabIndex = 21;
- this.c_Exit.Text = "退出";
- this.c_Exit.Click += new System.EventHandler(this.c_Exit_Click);
- //
- // c_DriveInfo
- //
- this.c_DriveInfo.Location = new System.Drawing.Point(19, 121);
- this.c_DriveInfo.Name = "c_DriveInfo";
- this.c_DriveInfo.Size = new System.Drawing.Size(96, 24);
- this.c_DriveInfo.TabIndex = 7;
- this.c_DriveInfo.Text = "驱动器信息";
- this.c_DriveInfo.Click += new System.EventHandler(this.c_DriveInfo_Click);
- //
- // c_Eject
- //
- this.c_Eject.Location = new System.Drawing.Point(269, 121);
- this.c_Eject.Name = "c_Eject";
- this.c_Eject.Size = new System.Drawing.Size(96, 24);
- this.c_Eject.TabIndex = 16;
- this.c_Eject.Text = "弹出";
- this.c_Eject.Click += new System.EventHandler(this.c_Eject_Click);
- //
- // c_Load
- //
- this.c_Load.Location = new System.Drawing.Point(269, 155);
- this.c_Load.Name = "c_Load";
- this.c_Load.Size = new System.Drawing.Size(96, 25);
- this.c_Load.TabIndex = 17;
- this.c_Load.Text = "装入";
- this.c_Load.Click += new System.EventHandler(this.c_Load_Click);
- //
- // c_DAE
- //
- this.c_DAE.Location = new System.Drawing.Point(394, 121);
- this.c_DAE.Name = "c_DAE";
- this.c_DAE.Size = new System.Drawing.Size(96, 24);
- this.c_DAE.TabIndex = 19;
- this.c_DAE.Text = "DAE(插件)";
- this.c_DAE.Click += new System.EventHandler(this.c_DAE_Click);
- //
- // label2
- //
- this.label2.Location = new System.Drawing.Point(10, 60);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(115, 18);
- this.label2.TabIndex = 4;
- this.label2.Text = "最后驱动器状态:";
- //
- // c_LastDriveStatus
- //
- this.c_LastDriveStatus.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
- this.c_LastDriveStatus.Location = new System.Drawing.Point(134, 60);
- this.c_LastDriveStatus.Name = "c_LastDriveStatus";
- this.c_LastDriveStatus.Size = new System.Drawing.Size(202, 18);
- this.c_LastDriveStatus.TabIndex = 5;
- //
- // c_BurnCopy
- //
- this.c_BurnCopy.Location = new System.Drawing.Point(144, 190);
- this.c_BurnCopy.Name = "c_BurnCopy";
- this.c_BurnCopy.Size = new System.Drawing.Size(96, 24);
- this.c_BurnCopy.TabIndex = 13;
- this.c_BurnCopy.Text = "光盘复制";
- this.c_BurnCopy.Click += new System.EventHandler(this.c_BurnCopy_Click);
- //
- // label3
- //
- this.label3.Location = new System.Drawing.Point(250, 9);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(105, 17);
- this.label3.TabIndex = 2;
- this.label3.Text = "API版本:";
- //
- // c_APIVersion
- //
- this.c_APIVersion.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
- this.c_APIVersion.Location = new System.Drawing.Point(250, 26);
- this.c_APIVersion.Name = "c_APIVersion";
- this.c_APIVersion.Size = new System.Drawing.Size(115, 17);
- this.c_APIVersion.TabIndex = 3;
- //
- // c_ImageInfo
- //
- this.c_ImageInfo.Location = new System.Drawing.Point(19, 190);
- this.c_ImageInfo.Name = "c_ImageInfo";
- this.c_ImageInfo.Size = new System.Drawing.Size(96, 24);
- this.c_ImageInfo.TabIndex = 9;
- this.c_ImageInfo.Text = "映像信息";
- this.c_ImageInfo.Click += new System.EventHandler(this.c_ImageInfo_Click);
- //
- // groupBox1
- //
- this.groupBox1.Location = new System.Drawing.Point(10, 95);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(115, 163);
- this.groupBox1.TabIndex = 6;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "信息";
- //
- // groupBox2
- //
- this.groupBox2.Location = new System.Drawing.Point(134, 95);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(116, 163);
- this.groupBox2.TabIndex = 10;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "烧录(Burn)";
- //
- // groupBox3
- //
- this.groupBox3.Location = new System.Drawing.Point(259, 95);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(115, 163);
- this.groupBox3.TabIndex = 15;
- this.groupBox3.TabStop = false;
- this.groupBox3.Text = "弹出/装入";
- //
- // groupBox4
- //
- this.groupBox4.Location = new System.Drawing.Point(384, 95);
- this.groupBox4.Name = "groupBox4";
- this.groupBox4.Size = new System.Drawing.Size(115, 163);
- this.groupBox4.TabIndex = 18;
- this.groupBox4.TabStop = false;
- this.groupBox4.Text = "杂项";
- //
- // c_NVAPI
- //
- this.c_NVAPI.Location = new System.Drawing.Point(144, 224);
- this.c_NVAPI.Name = "c_NVAPI";
- this.c_NVAPI.Size = new System.Drawing.Size(96, 25);
- this.c_NVAPI.TabIndex = 14;
- this.c_NVAPI.Text = "刻录NVAPI";
- this.c_NVAPI.Click += new System.EventHandler(this.c_NVAPI_Click);
- //
- // MainForm
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.CancelButton = this.c_Exit;
- this.ClientSize = new System.Drawing.Size(532, 295);
- this.Controls.Add(this.c_NVAPI);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.c_DriveInfo);
- this.Controls.Add(this.c_Exit);
- this.Controls.Add(this.c_Erase);
- this.Controls.Add(this.c_BurnIsoAudio);
- this.Controls.Add(this.c_Devices);
- this.Controls.Add(this.c_DiscInfo);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.c_BurnImage);
- this.Controls.Add(this.c_Eject);
- this.Controls.Add(this.c_Load);
- this.Controls.Add(this.c_DAE);
- this.Controls.Add(this.c_LastDriveStatus);
- this.Controls.Add(this.c_BurnCopy);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.c_APIVersion);
- this.Controls.Add(this.c_ImageInfo);
- this.Controls.Add(this.groupBox1);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox3);
- this.Controls.Add(this.groupBox4);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
- this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
- this.MaximizeBox = false;
- this.Name = "MainForm";
- this.Text = "NeroFiddlesCOM.NET";
- this.ResumeLayout(false);
- }
- #endregion
- /* /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- static void Main()
- {
- Application.Run(new MainForm());
- }*/
- // This is a helper function to get the currently selected drive
- // from the combobox as NeroDrive.
- //
- private NeroDrive GetCurrentlySelectedDrive ()
- {
- return c_Devices.SelectedIndex == -1? null: (NeroDrive) m_devices.Item(c_Devices.SelectedIndex);
- }
- private void DiscInfo_Click(object sender, System.EventArgs e)
- {
- // Show the disc info form.
- //
- DiscInfoForm frm = new DiscInfoForm (GetCurrentlySelectedDrive (), m_nero);
- frm.ShowDialog (this);
- }
- private void c_BurnIsoAudio_Click(object sender, System.EventArgs e)
- {
- // Show the burn iso audio form.
- //
- BurnIsoAudioForm frm = new BurnIsoAudioForm (GetCurrentlySelectedDrive (), m_nero);
-
- frm.ShowDialog (this);
- }
- private void c_Erase_Click(object sender, System.EventArgs e)
- {
- // Show the erase form.
- //
- EraseForm frm = new EraseForm (GetCurrentlySelectedDrive ());
-
- frm.ShowDialog (this);
- }
- private void c_BurnImage_Click(object sender, System.EventArgs e)
- {
- // Show the burn image form.
- //
- BurnImageForm frm = new BurnImageForm (GetCurrentlySelectedDrive (), m_nero);
-
- frm.ShowDialog (this);
- }
- private void c_Exit_Click(object sender, System.EventArgs e)
- {
- this.Close ();
- }
- private void c_DriveInfo_Click(object sender, System.EventArgs e)
- {
- // Show drive info form.
- //
- DriveInfoForm frm = new DriveInfoForm (m_nero, GetCurrentlySelectedDrive ());
-
- frm.ShowDialog (this);
- }
- private void c_Eject_Click(object sender, System.EventArgs e)
- {
- // Eject the current drive.
- //
- NeroDrive drive = GetCurrentlySelectedDrive ();
- if (drive != null)
- {
- drive.EjectCD ();
- }
- }
- private void c_Load_Click(object sender, System.EventArgs e)
- {
- // Load the current drive.
- //
- NeroDrive drive = GetCurrentlySelectedDrive ();
- if (drive != null)
- {
- drive.LoadCD ();
- }
- }
- private void c_DAE_Click(object sender, System.EventArgs e)
- {
- // Show the DAE form.
- //
- DAEForm frm = new DAEForm (GetCurrentlySelectedDrive ());
- frm.ShowDialog (this);
- }
- private void c_Devices_SelectedIndexChanged(object sender, System.EventArgs e)
- {
- // When selected index of the drive combobox is changed, let's
- // disable the status callback on that drive and enable it on
- // the new one.
- //
- if (m_lastDrive != null)
- {
- m_lastDrive.EnableStatusCallback (NERO_DRIVESTATUS_TYPE.NDT_DISC_CHANGE, false);
- m_lastDrive.EnableStatusCallback (NERO_DRIVESTATUS_TYPE.NDT_IN_USE_CHANGE, false);
- m_lastDrive.OnDriveStatusChanged -= m_evDriveStatusChanged;
- }
- m_lastDrive = GetCurrentlySelectedDrive ();
- if (m_lastDrive != null)
- {
- c_LastDriveStatus.Text = "<none>";
- m_evDriveStatusChanged = new _INeroDriveEvents_OnDriveStatusChangedEventHandler(m_lastDrive_OnDriveStatusChanged);
- m_lastDrive.OnDriveStatusChanged += m_evDriveStatusChanged;
- m_lastDrive.EnableStatusCallback (NERO_DRIVESTATUS_TYPE.NDT_DISC_CHANGE, true);
- m_lastDrive.EnableStatusCallback (NERO_DRIVESTATUS_TYPE.NDT_IN_USE_CHANGE, true);
- }
- }
- private void m_lastDrive_OnDriveStatusChanged(NERO_DRIVESTATUS_RESULT driveStatus)
- {
- // When the status is changed on the currently selected drive,
- // let's display it.
- //
- string sStatus;
- switch (driveStatus)
- {
- case NERO_DRIVESTATUS_RESULT.NDR_DISC_INSERTED:
- sStatus = "Disc inserted";
- break;
- case NERO_DRIVESTATUS_RESULT.NDR_DISC_REMOVED:
- sStatus = "Disc removed";
- break;
- case NERO_DRIVESTATUS_RESULT.NDR_DRIVE_IN_USE:
- sStatus = "Drive in use";
- break;
- case NERO_DRIVESTATUS_RESULT.NDR_DRIVE_NOT_IN_USE:
- sStatus = "Drive not in use";
- break;
- default:
- sStatus = "Unknown status";
- break;
- }
- c_LastDriveStatus.Text = sStatus;
- }
- private void c_BurnCopy_Click(object sender, System.EventArgs e)
- {
- // Show the disc copy form.
- //
- BurnDiscCopyForm frm = new BurnDiscCopyForm (m_nero, GetCurrentlySelectedDrive ());
- frm.ShowDialog (this);
- }
- private void c_ImageInfo_Click(object sender, System.EventArgs e)
- {
- // Show the disc info form but initialize it with a different
- // constructor. But first, get the user to select an image file.
- //
- OpenFileDialog dlg = new OpenFileDialog ();
- dlg.CheckFileExists = true;
- dlg.CheckPathExists = true;
- dlg.DefaultExt = ".nrg";
- dlg.Filter = "All image files|*.nrg;*.iso|NRG files (*.nrg)|*.nrg|ISO files (*.iso)|*.iso|All files (*.*)|*.*";
- if (DialogResult.OK == dlg.ShowDialog (this))
- {
- DiscInfoForm frm = new DiscInfoForm (dlg.FileName, m_nero);
- frm.ShowDialog (this);
- }
- }
- private void c_NVAPI_Click(object sender, System.EventArgs e)
- {
- // Show the form that allows to burn a NeroVisionAPI XML
- // project.
- //
- NVAPIForm frm = new NVAPIForm (GetCurrentlySelectedDrive (), m_nero);
- frm.ShowDialog (this);
- }
- }
- }
|