예제 #1
0
 private void btn_BurnDisc_Click(object sender, EventArgs e)
 {
     if (this.cboDevice.SelectedIndex > -1)
     {
         if (this._isBurning)
         {
             this.btn_BurnDisc.Text    = LangCtrl.GetString("lbl_BurnDisc", "Burn Disc");
             this.btn_BurnDisc.Enabled = true;
             this.backgroundWorker.CancelAsync();
             return;
         }
         this.DetectMedia();
         this.progBar.Value       = 0;
         this.progBar.Text        = "0%";
         this.lbl_DiscStatus.Text = LangCtrl.GetString("Disc_1", "Recording Disc...");
         this.btn_BurnDisc.Text   = LangCtrl.GetString("DiscCancel", "Cancel");
         this._isBurning          = true;
         this._closeMedia         = true;
         this._ejectMedia         = this.chkEject.Checked;
         ListItem selectedItem = this.cboDevice.SelectedItem;
         this.Callback(true);
         IDiscRecorder2 tag = (IDiscRecorder2)selectedItem.Tag;
         this._burnData.uniqueRecorderId = tag.ActiveDiscRecorder;
         this.backgroundWorker.RunWorkerAsync(this._burnData);
         this.Cursor = Cursors.WaitCursor;
     }
 }
예제 #2
0
        private void burnImage()
        {
            if (comboBoxDrive.SelectedIndex == -1)
            {
                return;
            }

            if (string.IsNullOrEmpty(textBoxImage.Text))
            {
                if (openFileImage.ShowDialog(this) == DialogResult.OK)
                {
                    textBoxImage.Text = openFileImage.FileName;
                }
            }

            if (sedangMembakar)
            {
                buttonBurn.Enabled = false;
                backgroundWorker.CancelAsync();
            }
            else
            {
                sedangMembakar = true;
                aktifkanUIImage(false);
                IDiscRecorder2 discRecorder = (IDiscRecorder2)comboBoxDrive.Items[comboBoxDrive.SelectedIndex];
                burnMedia.uniqueRecorderId = discRecorder.ActiveDiscRecorder;
                backgroundWorker.RunWorkerAsync(burnMedia);
            }
        }
예제 #3
0
        public void cekDrive()
        {
            IDiscRecorder2   Recorder   = (IDiscRecorder2)comboBoxDrive.Items[comboBoxDrive.SelectedIndex];
            IDiscFormat2Data FormatData = null;

            try
            {
                FormatData = new MsftDiscFormat2Data();
                if (!FormatData.IsRecorderSupported(Recorder))
                {
                    aktifkanUIData(false);
                    aktifkanUIImage(false);
                }
            }

            catch
            {
                suaraGalat(true);

                MessageBox.Show(this, "Drive ini tidak mendukung Burning. \nSilakan pilih drive lainnya atau hubungi manufaktur komputer ini.",
                                pesan, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            finally
            {
                if (FormatData != null)
                {
                    Marshal.ReleaseComObject(FormatData);
                }
            }
        }
예제 #4
0
        public static string GetMediaStateDescription(IDiscRecorder2 rec)
        {
            StringBuilder sb = null;
            var           mi = new MsftDiscFormat2Data();

            try
            {
                mi.Recorder = rec;
                // Get the media status properties for the media to for diagnostic purposes

                sb = new StringBuilder("Media type:");
                for (var i = 1; i <= (int)mi.CurrentMediaStatus; i <<= 1)
                {
                    if ((((int)mi.CurrentMediaStatus) & i) == i)
                    {
                        sb.Append(EnumHelper.GetDescription(((IMAPI_FORMAT2_DATA_MEDIA_STATE)i)));
                        sb.Append('|');
                    }
                }
                sb.Remove(sb.Length - 1, 1);
                return(sb.ToString());
            }
            catch
            {
                return("No Media or the selected drive is not a recorder.");
            }
            finally
            {
                Marshal.FinalReleaseComObject(mi);
                sb.Length = 0;
            }
        }
예제 #5
0
        private bool CreateMediaFileSystem(IDiscRecorder2 discRecorder, object[] multisessionInterfaces, out IStream dataStream)
        {
            bool flag;
            MsftFileSystemImage msftFileSystemImageClass = null;

            try
            {
                try
                {
                    msftFileSystemImageClass = (MsftFileSystemImage)(new MsftFileSystemImageClass());
                    msftFileSystemImageClass.ChooseImageDefaults(discRecorder);
                    msftFileSystemImageClass.FileSystemsToCreate = FsiFileSystems.FsiFileSystemISO9660 | FsiFileSystems.FsiFileSystemJoliet;
                    msftFileSystemImageClass.VolumeName          = this.txtVolumeLabel.Text;
                    msftFileSystemImageClass.Update += new DFileSystemImage_EventHandler(this.fileSystemImage_Update);
                    if (multisessionInterfaces != null)
                    {
                        msftFileSystemImageClass.MultisessionInterfaces = multisessionInterfaces;
                        msftFileSystemImageClass.ImportFileSystem();
                    }
                    IFsiDirectoryItem root = msftFileSystemImageClass.Root;
                    foreach (IMediaItem dirItem in this.DirItems)
                    {
                        if (this.backgroundWorker.CancellationPending)
                        {
                            break;
                        }
                        dirItem.AddToFileSystem(root);
                    }
                    msftFileSystemImageClass.Update -= new DFileSystemImage_EventHandler(this.fileSystemImage_Update);
                    if (!this.backgroundWorker.CancellationPending)
                    {
                        dataStream = msftFileSystemImageClass.CreateResultImage().ImageStream;
                    }
                    else
                    {
                        dataStream = null;
                        flag       = false;
                        return(flag);
                    }
                }
                catch (COMException cOMException1)
                {
                    COMException cOMException = cOMException1;
                    MessageBox.Show(this, cOMException.Message, "Create File System Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    dataStream = null;
                    flag       = false;
                    return(flag);
                }
                return(true);
            }
            finally
            {
                if (msftFileSystemImageClass != null)
                {
                    Marshal.ReleaseComObject(msftFileSystemImageClass);
                }
            }
            return(flag);
        }
예제 #6
0
        private bool CreateMediaFileSystem(IDiscRecorder2 discRecorder, object[] multisessionInterfaces, out IStream dataStream)
        {
            MsftFileSystemImage fileSystemImage = new MsftFileSystemImage();

            fileSystemImage.ChooseImageDefaults(discRecorder);
            fileSystemImage.FileSystemsToCreate =
                FsiFileSystems.FsiFileSystemJoliet | FsiFileSystems.FsiFileSystemISO9660;
            fileSystemImage.VolumeName = textBoxLabel.Text;

            fileSystemImage.Update += new DFileSystemImage_EventHandler(fileSystemImage_Update);

            //
            // If multisessions, then import previous sessions
            //
            if (multisessionInterfaces != null)
            {
                fileSystemImage.MultisessionInterfaces = multisessionInterfaces;
                fileSystemImage.ImportFileSystem();
            }

            //
            // Get the image root
            //
            IFsiDirectoryItem rootItem = fileSystemImage.Root;

            //
            // Add Files and Directories to File System Image
            //
            foreach (IMediaItem mediaItem in listBoxFiles.Items)
            {
                //
                // Check if we've cancelled
                //
                if (backgroundBurnWorker.CancellationPending)
                {
                    break;
                }

                //
                // Add to File System
                //
                mediaItem.AddToFileSystem(rootItem);
            }

            fileSystemImage.Update -= new DFileSystemImage_EventHandler(fileSystemImage_Update);

            //
            // did we cancel?
            //
            if (backgroundBurnWorker.CancellationPending)
            {
                dataStream = null;
                return(false);
            }

            dataStream = fileSystemImage.CreateResultImage().ImageStream;

            return(true);
        }
예제 #7
0
        /// <summary>
        /// Selected a new device
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void devicesComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("devicesComboBox_SelectedIndexChanged\n");
            IDiscRecorder2 discRecorder =
                (IDiscRecorder2)devicesComboBox.Items[devicesComboBox.SelectedIndex];

            supportedMediaLabel.Text = string.Empty;
            //mediaComboBox.Items.Clear();
            //m_isCdromSupported = false;
            //m_isDvdSupported = false;
            //m_isDualLayerDvdSupported = false;
            //m_isBluraySupported = false;

            //
            // Verify recorder is supported
            //
            IDiscFormat2Data discFormatData = new MsftDiscFormat2Data();

            if (!discFormatData.IsRecorderSupported(discRecorder))
            {
                MessageBox.Show("Recorder not supported", m_clientName,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            StringBuilder supportedMediaTypes = new StringBuilder();

            foreach (IMAPI_MEDIA_PHYSICAL_TYPE mediaType in discFormatData.SupportedMediaTypes)
            {
                if (supportedMediaTypes.Length > 0)
                {
                    supportedMediaTypes.Append(", ");
                }
                supportedMediaTypes.Append(GetMediaTypeString(mediaType));
            }
            supportedMediaLabel.Text = supportedMediaTypes.ToString();

            ////
            //// Add Media Selection
            ////
            //if (m_isCdromSupported)
            //{
            //    mediaComboBox.Items.Add(SIZE_CD);
            //}
            //if (m_isDvdSupported)
            //{
            //    mediaComboBox.Items.Add(SIZE_DVD);
            //}
            //if (m_isDualLayerDvdSupported)
            //{
            //    mediaComboBox.Items.Add(SIZE_DVDDL);
            //}
            //if (m_isBluraySupported)
            //{
            //    mediaComboBox.Items.Add(SIZE_BLURAY);
            //}
            //mediaComboBox.SelectedIndex = 0;
        }
예제 #8
0
파일: DVD.cs 프로젝트: Zenkinet/valycam
        public void burnFile2Disk(IDiscRecorder2 disk, IMediaItem mediaItem)
        {
            var discRecorder = disk;

            _burnData.uniqueRecorderId = discRecorder.ActiveDiscRecorder;
            _burnData.mediaItem        = mediaItem;

            backgroundWorkerBurn.RunWorkerAsync(_burnData);
        }
예제 #9
0
        private bool CreateMediaFileSystem(IDiscRecorder2 discRecorder, object[] multisessionInterfaces, out IStream dataStream)
        {
            MsftFileSystemImage fileSystemImage = null;

            try
            {
                fileSystemImage = new MsftFileSystemImage();
                fileSystemImage.ChooseImageDefaults(discRecorder);
                fileSystemImage.FileSystemsToCreate = FsiFileSystems.FsiFileSystemJoliet | FsiFileSystems.FsiFileSystemISO9660;
                fileSystemImage.VolumeName          = textBoxLabel.Text;

                fileSystemImage.Update += FileSystemImage_Update;

                if (multisessionInterfaces != null)
                {
                    fileSystemImage.MultisessionInterfaces = multisessionInterfaces;
                    fileSystemImage.ImportFileSystem();
                }

                var rootItem = fileSystemImage.Root;

                foreach (IMediaItem mediaItem in listBoxFiles.Items)
                {
                    if (backgroundBurnWorker.CancellationPending)
                    {
                        break;
                    }

                    mediaItem.AddToFileSystem(rootItem);
                }

                fileSystemImage.Update -= FileSystemImage_Update;

                if (backgroundBurnWorker.CancellationPending)
                {
                    dataStream = null;
                    return(false);
                }

                dataStream = fileSystemImage.CreateResultImage().ImageStream;
            }
            catch (COMException exception)
            {
                MessageBox.Show(this, exception.Message, "Create File System Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                dataStream = null;
                return(false);
            }
            finally
            {
                if (fileSystemImage != null)
                {
                    Marshal.ReleaseComObject(fileSystemImage);
                }
            }
            return(true);
        }
예제 #10
0
        private bool membuatFileSystem(IDiscRecorder2 Recorder, object[] multiSesi, out IStream streamData)
        {
            MsftFileSystemImage fileSystem = null;

            try
            {
                fileSystem = new MsftFileSystemImage();
                fileSystem.ChooseImageDefaults(Recorder);
                fileSystem.FileSystemsToCreate = FsiFileSystems.FsiFileSystemJoliet | FsiFileSystems.FsiFileSystemISO9660;
                fileSystem.VolumeName          = textBoxNamaDisc.Text;

                fileSystem.Update += new DFileSystemImage_EventHandler(fileSystemHandler);

                if (multiSesi != null)
                {
                    fileSystem.MultisessionInterfaces = multiSesi;
                    fileSystem.ImportFileSystem();
                }

                IFsiDirectoryItem rootItem = fileSystem.Root;

                foreach (IMediaItem mediaItem in listBox.Items)
                {
                    if (backgroundWorker.CancellationPending)
                    {
                        break;
                    }
                    mediaItem.tambahkanKeFileSystem(rootItem);
                }

                fileSystem.Update -= new DFileSystemImage_EventHandler(fileSystemHandler);

                if (backgroundWorker.CancellationPending)
                {
                    streamData = null;
                    return(false);
                }
                streamData = fileSystem.CreateResultImage().ImageStream;
            }

            catch (COMException exception)
            {
                MessageBox.Show(this, exception.Message, "Kesalahan File System dengan kode :",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                streamData = null;
                return(false);
            }

            finally
            {
                if (fileSystem != null)
                {
                    Marshal.ReleaseComObject(fileSystem);
                }
            }
            return(true);
        }
예제 #11
0
        private void DetectMedia()
        {
            if (this.cboDevice.SelectedIndex == -1)
            {
                return;
            }
            IDiscRecorder2      tag = (IDiscRecorder2)this.cboDevice.SelectedItem.Tag;
            MsftFileSystemImage msftFileSystemImageClass = null;
            GInterface6         msftDiscFormat2DataClass = null;

            try
            {
                try
                {
                    msftDiscFormat2DataClass = (GInterface6)(new MsftDiscFormat2DataClass());
                    if (msftDiscFormat2DataClass.IsCurrentMediaSupported(tag))
                    {
                        msftDiscFormat2DataClass.Recorder = tag;
                        IMAPI_MEDIA_PHYSICAL_TYPE currentPhysicalMediaType = msftDiscFormat2DataClass.CurrentPhysicalMediaType;
                        this.lblMedia.Text       = this.cdUtil.GetMediaTypeString(currentPhysicalMediaType);
                        msftFileSystemImageClass = (MsftFileSystemImage)(new MsftFileSystemImageClass());
                        msftFileSystemImageClass.ChooseImageDefaultsForMediaType(currentPhysicalMediaType);
                        if (!msftDiscFormat2DataClass.MediaHeuristicallyBlank)
                        {
                            msftFileSystemImageClass.MultisessionInterfaces = msftDiscFormat2DataClass.MultisessionInterfaces;
                            msftFileSystemImageClass.ImportFileSystem();
                        }
                        this._totalDiscSize       = 2048L * (long)msftFileSystemImageClass.FreeMediaBlocks;
                        this.btn_BurnDisc.Enabled = true;
                    }
                    else
                    {
                        this.lblMedia.Text  = LangCtrl.GetString("lblMedia", "NO MEDIA");
                        this._totalDiscSize = 0L;
                        return;
                    }
                }
                catch (COMException cOMException1)
                {
                    COMException cOMException = cOMException1;
                    MessageBox.Show(this, cOMException.Message, "Detect Media Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
            }
            finally
            {
                if (msftDiscFormat2DataClass != null)
                {
                    Marshal.ReleaseComObject(msftDiscFormat2DataClass);
                }
                if (msftFileSystemImageClass != null)
                {
                    Marshal.ReleaseComObject(msftFileSystemImageClass);
                }
            }
            this.UpdateCapacity();
        }
예제 #12
0
        /// <summary>
        /// The user has clicked the "Format" button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonFormat_Click(object sender, EventArgs e)
        {
            m_isFormatting = true;
            EnableFormatUI(false);

            IDiscRecorder2 discRecorder =
                (IDiscRecorder2)devicesComboBox.Items[devicesComboBox.SelectedIndex];

            backgroundFormatWorker.RunWorkerAsync(discRecorder.ActiveDiscRecorder);
        }
        /// <summary>Burns data files to disc in a single session using files from a single directory tree.</summary>
        /// <param name="recorder">Burning Device. Must be initialized.</param>
        /// <param name="path">Directory of files to burn.</param>
        public static void BurnDirectory(this IDiscRecorder2 recorder, string path, string imageName = "IMAPI Sample")
        {
            // Define the new disc format and set the recorder
            var dataWriterImage = new IDiscFormat2Data
            {
                Recorder = recorder
            };

            if (!dataWriterImage.IsRecorderSupported(recorder))
            {
                Console.WriteLine("The recorder is not supported");
                return;
            }

            if (!dataWriterImage.IsCurrentMediaSupported(recorder))
            {
                Console.WriteLine("The current media is not supported");
                return;
            }

            dataWriterImage.ClientName = imageName;

            // Create an image stream for a specified directory.

            // Create a new file system image and retrieve the root directory
            var fsi = new IFileSystemImage
            {
                // Set the media size
                FreeMediaBlocks = dataWriterImage.FreeSectorsOnMedia,

                // Use legacy ISO 9660 Format
                FileSystemsToCreate = FsiFileSystems.FsiFileSystemUDF
            };

            // Add the directory to the disc file system
            IFsiDirectoryItem dir = fsi.Root;

            Console.WriteLine();
            Console.Write("Adding files to image:".PadRight(80));
            using (var eventDisp = new ComConnectionPoint(fsi, new DFileSystemImageEventsSink(AddTreeUpdate)))
                dir.AddTree(path, false);
            Console.WriteLine();

            // Create an image from the file system
            Console.WriteLine("\nWriting content to disc...");
            IFileSystemImageResult result = fsi.CreateResultImage();

            // Data stream sent to the burning device
            IStream stream = result.ImageStream;

            // Write the image stream to disc using the specified recorder.
            using (var eventDisp = new ComConnectionPoint(dataWriterImage, new DDiscFormat2DataEventsSink(WriteUpdate)))
                dataWriterImage.Write(stream);                   // Burn the stream to disc

            Console.WriteLine("----- Finished writing content -----");
예제 #14
0
        /// <summary>
        /// Burns data files to disc in a single session using files from a
        /// single directory tree.
        /// </summary>
        /// <param name="recorder">Burning Device. Must be initialized.</param>
        /// <param name="path">Directory of files to burn.</param>
        public void BurnDirectory(IDiscRecorder2 recorder, String path)
        {
            // Define the new disc format and set the recorder
            IDiscFormat2Data dataWriterImage = new MsftDiscFormat2Data();

            dataWriterImage.Recorder = recorder;

            if (!dataWriterImage.IsRecorderSupported(recorder))
            {
                Console.WriteLine("The recorder is not supported");
                return;
            }

            if (!dataWriterImage.IsCurrentMediaSupported(recorder))
            {
                Console.WriteLine("The current media is not supported");
                return;
            }

            dataWriterImage.ClientName = "IMAPI Sample";

            // Create an image stream for a specified directory.

            // Create a new file system image and retrieve the root directory
            IFileSystemImage fsi = new MsftFileSystemImage();

            // Set the media size
            fsi.FreeMediaBlocks = dataWriterImage.FreeSectorsOnMedia;

            // Use legacy ISO 9660 Format
            fsi.FileSystemsToCreate = FsiFileSystems.FsiFileSystemISO9660;

            // Add the directory to the disc file system
            IFsiDirectoryItem dir = fsi.Root;

            dir.AddTree(path, false);

            // Create an image from the file system
            Console.WriteLine("Writing content to disc...");
            IFileSystemImageResult result = fsi.CreateResultImage();

            // Data stream sent to the burning device
            IStream stream = result.ImageStream;

            DiscFormat2Data_Events progress = dataWriterImage as DiscFormat2Data_Events;

            progress.Update += new DiscFormat2Data_EventsHandler(DiscFormat2Data_ProgressUpdate);

            // Write the image stream to disc using the specified recorder.
            dataWriterImage.Write(stream);   // Burn the stream to disc

            progress.Update -= new DiscFormat2Data_EventsHandler(DiscFormat2Data_ProgressUpdate);

            Console.WriteLine("----- Finished writing content -----");
        }
예제 #15
0
 /// <summary>
 /// Setto il masterizzatore sul quale scrivere
 /// </summary>
 /// <param name="volume"></param>
 public void setDiscRecorder(String volume)
 {
     foreach (IDiscRecorder2 discRecorder in _listRecorders)
     {
         if (discRecorder.VolumePathNames.GetValue(0).Equals(volume))
         {
             this.discRecorder = discRecorder;
             break;
         }
     }
 }
예제 #16
0
        /// <summary>
        /// Burns data files to disc in a single session using files from a 
        /// single directory tree.
        /// </summary>
        /// <param name="recorder">Burning Device. Must be initialized.</param>
        /// <param name="path">Directory of files to burn.</param>
        public void BurnDirectory(IDiscRecorder2 recorder, String path)
        {
            // Define the new disc format and set the recorder
            IDiscFormat2Data dataWriterImage = new MsftDiscFormat2Data();
            dataWriterImage.Recorder = recorder;

            if(!dataWriterImage.IsRecorderSupported(recorder))
            {
                Console.WriteLine("The recorder is not supported");
                return;
            }

            if (!dataWriterImage.IsCurrentMediaSupported(recorder))
            {
                Console.WriteLine("The current media is not supported");
                return;
            }

            dataWriterImage.ClientName = "IMAPI Sample";

            // Create an image stream for a specified directory.

            // Create a new file system image and retrieve the root directory
            IFileSystemImage fsi = new MsftFileSystemImage();

            // Set the media size
            fsi.FreeMediaBlocks = dataWriterImage.FreeSectorsOnMedia;

            // Use legacy ISO 9660 Format
            fsi.FileSystemsToCreate = FsiFileSystems.FsiFileSystemISO9660;

            // Add the directory to the disc file system
            IFsiDirectoryItem dir = fsi.Root;
            dir.AddTree(path, false);

            // Create an image from the file system
            Console.WriteLine("Writing content to disc...");
            IFileSystemImageResult result = fsi.CreateResultImage();

            // Data stream sent to the burning device
            IStream stream = result.ImageStream;

            DiscFormat2Data_Events progress = dataWriterImage as DiscFormat2Data_Events;
            progress.Update += new DiscFormat2Data_EventsHandler(DiscFormat2Data_ProgressUpdate);

            // Write the image stream to disc using the specified recorder.
            dataWriterImage.Write(stream);   // Burn the stream to disc

            progress.Update -= new DiscFormat2Data_EventsHandler(DiscFormat2Data_ProgressUpdate);

            Console.WriteLine("----- Finished writing content -----");
        }
예제 #17
0
        /// <summary>
        /// Examines and reports the burn device characteristics such
        /// as Product ID, Revision Level, Feature Set and Profiles.
        /// </summary>
        /// <param name="recorder">Burning Device. Must be initialized.</param>
        public void DisplayRecorderCharacteristics(IDiscRecorder2 recorder)
        {
            // Create a DiscMaster2 object to obtain an inventory of CD/DVD drives.
            IDiscMaster2 discMaster = new MsftDiscMaster2();

            //*** - Formating the way to display info on the supported recoders
            Console.WriteLine("--------------------------------------------------------------------------------");
            Console.WriteLine("ActiveRecorderId: {0}".PadLeft(22), recorder.ActiveDiscRecorder);
            Console.WriteLine("Vendor Id: {0}".PadLeft(22), recorder.VendorId);
            Console.WriteLine("Product Id: {0}".PadLeft(22), recorder.ProductId);
            Console.WriteLine("Product Revision: {0}".PadLeft(22), recorder.ProductRevision);
            Console.WriteLine("VolumeName: {0}".PadLeft(22), recorder.VolumeName);
            Console.WriteLine("Can Load Media: {0}".PadLeft(22), recorder.DeviceCanLoadMedia);
            Console.WriteLine("Device Number: {0}".PadLeft(22), recorder.LegacyDeviceNumber);

            foreach (String mountPoint in recorder.VolumePathNames)
            {
                Console.WriteLine("Mount Point: {0}".PadLeft(22), mountPoint);
            }

            foreach (IMAPI_FEATURE_PAGE_TYPE supportedFeature in recorder.SupportedFeaturePages)
            {
                Console.WriteLine("Feature: {0}".PadLeft(22), supportedFeature.ToString("F"));
            }

            Console.WriteLine("Current Features");
            foreach (IMAPI_FEATURE_PAGE_TYPE currentFeature in recorder.CurrentFeaturePages)
            {
                Console.WriteLine("Feature: {0}".PadLeft(22), currentFeature.ToString("F"));
            }

            Console.WriteLine("Supported Profiles");
            foreach (IMAPI_PROFILE_TYPE supportedProfile in recorder.SupportedProfiles)
            {
                Console.WriteLine("Profile: {0}".PadLeft(22), supportedProfile.ToString("F"));
            }

            Console.WriteLine("Current Profiles");
            foreach (IMAPI_PROFILE_TYPE currentProfile in recorder.CurrentProfiles)
            {
                Console.WriteLine("Profile: {0}".PadLeft(22), currentProfile.ToString("F"));
            }

            Console.WriteLine("Supported Mode Pages");
            foreach (IMAPI_MODE_PAGE_TYPE supportedModePage in recorder.SupportedModePages)
            {
                Console.WriteLine("Mode Page: {0}".PadLeft(22), supportedModePage.ToString("F"));
            }

            Console.WriteLine("\n----- Finished content -----");
        }
예제 #18
0
        internal async Task<int> StartFormat(IDiscRecorder2 discRecorder, bool quickFormat, bool ejectDisc,
            CancellationToken cancellationToken, IProgress<int> progress)
        {
            this.quickFormat = quickFormat;
            this.ejectDisc = ejectDisc;
            this.progress = progress;
            IsFormatting = true;

            var formatResult = await Task.Run(() => DoFormat(discRecorder.ActiveDiscRecorder));

            progress.Report(0);

            IsFormatting = false;

            return formatResult;
        }
예제 #19
0
        private void buttonDetectMedia_Click(object sender, EventArgs e)
        {
            IDiscRecorder2 discRecorder =
                (IDiscRecorder2)devicesComboBox.Items[devicesComboBox.SelectedIndex];

            //
            // Create and initialize the IDiscFormat2Data
            //
            MsftDiscFormat2Data discFormatData = new MsftDiscFormat2Data();

            if (!discFormatData.IsCurrentMediaSupported(discRecorder))
            {
                labelMediaType.Text = "Media not supported!";
                totalDiscSize       = 0;
                return;
            }
            else
            {
                //
                // Get the media type in the recorder
                //
                discFormatData.Recorder = discRecorder;
                IMAPI_MEDIA_PHYSICAL_TYPE mediaType = discFormatData.CurrentPhysicalMediaType;
                labelMediaType.Text = GetMediaTypeString(mediaType);

                //
                // Create a file system and select the media type
                //
                MsftFileSystemImage fileSystemImage = new MsftFileSystemImage();
                fileSystemImage.ChooseImageDefaultsForMediaType(mediaType);

                //
                // See if there are other recorded sessions on the disc
                //
                if (!discFormatData.MediaHeuristicallyBlank)
                {
                    fileSystemImage.MultisessionInterfaces = discFormatData.MultisessionInterfaces;
                    fileSystemImage.ImportFileSystem();
                }

                Int64 freeMediaBlocks = fileSystemImage.FreeMediaBlocks;
                totalDiscSize = 2048 * freeMediaBlocks;
            }


            UpdateCapacity();
        }
예제 #20
0
        public static string GetDevicePath(IDiscRecorder2 e)
        {
            IDiscRecorder2 discRecorder2 = e;
            string         devicePaths   = string.Empty;
            string         volumePath    = (string)discRecorder2.VolumePathNames.GetValue(0);

            foreach (string volPath in discRecorder2.VolumePathNames)
            {
                if (!string.IsNullOrEmpty(devicePaths))
                {
                    devicePaths += ",";
                }
                devicePaths += volumePath;
            }

            return(string.Format("{0} [{1}]", devicePaths, discRecorder2.ProductId));
        }
예제 #21
0
        private void listDrive_Format(object sender, ListControlConvertEventArgs e)
        {
            IDiscRecorder2 discRecorder2 = (IDiscRecorder2)e.ListItem;
            string         devicePaths   = string.Empty;
            string         volumePath    = (string)discRecorder2.VolumePathNames.GetValue(0);

            foreach (string volPath in discRecorder2.VolumePathNames)
            {
                if (!string.IsNullOrEmpty(devicePaths))
                {
                    devicePaths += ",";
                }
                devicePaths += volumePath;
            }

            e.Value = string.Format("{0} [{1}]", devicePaths, discRecorder2.ProductId);
        }
예제 #22
0
        private void comboBoxDrive_Format(object sender, ListControlConvertEventArgs e)
        {
            IDiscRecorder2 Recorder = (IDiscRecorder2)e.ListItem;
            string         device   = string.Empty;
            string         volume   = (string)Recorder.VolumePathNames.GetValue(0);

            foreach (string volPath in Recorder.VolumePathNames)
            {
                if (!string.IsNullOrEmpty(device))
                {
                    device += ",";
                }
                device += volume;
            }

            e.Value = string.Format("{0} [{1}]", device, Recorder.ProductId);
        }
예제 #23
0
        /// <summary>
        /// Burns a boot image and data files to disc in a single session
        /// using files from a single directory tree.
        /// </summary>
        /// <param name="recorder">Burning Device. Must be initialized.</param>
        /// <param name="path">Directory of files to burn.
        /// \\winbuilds\release\winmain\latest.tst\amd64fre\en-us\skus.cmi\staged\windows
        /// </param>
        /// <param name="bootFile">Path and filename of boot image.
        /// \\winbuilds\release\winmain\latest.tst\x86fre\bin\etfsboot.com
        /// </param>
        public void CreateBootDisc(IDiscRecorder2 recorder, String path, String bootFile)
        {
            // -------- Adding Boot Image Code -----
            Console.WriteLine("Creating BootOptions");
            IBootOptions bootOptions = new MsftBootOptions();

            bootOptions.Manufacturer = "Microsoft";
            bootOptions.PlatformId   = PlatformId.PlatformX86;
            bootOptions.Emulation    = EmulationType.EmulationNone;

            // Need stream for boot image file
            Console.WriteLine("Creating IStream for file {0}", bootFile);
            IStream iStream = new AStream(
                new FileStream(bootFile, FileMode.Open,
                               FileAccess.Read,
                               FileShare.Read));

            bootOptions.AssignBootImage(iStream);

            // Create disc file system image (ISO9660 in this example)
            IFileSystemImage fsi = new MsftFileSystemImage();

            fsi.FreeMediaBlocks     = -1; // Enables larger-than-CD image
            fsi.FileSystemsToCreate = FsiFileSystems.FsiFileSystemISO9660 |
                                      FsiFileSystems.FsiFileSystemJoliet |
                                      FsiFileSystems.FsiFileSystemUDF;

            // Hooking bootStream to FileSystemObject
            fsi.BootImageOptions = bootOptions;

            // Hooking content files FileSystemObject
            fsi.Root.AddTree(path, false);

            IFileSystemImageResult result = fsi.CreateResultImage();
            IStream stream = result.ImageStream;

            // Create and write stream to disc using the specified recorder.
            IDiscFormat2Data dataWriterBurn = new MsftDiscFormat2Data();

            dataWriterBurn.Recorder   = recorder;
            dataWriterBurn.ClientName = "IMAPI Sample";
            dataWriterBurn.Write(stream);

            Console.WriteLine("----- Finished writing content -----");
        }
예제 #24
0
        public static bool CanWriteMedia(IDiscRecorder2 rec)
        {
            var mi = new MsftDiscFormat2Data();

            try
            {
                mi.Recorder = rec;
                return(mi.IsRecorderSupported(rec) && mi.IsCurrentMediaSupported(rec));
            }
            catch
            {
                return(false);
            }
            finally
            {
                Marshal.FinalReleaseComObject(mi);
            }
        }
예제 #25
0
        public static IMAPI_MEDIA_PHYSICAL_TYPE CurrentPhysicalMediaType(IDiscRecorder2 rec)
        {
            var mi = new MsftDiscFormat2Data();

            try
            {
                mi.Recorder = rec;
                return(mi.CurrentPhysicalMediaType);
            }
            catch
            {
                return(IMAPI_MEDIA_PHYSICAL_TYPE.IMAPI_MEDIA_TYPE_UNKNOWN);
            }
            finally
            {
                Marshal.FinalReleaseComObject(mi);
            }
        }
예제 #26
0
        public static bool IsMediaBlank(IDiscRecorder2 rec)
        {
            var mi = new MsftDiscFormat2Data();

            try
            {
                mi.Recorder = rec;
                return(mi.MediaPhysicallyBlank || mi.MediaHeuristicallyBlank);
            }
            catch
            {
                return(false);
            }
            finally
            {
                Marshal.FinalReleaseComObject(mi);
            }
        }
예제 #27
0
        private void _CreateImage(IDiscRecorder2 discRecorder, object[] multisessionInterfaces, out IStream dataStream)
        {
            MsftFileSystemImage image = null;
            string volumeLabel        = this.VolumeLabel;

            try
            {
                if (String.IsNullOrEmpty(volumeLabel))
                {
                    volumeLabel = DateTime.Now.ToShortDateString();
                }

                image = new MsftFileSystemImage();
                image.ChooseImageDefaults(discRecorder);
                image.FileSystemsToCreate = FsiFileSystems.FsiFileSystemJoliet | FsiFileSystems.FsiFileSystemISO9660;
                image.VolumeName          = volumeLabel;

                image.Update += _fileSystemImage_Update;

                // If multisessions, then import previous sessions
                if (multisessionInterfaces != null)
                {
                    image.MultisessionInterfaces = multisessionInterfaces;
                    image.ImportFileSystem();
                }

                IFsiDirectoryItem rootNode = image.Root;
                foreach (IMediaNode node in this.Nodes)
                {
                    _AddNode(rootNode, node);
                }

                image.Update -= _fileSystemImage_Update;

                dataStream = image.CreateResultImage().ImageStream;
            }
            finally
            {
                if (image != null)
                {
                    Marshal.ReleaseComObject(image);
                }
            }
        }
예제 #28
0
        public void scanMedia()
        {
            if (comboBoxDrive.SelectedIndex == -1)
            {
                return;
            }

            IDiscRecorder2       Recorder    = (IDiscRecorder2)comboBoxDrive.Items[comboBoxDrive.SelectedIndex];
            MsftDiscFormat2Erase FormatErase = null;

            try
            {
                FormatErase = new MsftDiscFormat2Erase();
                if (!FormatErase.IsCurrentMediaSupported(Recorder))
                {
                    pictureBoxDisc.Image = BurnFormat.Properties.Resources.CAUTION;
                    suaraGalat(true);
                    buttonFormat.Enabled = false;
                    return;
                }
                else
                {
                    FormatErase.Recorder = Recorder;
                    IMAPI_MEDIA_PHYSICAL_TYPE mediaType = FormatErase.CurrentPhysicalMediaType;
                    pictureBoxDisc.Image = jenisDisc(mediaType);
                    buttonFormat.Enabled = true;
                }
            }

            catch
            {
                suaraGalat(true);
                buttonFormat.Enabled = false;
            }

            finally
            {
                if (FormatErase != null)
                {
                    Marshal.ReleaseComObject(FormatErase);
                    FormatErase = null;
                }
            }
        }
예제 #29
0
        public bool DetectMedia(ListItem li, ref Label lbl)
        {
            bool flag = false;

            lbl.Text = string.Empty;
            MsftFileSystemImage msftFileSystemImage      = null;
            GInterface6         msftDiscFormat2DataClass = null;
            IDiscRecorder2      tag = (IDiscRecorder2)li.Tag;

            try
            {
                try
                {
                    msftDiscFormat2DataClass = (GInterface6)(new MsftDiscFormat2DataClass());
                    if (msftDiscFormat2DataClass.IsCurrentMediaSupported(tag))
                    {
                        msftDiscFormat2DataClass.Recorder = tag;
                        lbl.Text = this.GetMediaTypeString(msftDiscFormat2DataClass.CurrentPhysicalMediaType);
                        flag     = true;
                    }
                    else
                    {
                        lbl.Text = "No Media";
                    }
                }
                catch (COMException cOMException)
                {
                }
            }
            finally
            {
                if (msftDiscFormat2DataClass != null)
                {
                    Marshal.ReleaseComObject(msftDiscFormat2DataClass);
                }
                if (msftFileSystemImage != null)
                {
                    Marshal.ReleaseComObject(msftFileSystemImage);
                }
            }
            return(flag);
        }
예제 #30
0
        private void buttonFormat_Click(object sender, EventArgs e)
        {
            if (comboBoxDrive.SelectedIndex == -1)
            {
                return;
            }

            if (sedangMenghapus)
            {
                buttonFormat.Enabled = false;
                backgroundWorker.CancelAsync();
            }
            else
            {
                sedangMenghapus = true;
                aktifkanUIFormat(false);
                IDiscRecorder2 discRecorder = (IDiscRecorder2)comboBoxDrive.Items[comboBoxDrive.SelectedIndex];
                backgroundWorker.RunWorkerAsync(discRecorder.ActiveDiscRecorder);
            }
        }
예제 #31
0
        /// <summary>
        /// User clicked the "Burn" button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonBurn_Click(object sender, EventArgs e)
        {
            if (m_isBurning)
            {
                buttonBurn.Enabled = false;
                backgroundBurnWorker.CancelAsync();
            }
            else
            {
                m_isBurning = true;
                EnableBurnUI(false);

                //m_burnData.mainForm = this;
                IDiscRecorder2 discRecorder =
                    (IDiscRecorder2)devicesComboBox.Items[devicesComboBox.SelectedIndex];
                m_burnData.uniqueRecorderId = discRecorder.ActiveDiscRecorder;

                backgroundBurnWorker.RunWorkerAsync(m_burnData);
            }
        }
예제 #32
0
        public void cekDrive()
        {
            IDiscRecorder2   Recorder   = (IDiscRecorder2)comboBoxDrive.Items[comboBoxDrive.SelectedIndex];
            IDiscFormat2Data FormatData = null;

            richTextBox.Text = string.Empty;

            try
            {
                StringBuilder tipeMedia = new StringBuilder();
                foreach (IMAPI_PROFILE_TYPE profileType in Recorder.SupportedProfiles)
                {
                    string profileName = jenisDrive(profileType);

                    if (string.IsNullOrEmpty(profileName))
                    {
                        continue;
                    }

                    if (tipeMedia.Length > 0)
                    {
                        tipeMedia.Append("\n");
                    }
                    tipeMedia.Append(profileName);
                }
                richTextBox.Text = tipeMedia.ToString();
            }

            catch
            {
                richTextBox.Text = "KESALAHAN MENDETEKSI DRIVE !@#$%";
            }

            finally
            {
                if (FormatData != null)
                {
                    Marshal.ReleaseComObject(FormatData);
                }
            }
        }
예제 #33
0
        private async Task<int> StartBurnProcess(IDiscRecorder2 discRecorder, bool ejectMedia,
            IList<MediaFile> mediaItems, IMAPI_BURN_VERIFICATION_LEVEL verificationLevel,
            CancellationToken cancellationToken, IProgress<BurnData> progress)
        {
            IsBurning = true;
            this.ejectMedia = ejectMedia;
            this.burnProgress = progress;
            this.mediaItems = mediaItems;
            this.cancellationToken = cancellationToken;

            burnData = new BurnData();
            burnData.uniqueRecorderId = discRecorder.ActiveDiscRecorder;

            var burnResult = await Task.Run(() => DoBurn(burnData.uniqueRecorderId));

            progress.Report(burnData);

            IsBurning = false;

            return burnResult;
        }
예제 #34
0
        private string GetDisplayString(IDiscRecorder2 discRecorder2)
        {
            var devicePaths = string.Empty;
            var volumePath = (string)discRecorder2.VolumePathNames.GetValue(0);
            foreach (string volPath in discRecorder2.VolumePathNames)
            {
                if (!string.IsNullOrEmpty(devicePaths))
                    devicePaths += ",";

                devicePaths += volumePath;
            }

            return string.Format("{0} [{1}]", devicePaths, discRecorder2.ProductId);
        }
예제 #35
0
        /// <summary>
        /// Examines and reports the burn device characteristics such 
        /// as Product ID, Revision Level, Feature Set and Profiles.
        /// </summary>
        /// <param name="recorder">Burning Device. Must be initialized.</param>
        public void DisplayRecorderCharacteristics(IDiscRecorder2 recorder)
        {
            // Create a DiscMaster2 object to obtain an inventory of CD/DVD drives.
            IDiscMaster2 discMaster = new MsftDiscMaster2();

            //*** - Formating the way to display info on the supported recoders
            Console.WriteLine("--------------------------------------------------------------------------------");
            Console.WriteLine("ActiveRecorderId: {0}".PadLeft(22), recorder.ActiveDiscRecorder);
            Console.WriteLine("Vendor Id: {0}".PadLeft(22), recorder.VendorId);
            Console.WriteLine("Product Id: {0}".PadLeft(22), recorder.ProductId);
            Console.WriteLine("Product Revision: {0}".PadLeft(22), recorder.ProductRevision);
            Console.WriteLine("VolumeName: {0}".PadLeft(22), recorder.VolumeName);
            Console.WriteLine("Can Load Media: {0}".PadLeft(22), recorder.DeviceCanLoadMedia);
            Console.WriteLine("Device Number: {0}".PadLeft(22), recorder.LegacyDeviceNumber);

            foreach (String mountPoint in recorder.VolumePathNames)
            {
                Console.WriteLine("Mount Point: {0}".PadLeft(22), mountPoint);
            }

            foreach (IMAPI_FEATURE_PAGE_TYPE supportedFeature in recorder.SupportedFeaturePages)
            {
                Console.WriteLine("Feature: {0}".PadLeft(22), supportedFeature.ToString("F"));
            }

            Console.WriteLine("Current Features");
            foreach (IMAPI_FEATURE_PAGE_TYPE currentFeature in recorder.CurrentFeaturePages)
            {
                Console.WriteLine("Feature: {0}".PadLeft(22), currentFeature.ToString("F"));
            }

            Console.WriteLine("Supported Profiles");
            foreach (IMAPI_PROFILE_TYPE supportedProfile in recorder.SupportedProfiles)
            {
                Console.WriteLine("Profile: {0}".PadLeft(22), supportedProfile.ToString("F"));
            }

            Console.WriteLine("Current Profiles");
            foreach (IMAPI_PROFILE_TYPE currentProfile in recorder.CurrentProfiles)
            {
                Console.WriteLine("Profile: {0}".PadLeft(22), currentProfile.ToString("F"));
            }

            Console.WriteLine("Supported Mode Pages");
            foreach (IMAPI_MODE_PAGE_TYPE supportedModePage in recorder.SupportedModePages)
            {
                Console.WriteLine("Mode Page: {0}".PadLeft(22), supportedModePage.ToString("F"));
            }

            Console.WriteLine("\n----- Finished content -----");
        }
예제 #36
0
        /// <summary>
        /// Examines and reports the media characteristics.
        /// </summary>
        /// <param name="recorder">Burning Device. Must be initialized.</param>
        public void DisplayMediaCharacteristics(IDiscRecorder2 recorder)
        {
            // Define the new disc format and set the recorder
            IDiscFormat2Data mediaImage = new MsftDiscFormat2Data();
            mediaImage.Recorder = recorder;

            // *** Validation methods inherited from IMAPI2.MsftDiscFormat2
            bool boolResult = mediaImage.IsRecorderSupported(recorder);
            if (boolResult)
            {
                Console.WriteLine("--- Current recorder IS supported. ---");
            }
            else
            {
                Console.WriteLine("--- Current recorder IS NOT supported. ---");
            }

            boolResult = mediaImage.IsCurrentMediaSupported(recorder);
            if (boolResult)
            {
                Console.WriteLine("--- Current media IS supported. ---");
            }
            else
            {
                Console.WriteLine("--- Current media IS NOT supported. ---");
            }

            Console.WriteLine("ClientName = {0}", mediaImage.ClientName);

            // Check a few CurrentMediaStatus possibilities. Each status is associated
            // with a bit and some combinations are legal.
            uint curMediaStatus = (uint)mediaImage.CurrentMediaStatus;
            Console.WriteLine("Checking Current Media Status");

            if (curMediaStatus == (uint)IMAPI_FORMAT2_DATA_MEDIA_STATE.IMAPI_FORMAT2_DATA_MEDIA_STATE_UNKNOWN)
            {
                Console.WriteLine("\tMedia state is unknown.");
            }
            else
            {
                if ((curMediaStatus & (uint)IMAPI_FORMAT2_DATA_MEDIA_STATE.IMAPI_FORMAT2_DATA_MEDIA_STATE_OVERWRITE_ONLY) != 0)
                {
                    Console.WriteLine("\tCurrently, only overwriting is supported.");
                }
                if ((curMediaStatus & (uint)IMAPI_FORMAT2_DATA_MEDIA_STATE.IMAPI_FORMAT2_DATA_MEDIA_STATE_RANDOMLY_WRITABLE) != 0)
                {
                    Console.WriteLine("\tCurrently, media supports random writing.");
                }
                if ((curMediaStatus & (uint)IMAPI_FORMAT2_DATA_MEDIA_STATE.IMAPI_FORMAT2_DATA_MEDIA_STATE_APPENDABLE) != 0)
                {
                    Console.WriteLine("\tMedia is currently appendable.");
                }
                if ((curMediaStatus & (uint)IMAPI_FORMAT2_DATA_MEDIA_STATE.IMAPI_FORMAT2_DATA_MEDIA_STATE_FINAL_SESSION) != 0)
                {
                    Console.WriteLine("\tMedia is in final writing session.");
                }
                if ((curMediaStatus & (uint)IMAPI_FORMAT2_DATA_MEDIA_STATE.IMAPI_FORMAT2_DATA_MEDIA_STATE_DAMAGED) != 0)
                {
                    Console.WriteLine("\tMedia is damaged.");
                }
            }

            IMAPI_MEDIA_PHYSICAL_TYPE mediaType = mediaImage.CurrentPhysicalMediaType;
            Console.Write("Current Media Type");
            DisplayMediaType(mediaType);

            Console.WriteLine("SupportedMediaTypes in the device: ");
            foreach (IMAPI_MEDIA_PHYSICAL_TYPE supportedMediaType in mediaImage.SupportedMediaTypes)
            {
                DisplayMediaType(supportedMediaType);
            }

            Console.Write("\n----- Finished -----");
        }
예제 #37
0
        /// <summary>
        /// Burns a boot image and data files to disc in a single session 
        /// using files from a single directory tree.
        /// </summary>
        /// <param name="recorder">Burning Device. Must be initialized.</param>
        /// <param name="path">Directory of files to burn.
        /// \\winbuilds\release\winmain\latest.tst\amd64fre\en-us\skus.cmi\staged\windows
        /// </param>
        /// <param name="bootFile">Path and filename of boot image.
        /// \\winbuilds\release\winmain\latest.tst\x86fre\bin\etfsboot.com
        /// </param>
        public void CreateBootDisc(IDiscRecorder2 recorder, String path, String bootFile)
        {
            // -------- Adding Boot Image Code -----
            Console.WriteLine("Creating BootOptions");
            IBootOptions bootOptions = new MsftBootOptions();
            bootOptions.Manufacturer = "Microsoft";
            bootOptions.PlatformId = PlatformId.PlatformX86;
            bootOptions.Emulation = EmulationType.EmulationNone;

            // Need stream for boot image file
            Console.WriteLine("Creating IStream for file {0}", bootFile);
            IStream iStream = new AStream(
                              new FileStream(bootFile, FileMode.Open,
                                                       FileAccess.Read,
                                                       FileShare.Read));
            bootOptions.AssignBootImage(iStream);

            // Create disc file system image (ISO9660 in this example)
            IFileSystemImage fsi = new MsftFileSystemImage();
            fsi.FreeMediaBlocks = -1; // Enables larger-than-CD image
            fsi.FileSystemsToCreate = FsiFileSystems.FsiFileSystemISO9660 |
                                      FsiFileSystems.FsiFileSystemJoliet  |
                                      FsiFileSystems.FsiFileSystemUDF;

            // Hooking bootStream to FileSystemObject
            fsi.BootImageOptions = bootOptions;

            // Hooking content files FileSystemObject
            fsi.Root.AddTree(path, false);

            IFileSystemImageResult result = fsi.CreateResultImage();
            IStream stream= result.ImageStream;

            // Create and write stream to disc using the specified recorder.
            IDiscFormat2Data dataWriterBurn = new MsftDiscFormat2Data();
            dataWriterBurn.Recorder = recorder;
            dataWriterBurn.ClientName = "IMAPI Sample";
            dataWriterBurn.Write(stream);

            Console.WriteLine("----- Finished writing content -----");
        }
예제 #38
0
        private bool CreateMediaFileSystem(IDiscRecorder2 discRecorder, object[] multisessionInterfaces, out IStream dataStream)
        {
            MsftFileSystemImage fileSystemImage = null;
            try
            {
                fileSystemImage = new MsftFileSystemImage();
                fileSystemImage.ChooseImageDefaults(discRecorder);
                fileSystemImage.FileSystemsToCreate =
                    FsiFileSystems.FsiFileSystemJoliet | FsiFileSystems.FsiFileSystemISO9660;
                fileSystemImage.VolumeName = volume_label.Text;

                fileSystemImage.Update += fileSystemImage_Update;

                //
                // If multisessions, then import previous sessions
                //
                if (multisessionInterfaces != null)
                {
                    fileSystemImage.MultisessionInterfaces = multisessionInterfaces;
                    fileSystemImage.ImportFileSystem();
                }

                //
                // Get the image root
                //
                IFsiDirectoryItem rootItem = fileSystemImage.Root;

                //
                // Add Files and Directories to File System Image
                //
                foreach (IMediaItem mediaItem in lb.Items)
                {
                    //
                    // Check if we've cancelled
                    //
                    if (backgroundBurnWorker.CancellationPending)
                    {
                        break;
                    }

                    //
                    // Add to File System
                    //
                    mediaItem.AddToFileSystem(rootItem);
                }

                fileSystemImage.Update -= fileSystemImage_Update;

                //
                // did we cancel?
                //
                if (backgroundBurnWorker.CancellationPending)
                {
                    dataStream = null;
                    return false;
                }

                dataStream = fileSystemImage.CreateResultImage().ImageStream;
            }
            catch (COMException exception)
            {
                MessageBox.Show(this, exception.Message, "Create File System Error", 
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                dataStream = null;
                return false;
            }
            finally
            {
                if (fileSystemImage != null)
                {
                    Marshal.ReleaseComObject(fileSystemImage);
                }
            }

	        return true;
        }
예제 #39
0
        private void _CreateImage(IDiscRecorder2 discRecorder, object[] multisessionInterfaces, out IStream dataStream)
        {
            MsftFileSystemImage image = null;
            string volumeLabel = this.VolumeLabel;
            try
            {
                if (String.IsNullOrEmpty(volumeLabel))
                    volumeLabel = DateTime.Now.ToShortDateString();

                image = new MsftFileSystemImage();
                image.ChooseImageDefaults(discRecorder);
                image.FileSystemsToCreate = FsiFileSystems.FsiFileSystemJoliet | FsiFileSystems.FsiFileSystemISO9660;
                image.VolumeName = volumeLabel;

                image.Update += _fileSystemImage_Update;

                // If multisessions, then import previous sessions
                if (multisessionInterfaces != null)
                {
                    image.MultisessionInterfaces = multisessionInterfaces;
                    image.ImportFileSystem();
                }

                IFsiDirectoryItem rootNode = image.Root;
                foreach (IMediaNode node in this.Nodes)
                {
                    _AddNode(rootNode, node);
                }

                image.Update -= _fileSystemImage_Update;

                dataStream = image.CreateResultImage().ImageStream;
            }
            finally
            {
                if (image != null)
                    Marshal.ReleaseComObject(image);
            }
        }
예제 #40
0
        private bool CreateMediaFileSystem(IDiscRecorder2 discRecorder, object[] multisessionInterfaces,
                    out IStream dataStream)
        {
            MsftFileSystemImage fileSystemImage = null;
            try
            {
                fileSystemImage = new MsftFileSystemImage();
                fileSystemImage.ChooseImageDefaults(discRecorder);
                fileSystemImage.FileSystemsToCreate = FsiFileSystems.FsiFileSystemJoliet | FsiFileSystems.FsiFileSystemISO9660;
                fileSystemImage.VolumeName = "";

                fileSystemImage.Update += fileSystemImage_Update;

                if (multisessionInterfaces != null)
                {
                    fileSystemImage.MultisessionInterfaces = multisessionInterfaces;
                    fileSystemImage.ImportFileSystem();
                }

                var rootItem = fileSystemImage.Root;

                foreach (var mediaItem in mediaItems)
                {
                    if (cancellationToken.IsCancellationRequested)
                        break;

                    mediaItem.AddToFileSystem(rootItem);
                }

                fileSystemImage.Update -= fileSystemImage_Update;

                if (cancellationToken.IsCancellationRequested)
                {
                    dataStream = null;
                    return false;
                }

                dataStream = fileSystemImage.CreateResultImage().ImageStream;
            }
            catch (COMException exception)
            {
                MessageBox.Show(exception.Message, "Create File System Error",
                    MessageBoxButton.OK, MessageBoxImage.Error);
                dataStream = null;
                return false;
            }
            finally
            {
                if (fileSystemImage != null)
                    Marshal.ReleaseComObject(fileSystemImage);
            }

            return true;
        }