Jump to content

How to apply the IndirectUI rules correctly?


ReMake

Recommended Posts

@midora thanks for the clarification.

 

2 hours ago, midora said:

            List<PropertyCollectionRule> propRules = new List<PropertyCollectionRule>()
            {
                new ReadOnlyBoundToBooleanRule(PropertyNames.Mode, PropertyNames.Gray, false),
                new ReadOnlyBoundToNameValuesRule(PropertyNames.CustomColor, false,
                        (PropertyNames.Gray, true),
                        (PropertyNames.Mode, ModeOptions.None),
                        (PropertyNames.Mode, ModeOptions.Primary),
                        (PropertyNames.Mode, ModeOptions.Secondary)
                ),
            };

 

Unfortunately, this does not work, because your proposed version of writing the rule is equivalent to this:

 

List<PropertyCollectionRule> propRules = new List<PropertyCollectionRule>()
{
    new ReadOnlyBoundToBooleanRule(PropertyNames.Mode, PropertyNames.Gray, true),
    new ReadOnlyBoundToNameValuesRule(PropertyNames.CustomColor, true,
             (PropertyNames.Gray, false),
             (PropertyNames.Mode, ModeOptions.CustomColor)),
};

 

The color wheel is still always active.

Link to comment
Share on other sites

4 hours ago, ReMake said:

Unfortunately, this does not work, because your proposed version of writing the rule is equivalent to this

 

Midora is, of course correct. You need to apply De Morgan's Law: negating a logical expression consisting of ORed terms produces an expression where the negated terms are ANDed. So your version will disable the control only if all the listed conditions are false. You want to disable the control if ANY of the conditions are false. Since there's no direct way to do this, you must instead list all the conditions for which you want the control disabled.

 

I'll put in another plug for my three-tuple idea: A nice feature would be to also allow an array of three-tuples consisting of two objects (the control and value) and a boolean. If the boolean were true, the condition would hold if the control matched the value; if the boolean were false, the condition would hold if the control didn't match the value.

  • Upvote 2
Link to comment
Share on other sites

4 hours ago, ReMake said:

Unfortunately, this does not work, because your proposed version of writing the rule is equivalent to this:

 

@midora, I take back my words. Yes, these two expressions are not equivalent. Your code works flawlessly. I looked it over carefully and fixed my code a bit. Now my code works too.

 

Thank you for your efforts and your time spent.

Link to comment
Share on other sites

@ReMakeGlad you figured it out.

One of the reasons doing OBL years ago was that I had to manage complex conditions which I couldn't handle in PropertyBased plugins. It's much easier to subscribe to value changed events and check conditions but for sure more error prone. So you need a little bit experience.

midoras signature.gif

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...