Jump to content

Controlling the progress bar


Recommended Posts

Is it in any was possible to control the progress bar or make your own in a PropertyBasedEffect?

 

I have an effect where I need to do some time consuming pre-processing before I can deliver the first pixel but after that the rest can be delivered in no time. This means that the default progress bar based on the calls to OnRender will stall at 0% for some a long time and then immediately go to 100% which is not very useful.

 

If this is not possible then I would suggest that if the effect sets EffectFlags.SingleRenderCall then PDN would just show the standard indeterminate progress bar while it is processing as it has no progress info anyway.

Michael Vinther

Link to comment
Share on other sites

With a custom Winform UI you can have your own progress bar. Planetoid uses an animation as a progress bar.  Most of TechnoRobbo's plugins have custom progress bars too.

  • Upvote 2
Link to comment
Share on other sites

I have a plugin that I think does what you want. Try using my Effects > Steganography > Encode from file:

http://forums.getpaint.net/index.php?/topic/4786-

When you click the browse button and choose a file, a progress bar shows. Is that what you want?

If so, here's what the code looks like:

public static Bitmap Process(Bitmap image)
{
    using (Form form = new Form())
    {
        // Show a popup loading bar because processing is sooooo slow.
        form.Text = "Loading image...";
        form.AutoSize = true;
        form.AutoSizeMode = AutoSizeMode.GrowAndShrink;
        form.FormBorderStyle = FormBorderStyle.FixedToolWindow;
        form.ShowInTaskbar = false;
        form.StartPosition = FormStartPosition.CenterScreen;

        ProgressBar progress = new ProgressBar();
        progress.Location = new System.Drawing.Point(5, 5);
        progress.Width = 252;
        progress.Minimum = 0;
        progress.Value = 0;
        progress.Maximum = image.Height + 1;
        form.Controls.Add(progress);

        form.Show();

        Bitmap resultBitmap = new Bitmap(image.Width, image.Height);

        for (int y = 0; y < image.Height; y++)
        {
            progress.Value = y + 1; // update the progress bar
            for (int x = 0; x < image.Width; x++)
            {
                // Do your processing here, etc.
            }
        }
        form.Close(); // hide progress bar
        return resultBitmap;
    }
}
  • Upvote 1

Click to play:
j.pngs.pngd.pnga.pngp.png
Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game

Link to comment
Share on other sites

Thanks for the code. I was hoping to be able to use PDN's standard progress bar but since that is not possible I'll use your solution.

 

By the way, I found that it looks better if the progress form does not take focus and cause PDN do be displayed as inactive. That can be achieved by making the form like this:

 

class ProgressForm : Form
{
    protected override bool ShowWithoutActivation { get { return true; } }
}

...

using (Form form = new ProgressForm())
Edited by MichaelVinther
  • Upvote 2

Michael Vinther

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