Jump to content

Update value from Render() function to dialog.


Recommended Posts

I am writting a new plug in for Paint.Net. I built new plugin like Rotate / Zoom plugin.

I have a problem that I want to display some value after executing from Render() function, but I set value to the properties and I get no changed value.

Example:

I have a variable in MyPluginEffectConfigToken.cs

...

private string resultPop;

public string ResultPop

{

get

{

return resultPop;

}

set

{

this.resultPop = value;

}

}

...

I set value for this variable in the Render() function in the MyPluginEffect.cs

...

public unsafe void Render(EffectConfigToken properties, RenderArgs dstArgs, RenderArgs srcArgs, PdnRegion roi)

{

RetinexEffectConfigToken token = (RetinexEffectConfigToken)properties;

token.ResultPop = "new";

...

}

In the MyPluginEffectConfigDialog.cs, I set value for the variable of token in the InitialInitToken() Function

...

protected override void InitialInitToken()

{

theEffectToken = new RetinexEffectConfigToken();

((MyPluginEffectConfigToken)theEffectToken).ResultPop = "old";

}

...

And, I have try many ways but, in the Dialog, I cannot get value of ((MyPluginEffectConfigToken)theEffectToken).ResultPop is "new" value. It always "old" value.

Please help me to solve this problem.

At the moment, I have a solution that the new value in the Render() function is written to a temp file. After that, in the dialog, the value will be gotten from that file. But, I think it is not good.

Link to comment
Share on other sites

The Effect instance is not capable of communicating back to the EffectConfigDialog via the EffectConfigToken. This was a concious design decision -- every time the token is updated, it is Clone()'d once for each rendering thread (there is always a minimum of 2 threads). This solves a lot of thread safety issues. Also, the config dialog is only meant to be a "front end" to the effect -- the dialog and effect are not supposed to be some tightly coupled pair. The effect, in essence, should be oblivious to the existence of its config dialog. I should be able to execute your effect without using the config dialog (this is required for Effect -> Repeat [effect name] to work).

You should also note that Render() will not be called just once, so you are going to have the problem that you will have 200+ "results" no matter what communication channel you are able to find to use.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

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