Ejemplo n.º 1
0
 private void InitBotModules()
 {
     try
     {
         var saved = XmlUtil.LoadXML(Application.StartupPath + "/bot_modules.save");
         if (saved != null)
         {
             var cfg = XmlUtil.XmlToObject <BotModulesConfig>(saved);
             foreach (var me in cfg.Modules)
             {
                 var mt = ReflectionUtil.GetType(me.Key);
                 if (mt != null)
                 {
                     BotModule.SetModuleEnable(mt, me.Value);
                 }
             }
         }
     }
     catch (Exception err)
     {
         MessageBox.Show(err.Message);
     }
     foreach (var mt in BotFactory.Instance.GetModuleTypes())
     {
         var enable = BotModule.GetModuleEnable(mt);
         var item   = new ToolStripMenuItem();
         item.CheckOnClick    = true;
         item.Size            = new System.Drawing.Size(152, 22);
         item.Text            = "模块:" + mt.Name;
         item.Tag             = mt;
         item.Checked         = enable;
         item.CheckedChanged += moduleItem_CheckedChanged;
         group_Module.DropDownItems.Add(item);
     }
 }
Ejemplo n.º 2
0
        private void SaveBotModules()
        {
            BotModulesConfig cfg = new BotModulesConfig();

            foreach (var mt in BotFactory.Instance.GetModuleTypes())
            {
                cfg.Modules.Add(mt.FullName, BotModule.GetModuleEnable(mt));
            }
            var save = XmlUtil.ObjectToXml(cfg);

            XmlUtil.SaveXML(Application.StartupPath + "/bot_modules.save", save);
        }