public MNReferencedStyle CreateCopy() { byte[] data = null; using (MemoryStream ms = new MemoryStream()) { using (BinaryWriter bw = new BinaryWriter(ms)) { RSFileWriter fw = new RSFileWriter(bw); this.Save(fw); } data = ms.GetBuffer(); } using (MemoryStream ms = new MemoryStream(data)) { MNReferencedStyle ns = new MNReferencedStyle(); using (BinaryReader br = new BinaryReader(ms)) { RSFileReader fr = new RSFileReader(br); ns.Load(fr); } ns.Name += " (copy)"; return(ns); } }
public bool Load(RSFileReader br, bool fullRead) { if (!br.ReadHeader(p_FileHeader)) { return(false); } Clear(); byte tag; while ((tag = br.ReadByte()) != 0) { switch (tag) { case 10: string key = br.ReadString(); string value = br.ReadString(); Properties.Add(key, value); if (key.Equals("TotalWork")) { long la; if (long.TryParse(value, out la)) { WorkTime.SetTotalWorkTime(la); } } break; case 100: if (!fullRead) { return(true); } MNReferencedText rt = new MNReferencedText(); rt.Load(br); Texts.Add(rt); break; case 101: if (!fullRead) { return(true); } MNReferencedImage ri = new MNReferencedImage(); ri.Load(br); Images.Add(ri); break; case 102: if (!fullRead) { return(true); } MNReferencedSound rs = new MNReferencedSound(); rs.Load(br); Sounds.Add(rs); break; case 103: if (!fullRead) { return(true); } MNReferencedAudioText ra = new MNReferencedAudioText(); ra.Load(br); AudioTexts.Add(ra); break; case 104: if (!fullRead) { return(true); } MNReferencedStyle rsa = new MNReferencedStyle(); rsa.Load(br); Styles.Add(rsa); break; default: LoadMessage = string.Format("Unknown tag {0} at position {1} in the file.", tag, br.Position); return(false); } } Modified = false; return(true); }