Merge branch 'master' of bitbucket.org:bluetradesys/spark

This commit is contained in:
Kevin Darby committed 2017-12-07 12:40:21 -05:00
commit 8a244d89b2
4 files changed
+116 -74

No files matched your search

@@ -32,8 +32,12 @@ namespace bts {
Window picker = new Window {
Content = view,
SizeToContent = SizeToContent.WidthAndHeight
Height = view.Height,
Width = view.Width
};
view.Height = Double.NaN;
view.Width = Double.NaN;
picker.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (sender, e) => picker.Close()));
vm.close_action = () => {
picker.Close();
@@ -49,8 +53,12 @@ namespace bts {
Window picker = new Window
{
Content = view,
SizeToContent = SizeToContent.WidthAndHeight
Height = view.Height,
Width = view.Width
};
view.Height = Double.NaN;
view.Width = Double.NaN;
picker.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (sender, e) => picker.Close()));
vm.close_action = () => {
picker.Close();
@@ -25,6 +25,8 @@ namespace mbts.spark
internal class ContractPickerModel : ViewModelBase
{
private const string dot = "•";
public ContractPickerModel(IBus bus, bool edit_mode, SecurityCriteria instrument_criteria) {
_bus = bus;
if (instrument_criteria == null) {
@@ -35,22 +37,30 @@ namespace mbts.spark
is_edit_mode = edit_mode;
_subs.Add(_bus.subscribe(SecuritiesTag).Subscribe(on_securities_changed));
add_criteria_command = new DelegateCommand(_ => {
security_criteria.Add(new SecurityCriteriaClause() {
pretty_name = criteria_input_name,
exchanges = selected_exchanges.ToArray(),
security_types = selected_security_types.ToArray(),
symbols = selected_symbols.ToArray(),
security_keys = selected_securities
});
criteria_input_name = string.Empty;
ok_button_command.TryRaiseCanExecuteChanged();
});
add_criteria_command = new DelegateCommand(
execute: _ => {
security_criteria.Add(new SecurityCriteriaClause() {
pretty_name = criteria_input_name,
exchanges = selected_exchanges.ToArray(),
security_types = selected_security_types.ToArray(),
symbols = selected_symbols.ToArray(),
security_keys = selected_securities
});
criteria_input_name = string.Empty;
ok_button_command.TryRaiseCanExecuteChanged();
remove_criteria_command.TryRaiseCanExecuteChanged();
},
can_execute: _ => { return !String.IsNullOrEmpty(criteria_input_name); }
);
remove_criteria_command = new DelegateCommand(_ => {
security_criteria.Remove(selected_security_criteria_clause);
ok_button_command.TryRaiseCanExecuteChanged();
});
remove_criteria_command = new DelegateCommand(
execute: _ => {
security_criteria.Remove(selected_security_criteria_clause);
ok_button_command.TryRaiseCanExecuteChanged();
remove_criteria_command.TryRaiseCanExecuteChanged();
},
can_execute: _ => { return security_criteria.Count > 0; }
);
ok_button_command = new DelegateCommand(
execute: _ => { close_action?.Invoke(); },
@@ -72,22 +82,22 @@ namespace mbts.spark
private void _compose_criteria_clause_name() {
string proposed_name = string.Empty;
if (selected_securities.Count > 0) {
proposed_name = all_securities.Where(s => selected_securities.Contains(s.Key)).Select(sec => sec.Value.security.ToString()).Aggregate((i, j) => $"{i} and {j}");
proposed_name = all_securities.Where(s => selected_securities.Contains(s.Key)).Select(sec => sec.Value.security.ToString()).Aggregate((i, j) => $"{i} {dot} {j}");
} else if (selected_symbols.Count > 0) {
proposed_name = $"{selected_symbols.Aggregate((i, j) => $"{i} and {j}")}";
proposed_name = $"{selected_symbols.Aggregate((i, j) => $"{i} {dot} {j}")}";
if (selected_security_types.Count > 0) {
proposed_name += $" {selected_security_types.Select(sec_type => sec_type.ToString()).Aggregate((i, j) => $"{i}s and {j}s")}";
proposed_name += $" {selected_security_types.Select(sec_type => sec_type.ToString()).Aggregate((i, j) => $"{i} {dot} {j}")}";
}
if (selected_exchanges.Count > 0) {
proposed_name += $" at {selected_exchanges.Select(exch => exch.ToString()).Aggregate((i, j) => $"{i} and {j}")}";
proposed_name += $" at {selected_exchanges.Select(exch => exch.ToString()).Aggregate((i, j) => $"{i} {dot} {j}")}";
}
} else if (selected_security_types.Count > 0) {
proposed_name = $"{selected_security_types.Select(sec_type => sec_type.ToString()).Aggregate((i, j) => $"{i}s and {j}s")}";
proposed_name = $"{selected_security_types.Select(sec_type => sec_type.ToString()).Aggregate((i, j) => $"{i} {dot} {j}")}";
if (selected_exchanges.Count > 0) {
proposed_name += $" at {selected_exchanges.Select(exch => exch.ToString()).Aggregate((i, j) => $"{i} and {j}")}";
proposed_name += $" at {selected_exchanges.Select(exch => exch.ToString()).Aggregate((i, j) => $"{i} {dot} {j}")}";
}
} else if (selected_exchanges.Count > 0) {
proposed_name = $"{selected_exchanges.Select(exch => exch.ToString()).Aggregate((i, j) => $"{i} and {j}")}";
proposed_name = $"{selected_exchanges.Select(exch => exch.ToString()).Aggregate((i, j) => $"{i} {dot} {j}")}";
}
criteria_input_name = proposed_name;
}
@@ -180,6 +190,7 @@ namespace mbts.spark
set {
_criteria_input_name = value;
RaisePropertyChanged("criteria_input_name");
add_criteria_command.TryRaiseCanExecuteChanged();
}
}
@@ -4,63 +4,86 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:converters="clr-namespace:mbts.ui.converters"
xmlns:c="clr-namespace:mbts.ui.controls"
x:ClassModifier="internal"
mc:Ignorable="d" d:DesignWidth="561.489">
<UserControl.Resources>
<converters:BooleanToObjectConverter x:Key="bool_to_selectmode" ValueForTrue="Extended" ValueForFalse="One" />
</UserControl.Resources>
<StackPanel>
<Grid Grid.IsSharedSizeScope="True" Margin="12,0,12,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="300"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="share_col_width" Width="Auto"/>
<ColumnDefinition SharedSizeGroup="share_col_width" Width="Auto"/>
<ColumnDefinition SharedSizeGroup="share_col_width" Width="Auto"/>
<ColumnDefinition MinWidth="300" Width="*"/>
</Grid.ColumnDefinitions>
<Label Grid.Row ="0" Grid.Column="0" Content="Exchange"></Label>
<Label Grid.Row ="0" Grid.Column="1" Content="Typs"></Label>
<Label Grid.Row ="0" Grid.Column="2" Content="Symbols"></Label>
<Label Grid.Row ="0" Grid.Column="3" Content="Securities"></Label>
<ListBox x:Name="_exchanges" Grid.Row ="1" Grid.Column="0" SelectionMode="{Binding is_edit_mode, Converter={StaticResource bool_to_selectmode}}" ItemsSource="{Binding all_exchanges}" Margin="2,0,2,2" ></ListBox>
<ListBox x:Name="_security_types" Grid.Row ="1" Grid.Column="1" Margin="2,0,2,2"
mc:Ignorable="d" d:DesignWidth="550" Height="500" Width="550">
<UserControl.Resources>
<converters:BooleanToObjectConverter x:Key="bool_to_selectmode" ValueForTrue="Extended" ValueForFalse="One" />
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Grid.Row="0" Grid.IsSharedSizeScope="True" Margin="12,0,12,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="share_col_width" Width="80"/>
<ColumnDefinition SharedSizeGroup="share_col_width" />
<ColumnDefinition SharedSizeGroup="share_col_width" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Grid.Row ="0" Grid.Column="0" Content="Exchange"></Label>
<Label Grid.Row ="0" Grid.Column="1" Content="Types"></Label>
<Label Grid.Row ="0" Grid.Column="2" Content="Symbols"></Label>
<Label Grid.Row ="0" Grid.Column="3" Content="Securities"></Label>
<ListBox x:Name="_exchanges" Grid.Row ="1" Grid.Column="0" SelectionMode="{Binding is_edit_mode, Converter={StaticResource bool_to_selectmode}}" ItemsSource="{Binding all_exchanges}" Margin="2,0,2,2" ></ListBox>
<ListBox x:Name="_security_types" Grid.Row ="1" Grid.Column="1" Margin="2,0,2,2"
SelectionMode="{Binding is_edit_mode, Converter={StaticResource bool_to_selectmode}}"
ItemsSource="{Binding security_types}">
</ListBox>
<ListBox x:Name="_symbols" Grid.Row ="1" Grid.Column="2" Margin="2,0,2,2"
</ListBox>
<ListBox x:Name="_symbols" Grid.Row ="1" Grid.Column="2" Margin="2,0,2,2"
SelectionMode="{Binding is_edit_mode, Converter={StaticResource bool_to_selectmode}}"
ItemsSource="{Binding symbols}"
ScrollViewer.VerticalScrollBarVisibility="Visible">
</ListBox>
<ListBox x:Name="_securities" Grid.Row ="1" Grid.Column="3" Margin="2,0,2,2"
</ListBox>
<ListBox x:Name="_securities" Grid.Row ="1" Grid.Column="3" Margin="2,0,2,2"
SelectionMode="{Binding is_edit_mode, Converter={StaticResource bool_to_selectmode}}"
ItemsSource="{Binding securities}"
ScrollViewer.VerticalScrollBarVisibility="Visible"
HorizontalAlignment="Stretch">
</ListBox>
</Grid>
<Grid Grid.Row="1" Margin="0,10,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Row="0" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="72"/>
</Grid.ColumnDefinitions>
<TextBox Grid.Row="0" Grid.Column="0" Text="{Binding criteria_input_name}" IsReadOnly="True" Visibility="{Binding is_edit_mode, Converter={StaticResource BoolToVisibility}}" Margin="12,0,10,0" VerticalAlignment="Top"></TextBox>
<Button Grid.Row="0" Grid.Column="1" Command="{Binding add_criteria_command}" HorizontalAlignment="Left" Width="60" Visibility="{Binding is_edit_mode, Converter={StaticResource BoolToVisibility}}">
<AccessText>_Add</AccessText>
</Button>
<Label Grid.Row="1" Content="Picked Securities" Visibility="{Binding is_edit_mode, Converter={StaticResource BoolToVisibility}}" Margin="12,0,0,0"></Label>
<ListBox x:Name="_criteria" Grid.Row="2" Grid.Column="0" ScrollViewer.VerticalScrollBarVisibility="Visible"
ItemsSource="{Binding security_criteria}" SelectedItem="{Binding selected_security_criteria_clause}"
Visibility="{Binding is_edit_mode, Converter={StaticResource BoolToVisibility}}"
Margin="12,0,10,10" VerticalAlignment="Stretch" Height="70">
</ListBox>
</Grid>
<GroupBox Header="Picked instruments" Margin="12,0,12,0" Visibility="{Binding is_edit_mode, Converter={StaticResource BoolToVisibility}}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*" MinHeight="100"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBox Grid.Row="0" Grid.Column="0" Text="{Binding criteria_input_name}" Margin="2" IsReadOnly="True"></TextBox>
<Button Grid.Row="0" Grid.Column="1" Command="{Binding add_criteria_command}" Margin="2" HorizontalAlignment="Left" Width="50">Add</Button>
<ListBox x:Name="_criteria" Grid.Row="1" Grid.Column="0" ItemsSource="{Binding security_criteria}" SelectedItem="{Binding selected_security_criteria_clause}" Margin="2"></ListBox>
<Button Grid.Row="1" Grid.Column="1" Command="{Binding remove_criteria_command}" Margin="2" HorizontalAlignment="Left" VerticalAlignment="Top" Width="50">Remove</Button>
</Grid>
</GroupBox>
<UniformGrid HorizontalAlignment="Right" Rows="1" Columns="2" Margin="0,12,12,12">
<Button Width="50" Margin="12,0,0,0" Command="{Binding ok_button_command}">Ok</Button>
<Button Width="50" Margin="12,0,0,0" Command="ApplicationCommands.Close">Cancel</Button>
</UniformGrid>
</StackPanel>
<Button Grid.Row="2" Grid.Column="1" Command="{Binding remove_criteria_command}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="60" Margin="0,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}"/>
</Grid>
</Grid>
</Grid>
</UserControl>
@@ -99,7 +99,7 @@ namespace mbts.spark
}
[Export(typeof(IShellModule))]
//[Export(typeof(IShellModule))]
public class TempModule : IShellModule {
private IBus _bus;
@@ -135,7 +135,7 @@ namespace mbts.spark
var x = new Window {
Content = new ContractPickerView(new ContractPickerModel(_bus, false, null))
};
x.SizeToContent = SizeToContent.WidthAndHeight;
//x.SizeToContent = SizeToContent.WidthAndHeight;
x.Show();
}
}