John8 Posted March 22, 2020 Share Posted March 22, 2020 Hello, I was wondering how to update controls in a plugin. The use case is to estimate some parameters and then let the user choose to adjust the values himself. I my case, I have properties like that : protected override PropertyCollection OnCreatePropertyCollection() { var propertyList = new List<Property> { StaticListChoiceProperty.CreateForEnum(PropertyNames.WhiteBalanceMethod, WhiteBalanceMethod.None, false), new DoubleProperty(PropertyNames.RedGain, 1.0, 0.0, 2.0), new DoubleProperty(PropertyNames.GreenGain, 1.0, 0.0, 2.0), new DoubleProperty(PropertyNames.BlueGain, 1.0, 0.0, 2.0) }; return new PropertyCollection(propertyList); } For those properties I set up the controles like that : protected override ControlInfo OnCreateConfigUI(PropertyCollection props) { var defaultConfigUi = CreateDefaultConfigUI(props); defaultConfigUi.SetPropertyControlValue(PropertyNames.RedGain, ControlInfoPropertyNames.DisplayName, "Red Gain"); defaultConfigUi.SetPropertyControlValue(PropertyNames.GreenGain, ControlInfoPropertyNames.DisplayName, "Green Gain"); defaultConfigUi.SetPropertyControlValue(PropertyNames.BlueGain, ControlInfoPropertyNames.DisplayName, "Blue Gain"); defaultConfigUi.SetPropertyControlValue(PropertyNames.WhiteBalanceMethod, ControlInfoPropertyNames.DisplayName, "White Balance Method"); var controlForPropertyName = defaultConfigUi.FindControlForPropertyName(PropertyNames.WhiteBalanceMethod); controlForPropertyName.SetValueDisplayName(WhiteBalanceMethod.None, "None"); controlForPropertyName.SetValueDisplayName(WhiteBalanceMethod.GrayWorld, "GrayWorld"); controlForPropertyName.SetValueDisplayName(WhiteBalanceMethod.Retinex, "Retinex"); controlForPropertyName.SetValueDisplayName(WhiteBalanceMethod.YCbCr, "YCbCr"); return defaultConfigUi; } Then, at some point, I update the properties' values with SetPropertyValue like that : private void UpdateProperties(PropertyBasedEffectConfigToken newToken, WhiteBalanceMethod whiteBalanceMethod) { var whiteBalanceFunction = GetWhiteBalanceFunction(whiteBalanceMethod); if (whiteBalanceFunction == null) return; var (redGain, greenGain, blueGain) = whiteBalanceFunction(SrcArgs.Surface); (redGain, greenGain, blueGain) = Normalize(redGain, greenGain, blueGain); newToken.SetPropertyValue(PropertyNames.RedGain, redGain); newToken.SetPropertyValue(PropertyNames.GreenGain, greenGain); newToken.SetPropertyValue(PropertyNames.BlueGain, blueGain); // XXX : How to update controls with new values ? } Updating the property values works, and I can read back the values with GetProperty. However it does not update the controls in the UI and the sliders remain to the value that was already set. How can I update the controls' value to display their properties' value ? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
BoltBait Posted March 22, 2020 Share Posted March 22, 2020 10 minutes ago, John8 said: I was wondering how to update controls in a plugin. The short answer is: you can’t do that with IndirectUI. Quote Download: BoltBait's Plugin Pack | CodeLab | and a Computer Dominos Game Link to comment Share on other sites More sharing options...
John8 Posted March 22, 2020 Author Share Posted March 22, 2020 (edited) Is there a way without IndirectUI ? Edited March 22, 2020 by John8 Quote Link to comment Share on other sites More sharing options...
Red ochre Posted March 22, 2020 Share Posted March 22, 2020 'Null54's posts in this thread may help if you want to convert to a Windows forms U.I. https://forums.getpaint.net/topic/27382-scribble-temp-surface-prop-rules-questions/ Good luck! Quote Red ochre Plugin pack.............. Diabolical Drawings ................Real Paintings Link to comment Share on other sites More sharing options...
MJW Posted March 22, 2020 Share Posted March 22, 2020 13 hours ago, John8 said: Is there a way without IndirectUI ? Without IndirectUI you can do pretty much what you want with the controls, including changing their values. The user interface is just a Windows Form. The challenge is sufficiently maintaining the look-and-feel of PDN user interfaces. For instance, most non-IndirecUI Effects I've encountered don't have control resets, which many users (e.g., me) expect. Quote Link to comment Share on other sites More sharing options...
xod Posted March 23, 2020 Share Posted March 23, 2020 This can be done using the OptionBasedLibrary. Below is an example: TextOnPath.zip Quote Link to comment Share on other sites More sharing options...
xod Posted March 23, 2020 Share Posted March 23, 2020 14 hours ago, MJW said: For instance, most non-IndirecUI Effects I've encountered don't have control resets, which many users (e.g., me) expect. Sometimes the reset button is actually a label just like the TechnoRobbo's plugin. Clicking on the label resets the control to its initial value. Quote 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.