Hannawell Posted January 29, 2010 Share Posted January 29, 2010 Is it possible to obtain the FileStream handle or the file's name from the input stream passed to the FileType plugin? My plugin handles multiple extension types, & I need a quick way to determine the file extension type prior to processing the stream data. I know the input stream is a 'PaintDotNet.SiphonStream'. I believe it contains another Stream which is 'the' FileStream (I can see it in the debugger), however that member is private. Is there a way to get to that data? If not, could an interface be added to the SiphonStream class? (based on some source I'd seen for SiphonStream.cs) thanks, Hannawell Quote Link to comment Share on other sites More sharing options...
Simon Brown Posted January 29, 2010 Share Posted January 29, 2010 If you want to have different code for different extensions, just create a FileType class for each one and add them to your FileTypeFactory. Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted January 29, 2010 Share Posted January 29, 2010 Your code is not allowed to know what underlying Stream is being used. Imagine your code expects a FileStream and casts to that, and accesses those properties. Then imagine I change my implementation to send you a MemoryStream or some other type of serialization stream because I'm embedding your data into something else. Your plugin would crash. Not a smart thing to do. The reason you're given a Stream is because you're supposed to write data to it, nothing else. Like Simon said, just register different extensions instead of using 1 uber FileType implementation. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Hannawell Posted January 29, 2010 Author Share Posted January 29, 2010 Thanks! That helps a great deal. I am also using the plugin to choose one of many images from pack/zip/wad type image collections. To do so, the plugin pops up a dialog box. It would be nice (not critical) if the dialog could display the wad's filename. I understand its not available now, possibly consider a static PaintDotNet.GetActiveFilename()? H Quote Link to comment Share on other sites More sharing options...
Simon Brown Posted January 29, 2010 Share Posted January 29, 2010 Is there anything the user would actually be able to do with that information? Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted January 29, 2010 Share Posted January 29, 2010 I understand its not available now, possibly consider a static PaintDotNet.GetActiveFilename()? What? I just told you that information is, by design, not available to the plugin. Asking for a static method instead of an abusable type cast is completely isomorphic. You're going about things the wrong way. FileTypes are supposed to open whole files, not import slices of them. They are not supposed to show UI, except via the Save Configuration dialog. You should write a tool to dump the contents of a WAD, and then have the user just edit the individual images via normal means, then have a tool to recompile everything into a new WAD. What you're trying to do is effectively treat a file as a directory, and then you're popping up a second "pick a file" dialog. That is absolutely the wrong approach. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Hannawell Posted January 30, 2010 Author Share Posted January 30, 2010 I will soon wrap the plugin+dialog in a standalone tool. It already provides the 'dump wad' contents 'button'. For now, Its simply convenient to have it integrated directly w/ Paint.net. Thanks again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.