internal static VGTExpCoefficientCollection LoadExpCoefficientFile(string filename) { if (string.IsNullOrEmpty(filename) || !File.Exists(filename)) { return(null); } VGTExpCoefficientCollection expInfos = new VGTExpCoefficientCollection(); XElement root = XElement.Load(filename); if (root == null) { return(null); } XElement edgesRoot = ReadXElement(root, "EdgesFile"); if (edgesRoot == null) { return(null); } expInfos.EgdesFilename = ReadAttributeValue(edgesRoot, "file"); XElement expRoot = ReadXElement(root, "ExpItems"); if (expRoot == null) { return(null); } expInfos.Exps = ReadVGTExpItem(expRoot, "ExpItem"); return(expInfos); }
public static bool SaveToFile(VGTExpCoefficientCollection expCollection, string filename) { string path = Path.GetDirectoryName(filename); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if (File.Exists(filename)) { File.Delete(filename); } try { _doc = new XmlDocument(); CreateBootXML("ExpInfos"); _bootNode = _doc.DocumentElement; WriteNode(_bootNode, "EdgesFile", expCollection.EgdesFilename); XmlNode expItemsNode = WriteNode(_bootNode, "ExpItems", ""); CreateExpItems(expItemsNode, expCollection); _doc.Save(filename); return(true); } finally { _doc = null; _bootNode = null; } }
private void btEditArgs_Click(object sender, EventArgs e) { VGTExpCoefficientCollection expParas = File.Exists(expFilename) ? ReadExpCofficientFile.LoadExpCoefficientFile(expFilename) : new VGTExpCoefficientCollection(); using (frmExpCoefficientSetting frm = new frmExpCoefficientSetting(expParas, expFilename)) { if (frm.ShowDialog() == DialogResult.OK) { if (_handler != null) { _handler(ReadExpCofficientFile.LoadExpCoefficientFile(expFilename)); } } } }
private static void CreateExpItems(XmlNode pNode, VGTExpCoefficientCollection expCollection) { WriteNode(pNode, "ExpItem", expCollection.Exps); }