123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- 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 ChooseSpeedForm.
- /// </summary>
- 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;
- /// <summary>
- /// Required designer variable.
- /// </summary>
- 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);
- }
- /// <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_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);
- }
- }
- }
|