diff --git a/src/client/spark/Modules/Trading/AlgoStudio/View/AlgoEditorGridView/AlgoEditorGridView.xaml b/src/client/spark/Modules/Trading/AlgoStudio/View/AlgoEditorGridView/AlgoEditorGridView.xaml index 65ff3d906..518f56ec6 100644 --- a/src/client/spark/Modules/Trading/AlgoStudio/View/AlgoEditorGridView/AlgoEditorGridView.xaml +++ b/src/client/spark/Modules/Trading/AlgoStudio/View/AlgoEditorGridView/AlgoEditorGridView.xaml @@ -377,7 +377,7 @@ diff --git a/src/client/spark/Modules/Trading/AlgoStudio/View/AlgoEditorGridView/AlgoEditorGridView.xaml.cs b/src/client/spark/Modules/Trading/AlgoStudio/View/AlgoEditorGridView/AlgoEditorGridView.xaml.cs index 93537fd45..19c59c204 100644 --- a/src/client/spark/Modules/Trading/AlgoStudio/View/AlgoEditorGridView/AlgoEditorGridView.xaml.cs +++ b/src/client/spark/Modules/Trading/AlgoStudio/View/AlgoEditorGridView/AlgoEditorGridView.xaml.cs @@ -5,8 +5,8 @@ using mbts.ui.controls; using mbts.ui.converters; using mbts.ui.utility; using System; +using System.Collections; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Linq; using System.Windows; using System.Windows.Controls; @@ -19,7 +19,19 @@ namespace mbts.ui.spark { public static readonly IValueConverter GeneralVisualStateConverter = ValueConverter.create(is_read_only => is_read_only ? VisualStateNames.General.ReadOnly : VisualStateNames.General.Normal), AlgoRootVisualStateConverter = ValueConverter.create(show_bbo => show_bbo ? VisualStateNames.AlgoRoot.Active : VisualStateNames.AlgoRoot.Inactive), - AlgoRootComboBoxMarginConverter = ValueConverter.create(name_col_width => new Thickness(name_col_width + 8, 0, 0, 0)); + AlgoRootComboBoxMarginConverter = ValueConverter.create(name_col_width => new Thickness(name_col_width + 8, 0, 0, 0)), + NullableEnumParamRowItemsSourceConverter = ValueConverter.create(param_row => { + if (param_row?.param != null) { + var tenum = param_row.param.GetType().GetInterfaceGenericArgument(AlgoParamTemplateSelector.generic_algo_param_itype); + if (tenum.IsNullable()) { + // .First() should be safe, since we know this is a Nullable. + tenum = tenum.GetGenericArguments().First(); + } + if (tenum.IsEnum) + return Enum.GetValues(tenum); + } + return null; + }); public static readonly MouseButtonEventHandler PayupTicksMouseButtonHandler = (s, e) => { if ((s as Hyperlink)?.Command is ICommand cmd) { diff --git a/src/client/spark/Modules/Trading/AlgoStudio/View/AlgoEditorGridView/AlgoParamTemplateSelector.cs b/src/client/spark/Modules/Trading/AlgoStudio/View/AlgoEditorGridView/AlgoParamTemplateSelector.cs index fcc96bc33..11459e1bc 100644 --- a/src/client/spark/Modules/Trading/AlgoStudio/View/AlgoEditorGridView/AlgoParamTemplateSelector.cs +++ b/src/client/spark/Modules/Trading/AlgoStudio/View/AlgoEditorGridView/AlgoParamTemplateSelector.cs @@ -19,6 +19,8 @@ namespace mbts.ui.spark { /// TODO: remove this class and just use a . class AlgoParamTemplateSelector : DataTemplateSelector { + public static readonly Type generic_algo_param_itype = typeof(IAlgoParamVM<>); + KeyedCollection _keyed_templates = new KeyedCollection(tsk => tsk.Key); public DataTemplate BoolTemplate { get; set; } @@ -58,7 +60,7 @@ namespace mbts.ui.spark { if (pvm is IAlgoParamVM) return QuantityMeasureTemplate; if (pvm is IAlgoParamVM) return ExecutionStrategyTemplate; if (pvm is IAlgoParamVM) return TimestampTemplate; - var targ = ReflectionHelper.GetGenericTypeArgs(pvm.GetType(), typeof(IAlgoParamVM<>)).FirstOrDefault(); + var targ = ReflectionHelper.GetGenericTypeArgs(pvm.GetType(), generic_algo_param_itype).FirstOrDefault(); if (targ != null) { if (targ.IsEnum) return EnumTemplate;