fix: Bind pnl account col to AccountTuple

Bugs (fixed):
  * The group-row pnl cell hyperlinks don't open anything when clicked

  Cause: An InvalidCastException is thrown when the code that creates the fills
  vm (for the popup) casts 'PNLRowCollectionViewGroup.Name' to an AccountTuple,
  as said 'Name' member is bound to the 'account_name' (of type string).
This commit is contained in:
John Colvin committed 2022-08-01 11:14:29 -04:00
1 parent 505cd37225
commit 960a618fe1
4 files changed
+8 -5

No files matched your search

@@ -286,6 +286,7 @@ namespace bts.shell.pnl {
AskLTESettle = Ask | Settle | 1 << 7
}
public AccountTuple account => new(account_id, account_name);
public string symbol => security?.pnl_symbol() ?? string.Empty;
public double effective_cpp => override_cpp ?? default_cpp;
@@ -36,7 +36,7 @@ namespace bts.shell.pnl {
_animator = new PNLCellEmbeddedAnimationModel<PNLRowData>(default_appearances, triggers);
_animator.on_row(data);
pnl_price = _cell_map.add_price_double(ColumnKeys.PNLPrice, d => d.pnl_price);
account_name_cell = _cell_map.add(ColumnKeys.Account, d => d.account_name);
account_cell = _cell_map.add(ColumnKeys.Account, d => d.account);
security_type_cell = _cell_map.add(ColumnKeys.SecurityType, d => d.security?.ContractCase ?? Security.ContractOneofCase.None);
exchange_cell = _cell_map.add(ColumnKeys.Exchange, d => d.security?.Exchange ?? Venue.Unset);
symbol_cell = _cell_map.add(ColumnKeys.Symbol, d => d.symbol);
@@ -159,7 +159,7 @@ namespace bts.shell.pnl {
public Security.ContractOneofCase security_type => security?.ContractCase ?? Security.ContractOneofCase.None;
public SecurityImmutable? security => data.security;
// cells
public PNLCellVM<PNLRowData, string> account_name_cell { get; }
public PNLCellVM<PNLRowData, AccountTuple> account_cell { get; }
public PNLCellVM<PNLRowData, Venue> exchange_cell { get; }
public PNLCellVM<PNLRowData, string> symbol_cell { get; }
public PNLCellVM<PNLRowData, Security.ContractOneofCase> security_type_cell { get; }
@@ -656,7 +656,9 @@ namespace bts.shell.pnl {
static void _append_fills_filter(fills.FillsFilterStates filter, PNLRowCollectionViewGroup group, ColumnKeys key) {
switch (key) {
case ColumnKeys.Account: filter.account = new[] { ((AccountTuple)group.Name).id }; break;
case ColumnKeys.Account:
filter.account = new[] { ((PNLCellValue<AccountTuple>)group.Name).value.id };
break;
case ColumnKeys.Symbol: filter.symbol = new[] { group.Name.ToString() }; break;
case ColumnKeys.Exchange: filter.exchange = new[] { (Venue)group.Name }; break;
case ColumnKeys.Security:
@@ -643,7 +643,7 @@
c:DataGridFilterProperties.FilterActive="{Binding DataContext.account_filter.active, Source={u:DirectReference _grid}}"
c:DataGridFilterProperties.FilterOpen="{Binding DataContext.account_filter.open, Source={u:DirectReference _grid}}"
key="Account"
data_member_path="account_name_cell.cell_data"
data_member_path="account_cell.cell_data"
sort_member_path="account_name"
HeaderTemplate="{StaticResource AnchorableColumnHeaderTemplate}"
/>
@@ -1112,7 +1112,7 @@
<Grid.Background>
<SolidColorBrush Color="{Binding DataContext.grid_background_color, RelativeSource={RelativeSource AncestorType=pnl:PNLView}}"/>
</Grid.Background>
<c:TextCell c:DIYGrid.ColumnKey="Account" DataContext="{Binding account_name_cell}" Style="{StaticResource RowTextCell}" Visibility="{Binding AnchorIndex.anchors.Account, RelativeSource={RelativeSource AncestorType=pnl:PNLView}, Converter={StaticResource FalseVisibilityConverter}}"/>
<c:TextCell c:DIYGrid.ColumnKey="Account" DataContext="{Binding account_cell}" Style="{StaticResource RowTextCell}" Visibility="{Binding AnchorIndex.anchors.Account, RelativeSource={RelativeSource AncestorType=pnl:PNLView}, Converter={StaticResource FalseVisibilityConverter}}"/>
<c:TextCell c:DIYGrid.ColumnKey="Exchange" DataContext="{Binding exchange_cell}" Style="{StaticResource RowTextCell}" Visibility="{Binding AnchorIndex.anchors.Exchange, RelativeSource={RelativeSource AncestorType=pnl:PNLView}, Converter={StaticResource FalseVisibilityConverter}}"/>
<c:TextCell c:DIYGrid.ColumnKey="Symbol" DataContext="{Binding symbol_cell}" Style="{StaticResource RowTextCell}" Visibility="{Binding AnchorIndex.anchors.Symbol, RelativeSource={RelativeSource AncestorType=pnl:PNLView}, Converter={StaticResource FalseVisibilityConverter}}"/>
<c:TextCell c:DIYGrid.ColumnKey="SecurityType" DataContext="{Binding security_type_cell}" Style="{StaticResource RowTextCell}" Visibility="{Binding AnchorIndex.anchors.SecurityType, RelativeSource={RelativeSource AncestorType=pnl:PNLView}, Converter={StaticResource FalseVisibilityConverter}}"/>