Sign in to follow this  
jchunn

VB.Net Effect Plugin Template (Indirect UI)

Recommended Posts

I'd like to say a few things. First, I love the resources on this site and the contributions from the community. This is good stuff. Second, thanks for posting the Vb template, it works great. Third, these ideological arguments about Vb vs. C# get old. C# does some things better without question but personally I prefer the additional functions that speed up common tasks I do in Vb. Honestly, when I want to use an unsafe code block, I'll just compile it into a library and include it in the Vb project. Not the cleanest approach, but it works well (for instance, I have a C# Bitmap class that uses Unsafe code that I use in Vb all the time, works very well and I get the best of both worlds... I think the term unsafe though is kind of misleading). Might not be the "preferred" solution, but it works well for me. I use both Vb and C# at work and like them both. I have a passion for BASIC though so I use it when possible while writing hobby projects (started on the C64 with BASIC and haven't looked back). Since I don't have a huge need to write code blocks that utilitize unmanged pointers, I don't run into the issues where I'd choose C# over VB (If I run into a huge performance problem here using Vb, I'll change to C# for the project).

I actually understand both points of view, but some things just come down to preference and weighing whether you can accept the trade offs. Some people value the benefits of one language over another in different ways. I don't think that either are wrong, it's more about opportunity cost and what you value while programming. There is so much polarization with tech issues today that it's overwhelming at times (Vb vs. C#, .Net vs. Java, Java vs. Php, Windows vs. Mac, XP vs. Vista, Linux vs. the world).

But back on topic, thanks for the template, it works great! Thanks to the community for all of the posts here, this is a wonderful site. I was going to put some UniCode art code I wrote into a plugin but I see it's already been done. Hehe. I'll have to think of something else to do.

Share this post


Link to post
Share on other sites

just adding my 1/2 pennies worth here. I really don't care what language you all write plugin in just as long as they work , and quickly with the minimum of errors.

would it be possible that when you write a plugin show in first post the language used VB.Net or C# .. mainly just to satify my curiosity.

I'm still trying to learn from this massive tomb of a book on my desk, about code writing.

ciao

OMA

Share this post


Link to post
Share on other sites

well I beleive there are three types of people in this world.

stupid people that never learn from mistakes theirs or others

intelligent people that learn from their mistakes

and

geniuses that learn from the mistakes of others and don't make the same.

I'm thinking I'm a genius. :lol::lol::lol: :wink:

if I ever figure out this book that is. :lol::lol:

Share this post


Link to post
Share on other sites

Hi everyone, I'm trying to get this template working under VS2008express. Rick Brewster's instructions don't work because the express version Project/Properties/Debug tab lacks the option to start an external program. There is a reply on that thread from someone who claims to have got it working under VS express but it leaves me none the wiser.

I decided to rummage around for a way of getting the Template code running myself, guided largely by blithe ignorance. What I came up with was this :

Unzipped the template in the VB2008\Project Templates folder.

Started the vbproj with VS2008. VS2008 converts it successfully but there are 40+ errors.

Added the folder "C:\Program Files\PaintDotNet\" on the Project/References tab.

This reduces the tally to 1 warning and 1 error. These are as follows:

Warning	1	Load of property 'RootNamespace' failed.  The string for the root namespace must be a valid identifier.
Error	2	'$safeprojectname$' is not a valid name and cannot be used as the root namespace name.

There is no indication of which file is responsible for the error.

Does anyone have a suggestion how I can proceed from here? Or am I barking up the wrong tree altogether?

Regards, Boopz

Share this post


Link to post
Share on other sites
Unzipped the template in the VB2008\Project Templates folder.

Wait, you UNZIPPED it?

I thought that was undesireable? jchunn specifically warned against this in the original post:

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.

I have got the template working under VB2008, but I don't recall getting the problem you have mentioned. Try not unzipping the template and see where this gets you.

Share this post


Link to post
Share on other sites
Unzipped the template in the VB2008\Project Templates folder.

Wait, you UNZIPPED it?

Yes, I thought I could get away with it in the privacy of my own home. And now the universe is going to collapse. Sorry about that. :|

Of course, I had already tried doing it with the ZIP file as specified. I was able look at the code in VS2008 but when I tried to run it I got this message:

"A project with an Output Type of Class Library cannot be started directly. In order to debug this project, add an executable project to this solution which references the library project. Set the executable project as the startup project."

So I tried making a simple Windows Forms project to use as a startup project. Then I tried to add a reference, but as far as I could see VS Express does not offer a way of adding a reference to a ZIP file. Hence my dastardly deed.

I'd appreciation any suggestion about what else to try.

All the best, Boopz

Share this post


Link to post
Share on other sites

That's right, a *.dll is not going to run by itself. In this case we need PDN to load and run it. So we can build it but not run it from the VB IDE.

After you build it, copy the *.dll to /paint.net/effects (you'll find the *.dll located in the project's Bin/Debug folder).

Now when you start PDN, it will find the *.dll and load it into the Effects menu.

Note that you will need to restart PDN after each build to make sure the most recent build loads.

Share this post


Link to post
Share on other sites

Thanks, EER, it's working fine now. Now I can get down to figuring out how the template works. A few things are starting to fall into place.

I have one final observation that may be useful to other Express newbies arriving here for information. I thought I'd be clever and set the template project's Build Output Path to the PdN Effects directory (in the project properties Compile tab). Forget it! It causes all kinds of problems and I wasted more than an hour before I discovered the cause.

It's this: VS express copies all the referenced PaintDotNet dlls (PaintDotNet.Core.dll etc.) into the target directory along with the template dll. It seems that when you run PdN it tries to interpret every dll in the Effects folder as a plugin, freaks out at finding itself digesting its own entrails, and refuses to load any Effect DLLs whatsover. (Thought: is this a bug?)

Once you know it, you can fix it just by deleting the 7 PaintDotNet dlls from the Effects folder after every build. But you might as well just use the default Build Output Path and copy the template dll from the project Obj\Release folder to the Effects folder after each build, as EER recommended.

all the best, Boopz

Share this post


Link to post
Share on other sites

Or you could setup a post-build event to copy the DLL accross.

And the reason PDN interprets the DLLs as effects is probably because that is precisely what PaintDotNet.Effects.dll consists of.

Share this post


Link to post
Share on other sites

I'm not sure that VB 2008 Express allows post-build events. I know C# Express does, but in VB there is no corresponding "Build Events" tab under "Project Properties".

So unless I'm being thick about this, I just copy the *.dll manually after each build. Does anyone have a workaround for this in VB Express? It would be very useful to know...,

Share this post


Link to post
Share on other sites

You can use a program to Close Paint.Net if running, copy the dll to the Effects menu and then restart Paint.Net. I've made a little example below in vb.net on a default Windows Form. No doubt it could be improved in various ways, but it seems to work so far. Here's how to use it:

1. compile the program

2. add the compiled program .exe to Visual Studio under Tools/External Tools...

3. link a key combination to the new External Tool (Tools/Customize/Keyboard...)

Now every time you rebuild your Paint.Net plugin, you just press one key (or combination) to go straight into PdN with your new plugin version loaded for use.

All the best, Boopz

Public Class Form1

    Private BuildFile As String =  '[FILL IN THE PATH/NAME OF THE BUILD OF YOUR PLUGIN DLL]
    Private DestinationFile As String = '[FILL IN THE PATH/NAME OF THE DLL IN YOUR PAINT.NET EFFECTS FOLDER]
 
   Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        'Close Paint.Net if running. I'm sure there must be a more elegant way but it works:
        Dim processes() = System.Diagnostics.Process.GetProcessesByName("PaintDotNet")
        If processes.Count > 0 Then
            processes(0).Kill()
            'Wait a moment to allow the files to be released:
            Threading.Thread.Sleep(50)
        End If

        'Copy the dll file overwriting any previous version:
         My.Computer.FileSystem.CopyFile(BuildFile, DestinationFile, True)
  
        'Start or restart Paint.Net:
        Dim PdNprocess As New System.Diagnostics.Process
        PdNprocess = Process.Start("c:\program files\Paint.Net\PaintDotNet.exe")

        Application.Exit()
    End Sub
End Class
 

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