SPARK-567 in synth security creation form the sec picker disappears on click

This commit is contained in:
John Colvin committed 2018-03-06 23:51:20 -05:00
1 parent d224527a3c
commit f141ff6135
8 files changed
+89 -21

No files matched your search

@@ -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);
};
@@ -221,8 +221,8 @@
IsOpen="{Binding IsNewLegPopupOpen, RelativeSource={RelativeSource AncestorType=usp:ExecutionStrategyEditor}, Mode=TwoWay}"
>
<msp:ContractPickerView
CloseOnOK="False" CloseOnCancel="False"
DataContext="{Binding ContractPickerModel, RelativeSource={RelativeSource AncestorType=usp:ExecutionStrategyEditor}}"
CloseOnOK="False"
/>
</c:PopupControl>
</DataGridTextColumn.Header>
@@ -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<Security>(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));
}
}
}
@@ -32,6 +32,9 @@
<Button Grid.Column="1"
HorizontalAlignment="Left"
Margin="8,12,12,10"
Command="{TemplateBinding CancelCommand}"
CommandParameter="{TemplateBinding CancelCommandParameter}"
u:Behavior.CloseWindow="{TemplateBinding CloseOnCancel}"
Style="{DynamicResource CancelButton}" />
</Grid>
</Border>
@@ -3,27 +3,65 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace mbts.ui.controls
{
namespace mbts.ui.controls {
/// <summary>
/// Interaction logic for DialogSkirtOKCancel.xaml
/// </summary>
public class DialogSkirtOKCancel : Control
{
static DialogSkirtOKCancel() {
class DialogSkirtOKCancel : Control {
static DialogSkirtOKCancel() =>
DefaultStyleKeyProperty.OverrideMetadata(typeof(DialogSkirtOKCancel), new FrameworkPropertyMetadata(typeof(DialogSkirtOKCancel)));
}
public static readonly DependencyProperty IsOkDefaultProperty = DependencyProperty.Register("IsOkDefault", typeof(bool), typeof(DialogSkirtOKCancel), new PropertyMetadata(true));
public static readonly DependencyProperty OKCommandProperty = DependencyProperty.Register("OKCommand", typeof(ICommand), typeof(DialogSkirtOKCancel));
public static readonly DependencyProperty OKCommandParameterProperty = DependencyProperty.Register("OKCommandParameter", typeof(object), typeof(DialogSkirtOKCancel));
public static readonly DependencyProperty CloseOnOKProperty = DependencyProperty.Register(nameof(CloseOnOK), typeof(bool), typeof(DialogSkirtOKCancel), new PropertyMetadata(true));
#region IsOKDefault
public static readonly DependencyProperty IsOkDefaultProperty =
DependencyProperty.Register(nameof(IsOkDefault), typeof(bool), typeof(DialogSkirtOKCancel), new PropertyMetadata(true));
public bool IsOkDefault { get { return (bool)GetValue(IsOkDefaultProperty); } set { SetValue(IsOkDefaultProperty, value); } }
#endregion
#region OKCommand
public static readonly DependencyProperty OKCommandProperty =
DependencyProperty.Register(nameof(OKCommand), typeof(ICommand), typeof(DialogSkirtOKCancel));
[Bindable(true)]
public ICommand OKCommand { get { return GetValue(OKCommandProperty) as ICommand; } set { SetValue(OKCommandProperty, value); } }
#endregion
#region OKCommandParameter
public static readonly DependencyProperty OKCommandParameterProperty =
DependencyProperty.Register(nameof(OKCommandParameter), typeof(object), typeof(DialogSkirtOKCancel));
[Bindable(true)]
public object OKCommandParameter { get { return GetValue(OKCommandParameterProperty); } set { SetValue(OKCommandParameterProperty, value); } }
#endregion
#region CancelCommand
public static readonly DependencyProperty CancelCommandProperty =
DependencyProperty.Register(nameof(CancelCommand), typeof(ICommand), typeof(DialogSkirtOKCancel));
[Bindable(true)]
public ICommand CancelCommand { get { return GetValue(CancelCommandProperty) as ICommand; } set { SetValue(CancelCommandProperty, value); } }
#endregion
#region CancelCommandParameter
public static readonly DependencyProperty CancelCommandParameterProperty =
DependencyProperty.Register(nameof(CancelCommandParameter), typeof(object), typeof(DialogSkirtOKCancel));
[Bindable(true)]
public object CancelCommandParameter { get { return GetValue(CancelCommandParameterProperty); } set { SetValue(CancelCommandParameterProperty, value); } }
#endregion
#region CloseOnOK
public static readonly DependencyProperty CloseOnOKProperty =
DependencyProperty.Register(nameof(CloseOnOK), typeof(bool), typeof(DialogSkirtOKCancel), new PropertyMetadata(true));
public bool CloseOnOK { get => (bool)GetValue(CloseOnOKProperty); set => SetValue(CloseOnOKProperty, value); }
#endregion
#region CloseOnCancel
public static readonly DependencyProperty CloseOnCancelProperty =
DependencyProperty.Register(nameof(CloseOnCancel), typeof(bool), typeof(DialogSkirtOKCancel), new PropertyMetadata(true));
public bool CloseOnCancel { get => (bool)GetValue(CloseOnCancelProperty); set => SetValue(CloseOnCancelProperty, value); }
#endregion
}
}
@@ -83,7 +83,7 @@ namespace mbts.spark
);
ok_button_command = new DelegateCommand(
execute: _ => { close_action?.Invoke(); },
execute: _ => { ok_action?.Invoke(); },
can_execute: _ => {
if (!is_edit_mode) {
return (selected_securities.Count > 0);
@@ -93,6 +93,8 @@ namespace mbts.spark
}
);
cancel_button_command = new DelegateCommand(() => cancel_action?.Invoke());
add_symbol_command = new DelegateCommand<string>(symbol => {
_compose_criteria_clause_name(true);
if (!security_criteria_clauses.Any(x => x.pretty_name == _criteria_input_name_from_double_click)) {
@@ -244,6 +246,7 @@ namespace mbts.spark
public ICommand add_criteria_command { get; }
public ICommand remove_criteria_command { get; }
public ICommand ok_button_command { get; }
public ICommand cancel_button_command { get; }
public ICommand add_symbol_command { get; }
public ICommand add_security_type_command { get; }
public ICommand add_exchange_command { get; }
@@ -277,7 +280,8 @@ namespace mbts.spark
}
}
public Action close_action { get; set; }
public Action ok_action { get; set; }
public Action cancel_action { get; set; }
public bool is_edit_mode { get; set; }
@@ -181,7 +181,13 @@
<Button Grid.Row="2" Grid.Column="1" Command="{Binding remove_criteria_command}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="60" Margin="5,0,0,10" Visibility="{Binding is_edit_mode, Converter={StaticResource BoolToVisibility}}">
<AccessText>_Remove</AccessText>
</Button>
<c:DialogSkirtOKCancel Grid.Row="3" Grid.ColumnSpan="2" OKCommand="{Binding ok_button_command}" CloseOnOK="{Binding CloseOnOK, RelativeSource={RelativeSource AncestorType=sp:ContractPickerView}}"/>
<c:DialogSkirtOKCancel
Grid.Row="3" Grid.ColumnSpan="2"
OKCommand="{Binding ok_button_command}"
CancelCommand="{Binding cancel_button_command}"
CloseOnOK="{Binding CloseOnOK, RelativeSource={RelativeSource AncestorType=sp:ContractPickerView}}"
CloseOnCancel="{Binding CloseOnCancel, RelativeSource={RelativeSource AncestorType=sp:ContractPickerView}}"
/>
</Grid>
</Grid>
</Grid>
@@ -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<SecurityCriteriaClause>());
}
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))]