mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-05-25 10:12:25 +00:00
Use CSharpier
This commit is contained in:
@@ -2,6 +2,4 @@
|
||||
|
||||
namespace DiscordChatExporter.Gui.Behaviors;
|
||||
|
||||
public class ChannelMultiSelectionListBoxBehavior : MultiSelectionListBoxBehavior<Channel>
|
||||
{
|
||||
}
|
||||
public class ChannelMultiSelectionListBoxBehavior : MultiSelectionListBoxBehavior<Channel> { }
|
||||
|
||||
@@ -20,10 +20,14 @@ public class MultiSelectionListBoxBehavior<T> : Behavior<ListBox>
|
||||
)
|
||||
);
|
||||
|
||||
private static void OnSelectedItemsChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
|
||||
private static void OnSelectedItemsChanged(
|
||||
DependencyObject sender,
|
||||
DependencyPropertyChangedEventArgs args
|
||||
)
|
||||
{
|
||||
var behavior = (MultiSelectionListBoxBehavior<T>) sender;
|
||||
if (behavior._modelHandled) return;
|
||||
var behavior = (MultiSelectionListBoxBehavior<T>)sender;
|
||||
if (behavior._modelHandled)
|
||||
return;
|
||||
|
||||
if (behavior.AssociatedObject is null)
|
||||
return;
|
||||
@@ -38,7 +42,7 @@ public class MultiSelectionListBoxBehavior<T> : Behavior<ListBox>
|
||||
|
||||
public IList? SelectedItems
|
||||
{
|
||||
get => (IList?) GetValue(SelectedItemsProperty);
|
||||
get => (IList?)GetValue(SelectedItemsProperty);
|
||||
set => SetValue(SelectedItemsProperty, value);
|
||||
}
|
||||
|
||||
@@ -60,16 +64,20 @@ public class MultiSelectionListBoxBehavior<T> : Behavior<ListBox>
|
||||
// Propagate selected items from the view to the model
|
||||
private void OnListBoxSelectionChanged(object? sender, SelectionChangedEventArgs args)
|
||||
{
|
||||
if (_viewHandled) return;
|
||||
if (AssociatedObject.Items.SourceCollection is null) return;
|
||||
if (_viewHandled)
|
||||
return;
|
||||
if (AssociatedObject.Items.SourceCollection is null)
|
||||
return;
|
||||
|
||||
SelectedItems = AssociatedObject.SelectedItems.Cast<T>().ToArray();
|
||||
}
|
||||
|
||||
private void OnListBoxItemsChanged(object? sender, NotifyCollectionChangedEventArgs args)
|
||||
{
|
||||
if (_viewHandled) return;
|
||||
if (AssociatedObject.Items.SourceCollection is null) return;
|
||||
if (_viewHandled)
|
||||
return;
|
||||
if (AssociatedObject.Items.SourceCollection is null)
|
||||
return;
|
||||
SelectItems();
|
||||
}
|
||||
|
||||
@@ -78,7 +86,8 @@ public class MultiSelectionListBoxBehavior<T> : Behavior<ListBox>
|
||||
base.OnAttached();
|
||||
|
||||
AssociatedObject.SelectionChanged += OnListBoxSelectionChanged;
|
||||
((INotifyCollectionChanged) AssociatedObject.Items).CollectionChanged += OnListBoxItemsChanged;
|
||||
((INotifyCollectionChanged)AssociatedObject.Items).CollectionChanged +=
|
||||
OnListBoxItemsChanged;
|
||||
}
|
||||
|
||||
protected override void OnDetaching()
|
||||
@@ -88,7 +97,8 @@ public class MultiSelectionListBoxBehavior<T> : Behavior<ListBox>
|
||||
if (AssociatedObject is not null)
|
||||
{
|
||||
AssociatedObject.SelectionChanged -= OnListBoxSelectionChanged;
|
||||
((INotifyCollectionChanged) AssociatedObject.Items).CollectionChanged -= OnListBoxItemsChanged;
|
||||
((INotifyCollectionChanged)AssociatedObject.Items).CollectionChanged -=
|
||||
OnListBoxItemsChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user