Jump to content

'Paint.NET User Files' filename


Recommended Posts

You can call Services.GetService<PaintDotNet.AppModel.IAppInfoService>().UserDataDirectory for effect plugins, this does not exist for FileType plugins unfortunately.

PdnSig.png

Plugin Pack | PSFilterPdn | Content Aware Fill | G'MICPaint 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

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");
 

midoras signature.gif

Link to comment
Share on other sites

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.

PdnSig.png

Plugin Pack | PSFilterPdn | Content Aware Fill | G'MICPaint 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

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...

midoras signature.gif

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...