public static void SaveToFile(this IAddonInstance addon, string file) { XmlDocument doc = XmlTool.CreateDocument("Addon"); addon.SaveToXml(doc.DocumentElement); doc.Save(file); }
public static void LoadFromFile(this IAddonInstance addon, string file) { XmlDocument doc = new XmlDocument(); doc.Load(file); addon.LoadFromXml(doc.DocumentElement); }
public StaticAddonHolder(AddonSpace adspace, RegisterAttribute attr, Type insttype) : base(adspace) { m_instanceType = insttype; m_attrib = attr; m_instanceModel = (IAddonInstance)m_instanceType.CreateNewInstance(); }
public override IAddonInstance CreateInstance() { WantLoaded(); IAddonInstance res = m_model.CreateInstance(); res.LoadFromXml(m_xml); return(res); }
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; }
public void EditProperties() { IAddonInstance addon = AddonBase.LoadFromFile(m_file.DataDiskPath); if (EditPropertiesForm.Run(addon, true)) { //addon.Original = false; addon.SaveToFile(m_file.DataDiskPath); } }
public AddonEditorFrame(IAddonInstance obj, string filepath) { InitializeComponent(); m_filepath = filepath; m_obj = obj; propertyFrame1.SelectedObject = m_obj; propertyFrame1.SendToBack(); toolStrip1.SendToBack(); }
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); } }
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(); }
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); }
public void AddonEditor() { IAddonInstance addon = AddonBase.LoadFromFile(m_file.DataDiskPath); MainWindow.Instance.OpenContent(new AddonEditorFrame(addon, m_file.DataDiskPath)); }
public RuntimeAddonInstance(IAddonInstance i, Bot bot) { Name = i.Name; Modules = i.Modules; this.bot = bot; }
public NamedAddonInstance(IAddonInstance instance, string name) { Instance = instance; Name = name; }