Exemple #1
0
        private void TestScript()
        {
            short w1, w2, w3;

            m_head.GetScriptCount(out w1);

            m_head.AddScript("foo", "barism", 0);

            m_head.GetScriptCount(out w2);
            Debug.Assert(w2 == w1 + 1);

            long  l;
            short pLen = 0, pCLen = 0;

            m_head.GetScript(w1, null, ref pLen, null, ref pCLen, out l);

            StringBuilder sbType = new StringBuilder(pLen);
            StringBuilder sbCom  = new StringBuilder(pCLen);

            m_head.GetScript(w1, sbType, ref pLen, sbCom, ref pCLen, out l);

            m_head.RemoveScript(w1);

            m_head.GetScriptCount(out w3);
            Debug.Assert(w3 == w1);
        }
Exemple #2
0
        //------------------------------------------------------------------------------
        // Name: CWMVCopy::CopyScriptInHeader()
        // Desc: Copies the script in the header of the source file to the header
        //       of the destination file .
        //------------------------------------------------------------------------------
        protected void CopyScriptInHeader()
        {
            short         cScript       = 0;
            StringBuilder pwszType      = null;
            StringBuilder pwszCommand   = null;
            long          cnsScriptTime = 0;

            m_pReaderHeaderInfo.GetScriptCount(out cScript);

            for (short i = 0; i < cScript; i++)
            {
                short cchTypeLen    = 0;
                short cchCommandLen = 0;

                //
                // Get the memory size for this script
                //
                m_pReaderHeaderInfo.GetScript(i,
                                              null,
                                              ref cchTypeLen,
                                              null,
                                              ref cchCommandLen,
                                              out cnsScriptTime);

                pwszType    = new StringBuilder(cchTypeLen);
                pwszCommand = new StringBuilder(cchCommandLen);

                //
                // Get the script
                //
                m_pReaderHeaderInfo.GetScript(i,
                                              pwszType,
                                              ref cchTypeLen,
                                              pwszCommand,
                                              ref cchCommandLen,
                                              out cnsScriptTime);

                //
                // Add the script to the writer
                //
                m_pWriterHeaderInfo.AddScript(pwszType.ToString(),
                                              pwszCommand.ToString(),
                                              cnsScriptTime);
            }
        }
Exemple #3
0
        //------------------------------------------------------------------------------
        // Name: CWMVCopy::CopyScriptInList()
        // Desc: Copies scripts in m_ScriptList to the header of the writer.
        //------------------------------------------------------------------------------
        protected void CopyScriptInList(string pwszOutputFile)
        {
            IWMMetadataEditor pEditor           = null;
            IWMHeaderInfo     pWriterHeaderInfo = null;

            //
            // Scripts can be added by the metadata editor.
            // Create an editor
            //
            WMUtils.WMCreateEditor(out pEditor);

            try
            {
                //
                // Open the output using the editor
                //
                pEditor.Open(pwszOutputFile);

                pWriterHeaderInfo = pEditor as IWMHeaderInfo;

                foreach (CScript pScript in m_ScriptList)
                {
                    //
                    // Add the script to the writer
                    //
                    pWriterHeaderInfo.AddScript(pScript.m_pwszType,
                                                pScript.m_pwszParameter,
                                                pScript.m_cnsTime);
                }

                //
                // Close and release the editor
                //
                pEditor.Flush();

                pEditor.Close();
            }
            finally
            {
                Marshal.ReleaseComObject(pEditor);
            }
        }
Exemple #4
0
 /// <summary>
 /// Add a scrip. Wraps IWMHeaderInfo.AddScript
 /// </summary>
 /// <param name="s">Scrip to add. <see cref="Script"/></param>
 public void AddScript(Script s)
 {
     m_HeaderInfo.AddScript(s.Type, s.Command, s.Time);
 }