コード例 #1
0
 public static void SetRestrictor(this IProperty child, int min, IProperty max)
 {
     child.Restrictor = val =>
     {
         if (val < min)
             return min;
         int finalValue = max.FinalValue;
         if (val > finalValue)
             return finalValue;
         return val;
     };
     EventListener el_invalid = () => child.Invalidate();
     EventListener el_remove = null;
     el_remove = () =>
     {
         max.RemoveInvalidationListener(el_invalid);
         child.RestrictorChangedListener -= el_remove;
     };
     child.RestrictorChangedListener += el_remove;
     max.AddInvalidationListener(el_invalid);
 }