EstimateTrackSize.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using NEROLib;
  7. namespace LYFZ.NeroDiscBurn.NET
  8. {
  9. /// <summary>
  10. /// Summary description for EstimateTrackSize.
  11. /// </summary>
  12. public class EstimateTrackSizeForm : System.Windows.Forms.Form
  13. {
  14. private NeroDrive m_drive;
  15. private NeroISOTrack m_isoTrack;
  16. private NERO_MEDIA_TYPE m_MediaType;
  17. private NERO_BURN_FLAGS m_BurnFlags;
  18. private _INeroDriveEvents_OnDoneEstimateTrackSizeEventHandler m_evOnDoneEstimateTrackSize;
  19. private System.Windows.Forms.Button c_Estimate;
  20. private System.Windows.Forms.Button c_Cancel;
  21. private System.Windows.Forms.Label label1;
  22. private System.Windows.Forms.ListView c_Flags;
  23. /// <summary>
  24. /// Required designer variable.
  25. /// </summary>
  26. private System.ComponentModel.Container components = null;
  27. public EstimateTrackSizeForm(NeroDrive drive, NeroISOTrack isoTrack, NERO_MEDIA_TYPE mediaType, NERO_BURN_FLAGS burnFlags)
  28. {
  29. //
  30. // Required for Windows Form Designer support
  31. //
  32. InitializeComponent();
  33. m_drive = drive;
  34. m_isoTrack = isoTrack;
  35. m_MediaType = mediaType;
  36. m_BurnFlags = burnFlags;
  37. }
  38. /// <summary>
  39. /// Clean up any resources being used.
  40. /// </summary>
  41. protected override void Dispose( bool disposing )
  42. {
  43. if( disposing )
  44. {
  45. if(components != null)
  46. {
  47. components.Dispose();
  48. }
  49. }
  50. base.Dispose( disposing );
  51. }
  52. #region Windows Form Designer generated code
  53. /// <summary>
  54. /// Required method for Designer support - do not modify
  55. /// the contents of this method with the code editor.
  56. /// </summary>
  57. private void InitializeComponent()
  58. {
  59. System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem("File system overhead");
  60. System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem("Data");
  61. System.Windows.Forms.ListViewItem listViewItem3 = new System.Windows.Forms.ListViewItem("Exact size");
  62. this.c_Estimate = new System.Windows.Forms.Button();
  63. this.c_Cancel = new System.Windows.Forms.Button();
  64. this.c_Flags = new System.Windows.Forms.ListView();
  65. this.label1 = new System.Windows.Forms.Label();
  66. this.SuspendLayout();
  67. //
  68. // c_Estimate
  69. //
  70. this.c_Estimate.Location = new System.Drawing.Point(200, 8);
  71. this.c_Estimate.Name = "c_Estimate";
  72. this.c_Estimate.TabIndex = 2;
  73. this.c_Estimate.Text = "Estimate";
  74. this.c_Estimate.Click += new System.EventHandler(this.c_Estimate_Click);
  75. //
  76. // c_Cancel
  77. //
  78. this.c_Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  79. this.c_Cancel.Location = new System.Drawing.Point(200, 40);
  80. this.c_Cancel.Name = "c_Cancel";
  81. this.c_Cancel.TabIndex = 3;
  82. this.c_Cancel.Text = "Cancel";
  83. //
  84. // c_Flags
  85. //
  86. this.c_Flags.CheckBoxes = true;
  87. listViewItem1.StateImageIndex = 0;
  88. listViewItem1.Tag = NEROLib.NERO_ESTIMATE_FLAGS.NETS_FILESYSTEM_OVERHEAD;
  89. listViewItem2.StateImageIndex = 0;
  90. listViewItem2.Tag = NEROLib.NERO_ESTIMATE_FLAGS.NETS_DATA;
  91. listViewItem3.StateImageIndex = 0;
  92. listViewItem3.Tag = NEROLib.NERO_ESTIMATE_FLAGS.NETS_EXACT_SIZE;
  93. this.c_Flags.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
  94. listViewItem1,
  95. listViewItem2,
  96. listViewItem3});
  97. this.c_Flags.Location = new System.Drawing.Point(8, 24);
  98. this.c_Flags.Name = "c_Flags";
  99. this.c_Flags.Size = new System.Drawing.Size(184, 64);
  100. this.c_Flags.TabIndex = 1;
  101. this.c_Flags.View = System.Windows.Forms.View.SmallIcon;
  102. //
  103. // label1
  104. //
  105. this.label1.Location = new System.Drawing.Point(8, 8);
  106. this.label1.Name = "label1";
  107. this.label1.Size = new System.Drawing.Size(100, 16);
  108. this.label1.TabIndex = 0;
  109. this.label1.Text = "Flags:";
  110. //
  111. // EstimateTrackSizeForm
  112. //
  113. this.AcceptButton = this.c_Estimate;
  114. this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  115. this.CancelButton = this.c_Cancel;
  116. this.ClientSize = new System.Drawing.Size(282, 96);
  117. this.Controls.Add(this.label1);
  118. this.Controls.Add(this.c_Flags);
  119. this.Controls.Add(this.c_Estimate);
  120. this.Controls.Add(this.c_Cancel);
  121. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  122. this.MaximizeBox = false;
  123. this.MinimizeBox = false;
  124. this.Name = "EstimateTrackSizeForm";
  125. this.ShowInTaskbar = false;
  126. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
  127. this.Text = "EstimateTrackSize";
  128. this.ResumeLayout(false);
  129. }
  130. #endregion
  131. private void c_Estimate_Click(object sender, System.EventArgs e)
  132. {
  133. // When estimate is requested, prepare the information we need
  134. // to pass on to the EstimateTrackSize.
  135. //
  136. NeroFileSystemTrackOptions nfsto = new NeroFileSystemTrackOptionsClass ();
  137. nfsto.BurnFlags = m_BurnFlags;
  138. nfsto.MediaType = m_MediaType;
  139. // Get estimate flags from the list view.
  140. //
  141. uint uFlags = 0;
  142. foreach (ListViewItem lvi in c_Flags.Items)
  143. {
  144. if (lvi.Checked)
  145. {
  146. uFlags |= (uint) (NERO_ESTIMATE_FLAGS) lvi.Tag;
  147. }
  148. }
  149. // Subscribe to the OnDoneEstimateTrackSize event.
  150. //
  151. m_evOnDoneEstimateTrackSize = new _INeroDriveEvents_OnDoneEstimateTrackSizeEventHandler(m_drive_OnDoneEstimateTrackSize);
  152. m_drive.OnDoneEstimateTrackSize += m_evOnDoneEstimateTrackSize;
  153. // Finally, do the estimation with the information we
  154. // have just assembled.
  155. //
  156. m_drive.EstimateTrackSize (m_isoTrack, (NERO_ESTIMATE_FLAGS) uFlags, nfsto);
  157. }
  158. private void m_drive_OnDoneEstimateTrackSize(bool bOk, int BlockSize)
  159. {
  160. // When the estimation is done, unsubscribe from the event
  161. // and show success or failure.
  162. //
  163. m_drive.OnDoneEstimateTrackSize -= m_evOnDoneEstimateTrackSize;
  164. if (bOk)
  165. {
  166. // If everything was ok, let's show the user the estimate
  167. // in blocks and bytes.
  168. //
  169. MessageBox.Show (this, "Track is estimated to "
  170. + BlockSize.ToString ()
  171. + " blocks or "
  172. + (BlockSize*2048).ToString ()
  173. + " bytes.");
  174. }
  175. else
  176. {
  177. MessageBox.Show (this, "There was an error getting track size estimate!");
  178. }
  179. }
  180. }
  181. }