fix: Remove item from vis series when removed from series
This commit is contained in:
1 parent
527cea74d3
commit
ffdd0fcff7
2 files changed
+16
-5
No files matched your search
@@ -2,9 +2,12 @@ using System;
|
||||
using System.Collections;
|
||||
|
||||
static class SelectAllToggle {
|
||||
public static bool? is_all_selected(int num_total, int num_selected) {
|
||||
public static bool? is_all_selected(int num_total, int num_selected, bool require_valid = false) {
|
||||
if (num_selected > num_total) {
|
||||
throw new ArgumentException($"{nameof(num_selected)} is greater than {nameof(num_total)}", nameof(num_selected));
|
||||
if (require_valid) {
|
||||
throw new ArgumentException($"{nameof(num_selected)} is greater than {nameof(num_total)}", nameof(num_selected));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return num_total switch {
|
||||
0 => null,
|
||||
|
||||
@@ -23,12 +23,20 @@ namespace mbts.spark {
|
||||
public SeriesSetVM(object id = null) {
|
||||
this.id = id;
|
||||
_raise_visible_series_changed = new(() => visible_series_changed?.Invoke(_visible_series));
|
||||
_dispose = ObservableAutoWrapper.connect_item_hooks(series, s => {
|
||||
_dispose = ObservableAutoWrapper.connect_item_hooks(series, connect_series);
|
||||
|
||||
IDisposable connect_series(SeriesVM s) {
|
||||
s.is_visible_changed += on_is_visible_changed;
|
||||
if (s.is_visible) {
|
||||
on_is_visible_changed(true);
|
||||
}
|
||||
return Disposable.Create(() => s.is_visible_changed -= on_is_visible_changed);
|
||||
return Disposable.Create(() => {
|
||||
if (s.is_visible) {
|
||||
on_is_visible_changed(false);
|
||||
}
|
||||
s.is_visible_changed -= on_is_visible_changed;
|
||||
});
|
||||
|
||||
void on_is_visible_changed(bool value) {
|
||||
int count_before = _visible_series.Count;
|
||||
_visible_series = value ? _visible_series.Add(s) : _visible_series.Remove(s);
|
||||
@@ -39,7 +47,7 @@ namespace mbts.spark {
|
||||
RaisePropertyChanged(nameof(is_visible));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public event Action<ImmutableHashSet<SeriesVM>> visible_series_changed;
|
||||
|
||||
Reference in new issue
Block a user