badge - the rest of SPARK-2291 - no more parent info
This commit is contained in:
1 parent
147783666c
commit
da1ae1b410
5 files changed
+33
-69
No files matched your search
@@ -34,9 +34,9 @@ namespace mbts.spark {
|
||||
readonly Property<FontFamily> _font_family;
|
||||
readonly Property<FontWeight> _font_weight;
|
||||
readonly Property<double> _font_size;
|
||||
readonly Property<Brush> _foreground, _background, _hoverbackground, _border, _parent_algo_type_brush;
|
||||
readonly Property<Brush> _foreground, _background, _hoverbackground, _border;
|
||||
readonly Property<bool> _has_multiple_orders_at_same_level, _is_hedge_order;
|
||||
readonly Property<CustomOrderDefinition.CustomOneofCase> _parent_algo_type;
|
||||
readonly Property<CustomOrderDefinition.CustomOneofCase> _algo_type;
|
||||
readonly Property<string> _summary;
|
||||
IObservable<LadderSettings.BadgeStyle> _bs;
|
||||
LadderSettings.BadgeStyle _current_badge_style;
|
||||
@@ -65,8 +65,7 @@ namespace mbts.spark {
|
||||
_summary = backing(nameof(summary), string.Empty);
|
||||
_has_multiple_orders_at_same_level = backing(nameof(has_multiple_orders_at_same_level), false);
|
||||
_is_hedge_order = backing(nameof(is_hedge_order), false);
|
||||
_parent_algo_type = backing(nameof(parent_algo_type), CustomOrderDefinition.CustomOneofCase.None);
|
||||
_parent_algo_type_brush = backing(nameof(parent_algo_type_brush), _color_bg_brush);
|
||||
_algo_type = backing(nameof(algo_type), CustomOrderDefinition.CustomOneofCase.None);
|
||||
FontFamily get_font_family(LadderSettings s) => new FontFamily(s.orders_column.font_family);
|
||||
FontWeight get_font_weight(LadderSettings s) => ui.utility.text.TextUtils.from_open_type_weight_safe(s.orders_column.font_weight);
|
||||
double get_font_size(LadderSettings s) => s.orders_column.font_size;
|
||||
@@ -94,9 +93,6 @@ namespace mbts.spark {
|
||||
}
|
||||
var darker = BTSColor.darken2(color.R, color.G, color.B, 0.75);
|
||||
Color dark = new Color() { A = 255, R = darker.r, G = darker.g, B = darker.b };
|
||||
//var completion = _parent_and_child_not_sharing_slot().Sum(order => OrderUtils.filled(order)) / _parent_and_child_not_sharing_slot().Sum(order => OrderUtils.quantity(order));
|
||||
bts.spark.OrderMetadata parent_algo_metadata = _parent.model.order_gateway.factory.get_metadata(parent_algo_type);
|
||||
parent_algo_type_brush = parent_algo_metadata.Color.rgb_brush();
|
||||
var buy_sell_background_fill_color = new SolidColorBrush(color);
|
||||
buy_sell_background_fill_color.Freeze();
|
||||
background = buy_sell_background_fill_color;
|
||||
@@ -117,6 +113,12 @@ namespace mbts.spark {
|
||||
var single_order = _orders.Values.First();
|
||||
var single_order_metadata = _parent.model.order_gateway.factory.get_metadata(single_order);
|
||||
border = single_order_metadata.Color.rgb_brush();
|
||||
if (single_order.order_type().is_bts_algo_type()) {
|
||||
algo_type = single_order.order_type();
|
||||
} else {
|
||||
algo_type = CustomOrderDefinition.CustomOneofCase.None;
|
||||
}
|
||||
|
||||
} else {
|
||||
border = new SolidColorBrush(color);
|
||||
}
|
||||
@@ -190,9 +192,7 @@ namespace mbts.spark {
|
||||
public string summary { get => _summary.Value; private set => _summary.Value = value; }
|
||||
public bool has_multiple_orders_at_same_level { get => _has_multiple_orders_at_same_level.Value; private set => _has_multiple_orders_at_same_level.Value = value; }
|
||||
public bool is_hedge_order { get => _is_hedge_order.Value; private set => _is_hedge_order.Value = value; }
|
||||
public Brush parent_algo_type_brush { get => _parent_algo_type_brush.Value; private set => _parent_algo_type_brush.Value = value; }
|
||||
// the setter is public so that the LadderVM can set this field
|
||||
public CustomOrderDefinition.CustomOneofCase parent_algo_type { get => _parent_algo_type.Value; set => _parent_algo_type.Value = value; }
|
||||
public CustomOrderDefinition.CustomOneofCase algo_type { get => _algo_type.Value; private set => _algo_type.Value = value; }
|
||||
|
||||
public IEnumerable<OrderRecordImmutable> orders => _orders.Values;
|
||||
|
||||
|
||||
@@ -193,25 +193,6 @@ namespace mbts.spark {
|
||||
|
||||
// update dirty brushes and text
|
||||
foreach (var lovm in _slot_price_vs_orders.Values) {
|
||||
// the parent algo is only valid when there is only a single order at a level
|
||||
if (lovm.orders.Count() == 1) {
|
||||
var only_order = lovm.orders.First();
|
||||
|
||||
if (only_order.has_parent()) {
|
||||
var traversal_candidate = only_order;
|
||||
bool exit_early = false;
|
||||
while (!exit_early && traversal_candidate.ParentKey != 0) {
|
||||
if (_cache.TryGetValue(traversal_candidate.ParentKey, out var target))
|
||||
traversal_candidate = target;
|
||||
else
|
||||
exit_early = true;
|
||||
}
|
||||
if (!exit_early)
|
||||
// we have successfully reached the root
|
||||
lovm.parent_algo_type = traversal_candidate.Def.CustomDef.CustomCase;
|
||||
}
|
||||
// else this a single order, so do nothing
|
||||
}
|
||||
lovm.update();
|
||||
}
|
||||
|
||||
|
||||
@@ -554,8 +554,7 @@
|
||||
<Setter Property="Width" Value="{x:Static controls:Badge.DefaultWidth}"/>
|
||||
<Setter Property="HasMultipleOrdersAtLevel" Value="{Binding has_multiple_orders_at_same_level}" />
|
||||
<Setter Property="IsHedgeOrder" Value="{Binding is_hedge_order}" />
|
||||
<Setter Property="ParentAlgoType" Value="{Binding parent_algo_type}" />
|
||||
<Setter Property="ParentAlgoTypeBrush" Value="{Binding parent_algo_type_brush}" />
|
||||
<Setter Property="AlgoType" Value="{Binding algo_type}" />
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
|
||||
@@ -102,8 +102,7 @@
|
||||
<Setter Property="Width" Value="{x:Static c:Badge.DefaultWidth}"/>
|
||||
<Setter Property="HasMultipleOrdersAtLevel" Value="{Binding has_multiple_orders_at_same_level}"/>
|
||||
<Setter Property="IsHedgeOrder" Value="{Binding is_hedge_order}"/>
|
||||
<Setter Property="ParentAlgoType" Value="{Binding parent_algo_type}"/>
|
||||
<Setter Property="ParentAlgoTypeBrush" Value="{Binding parent_algo_type_brush}"/>
|
||||
<Setter Property="AlgoType" Value="{Binding algo_type}"/>
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
|
||||
@@ -36,9 +36,9 @@ namespace mbts.ui.controls {
|
||||
//static ConcurrentDictionary<(Point p1, Point p2, Point p3), StreamGeometry> _sg_cache = new ConcurrentDictionary<(Point p1, Point p2, Point p3), StreamGeometry>();
|
||||
|
||||
readonly GlyphContentRect _gcr = new GlyphContentRect();
|
||||
Brush _background, _foreground, _border_brush, _parent_algo_type_brush;
|
||||
Brush _background, _foreground, _border_brush;
|
||||
bool _has_multiple_orders_at_level, _is_hedge_order;
|
||||
CustomOrderDefinition.CustomOneofCase _parent_algo_type;
|
||||
CustomOrderDefinition.CustomOneofCase _algo_type;
|
||||
(Point p1, Point p2, Point p3) _current_triangle_vertices;
|
||||
StreamGeometry _triangle_geometry;
|
||||
Popup _popup;
|
||||
@@ -221,30 +221,18 @@ namespace mbts.ui.controls {
|
||||
(b, v) => b._has_multiple_orders_at_level = v,
|
||||
false);
|
||||
|
||||
public CustomOrderDefinition.CustomOneofCase ParentAlgoType {
|
||||
get { return (CustomOrderDefinition.CustomOneofCase)GetValue(ParentAlgoTypeProperty); }
|
||||
set { SetValue(ParentAlgoTypeProperty, value); }
|
||||
public CustomOrderDefinition.CustomOneofCase AlgoType {
|
||||
get { return (CustomOrderDefinition.CustomOneofCase)GetValue(AlgoTypeProperty); }
|
||||
set { SetValue(AlgoTypeProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ParentAlgoTypeProperty =
|
||||
public static readonly DependencyProperty AlgoTypeProperty =
|
||||
WPFHelper.create_dp<CustomOrderDefinition.CustomOneofCase, Badge>(
|
||||
nameof(ParentAlgoType),
|
||||
nameof(AlgoType),
|
||||
FrameworkPropertyMetadataOptions.AffectsRender,
|
||||
(b, v) => b._parent_algo_type = v,
|
||||
(b, v) => b._algo_type = v,
|
||||
CustomOrderDefinition.CustomOneofCase.None);
|
||||
|
||||
public Brush ParentAlgoTypeBrush {
|
||||
get { return (Brush)GetValue(ParentAlgoTypeBrushProperty); }
|
||||
set { SetValue(ParentAlgoTypeBrushProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ParentAlgoTypeBrushProperty =
|
||||
WPFHelper.create_dp<Brush, Badge>(
|
||||
nameof(ParentAlgoTypeBrush),
|
||||
FrameworkPropertyMetadataOptions.AffectsRender,
|
||||
(b, v) => b._parent_algo_type_brush = v,
|
||||
Brushes.White);
|
||||
|
||||
public bool IsHedgeOrder {
|
||||
get { return (bool)GetValue(IsHedgeOrderProperty); }
|
||||
set { SetValue(IsHedgeOrderProperty, value); }
|
||||
@@ -326,22 +314,19 @@ namespace mbts.ui.controls {
|
||||
dc.DrawGlyphRun(Brushes.Black, a_glyph_run);
|
||||
|
||||
}
|
||||
if (ParentAlgoType != CustomOrderDefinition.CustomOneofCase.None) {
|
||||
dc.DrawRectangle(ParentAlgoTypeBrush, null, new Rect(4 * border_thickness, 0 + 2 * border_thickness, 10, _gcr.layout_size.Height - 2 * border_thickness));
|
||||
var palgo_type_name = utility.EnumHelper.get_display_name(ParentAlgoType);
|
||||
if (palgo_type_name.Length > 1) {
|
||||
var a_glyph_context = _gcr.glyph_context;
|
||||
var a_glyph_run = a_glyph_context.get_glyph_run(
|
||||
palgo_type_name.Substring(0, 1),
|
||||
12,
|
||||
_gcr.layout_size.Width,
|
||||
_gcr.layout_size.Height,
|
||||
HorizontalAlignment.Left,
|
||||
4 * border_thickness + 1,
|
||||
VerticalAlignment.Center,
|
||||
0);
|
||||
dc.DrawGlyphRun(Brushes.Black, a_glyph_run);
|
||||
}
|
||||
if (AlgoType != CustomOrderDefinition.CustomOneofCase.None) {
|
||||
var a_glyph_context = _gcr.glyph_context;
|
||||
var a_glyph_run = a_glyph_context.get_glyph_run(
|
||||
mbts.spark.utilities.OrderDataHelper.abbreviate_algo_type(AlgoType),
|
||||
12,
|
||||
_gcr.layout_size.Width,
|
||||
_gcr.layout_size.Height,
|
||||
HorizontalAlignment.Left,
|
||||
2 * border_thickness + 1,
|
||||
VerticalAlignment.Center,
|
||||
0);
|
||||
dc.DrawGlyphRun(Brushes.Black, a_glyph_run);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user