From f2b7e692f8ba3bb1dbc69bdc914b131eb6bd4905 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Mon, 17 Jun 2019 14:49:39 -0500 Subject: [PATCH] ShowQuantity param now defaults to 1 and the associated TickUpDownUint has a min of 1 as well --- .../Spreader/ExecutionStrategyEditor.xaml | 6 +++++ .../Spreader/ExecutionStrategyEditor.xaml.cs | 26 ++++++++++++------- .../Modules/Spreader/SyntheticDataHelper.cs | 2 +- src/client/spark/Modules/Spreader/VM/Cell.cs | 4 +++ .../ShowQuantity/ShowQuantityQuantityModel.cs | 2 +- .../Spreader/VM/ParameterRows/RowModel.cs | 3 ++- 6 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml b/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml index 49bfb654f..15673a066 100644 --- a/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml +++ b/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml @@ -59,6 +59,7 @@ MarketDataTypeTemplate="{StaticResource SimpleValueTextTemplate}" MarketDataCalculationTemplate="{StaticResource SimpleValueTextTemplate}" ConditionalPriceTypeTemplate="{StaticResource SimpleValueTextTemplate}" + ShowQuantityTemplate="{StaticResource SimpleValueTextTemplate}" > @@ -115,6 +116,11 @@ + + + + + diff --git a/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml.cs b/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml.cs index 187849f97..2b8d3ce04 100644 --- a/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml.cs +++ b/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml.cs @@ -240,7 +240,7 @@ namespace mbts.ui.spark { FrameworkElement _generate_element(IValueConverter cell_template_converter) { var rv = new ContentControl(); rv.SetBinding(ContentControl.ContentProperty, new Binding()); - rv.SetBinding(ContentControl.ContentTemplateProperty, new Binding(nameof(ICell.data_type)) { Converter = cell_template_converter }); + rv.SetBinding(ContentControl.ContentTemplateProperty, new Binding() { Converter = cell_template_converter }); return rv; } } @@ -306,17 +306,23 @@ namespace mbts.ui.spark { public DataTemplate MarketDataTypeTemplate { get; set; } public DataTemplate MarketDataCalculationTemplate { get; set; } public DataTemplate ConditionalPriceTypeTemplate { get; set; } + public DataTemplate ShowQuantityTemplate { get; set; } public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - Type t = (Type)value; - if (t == typeof(double)) return DoubleTemplate; - else if (t == typeof(bool)) return BooleanTemplate; - else if (t == typeof(int)) return IntTemplate; - else if (t == typeof(uint)) return UIntTemplate; - else if (t == typeof(QuantityMeasure)) return QuantityMeasureTemplate; - else if (t == typeof(LegSpreaderParams.Types.MarketDataType)) return MarketDataTypeTemplate; - else if (t == typeof(ConditionalQuoting.Types.PriceType)) return ConditionalPriceTypeTemplate; - else return null; + if (value is ICell cell) { + if (cell.row is ShowQuantityQuantityModel) { + return ShowQuantityTemplate; + } + Type t = cell.data_type; + if (t == typeof(double)) return DoubleTemplate; + else if (t == typeof(bool)) return BooleanTemplate; + else if (t == typeof(int)) return IntTemplate; + else if (t == typeof(uint)) return UIntTemplate; + else if (t == typeof(QuantityMeasure)) return QuantityMeasureTemplate; + else if (t == typeof(LegSpreaderParams.Types.MarketDataType)) return MarketDataTypeTemplate; + else if (t == typeof(ConditionalQuoting.Types.PriceType)) return ConditionalPriceTypeTemplate; + } + return null; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => diff --git a/src/client/spark/Modules/Spreader/SyntheticDataHelper.cs b/src/client/spark/Modules/Spreader/SyntheticDataHelper.cs index d7ebaef72..2b35df0f2 100644 --- a/src/client/spark/Modules/Spreader/SyntheticDataHelper.cs +++ b/src/client/spark/Modules/Spreader/SyntheticDataHelper.cs @@ -109,7 +109,7 @@ namespace bts.shell { PriceType = ConditionalQuoting.Types.PriceType.Leg }; public static NullableQuantity ShowQuantity => new NullableQuantity { - Quantity = 0 + Quantity = 1 }; public static QuoteInsideMarketDistanceWithTravel QuoteInsideMarketDistanceWithTravel => new QuoteInsideMarketDistanceWithTravel { Priority = RulePriority }; public static QuoteInsideMarketDistance QuoteInsideMarketDistance => new QuoteInsideMarketDistance { Priority = RulePriority }; diff --git a/src/client/spark/Modules/Spreader/VM/Cell.cs b/src/client/spark/Modules/Spreader/VM/Cell.cs index 1e55fa6fd..5932bdf09 100644 --- a/src/client/spark/Modules/Spreader/VM/Cell.cs +++ b/src/client/spark/Modules/Spreader/VM/Cell.cs @@ -34,6 +34,8 @@ namespace mbts.spark { public virtual Type data_type { get; } = typeof(T); + public virtual IRowModel row { get => _model; } + public T value { get => _model.get_value(_leg_tup); set { @@ -64,6 +66,8 @@ namespace mbts.spark { public Type data_type { get; } = typeof(QuantityMeasure); + public virtual IRowModel row { get => _model; } + public double ratio { get => _get_qm().Ratio; set { diff --git a/src/client/spark/Modules/Spreader/VM/ParameterRows/Quote/ShowQuantity/ShowQuantityQuantityModel.cs b/src/client/spark/Modules/Spreader/VM/ParameterRows/Quote/ShowQuantity/ShowQuantityQuantityModel.cs index 1bd5982f1..4cdb916f1 100644 --- a/src/client/spark/Modules/Spreader/VM/ParameterRows/Quote/ShowQuantity/ShowQuantityQuantityModel.cs +++ b/src/client/spark/Modules/Spreader/VM/ParameterRows/Quote/ShowQuantity/ShowQuantityQuantityModel.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; namespace mbts.spark { partial class SyntheticEditorVM { - class ShowQuantityQuantityModel : RowModelBase { + internal class ShowQuantityQuantityModel : RowModelBase { IDictionary _value_store = new Dictionary(); public override string display_name => "Quantity"; diff --git a/src/client/spark/Modules/Spreader/VM/ParameterRows/RowModel.cs b/src/client/spark/Modules/Spreader/VM/ParameterRows/RowModel.cs index bae210251..acb145abb 100644 --- a/src/client/spark/Modules/Spreader/VM/ParameterRows/RowModel.cs +++ b/src/client/spark/Modules/Spreader/VM/ParameterRows/RowModel.cs @@ -32,6 +32,7 @@ namespace mbts.spark { internal interface ICell { event Action value_changed; + IRowModel row { get; } Type data_type { get; } bool enabled { get; } } @@ -40,7 +41,7 @@ namespace mbts.spark { FontWeight font_weight { get; } } - abstract class RowModelBase : ViewModelBase, IRowModel { + internal abstract class RowModelBase : ViewModelBase, IRowModel { readonly Dictionary> _enabled_store = new Dictionary>(); readonly Dictionary> _override_value_store = new Dictionary>();