Sign in to follow this  
BoltBait

CodeLab 4.0 for the new Paint.NET 4.1 - UPDATED to Beta 3!

Recommended Posts

This will be officially released when Rick releases Paint.NET v4.1.

CodeLab v4.0 Beta*:    <snip>        :LeftArrowBlue: Beta 3 build

 

Requires: Paint.NET v4.1+

 

New Features:

  • Editor has tabs (toe_head2001)
  • Colorwheel control now has Alpha style option (BoltBait)
  • Filename control (BoltBait)
  • Generate VS Project function on Build screen (toe_head2001)
  • File > New templates have a new "Non Looping" style for all of your GDI+ work (BoltBait)
  • Separate Save and Save As functions (toe_head2001)
  • The autocomplete function now does matching initials (as described below) (toe_head2001)
  • Minor bug fixes (toe_head2001 and BoltBait)

 

New Features in the Second Beta:

  • Indicator Map (Ctrl+M) now integrated with scroll bar (toe_head2001)
  • Colorwheel control reset button can now be hidden (BoltBait)
  • Building to DLL now saves to Desktop in a ZIP file all ready for posting to the forum (BoltBait)
  • Install.BAT files now work for both the Classic install and the Store version of Paint.NET (BoltBait)
  • Generate VS Solution function now has an updated Post Build Event script (BoltBait)

 

New Features in the Third Beta:

  • Fixed bug in smallest colorwheel (found by @xod) (BoltBait)

 

Now, before anyone says anything... when running CodeLab it may prompt you to download v3.5. This is normal!  Just ignore it.  That error message won't be there once the official release happens. :) 

 

Check out this new UI feature, tabs:

 

CodeLab40UI.png

 

How to access the new Colorwheel with Alpha:

UIDesigner.png:RightArrowBlue:  ColorWheelSizes.png

 

How to generate a script for using GDI+ commands:

NewTemplate.png

  

 

*This download has been deleted as the official version has been released.

 

 

  • Like 3
  • Upvote 3

Share this post


Link to post
Share on other sites

Here is a CodeLab script for using the new FilenameControl:

// Name: Fill from file
// Author: BoltBait
#region UICode
FilenameControl Amount1 = @""; // Open Image|jpg|png|gif|bmp
#endregion

Surface wrk = null;

protected override void OnDispose(bool disposing)
{
    if (wrk != null) wrk.Dispose();
    wrk = null;
    base.OnDispose(disposing);
}

void PreRender(Surface dst, Surface src)
{
    if (wrk == null)
    {
        wrk = new Surface(src.Size);
    }

    try
    {
        // Use your FilenameControl to load an image for use
        wrk = Surface.CopyFromBitmap((Bitmap)Bitmap.FromFile(Amount1));
    }
    catch
    {
        wrk.Clear(ColorBgra.Transparent);
    }
}

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 = wrk.GetBilinearSampleWrapped(x,y);
            dst[x,y] = CurrentPixel;
        }
    }
}

 

 

Notice in the definition of the control, in the comment we have the title of the control followed by the file types allowed:

 

FilenameControl Amount1 = @""; // Open Image|jpg|png|gif|bmp

So, in this example, the prompt will be "Open Image" and the allowed file types will be .jpg, .png, .gif, and .bmp.

 

For tinkering inside of CodeLab, between the quotes you can place a path to a file.  (Notice that the @ sign before the first quote allows you to use the backslash character "\" without escaping it (doubling them).

  

  • Like 1

Share this post


Link to post
Share on other sites

On the File > New (Templates) screen, you can now choose a looping style of "None".  This will generate a script like this:

 

// Name: GDI+ Example
// Author: BoltBait
#region UICode
#endregion

// Working surface
Surface wrk = null;

// Setup for using Normal blend op
private BinaryPixelOp normalOp = LayerBlendModeUtil.CreateCompositionOp(LayerBlendMode.Normal);

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

void PreRender(Surface dst, Surface src)
{
    if (wrk == null)
    {
        wrk = new Surface(src.Size);
    }

    wrk.Clear(ColorBgra.Transparent);
}

// Here is the main render loop function
void Render(Surface dst, Surface src, Rectangle rect)
{
    using (Graphics g = new RenderArgs(wrk).Graphics)
    using (Region gClipRegion = new Region(rect))
    using (Pen pen = new Pen(ColorBgra.Black, 1))
    using (GraphicsPath path = new GraphicsPath())
    using (SolidBrush brush = new SolidBrush(ColorBgra.Black))
    using (Font font = new Font("Arial", 12))
    {
        g.Clip = gClipRegion;
        g.SmoothingMode = SmoothingMode.AntiAlias;
        g.TextRenderingHint = TextRenderingHint.AntiAlias;
        pen.LineJoin = LineJoin.Round;

        // add additional GDI+ commands here

    }
    normalOp.Apply(dst, src, wrk, rect);
}

Notice that there are no loops in the Render method.

 

In the Render method, CodeLab generates several "using" blocks. Just delete the ones you won't be using yourself.  You'll probably want to modify the remaining "using" statements with user controls to make the various colors and sizes adjustable in your plugin.

 

Finally, you can add additional GDI+ commands to render text, lines, and shapes to the wrk canvas which will then be combined with the source canvas to create your result.

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Some other stuff you'll find in this 4.0 Beta:

 

- The Save button is now an actual Save (Non-SaveAs) button.  As separate SaveAs button is available in the File menu.

 

- Matching of Initials in the AutoComplete box filter.

 

db - DrawBezier

memAbrev.png

 

isc - IntSliderControl

(and of course IsCancelRequested is still listed, since it starts with isc)

iscAbrev.png

Edited by toe_head2001
  • Upvote 2

Share this post


Link to post
Share on other sites
On 8/23/2018 at 9:26 AM, BoltBait said:

New Features:

  • Editor has tabs (toe_head2001)

Thank you very much for tabs. @BoltBait & @toe_head2001 ?

 

On 8/23/2018 at 9:26 AM, BoltBait said:

This will be officially released when Rick releases Paint.NET v4.1.

Version 4.1 is on its way!! I'm eager for the new things. ?

Share this post


Link to post
Share on other sites

First post updated with the Beta 2 build of CodeLab.

 

See above for a list of new features.

Share this post


Link to post
Share on other sites
On 8/22/2018 at 8:56 PM, BoltBait said:

Building to DLL now saves to Desktop in a ZIP file all ready for posting to the forum

 

Why did we do this?!

 

Well, now that we have live preview in CodeLab itself, there really isn't as much of a need to "build to dll, install dll, run Paint.NET" to test your plugin.

 

AND, people keep posting zipped DLL files to the forum without including the install.bat file that goes with them.

 

So... I thought it would be convenient to just prepare the zip file for you.  This way, it is all ready for you to post to the forum. 

 

PLUS, the new install.bat file that is built for you supports both the Classic version and the Store version of Paint.NET.

 

  • Upvote 3

Share this post


Link to post
Share on other sites

Type: ColorWheel, Style: Default no Reset has some problems in preview mode. Doesn't render text.

Share this post


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

Type: ColorWheel, Style: Default no Reset has some problems in preview mode. Doesn't render text.

 

Show me.

 

Nevermind.  I'm able to reproduce the problem.  Thanks for the bug report!

 

...Now, let's see if I can fix it. :D 

 

EDIT: Yup, CodeLab is generating the wrong code.  Fix should be easy.

 

EDITEDIT: Fix posted.

  • Upvote 1

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this