123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- 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 EstimateTrackSize.
- /// </summary>
- public class EstimateTrackSizeForm : System.Windows.Forms.Form
- {
- private NeroDrive m_drive;
- private NeroISOTrack m_isoTrack;
- private NERO_MEDIA_TYPE m_MediaType;
- private NERO_BURN_FLAGS m_BurnFlags;
- private _INeroDriveEvents_OnDoneEstimateTrackSizeEventHandler m_evOnDoneEstimateTrackSize;
- private System.Windows.Forms.Button c_Estimate;
- private System.Windows.Forms.Button c_Cancel;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.ListView c_Flags;
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.Container components = null;
- public EstimateTrackSizeForm(NeroDrive drive, NeroISOTrack isoTrack, NERO_MEDIA_TYPE mediaType, NERO_BURN_FLAGS burnFlags)
- {
- //
- // Required for Windows Form Designer support
- //
- InitializeComponent();
- m_drive = drive;
- m_isoTrack = isoTrack;
- m_MediaType = mediaType;
- m_BurnFlags = burnFlags;
- }
- /// <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.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem("File system overhead");
- System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem("Data");
- System.Windows.Forms.ListViewItem listViewItem3 = new System.Windows.Forms.ListViewItem("Exact size");
- this.c_Estimate = new System.Windows.Forms.Button();
- this.c_Cancel = new System.Windows.Forms.Button();
- this.c_Flags = new System.Windows.Forms.ListView();
- this.label1 = new System.Windows.Forms.Label();
- this.SuspendLayout();
- //
- // c_Estimate
- //
- this.c_Estimate.Location = new System.Drawing.Point(200, 8);
- this.c_Estimate.Name = "c_Estimate";
- this.c_Estimate.TabIndex = 2;
- this.c_Estimate.Text = "Estimate";
- this.c_Estimate.Click += new System.EventHandler(this.c_Estimate_Click);
- //
- // c_Cancel
- //
- this.c_Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- this.c_Cancel.Location = new System.Drawing.Point(200, 40);
- this.c_Cancel.Name = "c_Cancel";
- this.c_Cancel.TabIndex = 3;
- this.c_Cancel.Text = "Cancel";
- //
- // c_Flags
- //
- this.c_Flags.CheckBoxes = true;
- listViewItem1.StateImageIndex = 0;
- listViewItem1.Tag = NEROLib.NERO_ESTIMATE_FLAGS.NETS_FILESYSTEM_OVERHEAD;
- listViewItem2.StateImageIndex = 0;
- listViewItem2.Tag = NEROLib.NERO_ESTIMATE_FLAGS.NETS_DATA;
- listViewItem3.StateImageIndex = 0;
- listViewItem3.Tag = NEROLib.NERO_ESTIMATE_FLAGS.NETS_EXACT_SIZE;
- this.c_Flags.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
- listViewItem1,
- listViewItem2,
- listViewItem3});
- this.c_Flags.Location = new System.Drawing.Point(8, 24);
- this.c_Flags.Name = "c_Flags";
- this.c_Flags.Size = new System.Drawing.Size(184, 64);
- this.c_Flags.TabIndex = 1;
- this.c_Flags.View = System.Windows.Forms.View.SmallIcon;
- //
- // 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 = "Flags:";
- //
- // EstimateTrackSizeForm
- //
- this.AcceptButton = this.c_Estimate;
- this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
- this.CancelButton = this.c_Cancel;
- this.ClientSize = new System.Drawing.Size(282, 96);
- this.Controls.Add(this.label1);
- this.Controls.Add(this.c_Flags);
- this.Controls.Add(this.c_Estimate);
- this.Controls.Add(this.c_Cancel);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "EstimateTrackSizeForm";
- this.ShowInTaskbar = false;
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
- this.Text = "EstimateTrackSize";
- this.ResumeLayout(false);
- }
- #endregion
- private void c_Estimate_Click(object sender, System.EventArgs e)
- {
- // When estimate is requested, prepare the information we need
- // to pass on to the EstimateTrackSize.
- //
- NeroFileSystemTrackOptions nfsto = new NeroFileSystemTrackOptionsClass ();
- nfsto.BurnFlags = m_BurnFlags;
- nfsto.MediaType = m_MediaType;
- // Get estimate flags from the list view.
- //
- uint uFlags = 0;
- foreach (ListViewItem lvi in c_Flags.Items)
- {
- if (lvi.Checked)
- {
- uFlags |= (uint) (NERO_ESTIMATE_FLAGS) lvi.Tag;
- }
- }
- // Subscribe to the OnDoneEstimateTrackSize event.
- //
- m_evOnDoneEstimateTrackSize = new _INeroDriveEvents_OnDoneEstimateTrackSizeEventHandler(m_drive_OnDoneEstimateTrackSize);
- m_drive.OnDoneEstimateTrackSize += m_evOnDoneEstimateTrackSize;
- // Finally, do the estimation with the information we
- // have just assembled.
- //
- m_drive.EstimateTrackSize (m_isoTrack, (NERO_ESTIMATE_FLAGS) uFlags, nfsto);
- }
- private void m_drive_OnDoneEstimateTrackSize(bool bOk, int BlockSize)
- {
- // When the estimation is done, unsubscribe from the event
- // and show success or failure.
- //
- m_drive.OnDoneEstimateTrackSize -= m_evOnDoneEstimateTrackSize;
- if (bOk)
- {
- // If everything was ok, let's show the user the estimate
- // in blocks and bytes.
- //
- MessageBox.Show (this, "Track is estimated to "
- + BlockSize.ToString ()
- + " blocks or "
- + (BlockSize*2048).ToString ()
- + " bytes.");
- }
- else
- {
- MessageBox.Show (this, "There was an error getting track size estimate!");
- }
- }
- }
- }
|