SPARK-1082 - for now on one line, but next sprint we should do it right like John suggested with a MeasureOverride and what not
This commit is contained in:
1 parent
96754066bd
commit
92b02833df
3 files changed
+65
-7
No files matched your search
@@ -23,12 +23,16 @@ 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(10.0, FrameworkPropertyMetadataOptions.AffectsRender, update_text));
|
||||
FontSizeProperty.OverrideMetadata(typeof(Badge), new FrameworkPropertyMetadata(10.0, FrameworkPropertyMetadataOptions.AffectsRender /*| FrameworkPropertyMetadataOptions.AffectsMeasure*/, 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)));
|
||||
BorderBrushProperty.OverrideMetadata(typeof(Badge), new FrameworkPropertyMetadata(Brushes.Black));
|
||||
FontFamilyProperty.OverrideMetadata(typeof(Badge), new FrameworkPropertyMetadata(new FontFamily("Consolas"), FrameworkPropertyMetadataOptions.AffectsRender, update_text));
|
||||
FontFamilyProperty.OverrideMetadata(typeof(Badge), new FrameworkPropertyMetadata(new FontFamily("Consolas"), FrameworkPropertyMetadataOptions.AffectsRender /*| FrameworkPropertyMetadataOptions.AffectsMeasure*/, update_text));
|
||||
|
||||
//TextProperty.OverrideMetadata(typeof(Badge), new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure, update_text));
|
||||
//TopTextProperty.OverrideMetadata(typeof(Badge), new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure, update_text));
|
||||
//BottomTextProperty.OverrideMetadata(typeof(Badge), new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.AffectsMeasure, update_text));
|
||||
}
|
||||
|
||||
public string Text {
|
||||
@@ -98,6 +102,29 @@ namespace mbts.ui.controls {
|
||||
b._face = b._face ?? new Typeface(b.FontFamily, b.FontStyle, b.FontWeight, b.FontStretch);
|
||||
}
|
||||
|
||||
//protected override Size MeasureOverride(Size availableSize) {
|
||||
// Double calc_height = 0.0;
|
||||
// Double calc_width = 0.0;
|
||||
// Size size = new Size(0, 0);
|
||||
|
||||
// Size center_size = new Size(_center_text.Width, _center_text.Height);
|
||||
// Size top_size = new Size(_top_text.Width, _top_text.Height);
|
||||
// Size bottom_size = new Size(_bottom_text.Width, _bottom_text.Height);
|
||||
|
||||
// calc_width = Math.Max(center_size.Width, top_size.Width);
|
||||
// calc_width = Math.Max(calc_width, bottom_size.Width);
|
||||
|
||||
// calc_height += center_size.Height;
|
||||
// calc_height += top_size.Height;
|
||||
// calc_height += bottom_size.Height;
|
||||
|
||||
// size.Width = calc_width;
|
||||
// size.Height = calc_height;
|
||||
|
||||
// return size;
|
||||
|
||||
//}
|
||||
|
||||
protected override void OnRender(DrawingContext dc) {
|
||||
base.OnRender(dc);
|
||||
double border_thickness = BorderThickness.Top;
|
||||
@@ -106,7 +133,7 @@ namespace mbts.ui.controls {
|
||||
if (_center_text != null)
|
||||
dc.DrawText(_center_text, new Point((ActualWidth-_center_text.Width)/2, (ActualHeight-_center_text.Height)/2));
|
||||
if (_top_text != null)
|
||||
_top_text.SetFontSize(FontSize);
|
||||
dc.DrawText(_top_text, new Point(border_thickness, 0.0));
|
||||
if (_bottom_text != null)
|
||||
dc.DrawText(_bottom_text, new Point(border_thickness, ActualHeight - _bottom_text.Height));
|
||||
}
|
||||
|
||||
@@ -58,7 +58,9 @@ namespace mbts.spark {
|
||||
_bs.Subscribe( badge => {
|
||||
switch (badge) {
|
||||
case LadderSettings.BadgeStyle.Alternate:
|
||||
text = $"{_buy_sell_indicator} {OrderUtils.filled(_order)}/{_order.State.Quantity}";
|
||||
//top_line = $"{_buy_sell_indicator}:{OrderUtils.filled(_order)}";
|
||||
//bottom_line = $"W:{_order.working_quantity()}";
|
||||
text = $"{_buy_sell_indicator}:{OrderUtils.filled(_order)} W:{_order.working_quantity()}";
|
||||
break;
|
||||
case LadderSettings.BadgeStyle.Normal:
|
||||
default:
|
||||
@@ -120,10 +122,37 @@ namespace mbts.spark {
|
||||
private string _text;
|
||||
public string text {
|
||||
get { return _text; }
|
||||
private set { _text = value; RaisePropertyChanged(nameof(text)); }
|
||||
private set {
|
||||
_text = value;
|
||||
if (value != string.Empty) {
|
||||
top_line = string.Empty;
|
||||
bottom_line = string.Empty;
|
||||
}
|
||||
RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private string _top_line;
|
||||
public string top_line {
|
||||
get { return _top_line; }
|
||||
private set {
|
||||
_top_line = value;
|
||||
if (value != string.Empty) {
|
||||
text = string.Empty;
|
||||
}
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
private string _bottom_line;
|
||||
public string bottom_line {
|
||||
get { return _bottom_line; }
|
||||
private set {
|
||||
_bottom_line = value;
|
||||
if (value != string.Empty) {
|
||||
text = string.Empty;
|
||||
}
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
public string line1 => $"{_buy_sell_indicator}:{OrderUtils.filled(_order)}";
|
||||
public string line2 => $"W:{_order.working_quantity()}";
|
||||
|
||||
public string summary => _order.short_description(_parent.security.ContractSpec);
|
||||
public string description => _order.full_description(_parent.security);
|
||||
|
||||
@@ -414,6 +414,8 @@
|
||||
<Setter Property="FontSize" Value="{Binding font_size}"/>
|
||||
<Setter Property="Foreground" Value="{Binding foreground}"/>
|
||||
<Setter Property="Text" Value="{Binding text}" />
|
||||
<Setter Property="TopText" Value="{Binding top_line}" />
|
||||
<Setter Property="BottomText" Value="{Binding bottom_line}" />
|
||||
<Setter Property="BorderThickness" Value="3" />
|
||||
<Setter Property="Width" Value="50" />
|
||||
<Setter Property="Height" Value="20" />
|
||||
|
||||
Reference in new issue
Block a user