Jump to content

Attempting to Rebuild an Old plugin - Solved


Recommended Posts

2 minutes ago, AndrewDavid said:

Buried in Unfinished plugins

 

Can you provide a link, so I don't have to dig it up?

 

Just now, AndrewDavid said:

ILSpy.exe

 

That explains some of your issues. You should use dotPeek instead.

https://www.jetbrains.com/decompiler/

(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

https://forums.getpaint.net/topic/111330-unfinished-plugins/page/6/

 

After building JustifyText I see no problem using ILSpy.exe. I didn't need any assistance for that one. (After finding a message you wrote along time ago). At least that's one app I understand. I'll try your suggestion and see if its any better. I think these plugins were built in codelab. Decompiling them for Visual Studio is the challenge.

 

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

1 hour ago, AndrewDavid said:

I think these plugins were built in codelab. Decompiling them for Visual Studio is the challenge.

 

Sorry, but this makes no sense. CodeLab and Visual Studio compile code the same way.

Fun fact though, neither of these two plugins were made using CodeLab.

(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

14 hours ago, AndrewDavid said:

@Rick Brewster @toe_head2001

JusttifyText.DLL

 

Uploaded another broken plugin to GitHub for determining what is causing the failure of the plugin's menu attempt to save/load files. Definitely need help for this one.

I can't even find the source code for that functionality. I have been able to create the DLL correctly, I have updated it to run on net5.0-windows and hope you can resolve this loss of functionality. There are about six more plugins that fail in the same manner, so I hope when we determine the correct code for this one, it can be applied to the others.

image.png.cb13da145435f33ce333739c79b03989.png

This is the error 

 

That's the same error I got while trying to patch up some of the remaining plugins you mentioned in the "Plugins that fail in 4.3" topic. I'm not sure how to fix this, nor how it worked in the first place. Something in XmlSerializer (part of the framework) may have changed?

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

CircularText.DLL

 

Uploaded another broken plugin to GitHub. This is one that would not load in the new beta version. It loads fine now but still has the menu problem. Different error as well.

It will load but not save. 

 

image.png.2f7db978a2c8be319e17446af2c4c981.png

7 hours ago, Rick Brewster said:

Something in XmlSerializer (part of the framework) may have changed?

That ball is in your court. The headache of updating software. The plugin still works, just lost some of its functionality. 

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

Like I said in the thread for the previous alpha build, I'm not sure there's anything I can do. The plugin(s) will just be at reduced functionality until updates to them are released. @midora is the author of OptionBasedLibrary, he'll need to look into it.

 

If there's something that can be changed in the plugin to make this work, I can probably make a shim for it so that no updates are needed, but I am deferring/delegating to y'all to figure out what changes are needed here.

  • Upvote 1

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

@Rick Brewster

I would like to go back to the list of broken plugins and remove all the lines over plugins that are still not operating at 100%.

When and if you release the next update, users will need to know what no longer works. I can think of 3 categories. 1. Broken - Will not load/crashes Paint.Net.

2. Fixed - Will run but at reduced capability/new version may or may not needs to be downloaded. (Like CircularText)  3. Fixed to full functionality/Download required. (Like Plugin Browser). Red/Yellow\Green markers. Maybe the text if the software will allow, Thoughts?

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

Regarding OptionBasedLibrary.

OBL was still under development when I had to interrupt my support. Some people still continued to use it in their plugins. I guess it makes no sense to get all the old variants of OBL to run. IMHO this is a waste of time. I'm concentrating on the work to finalize a single OBL and get my own plugins to run. In a next step other plugins could be updated (or die 😉

 

By the way would it be possible to increase the width of the settings panel a bit in the save dialog? It's really ultra small if a vertical slider is needed. Or even better would be a splitter between settings and preview. 🙂

 

  • Like 1

midoras signature.gif

Link to comment
Share on other sites

Here I have problem with a simple solution you can find I'm sure.

I decompiled  a small outdated plugin AdvGrey.dll to try and build it in VS2022 Preview Net 5.0 from the beginning.

One error has stumped me in the code.

 

Spoiler

using System.Drawing;
using System.Reflection;

namespace PaintDotNet.Effects
{
    [EffectCategory(EffectCategory.Effect)]
    public class UserScript : Effect
    {
        private int Amount1 = 100;
        private int Amount2 = 100;
        private int Amount3 = 100;
        private EffectConfigDialog threeAmountsConfigDialog;
        private object selection;
        public string Amount1Label { get; private set; }
        public string Amount2Label { get; private set; }
        public string Amount3Label { get; private set; }
        public string Amount4Label { get; private set; }
        public int Amount1Minimum { get; private set; }
        public int Amount1Maximum { get; private set; }
        public int Amount1Default { get; private set; }
        public int Amount2Minimum { get; private set; }
        public int Amount2Maximum { get; private set; }
        public int Amount2Default { get; private set; }
        public int Amount3Minimum { get; private set; }
        public int Amount3Maximum { get; private set; }
        public int Amount3Default { get; private set; }

        public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length)
        {
            for (int i = startIndex; i < startIndex + length; i++)
            {
            }
        }
        [System.Obsolete]
        public UserScript()
#pragma warning disable CA1416 // Validate platform compatibility
            : base("Advanced Greyscale", new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("ico.png")), isConfigurable: true)
#pragma warning restore CA1416 // Validate platform compatibility
        {
        }
        public override EffectConfigDialog CreateConfigDialog()
        {
            {
                Amount1Label = "Red";
                Amount1Minimum = 0;
                Amount1Maximum = 100;
                Amount1Default = 100;
                Amount2Label = "Green";
                Amount2Minimum = 0;
                Amount2Maximum = 100;
                Amount2Default = 100;
                Amount3Label = "Blue";
                Amount3Minimum = 0;
                Amount3Maximum = 100;
                Amount3Default = 100;
                Amount4Label = "Advanced Greyscale";
            };
            return threeAmountsConfigDialog;
        }
        private void Render(Surface dst, Surface src, Rectangle rect)
        {
            Rectangle boundsInt = EnvironmentParameters.GetSelectionAsPdnRegion().GetBoundsInt();
            for (int i = rect.Top; i < rect.Bottom; i++)
            {
                for (int j = rect.Left; j < rect.Right; j++)
                {
                    if (boundsInt.IsVisible(j, i))
                    {
                        ColorBgra colorBgra = src[j, i];
                        byte r = colorBgra.R;
                        byte g = colorBgra.G;
                        byte b = colorBgra.B;
                        byte a = colorBgra.A;
                        float num = (float)Amount1 / 100f;
                        float num2 = (float)Amount2 / 100f;
                        float num3 = (float)Amount3 / 100f;
                        num *= (float)(int)r;
                        num2 *= (float)(int)g;
                        num3 *= (float)(int)b;
                        float num4 = Amount1 + Amount2 + Amount3;
                        num4 /= 300f;
                        float num5 = (int)(byte)((num + num2 + num3) / 3f);
                        num5 /= num4;
                        byte b2 = (byte)num5;
                        colorBgra = (dst[j, i] = ColorBgra.FromBgra(b2, b2, b2, a));
                    }
                }
            }
        }
    }
}

 

The only error I get is for the underlined IsVisible extension method found at line 67
Its such a small plugin, I don't know how it could stump me. The code is contained in the old DLL and works fine in Paint.net. Upgrading it to Net 5.0 showed what has been depreciated and I was able to fix all errors except this one. Could you please help?

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

  • 3 weeks later...

To whom it may concern

I've come a long way since my last post. Found some guides buried in the forum.

 

Visual Studio 3033 has had some issues

image.png.a455dd76542749ac5de746da178c71a2.png

I would think Net 5.0 has some too. Still missing documentation for many issues.

 

I think I have a good working template now.

 

Now when I try to create a Git repository, I have to do it through the command line. It was uploading fine a few weeks ago.

I also don't get the blue icons anymore for my newer repositories. The resource files are not segregated into their own folders.

https://github.com/AndrewDavid007/DrawGrid2021

 

I have built this one totally on Net 5.0

However it is not rendering the grid to the surface.

I'm sure you will find the code messy - but it does work with that exception.

If you have the time and patience have a look and see what is wrong. You are free to update as necessary on Git

Thank you in advance.

I know you guys like puzzles 😊

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

Your override of the Render method doesn't render anything. To create a virtual OnRender method makes only sense if you like to override it (and the loop there executes an empty statement). So add the loop with a call to the second Render method to the first one. Take the surfaces from the RenderArgs. I'm not adding a code snippet now.

midoras signature.gif

Link to comment
Share on other sites

Untested, just looking in the repo. Add to the override Render method

 

// Get the current settings from the token (or do it in OnSetRenderInfo)

Amount1 =

Amount2 =

 

// Render each rectangle

for (int index = startIndex; index < startIndex + length; ++index)

    Render(dstArgs.Surface, srcArgs.Surface, rois[index]);

 

But you should really start  with a more simple project. There is too much overhead in this one.

 

midoras signature.gif

Link to comment
Share on other sites

@midora

 

And here I thought that was a simple one. I just go by the size of the DLL.

 

Remember the original crashed trying to divide by 0?

 

Well I tried your suggestions but I couldn't find a place to put your Amount statements without causing an error.

I placed your other snippet where I think it should go, but that caused a crash. Crashed trying to divide by 0.

Perhaps I didn't put it in the right place. All the code was copied from the original and placed in my Net 5.0 template.

 

Some things I understand but the actual coding is beyond my ability to fathom at this time. I'm hoping to gather experience doing thesr small plugins.

 

I was able to rebuild @xod,s text plugins. But they were working to begin with.  Hope you will try again and test.

 

 

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

  • 1 month later...

@Rick Brewster @toe_head2001

This may sound ridiculous, but I am unable to create a form based project in Visual Studio 2022.

 

When I create the project, without adding references to Paint.Net I can build the form.

 

image.png.99c4fb37aeb3e7e6429334e64b46735d.png

When I add Paint.Net references I receive the failed to launch error.

 

image.png.0402c0725151ec5c0f747a8e2c5cb4c2.png

I've tried adding the references first, but that is of no help.

I've made a Git repository of a working form without references to Paint.Net assemblies.

See for yourself when Paint.Net references are added, You can no longer view the form.

https://github.com/AndrewDavid007/ZoomBlurDeluxe

 

Now that I made a post, it works. 

 

 

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.png

Link to comment
Share on other sites

  • 5 months later...
  • AndrewDavid changed the title to Attempting to Rebuild an Old plugin - Solved
On 11/21/2021 at 2:41 AM, AndrewDavid said:

This may sound ridiculous, but I am unable to create a form based project in Visual Studio 2022

 

How did you resolve the failure of the Form Designer?

Link to comment
Share on other sites

I used Paint.net 4.3.10. 

 

VS2022 17.2.0 preview 5.0 is my current version. There was 2 updates last week. the first update 17.2.0 Preview 4.0 I believe resolved the issue.

 

Rather than building it from scratch, I used a template from a project that was working for me when I started learning VS. I used it to build ColorCount (a smaller form based plugin). I then created another template from the working ColorCount to build ZoomBlurDeluxe. What was interesting was the size of these 2 templates. The first one was 19MB. When I loaded it, I found a lot of unnecessary files like all the dlls from Paint.net. I removed them and when I built the next template, it turned  out just a 55kb file size. Maybe it was practice and determination. I have been called a bulldog before. :)

 

PaintNetSignature.png.6bca4e07f5d738b2436f83d0ce1b876f.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...