Esempio n. 1
0
        private void SetDrive(int driveIndex)
        {
            switch (fActiveFormat)
            {
            case RecordType.afMusic:
                if ((driveIndex > fMusicRecorders.Count) || (driveIndex < 0))
                {
                    throw new XPBurnException(String.Format(Resource.CantSetDriver, driveIndex.ToString()));
                }

                fActiveRecorder = (IDiscRecorder)fMusicRecorders[driveIndex];

                break;

            case RecordType.afData:
                if ((driveIndex > fDataRecorders.Count) || (driveIndex < 0))
                {
                    throw new XPBurnException(String.Format(Resource.CantSetDriver, driveIndex.ToString()));
                }

                fActiveRecorder = (IDiscRecorder)fDataRecorders[driveIndex];

                break;
            }

            fCancel      = false;
            fBurnerDrive = driveIndex;

            fActiveRecorder.GetDisplayNames(out fVendor, out fProductID, out fRevision);

            int typeCode;

            fActiveRecorder.GetRecorderType(out typeCode);

            switch (typeCode)
            {
            case 0x1:
                fRecorderType = RecorderType.rtCDR;
                break;

            case 0x2:
                fRecorderType = RecorderType.rtCDRW;
                break;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Sets the property value.
        /// </summary>
        /// <param name="discRecorder">The disc recorder.</param>
        /// <param name="propertyID">The property ID.</param>
        /// <param name="value">The value.</param>
        /// <exception cref="COMException"></exception>
        /// <exception cref="NoDevicePropertiesException"></exception>
        /// <exception cref="RecorderNotInitializedException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        internal static void SetDiscRecorderPropertyValue( IDiscRecorder discRecorder, string propertyID, object value )
        {
            IPropertyStorage ppPropStg;
            PropSpec rgPropID;
            object newValue;

            try
            {
                discRecorder.GetRecorderProperties( out ppPropStg );
            }
            catch ( COMException ex )
            {
                Trace.WriteLine( ex.Message + Environment.NewLine + ex.StackTrace );
                switch ( (uint) ex.ErrorCode )
                {
                    case ErrorCodes.IMAPI_E_DEVICE_NOPROPERTIES:
                        throw new NoDevicePropertiesException();
                    case ErrorCodes.IMAPI_E_NOTOPENED:
                        throw new DiscMasterNotOpenedException();
                    case ErrorCodes.IMAPI_E_NOACTIVEFORMAT:
                        throw new NoActiveFormatException();
                    case ErrorCodes.IMAPI_E_WRONGFORMAT:
                        throw new WrongFormatException();
                    default:
                        throw;
                }
            }
            newValue = value;
            rgPropID = new PropSpec();

            rgPropID.ulKind = PrpSpec.LPWStr;
            rgPropID.ID_or_LPWSTR = Marshal.StringToCoTaskMemUni( propertyID );

            try
            {
                ppPropStg.WriteMultiple( 1, ref rgPropID, ref newValue, 8 );
            } // End try
            catch ( Exception ex )
            {
                Trace.WriteLine( "Error setting " + propertyID + "." + Environment.NewLine + ex.Message +
                                 Environment.NewLine + ex.StackTrace );
                throw;
            }
            finally
            {
                Marshal.FreeCoTaskMem( rgPropID.ID_or_LPWSTR );
            }

            try
            {
                discRecorder.SetRecorderProperties( ppPropStg );
            }
            catch ( COMException ex )
            {
                Trace.WriteLine( ex.Message + Environment.NewLine + ex.StackTrace );
                switch ( (uint) ex.ErrorCode )
                {
                    case ErrorCodes.IMAPI_S_PROPERTIESIGNORED:
                        Trace.WriteLine( Resources.Error_Msg_IMAPI_S_PROPERTIESIGNORED );
                        break;
                    case ErrorCodes.IMAPI_E_DEVICE_NOPROPERTIES:
                        throw new NoDevicePropertiesException();
                    case ErrorCodes.IMAPI_E_NOTOPENED:
                        throw new DiscMasterNotOpenedException();
                    case ErrorCodes.IMAPI_E_NOACTIVEFORMAT:
                        throw new NoActiveFormatException();
                    case ErrorCodes.IMAPI_E_WRONGFORMAT:
                        throw new WrongFormatException();
                    default:
                        throw;
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Sets the property value.
        /// </summary>
        /// <param name="discRecorder">The disc recorder.</param>
        /// <param name="propertyID">The property ID.</param>
        /// <returns></returns>
        /// <exception cref="COMException"></exception>
        /// <exception cref="NoDevicePropertiesException"></exception>
        /// <exception cref="RecorderNotInitializedException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        internal static object GetDiscRecorderPropertyValue( IDiscRecorder discRecorder, string propertyID )
        {
            IPropertyStorage ppPropStg;
            PropSpec rgPropID;
            object rgPropVar;

            try
            {
                discRecorder.GetRecorderProperties( out ppPropStg );
            }
            catch ( COMException ex )
            {
                switch ( (uint) ex.ErrorCode )
                {
                    case ErrorCodes.IMAPI_E_DEVICE_NOPROPERTIES:
                        throw new NoDevicePropertiesException();
                    case ErrorCodes.IMAPI_E_NOTINITIALIZED:
                        throw new RecorderNotInitializedException();
                    default:
                        throw;
                }
            }

            rgPropID = new PropSpec();
            rgPropVar = null;
            rgPropID.ulKind = PrpSpec.LPWStr;
            rgPropID.ID_or_LPWSTR = Marshal.StringToCoTaskMemUni( propertyID );

            try
            {
                ppPropStg.ReadMultiple( 1, ref rgPropID, out rgPropVar );
            }
            catch ( COMException ce )
            {
                Trace.WriteLine( CultureInfo.CurrentCulture, "Error getting AudioGapSize." );
                Trace.WriteLine( string.Format( CultureInfo.CurrentCulture, "{0}{1}{2}", ce.Message, Environment.NewLine,
                                                ce.StackTrace ) );
                return -1;
            }
            finally
            {
                Marshal.FreeCoTaskMem( rgPropID.ID_or_LPWSTR );
            }

            try
            {
                return Int32.Parse( rgPropVar.ToString(), CultureInfo.CurrentCulture );
            }
            catch ( Exception ex )
            {
                Trace.WriteLine( ex.Message + Environment.NewLine + ex.StackTrace );
                return -1;
            }
        }