Use CSharpier

This commit is contained in:
Tyrrrz
2023-08-22 21:17:19 +03:00
parent c410e745b1
commit 20f58963a6
174 changed files with 11084 additions and 10670 deletions

View File

@@ -2,6 +2,4 @@
namespace DiscordChatExporter.Gui.Behaviors;
public class ChannelMultiSelectionListBoxBehavior : MultiSelectionListBoxBehavior<Channel>
{
}
public class ChannelMultiSelectionListBoxBehavior : MultiSelectionListBoxBehavior<Channel> { }

View File

@@ -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;
}
}
}
}