/// <summary> /// Handles a change to a User record in the data model. /// </summary> /// <param name="sender">The object that originated the event.</param> /// <param name="userRowChangeEventArgs">The event arguments.</param> private void OnUserRowDeleted(Object sender, DataModel.UserRowChangeEventArgs userRowChangeEventArgs) { // This will delete the item from the list when it is deleted from the data model. if (userRowChangeEventArgs.Action == DataRowAction.Delete) { Int32 index = this.BinarySearch(userItem => userItem.UserId, userRowChangeEventArgs.Row.UserId); if (index >= 0) { this.RemoveAt(index); } } }
/// <summary> /// Handles a change to a User record in the data model. /// </summary> /// <param name="sender">The object that originated the event.</param> /// <param name="userRowChangeEventArgs">The event arguments.</param> private void OnUserRowChanged(Object sender, DataModel.UserRowChangeEventArgs userRowChangeEventArgs) { // We're only interested in additions and changes in this handler. if (userRowChangeEventArgs.Action == DataRowAction.Add || userRowChangeEventArgs.Action == DataRowAction.Change) { // If the item doesn't exist, it is added. If it exists, it's updated. Int32 index = this.BinarySearch(userItem => userItem.UserId, userRowChangeEventArgs.Row.UserId); if (index < 0) { this.Insert(~index, new UserItem(userRowChangeEventArgs.Row)); } else { this[index].Copy(userRowChangeEventArgs.Row); } } }
/// <summary> /// Handles a change to the DataModel.User table. /// </summary> /// <param name="sender">User that generated the event.</param> /// <param name="userRowChangeEvent">The event arguments.</param> void OnChangeUserRow(Object sender, DataModel.UserRowChangeEventArgs userRowChangeEvent) { // Update the entire collection when the user data changes. this.UpdateCollection(); }