From d8ed402779e20483c2d32efed137f1ae20d68aed Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 20 May 2019 14:47:46 +0900 Subject: [PATCH] Make use of ValueChanged.OldValue --- .../Components/TournamentBeatmapPanel.cs | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs b/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs index 8ab0dc2459..818d25d559 100644 --- a/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs +++ b/osu.Game.Tournament/Components/TournamentBeatmapPanel.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using System; -using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Linq; using osu.Framework.Allocation; @@ -146,10 +145,15 @@ namespace osu.Game.Tournament.Components private void matchChanged(ValueChangedEvent pairing) { + if (pairing.OldValue != null) + pairing.OldValue.PicksBans.CollectionChanged -= picksBansOnCollectionChanged; pairing.NewValue.PicksBans.CollectionChanged += picksBansOnCollectionChanged; updateState(); } + private void picksBansOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) + => updateState(); + private BeatmapChoice choice; private void updateState() @@ -197,19 +201,5 @@ namespace osu.Game.Tournament.Components Alpha = 1; } } - - private void picksBansOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { - var list = (ObservableCollection)sender; - - if (sender != currentMatch.Value.PicksBans) - { - // todo: we need a last attribute in bindable valuechanged events badly. - list.CollectionChanged -= picksBansOnCollectionChanged; - return; - } - - updateState(); - } } }