/// <summary> /// Handles change events from own data properties. /// Raises modification state change if a property value has changed. /// </summary> /// <param name="sender">Property that send the event.</param> /// <param name="e">The property change event.</param> protected virtual void OnDataPropertyChange(object sender, PropertyChangeEventArgs e) { if (e.Change.IncludesValue()) { OnPropertyChanged(new PropertyChangedEventArgs(nameof(Modified))); } }
/// <summary> /// A callback that validates the property when it stops being edited. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The callback arguments.</param> protected void ValidateOnStopEditing(object sender, PropertyChangeEventArgs args) { if (this == sender && args.Change.IncludesEditing() && !Editing) { Validate(); } }
private void Recompute(object sender, PropertyChangeEventArgs e) { if (!e.IsAsync && sender is BaseProperty bp && properties.TryGetValue(bp, out PropertyChange chg) && e.Change.IncludesChanges(chg)) { Update(e.Row); } }
private async Task RecomputeAsync(object sender, PropertyChangeEventArgs e, CancellationToken token) { if (e.IsAsync && sender is BaseProperty bp && properties.TryGetValue(bp, out PropertyChange chg) && e.Change.IncludesChanges(chg)) { await UpdateAsync(e.Row, token); } }
/// <summary> /// Listens to the property change events and updates the framework element accordingly. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Property change event arguments.</param> protected virtual void OnPropertyChange(object sender, PropertyChangeEventArgs e) { if (property == sender && !PreventElementUpdate) { bool b = PreventModelUpdate; PreventModelUpdate = true; UpdateElement(e.Change); PreventModelUpdate = b; } }
/// <summary> /// Fires a property change event recursively through all properties and child objects. /// </summary> /// <param name="args">Property change event arguments.</param> protected void FireDataPropertyChange(PropertyChangeEventArgs args) { foreach (DataProperty p in properties.Values) { p.FirePropertyChange(args); } foreach (DataObject obj in childObjects.Values) { obj.FireDataPropertyChange(args); } }
public void OnCustomerChanged(object sender, PropertyChangeEventArgs e) { if (!e.Change.IncludesValue() || DataProperty.Equals(e.OldValue, e.NewValue) || customer.PersonIdProperty.Value == null && customer.StoreIdProperty.Value == null) return; LoadCache(Enumerations.BusinessEntityAddress.EnumName, delegate (LookupTable tbl) { UpdateProperty(tbl, customer.BillingAddressObject.AddressIdProperty); UpdateProperty(tbl, customer.ShippingAddressObject.AddressIdProperty); }); }
private void OnCreditCardChanged(object sender, PropertyChangeEventArgs e) { if (e.Change.IncludesValue() && !DataProperty.Equals(e.OldValue, e.NewValue)) { Header cc = CreditCardIdProperty.Value; CardNumberProperty.SetValue(cc == null ? null : cc[Enumerations.PersonCreditCard.Attributes.CardNumber]); ExpirationProperty.SetValue(cc == null ? null : cc[Enumerations.PersonCreditCard.Attributes.ExpMonth] + "/" + cc[Enumerations.PersonCreditCard.Attributes.ExpYear]); } }
private void OnAddressChanged(object sender, PropertyChangeEventArgs e) { if (!e.Change.IncludesValue() || DataProperty.Equals(e.OldValue, e.NewValue)) return; Header h = AddressIdProperty.Value; AddressLine1Property.SetValue(h == null ? null : h[Enumerations.BusinessEntityAddress.Attributes.AddressLine1]); AddressLine2Property.SetValue(h == null ? null : h[Enumerations.BusinessEntityAddress.Attributes.AddressLine2]); CityStateProperty.SetValue(h == null ? null : h[Enumerations.BusinessEntityAddress.Attributes.City] + ", " + h[Enumerations.BusinessEntityAddress.Attributes.State]); PostalCodeProperty.SetValue(h == null ? null : h[Enumerations.BusinessEntityAddress.Attributes.PostalCode]); CountryProperty.SetValue(h == null ? null : h[Enumerations.BusinessEntityAddress.Attributes.Country]); }
/// <inheritdoc/> /// Overridden to update elements in a thread-safe manner. protected override void OnPropertyChange(object sender, PropertyChangeEventArgs e) { if (property == sender && !PreventElementUpdate) { element.Dispatcher.InvokeAsync(async() => { bool b = PreventModelUpdate; PreventModelUpdate = true; await UpdateElementAsync(e.Change); PreventModelUpdate = b; }); } }
public void OnCustomerPersonChanged(object sender, PropertyChangeEventArgs e) { if (!e.Change.IncludesValue() || DataProperty.Equals(e.OldValue, e.NewValue) || salesOrder.CustomerObject.PersonIdProperty.Value == null) return; LoadCache(Enumerations.PersonCreditCard.EnumName, delegate (LookupTable tbl) { EnumProperty p = salesOrder.PaymentObject.CreditCardObject.CreditCardIdProperty; p.SetValue(null); p.LocalLookupTable = tbl; p.FirePropertyChange(new PropertyChangeEventArgs(PropertyChange.Items, null, null)); }); }
/// <summary> /// Fires a property change event recursively through all properties and child objects. /// </summary> /// <param name="args">Property change event arguments.</param> protected void FireDataPropertyChange(PropertyChangeEventArgs args) { foreach (DataProperty p in properties.Values) { p.FirePropertyChange(args); } foreach (ActionProperty a in actions.Values) { a.FirePropertyChange(args); } foreach (DataObject obj in childObjects.Values) { obj.FireDataPropertyChange(args); } if (args.Change.IncludesEditable()) { OnPropertyChanged(new PropertyChangedEventArgs(nameof(Editable))); } }
/// <summary> /// Fires a property change event recursively through all properties and child objects. /// </summary> /// <param name="args">Property change event arguments.</param> public void FirePropertyChange(PropertyChangeEventArgs args) { foreach (DataProperty p in properties.Values) p.FirePropertyChange(args); foreach (IDataObject obj in childObjects.Values) obj.FirePropertyChange(args); }
/// <summary> /// A callback that validates the property when it stops being edited. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The callback arguments.</param> protected void ValidateOnStopEditing(object sender, PropertyChangeEventArgs args) { if (this == sender && args.Change.IncludesEditing() && !Editing) Validate(); }
/// <summary> /// A method to fire a property change event. /// If certain property information is calculated and depends on the factors /// that are outside of the property's control (e.g. editability), /// then this method may need to be called from outside to fire a property change event /// if certain conditions that affect the calculated value have changed. /// </summary> /// <param name="args">Property change event arguments.</param> public void FirePropertyChange(PropertyChangeEventArgs args) { Change?.Invoke(this, args); }