post-refactor clean up
This commit is contained in:
parent
a89b07394f
commit
801e154d15
@ -6,7 +6,7 @@ namespace LibationWinForms
|
||||
{
|
||||
public abstract class AsyncNotifyPropertyChanged : SynchronizeInvoker, INotifyPropertyChanged
|
||||
{
|
||||
// see also notes in Libation/Source/__ARCHITECTURE NOTES.txt :: MVVM
|
||||
// see also notes in Libation/Source/_ARCHITECTURE NOTES.txt :: MVVM
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
// per standard INotifyPropertyChanged pattern:
|
||||
|
||||
@ -76,9 +76,6 @@ namespace LibationWinForms
|
||||
}
|
||||
#endregion
|
||||
|
||||
public event EventHandler LibraryBookUpdated;
|
||||
public event EventHandler Committed;
|
||||
|
||||
// alias
|
||||
private Book Book => LibraryBook.Book;
|
||||
|
||||
@ -125,9 +122,6 @@ namespace LibationWinForms
|
||||
}
|
||||
|
||||
UserDefinedItem.ItemChanged += UserDefinedItem_ItemChanged;
|
||||
|
||||
// this will never have a value when triggered by ctor b/c nothing can subscribe to the event until after ctor is complete
|
||||
LibraryBookUpdated?.Invoke(this, null);
|
||||
}
|
||||
|
||||
private void PictureStorage_PictureCached(object sender, PictureCachedEventArgs e)
|
||||
@ -189,9 +183,6 @@ namespace LibationWinForms
|
||||
Book.UserDefinedItem.BookStatus = bookStatus;
|
||||
Book.UserDefinedItem.PdfStatus = pdfStatus;
|
||||
LibraryCommands.UpdateUserDefinedItem(Book);
|
||||
|
||||
// notify
|
||||
Committed?.Invoke(this, null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -9,6 +9,5 @@ see also: https://docs.microsoft.com/en-us/dotnet/desktop/winforms/controls/rais
|
||||
BindingSource + INotifyPropertyChanged + DataGridView is the backbone of our implementation. The SortableBindingList (BindingList/BindingSource) automatically subscribes to each entry's NotifyPropertyChanged -- which is why our AsyncNotifyPropertyChanged.NotifyPropertyChanged is needed even though none of our code calls it.
|
||||
|
||||
- Adding or removing an entry to/from this BindingSource automatically updates the UI. No additional code needed.
|
||||
- Updating a field updates the UI via calling NotifyPropertyChanged.
|
||||
|
||||
We break the pattern with updating the book inside of GridEntry. To really follow MVVM, iterate through every bound ("binded"?) field name and call NotifyPropertyChanged. It's much more convenient, quicker, and less error prone to make an exception to MVVM via GridEntry.LibraryBookUpdated => InvalidateRow. The downside is that the view has to wire this up. If we change where in the code we can update the book inside of GridEntry, this dependency will also need to be duplicated in the new place
|
||||
- Calling NotifyPropertyChanged with the name of a field updates that field in the UI
|
||||
- Calling NotifyPropertyChanged without a field name (or with an invalid field name) updates the whole entry in the UI
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user