Beispiel #1
0
        public void ShowPage(EncodeProfile profile)
        {
            this.profile = (CmdLineEncoderProfile)profile;

            UpdateProfileList();

            Show();
        }
        // [i] �lj��p�����[�^
        //=========================================================================
        ///	<summary>
        ///		�G���R�[�h���s
        ///	</summary>
        /// <remarks>
        /// </remarks>
        /// <history>2006/XX/XX �V�K�쐬</history>
        //=========================================================================
        public override void DoEncode(
			string			sourceFile	,	// [i] �\�[�X�t�@�C��
			ref string		outputFile	,	// [io] �o�̓t�@�C��
			EncodeProfile	_profie		,	// [i] �G���R�[�h�v���t�@�C��
			object			_ai			)
        {
            string strDate;
            string sourceTempName = null;
            string outputTempName = null;
            CmdLineEncoderProfile			profile	= (CmdLineEncoderProfile)_profie;
            Encoder.TvProgramAdditionalInfo	ai		= null;

            if ( _ai.GetType() == typeof(magicAnime.Encoder.TvProgramAdditionalInfo) )
            {
                ai = (Encoder.TvProgramAdditionalInfo)_ai;
            }

            try
            {
                //--------------------------
                // �v���t�@�C����Ǎ�
                //--------------------------

                CmdLineInternalProfile prof = LoadProfile(profile.profileName);

                if (prof == null)
                    throw new Exception("�v���t�@�C�������‚���܂���");

                bool	isShortName	=	(prof.OutputType == 0)
                                    ||	(prof.OutputType == 1);
                bool	isTempName	=	(prof.OutputType == 0)
                                    ||	(prof.OutputType == 2);

                //
                // ���̓t�@�C���p�X
                //
                if( isShortName	)
                {
                    sourceTempName = FileSystem.ConvertToShortPathName( sourceFile );
                }
                else
                {
                    sourceTempName = sourceFile;
                }

                if (!File.Exists(sourceTempName))
                    throw new Exception("�G���R�[�h���̃t�@�C�������‚���܂���");

                //
                // �o�̓t�@�C���p�X
                //
                string ext;

                ext = prof.Extension.Trim();
                if ( !ext.Equals( "" ) )
                    ext = "." + ext;

                if( isTempName )
                {
                    //------------------------------
                    // �ꎞ�t�@�C������n��
                    //------------------------------
                    string dir;

                    strDate = DateTime.Now.ToString();
                    strDate = strDate.Replace( " ", "_" ).Replace( " ", "_" ).Replace( ":", "-" ).Replace( "/", "-" );

                    if (prof.OutputType == 0)
                    {
                        dir = FileSystem.ConvertToShortPathName(Path.GetDirectoryName(outputFile));
                        if (dir == "")
                            throw new Exception("DOS�`���̃f�B���N�g������擾�ł��܂���(" + outputFile.ToString() + ")");
                    }
                    else
                        dir = Path.GetDirectoryName(outputFile);

                    outputTempName = dir + "\\ENCODED" + strDate + ext;

                }
                else if( !isTempName )
                {
                    //------------------------------
                    // �ۑ��t�@�C������n��
                    //------------------------------
                    string dir;

                    if (prof.OutputType == 1)
                    {
                        dir = FileSystem.ConvertToShortPathName(Path.GetDirectoryName(outputFile));
                        if (dir == "")
                            throw new Exception("DOS�`���̃f�B���N�g������擾�ł��܂���(" + outputFile.ToString() + ")");
                    }
                    else
                        dir = Path.GetDirectoryName(outputFile);

                    outputTempName = dir + "\\" + Path.GetFileNameWithoutExtension( outputFile ) + ext;
                }
                else
                {
                    throw new Exception("�ݒ肪����������܂���B");
                }

                ExecEncoder(sourceTempName, outputTempName, prof, ai );

                if (!File.Exists(outputTempName))
                    throw new Exception("�G���R�[�h�����o�̓t�@�C�����s���s��");

                // �����t�@�C����outputFile�̊g���q��ύX����
                outputFile = outputFile.Substring(0, outputFile.Length - Path.GetExtension(outputFile).Length) + ext;

                // �ꎞ�t�@�C�����𐳎����ɕύX����
                if( isTempName )
                {
                    File.Move( outputTempName, outputFile );
                }

            }
            catch (AbortException e)
            {
                if (outputTempName!=null && File.Exists(outputTempName))
                    File.Delete(outputTempName);
                throw e;
            }
        }
        /////////////////////////////////////////////////////////////////////////////
        // FUNCTION	:	CreatePropertyPage
        // DESCRIPT	:	�v���t�@�C����ҏW����v���p�e�B�y�[�W��쐬����
        /////////////////////////////////////////////////////////////////////////////
        public override Form CreatePropertyPage(
			Control parent,
			EncodeProfile profile)
        {
            cmdLineProperty page = new cmdLineProperty();

            page.TopLevel	= false;
            page.Parent		= parent;
            page.ShowPage(profile);

            return page;
        }