123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 |
- 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 ChooseSession.
- /// ¸ÅҪ˵Ã÷ÁËÑ¡Ôñ»á»°¡£
- /// </summary>
- public class ChooseSessionForm : System.Windows.Forms.Form
- {
- private NeroDrive m_drive;
- 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 label5;
- private System.Windows.Forms.ListView c_PreviousVMS;
- private System.Windows.Forms.ColumnHeader columnHeader4;
- private System.Windows.Forms.ColumnHeader columnHeader2;
- private System.Windows.Forms.ListView c_PreviousSessions;
- private System.Windows.Forms.ColumnHeader columnHeader3;
- private System.Windows.Forms.ColumnHeader columnHeader1;
- private System.Windows.Forms.Button c_Refresh;
- private System.Windows.Forms.Label label6;
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.Container components = null;
- public ChooseSessionForm(NeroDrive drive)
- {
- //
- // Required for Windows Form Designer support
- //
- InitializeComponent();
- m_drive = drive;
- 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.label5 = new System.Windows.Forms.Label();
- this.c_PreviousVMS = new System.Windows.Forms.ListView();
- this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
- this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
- this.c_PreviousSessions = new System.Windows.Forms.ListView();
- this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
- this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
- this.c_Refresh = new System.Windows.Forms.Button();
- this.label6 = 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(269, 26);
- this.c_OK.Name = "c_OK";
- this.c_OK.Size = new System.Drawing.Size(90, 25);
- this.c_OK.TabIndex = 5;
- this.c_OK.Text = "OK";
- //
- // c_Cancel
- //
- this.c_Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- this.c_Cancel.Location = new System.Drawing.Point(269, 60);
- this.c_Cancel.Name = "c_Cancel";
- this.c_Cancel.Size = new System.Drawing.Size(90, 25);
- this.c_Cancel.TabIndex = 6;
- this.c_Cancel.Text = "Cancel";
- //
- // label5
- //
- this.label5.Location = new System.Drawing.Point(10, 9);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(120, 17);
- this.label5.TabIndex = 0;
- this.label5.Text = "Previous sessions:";
- //
- // c_PreviousVMS
- //
- this.c_PreviousVMS.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
- this.columnHeader4,
- this.columnHeader2});
- this.c_PreviousVMS.Enabled = false;
- this.c_PreviousVMS.FullRowSelect = true;
- this.c_PreviousVMS.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
- this.c_PreviousVMS.HideSelection = false;
- this.c_PreviousVMS.Location = new System.Drawing.Point(10, 172);
- this.c_PreviousVMS.MultiSelect = false;
- this.c_PreviousVMS.Name = "c_PreviousVMS";
- this.c_PreviousVMS.Size = new System.Drawing.Size(249, 121);
- this.c_PreviousVMS.TabIndex = 3;
- this.c_PreviousVMS.UseCompatibleStateImageBehavior = false;
- this.c_PreviousVMS.View = System.Windows.Forms.View.Details;
- //
- // columnHeader4
- //
- this.columnHeader4.Text = "T#";
- this.columnHeader4.Width = 33;
- //
- // columnHeader2
- //
- this.columnHeader2.Text = "Session Name";
- this.columnHeader2.Width = 152;
- //
- // c_PreviousSessions
- //
- this.c_PreviousSessions.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
- this.columnHeader3,
- this.columnHeader1});
- this.c_PreviousSessions.Enabled = false;
- this.c_PreviousSessions.FullRowSelect = true;
- this.c_PreviousSessions.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
- this.c_PreviousSessions.HideSelection = false;
- this.c_PreviousSessions.Location = new System.Drawing.Point(10, 26);
- this.c_PreviousSessions.MultiSelect = false;
- this.c_PreviousSessions.Name = "c_PreviousSessions";
- this.c_PreviousSessions.Size = new System.Drawing.Size(249, 120);
- this.c_PreviousSessions.TabIndex = 1;
- this.c_PreviousSessions.UseCompatibleStateImageBehavior = false;
- this.c_PreviousSessions.View = System.Windows.Forms.View.Details;
- //
- // columnHeader3
- //
- this.columnHeader3.Text = "Session number";
- this.columnHeader3.Width = 97;
- //
- // columnHeader1
- //
- this.columnHeader1.Text = "Track number";
- this.columnHeader1.Width = 85;
- //
- // c_Refresh
- //
- this.c_Refresh.Location = new System.Drawing.Point(269, 121);
- this.c_Refresh.Name = "c_Refresh";
- this.c_Refresh.Size = new System.Drawing.Size(90, 24);
- this.c_Refresh.TabIndex = 4;
- this.c_Refresh.Text = "Refresh";
- this.c_Refresh.Click += new System.EventHandler(this.c_Refresh_Click);
- //
- // label6
- //
- this.label6.Location = new System.Drawing.Point(10, 155);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(120, 17);
- this.label6.TabIndex = 2;
- this.label6.Text = "Previous VMS:";
- //
- // ChooseSessionForm
- //
- this.AcceptButton = this.c_OK;
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.CancelButton = this.c_Cancel;
- this.ClientSize = new System.Drawing.Size(457, 280);
- this.Controls.Add(this.label5);
- this.Controls.Add(this.c_PreviousVMS);
- this.Controls.Add(this.c_PreviousSessions);
- this.Controls.Add(this.c_Refresh);
- this.Controls.Add(this.label6);
- 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 = "ChooseSessionForm";
- this.ShowInTaskbar = false;
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
- this.Text = "ChooseSession";
- this.ResumeLayout(false);
- }
- #endregion
- protected override void OnLoad(EventArgs e)
- {
- base.OnLoad (e);
- // On load, display the sessions.
- //
- RefreshSessions ();
- }
- private void RefreshSessions()
- {
- // Subscribe to the OnDoneCDInfo event.
- //
- m_evOnDoneCDInfo = new _INeroDriveEvents_OnDoneCDInfoEventHandler(m_drive_OnDoneCDInfo);
- m_drive.OnDoneCDInfo += m_evOnDoneCDInfo;
- // We could do a this.Enabled=false here but then the wait
- // cursor will always be the arrow.
- //
- m_controlEnabler.EnableAllControls (false);
- this.Cursor = Cursors.WaitCursor;
- // When everything is setup, do the disc info.
- //
- m_drive.CDInfo (0);
- }
- private void c_Refresh_Click(object sender, System.EventArgs e)
- {
- // Refresh everything on request...
- //
- RefreshSessions ();
- }
- private void m_drive_OnDoneCDInfo(INeroCDInfo pCDInfo)
- {
- // When the disc info event fires, we should return
- // to the previous state of all controls, restore the
- // cursor and unsubscribe from the event.
- //
- m_controlEnabler.EnableAllControls (true);
- m_drive.OnDoneCDInfo -= m_evOnDoneCDInfo;
- c_PreviousSessions.Items.Clear ();
- c_PreviousVMS.Items.Clear ();
- NeroCDInfo cdinfo = (NeroCDInfo) pCDInfo;
- if (cdinfo != null)
- {
- // If we got a disc information, let's add all the data
- // tracks to the list view.
- //
- int iTrackCount = 0;
- foreach (NeroTrack trk in cdinfo.Tracks)
- {
- if (trk.TrackType == NERO_TRACK_TYPE.NERO_TT_DATA)
- {
- iTrackCount ++;
- ListViewItem lvi = c_PreviousSessions.Items.Add (trk.SessionNumber.ToString ());
- lvi.SubItems.Add (trk.TrackNumber.ToString ());
- }
- }
- int iVMSCount = 0;
- bool bVMS = 0 != (cdinfo.MediumFlags & NERO_MEDIUM_FLAGS.NCDIMF_VIRTUALMULTISESSION);
- // If there is VMS info, display that as well.
- //
- if (bVMS)
- {
- NeroVMSInfo vmsInfo = m_drive.GetVMSInfo ();
- if (vmsInfo != null)
- {
- iVMSCount = vmsInfo.Count;
- int i = 1;
- foreach (NeroVMSSession vmsSession in vmsInfo)
- {
- ListViewItem lvi = c_PreviousVMS.Items.Add (i.ToString ());
- lvi.SubItems.Add (vmsSession.SessionName);
- i++;
- }
- }
- }
- c_PreviousSessions.Enabled = !bVMS && iTrackCount > 0;
- c_PreviousVMS.Enabled = bVMS && iVMSCount > 0;
- }
- else
- {
- c_PreviousSessions.Enabled = false;
- c_PreviousVMS.Enabled = false;
- }
- this.Cursor = Cursors.Default;
- }
- // This is a public function for the outside world to
- // find out which is the selected previous session,
- // if any. It is required that NERO_IMPORT_ISO_TRACK_FLAGS
- // variable is passed by reference so that it is modified
- // if needed.
- //
- public int GetTrackNumber (ref NERO_IMPORT_ISO_TRACK_FLAGS importFlags)
- {
- int iTrackNumber = -1;
- if (c_PreviousSessions.Enabled && c_PreviousSessions.SelectedIndices.Count > 0)
- {
- iTrackNumber = Convert.ToInt32 (c_PreviousSessions.SelectedItems[0].SubItems[0].Text);
- }
- else if (c_PreviousVMS.Enabled && c_PreviousVMS.SelectedIndices.Count > 0)
- {
- iTrackNumber = Convert.ToInt32 (c_PreviousVMS.SelectedItems[0].Text);
- importFlags = (NERO_IMPORT_ISO_TRACK_FLAGS) ((uint)importFlags + (uint)NERO_IMPORT_ISO_TRACK_FLAGS.NERO_IMPORT_VMS_SESSION);
- }
- return iTrackNumber;
- }
- // This is a ToString override that returns the description of
- // the currently selected session.
- //
- public new string ToString ()
- {
- NERO_IMPORT_ISO_TRACK_FLAGS importFlags = 0;
- int iTrackNumber = GetTrackNumber (ref importFlags);
- if (iTrackNumber != -1)
- {
- return iTrackNumber.ToString () + (0 != (importFlags & NERO_IMPORT_ISO_TRACK_FLAGS.NERO_IMPORT_VMS_SESSION)? " (VMS)" : "");
- }
- else
- {
- return "<none>";
- }
- }
- }
- }
|