RQ Overlay: оверлей заработка и статистики для Royal Quest
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
51
src/RQOverlay/Views/MobsSessionView.xaml.cs
Normal file
51
src/RQOverlay/Views/MobsSessionView.xaml.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
using RQOverlay.Plugins.Builtin;
|
||||
|
||||
namespace RQOverlay.Views;
|
||||
|
||||
public partial class MobsSessionView : UserControl
|
||||
{
|
||||
ListCollectionView? _view;
|
||||
|
||||
public MobsSessionView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// Только мобы, убитые в этой сессии; больше всего убийств — сверху. Всё обновляется на лету.
|
||||
DataContextChanged += (_, _) =>
|
||||
{
|
||||
if (DataContext is not MobStatsPlugin plugin) return;
|
||||
|
||||
_view = new ListCollectionView(plugin.Rows) { Filter = o => ((MobStat)o).SessionKills > 0 };
|
||||
_view.SortDescriptions.Add(new SortDescription(nameof(MobStat.SessionKills), ListSortDirection.Descending));
|
||||
_view.IsLiveFiltering = true;
|
||||
_view.LiveFilteringProperties.Add(nameof(MobStat.SessionKills));
|
||||
_view.IsLiveSorting = true;
|
||||
_view.LiveSortingProperties.Add(nameof(MobStat.SessionKills));
|
||||
((INotifyCollectionChanged)_view).CollectionChanged += (_, _) => UpdateEmpty();
|
||||
|
||||
MobGrid.ItemsSource = _view;
|
||||
UpdateEmpty();
|
||||
};
|
||||
}
|
||||
|
||||
void UpdateEmpty()
|
||||
{
|
||||
bool empty = _view is null || _view.Count == 0;
|
||||
Empty.Visibility = empty ? Visibility.Visible : Visibility.Collapsed;
|
||||
Table.Visibility = empty ? Visibility.Collapsed : Visibility.Visible;
|
||||
}
|
||||
|
||||
/// <summary>Таблица стоит внутри прокручиваемой страницы — колесо мыши передаём странице.</summary>
|
||||
void Grid_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
var copy = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta) { RoutedEvent = MouseWheelEvent, Source = sender };
|
||||
((UIElement)((FrameworkElement)sender).Parent).RaiseEvent(copy);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user