Adding Abbreviation to badge
This commit is contained in:
1 parent
f94aa936b0
commit
2064de0752
5 files changed
+42
-7
No files matched your search
@@ -37,6 +37,7 @@ namespace mbts.spark {
|
||||
readonly Property<Brush> _foreground, _background, _hoverbackground, _border;
|
||||
readonly Property<bool> _has_multiple_orders_at_same_level, _is_hedge_order;
|
||||
readonly Property<CustomOrderDefinition.CustomOneofCase> _algo_type;
|
||||
readonly Property<string> _algo_studio_abbreviation;
|
||||
IObservable<LadderSettings.BadgeStyle> _bs;
|
||||
LadderSettings.BadgeStyle _current_badge_style;
|
||||
int _n_active_price_change_ops = 0;
|
||||
@@ -45,9 +46,9 @@ namespace mbts.spark {
|
||||
int working_quantity;
|
||||
|
||||
LadderModel model => _owner.model;
|
||||
Dictionary<uint, (OrderRecordImmutable order, uint? p)> _orders = new Dictionary<uint, (OrderRecordImmutable order, uint? p)>();
|
||||
Dictionary<uint, (OrderRecordImmutable order, uint? p, AlgoDefinitionMetadata? meta)> _orders = new Dictionary<uint, (OrderRecordImmutable order, uint? p, AlgoDefinitionMetadata? meta)>();
|
||||
|
||||
public LadderOrderVM((OrderRecordImmutable, uint?) op, double real_price, LadderVM owner, IBus bus, IObservable<LadderSettings.BadgeStyle> bs) {
|
||||
public LadderOrderVM((OrderRecordImmutable, uint?, AlgoDefinitionMetadata?) op, double real_price, LadderVM owner, IBus bus, IObservable<LadderSettings.BadgeStyle> bs) {
|
||||
_owner = owner;
|
||||
_bus = bus;
|
||||
_bs = bs;
|
||||
@@ -64,6 +65,7 @@ namespace mbts.spark {
|
||||
_has_multiple_orders_at_same_level = backing(nameof(has_multiple_orders_at_same_level), false);
|
||||
_is_hedge_order = backing(nameof(is_hedge_order), false);
|
||||
_algo_type = backing(nameof(algo_type), CustomOrderDefinition.CustomOneofCase.None);
|
||||
_algo_studio_abbreviation = backing(nameof(algo_studio_abbreviation), string.Empty);
|
||||
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;
|
||||
@@ -111,6 +113,11 @@ namespace mbts.spark {
|
||||
var single_order = _root_nodes().First();
|
||||
var single_order_metadata = _owner.model.order_gateway.factory.get_metadata(single_order);
|
||||
border = single_order_metadata.Color.rgb_brush();
|
||||
if (_orders.TryGetValue(single_order.Key, out var opm) && opm.meta.HasValue) {
|
||||
algo_studio_abbreviation = opm.meta.Value.abbreviation;
|
||||
} else {
|
||||
algo_studio_abbreviation = string.Empty;
|
||||
}
|
||||
if (single_order.order_type().is_bts_algo_type()) {
|
||||
algo_type = single_order.order_type();
|
||||
} else {
|
||||
@@ -132,7 +139,7 @@ namespace mbts.spark {
|
||||
RaisePropertyChanged(nameof(text_lines));
|
||||
}
|
||||
|
||||
public void add_order((OrderRecordImmutable order, uint? p) new_op) {
|
||||
public void add_order((OrderRecordImmutable order, uint? p, AlgoDefinitionMetadata? meta) new_op) {
|
||||
_orders[new_op.order.Key] = new_op;
|
||||
}
|
||||
|
||||
@@ -186,6 +193,7 @@ namespace mbts.spark {
|
||||
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 CustomOrderDefinition.CustomOneofCase algo_type { get => _algo_type.Value; private set => _algo_type.Value = value; }
|
||||
public string algo_studio_abbreviation { get => _algo_studio_abbreviation.Value; private set => _algo_studio_abbreviation.Value = value; }
|
||||
|
||||
public IReadOnlyList<uint> order_keys => _orders.Keys.ToReadOnlyList();
|
||||
public IEnumerable<OrderRecordImmutable> root_orders => _root_nodes();
|
||||
|
||||
@@ -165,9 +165,9 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
if (_slot_price_vs_orders.TryGetValue(slot_price_target, out LadderOrderVM slot_vm)) {
|
||||
slot_vm.add_order((wo, os.piq));
|
||||
slot_vm.add_order((wo, os.piq, os.meta));
|
||||
} else {
|
||||
slot_vm = new LadderOrderVM((wo, os.piq), slot_price_target, this, _bus, _settings_manager.subscribe_current().Select(s => s.badge_style));
|
||||
slot_vm = new LadderOrderVM((wo, os.piq, os.meta), slot_price_target, this, _bus, _settings_manager.subscribe_current().Select(s => s.badge_style));
|
||||
_slot_price_vs_orders[slot_price_target] = slot_vm;
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ namespace mbts.spark {
|
||||
public uint volume_column_width { get => _volume_column_width.Value; set => _volume_column_width.set(value); }
|
||||
internal LadderModel model => _model;
|
||||
internal IObservable<LadderSettings> settings => _settings_manager.subscribe_current();
|
||||
internal OrderRecordImmutable get_root_at_price((OrderRecordImmutable order, uint? _) op) {
|
||||
internal OrderRecordImmutable get_root_at_price((OrderRecordImmutable order, uint? _, AlgoDefinitionMetadata? meta) op) {
|
||||
var order = op.order;
|
||||
double p = order.price();
|
||||
foreach (var o in lineage(order.ParentKey)) {
|
||||
|
||||
@@ -556,6 +556,7 @@
|
||||
<Setter Property="HasMultipleOrdersAtLevel" Value="{Binding has_multiple_orders_at_same_level}" />
|
||||
<Setter Property="IsHedgeOrder" Value="{Binding is_hedge_order}" />
|
||||
<Setter Property="AlgoType" Value="{Binding algo_type}" />
|
||||
<Setter Property="Abbreviation" Value="{Binding algo_studio_abbreviation}" />
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
|
||||
@@ -103,6 +103,7 @@
|
||||
<Setter Property="HasMultipleOrdersAtLevel" Value="{Binding has_multiple_orders_at_same_level}"/>
|
||||
<Setter Property="IsHedgeOrder" Value="{Binding is_hedge_order}"/>
|
||||
<Setter Property="AlgoType" Value="{Binding algo_type}"/>
|
||||
<Setter Property="Abbreviation" Value="{Binding algo_studio_abbreviation}" />
|
||||
<Setter Property="Cursor" Value="Hand"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace mbts.ui.controls {
|
||||
Brush _background, _foreground, _border_brush;
|
||||
bool _has_multiple_orders_at_level, _is_hedge_order;
|
||||
CustomOrderDefinition.CustomOneofCase _algo_type;
|
||||
string _abbreviation;
|
||||
(Point p1, Point p2, Point p3) _current_triangle_vertices;
|
||||
StreamGeometry _triangle_geometry;
|
||||
Popup _popup;
|
||||
@@ -233,6 +234,18 @@ namespace mbts.ui.controls {
|
||||
(b, v) => b._algo_type = v,
|
||||
CustomOrderDefinition.CustomOneofCase.None);
|
||||
|
||||
public string Abbreviation {
|
||||
get { return (string)GetValue(AbbreviationProperty); }
|
||||
set { SetValue(AbbreviationProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty AbbreviationProperty =
|
||||
WPFHelper.create_dp<string, Badge>(
|
||||
nameof(Abbreviation),
|
||||
FrameworkPropertyMetadataOptions.AffectsRender,
|
||||
(b, v) => b._abbreviation = v,
|
||||
string.Empty);
|
||||
|
||||
public bool IsHedgeOrder {
|
||||
get { return (bool)GetValue(IsHedgeOrderProperty); }
|
||||
set { SetValue(IsHedgeOrderProperty, value); }
|
||||
@@ -314,7 +327,19 @@ namespace mbts.ui.controls {
|
||||
dc.DrawGlyphRun(Brushes.Black, a_glyph_run);
|
||||
|
||||
}
|
||||
if (AlgoType != CustomOrderDefinition.CustomOneofCase.None) {
|
||||
if (!string.IsNullOrEmpty(Abbreviation)) {
|
||||
var a_glyph_context = _gcr.glyph_context;
|
||||
var a_glyph_run = a_glyph_context.get_glyph_run(
|
||||
Abbreviation,
|
||||
FontSize,
|
||||
_gcr.layout_size.Width,
|
||||
_gcr.layout_size.Height,
|
||||
HorizontalAlignment.Left,
|
||||
2 * border_thickness + 1,
|
||||
VerticalAlignment.Center,
|
||||
0);
|
||||
dc.DrawGlyphRun(Brushes.Black, a_glyph_run);
|
||||
} else 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),
|
||||
|
||||
Reference in new issue
Block a user