示例#1
0
文件: Main.cs 项目: inorton/bpp
        public XmlDocument ProcessBmml( string outfile )
        {
            IEnumerable<CustomBmmlControl> clist = FindCustomControls( doc );

            foreach ( CustomBmmlControl c in clist ){
                Console.WriteLine( c.ControlId );
                // try to load that file

                if ( !String.IsNullOrEmpty(c.CustomData) ){

                    Bpp subproc = new Bpp();
                    subproc.LoadBmmlFile( c.CustomData );
                    XmlDocument cust = subproc.ProcessBmml(c.CustomData);

                    // get actual content
                    XmlNode docdata = cust.FirstChild.FirstChild.FirstChild;

                    Console.WriteLine( c.XmlNode.Name );

                    XmlNode replace = doc.ImportNode( docdata, true );

                    c.XmlNode.ParentNode.ReplaceChild( replace, c.XmlNode );

                    Console.Error.WriteLine( c.XmlNode.Name );

                    // copy position/id/size from replaced control to new one
                    foreach ( XmlAttribute a in c.XmlNode.Attributes ){

                        switch( a.Name ){

                            case "controlID":
                            case "x":
                            case "y":
                            case "isInGroup":
                            Console.Error.WriteLine( "keep Name={0} Value={1}", a.Name, a.Value );
                            replace.Attributes[a.Name].Value = a.Value;
                            break;

                            default:
                            Console.Error.WriteLine( "ignore Name={0} Value={1}", a.Name, a.Value );
                            break;

                        }
                    }

                }
            }

            if ( outfile != null ){
                StreamWriter sw = new StreamWriter( outfile );
                sw.Write( doc.OuterXml );
                sw.Close();
            }
            return doc;
        }
示例#2
0
文件: Main.cs 项目: inorton/bpp
 public static void Main(string[] args)
 {
     processor = new Bpp();
     processor.LoadBmmlFile( args[0] );
     processor.ProcessBmml("output.bmml");
 }