PR - backings for a lazy life

This commit is contained in:
Jake Norbut committed 2018-06-06 12:31:22 -05:00
1 parent 83b1bbf087
commit 50214741e7
1 file changed
+8 -27
@@ -16,6 +16,7 @@ namespace mbts.spark {
class LadderOrderVM : DisposableViewModelBase {
#region Colors
static readonly Color _colorbg = Colors.White, _darkbg = Color.FromRgb(0xbf, 0xbf, 0xbf);
static readonly Brush _color_bg_brush = _colorbg.rgb_color().rgb_brush();
static Brush mkbrush(Color color, Color endcolor, double pct_complete) {
GradientStopCollection stops = new GradientStopCollection();
stops.Add(new GradientStop(color, 0.0));
@@ -34,7 +35,7 @@ namespace mbts.spark {
readonly Property<FontFamily> _font_family;
readonly Property<FontWeight> _font_weight;
readonly Property<double> _font_size;
readonly Property<Brush> _foreground;
readonly Property<Brush> _foreground, _background, _hoverbackground, _border;
IObservable<LadderSettings.BadgeStyle> _bs;
LadderSettings.BadgeStyle _current_badge_style;
int _n_active_price_change_ops = 0;
@@ -56,6 +57,9 @@ namespace mbts.spark {
_font_weight = backing(nameof(font_weight), parent.settings, get_font_weight, get_font_weight(fs));
_font_size = backing(nameof(font_size), parent.settings, get_font_size, get_font_size(fs));
_foreground = backing(nameof(foreground), parent.settings, get_foreground, get_foreground(fs));
_background = backing(nameof(background), _color_bg_brush);
_hoverbackground = backing(nameof(hoverbackground), _color_bg_brush);
_border = backing(nameof(border), _color_bg_brush);
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;
@@ -209,32 +213,9 @@ namespace mbts.spark {
public FontWeight font_weight => _font_weight.Value;
public double font_size => _font_size.Value;
public Brush foreground => _foreground.Value;
private Brush _background;
public Brush background {
get { return _background; }
private set {
_background = value;
RaisePropertyChanged();
}
}
private Brush _hoverbackground;
public Brush hoverbackground {
get { return _hoverbackground; }
private set {
_hoverbackground = value;
RaisePropertyChanged();
}
}
private Brush _border;
public Brush border {
get { return _border; }
private set {
_border = value;
RaisePropertyChanged();
}
}
public Brush background { get; private set; }
public Brush hoverbackground { get; private set; }
public Brush border { get; private set; }
public IEnumerable<OrderRecordImmutable> orders => _orders.Values;
void _cancel_order() {