public override bool Export(string filename, IPackage package) { ImageResource.ImageResource resource = CreateResource(package) as ImageResource.ImageResource; FileStream fileStream = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.Write); try { BinaryReader stream = new BinaryReader(resource.Stream); stream.BaseStream.Position = 0; new BinaryWriter(fileStream).Write(stream.ReadBytes((int)stream.BaseStream.Length)); return(true); } catch (Exception ex) { MainForm.IssueError(ex, "Export failed."); return(false); } finally { fileStream.Close(); } }
public override bool Import(string filename, IPackage package) { ImageResource.ImageResource resource = CreateResource(package) as ImageResource.ImageResource; FileStream fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read); try { using (BinaryReader stream = new BinaryReader(fileStream)) { resource.Stream.Position = 0; resource.Stream.SetLength(stream.BaseStream.Length); resource.Stream.Write(stream.ReadBytes((int)stream.BaseStream.Length), 0, (int)stream.BaseStream.Length); } package.ReplaceResource(mEntry, resource); return(true); } catch (Exception ex) { MainForm.IssueError(ex, "Import failed."); return(false); } finally { fileStream.Close(); } }
protected override void Set(IResourceIndexEntry entry, IPackage package) { base.Set(entry, package); mResource = ResourceHandlers.CreateResource(entry, package) as ImageResource.ImageResource; }
protected override void Set(IResourceIndexEntry entry, IPackage package) { base.Set(entry, package); mResource = ResourceHandlers.CreateResource(entry, package) as ImageResource.ImageResource; }