Jump to content

Attempting to Rebuild an Old plugin


Recommended Posts

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.

 

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

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. 

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

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

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

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

 

 

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

 Share

×
×
  • Create New...