Пример #1
0
        public static void SaveToFile(this IAddonInstance addon, string file)
        {
            XmlDocument doc = XmlTool.CreateDocument("Addon");

            addon.SaveToXml(doc.DocumentElement);
            doc.Save(file);
        }
Пример #2
0
        public static void LoadFromFile(this IAddonInstance addon, string file)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(file);
            addon.LoadFromXml(doc.DocumentElement);
        }
Пример #3
0
 public StaticAddonHolder(AddonSpace adspace, RegisterAttribute attr, Type insttype)
     : base(adspace)
 {
     m_instanceType  = insttype;
     m_attrib        = attr;
     m_instanceModel = (IAddonInstance)m_instanceType.CreateNewInstance();
 }
Пример #4
0
        public override IAddonInstance CreateInstance()
        {
            WantLoaded();
            IAddonInstance res = m_model.CreateInstance();

            res.LoadFromXml(m_xml);
            return(res);
        }
Пример #5
0
 public PredefinedAddonHolder(AddonSpace adspace, string name, string title, Func <IAddonInstance> createInstance)
     : base(adspace)
 {
     m_createInstance = createInstance;
     m_instanceModel  = createInstance();
     m_name           = name;
     m_title          = title;
 }
Пример #6
0
        public void EditProperties()
        {
            IAddonInstance addon = AddonBase.LoadFromFile(m_file.DataDiskPath);

            if (EditPropertiesForm.Run(addon, true))
            {
                //addon.Original = false;
                addon.SaveToFile(m_file.DataDiskPath);
            }
        }
Пример #7
0
        public AddonEditorFrame(IAddonInstance obj, string filepath)
        {
            InitializeComponent();

            m_filepath = filepath;
            m_obj      = obj;

            propertyFrame1.SelectedObject = m_obj;

            propertyFrame1.SendToBack();
            toolStrip1.SendToBack();
        }
Пример #8
0
 private void WantLoaded()
 {
     if (m_xml == null)
     {
         XmlDocument doc = new XmlDocument();
         doc.Load(m_file);
         m_xml           = doc.DocumentElement;
         m_model         = AddonType.StaticSpace.FindHolder(m_xml.GetAttribute("type"));
         m_instanceModel = m_model.CreateInstance();
         m_instanceModel.LoadFromXml(m_xml);
     }
 }
Пример #9
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            var sel = cbxType.SelectedItem as AddonHolder;

            if (sel == null)
            {
                StdDialog.ShowError("s_please_choose_type");
                return;
            }
            if (tbxNewName.Text.IsEmpty())
            {
                StdDialog.ShowError("s_please_fill_name");
                return;
            }
            DialogResult = DialogResult.OK;
            m_addon      = sel.CreateInstance();
            Close();
        }
Пример #10
0
        public string SaveCommonTemplate(IAddonInstance addon, string defname)
        {
            string name = InputBox.Run(Texts.Get("s_select_template_name"), defname ?? "tpl1");

            if (name != null)
            {
                WantCommonFolder();
                string fn = Path.Combine(CommonSpace.Folder, name + FileExtension);
                if (File.Exists(fn))
                {
                    if (!StdDialog.ReallyOverwriteFile(fn))
                    {
                        return(null);
                    }
                }
                addon.SaveToFile(fn);
                CommonSpace.ClearCache();
                return(name + ".");
            }
            return(null);
        }
Пример #11
0
        public void AddonEditor()
        {
            IAddonInstance addon = AddonBase.LoadFromFile(m_file.DataDiskPath);

            MainWindow.Instance.OpenContent(new AddonEditorFrame(addon, m_file.DataDiskPath));
        }
Пример #12
0
 public RuntimeAddonInstance(IAddonInstance i, Bot bot)
 {
     Name     = i.Name;
     Modules  = i.Modules;
     this.bot = bot;
 }
Пример #13
0
 public NamedAddonInstance(IAddonInstance instance, string name)
 {
     Instance = instance;
     Name     = name;
 }