Ladder - order badges actually use settings fontfamily/size/color
This commit is contained in:
1 parent
0dc6c16e6b
commit
e821548a5d
4 files changed
+26
-8
No files matched your search
@@ -23,7 +23,7 @@ namespace mbts.ui.controls {
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(Badge), new FrameworkPropertyMetadata(typeof(Badge)));
|
||||
WidthProperty.OverrideMetadata(typeof(Badge), new FrameworkPropertyMetadata(15.0));
|
||||
HeightProperty.OverrideMetadata(typeof(Badge), new FrameworkPropertyMetadata(10.0));
|
||||
FontSizeProperty.OverrideMetadata(typeof(Badge), new FrameworkPropertyMetadata(9.0, FrameworkPropertyMetadataOptions.AffectsRender, update_text));
|
||||
FontSizeProperty.OverrideMetadata(typeof(Badge), new FrameworkPropertyMetadata(10.0, FrameworkPropertyMetadataOptions.AffectsRender, update_text));
|
||||
ForegroundProperty.OverrideMetadata(typeof(Badge), new FrameworkPropertyMetadata(Brushes.White, update_text));
|
||||
BackgroundProperty.OverrideMetadata(typeof(Badge), new FrameworkPropertyMetadata(Brushes.Transparent, FrameworkPropertyMetadataOptions.AffectsRender));
|
||||
BorderThicknessProperty.OverrideMetadata(typeof(Badge), new FrameworkPropertyMetadata(new Thickness(1)));
|
||||
@@ -31,10 +31,6 @@ namespace mbts.ui.controls {
|
||||
FontFamilyProperty.OverrideMetadata(typeof(Badge), new FrameworkPropertyMetadata(new FontFamily("Consolas")));
|
||||
}
|
||||
|
||||
public Badge() {
|
||||
FontSize = 10;
|
||||
}
|
||||
|
||||
public string Text {
|
||||
get { return (string)GetValue(TextProperty); }
|
||||
set { SetValue(TextProperty, value); }
|
||||
|
||||
@@ -66,6 +66,9 @@ namespace mbts.ui {
|
||||
return Color.FromRgb(bytes[2], bytes[1], bytes[0]);
|
||||
}
|
||||
|
||||
public static Brush rgb_brush(this uint color) =>
|
||||
new SolidColorBrush(rgb_color(color));
|
||||
|
||||
public static UInt32 rgb_color(this Color color) {
|
||||
return (uint)color.A << 24 | (uint)color.R << 16 | (uint)color.G << 8 | (uint)color.B;
|
||||
}
|
||||
|
||||
@@ -6,12 +6,14 @@ using mbts.ui;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.shell;
|
||||
using System;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace mbts.spark {
|
||||
class LadderOrderVM : ViewModelBase, IEquatable<LadderOrderVM> {
|
||||
class LadderOrderVM : DisposableViewModelBase, IEquatable<LadderOrderVM> {
|
||||
#region Colors
|
||||
static readonly Color _colorbg = Colors.White, _darkbg = Color.FromRgb(0xbf, 0xbf, 0xbf);
|
||||
static Brush mkbrush(Color color, Color endcolor, double pct_complete) {
|
||||
@@ -29,6 +31,10 @@ namespace mbts.spark {
|
||||
|
||||
readonly LadderVM _parent;
|
||||
readonly IBus _bus;
|
||||
readonly Property<FontFamily> _font_family;
|
||||
readonly Property<FontWeight> _font_weight;
|
||||
readonly Property<double> _font_size;
|
||||
readonly Property<Brush> _foreground;
|
||||
int _n_active_price_change_ops = 0;
|
||||
double _real_price = double.NaN, _phantom_price = double.NaN;
|
||||
|
||||
@@ -39,6 +45,14 @@ namespace mbts.spark {
|
||||
_parent = parent;
|
||||
_bus = bus;
|
||||
_order = order;
|
||||
_font_family = backing(nameof(font_family),
|
||||
parent.settings.Select(s => new FontFamily(s.orders_column.font_family)));
|
||||
_font_weight = backing(nameof(font_weight),
|
||||
parent.settings.Select(s => ui.utility.text.TextUtils.from_open_type_weight_safe(s.orders_column.font_weight)));
|
||||
_font_size = backing(nameof(font_size),
|
||||
parent.settings.Select(s => s.orders_column.font_size));
|
||||
_foreground = backing(nameof(foreground),
|
||||
parent.settings.Select(s => s.orders_column.foreground.rgb_brush()));
|
||||
_init(order);
|
||||
}
|
||||
|
||||
@@ -103,7 +117,10 @@ namespace mbts.spark {
|
||||
command_executed?.Invoke();
|
||||
}
|
||||
|
||||
public Brush foreground => Brushes.Black;
|
||||
public FontFamily font_family => _font_family.Value;
|
||||
public FontWeight font_weight => _font_weight.Value;
|
||||
public double font_size => _font_size.Value;
|
||||
public Brush foreground => _foreground.Value;
|
||||
public Brush background { get; private set; }
|
||||
public Brush hoverbackground { get; private set; }
|
||||
public Brush header_brush => _order.Def.Side == Side.Buy ? BTSColors.MarketData.bid : BTSColors.MarketData.ask;
|
||||
|
||||
@@ -407,7 +407,9 @@
|
||||
<Style TargetType="controls:Badge">
|
||||
<Setter Property="Background" Value="{Binding background}" />
|
||||
<Setter Property="BorderBrush" Value="{Binding border}" />
|
||||
<Setter Property="Foreground" Value="Black" />
|
||||
<Setter Property="FontFamily" Value="{Binding font_family}"/>
|
||||
<Setter Property="FontSize" Value="{Binding font_size}"/>
|
||||
<Setter Property="Foreground" Value="{Binding foreground}"/>
|
||||
<Setter Property="Text" Value="{Binding text}" />
|
||||
<Setter Property="BorderThickness" Value="3" />
|
||||
<Setter Property="Width" Value="50" />
|
||||
|
||||
Reference in new issue
Block a user