Rick Brewster

CodeLab v4.0 (for advanced users) Released September 5, 2018

Recommended Posts

VS allows to

-add a picture 200x150 to illustrate the effect

-use multi language labels

-use multi language keywords

 

 

Share this post


Link to post
Share on other sites
3 hours ago, MadJik said:

VS allows to

-add a picture 200x150 to illustrate the effect

 

As I said before, CodeLab has this capability.

Share this post


Link to post
Share on other sites

Hi, can tabs be supported in Codelab? if there would be 3 or 4 tabs, it would be quite helpful in copying and testing different versions together.

Share this post


Link to post
Share on other sites
17 hours ago, Pratyush said:

... can tabs be supported in Codelab?

 

Yes, tabs could be supported in CodeLab. You might be the only person who would use such a feature though.

Personally, I have no interest in putting in the work to add tabs. It really wouldn't be difficult to implement though. It would mostly consist of making sure all the user interface buttons get mapped to the active tab.

Share this post


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

Personally, I have no interest in putting in the work to add tabs.

 

Me either.

Share this post


Link to post
Share on other sites

CodeLab crashes if we use the slash character in the UI.

Same for any mathematical symbol.

 

oP8qyyJ.png

 

Exception details:
System.FormatException: Input string was not in a correct format.
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at PaintDotNet.Effects.UIBuilder.ControlType_SelectedIndexChanged(Object sender, EventArgs e)
   at System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)
   at System.Windows.Forms.ComboBox.set_SelectedIndex(Int32 value)
   at System.Windows.Forms.ComboBox.set_Text(String value)
   at PaintDotNet.Effects.UIBuilder.ControlListView_SelectedIndexChanged(Object sender, EventArgs e)
   at System.Windows.Forms.ListView.OnSelectedIndexChanged(EventArgs e)
   at System.Windows.Forms.ListView.WmReflectNotify(Message& m)
   at System.Windows.Forms.ListView.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Edited by xod
Added image.

Share this post


Link to post
Share on other sites
3 hours ago, xod said:

CodeLab crashes if we use the slash character in the UI. Same for any mathematical symbol. 

 

Slashes seem to work fine.

The crash is actually caused by the 0.6 in the Default box.  When switching to the Checkbox, CodeLab attempts to Parse the 0.6 as an integer. :/

 

Fixed for the next release:

if (int.TryParse(ControlDef.Text, out int result) && result > 0)

 

  • Upvote 1

Share this post


Link to post
Share on other sites

Tired of having to create a Visual Studio project and configure it ... every time you export from plugin from CodeLab?

 

Me too, so I automated it all! 😎

 

GenerateSolution.png

  • Like 1
  • Upvote 4

Share this post


Link to post
Share on other sites
On 3/25/2018 at 6:22 AM, Pratyush said:

Hi, can tabs be supported in Codelab? if there would be 3 or 4 tabs, it would be quite helpful in copying and testing different versions together.

 

This would be even easier than I original thought. A whole lot easier.

Scintilla can actually handle multiple documents natively, so we wouldn't even need to spawn additional editor controls (which was my main concern).

 

Therefore, I am reconsidering adding tabs, as my older assessment of "not worth the effort" is no longer accurate.

  • Like 2
  • Upvote 1

Share this post


Link to post
Share on other sites

CodeLab 4.0 Released

This is only for Paint.NET 4.1+!

 

Big update today...

 

Changes:

▪ Editor has tabs and can edit more than one file at a time. (toe_head2001)
▪ Generate VS Project function on Build screen. (toe_head2001)
▪ Separate Save and Save As functions. (toe_head2001)
▪ The autocomplete function now does matching initials. (toe_head2001)
▪ Indicator Map (Ctrl+M) now integrated with scroll bar. (toe_head2001)
▪ Building to DLL now saves to Desktop in a ZIP file all ready for posting. (BoltBait)
▪ Install.BAT files now work for both the Classic and Store versions of PdN. (BoltBait)
▪ Colorwheel control now has Alpha style option. (BoltBait)
▪ Colorwheel control reset button can now be hidden. (BoltBait)
▪ Filename control added. (BoltBait)
▪ File>New templates have a "non-looping" style for GDI+ plugins. (BoltBait)

 

Grab the CodeLab DLL here:

 

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

 

Screenshot(s):

 

Check out this new UI feature, tabs:

 

CodeLab40UI.png:LeftArrowBlue:Indicator Map scrollbar

 

How to access the new Colorwheel with Alpha:

UIDesigner.png:RightArrowBlue:  ColorWheelSizes.png

 

How to generate a script for using GDI+ commands:

NewTemplate.png

  

 

Example Scripts:

 

Here is a CodeLab script for using the new FilenameControl:

 

Spoiler

// 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).

 

Here is an example GDI+ script:

 

Spoiler

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.

 

 

Questions and Answers:

 

"Building to DLL now saves to Desktop in a ZIP file.Why would you do that?!

 

Quote

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.

 

"Matching of Initials in the AutoComplete box filter."  What's that?!

 

Quote

db - DrawBezier

memAbrev.png

 

isc - IntSliderControl

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

iscAbrev.png


 

  • Like 1
  • Upvote 3

Share this post


Link to post
Share on other sites

CodeLab 4.0 in Russian

 

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

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

Share this post


Link to post
Share on other sites

I think that with the launch of the new version of paint.net 4.1.1 CodeLab should also be revised.

 

Color Wheel Control does not behave properly.

 

As shown in the image below, I chose the Default style but the chosen color has Alpha = 0 although I do not have a slider for Alpha.

 

wk5IEdT.png

Share this post


Link to post
Share on other sites

@xod, is the default set to Primary color and is your primary color have alpha set to 0?

Share this post


Link to post
Share on other sites

This isn't a codelab question but I've noticed all my plugins which have a colour option have the colour showing alpha in the colour box, not a solid colour.

It hasn't always been like this has it ?  

 

as an example EER's Organigram

 

origram.png

Share this post


Link to post
Share on other sites
2 hours ago, xod said:

Color Wheel Control does not behave properly. 

 

This is just visual issue in the control itself. The ColorBgra from the control will still have an Alpha channel value 255.

The issue is in paint.net v4.1.1; not CodeLab.

Edited by toe_head2001

Share this post


Link to post
Share on other sites

Yes, you're right is just visual issue.
Does not affect the plugins made with OptionBasedLibrary.

 

sp4NgBK.png

Share this post


Link to post
Share on other sites
On 9/12/2018 at 8:21 AM, xod said:

Color Wheel Control does not behave properly.

 

Thanks for the bug report.  It was definitely a bug in Paint.NET.  Sorry about that.

 

I submitted a code fix.  When Rick approves the fix, it will show up in the next build of Paint.NET.

 

EDIT: It has been approved.

  • Like 2
  • Upvote 1

Share this post


Link to post
Share on other sites
5 hours ago, georch said:

Your server is down, it gives me a HTTP 500 answer from IIS. Can you fix that, or, for that matter, mirror CodeLab elsewhere?

 

The direct link to the zip file should still work:

 

http://boltbait.com/pdn/CodeLab/CodeLabInstaller400.zip

 

Sorry about my web site issues.  My hosting company is a piece of ... um ... garbage!  I'm in the process of shopping around for a new company that actually knows what they're doing.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now