using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using NEROLib; namespace NeroFiddlesCOM.NET { /// /// Summary description for ChooseSpeedForm. /// public class ChooseSpeedForm : System.Windows.Forms.Form { public NeroDrive m_drive; private bool m_bWriteSpeeds; private _INeroDriveEvents_OnDoneCDInfoEventHandler m_evOnDoneCDInfo; private ControlEnabler m_controlEnabler; private System.Windows.Forms.Button c_OK; private System.Windows.Forms.Button c_Cancel; private System.Windows.Forms.Label label1; private SpeedComboBox c_Speeds; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public ChooseSpeedForm(NeroDrive drive, bool bWriteSpeeds) { // // Required for Windows Form Designer support // InitializeComponent(); m_drive = drive; m_bWriteSpeeds = bWriteSpeeds; m_controlEnabler = new ControlEnabler (this); } /// /// 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_OK = new System.Windows.Forms.Button(); this.c_Cancel = new System.Windows.Forms.Button(); this.c_Speeds = new SpeedComboBox(); this.label1 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // c_OK // this.c_OK.DialogResult = System.Windows.Forms.DialogResult.OK; this.c_OK.Location = new System.Drawing.Point(144, 8); this.c_OK.Name = "c_OK"; this.c_OK.TabIndex = 2; this.c_OK.Text = "OK"; // // c_Cancel // this.c_Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.c_Cancel.Location = new System.Drawing.Point(144, 40); this.c_Cancel.Name = "c_Cancel"; this.c_Cancel.TabIndex = 3; this.c_Cancel.Text = "Cancel"; // // c_Speeds // this.c_Speeds.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.c_Speeds.Location = new System.Drawing.Point(8, 24); this.c_Speeds.Name = "c_Speeds"; this.c_Speeds.Size = new System.Drawing.Size(121, 21); this.c_Speeds.TabIndex = 1; // // label1 // this.label1.Location = new System.Drawing.Point(8, 8); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(100, 16); this.label1.TabIndex = 0; this.label1.Text = "Speeds:"; // // ChooseSpeedForm // this.AcceptButton = this.c_OK; this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.CancelButton = this.c_Cancel; this.ClientSize = new System.Drawing.Size(226, 72); this.Controls.Add(this.label1); this.Controls.Add(this.c_Speeds); this.Controls.Add(this.c_OK); this.Controls.Add(this.c_Cancel); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "ChooseSpeedForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Choose Speed"; this.ResumeLayout(false); } #endregion protected override void OnLoad(EventArgs e) { base.OnLoad (e); // The same form is used both for read and write speeds. // this.Text = m_bWriteSpeeds? "Choose write speed:": "Choose read speed:"; // Disable all form controls and display wait cursor. // c_Speeds.Items.Clear (); m_controlEnabler.EnableAllControls (false); this.Cursor = Cursors.WaitCursor; // Subscribe to event and do a disc info. // m_evOnDoneCDInfo = new _INeroDriveEvents_OnDoneCDInfoEventHandler(m_drive_OnDoneCDInfo); m_drive.OnDoneCDInfo += m_evOnDoneCDInfo; m_drive.CDInfo (0); } public new string ToString () { return c_Speeds.ToString (); } public int GetSpeed () { return c_Speeds.GetSpeed (); } private void m_drive_OnDoneCDInfo(INeroCDInfo pCDInfo) { // Unsubscribe from event, get the speeds and populate the // speeds combobox with it. // m_drive.OnDoneCDInfo -= m_evOnDoneCDInfo; NERO_MEDIA_TYPE nmt = pCDInfo != null? pCDInfo.MediaType: NERO_MEDIA_TYPE.NERO_MEDIA_NONE; NeroSpeeds speeds = m_drive.get_AvailableSpeeds (m_bWriteSpeeds? NERO_ACCESSTYPE.NERO_ACCESSTYPE_WRITE: NERO_ACCESSTYPE.NERO_ACCESSTYPE_READ, nmt); c_Speeds.Populate (speeds); this.Cursor = Cursors.Default; m_controlEnabler.EnableAllControls (true); } } }