コード例 #1
0
ファイル: BurnerSrvImpl.cs プロジェクト: digiPHOTO-it/lumen
        /// <summary>
        /// Completed the "Burn" thread
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backgroundBurnWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            BurnerMsg burnerMsg = new BurnerMsg(this);

            System.Diagnostics.Trace.WriteLine((int)e.Result == 0 ? "Finished Burning Disc!" : "Error Burning Disc!");
            burnerMsg.fase = (int)e.Result == 0 ? Fase.MasterizzazioneCompletata : Fase.MasterizzazioneFallita;
            OnInviaStatoMasterizzazione(burnerMsg);
        }
コード例 #2
0
ファイル: BurnerSrvImpl.cs プロジェクト: digiPHOTO-it/lumen
        private void backgroundFormatWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            System.Diagnostics.Trace.WriteLine((int)e.Result == 0 ?"Finished Formatting Disc!" : "Error Formatting Disc!");
            BurnerMsg burnerMsg = new BurnerMsg(this);

            burnerMsg.fase = (int)e.Result == 0 ? Fase.FormattazioneCompletata : Fase.FormattazioneFallita;
            OnInviaStatoMasterizzazione(burnerMsg);
            //formatProgressBar.Value = 0;
        }
コード例 #3
0
ファイル: BurnerSrvImpl.cs プロジェクト: digiPHOTO-it/lumen
        private void backgroundFormatWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            System.Diagnostics.Trace.WriteLine("Formatting {0}%... " + e.ProgressPercentage);
            BurnerMsg burnerMsg = new BurnerMsg(this);

            burnerMsg.statusMessage = "Formatting {0}%... " + e.ProgressPercentage;
            burnerMsg.progress      = 0;
            OnInviaStatoMasterizzazione(burnerMsg);
            //formatProgressBar.Value = e.ProgressPercentage;
        }
コード例 #4
0
ファイル: BurnerSrvImpl.cs プロジェクト: digiPHOTO-it/lumen
        /// <summary>
        /// Notifico l'Evento agli ascoltatori
        /// </summary>
        /// <param name="e">Classe che rappresenta l'unità di informazione
        /// trasportata dall'evento</param>
        protected virtual void OnInviaStatoMasterizzazione(BurnerMsg e)
        {
            StatoMasterizzazioneEventHandler handler = InviaStatoMasterizzazione;

            // non ho nessun ascoltatore
            if (handler != null)
            {
                // L'evento è un delegato, quindi eseguendo il delegato eseguiamo tutti i metodi
                // ad esso registrati.
                handler(this, e);
            }
        }
コード例 #5
0
ファイル: BurnerSrvImpl.cs プロジェクト: digiPHOTO-it/lumen
        /// <summary>
        /// Aggiorna la capacità rimanente nel disco
        /// </summary>
        private String UpdateCapacity()
        {
            string capacity = "OMB";

            //
            // Get the text for the Max Size
            //
            if (_totalDiscSize == 0)
            {
                return(capacity = "0MB");
            }

            capacity = _totalDiscSize < 1000000000 ?
                       string.Format("{0}MB", _totalDiscSize / 1000000) :
                       string.Format("{0:F2}GB", (float)_totalDiscSize / 1000000000.0);

            //
            // Calculate the size of the files
            //
            Int64 totalMediaSize = 0;

            foreach (IMediaItem mediaItem in listaFileDaMasterizzare)
            {
                totalMediaSize += mediaItem.SizeOnDisc;
            }
            BurnerMsg burnerMsg = new BurnerMsg(this);

            burnerMsg.capacity = capacity;
            OnInviaStatoMasterizzazione(burnerMsg);
            return(capacity);
            // Aggiornamento grafica

            //if (totalMediaSize == 0)
            //{
            //    progressBarCapacity.Value = 0;
            //    progressBarCapacity.ForeColor = SystemColors.Highlight;
            //}
            //else
            //{
            //    var percent = (int)((totalMediaSize * 100) / _totalDiscSize);
            //    if (percent > 100)
            //    {
            //        progressBarCapacity.Value = 100;
            //        progressBarCapacity.ForeColor = Color.Red;
            //    }
            //    else
            //    {
            //        progressBarCapacity.Value = percent;
            //        progressBarCapacity.ForeColor = SystemColors.Highlight;
            //    }
            //}
        }
コード例 #6
0
ファイル: BurnerSrvImpl.cs プロジェクト: digiPHOTO-it/lumen
        public void formatting()
        {
            BurnerMsg burnerMsg = new BurnerMsg(this);

            burnerMsg.fase = Fase.FormattazioneIniziata;
            OnInviaStatoMasterizzazione(burnerMsg);

            System.Diagnostics.Trace.WriteLine("Inizio Formattazione");

            backgroundFormatWorker = new BackgroundWorker();
            backgroundFormatWorker.WorkerReportsProgress      = true;
            backgroundFormatWorker.WorkerSupportsCancellation = true;
            backgroundFormatWorker.DoWork             += backgroundFormatWorker_DoWork;
            backgroundFormatWorker.ProgressChanged    += new ProgressChangedEventHandler(backgroundFormatWorker_ProgressChanged);
            backgroundFormatWorker.RunWorkerCompleted += backgroundFormatWorker_RunWorkerCompleted;
            backgroundFormatWorker.RunWorkerAsync(discRecorder.ActiveDiscRecorder);
        }
コード例 #7
0
ファイル: BurnerSrvImpl.cs プロジェクト: digiPHOTO-it/lumen
        public void burning()
        {
            BurnerMsg burnerMsg = new BurnerMsg(this);

            burnerMsg.fase = Fase.MasterizzazioneIniziata;
            burnerMsg.totaleFileAggiunti = listaFileDaMasterizzare.Count;
            OnInviaStatoMasterizzazione(burnerMsg);

            _burner.uniqueRecorderId = this.discRecorder.ActiveDiscRecorder;

            backgroundBurnWorker = new BackgroundWorker();
            backgroundBurnWorker.WorkerReportsProgress      = true;
            backgroundBurnWorker.WorkerSupportsCancellation = true;
            backgroundBurnWorker.DoWork             += backgroundBurnWorker_DoWork;
            backgroundBurnWorker.ProgressChanged    += backgroundBurnWorker_ProgressChanged;
            backgroundBurnWorker.RunWorkerCompleted += backgroundBurnWorker_RunWorkerCompleted;
            backgroundBurnWorker.RunWorkerAsync(_burner);
        }
コード例 #8
0
ファイル: BurnerSrvImpl.cs プロジェクト: digiPHOTO-it/lumen
        /// <summary>
        /// Worker thread that Formats the Disc
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backgroundFormatWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            MsftDiscRecorder2    discRecorder    = null;
            MsftDiscFormat2Erase discFormatErase = null;
            BurnerMsg            burnerMsg       = new BurnerMsg(this);

            try
            {
                //
                // Create and initialize the IDiscRecorder2
                //
                discRecorder = new MsftDiscRecorder2();
                var activeDiscRecorder = (string)e.Argument;
                discRecorder.InitializeDiscRecorder(activeDiscRecorder);

                //
                // Create the IDiscFormat2Erase and set properties
                //
                discFormatErase = new MsftDiscFormat2Erase
                {
                    Recorder   = discRecorder,
                    ClientName = ClientName,
                    FullErase  = !quickFormat
                };

                //
                // Setup the Update progress event handler
                //
                discFormatErase.Update += discFormatErase_Update;

                //
                // Erase the media here
                //
                try
                {
                    discFormatErase.EraseMedia();
                    e.Result = 0;
                }
                catch (COMException ex)
                {
                    e.Result = ex.ErrorCode;
                    System.Diagnostics.Trace.WriteLine("IDiscFormat2.EraseMedia failed " + ex.Message);
                    burnerMsg.fase = Fase.FormattazioneFallita;
                    OnInviaStatoMasterizzazione(burnerMsg);
                }

                //
                // Remove the Update progress event handler
                //
                discFormatErase.Update -= discFormatErase_Update;

                //
                // Eject the media
                //
                if (ejectMedia)
                {
                    discRecorder.EjectMedia();
                }
                burnerMsg.fase = Fase.FormattazioneCompletata;
                OnInviaStatoMasterizzazione(burnerMsg);
            }
            catch (COMException exception)
            {
                //
                // If anything happens during the format, show the message
                //
                System.Diagnostics.Trace.WriteLine(exception.Message);
                burnerMsg.fase = Fase.FormattazioneFallita;
                OnInviaStatoMasterizzazione(burnerMsg);
            }
            finally
            {
                if (discRecorder != null)
                {
                    Marshal.ReleaseComObject(discRecorder);
                }

                if (discFormatErase != null)
                {
                    Marshal.ReleaseComObject(discFormatErase);
                }
            }
        }
コード例 #9
0
ファイル: BurnerSrvImpl.cs プロジェクト: digiPHOTO-it/lumen
        /// <summary>
        /// Event receives notification from the Burn thread of an event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backgroundBurnWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            BurnerMsg burnerMsg = new BurnerMsg(this);
            //int percent = e.ProgressPercentage;
            var burnData = (BurnData)e.UserState;

            if (burnData.task == BURN_MEDIA_TASK.BURN_MEDIA_TASK_FILE_SYSTEM)
            {
                System.Diagnostics.Trace.WriteLine("[0]:" + burnData.statusMessage);
                burnerMsg.statusMessage = burnData.statusMessage;
                burnerMsg.progress      = 0;
                OnInviaStatoMasterizzazione(burnerMsg);
            }
            else if (burnData.task == BURN_MEDIA_TASK.BURN_MEDIA_TASK_WRITING)
            {
                switch (burnData.currentAction)
                {
                case IMAPI_FORMAT2_DATA_WRITE_ACTION.IMAPI_FORMAT2_DATA_WRITE_ACTION_VALIDATING_MEDIA:
                    System.Diagnostics.Trace.WriteLine("[0]:" + "Validating current media...");
                    burnerMsg.fase          = Fase.ValidatingCurrentMedia;
                    burnerMsg.statusMessage = "Validating Current Media";
                    OnInviaStatoMasterizzazione(burnerMsg);
                    break;

                case IMAPI_FORMAT2_DATA_WRITE_ACTION.IMAPI_FORMAT2_DATA_WRITE_ACTION_FORMATTING_MEDIA:
                    System.Diagnostics.Trace.WriteLine("[0]:" + "Formatting media...");
                    burnerMsg.fase          = Fase.FormattingMedia;
                    burnerMsg.statusMessage = "Formatting Media";
                    OnInviaStatoMasterizzazione(burnerMsg);
                    break;

                case IMAPI_FORMAT2_DATA_WRITE_ACTION.IMAPI_FORMAT2_DATA_WRITE_ACTION_INITIALIZING_HARDWARE:
                    System.Diagnostics.Trace.WriteLine("[0]:" + "Initializing hardware...");
                    burnerMsg.fase          = Fase.InitializingHardware;
                    burnerMsg.statusMessage = "Initializing hardware";
                    OnInviaStatoMasterizzazione(burnerMsg);
                    break;

                case IMAPI_FORMAT2_DATA_WRITE_ACTION.IMAPI_FORMAT2_DATA_WRITE_ACTION_CALIBRATING_POWER:
                    System.Diagnostics.Trace.WriteLine("[0]:" + "Optimizing laser intensity...");
                    burnerMsg.statusMessage = "Optimizing Laser Intensity";
                    burnerMsg.fase          = Fase.OptimizingLaserIntensity;
                    OnInviaStatoMasterizzazione(burnerMsg);
                    break;

                case IMAPI_FORMAT2_DATA_WRITE_ACTION.IMAPI_FORMAT2_DATA_WRITE_ACTION_WRITING_DATA:
                    long writtenSectors = burnData.lastWrittenLba - burnData.startLba;

                    if (writtenSectors > 0 && burnData.sectorCount > 0)
                    {
                        var percent = (int)((100 * writtenSectors) / burnData.sectorCount);
                        System.Diagnostics.Trace.WriteLine("[0]:" + string.Format("Progress: {0}%", percent));
                        burnerMsg.progress = percent;
                        OnInviaStatoMasterizzazione(burnerMsg);
                    }
                    else
                    {
                        System.Diagnostics.Trace.WriteLine("[0]:" + "Progress 0%");
                        burnerMsg.progress = 0;
                        OnInviaStatoMasterizzazione(burnerMsg);
                    }
                    break;

                case IMAPI_FORMAT2_DATA_WRITE_ACTION.IMAPI_FORMAT2_DATA_WRITE_ACTION_FINALIZATION:
                    System.Diagnostics.Trace.WriteLine("[0]:" + "Finalizing writing...");
                    burnerMsg.statusMessage = "Finalizing Writing";
                    burnerMsg.fase          = Fase.FinalizingWriting;
                    OnInviaStatoMasterizzazione(burnerMsg);
                    break;

                case IMAPI_FORMAT2_DATA_WRITE_ACTION.IMAPI_FORMAT2_DATA_WRITE_ACTION_COMPLETED:
                    System.Diagnostics.Trace.WriteLine("[0]:" + "Completed!");
                    burnerMsg.statusMessage = "Completed";
                    burnerMsg.fase          = Fase.Completed;
                    OnInviaStatoMasterizzazione(burnerMsg);
                    break;

                case IMAPI_FORMAT2_DATA_WRITE_ACTION.IMAPI_FORMAT2_DATA_WRITE_ACTION_VERIFYING:
                    System.Diagnostics.Trace.WriteLine("[0]:" + "Verifying");
                    burnerMsg.statusMessage = "Verifying";
                    burnerMsg.fase          = Fase.Verifying;
                    OnInviaStatoMasterizzazione(burnerMsg);
                    break;
                }
            }
        }
コード例 #10
0
ファイル: BurnerSrvImpl.cs プロジェクト: digiPHOTO-it/lumen
        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;
                System.Diagnostics.Trace.WriteLine("Etichetta: " + this.etichetta);
                fileSystemImage.VolumeName = this.etichetta;

                //fileSystemImage.Update += fileSystemImage_Update;
                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 listaFileDaMasterizzare)
                {
                    //
                    // Check if we've cancelled
                    //
                    if (backgroundBurnWorker.CancellationPending)
                    {
                        break;
                    }

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

                //fileSystemImage.Update -= fileSystemImage_Update;
                fileSystemImage.Update -= new DFileSystemImage_EventHandler(fileSystemImage_Update);

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

                dataStream = fileSystemImage.CreateResultImage().ImageStream;
            }
            catch (COMException exception)
            {
                System.Diagnostics.Trace.WriteLine("FileSystem" + exception.Message);
                BurnerMsg burnerMsg = new BurnerMsg(this);
                burnerMsg.fase = Fase.MasterizzazioneFallita;
                OnInviaStatoMasterizzazione(burnerMsg);
                //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);
        }
コード例 #11
0
ファイル: BurnerSrvImpl.cs プロジェクト: digiPHOTO-it/lumen
        /// <summary>
        /// The thread that does the burning of the media
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backgroundBurnWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            MsftDiscRecorder2   discRecorder   = null;
            MsftDiscFormat2Data discFormatData = null;

            try
            {
                //
                // Create and initialize the IDiscRecorder2 object
                //
                discRecorder = new MsftDiscRecorder2();
                var burnData = (BurnData)e.Argument;
                discRecorder.InitializeDiscRecorder(burnData.uniqueRecorderId);

                //
                // Create and initialize the IDiscFormat2Data
                //
                discFormatData = new MsftDiscFormat2Data
                {
                    Recorder             = discRecorder,
                    ClientName           = ClientName,
                    ForceMediaToBeClosed = closeMedia
                };

                //
                // Set the verification level
                //
                var burnVerification = (IBurnVerification)discFormatData;
                burnVerification.BurnVerificationLevel = _verificationLevel;

                //
                // Check if media is blank, (for RW media)
                //
                object[] multisessionInterfaces = null;
                if (!discFormatData.MediaHeuristicallyBlank)
                {
                    multisessionInterfaces = discFormatData.MultisessionInterfaces;
                }

                //
                // Create the file system
                //
                IStream fileSystem;
                if (!CreateMediaFileSystem(discRecorder, multisessionInterfaces, out fileSystem))
                {
                    e.Result = -1;
                    return;
                }

                //
                // add the Update event handler
                //

                discFormatData.Update += new DiscFormat2Data_EventHandler(discFormatData_Update);
                //
                // Write the data here
                //
                try
                {
                    discFormatData.Write(fileSystem);
                    e.Result = 0;
                }
                catch (COMException ex)
                {
                    e.Result = ex.ErrorCode;
                    BurnerMsg burnerMsg = new BurnerMsg(this);
                    burnerMsg.fase          = Fase.MasterizzazioneFallita;
                    burnerMsg.statusMessage = "IDiscFormat2Data.Write failed";
                    OnInviaStatoMasterizzazione(burnerMsg);
                    System.Diagnostics.Trace.WriteLine(ex.Message, "IDiscFormat2Data.Write failed");
                }
                finally
                {
                    if (fileSystem != null)
                    {
                        Marshal.FinalReleaseComObject(fileSystem);
                    }
                }

                //
                // remove the Update event handler
                //
                discFormatData.Update -= new DiscFormat2Data_EventHandler(discFormatData_Update);

                if (ejectMedia)
                {
                    discRecorder.EjectMedia();
                }
            }
            catch (COMException exception)
            {
                //
                // If anything happens during the format, show the message
                //
                System.Diagnostics.Trace.WriteLine("[Eccezione]: " + exception.Message);
                e.Result = exception.ErrorCode;
                BurnerMsg burnerMsg = new BurnerMsg(this);
                burnerMsg.fase          = Fase.MasterizzazioneFallita;
                burnerMsg.statusMessage = exception.Message;
                OnInviaStatoMasterizzazione(burnerMsg);
            }
            finally
            {
                if (discRecorder != null)
                {
                    Marshal.ReleaseComObject(discRecorder);
                }

                if (discFormatData != null)
                {
                    Marshal.ReleaseComObject(discFormatData);
                }
            }
        }
コード例 #12
0
ファイル: BurnerSrvImpl.cs プロジェクト: digiPHOTO-it/lumen
        /// <summary>
        /// Verifico se il supporto può essere utilizzato per masterizzare
        /// </summary>
        public bool testMedia()
        {
            MsftFileSystemImage fileSystemImage = null;
            MsftDiscFormat2Data discFormatData  = null;

            try
            {
                //
                // Create and initialize the IDiscFormat2Data
                //
                discFormatData = new MsftDiscFormat2Data();
                if (!discFormatData.IsCurrentMediaSupported(discRecorder))
                {
                    System.Diagnostics.Trace.WriteLine("Media not supported!");
                    _totalDiscSize = 0;
                    BurnerMsg errorMediaMsg = new BurnerMsg(this);
                    errorMediaMsg.fase          = Fase.ErrorMedia;
                    errorMediaMsg.statusMessage = "Media not supported!";
                    OnInviaStatoMasterizzazione(errorMediaMsg);
                    return(false);
                }
                else
                {
                    //
                    // Get the media type in the recorder
                    //
                    discFormatData.Recorder = this.discRecorder;
                    IMAPI_MEDIA_PHYSICAL_TYPE mediaType = discFormatData.CurrentPhysicalMediaType;
                    System.Diagnostics.Trace.WriteLine("Etichetta Media: " + GetMediaTypeString(mediaType));

                    //
                    // Create a file system and select the media type
                    //
                    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;
                }
            }
            catch (COMException exception)
            {
                System.Diagnostics.Trace.WriteLine("Detect Media Error " + exception.Message);
                BurnerMsg errorMediaMsg = new BurnerMsg(this);
                errorMediaMsg.fase          = Fase.ErrorMedia;
                errorMediaMsg.statusMessage = "Detect Media Error " + exception.Message;
                OnInviaStatoMasterizzazione(errorMediaMsg);
                return(false);
            }
            finally
            {
                if (discFormatData != null)
                {
                    Marshal.ReleaseComObject(discFormatData);
                }

                if (fileSystemImage != null)
                {
                    Marshal.ReleaseComObject(fileSystemImage);
                }
            }
            UpdateCapacity();
            return(true);
        }