SPARK-1196 synth dialog - security text in column header is wrong
This commit is contained in:
1 parent
f69ec8d32b
commit
e1e0565fbd
4 files changed
+12
-28
No files matched your search
@@ -318,7 +318,7 @@
|
||||
Command="{Binding RemoveLegCommand, RelativeSource={RelativeSource AncestorType=usp:ExecutionStrategyEditor}}"
|
||||
CommandParameter="{Binding}" Style="{StaticResource RoundCloseButton}"
|
||||
/>
|
||||
<TextBlock Grid.Column="1" Margin="4,0,0,0" Text="{Binding}"/>
|
||||
<TextBlock Grid.Column="1" Margin="4,0,0,0" Text="{Binding Converter={StaticResource SecurityTextConverter}}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
|
||||
+7
-25
@@ -1,34 +1,16 @@
|
||||
using mbts.ui.utility;
|
||||
using bts.api;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace mbts.ui.converters
|
||||
{
|
||||
namespace mbts.ui.converters {
|
||||
[ValueConversion(typeof(SecurityTuple), typeof(string))]
|
||||
public class SecurityDisplayTextConverter : IValueConverter
|
||||
{
|
||||
public bool ShowExchange { get; set; }
|
||||
public bool ShowType { get; set; }
|
||||
|
||||
public string TextForNull { get; set; }
|
||||
public string TextForEmpty { get; set; }
|
||||
|
||||
public class SecurityDisplayTextConverter : IValueConverter {
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
var sec = value as SecurityTuple;
|
||||
if (sec == null) return TextForNull;
|
||||
else if (sec.is_empty()) return TextForEmpty;
|
||||
else {
|
||||
if (ShowExchange) {
|
||||
if (ShowType) return "[{0} {1}] {2}".fmt(SecurityDisplay.format_security_type(sec.security_type), sec.security_exchange, sec.security_name);
|
||||
else return "[{0}] {1}".fmt(sec.security_exchange, sec.security_name);
|
||||
} else if (ShowType) return "[{0}] {1}".fmt(SecurityDisplay.format_security_type(sec.security_type), sec.security_name);
|
||||
else return sec.security_name;
|
||||
}
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
throw new NotImplementedException();
|
||||
if (value is Security s)
|
||||
return SecurityFormatter.format(s);
|
||||
return value?.ToString() ?? "Unknown";
|
||||
}
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
xmlns:uc="clr-namespace:mbts.ui"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:cv="clr-namespace:mbts.ui.converters"
|
||||
xmlns:usp="clr-namespace:mbts.ui.spark"
|
||||
xmlns:uspcv="clr-namespace:mbts.ui.spark.converters"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib">
|
||||
<cv:BooleanOrConverter x:Key="OrConverter" />
|
||||
@@ -23,7 +22,7 @@
|
||||
<cv:EnumerableDoubleStringConverter x:Key="EnumerableDoublesConverter" />
|
||||
<cv:CellPathConverter x:Key="CellPathConverter" />
|
||||
<cv:CellKeyConverter x:Key="CellKeyConverter" />
|
||||
<cv:SecurityDisplayTextConverter x:Key="SecurityTextConverter" ShowType="True" />
|
||||
<cv:SecurityDisplayTextConverter x:Key="SecurityTextConverter"/>
|
||||
<cv:SecurityTypeForegroundConverter x:Key="SecurityTypeForegroundConverter" />
|
||||
<cv:SecurityTypeStringConverter x:Key="SecurityTypeStringConverter" />
|
||||
<cv:NumericSignBrushConverter x:Key="NumericSignBrushConverter" />
|
||||
|
||||
@@ -21,6 +21,9 @@ namespace bts.api {
|
||||
static class SecurityFormatter {
|
||||
static readonly ConcurrentDictionary<uint, string> _formatted_names_cache = new ConcurrentDictionary<uint, string>();
|
||||
|
||||
public static string format(Security security) =>
|
||||
_formatted_names_cache.GetOrAdd(security.Id, _format(security));
|
||||
|
||||
public static string format(SecurityImmutable security) =>
|
||||
_formatted_names_cache.GetOrAdd(security.Id, _ => _format(security));
|
||||
|
||||
|
||||
Reference in new issue
Block a user