Merge branch 'master' of bitbucket.org:bluetradesys/spark
This commit is contained in:
commit
ff363d1398
8 files changed
+98
-77
No files matched your search
@@ -400,17 +400,21 @@ namespace mbts
|
||||
return -1;
|
||||
}
|
||||
|
||||
#region Curry
|
||||
public static Func<TA, Func<TB, TR>> curry<TA, TB, TR>(Func<TA, TB, TR> fn) {
|
||||
return a => b => fn(a, b);
|
||||
public static void ignore(this Task t) { }
|
||||
|
||||
public static Google.Protobuf.WellKnownTypes.Timestamp ToGoogleTime(this DateTime self) {
|
||||
return Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(self);
|
||||
}
|
||||
public static Func<TA, Func<TB, Func<TC, TR>>> curry<TA, TB, TC, TR>(Func<TA, TB, TC, TR> fn) {
|
||||
return a => b => c => fn(a, b, c);
|
||||
|
||||
public static bool TryGetValue<TKey, T>(this ILookup<TKey, T> self, TKey key, out IEnumerable<T> value) {
|
||||
bool has_value = self.Contains(key);
|
||||
if (has_value) {
|
||||
value = self[key];
|
||||
}
|
||||
else { value = Enumerable.Empty<T>(); }
|
||||
return has_value;
|
||||
}
|
||||
public static Func<TA, Func<TB, Func<TC, Func<TD, TR>>>> curry<TA, TB, TC, TD, TR>(this Func<TA, TB, TC, TD, TR> fn) {
|
||||
return a => b => c => d => fn(a, b, c, d);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,9 @@ namespace mbts.spark {
|
||||
private class SparkTag<T> : ITag<T> { private readonly string Name; public SparkTag(string name) { Name = name; } }
|
||||
|
||||
#region Core Data
|
||||
public static ITag ExchangeSecuritiesTag { get; } = new SparkTag("ExchangeSecuritiesTag");
|
||||
public static ITag<IReadOnlyDictionary<uint, SecurityMD>> SecuritiesTag { get; } = new SparkTag<IReadOnlyDictionary<uint, SecurityMD>>("Securities");
|
||||
public static ITag SyntheticSecuritiesTag { get; } = new SparkTag("SyntheticSecuritiesTag");
|
||||
public static ITag OrderBookTag = new SparkTag("OrderBookTag");
|
||||
public static ITag OrderBookTag { get; } = new SparkTag("OrderBookTag");
|
||||
public static ITag PositionsTag { get; } = new SparkTag(nameof(PositionsTag));
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ namespace mbts.spark
|
||||
} else show_synthetic_editor(msg.data.CloneToMutable(), ses.ExecutionStrategy);
|
||||
}
|
||||
private void show_synthetic_editor_warning(string warn_msg) {
|
||||
BTSMessageBox.Show(warn_msg, "Synthetic Strategy", MessageBoxButton.OK, MessageBoxImage.Exclamation, true, false, true);
|
||||
BTSMessageBox.Show(warn_msg, "Synthetic Strategy", BTSMessageBoxButtons.OK, MessageBoxImage.Exclamation, true, false, true);
|
||||
}
|
||||
private void show_synthetic_editor(Security synthetic, ExecutionStrategy strategy) {
|
||||
var dialog = new SyntheticEditorDialog { DataContext = new SyntheticEditorVM(_bus, synthetic, strategy) }.Show(-200, -300, true);
|
||||
|
||||
@@ -454,6 +454,18 @@ M0,0L63.999001,0 63.999001,48.792999 0,48.792999z">
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
|
||||
<!-- help / support -->
|
||||
<DrawingImage x:Key="SupportIcon">
|
||||
<DrawingImage.Drawing>
|
||||
<DrawingGroup>
|
||||
<DrawingGroup.Children>
|
||||
<GeometryDrawing Brush="Black"
|
||||
Geometry="M23.679005,26.495C23.99901,26.495 24.265014,26.59 24.475017,26.78 24.685019,26.967 24.79102,27.204 24.79102,27.491 24.79102,27.783 24.68802,28.024 24.481016,28.214 24.271013,28.405 24.00301,28.5 23.679005,28.5 23.354001,28.5 23.085997,28.403 22.870994,28.208 22.655991,28.006 22.54899,27.766 22.54899,27.491 22.54899,27.207 22.655991,26.97 22.870994,26.78 23.085997,26.59 23.354001,26.495 23.679005,26.495z M23.734006,19.5C24.110011,19.5 24.460016,19.541 24.785021,19.625 25.110025,19.708 25.392029,19.839 25.632032,20.017 25.874036,20.195 26.062038,20.422 26.19904,20.7 26.333042,20.978 26.401043,21.311 26.401043,21.7 26.401043,21.947 26.373043,22.171 26.316042,22.371 26.259041,22.572 26.17704,22.762 26.067039,22.94 25.958037,23.118 25.822035,23.289 25.660033,23.453 25.498031,23.617 25.311028,23.786 25.101026,23.961 24.959023,24.078 24.835021,24.187 24.72802,24.289 24.620018,24.39 24.531017,24.49 24.460016,24.589 24.389015,24.689 24.335014,24.794 24.299014,24.905 24.262013,25.017 24.244013,25.144 24.244013,25.285 24.244013,25.383 24.257013,25.482 24.283013,25.583 24.310014,25.685 24.345015,25.77 24.390016,25.838L22.791993,25.838C22.751992,25.733 22.719992,25.615 22.697992,25.483 22.674991,25.351 22.663991,25.226 22.663991,25.109 22.663991,24.922 22.681992,24.752 22.718992,24.599 22.754992,24.445 22.809993,24.3 22.882994,24.164 22.955995,24.029 23.046997,23.898 23.155998,23.775 23.266,23.652 23.393002,23.529 23.539003,23.407 23.694005,23.278 23.828007,23.157 23.943009,23.046 24.059011,22.935 24.157012,22.823 24.238013,22.712 24.320014,22.6 24.380015,22.485 24.420015,22.365 24.460016,22.246 24.481016,22.113 24.481016,21.967 24.481016,21.841 24.459016,21.725 24.414016,21.618 24.369015,21.51 24.306014,21.419 24.222013,21.341 24.140012,21.264 24.03901,21.203 23.918009,21.159 23.799007,21.115 23.667005,21.092 23.521003,21.092 23.204998,21.092 22.876994,21.158 22.536989,21.29 22.195985,21.422 21.87398,21.621 21.569976,21.888L21.569976,20.059C21.88298,19.872 22.222985,19.733 22.59099,19.64 22.959995,19.547 23.341001,19.5 23.734006,19.5z M23.985949,18C20.670016,18 17.972007,20.69101 17.972007,24 17.972007,27.309021 20.670016,30 23.985949,30 27.302003,30 30.000989,27.309021 30.000989,24 30.000989,20.69101 27.302003,18 23.985949,18z M14,2C10.968,2 8.5,4.467 8.5,7.5 8.5,10.438219 10.81616,12.84526 13.717461,12.992831L13.973991,12.99934 13.99997,12.999012 14.027442,12.999304 14.28254,12.992831C17.18384,12.84526 19.5,10.438219 19.5,7.5 19.5,4.467 17.032,2 14,2z M14,0C18.136,0 21.5,3.3640003 21.5,7.5 21.5,9.95575 20.314059,12.13934 18.484733,13.508212L18.265061,13.664531 18.342722,13.68891C19.921902,14.202736,21.408062,14.995103,22.721599,16.037384L22.786062,16.089699 22.966662,16.064397C23.300515,16.021905 23.640717,16 23.985949,16 28.405035,16 32.000998,19.588989 32.000998,24 32.000998,28.411011 28.405035,32 23.985949,32 19.566984,32 15.971998,28.411011 15.971998,24 15.971998,20.96743 17.671191,18.323394 20.169134,16.967021L20.4065,16.845489 20.189965,16.712549C18.448412,15.669154,16.455822,15.076083,14.409823,15.006025L14.033219,14.999578 14,15 13.960834,14.999503 13.690718,15.00291C7.2160797,15.166433,1.9999962,20.449734,1.9999962,26.921989L0,26.928989 0,26.921989C0,20.80439,3.9878531,15.595488,9.51441,13.731782L9.7309766,13.661711 9.5152669,13.508212C7.6859417,12.13934 6.5,9.95575 6.5,7.5 6.5,3.3640003 9.8640003,0 14,0z" />
|
||||
</DrawingGroup.Children>
|
||||
</DrawingGroup>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
|
||||
<!-- Pin
|
||||
<Path Data="F1M3,11L3,7 0,7 0,6 1,6 1,1 1,0 6,0 6,1 6,6 7,6 7,7 4,7 4,11 3,11z M2,1L2,6 4,6 4,1 2,1z" />
|
||||
Unpin
|
||||
|
||||
@@ -9,29 +9,35 @@
|
||||
ui:WindowStyle.ShowMaximizeButton="False" ui:WindowStyle.ShowMinimizeButton="False" ui:WindowStyle.AllowResize="False"
|
||||
Style="{StaticResource BTSWindow}"
|
||||
mc:Ignorable="d" SizeToContent="WidthAndHeight">
|
||||
<Window.Resources>
|
||||
<converters:SystemIconConverter x:Key="SystemIconConverter" />
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="60"/>
|
||||
<ColumnDefinition Width="220" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition MinHeight="92" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Window.Resources>
|
||||
<converters:SystemIconConverter x:Key="SystemIconConverter" />
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="60"/>
|
||||
<ColumnDefinition Width="220" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition MinHeight="92" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Image Source="{Binding Image, Converter={StaticResource SystemIconConverter}}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="32" Height="32" SnapsToDevicePixels="True" />
|
||||
<TextBlock TextWrapping="Wrap" Text="{Binding Text}" VerticalAlignment="Center" Grid.Column="1" Margin="5"/>
|
||||
<Image Source="{Binding Image, Converter={StaticResource SystemIconConverter}}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="32" Height="32" SnapsToDevicePixels="True" />
|
||||
<TextBlock TextWrapping="Wrap" Text="{Binding Text}" VerticalAlignment="Center" Grid.Column="1" Margin="5"/>
|
||||
|
||||
<Rectangle Fill="{x:Static uicore:BTSColors.dialog_skirt_brush}" Grid.Row="1" Grid.ColumnSpan="2" Opacity="0.2"/>
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="1" Grid.ColumnSpan="2" HorizontalAlignment="Right" Margin="0,5,0,8">
|
||||
<Button Margin="0,0,15,0" Height="22" Width="60" Click="yes_click" Visibility="{Binding show_yes_no, Converter={StaticResource BoolToVisibility}}">Yes</Button>
|
||||
<Button Margin="0,0,15,0" Height="22" Width="60" Click="no_click" Visibility="{Binding show_yes_no, Converter={StaticResource BoolToVisibility}}">No</Button>
|
||||
<Button IsDefault="True" Margin="0,0,15,0" Width="60" Height="22" Click="ok_click" Visibility="{Binding show_ok, Converter={StaticResource BoolToVisibility}}">OK</Button>
|
||||
<Button IsCancel="True" Margin="0,0,15,0" Width="60" Height="22" Visibility="{Binding show_cancel, Converter={StaticResource BoolToVisibility}}">Cancel</Button>
|
||||
<Rectangle Fill="{x:Static uicore:BTSColors.dialog_skirt_brush}" Grid.Row="1" Grid.ColumnSpan="2" Opacity="0.2"/>
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="1" Grid.ColumnSpan="2" HorizontalAlignment="Right" Margin="0,5,0,8">
|
||||
<Button Margin="0,0,15,0" Height="22" MinWidth="60" Click="support_click" Visibility="{Binding show_support, Converter={StaticResource BoolToVisibility}}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image Source="{StaticResource SupportIcon}" Margin="5,0" />
|
||||
<TextBlock Margin="5,0">Support</TextBlock>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Margin="0,0,15,0" Height="22" Width="60" Click="yes_click" Visibility="{Binding show_yes_no, Converter={StaticResource BoolToVisibility}}">Yes</Button>
|
||||
<Button Margin="0,0,15,0" Height="22" Width="60" Click="no_click" Visibility="{Binding show_yes_no, Converter={StaticResource BoolToVisibility}}">No</Button>
|
||||
<Button IsDefault="True" Margin="0,0,15,0" Width="60" Height="22" Click="ok_click" Visibility="{Binding show_ok, Converter={StaticResource BoolToVisibility}}">OK</Button>
|
||||
<Button IsCancel="True" Margin="0,0,15,0" Width="60" Height="22" Visibility="{Binding show_cancel, Converter={StaticResource BoolToVisibility}}">Cancel</Button>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,86 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Media;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace mbts.ui
|
||||
{
|
||||
namespace mbts.ui {
|
||||
[Flags]
|
||||
public enum BTSMessageBoxButtons {
|
||||
OK = 0x1,
|
||||
Cancel = 0x2,
|
||||
Yes = 0x4,
|
||||
No = 0x8,
|
||||
Support = 0x10
|
||||
}
|
||||
public partial class BTSMessageBox : Window
|
||||
{
|
||||
private BTSMessageBox(MessageBoxButton buttons)
|
||||
private BTSMessageBox(BTSMessageBoxButtons buttons)
|
||||
{
|
||||
InitializeComponent();
|
||||
Text = "There has been an error in the designer and you need to set text in order for it to be displayed.";
|
||||
Image = MessageBoxImage.Error;
|
||||
//far_right = new Thickness(0, 0, 8, 0);
|
||||
//middle = new Thickness(0, 0, 8, 0);
|
||||
}
|
||||
|
||||
#region dependency properties
|
||||
|
||||
public string Text { get; private set; }
|
||||
public MessageBoxImage Image { get; private set; }
|
||||
public MessageBoxButton Buttons { get; private set; }
|
||||
public MessageBoxResult Result { get; private set; }
|
||||
public BTSMessageBoxButtons Buttons { get; private set; }
|
||||
public BTSMessageBoxButtons Result { get; private set; }
|
||||
|
||||
public bool show_ok { get { return Buttons == MessageBoxButton.OK || Buttons == MessageBoxButton.OKCancel; } }
|
||||
public bool show_cancel { get { return Buttons == MessageBoxButton.OKCancel || Buttons == MessageBoxButton.YesNoCancel; } }
|
||||
public bool show_yes_no { get { return Buttons == MessageBoxButton.YesNo || Buttons == MessageBoxButton.YesNoCancel; } }
|
||||
public bool show_ok => Buttons.HasFlag(BTSMessageBoxButtons.OK);
|
||||
public bool show_cancel => Buttons.HasFlag(BTSMessageBoxButtons.Cancel);
|
||||
public bool show_yes_no => Buttons.HasFlag(BTSMessageBoxButtons.Yes) || Buttons.HasFlag(BTSMessageBoxButtons.No);
|
||||
public bool show_support => Buttons.HasFlag(BTSMessageBoxButtons.Support);
|
||||
|
||||
#endregion
|
||||
|
||||
public static Task<MessageBoxResult> ShowAsTask(string message, string title) {
|
||||
return ShowAsTask(message, title, MessageBoxButton.OK, MessageBoxImage.None, false, false);
|
||||
public static Task<BTSMessageBoxButtons> ShowAsync(string message, string title) {
|
||||
return ShowAsync(message, title, BTSMessageBoxButtons.OK, MessageBoxImage.None, false, false);
|
||||
}
|
||||
|
||||
public static Task<MessageBoxResult> ShowAsTask(string message, string title, MessageBoxButton buttons) {
|
||||
return ShowAsTask(message, title, buttons, MessageBoxImage.None);
|
||||
public static Task<BTSMessageBoxButtons> ShowAsTask(string message, string title, BTSMessageBoxButtons buttons) {
|
||||
return ShowAsync(message, title, buttons, MessageBoxImage.None);
|
||||
}
|
||||
|
||||
public static Task<MessageBoxResult> ShowAsTask(string message, string title, MessageBoxButton buttons, MessageBoxImage icon) {
|
||||
return ShowAsTask(message, title, buttons, icon, false, false);
|
||||
public static Task<BTSMessageBoxButtons> ShowAsync(string message, string title, BTSMessageBoxButtons buttons, MessageBoxImage icon) {
|
||||
return ShowAsync(message, title, buttons, icon, false, false);
|
||||
}
|
||||
|
||||
public static Task<MessageBoxResult> ShowAsTask(string message, string title, MessageBoxButton buttons, MessageBoxImage icon, bool move_to_mouse, bool top_most = true) {
|
||||
var tcs = new TaskCompletionSource<MessageBoxResult>();
|
||||
public static Task<BTSMessageBoxButtons> ShowAsync(string message, string title, BTSMessageBoxButtons buttons, MessageBoxImage icon, bool move_to_mouse, bool top_most = true) {
|
||||
var tcs = new TaskCompletionSource<BTSMessageBoxButtons>();
|
||||
var mb = _create_message_box(message, title, buttons, icon, move_to_mouse, top_most);
|
||||
mb.Closed += (s, e) => tcs.SetResult(mb.Result);
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
public static MessageBoxResult Show(string message)
|
||||
public static BTSMessageBoxButtons Show(string message)
|
||||
{
|
||||
return Show(message, message);
|
||||
}
|
||||
|
||||
public static MessageBoxResult Show(string message, string title)
|
||||
public static BTSMessageBoxButtons Show(string message, string title)
|
||||
{
|
||||
return Show(message, title, MessageBoxButton.OK);
|
||||
return Show(message, title, BTSMessageBoxButtons.OK);
|
||||
}
|
||||
|
||||
public static MessageBoxResult Show(string message, string title, MessageBoxButton buttons)
|
||||
public static BTSMessageBoxButtons Show(string message, string title, BTSMessageBoxButtons buttons)
|
||||
{
|
||||
return Show(message, title, buttons, MessageBoxImage.None);
|
||||
}
|
||||
|
||||
public static MessageBoxResult Show(string message, string title, MessageBoxButton buttons, MessageBoxImage icon)
|
||||
public static BTSMessageBoxButtons Show(string message, string title, BTSMessageBoxButtons buttons, MessageBoxImage icon)
|
||||
{
|
||||
return Show(message, title, buttons, icon, false, true, false);
|
||||
}
|
||||
|
||||
public static MessageBoxResult Show(string message, string title, MessageBoxButton buttons, MessageBoxImage icon, bool move_to_mouse, bool is_modal, bool top_most = true)
|
||||
public static BTSMessageBoxButtons Show(string message, string title, BTSMessageBoxButtons buttons, MessageBoxImage icon, bool move_to_mouse, bool is_modal, bool top_most = true)
|
||||
{
|
||||
var mb = _create_message_box(message, title, buttons, icon, move_to_mouse, top_most);
|
||||
if (is_modal)
|
||||
@@ -90,11 +85,11 @@ namespace mbts.ui
|
||||
return mb.Result;
|
||||
}
|
||||
|
||||
public static MessageBoxResult ShowError(string error_prefix, string title, Exception ex, bool show_full_error = false) {
|
||||
return Show("{0}:\n{1}".fmt(error_prefix, show_full_error ? ex.ToString() : ex.Message), title, MessageBoxButton.OK, MessageBoxImage.Error, true, false, true);
|
||||
public static BTSMessageBoxButtons ShowError(string error_prefix, string title, Exception ex, bool show_full_error = false) {
|
||||
return Show("{0}:\n{1}".fmt(error_prefix, show_full_error ? ex.ToString() : ex.Message), title, BTSMessageBoxButtons.OK, MessageBoxImage.Error, true, false, true);
|
||||
}
|
||||
|
||||
private static BTSMessageBox _create_message_box(string message, string title, MessageBoxButton buttons, MessageBoxImage icon, bool move_to_mouse, bool top_most) {
|
||||
private static BTSMessageBox _create_message_box(string message, string title, BTSMessageBoxButtons buttons, MessageBoxImage icon, bool move_to_mouse, bool top_most) {
|
||||
var mb = new BTSMessageBox(buttons)
|
||||
{
|
||||
Text = message,
|
||||
@@ -125,28 +120,33 @@ namespace mbts.ui
|
||||
|
||||
private void ok_click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Result = MessageBoxResult.OK;
|
||||
this.Result = BTSMessageBoxButtons.OK;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void cancel_click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Result = MessageBoxResult.Cancel;
|
||||
this.Result = BTSMessageBoxButtons.Cancel;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void yes_click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Result = MessageBoxResult.Yes;
|
||||
this.Result = BTSMessageBoxButtons.Yes;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void no_click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Result = MessageBoxResult.No;
|
||||
this.Result = BTSMessageBoxButtons.No;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void support_click(object sender, RoutedEventArgs e) {
|
||||
Result = BTSMessageBoxButtons.Support;
|
||||
Close();
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(KeyEventArgs e) {
|
||||
base.OnKeyDown(e);
|
||||
if (e.Key == Key.C && Keyboard.Modifiers == ModifierKeys.Control) {
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace mbts.ui.shell
|
||||
VisualState = "BadPassword";
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(message)) {
|
||||
BTSMessageBox.Show(message, "Login Message", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
BTSMessageBox.Show(message, "Login Message", BTSMessageBoxButtons.OK, MessageBoxImage.Information);
|
||||
}
|
||||
}
|
||||
private void OnCancel(object unused) {
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace mbts
|
||||
}
|
||||
}
|
||||
|
||||
public static void notnull(object o) {
|
||||
public static void notnull<T>(T o) where T : class {
|
||||
assert(o != null);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user