xod Posted January 27, 2017 Posted January 27, 2017 (edited) I don't want to abuse for your kindness but maybe you can help me in the next problem: //two sliders AmountX, AmountY with link checkbox = AmountZ; if the checkbox is ticked then AmountX and AmountY sliders is linked. propRules.Add(new LinkValuesBasedOnBooleanRule<int, Int32Property>(new ValueType[] { PropertyNames.AmountX, PropertyNames.AmountY }, PropertyNames.AmountZ, false)); //found on simonbrown site //one slider = AmountX with enable checkbox = AmountY; if the checkbox is unticked then AmountX slider is disabled. propRules.Add(new ReadOnlyBoundToBooleanRule(PropertyNames.AmountX, PropertyNames.AmountY, true));//also found on simonbrown site Now, if I have a dropdown list and I want to enable a slider when an option from that dropdown list is choosed, how can I make that? propRules.Add(new ReadOnlyBoundToBooleanRule(PropertyNames.AmountXOptionN, PropertyNames.AmountY, true));//does not work Edited November 14, 2017 by BoltBait Split from unrelated topic Quote
ReMake Posted January 28, 2017 Posted January 28, 2017 Your code might look like this: protected override PropertyCollection OnCreatePropertyCollection() { List<Property> props = new List<Property>(); props.Add(StaticListChoiceProperty.CreateForEnum<AmountXOptions>(PropertyNames.AmountX, 0, false)); props.Add(new Int32Property(PropertyNames.AmountY, 5, 0, 100)); ... ... List<PropertyCollectionRule> propRules = new List<PropertyCollectionRule>(); propRules.Add(new ReadOnlyBoundToValueRule<object, StaticListChoiceProperty>(PropertyNames.AmountY, PropertyNames.AmountX, AmountXOptions.AmountXOptionN, true)); return new PropertyCollection(props, propRules); } Pay attention to the last line. 1 Quote
xod Posted January 29, 2017 Author Posted January 29, 2017 (edited) Thanks @ReMake! Edited June 2, 2017 by xod 1 Quote
xod Posted November 13, 2017 Author Posted November 13, 2017 If I have a dropdown list with 8 options and I want to enable a slider when only 3 options (not necessarily one after another) from that dropdown list is choosed, how can I make that? Quote
MJW Posted November 14, 2017 Posted November 14, 2017 I believe the proper format is: object[] conditions = new object[] { MyDropDownOptions.MyDropDownOption2, MyDropDownOptions.MyDropDownOption3 }; propRules.Add(new ReadOnlyBoundToValueRule<object, StaticListChoiceProperty>(PropertyNames.MySlider, PropertyNames.MyDropDown, conditions, false)); EDIT: A more complete explanation is here. 3 Quote
toe_head2001 Posted November 14, 2017 Posted November 14, 2017 Cool, I had forgotten about that. Thanks. Quote My Gallery | My Plugin Pack Layman's Guide to CodeLab
xod Posted November 14, 2017 Author Posted November 14, 2017 (edited) Thank you MJW. For more complex situations like the one in the picture below I tried to create a new cond2 condition, but it does not work. object[] cond1 = new object[] {Amount9Options.Amount9Option2, Amount9Options.Amount9Option5, Amount9Options.Amount9Option8}; propRules.Add(new ReadOnlyBoundToValueRule<object, StaticListChoiceProperty>(PropertyNames.Amount10, PropertyNames.Amount9, cond1, true)); propRules.Add(new ReadOnlyBoundToValueRule<object, StaticListChoiceProperty>(PropertyNames.Amount11, PropertyNames.Amount9, cond1, true)); object[] cond2 = new object[] {Amount9Options.Amount9Option3, Amount9Options.Amount9Option6}; propRules.Add(new ReadOnlyBoundToValueRule<object, StaticListChoiceProperty>(PropertyNames.Amount10, PropertyNames.Amount9, cond2, true)) Edited November 14, 2017 by xod Quote
MJW Posted November 14, 2017 Posted November 14, 2017 58 minutes ago, xod said: For more complex situations like the one in the picture below I tried to create a new cond2 condition, but it does not work. I'm not clear what each option is supposed to do. For instance, what the difference is between Option2 and Option5, both of which are labeled "Slider X, Y". it's certainly possible to enable any combination of the sliders with the list box. Assuming the labels specify which controls to enable: object[] condX = new object[] {Amount9Options.Amount9Option2, Amount9Options.Amount9Option3, Amount9Options.Amount9Option5, Amount9Options.Amount9Option6, Amount9Options.Amount9Option8}; object[] condY = new object[] {Amount9Options.Amount9Option2, Amount9Options.Amount9Option4, Amount9Options.Amount9Option5, Amount9Options.Amount9Option7, Amount9Options.Amount9Option8}; You probably have something more complex in mind. 1 Quote
xod Posted November 14, 2017 Author Posted November 14, 2017 It's about that kind of situation: Quote
MJW Posted November 14, 2017 Posted November 14, 2017 20 minutes ago, xod said: It's about that kind of situation: In that case, I expect the values I gave should work. Each control is independent: it only cares about the values that enable it, so there's really no additional complexity in enabling two slider controls with one list control. If you were trying to enable a single control based on the values of two controls, that would be more complex -- and as far as I know, impossible. 1 Quote
xod Posted November 14, 2017 Author Posted November 14, 2017 Yes, it works very well, thanks for your help. Quote
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.