Skip to content

Commit

Permalink
Fix property change notification
Browse files Browse the repository at this point in the history
  • Loading branch information
jurihock committed May 19, 2024
1 parent 87ab67e commit 714abea
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/Spectrality/Controls/NoteSelectorControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ public sealed partial class NoteSelectorControl : TemplatedControlBase
public int Octave
{
get => Get(ref octave);
set => SetAndNotify(ref octave, value).AlsoNotifyOthers();
set => SetAndNotify(ref octave, value).AlsoNotifyAll();
}

public string Note
{
get => Get(ref note);
set => SetAndNotify(ref note, value ?? note).AlsoNotifyOthers();
set => SetAndNotify(ref note, value ?? note).AlsoNotifyAll();
}

public double A4
{
get => Get(ref a4);
set => SetAndNotify(ref a4, value).AlsoNotifyOthers();
set => SetAndNotify(ref a4, value).AlsoNotifyAll();
}

public string NoteString => $"{Note}{Octave}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,12 @@ public PropertyChange AlsoNotify(params string[] propertyNames)
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public PropertyChange AlsoNotifyOthers()
public PropertyChange AlsoNotifyAll()
{
if (IsPropertyChanged)
{
foreach (var propertyName in PropertyOwner.DirectProperties.Keys)
{
if (propertyName == PropertyName)
{
continue;
}

PropertyOwner.DirectProperties[propertyName].Raise();
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Spectrality/Controls/TimespanSelectorControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public double? Begin
set
{
if (value is null) { return; }
SetAndNotify(ref begin, value).AlsoInvoke(OnChange).AlsoNotifyOthers();
SetAndNotify(ref begin, value).AlsoInvoke(OnChange).AlsoNotifyAll();
}
}

Expand All @@ -45,7 +45,7 @@ public double? End
set
{
if (value is null) { return; }
SetAndNotify(ref end, value).AlsoInvoke(OnChange).AlsoNotifyOthers();
SetAndNotify(ref end, value).AlsoInvoke(OnChange).AlsoNotifyAll();
}
}

Expand All @@ -59,14 +59,14 @@ public double? Length
set
{
if (value is null) { return; }
SetAndNotify(ref length, value).AlsoInvoke(OnChange).AlsoNotifyOthers();
SetAndNotify(ref length, value).AlsoInvoke(OnChange).AlsoNotifyAll();
}
}

public long Total
{
get => Get(ref total);
set => SetAndNotify(ref total, value).AlsoInvoke(OnChange).AlsoNotifyOthers();
set => SetAndNotify(ref total, value).AlsoInvoke(OnChange).AlsoNotifyAll();
}

private double? begin = 0, end = 0, length = 0;
Expand Down

0 comments on commit 714abea

Please sign in to comment.