diff --git a/src/client/spark/Modules/Trading/PNL/View/PNLView.xaml b/src/client/spark/Modules/Trading/PNL/View/PNLView.xaml
index b2f59396e..1fdb0f668 100644
--- a/src/client/spark/Modules/Trading/PNL/View/PNLView.xaml
+++ b/src/client/spark/Modules/Trading/PNL/View/PNLView.xaml
@@ -1,1153 +1,1156 @@
-
-
-
-
-
-
-
-
-
-
- False
-
- #FFAAAAAA
- #FF000000
- #FF000000
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Total
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- SelectedTotal
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- SelectedTotal
-
-
-
-
-
-
-
-
- font_weight
- font_size
- font_brush
- font_family
- horizontal_alignment
- group_font_weight
- group_font_size
- group_font_family
- group_font_color
- header_font_weight
- header_font_size
- header_font_family
- header_font_color
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ False
+
+ #FFAAAAAA
+ #FF000000
+ #FF000000
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Total
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ SelectedTotal
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ SelectedTotal
+
+
+
+
+
+
+
+
+ font_weight
+ font_size
+ font_brush
+ font_family
+ horizontal_alignment
+ group_font_weight
+ group_font_size
+ group_font_family
+ group_font_color
+ header_font_weight
+ header_font_size
+ header_font_family
+ header_font_color
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/client/spark/Modules/Trading/PNL/View/PNLView.xaml.cs b/src/client/spark/Modules/Trading/PNL/View/PNLView.xaml.cs
index 2b1482a0c..794848158 100644
--- a/src/client/spark/Modules/Trading/PNL/View/PNLView.xaml.cs
+++ b/src/client/spark/Modules/Trading/PNL/View/PNLView.xaml.cs
@@ -6,6 +6,7 @@ using mbts.ui;
using mbts.ui.controls;
using mbts.ui.controls.adorners;
using mbts.ui.converters;
+using mbts.ui.dpi;
using mbts.ui.extensions;
using mbts.ui.spark;
using mbts.ui.utility;
@@ -31,6 +32,10 @@ namespace bts.shell.pnl {
}
partial class PNLView : UserControl {
+ public static readonly double
+ MinGroupRowHeight = 24.0.RoundLayoutValue(),
+ MinHeaderRowHeight = 24.0.RoundLayoutValue();
+
public enum Columns {
Account = 1,
// Security
@@ -85,6 +90,7 @@ namespace bts.shell.pnl {
public static readonly IValueConverter
IncrementalGroupLevelConverter = ValueConverter.create(level => level + 1),
GroupLevelMarginConverter = ValueConverter.create(level => new Thickness(24 * level, 0, 0, 0)),
+ HeaderRowHeightConverter = new RangeBlockConverter { Minimum = MinHeaderRowHeight },
ExpandedVisualStateConverter = ValueConverter.create(is_expanded => is_expanded ? "Expanded" : "Collapsed");
public static readonly IMultiValueConverter
@@ -163,17 +169,22 @@ namespace bts.shell.pnl {
void _grid_loaded(object sender, RoutedEventArgs e) {
// this is a hack to make room for the 'totals row' between the column headers and the regular rows.
if (_grid.try_find_descendent_of_type(out DIYGridRowsPresenter rp)) {
- rp.SetBinding(MarginProperty, new Binding(nameof(PNLVM.header_row_display)) {
- Converter = ValueConverter.create(hrd => {
- double top = 0;
- if ((hrd & PNLHeaderRowDisplay.Total) != 0)
- top += 24;
- if ((hrd & PNLHeaderRowDisplay.SelectedTotal) != 0)
- top += 24;
- return new Thickness(0, top, 0, 0);
- }),
- Source = DataContext
- });
+ rp.SetBinding(MarginProperty,
+ BindingHelper.create_multi(
+ ValueConverter.create((hrd, row_height) => {
+ double top = 0;
+ if ((hrd & PNLHeaderRowDisplay.Total) != 0)
+ top += row_height;
+ if ((hrd & PNLHeaderRowDisplay.SelectedTotal) != 0)
+ top += row_height;
+ return new Thickness(0, top, 0, 0);
+ }),
+ new Binding(nameof(PNLVM.header_row_display)),
+ new Binding {
+ Path = new PropertyPath(DIYGrid.RowHeightProperty),
+ Converter = HeaderRowHeightConverter,
+ Source = _grid
+ }));
}
}
#endregion
diff --git a/src/client/spark/view/Converters/RangeBlockConverter.cs b/src/client/spark/view/Converters/RangeBlockConverter.cs
new file mode 100644
index 000000000..b017e8dd0
--- /dev/null
+++ b/src/client/spark/view/Converters/RangeBlockConverter.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Globalization;
+using System.Windows.Controls;
+using System.Windows.Data;
+
+namespace mbts.ui.converters {
+ class RangeBlockConverter : IValueConverter {
+ public IComparable Minimum { get; set; }
+ public IComparable Maximum { get; set; }
+
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
+ if (value is IComparable comp) {
+ if (Minimum != null && comp.CompareTo(Minimum) < 0)
+ return Minimum;
+ if (Maximum != null && comp.CompareTo(Maximum) > 0)
+ return Maximum;
+ } else {
+ return new ValidationResult(false, $"Value does not implement {typeof(IComparable)}.");
+ }
+ return value;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) =>
+ throw new NotImplementedException();
+ }
+
+ class RangeBlockConverter : IValueConverter where T : struct, IComparable {
+ public T? Maximum { get; set; }
+ public T? Minimum { get; set; }
+
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
+ if (value is T v) {
+ if (Minimum.HasValue && v.CompareTo(Minimum.Value) < 0)
+ return Minimum.Value;
+ if (Maximum.HasValue && v.CompareTo(Maximum.Value) > 0)
+ return Maximum.Value;
+ } else {
+ return new ValidationResult(false, $"Value is not of type {typeof(T)}.");
+ }
+ return value;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) =>
+ throw new NotImplementedException();
+ }
+}
diff --git a/src/client/spark/view/Utility/BindingHelper.cs b/src/client/spark/view/Utility/BindingHelper.cs
new file mode 100644
index 000000000..00dffa4e2
--- /dev/null
+++ b/src/client/spark/view/Utility/BindingHelper.cs
@@ -0,0 +1,14 @@
+using System.Windows.Data;
+
+namespace mbts.ui {
+ static class BindingHelper {
+ public static MultiBinding create_multi(IMultiValueConverter converter, params Binding[] bindings) {
+ var mb = new MultiBinding {
+ Converter = converter
+ };
+ for (int i = 0; i < bindings.Length; i++)
+ mb.Bindings.Add(bindings[i]);
+ return mb;
+ }
+ }
+}