//////////////////////////////////////////////////////////////////////////

        public void readGameXML(String xmlfile)
        {
            XmlDocument xml = new XmlDocument();

            xml.Load(xmlfile);
            XmlNode root  = xml.SelectSingleNode("xml");
            XmlNode games = root.SelectSingleNode("games");

            GameList.Clear();
            foreach (XmlNode game in games.ChildNodes)
            {
                Game g = new Game();
                foreach (XmlNode p in game.ChildNodes)
                {
                    if (p.Attributes["name"] != null)
                    {
                        Param pm = g.Params[p.Attributes["name"].Value as String];
                        if (pm != null)
                        {
                            pm.value.value = p.Attributes["value"].Value as String;
                        }
                        else
                        {
                            Console.WriteLine(p.Attributes["name"].Value as String);
                        }
                    }
                }
                XmlNode log = game.SelectSingleNode("log");
                if (log != null)
                {
                    foreach (XmlNode l in log.ChildNodes)
                    {
                        if (l.Attributes["name"] != null)
                        {
                            String key   = l.Attributes["name"].Value as String;
                            String value = "";
                            String desc  = "";
                            if (l.Attributes["value"] != null)
                            {
                                value = l.Attributes["value"].Value as String;
                            }
                            if (l.Attributes["desc"] != null)
                            {
                                desc = l.Attributes["desc"].Value as String;
                            }

                            Param pm = new Param(key, value, desc);
                            g.Logs.Add(key, pm);
                        }
                    }
                }
                g.AppName = g.Params["appName"].value.value;
                if (g.AppName == "")
                {
                    continue;
                }

                g.GameChannel = new GameChannel();
                g.GameChannel.readGameConfig(ProjectConfig.getInstance().getGameList() + g.AppName + "\\config.xml");
                GameList.Add(g);
            }
            xml.Save(xmlfile);
        }
        public void saveGameXML(String xmlfile)
        {
            XmlDocument xml   = new XmlDocument();
            XmlElement  root  = xml.CreateElement("xml");
            XmlElement  games = xml.CreateElement("games");

            xml.AppendChild(root);
            root.AppendChild(games);

            foreach (Game g in GameList)
            {
                XmlElement game = xml.CreateElement("game");
                games.AppendChild(game);
                foreach (KeyValuePair <String, Param> entry in g.Params)
                {
                    if (entry.Value.value.value != "")
                    {
                        XmlElement e = xml.CreateElement("param");
                        e.SetAttribute(entry.Value.name.key, entry.Value.name.value);
                        e.SetAttribute(entry.Value.value.key, entry.Value.value.value);
                        e.SetAttribute(entry.Value.desc.key, entry.Value.desc.value);
                        game.AppendChild(e);
                    }
                }
                if (g.Logs.Count > 0)
                {
                    XmlElement log = xml.CreateElement("log");
                    game.AppendChild(log);
                    foreach (KeyValuePair <String, Param> entry in g.Logs)
                    {
                        if (entry.Value.value.value != "")
                        {
                            XmlElement e = xml.CreateElement("param");
                            e.SetAttribute(entry.Value.name.key, entry.Value.name.value);
                            e.SetAttribute(entry.Value.value.key, entry.Value.value.value);
                            e.SetAttribute(entry.Value.desc.key, entry.Value.desc.value);
                            log.AppendChild(e);
                        }
                    }
                }

                try
                {
                    String dest = g.Params["appName"].value.value;
                    if (g.AppName != dest && dest != "")
                    {
                        String source = g.AppName;
                        g.AppName = dest;
                        Directory.Move(ProjectConfig.getInstance().getGameList() + source, ProjectConfig.getInstance().getGameList() + dest);
                    }
                }
                catch (System.Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }

            XmlDeclaration xmldecl = xml.CreateXmlDeclaration("1.0", "UTF-8", null);

            xml.InsertBefore(xmldecl, root);
            xml.Save(xmlfile);
        }