Foreign/RibbonLib_v2.6/RibbonGenerator/RibbonGenerator/Manager.cs
/// <summary>
/// Create and execute the bat file to create a ribbon dll.
/// </summary>
/// <param name="localizedRibbonXmlFilename">the name of the ribbon xaml</param>
/// <returns>the name of the dll file</returns>
Create and execute the bat file to create a ribbon dll.
Create and execute the bat file to create a ribbon dll .
string ConvertXmlToDll(string localizedRibbonXmlFilename)
        {
            string batFilename = Path.ChangeExtension(localizedRibbonXmlFilename, ".bat");
            string bmlFilename = Path.ChangeExtension(localizedRibbonXmlFilename, ".bml");
            string rcFilename = Path.ChangeExtension(localizedRibbonXmlFilename, ".rc");
            string resFilename = Path.ChangeExtension(localizedRibbonXmlFilename, ".res");
            string dllFilename = Path.ChangeExtension(localizedRibbonXmlFilename, ".ribbondll");
            this.CleanupFiles.AddRange(new string[] {batFilename, bmlFilename, rcFilename, resFilename, dllFilename });
            var bat = File.ReadAllText(Util.TemplateBatFilename);
            bat = bat.Replace("{XmlFilename}", localizedRibbonXmlFilename);
            bat = bat.Replace("{BmlFilename}", bmlFilename);
            bat = bat.Replace("{RcFilename}", rcFilename);
            bat = bat.Replace("{DllFilename}", dllFilename);
            bat = bat.Replace("{ResFilename}", resFilename);
            File.WriteAllText(batFilename, bat);
            System.Diagnostics.Process proc = new System.Diagnostics.Process();
            proc.StartInfo.FileName = batFilename;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.StartInfo.UseShellExecute = false;
            proc.StartInfo.CreateNoWindow = true;
            proc.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(proc_OutputDataReceived);
            proc.Start();
            proc.BeginOutputReadLine();
            proc.WaitForExit();
            if (!File.Exists(bmlFilename) || !File.Exists(rcFilename))
                throw new FaildException("uicc.exe failed to generate .bml or .rc file!");
            if (!File.Exists(resFilename))
                throw new FaildException("rc.exe failed to generate binary .res file!");
            if(!File.Exists(dllFilename))
                throw new FaildException("link.exe failed to generate binary resource .dll file!");
            return dllFilename;
        }
string ConvertXmlToDll ( string localizedRibbonXmlFilename ) { string batFilename = Path . ChangeExtension ( localizedRibbonXmlFilename , " " ) ; string bmlFilename = Path . ChangeExtension ( localizedRibbonXmlFilename , " " ) ; string rcFilename = Path . ChangeExtension ( localizedRibbonXmlFilename , " " ) ; string resFilename = Path . ChangeExtension ( localizedRibbonXmlFilename , " " ) ; string dllFilename = Path . ChangeExtension ( localizedRibbonXmlFilename , " " ) ; this . CleanupFiles . AddRange ( new string [ ] { batFilename , bmlFilename , rcFilename , resFilename , dllFilename } ) ; var bat = File . ReadAllText ( Util . TemplateBatFilename ) ; bat = bat . Replace ( " " , localizedRibbonXmlFilename ) ; bat = bat . Replace ( " " , bmlFilename ) ; bat = bat . Replace ( " " , rcFilename ) ; bat = bat . Replace ( " " , dllFilename ) ; bat = bat . Replace ( " " , resFilename ) ; File . WriteAllText ( batFilename , bat ) ; System . Diagnostics . Process proc = new System . Diagnostics . Process ( ) ; proc . StartInfo . FileName = batFilename ; proc . StartInfo . RedirectStandardOutput = true ; proc . StartInfo . UseShellExecute = false ; proc . StartInfo . CreateNoWindow = true ; proc . OutputDataReceived += new System . Diagnostics . DataReceivedEventHandler ( proc_OutputDataReceived ) ; proc . Start ( ) ; proc . BeginOutputReadLine ( ) ; proc . WaitForExit ( ) ; if ( ! File . Exists ( bmlFilename ) || ! File . Exists ( rcFilename ) ) throw new FaildException ( " " ) ; if ( ! File . Exists ( resFilename ) ) throw new FaildException ( " " ) ; if ( ! File . Exists ( dllFilename ) ) throw new FaildException ( " " ) ; return dllFilename ; }
Create and execute the bat file to create a ribbon dll.
Create and execute the bat file to create a ribbon dll .
the name of the dll file
the name of the dll file
localizedRibbonXmlFilename
string
the name of the ribbon xaml
the name of the ribbon xaml