MJW Posted July 13, 2015 Share Posted July 13, 2015 Is there a way for a plugin to get the list of colors in the current palette? By "current palette," I mean the colors displayed in the color window, which may have been modified by the user from the loaded palette file or default palette. Quote Link to comment Share on other sites More sharing options...
BoltBait Posted July 13, 2015 Share Posted July 13, 2015 Nope. EDIT: Well....... maybe. It is stored in the registry under Computer\HKEY_CURRENT_USER\Software\Paint.NET\CurrentPalette Not sure the format... you'll have to play with it. Also, you could prompt the user for a palette file (from the palette folder) and go that way. Here is some code to get you started: http://forums.getpaint.net/index.php?/topic/31921-adding-a-help-button-to-codelab-plugins/?p=427601 1 Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
MJW Posted July 13, 2015 Author Share Posted July 13, 2015 Thanks, BoltBait (even though it isn't the answer I would have preferred). I wanted some relatively easy way for the user to pass a list of colors to the plugin, selected using the Color Picker. Unfortunately, having to create then open a new palette file each time seems a bit too roundabout for my purposes. Quote Link to comment Share on other sites More sharing options...
BoltBait Posted July 13, 2015 Share Posted July 13, 2015 Check my edit above... Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
MJW Posted July 13, 2015 Author Share Posted July 13, 2015 Thanks again! I'll have to give the registry method a try. That sounds promising. Quote Link to comment Share on other sites More sharing options...
MJW Posted July 14, 2015 Author Share Posted July 14, 2015 Is reading the PDN variables through the registry Rick-approved? Â I looked at the Palette entry in Regedit, and it's a text string which includes comments documenting the format. The colors are stored as strings representing the hex values as "aarrggbb." It should be very easy to parse. I changed a palette value in PDN, and the registry value changed exactly in the way I expected it to. Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted July 14, 2015 Share Posted July 14, 2015 I could also just give you an IUserPalettesService accessible via the Services property. I already have this it's just not exposed for effects. It would require v4.0.6+ though.  In general, I would rather add access to stuff in this way vs. requiring you to reverse engineer something like what you're proposing. But I can't just say "no" to everything, so if you want to read from the registry, and as long as you've got reasonable error handling in there (plz don't crash), and as long as you're not writing back to it, I don't really see the harm. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
BoltBait Posted July 14, 2015 Share Posted July 14, 2015 I could also just give you an IUserPalettesService accessible via the Services property. I already have this it's just not exposed for effects. It would require v4.0.6+ though. That would be really handy. This is not the first request we've had for access to the current palette. Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
MJW Posted July 14, 2015 Author Share Posted July 14, 2015 I would definitely prefer the cleaner interface. I'm in no hurry to write this particular plugin, so I'll probably wait and see if palette access available by a non-registry method in a future version. Or perhaps I'll write it using the registry, with the idea of changing it later. (I always do my best to avoid crashing PDN with a plugin.) Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted July 19, 2015 Share Posted July 19, 2015 Okay you can expect this in the next update namespace PaintDotNet.AppModel {   public interface IPalettesService   {     IReadOnlyList<ColorBgra> DefaultPalette     {       get;     }      IReadOnlyList<ColorBgra> CurrentPalette     {       get;     }   } } 2 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
BoltBait Posted July 19, 2015 Share Posted July 19, 2015 The next version of CodeLab will include an option in the File New template to generate code to use this new service. 3 Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
MJW Posted July 20, 2015 Author Share Posted July 20, 2015 Thanks, Rick and BoltBait. That sounds very nice. Quote Link to comment Share on other sites More sharing options...
BoltBait Posted August 3, 2015 Share Posted August 3, 2015 This is now built-in to CodeLab (starting with version 2.6) http://forums.getpaint.net/index.php?/topic/880-codelab-v26-for-advanced-users-released-august-2-2015/?p=429174 Enjoy. Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.