Rick Brewster

CodeLab v4.3 (for advanced users) Released July 13, 2019

Recommended Posts

Where do you see this error:

 

2 hours ago, xod said:

Could not load file or assembly '0 bytes loaded from System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Share this post


Link to post
Share on other sites

This error sometimes appears in the Show Error List panel.
Errors do not occur all at once but one at a time as I open the .cs files.
I may have some broken registers because I was infected with malware Mail.Ru.

Thank you for your patience.

Share this post


Link to post
Share on other sites

Sounds like something is interfering with your %temp% directory.  If you aren't deleting those .DLL files in %temp%, then maybe your malware is deleting them. Or maybe your anti-malware software deletes them. I don't know.

 

If that's the case, there's really nothing we can fix up in CodeLab to resolve your issue.

 

Under normal circumstances, restarting Paint.NET will fix that error.

Share this post


Link to post
Share on other sites

izAW177.png

This error occurs after I build a CodeLab plugin.

1. Choose the icon you want to appear in your plugin(16x16px).
2. Build the plugin
3. Close CodeLab
4. Open the icon and try to save it

The icon it can only be saved as SaveAs under another name.
Maybe something is broken in my OS?
Anyone else can reproduce this error?

Otherwise, everything works correctly.

Share this post


Link to post
Share on other sites

CodeLab is probably holding the file open.  I'll look into this one.

 

EDIT: This will be fixed in the next release of CodeLab.

  • Like 1

Share this post


Link to post
Share on other sites

CodeLab 4.3 Released

This is only for Paint.NET 4.2+!

 

Big update today...

 

Changes:
▪ Redesign File > New screen (BoltBait)
▪ HighDPI icons (toe_head2001)
▪ Add Format, Find, and Replace toolbar buttons (toe_head2001)
▪ Add snippet for Try/Catch (toe_head2001)
▪ Bug fixes to Quick Format (toe_head2001)
▪ Added flexible, themeable, customizable message boxes (BoltBait)
▪ Allow arbitrary names for UI fields, also removed UI Elements Renumber command (toe_head2001)
▪ Added light bulb renaming of fields defined in user's script (toe_head2001)
▪ Redesigned UI Builder screen (BoltBait)
▪ Added support for the new Uri Control (BoltBait)
▪ Update clipboard template code (null54)
▪ Improvements to code completion (toe_head2001)
▪ Intelligent Assistance improvements for Extension Methods, Generic Methods, and Generic Types (toe_head2001)
▪ Fixed build screen to not hold the icon file open (BoltBait)
▪ Various code cleanups and improvements (toe_head2001 and BoltBait)


Grab the CodeLab DLL here:

 

http://www.boltbait.com/pdn/CodeLab/


Screenshots:

 

File > New screen redesign:

FileNew.png

 

 

New high resolution icons:

 

NewIcons.png

 

 

Themeable message boxes that can have custom buttons:

 

MsgBoxes.png

 

I was tired of MessageBox being displayed with white backgrounds when running the dark theme.  So, I found FlexibleMessageBox source code and fixed it up for use in Paint.NET... added a few features, like customizable buttons and themes... fixed a few bugs.  I think they look awesome.

 

 

UI Designer redesign and new Web Link control:

UIDesigner.png

 

Notice that the Variables can be specified--you no longer need to use Amount1, Amount2, ...

You can, if you want, but it is not necessary as the defaults are the same as before.

 

We also have the new Web Link control type. This gives IndirectUI the ability to have a clickable link that opens a browser to a specified URL.  If a Display Name is specified it is linked.  If no Display Name is specified, the URL is displayed and linked.

 

Rename Variables:

 

Select the variable you wish to rename and start typing... a light bulb will appear.  Click on that and you can rename your variable everywhere in the script where it appears.

 

RenameVar.png

 

 

New Clipboard Code:

 

Paint.NET v4.2 has a new helper class for accessing the clipboard.  CodeLab has been updated to take advantage of this new service.

 

On the File > New screen, when selecting "Clipboard" in the sample code drop-down box, the following code is now generated:

// Name:
// Submenu:
// Author:
// Title:
// Version:
// Desc:
// Keywords:
// URL:
// Help:
#region UICode
#endregion

private Surface clipboardSurface = null;
private bool readClipboard = false;

protected override void OnDispose(bool disposing)
{
    if (disposing)
    {
        // Release any surfaces or effects you've created.
        if (clipboardSurface != null) clipboardSurface.Dispose();
        clipboardSurface = null;
    }

    base.OnDispose(disposing);
}

void PreRender(Surface dst, Surface src)
{
    if (!readClipboard)
    {
        readClipboard = true;
        clipboardSurface = Services.GetService<IClipboardService>().TryGetSurface();
    }
}

// Here is the main render loop function
void Render(Surface dst, Surface src, Rectangle rect)
{
    for (int y = rect.Top; y < rect.Bottom; y++)
    {
        if (IsCancelRequested) return;
        for (int x = rect.Left; x < rect.Right; x++)
        {
            ColorBgra CurrentPixel = src[x,y];
            if (IsCancelRequested) return;
            // If clipboard has an image, get it
            if (clipboardSurface != null)
            {
                CurrentPixel = clipboardSurface.GetBilinearSampleWrapped(x, y);
            }

            // TODO: Add additional pixel processing code here



            dst[x,y] = CurrentPixel;
        }
    }
}

This clipboard code is way faster than the older code CodeLab used to generate.  Notice that the try/catch blocks are gone. That speeds up our code a lot.

 

  • Like 1
  • Upvote 3

Share this post


Link to post
Share on other sites

CodeLab 4.3 in Russian

 

You can find the new version of CodeLab in Russian here.

Вы можете найти новую версию CodeLab на русском языке здесь.

Share this post


Link to post
Share on other sites

CodeLab 4.3 does not retain CheckBox control checked / unchecked status ?

 

Reverted to v4.2  which works correctly.

Edited by xod

Share this post


Link to post
Share on other sites

What a shame. I liked the new features of renaming the AmountX variables.
I wonder if it's possible to do the same thing with the RadioButtonList or DropDownList options so that using 'switch variableX' we can use 'case variableX.name:' instead of 'case 0 :, case 1:' etc.

Share this post


Link to post
Share on other sites
28 minutes ago, xod said:

I wonder if it's possible to do the same thing with the RadioButtonList or DropDownList options so that using 'switch variableX' we can use 'case variableX.name:'

 

Possibly, but it would probably be a bit clumsy.  But using numbers is clumsy too...

I do have idea on how to do it though, and it would require you to define an enum for each RadioButtonList or DropDownList. (right now, CodeLab generates these enums for you)

 

In Visual Studio it's much easier to use enums with RadioButtonList and DropDownList.

In CodeLab, the values are just cast to numbers, because that's the easiest thing to do.  (Because CodeLab generates the enums for you "behind the scenes", you have no way of knowing what they're named when you're working in the CodeLab editor.)

Share this post


Link to post
Share on other sites
9 minutes ago, toe_head2001 said:

...it would probably be a bit clumsy.

 

Starting from the beginning (the very first build of CodeLab that I worked on), I have tried to avoid "clumsy" at all costs.

 

I haven't always been successful, of course, but that's always been my goal--that, and ease of use.

  • Like 1

Share this post


Link to post
Share on other sites

Here's one possible solution, and it would retain the easier way too.

#region UICode
RadioButtonControl<Positions> position = 0; // [1] Image Position|On the Left|In the Center|On the Right
#endregion

enum Positions
{
    Left,
    Center,
    Right
}

void Render(Surface dst, Surface src, Rectangle rect)
{
    switch (position)
    {
        case Positions.Left:
            // Code Here
            break;
        case Positions.Center:
            // Code Here
            break;
        case Positions.Right:
            // Code Here
            break;
    }

    dst.CopySurface(src, rect.Location, rect);
}

 

If RadioButtonControl<TEnum> is too clumsy or confusing, a person could just continue using RadioButtonControl.

  • Like 1
  • Upvote 2

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.