NomBot Posted December 10, 2016 Share Posted December 10, 2016 I'm looking for a way to restart a plugin (as if the user cancelled then reopened it) but without the user actually doing that. If it's possible, what's the safest way of doing it? In other words, what gets called when 'cancel' is pressed and when the plugin is reopened? Quote "No live organism can continue for long to exist sanely under conditions of absolute reality; even larks and katydids are supposed, by some, to dream." Link to comment Share on other sites More sharing options...
BoltBait Posted December 10, 2016 Share Posted December 10, 2016 If the plug-in is written using indirect UI, that really isn't possible. Basically, what you are doing is pressing the reset button on each control. There is no quick way to do that. In fact, there is no way to programmatically change values on the UI while the effect is running. Now, if you are running your own effect without using indirect UI, you can initialize each of your controls from the values in the token. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Computer Dominos Game Link to comment Share on other sites More sharing options...
NomBot Posted December 10, 2016 Author Share Posted December 10, 2016 Thanks, BoltBait. I guess that explains why trying to change the UI wasn't working for me ... What I'm trying to do is read from a file then alter the UI based on that. Any tips on doing this while avoiding indirect UI? Quote "No live organism can continue for long to exist sanely under conditions of absolute reality; even larks and katydids are supposed, by some, to dream." Link to comment Share on other sites More sharing options...
toe_head2001 Posted December 10, 2016 Share Posted December 10, 2016 1 hour ago, NomBot said: ... then alter the UI based on that. What all are you wanting to change? Just setting the values (or other properties) of different controls? The XmlSerializer in .NET makes this very easy. It automatically generates a properly structured XML file based on your code, making the importing and exporting of plugin settings (values) nearly effortless. Or it could be used for loading presets into a plugin. Is that what you're looking for? 1 hour ago, NomBot said: Any tips on doing this while avoiding indirect UI? If want to avoid using WinForms, you could try OptionBasedEffects. It gives you a good balance of the customization of WinForms and the abstraction of IndirectUI. Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
NomBot Posted December 10, 2016 Author Share Posted December 10, 2016 (edited) hi toe_head2001, XML serializer is something I need to look into. but this is what I want to do: 1. user enters settings in UI. 2. this is saved to a file. 3. plugin reads the file. 4. plugin alters UI based on the file.(persistent save of UI option) without user restarting the plugin. I can't figure out how to do that... also looked at optionbased, but can it get around the problem? and is there any doc for this other than play it by ear? Edited December 10, 2016 by NomBot missed ref Quote "No live organism can continue for long to exist sanely under conditions of absolute reality; even larks and katydids are supposed, by some, to dream." Link to comment Share on other sites More sharing options...
toe_head2001 Posted December 10, 2016 Share Posted December 10, 2016 19 minutes ago, NomBot said: 1. user enters settings in UI. 2. this is saved to a file. 3. plugin reads the file. 4. plugin alters UI based on the file.(persistent save of UI option) I have no idea why you'd do that, it can be done in WinForms for sure. If you need an example of the XmlSerializer in action, you can take a look at my Tartan plugin. Here's the two commits that added the XmlSerializer import/export functionality. 26 minutes ago, NomBot said: also looked at optionbased, but can it get around the problem? and is there any doc for this other than play it by ear? I'm not sure it could be done with OptionBasedEffects. Maybe it can. There really isn't any documentation for it. I used it for my Graph Paper plugin, and I just figured out what I needed to as I went along. Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
NomBot Posted December 10, 2016 Author Share Posted December 10, 2016 (edited) Toe_head2001, as a sort of Scot, I read your Tartan, briefly. and it was good coding. and a good plugin. and I think I'll need to delve into WinForms to do what i want to do, and i'm a c# noob. edit: Looks like what you did there is the way to go. Thanks Edited December 10, 2016 by NomBot Quote "No live organism can continue for long to exist sanely under conditions of absolute reality; even larks and katydids are supposed, by some, to dream." Link to comment Share on other sites More sharing options...
NomBot Posted December 10, 2016 Author Share Posted December 10, 2016 (edited) just to clarify: ops = GetOpts(filePath); Amount1Control.SetValueDisplayName(Amount1Options.Amount1Option1, ops[1]); etc. if that makes sense ... doesn't do what I wanted it to do Edited December 10, 2016 by NomBot Quote "No live organism can continue for long to exist sanely under conditions of absolute reality; even larks and katydids are supposed, by some, to dream." Link to comment Share on other sites More sharing options...
Rick Brewster Posted December 10, 2016 Share Posted December 10, 2016 Whether a real person changes the UI properties, or you park a FileSystemWatcher on some configuration file which is used to populate the UI properties, it's the same idea. External input changes the property values which causes the effect rendering to begin a new. But yeah you can't do that with IndirectUI because you don't have write access to the properties and their values. Only the UI, and thus the user, has that access. 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...
NomBot Posted December 11, 2016 Author Share Posted December 11, 2016 Thanks Rick, That makes sense now that I think about it. And thanks for your work developing Paint.NET... hat's off Quote "No live organism can continue for long to exist sanely under conditions of absolute reality; even larks and katydids are supposed, by some, to dream." Link to comment Share on other sites More sharing options...
NomBot Posted December 20, 2016 Author Share Posted December 20, 2016 Update: Good news, OptionBasedEffects can do what I wanted to do (update UI behind-the-scenes etc) ... and I like the look and feel of it better than WinForms. minor snag: can't get the OptionDoubleVectorPan control to work, wondering if anyone has used it in a plugin. OptionDoubleVectorPan(OptionNames.VecPan,optContext,0.5,0.0,1.0,0.5,0.0,1.0), gives me a System.OverflowException: Overflow error. Quote "No live organism can continue for long to exist sanely under conditions of absolute reality; even larks and katydids are supposed, by some, to dream." Link to comment Share on other sites More sharing options...
toe_head2001 Posted December 20, 2016 Share Posted December 20, 2016 1 hour ago, NomBot said: OptionDoubleVectorPan(OptionNames.VecPan,optContext,0.5,0.0,1.0,0.5,0.0,1.0), gives me a System.OverflowException: Overflow error. It's System.Drawing that is throwing the exception, because it can't draw the Pan's vector lines. Easy fix though. You just need set the StaticBitmapUnderlay property. Then it will have an area in which to draw those lines. To set the image as the source selection: Rectangle selection = this.EnvironmentParameters.GetSelection(this.EnvironmentParameters.SourceSurface.Bounds).GetBoundsInt(); OptionDoubleVectorPan pan = new OptionDoubleVectorPan(OptionNames.Pan, optContext, 0.5, 0.0, 1.0, 0.5, 0.0, 1.0); pan.StaticBitmapUnderlay = this.EnvironmentParameters.SourceSurface.CreateAliasedBitmap(selection); or Rectangle selection = this.EnvironmentParameters.GetSelection(this.EnvironmentParameters.SourceSurface.Bounds).GetBoundsInt(); new OptionDoubleVectorPan(OptionNames.Pan, optContext, 0.5, 0.0, 1.0, 0.5, 0.0, 1.0) { StaticBitmapUnderlay = this.EnvironmentParameters.SourceSurface.CreateAliasedBitmap(new Rectangle(0, 0, 50, 50)) }, 1 Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
NomBot Posted December 20, 2016 Author Share Posted December 20, 2016 Thanks, Toe_head! would have taken me a while to figure that one out on my own ... Quote "No live organism can continue for long to exist sanely under conditions of absolute reality; even larks and katydids are supposed, by some, to dream." 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.