fix mview sorting (use new ColumnSortManager)
This commit is contained in:
1 parent
c6c7350dad
commit
0ae61d3e82
2 files changed
+21
-19
No files matched your search
@@ -54,7 +54,7 @@ namespace mbts.spark {
|
||||
readonly Property<Row> _current_row;
|
||||
readonly DeferrableActionWrapper _refresh_filter;
|
||||
Func<Row, bool> _filter;
|
||||
IReadOnlyList<(Columns key, ListSortDirection direction)> _sorting_hierarchy;
|
||||
IComparer<Row> _comparer;
|
||||
Color _selection_highlight;
|
||||
|
||||
/// <summary>
|
||||
@@ -72,7 +72,6 @@ namespace mbts.spark {
|
||||
_bus = bus;
|
||||
_orders_model = orders_model;
|
||||
security_filter = new RegexFilterVM<Row>(r => r.security.ToString(), nameof(Row.security));
|
||||
comparer = DIYGridSortHelper.build_comparer(sorting_hierarchy, get_column_comparer, Columns.Security);
|
||||
// rows
|
||||
_wrapped_rows = _rows.WrapSelector(r => r.security_md, s => {
|
||||
var r = new Row(_bus, s, _orders_model);
|
||||
@@ -346,18 +345,6 @@ namespace mbts.spark {
|
||||
internal IBus bus => _bus;
|
||||
internal OrdersModel orders_model => _orders_model;
|
||||
|
||||
public IReadOnlyList<(Columns key, ListSortDirection direction)> sorting_hierarchy {
|
||||
get => _sorting_hierarchy ?? (_sorting_hierarchy = Array.Empty<(Columns, ListSortDirection)>());
|
||||
set {
|
||||
_sorting_hierarchy = value;
|
||||
comparer = DIYGridSortHelper.build_comparer(value, get_column_comparer, Columns.SecurityKey);
|
||||
DIYGridSortHelper.reset_sorting(columns, value);
|
||||
_rows_view.CustomSort = comparer.to_non_generic();
|
||||
}
|
||||
}
|
||||
|
||||
public IComparer<Row> comparer { get; private set; }
|
||||
|
||||
public IDataGridColumnPersistentFilter<Row, string> security_filter { get; }
|
||||
public IDataGridColumnPersistentFilter<Row, DoubleMinMaxState> bid_price_filter { get; } = new DoubleMinMax<Row>(r => r.bid_price, nameof(Row.bid_price));
|
||||
public IDataGridColumnPersistentFilter<Row, UIntMinMaxState> bid_merged_size_filter { get; } = new UIntMinMax<Row>(r => r.bid_merged_size, nameof(Row.bid_merged_size));
|
||||
@@ -426,6 +413,11 @@ namespace mbts.spark {
|
||||
Comparer<T>.Default.wrap(selector);
|
||||
}
|
||||
|
||||
public IComparer<Row> comparer {
|
||||
get => _comparer;
|
||||
set => _rows_view.CustomSort = (_comparer = value)?.to_non_generic();
|
||||
}
|
||||
|
||||
public (FillsVM vm, string context, string title, Color fg) fills_params(IEnumerable<SecurityImmutable> securities, Columns column) {
|
||||
var (title_desc, fg) = _fills_title(column);
|
||||
var state = StartupData.DefaultAuxiliaryFills;
|
||||
|
||||
@@ -10,6 +10,7 @@ using bts.view;
|
||||
|
||||
using mbts.persist;
|
||||
using mbts.ui;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.settings;
|
||||
using mbts.ui.spark;
|
||||
using mbts.ui.utility;
|
||||
@@ -18,6 +19,7 @@ using mbts.utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
@@ -37,6 +39,8 @@ namespace mbts.spark {
|
||||
readonly OrdersModel _orders_model;
|
||||
readonly AllowOnce _init_guard = new AllowOnce("MarketView");
|
||||
readonly IWindowSettingsManager<GridSettings> _settings_manager;
|
||||
|
||||
List<SortingCriteria> _current_sorting_criteria;
|
||||
MarketViewVM _vm;
|
||||
MarketViewView _view;
|
||||
MarketViewWindowFactory.StartupData _state;
|
||||
@@ -70,10 +74,7 @@ namespace mbts.spark {
|
||||
_state.security_criteria,
|
||||
_vm.get_filter_states(),
|
||||
_settings_manager.instance_settings,
|
||||
_vm.sorting_hierarchy.Select(tup => new SortingCriteria(tup.key.ToString(), tup.direction == System.ComponentModel.ListSortDirection.Ascending))
|
||||
.ToList()) {
|
||||
menu_display = _menu_display_vm.safe_create()
|
||||
};
|
||||
_current_sorting_criteria);
|
||||
|
||||
public override double MinWidth => MarketViewWindowFactory.StartupData.DefaultGridSettings.columns.Where(c => c.is_visible).Sum(gcs => gcs.width)
|
||||
+ SPARK_MENU_COLLAPSED_WIDTH
|
||||
@@ -118,7 +119,11 @@ namespace mbts.spark {
|
||||
.Table(SecurityMD.key_fn)
|
||||
.Where(t => t.has_changes())
|
||||
.OnDispatcher());
|
||||
var sort_man = new ColumnSortManager(_vm.columns, MarketViewView.Columns.Security.ToString());
|
||||
_current_sorting_criteria = _state.sorting_criterion.ToList();
|
||||
sort_man.SortingCriteria = _state.sorting_criterion;
|
||||
_vm.load_filters(_state.filters);
|
||||
_vm.comparer = sort_man.BuildComparer<MarketViewView.Columns, MarketViewVM.Row>(MarketViewVM.get_column_comparer);
|
||||
_view = new MarketViewView { DataContext = _vm };
|
||||
_view._grid.Sorting += on_grid_sorting;
|
||||
_grid_settings_manager = new SimpleGridSettingsManager<MarketViewVM.Row>(_vm.columns, _col_settings_flags, _vm.rows);
|
||||
@@ -226,8 +231,13 @@ namespace mbts.spark {
|
||||
show_ticket_cmd.RaiseCanExecuteChanged();
|
||||
}
|
||||
|
||||
void on_grid_sorting(object sender, ui.controls.DIYGridSortingEventArgs e) =>
|
||||
void on_grid_sorting(object sender, ui.controls.DIYGridSortingEventArgs e) {
|
||||
_sorted_selected_security_criteria_backing = null;
|
||||
sort_man.OnColumnClick(e.Column, KeyboardExtensions.IsShiftDown());
|
||||
_vm.comparer = sort_man.BuildComparer<MarketViewView.Columns, MarketViewVM.Row>(MarketViewVM.get_column_comparer);
|
||||
_current_sorting_criteria = sort_man.SortingCriteria.ToList();
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnParentViewCreated(SparkWindowView parent_view) =>
|
||||
|
||||
Reference in new issue
Block a user