Sign in to follow this  
jchunn

VB.Net Effect Plugin Template (Indirect UI)

Recommended Posts

This is a template that will allow you to easily create PDN Effect Plugins with Visual Basic. Before you download it, please read ALL of these instructions carefully.

VB_PDN_Effect.zip

Ok, I know you didn't read all the instructions carefully before you downloaded that file, so once you mess around and it doesn't work, read ALL of these instructions carefully before you post any questions.

If you follow these instructions and then you simply create a new project based on this template and compile it without any modifications, you will have a basic working plugin (in the form of a dll) that will work in Paint.Net right out of the box. I highly recommend you modify it before you post your new dll and start bragging about it.

This was created and tested with VB.Net 2005 and Paint.Net 3.22, but should work with newer versions. Report issues here and I'll follow up when I can.

Here is how to install and use the template:

Step 1: DO NOT UNZIP THE FILE. Download the zip file and save it into your templates directory (something like "C:\Documents and Settings\Jesse Chunn\My Documents\Visual Studio 2005\Templates\ProjectTemplates"). DO NOT UNZIP THE FILE... Visual Studio knows how to handle the zipped file. DO NOT UNZIP THE FILE... EVER.

Step 2: Run VB.Net and go to "File->New Project. You should see this new option:

12758_a66de4b397e723143023185c2f7d0e83

If you do not see that option, then you put the file in the wrong place, or you unzipped it, or the file is corrupt, or Venus is in retrograde... so look here and figure out what you did wrong: http://msdn.microsoft.com/msdnmag/issues/06/01/CodeTemplates/

Once you get that to work, go ahead and create a new project based on the template. Now, follow the instructions here: http://paintdotnet.forumer.com/viewtopic.php?f=6&t=4920. Once you have done all that, then all you have to do is run the app from the VB environment Paint.Net will start up with your plugin loaded and ready to test... and you will be on your way to creating some killer effects.

Good Luck!

Jesse Chunn

Share this post


Link to post
Share on other sites

This template is simply brilliant :!:

I flicked the template through VB 2005 express last night and had the default *.dll running in PDN in minutes. Unbelievable :shock:

So if you fancy creating an effect in Visual Basic rather than in the C#/Codelab system you should give this template a try. I highly recommend it!

This template obviously took a fair amount of hard work to put together - many thanks to Jesse for making it available.

Share this post


Link to post
Share on other sites
Ewww! VB.NET! Eww!

Still, if it gets more people writing plugins, I guess I really shouldn't complain.

But... VB.NET...

I hear you :wink: but it's what I have installed. Yes I could d/l VS but I have a rural dial-up connection and the files are huge!

My point was that this template does exactly what it is intended to do and is easy to use - even in a "humble" version of VB.

Share this post


Link to post
Share on other sites
VB.Net can do exactly the same thing as C#.Net can, in the end it's all .Net.

Clearly, you are not a C# programmer. There are several things C# can do that VB.NET cannot. Such as unmanaged code; in VB.NET, your usage of pointers is pretty much limited to window handles and such. In C#, you have full pointer support, and therefore can directly manipulate memory, which is much faster than the equivalent managed code.

Let's put it this way: If Paint.NET had been written in VB.NET, even very simple operations like Invert Colors, Black & White, or even the very basic concept of compositing one layer on top of another would be much, much, much slower.

Share this post


Link to post
Share on other sites

I mean unsafe blocks of code. You know, to use pointers.

like

private unsafe void myUnmanagedFunction()
{
   //I can use pointers in here!
}

Using pointers is not managed by the CLR. Which is why it's considered "unsafe."

  • Upvote 1

Share this post


Link to post
Share on other sites

And there are things you can do in C++ that you can't do in C#, and there are things you can do in Assembler that you can't do with C++, and there are things you can do with machine code that you cant do with Assembler, and there are things you can do with hardware that you can't do with machine code... so I guess "real" programmers do it with hardware.

My point is that if I need to use pointers, I would probably go to C++. C# and VB.Net were created to utilize the .Net framework. I would propose that anyone using unsafe C# code on a regular basis probably should be using C++ anyway, like I do when I need pointers.

For writing managed code, there is no significant difference between any two .Net languages. It is a matter of preference. If I were Rick, I would discourage the use of unsafe code in plugins. It will only serve to introduce instability and crashes, and will rarely make a significant difference in execution speed since the plugin model is multithreaded anyway. I'd love to see an example of a plugin that is "fast enough" using pointers that I can't write without pointers that is also "fast enough". If there is such a plugin, send me the source... I'll take the challenge gladly.

At any rate, I think it is a shame that anyone goes out of their way anymore to bash VB. It is a great language. If some people don't like it, then they should just avoid it. There is nothing you can do in VB that you can't do in C#... so why even waste your energy with VB conversations? I went to a lot of trouble to create this template, and instead of encouragement to use it, I see somebody that has no intention of using it discouraging others, as if somehow the fact that it is VB is a big deal... why would you do that? Why not just leave it alone? Are you saying that VB cannot be used to write really excellent plugins (just as good as any out there today) because you can use unsafe code in C#? That is just silly.

Share this post


Link to post
Share on other sites

I'm not "bashing" your template, and I am only expressing my distaste for VB.NET, and clarifying the misconception that anything done in C# can be done in VB.NET.

My point is that if I need to use pointers, I would probably go to C++. C# and VB.Net were created to utilize the .Net framework. I would propose that anyone using unsafe C# code on a regular basis probably should be using C++ anyway, like I do when I need pointers.
If you need to make extensive use of pointers, C++ is the way to go. But the fact is, C# is easier and faster to write for in almost all situations than C++, especially if there is any sort of GUI involved. When you're writing something as simple as a plugin, but want good performance and don't want to waste half your life writing C++ boilerplate, you simply can't beat C# with pointers.
If I were Rick, I would discourage the use of unsafe code in plugins.

That's just stupid. Pointers give a great performance boost over simply iterating through an array, and not taking advantage of that, if you know how, is rather dull.

will rarely make a significant difference in execution speed since the plugin model is multithreaded anyway. I'd love to see an example of a plugin that is "fast enough" using pointers that I can't write without pointers that is also "fast enough". If there is such a plugin, send me the source... I'll take the challenge gladly.
Obviously, you have not actually timed any array-loop code against its equivalent pointer-based code. It's faster. Period. Not only plugins, but also most of Paint.NET's own built-in effects and adjustments use pointers. Examples? Invert. Black & White. Sepia. Curves would be dreadfully slow without pointers. Pixelate as well. Splatter. Gradient bars. Gradient mapping would be excruciatingly slow without pointers.
At any rate, I think it is a shame that anyone goes out of their way anymore to bash VB. It is a great language. If some people don't like it, then they should just avoid it. There is nothing you can do in VB that you can't do in C#... so why even waste your energy with VB conversations?

I LOVE VB. It is a great language. I don't like VB.NET, but I'm not saying it's a bad language. And no, there is nothing that VB can do that C# can't. But the opposite is not true. C# can do more, and can do it with better performance fi the programmer knows his stuff.

Are you saying that VB cannot be used to write really excellent plugins (just as good as any out there today) because you can use unsafe code in C#? That is just silly.

Where did I ever say that your plugins weren't good? Where did I ever say that the template is not good? I seem to remember writing something along the lines of "if it gets more people writing plugins, I can't complain." You seem to have "overlooked" that little bit, simply so you could start flaming my opinions of the language.

Respect--;

for being unable to accept the fact that VB.NET is not always the perfect little tool for everything, and feeling the need to flame anyone who doesn't like it.

Share this post


Link to post
Share on other sites

Pyro, you have a tendancy to start this kind of thing anytime somebody other than yourself comes up with something useful. You hijack their thread with your negative comments and insults and start a fight, then act like you are so innocent... and eventually you get their thread locked when they try to stick up for themselves.

Ewww! VB.NET! Eww!

Still, if it gets more people writing plugins, I guess I really shouldn't complain.

But... VB.NET...

That is the post that you are defending, and you are trying to say that I am "overlooking" your love for VB. Give me a break. Exactly how is your original post productive? Why don't you please start a new thread to bash vb and leave this thread to the people that might actually want to use this template? There are only two possible outcomes with that kind of post... either everybody ignores it, which makes it totally useless, or somebody responds, in which case you completely hijack the thread. Congrats... you have hijacked the thread.

Share this post


Link to post
Share on other sites
Congrats... you have hijacked the thread.

Everything I have said in this thread so far has been directly related to your template. (Up until this post)

Just because you don't agree with what I say doesn't mean it's hijacking.

Share this post


Link to post
Share on other sites
That is the post that you are defending, and you are trying to say that I am "overlooking" your love for VB. Give me a break. Exactly how is your original post productive? Why don't you please start a new thread to bash vb and leave this thread to the people that might actually want to use this template? There are only two possible outcomes with that kind of post... either everybody ignores it, which makes it totally useless, or somebody responds, in which case you completely hijack the thread. Congrats... you have hijacked the thread.

He is saying that he likes your plugins - but hates VB.NET. And there have been tonnes of useful plugins he hasn't flamed.

Share this post


Link to post
Share on other sites
VB n00b question here - how do you save the project file as a .dll ( I havent use VB in ages :| )

My Documents/Visual Studio 2008/[Your Project Name]/[Your Project Name]/Bin/Release/[Your Project Name].dll

Share this post


Link to post
Share on other sites

Feel like uninstalling VB!!!!!!!

Got this error -

Error 1 The command "copy "C:\Users\James\AppData\Local\Temporary Projects\VB_PDN_Effect1\bin\Release\test.dll" "c:\program files\paint.net\effects\"" exited with code 1. VB_PDN_Effect1

WTF! - lol, i was just seing what the original effect would do (no modifications and it throws me an error!)

Why does it do this? :cry:

Share this post


Link to post
Share on other sites
WTF! - lol, i was just seing what the original effect would do (no modifications and it throws me an error!)

It looks like Pdn was running when it tried to copy the file over. You can't replace a file when the original is in use.

Share this post


Link to post
Share on other sites

The code works. Did you read the entire post (the post with the download link)? Is Paint.Net installed in the default location (c:\program files\paint.net)?

The project is set up with a build action to copy the compiled dll to the "c:\program files\paint.net\effects" folder. If that folder is not there, you will have problems. If the folder is there, and Paint.Net is running, you will also have problems since (as Pyro pointed out) the dll will be in use by Paint.Net and therefore cannot be replaced. If you follow ALL of the instructions, then when you run your application, it will automatically copy the dll to the folder and then run Paint.Net for you, with your plugin in the menu.

If you did not install Paint.Net to the default location, then you either need to remove the build action (and manually copy the dll to the effects folder when you want to test it), or modify it to point to the correct folder based on where you installed Paint.Net.

Share this post


Link to post
Share on other sites

To be honest, I don't think I will bother with VB (or any other Programing language for that matter :|) as PDN is in defualt location and everything is as it is...

Share this post


Link to post
Share on other sites

In step 1, the path could be generalized to %userprofile%\My Documents\Visual Studio 2005\Templates

I'm fairly certain there's a way to get the "My Documents" part too but I can't remember it right now.

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