Synthetic Management row default action (show ladder)
This commit is contained in:
1 parent
da2888eecc
commit
0201b01d34
2 files changed
+18
-2
No files matched your search
@@ -16,6 +16,12 @@
|
||||
GridLinesVisibility="None" ItemsSource="{Binding rows_view}"
|
||||
CurrentItem="{Binding current_row, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
>
|
||||
<DataGrid.RowStyle>
|
||||
<Style TargetType="DataGridRow">
|
||||
<Setter Property="u:AttachedCommands.DoubleClick" Value="{Binding show_ladder}"/>
|
||||
<Setter Property="u:AttachedCommands.Enter" Value="{Binding show_ladder}"/>
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn
|
||||
Header="Create Time" Binding="{Binding create_time}"
|
||||
|
||||
@@ -5,17 +5,20 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Windows.Input;
|
||||
using static bts.api.SecurityFormatter;
|
||||
using static bts.shell.SyntheticManagementWindowFactory;
|
||||
using static mbts.spark.DataGridColumnFilters;
|
||||
|
||||
namespace mbts.spark {
|
||||
class SyntheticManagementDialogVM : SecurityMDGrid<SyntheticManagementDialogVM.Row, (ExecutionStrategyImmutable? strategy, SecurityMD md)> {
|
||||
readonly IBus _bus;
|
||||
readonly OrdersModel _orders_model;
|
||||
|
||||
public SyntheticManagementDialogVM(IBus bus, OrdersModel orders_model) : this(bus, orders_model, null, null) { }
|
||||
public SyntheticManagementDialogVM(IBus bus, OrdersModel orders_model, IReadOnlyCollection<SortingCriteria> sorting, FilterStates filters)
|
||||
: base(orders_model.spreader.strategy_tuple.Select(map => map.Values), sorting) {
|
||||
_bus = bus;
|
||||
_orders_model = orders_model;
|
||||
if (filters != null) {
|
||||
create_time_filter.load_state(filters.create_time);
|
||||
@@ -27,7 +30,7 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
protected override Row row_factory((ExecutionStrategyImmutable? strategy, SecurityMD md) row_model) =>
|
||||
new Row(row_model.md, row_model.strategy, _orders_model);
|
||||
new Row(_bus, row_model.md, row_model.strategy, _orders_model);
|
||||
|
||||
protected override void on_row_removed(Row row) => row.Dispose();
|
||||
|
||||
@@ -54,10 +57,13 @@ namespace mbts.spark {
|
||||
new PartFormattingTuple(ContractParts.Symbol),
|
||||
new PartFormattingTuple(ContractParts.RawExp, "l")
|
||||
};
|
||||
|
||||
readonly IBus _bus;
|
||||
readonly ExecutionStrategyImmutable? _strategy;
|
||||
readonly Property<uint> _n_working_orders;
|
||||
|
||||
public Row(SecurityMD security_md, ExecutionStrategyImmutable? strategy, OrdersModel orders_model) : base(security_md) {
|
||||
public Row(IBus bus, SecurityMD security_md, ExecutionStrategyImmutable? strategy, OrdersModel orders_model) : base(security_md) {
|
||||
_bus = bus;
|
||||
_strategy = strategy;
|
||||
_n_working_orders = backing(nameof(n_working_orders),
|
||||
orders_model.on_security_orders(security_key)
|
||||
@@ -68,6 +74,7 @@ namespace mbts.spark {
|
||||
name = security.Synthetic.Name;
|
||||
n_legs = security.Synthetic.Legs.Count();
|
||||
description = Format(security, _desc_parts);
|
||||
show_ladder = new DelegateCommand(_show_ladder);
|
||||
}
|
||||
|
||||
public DateTime create_time => DateTime.MinValue; //TODO
|
||||
@@ -76,6 +83,9 @@ namespace mbts.spark {
|
||||
public string description { get; }
|
||||
public bool strategy_present => _strategy.HasValue;
|
||||
public uint n_working_orders => _n_working_orders.Value;
|
||||
public ICommand show_ladder { get; }
|
||||
|
||||
void _show_ladder() => _bus.post(SparkTags.ShowLadderTag, md);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user