protected void RaisePropertyChanged(string propertyName) { try { if (m_disposed) { return; } EventInvoker.BeginInvokeIfRequired(t => { try { PropertyChanged.Fire(this, propertyName); } catch (Exception e) { Debug.WriteLine(e); } }); } catch (ObjectDisposedException) { // if the Form to which we're sending a message is disposed, // this gets thrown but can safely be ignored } catch (Exception ex) { // TODO: log this } }
/// <summary> /// Explicity fire the property changed event. /// </summary> public void FirePropertyChangedEvent(IEntity record, string columnName, object val, object oldVal) { PropertyChanged.Fire(record, new ModelPropertyChangedEventArgs() { FieldName = columnName, Value = val, OldValue = oldVal }); }
// TODO: Get rid of this for programmatic calls, instead the model's property setter should fire the property change event. /// <summary> /// Called from the ModelTable.Table_ColumnChanged event handler. /// Also called when the model field is programmatically changed via the model's call to UpdateTableRowField. /// The programmatic implementation is a workaround to get the change event to fire when the model field is changed. /// </summary> public void UpdateRecordField(IEntity record, string columnName, object val) { PropertyInfo pi = record.GetType().GetProperty(columnName); object oldVal = pi.GetValue(record); // TODO: Is this test for oldValue != newValue nececssary anymore??? // TODO: CAN PROBABLY BE REMOVED NOW THAT WE HAVE THE MODEL MANAGER SETTING THE PROGRAMMATIC FLAG. // Prevents infinite recursion by updating the model only when the field has changed. // Otherwise, programmatically setting a field calls UpdateRowField, which changes the table's field, // which fires the ModelTable.Table_ColumnChanged event. This then calls back here, creating an infinite loop. if (((oldVal == null) && (val != DBNull.Value)) || ((oldVal != null) && (!oldVal.Equals(val)))) { pi.SetValue(record, DbNullConverter(val)); // We always want this event to fire, whether the change was done in the DataGridView or programmatically. // TODO: Should the event fire only when the value hasn't changed? // Apparently so, otherwise we can get continuous calls to UpdateRecordField by the app. PropertyChanged.Fire(record, new ModelPropertyChangedEventArgs() { FieldName = columnName, Value = val, OldValue = oldVal }); } }
/// <summary> /// Settings in this object have been modified /// </summary> void IModifiable.OnModified() { if (Route != null) { Route.OnModified(); } PropertyChanged.Fire(this); }
protected virtual void NotifyPropertyChanged(IEnumerable <string> propertyNames) { PropertyChanged.Fire(this, propertyNames); }
protected virtual void NotifyPropertyChanged(params string[] propertyNames) { PropertyChanged.Fire(this, propertyNames); }
protected virtual void NotifyPropertyChanged(string propertyName) { PropertyChanged.Fire(this, propertyName); }
/// <summary> /// Fire the PropertyChanged event. /// </summary> protected void OnPropertyChanged() { PropertyChanged.Fire(this); }