public override void Save() { string path = System.IO.Path.ChangeExtension(Name, "xml"); if (DefaultValue.IsDefault(this)) { if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } return; } XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement("sound"); doc.AppendChild(root); XmlElement format = doc.CreateElement("format"); doc.AppendChild(format); if (Frequency != 0) { format.SetAttribute("frequency", Frequency.ToString()); } if (Is16Bit) { format.SetAttribute("sixteenbit", Is16Bit ? "true":"false"); } format.SetAttribute("stereo", IsStereo ? "true" : "false"); if (IsLooping) { XmlElement loop = doc.CreateElement("loop"); doc.AppendChild(loop); loop.SetAttribute("enable", IsLooping ? "true" : "false"); if (LoopStart != 0) { loop.SetAttribute("start", LoopStart.ToString()); } if (LoopEnd != 0) { loop.SetAttribute("end", LoopEnd.ToString()); } } XmlWriterSettings xws = new XmlWriterSettings { OmitXmlDeclaration = true }; using (XmlWriter xw = XmlWriter.Create(path, xws)) doc.Save(xw); }
public override void Save() { string path = System.IO.Path.ChangeExtension(fileName_, "xml"); if (DefaultValue.IsDefault(this)) { if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } return; } XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement("texture"); doc.AppendChild(root); XmlElement addr = writeAddress(doc, "u", UAddress); if (addr != null && !DefaultValue.IsDefault(this, "UAddress")) { root.AppendChild(addr); } addr = writeAddress(doc, "v", VAddress); if (addr != null && !DefaultValue.IsDefault(this, "VAddress")) { root.AppendChild(addr); } addr = writeAddress(doc, "w", WAddress); if (addr != null && !DefaultValue.IsDefault(this, "WAddress")) { root.AppendChild(addr); } if (BorderColor != null && !DefaultValue.IsDefault(this, "BorderColor")) { XmlElement bc = doc.CreateElement("border"); bc.SetAttribute("color", UColor.ColorToString(BorderColor)); root.AppendChild(bc); } XmlElement filt = doc.CreateElement("filter"); filt.SetAttribute("mode", FilteringMode.ToString().ToLower()); if (!DefaultValue.IsDefault(this, "FilteringMode")) { root.AppendChild(filt); } if (Mipmapping && !DefaultValue.IsDefault(this, "Mipmapping")) { XmlElement elem = doc.CreateElement("mipmap"); elem.SetAttribute("enabled", "true"); root.AppendChild(elem); } if (SRGBEnabled && !DefaultValue.IsDefault(this, "SRGBEnabled")) { XmlElement elem = doc.CreateElement("srgb"); elem.SetAttribute("enabled", "true"); root.AppendChild(elem); } XmlWriterSettings xws = new XmlWriterSettings { OmitXmlDeclaration = true, Indent = true }; using (XmlWriter xw = XmlWriter.Create(System.IO.Path.ChangeExtension(Name, "xml"), xws)) doc.Save(xw); }