Jump to content

How to Write an Effect Plugin (Part 6 - Adding Help)


BoltBait

Recommended Posts

I haven't time to add help to existing plugins (many of my larger project already have some sort of help built in).

New plugins will definitely have help added ;)

Link to comment
Share on other sites

I successfully added a Help menu to Texture Shader, and will update the published plugin as soon as I decide there are no further changes I want to make to Help.

 

I found a useful trick. If you paste formatted text into this edit window, then click the little Show BB Code switch, it will display the control codes for the the formatted text. That's quite handy for me, since I've usually included a proto-Help menu in the description of the plugins.
 
 

Link to comment
Share on other sites

  • 2 months later...

I have a question, which is mostly just out of curiosity, though it may be helpful to know for something I'm working on. I notice the CodeLab Help menu code includes:

 protected override void OnCustomizeConfigUIWindowProperties(PropertyCollection props)
{
     // Change the effect's window title
     props[ControlInfoPropertyNames.WindowTitle].Value = "HSV Eraser";
     // Add help button to effect UI
     props[ControlInfoPropertyNames.WindowHelpContentType].Value = WindowHelpContentType.CustomViaCallback;
     props[ControlInfoPropertyNames.WindowHelpContent].Value = Properties.Resources.Help;
     base.OnCustomizeConfigUIWindowProperties(props);
}

Is assigning the title necessary, and if so, can it be changed to:
 

props[ControlInfoPropertyNames.WindowTitle].Value = StaticName;

 

 

 

As an experiment, I tried removing the line in a CodeLab-based VS project, and for that specific case, the title still seemed to be correct in both the main menu and the Help menu.

Edited by MJW
Link to comment
Share on other sites

These lines are there to set the effect window's title:

     // Change the effect's window title
     props[ControlInfoPropertyNames.WindowTitle].Value = "HSV Eraser";
Usually, they are only included if you specify:

// Title: HSV Eraser
in your script.

If you leave that line out, paint.net generates a title for your window automatically.

Link to comment
Share on other sites

I think maybe I'm confused. I thought the window's title was determined by the StaticName property, which is defined whether or not the plugin has the Help feature. Plugins that don't have Help don't get the additional OnCustomizeConfigUIWindowProperties call added, but their windows have the correct titles.

Link to comment
Share on other sites

Another question: I believe I know how the Help menu is enabled in IndirectUI plugins, but I was wondering if it could also be enabled in non-IndirectUI plugins, and if so, how.

 

The statements in IndirectUI are:

protected override void OnCustomizeConfigUIWindowProperties(PropertyCollection props)
{
    props[ControlInfoPropertyNames.WindowTitle].Value = "HSV Eraser";
    props[ControlInfoPropertyNames.WindowHelpContentType].Value = WindowHelpContentType.CustomViaCallback;
    props[ControlInfoPropertyNames.WindowHelpContent].Value = helpText;
    base.OnCustomizeConfigUIWindowProperties(props);
}

I don't really understand what the ControlInfoPropertyNames stuff does, but I know it's defined as part of IndirectUI, so I'm not sure what the equivalent thing is for non-IndirectUI plugins.

 

EDIT: On second thought, I don't think this even makes sense to ask, since the a non-IndirectUI plugin can enable the little question mark, and can display a Help Menu the same way it can display any other dialog. Since I've yet to write a non-IndirectUI plugin, I tent to forget such things.

Edited by MJW
Link to comment
Share on other sites

I think maybe I'm confused. I thought the window's title was determined by the StaticName property,

 

I'm pretty sure StaticName refers to the plugin name in paint.net's menu system. For a dialog title you might put "PornoErotica plugin - by EER © 2015", however the menu title would just be more concise like "PornoErotica". Having two entries allows a more verbose dialog title = more information.

  • Upvote 2
Link to comment
Share on other sites

I'm pretty sure StaticName refers to the plugin name in paint.net's menu system. For a dialog title you might put "PornoErotica plugin - by EER © 2015", however the menu title would just be more concise like "PornoErotica". Having two entries allows a more verbose dialog title = more information.

 

Interesting choice of plugin name, I thought this was supposed to be a family friendly forum.  :P

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

Thank you very much, Ego Eram Reputo. That's exactly what it is. I guess the reason I haven't seen the OnCustomizeConfigUIWindowProperties routine before in compiled CodeLab source is that in the past, before the blank header comments were automatically added in CodeLab, I just specified the Name and let it be inherited as the Title. In that case, prior to the Help menu stuff, no code for OnCustomizeConfigUIWindowProperties was generated. Eliminating the assignment didn't change the results for me, since the Title matched the Name in my plugin.

 

The real question I had was whether that assignment was somehow tied into the Help menu or was something unrelated.

Edited by MJW
Link to comment
Share on other sites

Interesting choice of plugin name, I thought this was supposed to be a family friendly forum.  :P

:mrviolet:

I used that name in the unpublished guide. I was merely being......consistent.

  • Upvote 1
Link to comment
Share on other sites

No one forgets that plugin name :D

Another question: I believe I know how the Help menu is enabled in IndirectUI plugins, but I was wondering if it could also be enabled in non-IndirectUI plugins, and if so, how.

 

....

...a non-IndirectUI plugin can enable the little question mark, and can display a Help Menu the same way it can display any other dialog. Since I've yet to write a non-IndirectUI plugin, I tent to forget such things.

Help button is given as an example in the guide. Create the button, tie its click event to messagebox.show and you have a very easy help dialog.

Link to comment
Share on other sites

Adding the little question-mark Help button at the top of the window's frame is done a bit differently than adding a standard button. Something like:

form.HelpButton = true;
form.HelpButtonClicked += new System.ComponentModel.CancelEventHandler(HelpButtonClicked);

The event handler is standard, except it must cancel the Help event.

public void HelpButtonClicked(Object sender, System.ComponentModel.CancelEventArgs e)
{
     e.Cancel = true;
     System.Windows.Forms.MessageBox.Show("This is the help text");
}
Edited by MJW
  • Upvote 1
Link to comment
Share on other sites

Much more elegant! I might add that to the guide. Thanks for the tip.

Link to comment
Share on other sites

  • 1 year later...

OK, I can activate the help button in PropertyBased plugins

 

protected override void OnCustomizeConfigUIWindowProperties(PropertyCollection props)
{
    props[ControlInfoPropertyNames.WindowHelpContentType].Value = WindowHelpContentType.CustomViaCallback;
    base.OnCustomizeConfigUIWindowProperties(props);
}

 

and provide the method

 

private void OnWindowHelpButtonClicked(IWin32Window owner, string helpContent)
{
}

 

this works, but how?

 

The method is private and doesn't use override. Is it handled via Reflection?

 

midoras signature.gif

Link to comment
Share on other sites

4 hours ago, midora said:

this works, but how?

 

The method is private and doesn't use override. Is it handled via Reflection?

 

Correct, the method is invoked via Reflection.

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

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