Jump to content

Accessing the destination canvas from an effect dialog


Recommended Posts

How do I access the destination canvas to render an image to from the effect configuration dialog box?
You don't
Or how do I access the dialog box from SetRenderInfo?
SetRenderInfo gives you the token, no? So just set the token via the dialog, then get the data you need from setrenderinfo.

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

I have another problem. Render() only seems to be called when the dialog first shows.

Unless I am misunderstanding what you are saying, Render is called when the dialog shows, and anytime a setting is changed, and anytime the "ok" button is clicked.

Total hack.

Link to comment
Share on other sites

I have another problem. Render() only seems to be called when the dialog first shows.

Unless I am misunderstanding what you are saying, Render is called when the dialog shows, and anytime a setting is changed, and anytime the "ok" button is clicked.

But how do I get it to re-render. I am not using DirectUI by the way.

KaHuc.png
Link to comment
Share on other sites

In the dialog you need to override InitTokenFromDialog.

In that, you need to create a casted reference to theEffectToken, and set your variables in that.

protected override void InitTokenFromDialog()
{
YourCustomToken token = theEffectToken as YourCustomToken;
token.val1 = slider1.Value;
token.val2 = checkbox1.Checked;
//etc...
}

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

In the dialog you need to override InitTokenFromDialog.

In that, you need to create a casted reference to theEffectToken, and set your variables in that.

protected override void InitTokenFromDialog()
{
YourCustomToken token = theEffectToken as YourCustomToken;
token.val1 = slider1.Value;
token.val2 = checkbox1.Checked;
//etc...
}

I have added that and the parameters object is still null and I have checked the status of that in the override and it is not null.

KaHuc.png
Link to comment
Share on other sites

What are you trying to do? Why do you need to force a re-render when the user clicks OK? The rendering workflow is automatically handled by the effect hosting system. If the token doesn't change as a result of clicking OK, then there's really no reason to do any re-rendering.

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

I can't get this to work so I have given up on trying to do it that way.

Instead of giving up, you should look at other people's source code. Also, the C# template available has all the grunt-work done for you. All you have to do is update the references (PdnLib.dll was renamed to PaintDotNet.Core.dll), and start stuffing your own code in there.

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

All of MadJik's plugins are source-available.

Most of them use IndirectUI, but I believe LightRays still uses the traditional method. As well as my own Splatter, which will also provide insight as to a more correct way to implement a brush-based renderer.

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

All of MadJik's plugins are source-available.

Most of them use IndirectUI, but I believe LightRays still uses the traditional method. As well as my own Splatter, which will also provide insight as to a more correct way to implement a brush-based renderer.

Thank for your help.

KaHuc.png
Link to comment
Share on other sites

it will be called whenever FinishTokenUpdate is.

One thing I forgot to tell you earlier is that you have to override InitialInitToken.

protected override void InitialInitToken()

{

theEffectToken = new WhateverConfigToken();

}

xZYt6wl.png

ambigram signature by Kemaru

[i write plugins and stuff]

If you like a post, upvote it!

Link to comment
Share on other sites

it will be called whenever FinishTokenUpdate is.

One thing I forgot to tell you earlier is that you have to override InitialInitToken.

protected override void InitialInitToken()

{

theEffectToken = new WhateverConfigToken();

}

I did that after following your advice and looking at the splatter source.

-----

I have realised it is being called when I do that, but the code I am using to set the canvas to the image of the dialog isn't working:

CustomBrushesConfigToken cbct = (CustomBrushesConfigToken)parameters;

dstArgs.Surface.CopySurface(Surface.CopyFromBitmap(cbct.TheImage));

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