Jump to content

Question about pan slider control with white or colored background


MJW

Recommended Posts

I have a use for a pan slider control with no background image. I simply want a square with either a white or (preferably) colored background.

 

I could create an appropriately-sized bitmap, fill it with the desired color, and call:

ImageResource bgImage = ImageResource.FromImage(bitmap);
configUI.SetPropertyControlValue(name, ControlInfoPropertyNames.StaticImageUnderlay, bgImage);

There are at least two reasons I'd prefer a different approach if one exists. First, since it's a bitmap, I assume I should dispose of it when the effect exits, which prevents me (as far as I can see) from creating it at the low level of the call that configures the control. Second, I want to make the bitmap as small as possible, while still creating a full-sized rectangle in the control. That seems like it might depend on the screen resolution, which would prevent me from determining the correct size through trial and error.

 

If I just want a white background, I can leave off the SetPropertyControlValue call. That works, except it creates a rectangle without a border. I want a border.

 

Is there a way, other than using a bitmap, to create a pan slider control with a blank background and a border? And if not, how do I determine the correct size for the bitmap, so that it works with all displays?

 

Link to comment
Share on other sites

When Rick added new icons to Paint.NET he talked about using SVG to produce them and something about high DPI scaling and dynamic DPI infrastructure. Maybe that is something that could apply to your query and not just to the UI of Paint.NET?

Edited by HyReZ


 

Link to comment
Share on other sites

My Effects > Fill > With Clipboard does this.

 

After generating a VS solution from the CodeLab script, I made the following changes:

 

//Surface sourceSurface1 = this.EnvironmentParameters.SourceSurface;
//Bitmap bitmap1 = sourceSurface1.CreateAliasedBitmap();
ImageResource imageResource1 = ImageResource.FromImage(new Bitmap(typeof(FillFromClipboardEffectPlugin), "BlankCanvas.png"));
configUI.SetPropertyControlValue(PropertyNames.Amount1, ControlInfoPropertyNames.StaticImageUnderlay, imageResource1);

BlankCanvas.png is an 81x81 bitmap that is completely white.

 

Just include in project and set to Embedded Resource.

 

  • Like 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, BoltBait.

 

I was (and still am, somewhat) concerned that for high-resolution screens PDN would create larger UIs, so that it's a better size for the user, and therefore a rectangle size the works with my monitor might be too small with some other types.

 

Creating the bitmap as a resource instead of programmatically, as I was thinking, is most likely a better way to go.

 

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.

×
×
  • Create New...