midora Posted April 5, 2013 Share Posted April 5, 2013 Is there a property or a method to get this filename from Paint.NET? Would like to use it to store options and default values for OptionBased effect and filetype plugins as xml files. Thanks Quote Link to comment Share on other sites More sharing options...
null54 Posted April 5, 2013 Share Posted April 5, 2013 You can call Services.GetService<PaintDotNet.AppModel.IAppInfoService>().UserDataDirectory for effect plugins, this does not exist for FileType plugins unfortunately. Quote Plugin Pack | PSFilterPdn | Content Aware Fill | G'MIC | Paint Shop Pro Filetype | RAW Filetype | WebP Filetype The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait Link to comment Share on other sites More sharing options...
midora Posted April 6, 2013 Author Share Posted April 6, 2013 Could you provide a code sippet because configFolder = Services.GetService<PaintDotNet.AppModel.IAppInfoService>().UserDataDirectory; just throws the exception: Object reference not set to an instance of an object. So some object is needed first. Worst case I have to go back to string mydocuments = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); configFolder = Path.Combine(mydocuments, "Paint.NET User Files"); Quote Link to comment Share on other sites More sharing options...
null54 Posted April 6, 2013 Share Posted April 6, 2013 protected override void OnSetRenderInfo(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs) { string userDataPath = this.Services.GetService<PaintDotNet.AppModel.IAppInfoService>().UserDataDirectory; if (!Directory.Exists(userDataPath)) { Directory.CreateDirectory(userDataPath); } } Any instance method in the Effect class should have access to the Services property. Worst case I have to go back to string mydocuments = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); configFolder = Path.Combine(mydocuments, "Paint.NET User Files"); Which only works for English language versions of Paint.NET. Quote Plugin Pack | PSFilterPdn | Content Aware Fill | G'MIC | Paint Shop Pro Filetype | RAW Filetype | WebP Filetype The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait Link to comment Share on other sites More sharing options...
midora Posted April 6, 2013 Author Share Posted April 6, 2013 Any instance method in the Effect class should have access to the Services property. Ok, it works for me in OnSetRenderInfo but not in CreateInitialToken. Seems the Services object in Effects is not ready at this time. I like to use the path in CreateInitialToken to allow 'user default values' for the effect. Which only works for English language versions of Paint.NET. For sure I do not like a static solution, but if the path is not accessible... 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.