Sign in to follow this  
Sepcot

Visual Studio 2005 - Effect Plugin Template

Recommended Posts

Note: this is not a Paint.NET effect. This is a Visual Studio 2005 template that can be used to create further Paint.NET effects.

This template is here to help speed the development process of creating Paint.NET effect plugins. It contains the C# code skeleton necessary to build your own effect.

Effects Plugin Template - Save this zip file into your Visual Studio 2005 "Project Templates" directory (typically: My Documents\Visual Studio 2005\Templates\ProjectTemplates\). Do NOT unzip the file, just drop it into the ProjectTemplates directory.

You can go here: http://www.sepcot.com/blog/2006/11/PDN-EffectPluginTemplate for a brief walkthrough of the code contained within the template.

Note: the code contained in the template can be built as is, but it won't yeild you any interesting effects. In fact, it will just render a configuration dialog box with "OK" and "Cancel" buttons that do nothing to alter the canvas.

I think this should go here rather than the Tutorial forum because of this is specifically related to creating plugins for Paint.NET rather than using Paint.NET to achieve some effect.

Share this post


Link to post
Share on other sites
You can go here: http://www.sepcot.com/blog/2006/11-2006-PDN-EffectPluginTemplate.shtml for a brief walkthrough of the code contained within the template.

Talk about "brief" ;)

OK, I've used this to build a couple of effects now so I thought I'd give the list of steps I use when creating an effect.

Before I begin, I use CodeLab to perfect the effect. Believe me, that is sooo much easier than compiling each time you want to try something.

Once I have a working CodeLab script and an idea of what kind of controls I want in the user interface (UI), I follow this list (I'm going to be brief since I figure that if you've read this far, you already know what you're doing):

  1. Create the project using EffectsPlugin template under C# - name the project what the dll should be called.
  2. When the project opens, fix the project references - point them to the current install of Paint.NET
  3. Edit EffectPlugin.cs and change the menu display name.
  4. Use Paint.NET to create a 16x16 PNG icon - save and overwrite the existing icon file.
  5. Build the project - this will create the UI design view
  6. Open EffectsConfigDialog.cs (Design view)
  7. Add any controls needed for the UI
  8. Double-click on a new control and add "FinishtokenUpdate();" to the function. Repeat this for all new controls.
  9. Open EffectPluginToken.cs and add any desired variables--one for each UI element. Be sure to make them public.
  10. Set their default values in the constructor (base).
  11. Edit copyMe and add "this.variable = copyMe.variable;" for each of the variables.
  12. Open EffectPluginConfigDialog.cs (code view) and update function InitTokenFromDialog to save the UI information to the token variables.
  13. Then, update function InitDialogFromToken to initialize the UI with information from the token variables.
  14. Edit EffectPlugin.cs and port over the render function from the CodeLab script.
  15. Build, install, and test the new DLL - the new DLL is located in the project's Bin/Debug folder. Be sure to compile for release before posting the final DLL file to the web.

Sepcot, I would recommend the following changes to your template:

  1. Add the code from my project listed above to your template for adding the effect to a submenu. There is some code and the reference to it.
  2. The OK and Cancel buttons should be anchored bottom & right instead of top & left.
  3. Add a "// place your public variables here" and "// set your default values here" to the token file.
  4. Add a few "using" lines to open up access to various controls (like I did in the project linked above.)

Nice template, by the way! Thanks!

Share this post


Link to post
Share on other sites
Sepcot, I would recommend the following changes to your template:

  1. [*:58569]Add the code from my project listed above to your template for adding the effect to a submenu. There is some code and the reference to it.
    [*:58569]The OK and Cancel buttons should be anchored bottom & right instead of top & left.
    [*:58569]Add a "// place your public variables here" and "// set your default values here" to the token file.
    [*:58569]Add a few "using" lines to open up access to various controls (like I did in the project linked above.)

Nice template, by the way! Thanks!

Updated! Effects Plugin Template

All of BoltBait's points above have been addressed.

  • [*:58569]Added SubMenu Option.
    [*:58569]Buttons anchored.
    [*:58569]Token file updated. Added getter/setter example.
    [*:58569]Added reference to PaintDotNet in Configuration Dialog

Share this post


Link to post
Share on other sites

You'll need to update your plugin for Paint.NET 3.05.

Change all references of PdnLib.dll to PaintDotNet.Core.dll

BTW, I would also add references to PaintDotNet.Data.dll so that you can have access to the blending ops.

Share this post


Link to post
Share on other sites

I am assuming that this will work with the VS2005 express addition (which supposedly is free?)

I will have to download and try, but thanks for this. has anyone considered doing a template for wxdev c++?

Thanks

Sage

Share this post


Link to post
Share on other sites
I am assuming that this will work with the VS2005 express addition (which supposedly is free?)

MadJik can confirm that it does work with the free version.

And, why would you want to program in C++ when C# is soooo much better? Seriously.

Share this post


Link to post
Share on other sites

Yes I do!

I don't remember having problem with the template. I've always used VS 2005 express.

Problem isn't the template, it's the code we expect to make a plugin with! ;)

BTW, find a source from one of my plugin, you could use it at a template...

BTW2, each plugin is so particular that it can't fit any template ;)

Share this post


Link to post
Share on other sites

BoltBait,

actually, cause C++ is what I know (somewhat)...

Actually, my druthers would be Visual Basic 6, since I happen to have enterprise edition of it, and I am sort of kind of ok with programming in it.

C# Better? Says YOU. And, not that I don't trust you, however, so many people have so many different opinions on which language to use that I ended up deciding to learn C++ based on the fact that printed (book) literature on C++ dealing with the subjects that I am most interested in far out number that of C# books of the same topics. Namely game programming, and 3d game engine, rendering and shaders.

One of these days, I might learn C#, but for now, I need to stick with what I started with, otherwise, I won't learn as much.

Thanks for the help

Sage

Share this post


Link to post
Share on other sites

Just a few points to consider here:

BoltBait,

actually, cause C++ is what I know (somewhat)...

Actually, my druthers would be Visual Basic 6, since I happen to have enterprise edition of it, and I am sort of kind of ok with programming in it.

And it's certainly fine that you like C++., don't let that keep you away from Visual Studio 2005. The Express Editions (C++ is one of those, by the way) are free to download and use, and while they don't come with all of the features of VS 2005 Enterprise Edition, they have at least as much going for them as VS6 (speaking as someone who has and uses both).

C# Better? Says YOU. And, not that I don't trust you, however, so many people have so many different opinions on which language to use that I ended up deciding to learn C++ based on the fact that printed (book) literature on C++ dealing with the subjects that I am most interested in far out number that of C# books of the same topics. Namely game programming, and 3d game engine, rendering and shaders.

Well, says modern Windows Programming. Granted, you can develop in-house low-level code for shaders, etc with C++ and VB6, but most of the Windows machines you're targeting these days are going to be running Windows XP or Vista, and that means the .NET Framework is likely installed and available.

If you're favorite thing to do is to write low-level graphics code and try to best the OS vendor's implementation of a certain routine, then I suppose making use of the framework isn't for you, but if you just want to build something useful relatively quickly, you might want to build a few small apps that make use of it.

One of these days, I might learn C#, but for now, I need to stick with what I started with, otherwise, I won't learn as much.

Thanks for the help

Sage

For Paint.NET, the most accessible way to write a plugin is by using VS 2005 (or codelab, if it's not a complicated UI or effect), and accessing the exposed interfaces for plugins that Rick has provided. You can do that in whatever .NET language you like.

I'd say that learning a second (or third, or fourth) programming language typically teaches you more, since you get to see how easily certain programming problems are solved with the various languages. VB used to be my programming language of choice because I made a lot of classic ASP web pages. Perl came in to the picture because of the fact that I hate to do something over and over again if I can automate it. Java I learned because of necessity, since I wanted to create code that ran equally well (or badly, I'm not that good at Java yet) on a variety of platforms with minimal work. C grew out of getting familiar with various *NIX shells. C# is new to me, but it has it's advantages.

I'd just hate to see you say you're going to wait to learn it because you won't learn as much...it ain't necessarily so.

Share this post


Link to post
Share on other sites

drakaan,

you are an amazing individual to take the time to sit and give that explination. I suspect most would have just wrote "dumb @$$" and left it at that.

And Bolbait is probably sitting there thinking "Sage is such an ignoramous"... LOL..

And seriously, my "says YOU" wasn't really an attack, but you can imagine, when I first started out, and explained that I was trying to learn programming, everyone gave an opinion and everyone's different based on what they know best. One could get frustrated, and frustrated I got.

Finally I went to Barnes and Nobles, and just browsed the section. on programming.

Found a book on C, beginners guide, which only explained how to write programs in dos. Not what I was looking for at all, but, I got the basics. Would have been nice if the book had something on the back that said "this doesn't show you gui implimentation".

Back at the store. Found one on C#, again, same deal, no GUI... pretty much the same programs built as well "hello world" and "simple calculator"...

Finally, after several books on C, C# and C++ and even a couple on Visual basic, I found a book "3d game engine programming"... All in C++ even though it didn't tell you that up front...

I'm getting fairly decent with C++, but yeah, maybe I need to take another look at my C# books, and get online and check it out.

I just totally got frustrated at the miriads of opinions out there and decided on just going with what was readily available with my interest.

And now, I just made a long post, about my own ignorance, LOL... But, thanks for all the help... I'll dl 2005 express and try messing with this plugin template.

Thanks

Sage

Share this post


Link to post
Share on other sites

My advice would be to find a project that you're interested in, and then let your choice of language fall from that. For instance, if you're interested in, I dunno, writing a clone of Picasa, then it probably makes sense to choose from C++ or C#. If you want to write an online baseball card tracker, then maybe Python or PHP along with some form of SQL is a much better choice. As long as you have strong interest in the project, then the motivation will follow from there and feed into doing whatever it takes to get the job done.

For the record, I've found that UI work in C/C++ is extraordinarily painful.

Share this post


Link to post
Share on other sites
Can somebody compile a package that works in Visual Studio .Net 2003?

I haven't got around to upgrade my 4-year-old program yet.

Right now I can only use codelab...

You can always use the free Visual Studio 2005 Express Editions (or their 2008 Beta 2 counterparts), though debugging will be a pain, or you can go download the Visual Studio 2008 Beta 2. You can also try SharpDevelop, though I'm not sure how that'll work out for ya. Don't know what its debuggin tools are like and whatnot.

***If you use a beta, be sure to select .NET Framework v. 3.0 or older, as 3.5 is still changing, and building a published program on a beta platform is just plain dumb.***

Share this post


Link to post
Share on other sites
You'll need to update your plugin for Paint.NET 3.05.

Change all references of PdnLib.dll to PaintDotNet.Core.dll

BTW, I would also add references to PaintDotNet.Data.dll so that you can have access to the blending ops.

Guys, am I missing something or in spite of both this alert and an update note at Sepcot's page ("Updated: April 23, 2007 - Changed references of PdnLib to PaintDotNet.Core in compliance with Paint.NET Version 3.05 and above."), the downloadable template is not the (supposedly) updated one, but the one from 2007-03-06 (first update) that still references PdnLib and stuff?? :?: :?

Share this post


Link to post
Share on other sites
You'll need to update your plugin for Paint.NET 3.05.

Change all references of PdnLib.dll to PaintDotNet.Core.dll

BTW, I would also add references to PaintDotNet.Data.dll so that you can have access to the blending ops.

Guys, am I missing something or in spite of both this alert and an update note at Sepcot's page ("Updated: April 23, 2007 - Changed references of PdnLib to PaintDotNet.Core in compliance with Paint.NET Version 3.05 and above."), the downloadable template is not the (supposedly) updated one, but the one from 2007-03-06 (first update) that still references PdnLib and stuff?? :?: :?

Yeah, I just changed that myself in the template. It's takes a minute :)

So, it works in the BETA of VS 2008, good......I'll check when it's released as a full version.

Share this post


Link to post
Share on other sites
Yeah, I just changed that myself in the template. It's takes a minute :)

So did I... :)

It'd be a good thing either writing a warning about it at this first thread's post or - even better! ;) - supplying an alternate download link to a revised version of this template (if the author doesn't complain). It's a very handy time saver!

Share this post


Link to post
Share on other sites
If anybody is interested in writing plugin's in vb.net, I have converted the template to vb.net and it works.

Then why not post it?

Edit: And I think that Sepcot should change the thread title to note that this template is for C#.

Edit #2: Is there any chance this can be updated to work with the new plugin system introduced in 3.0.

Share this post


Link to post
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.

Sign in to follow this