Esempio n. 1
0
 public DependentCollection(Func <IEnumerable <T> > getMethod)
 {
     _getMethod                  = getMethod;
     _depCollection              = new Dependent(OnUpdateCollection);
     _depCollection.Invalidated += () => UpdateScheduler.ScheduleUpdate(this);
     _depCollection.Touch();
 }
 public ObjectPropertyAtom(IObjectInstance objectInstance, ClassProperty classProperty)
     : base(objectInstance, classProperty)
 {
     if (ClassProperty.CanRead)
     {
         // When the property is out of date, update it from the wrapped object.
         _depProperty = new Dependent(delegate
         {
             object value = ClassProperty.GetObjectValue(ObjectInstance.WrappedObject);
             value        = TranslateOutgoingValue(value);
             if (!Object.Equals(_value, value))
             {
                 _value = value;
             }
             if (_firePropertyChanged)
             {
                 ObjectInstance.FirePropertyChanged(ClassProperty.Name);
             }
             _firePropertyChanged = true;
         });
         // When the property becomes out of date, trigger an update.
         // The update should have lower priority than user input & drawing,
         // to ensure that the app doesn't lock up in case a large model is
         // being updated outside the UI (e.g. via timers or the network).
         _depProperty.Invalidated += () => UpdateScheduler.ScheduleUpdate(this);
     }
 }
Esempio n. 3
0
 private void Invalidated()
 {
     // When the "can execute" flag is invalidated, we need to queue
     // up a call to update it. This will cause the UI thread to
     // call TriggerUpdate (below) when everything settles down.
     UpdateScheduler.ScheduleUpdate(this);
 }
Esempio n. 4
0
 public ComputedCollection(Func <IEnumerable <T> > getMethod)
 {
     _getMethod                  = getMethod;
     _depCollection              = new Computed(OnUpdateCollection);
     _depCollection.Invalidated += () => UpdateScheduler.ScheduleUpdate(UpdateNow);
     _depCollection.Touch();
 }
Esempio n. 5
0
 private void Computed_Invalidated()
 {
     UpdateScheduler.ScheduleUpdate(delegate()
     {
         _priorState = _update(_priorState);
     });
 }
Esempio n. 6
0
 public Tree()
 {
     _depNodes = new Dependent(delegate
     {
         _root.UpdateNodes();
     });
     _depNodes.Invalidated += () => UpdateScheduler.ScheduleUpdate(this);
 }
Esempio n. 7
0
 public Tree()
 {
     _depNodes = new Computed(delegate
     {
         _root.UpdateNodes();
     });
     _depNodes.Invalidated += () => UpdateScheduler.ScheduleUpdate(UpdateNow);
 }
Esempio n. 8
0
 public MethodCommand(object instance, CommandMeta meta)
 {
     Instance = instance;
     Meta     = meta;
     if (meta.Condition != null)
     {
         _computedCan              = new Computed <bool>(() => (bool)meta.Condition.GetValue(Instance));
         _computedCan.Invalidated += () => UpdateScheduler.ScheduleUpdate(UpdateNow);
     }
 }
Esempio n. 9
0
        public static Dependent WhenNecessary(Action updateMethod)
        {
            var    dependent = new Dependent(updateMethod);
            Update update    = new Update(dependent);

            dependent.Invalidated += delegate
            {
                UpdateScheduler.ScheduleUpdate(update);
            };
            dependent.OnGet();
            return(dependent);
        }
Esempio n. 10
0
 public ObjectPropertyAtom(IObjectInstance objectInstance, ClassMember classProperty)
     : base(objectInstance, classProperty)
 {
     if (ClassProperty.CanRead)
     {
         // When the property is out of date, update it from the wrapped object.
         _depProperty = new Dependent(() => BindingInterceptor.Current.UpdateValue(this));
         // When the property becomes out of date, trigger an update.
         // The update should have lower priority than user input & drawing,
         // to ensure that the app doesn't lock up in case a large model is
         // being updated outside the UI (e.g. via timers or the network).
         _depProperty.Invalidated += () => UpdateScheduler.ScheduleUpdate(this);
     }
 }
Esempio n. 11
0
 protected MemberSlot(ViewProxy proxy, MemberMeta member)
 {
     Proxy  = proxy;
     Member = member;
     if (member.CanRead)
     {
         // When the property is out of date, update it from the wrapped object.
         _computed = new Computed(() => BindingInterceptor.Current.UpdateValue(this));
         // When the property becomes out of date, trigger an update.
         // The update should have lower priority than user input & drawing,
         // to ensure that the app doesn't lock up in case a large model is
         // being updated outside the UI (e.g. via timers or the network).
         _computed.Invalidated += () => UpdateScheduler.ScheduleUpdate(UpdateNow);
     }
 }
Esempio n. 12
0
 public ObjectPropertyAtom(IObjectInstance objectInstance, ClassProperty classProperty)
     : base(objectInstance, classProperty)
 {
     if (ClassProperty.CanRead)
     {
         // When the property is out of date, update it from the wrapped object.
         _depProperty = new Computed(delegate
         {
             object value = ClassProperty.GetObjectValue(ObjectInstance.WrappedObject);
             value        = TranslateOutgoingValue(value);
             if (!Object.Equals(_value, value))
             {
                 _value = value;
             }
             if (_firePropertyChanged)
             {
                 ObjectInstance.FirePropertyChanged(ClassProperty.Name);
             }
             _firePropertyChanged = true;
         });
         // When the property becomes out of date, trigger an update.
         _depProperty.Invalidated += () => UpdateScheduler.ScheduleUpdate(UpdateNow);
     }
 }
Esempio n. 13
0
 public ComputedAtom(Action firePropertyChanged, Func <T> getMethod)
 {
     _firePropertyChanged   = firePropertyChanged;
     _depValue              = new Computed(() => _value = getMethod());
     _depValue.Invalidated += () => UpdateScheduler.ScheduleUpdate(UpdateNow);
 }
 public ViewModelContainer(Action firePropertyChanged, Func <object> constructor)
 {
     _firePropertyChanged   = firePropertyChanged;
     _computed              = new Computed(() => _viewModel = ForView.Wrap(constructor()));
     _computed.Invalidated += () => UpdateScheduler.ScheduleUpdate(UpdateNow);
 }
Esempio n. 15
0
 public DependentAtom(Action firePropertyChanged, Func <T> getMethod)
 {
     _firePropertyChanged   = firePropertyChanged;
     _depValue              = new Dependent(() => _value = getMethod());
     _depValue.Invalidated += () => UpdateScheduler.ScheduleUpdate(this);
 }
Esempio n. 16
0
 private void Computed_Invalidated()
 {
     UpdateScheduler.ScheduleUpdate(_update);
 }
Esempio n. 17
0
 private void ValueInvalidated()
 {
     UpdateScheduler.ScheduleUpdate(this);
 }
Esempio n. 18
0
 public ViewModelContainer(Action firePropertyChanged, Func <object> constructor)
 {
     _firePropertyChanged    = firePropertyChanged;
     _dependent              = new Dependent(() => _viewModel = ForView.Wrap(constructor()));
     _dependent.Invalidated += () => UpdateScheduler.ScheduleUpdate(this);
 }