From f141ff6135946c510f49437f2a158deecdd80a4a Mon Sep 17 00:00:00 2001 From: John Colvin Date: Tue, 6 Mar 2018 23:51:20 -0500 Subject: [PATCH] SPARK-567 in synth security creation form the sec picker disappears on click --- .../spark/Daemons/SecurityPickerDaemon.cs | 6 +- .../Spreader/ExecutionStrategyEditor.xaml | 2 +- .../Modules/Spreader/VM/SyntheticEditorVM.cs | 11 +++- .../DialogSkirts/DialogSkirtOKCancel.xaml | 3 + .../DialogSkirts/DialogSkirtOKCancel.xaml.cs | 58 +++++++++++++++---- .../ContractPicker/ContractPickerModel.cs | 8 ++- .../ContractPicker/ContractPickerView.xaml | 8 ++- .../ContractPicker/ContractPickerView.xaml.cs | 14 ++++- 8 files changed, 89 insertions(+), 21 deletions(-) diff --git a/src/client/spark/Daemons/SecurityPickerDaemon.cs b/src/client/spark/Daemons/SecurityPickerDaemon.cs index 39b4c2fe7..d85d45a37 100644 --- a/src/client/spark/Daemons/SecurityPickerDaemon.cs +++ b/src/client/spark/Daemons/SecurityPickerDaemon.cs @@ -44,7 +44,7 @@ namespace bts { view.Height = Double.NaN; view.Width = Double.NaN; - vm.close_action = () => { + vm.ok_action = () => { picker.Close(); message.complete(vm.result).execute(_bus); }; @@ -68,7 +68,7 @@ namespace bts { view.Height = Double.NaN; view.Width = Double.NaN; - vm.close_action = () => { + vm.ok_action = () => { picker.Close(); message.complete(vm.result_criteria).execute(_bus); }; @@ -91,7 +91,7 @@ namespace bts { view.Height = Double.NaN; view.Width = Double.NaN; - vm.close_action = () => { + vm.ok_action = () => { picker.Close(); message_and_data.message.complete(vm.result_criteria).execute(_bus); }; diff --git a/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml b/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml index 6bf5b35da..f0dbb45f5 100644 --- a/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml +++ b/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml @@ -221,8 +221,8 @@ IsOpen="{Binding IsNewLegPopupOpen, RelativeSource={RelativeSource AncestorType=usp:ExecutionStrategyEditor}, Mode=TwoWay}" > diff --git a/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs b/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs index 8399981fa..431550708 100644 --- a/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs +++ b/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs @@ -46,11 +46,11 @@ namespace mbts.spark { title = "Create Synthetic"; icon = Icons.Tetris; contract_picker_model = new ContractPickerModel(bus, false, null); - contract_picker_model.close_action = () => { + contract_picker_model.cancel_action = _close_new_leg_popup; + contract_picker_model.ok_action = () => { if (!leg_tuples.Any(l => l.leg.Security.Id == contract_picker_model.result.security.Id)) { leg_tuples.Add(leg_tuple_factory(contract_picker_model.result.security)); - is_new_leg_popup_open = false; - RaisePropertyChanged(nameof(is_new_leg_popup_open)); + _close_new_leg_popup(); } }; remove_leg = new DelegateCommand(s => leg_tuples.removeFirst(l => l.leg.Security.Id == s.Id)); @@ -154,5 +154,10 @@ namespace mbts.spark { _tick_factors = TickUtils.deduce_ticks(leg_tuples.Select(l => l.leg.Security.ContractSpec)); RaisePropertyChanged(nameof(tick_factors)); } + + void _close_new_leg_popup() { + is_new_leg_popup_open = false; + RaisePropertyChanged(nameof(is_new_leg_popup_open)); + } } } \ No newline at end of file diff --git a/src/client/spark/view/Controls/DialogSkirts/DialogSkirtOKCancel.xaml b/src/client/spark/view/Controls/DialogSkirts/DialogSkirtOKCancel.xaml index 0f65ba4ed..9008edf0e 100644 --- a/src/client/spark/view/Controls/DialogSkirts/DialogSkirtOKCancel.xaml +++ b/src/client/spark/view/Controls/DialogSkirts/DialogSkirtOKCancel.xaml @@ -32,6 +32,9 @@ - + diff --git a/src/client/spark/view/Spark/ContractPicker/ContractPickerView.xaml.cs b/src/client/spark/view/Spark/ContractPicker/ContractPickerView.xaml.cs index 99cf55cf9..f582f25ab 100644 --- a/src/client/spark/view/Spark/ContractPicker/ContractPickerView.xaml.cs +++ b/src/client/spark/view/Spark/ContractPicker/ContractPickerView.xaml.cs @@ -17,6 +17,7 @@ using System.IO; using bts.api; using System.ComponentModel.Composition; using bts.spark; +using mbts.ui.controls; namespace mbts.spark { @@ -107,8 +108,19 @@ namespace mbts.spark ((ContractPickerModel)DataContext).criteria_selection_changed(_criteria.SelectedItems.Cast()); } - public static readonly DependencyProperty CloseOnOKProperty = DependencyProperty.Register(nameof(CloseOnOK), typeof(bool), typeof(ContractPickerView), new PropertyMetadata(true)); + #region CloseOnOK + public static readonly DependencyProperty CloseOnOKProperty = + DialogSkirtOKCancel.CloseOnOKProperty.AddOwner(typeof(ContractPickerView)); + public bool CloseOnOK { get => (bool)GetValue(CloseOnOKProperty); set => SetValue(CloseOnOKProperty, value); } + #endregion + + #region CloseOnCancel + public static readonly DependencyProperty CloseOnCancelProperty = + DialogSkirtOKCancel.CloseOnCancelProperty.AddOwner(typeof(ContractPickerView)); + + public bool CloseOnCancel { get => (bool)GetValue(CloseOnCancelProperty); set => SetValue(CloseOnCancelProperty, value); } + #endregion } //[Export(typeof(IShellModule))]