diff --git a/src/client/spark/Images/Icons.cs b/src/client/spark/Images/Icons.cs
index b3e9ec944..b97a49b55 100644
--- a/src/client/spark/Images/Icons.cs
+++ b/src/client/spark/Images/Icons.cs
@@ -68,9 +68,12 @@ namespace mbts.ui
public static ImageSource Window { get { return (DrawingImage)_resources["Window"]; } }
public static ImageSource ActiveWindow { get { return (DrawingImage)_resources["ActiveWindow"]; } }
public static ImageSource Trash { get { return (DrawingImage)_resources["Trash"]; } }
+ public static ImageSource Trash2 { get { return (DrawingImage)_resources["Trash2"]; } }
public static ImageSource Crucible { get { return (DrawingImage)_resources["Crucible"]; } }
public static ImageSource Accounting { get { return (DrawingImage)_resources["Accounting"]; } }
+ public static ImageSource Add { get { return (DrawingImage)_resources["Add"]; } }
+ public static ImageSource AddEncircled { get { return (DrawingImage)_resources["AddEncircled"]; } }
public static ImageSource Beaker { get { return (DrawingImage)_resources["Beaker"]; } }
public static ImageSource Book { get { return (DrawingImage)_resources["Book"]; } }
public static ImageSource CancelOrders { get { return (DrawingImage)_resources["CancelOrders"]; } }
diff --git a/src/client/spark/Images/Vector/Icons.xaml b/src/client/spark/Images/Vector/Icons.xaml
index 2db7fb194..dedf416bf 100644
--- a/src/client/spark/Images/Vector/Icons.xaml
+++ b/src/client/spark/Images/Vector/Icons.xaml
@@ -2,258 +2,272 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" >
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -283,7 +297,7 @@ M0,0L63.999001,0 63.999001,48.792999 0,48.792999z">
-
+
@@ -324,6 +338,30 @@ M0,0L63.999001,0 63.999001,48.792999 0,48.792999z">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -382,7 +420,7 @@ M0,0L63.999001,0 63.999001,48.792999 0,48.792999z">
-
+
@@ -403,7 +441,7 @@ M0,0L63.999001,0 63.999001,48.792999 0,48.792999z">
-
+
@@ -425,159 +463,156 @@ M0,0L63.999001,0 63.999001,48.792999 0,48.792999z">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
diff --git a/src/client/spark/Modules/Market/MarketView/MarketViewWindow.cs b/src/client/spark/Modules/Market/MarketView/MarketViewWindow.cs
index c4cde1e3d..51da1b177 100644
--- a/src/client/spark/Modules/Market/MarketView/MarketViewWindow.cs
+++ b/src/client/spark/Modules/Market/MarketView/MarketViewWindow.cs
@@ -36,7 +36,7 @@ namespace mbts.spark
SparkCommands.ShowTimeAndSales.complete(_vm.Observable.SelectMany(vm => vm.selected_securities_observable()), secs => secs.Count > 0, secs => new SecurityCriteria(secs)),
// SpreadMatrix ??
// SyntheticCreate
- SparkCommands.ShowSyntheticSpreads,
+ SparkCommands.ShowSyntheticManagement,
SparkCommands.ShowSyntheticCreate.complete(_vm.Observable.SelectMany(vm => vm.selected_securities_observable()), secs => secs.Count > 0, secs => new SecurityCriteria(secs))
// ModifyOrder - await orders
// CancelOrdersRoot ?
diff --git a/src/client/spark/Modules/Market/TimeAndSales/TimeAndSalesWindow.cs b/src/client/spark/Modules/Market/TimeAndSales/TimeAndSalesWindow.cs
index 2986c8f3d..e2e72361e 100644
--- a/src/client/spark/Modules/Market/TimeAndSales/TimeAndSalesWindow.cs
+++ b/src/client/spark/Modules/Market/TimeAndSales/TimeAndSalesWindow.cs
@@ -38,7 +38,7 @@ namespace mbts.spark
SparkCommands.ShowMarketView.complete(_vm.Observable.SelectMany(vm => vm.selected_securities_observable()), secs => secs.Count > 0, secs => new SecurityCriteria(secs)),
// SpreadMatrix ??
// SyntheticCreate
- SparkCommands.ShowSyntheticSpreads,
+ SparkCommands.ShowSyntheticManagement,
// ModifyOrder - await orders
// CancelOrdersRoot ?
//SparkCommands.CancelBuyOrders,
diff --git a/src/client/spark/Modules/Spreader/SyntheticEditor.xaml b/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml
similarity index 83%
rename from src/client/spark/Modules/Spreader/SyntheticEditor.xaml
rename to src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml
index 26c5e0dc0..ba181b563 100644
--- a/src/client/spark/Modules/Spreader/SyntheticEditor.xaml
+++ b/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml
@@ -1,6 +1,7 @@
+
@@ -190,7 +192,7 @@
-
+
@@ -200,9 +202,30 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Name
Pricing
-
+
@@ -236,17 +259,17 @@
+ Grid.Row="1"
+ Margin="0,4,0,0"
+ BorderBrush="Transparent"
+ BorderThickness="0"
+ GridLinesVisibility="None"
+ HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+ VerticalAlignment="{TemplateBinding VerticalAlignment}"
+ HeadersVisibility="All"
+ RowHeaderWidth="265"
+ RowStyle="{StaticResource DataGridRowStyle}"
+ ItemsSource="{Binding ParameterRowsView, RelativeSource={RelativeSource TemplatedParent}}">
\ No newline at end of file
diff --git a/src/client/spark/Modules/Spreader/SyntheticEditor.xaml.cs b/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml.cs
similarity index 64%
rename from src/client/spark/Modules/Spreader/SyntheticEditor.xaml.cs
rename to src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml.cs
index d553e0d28..ae43ba468 100644
--- a/src/client/spark/Modules/Spreader/SyntheticEditor.xaml.cs
+++ b/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml.cs
@@ -4,23 +4,27 @@ using mbts.ui.controls;
using mbts.ui.utility;
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
+using System.Windows.Input;
+using System.Windows.Media;
namespace mbts.ui.spark
{
///
- /// Interaction logic for SyntheticEditor.xaml
+ /// Interaction logic for ExecutionStrategyEditor.xaml
///
///
- internal partial class SyntheticEditor : Control
+ internal partial class ExecutionStrategyEditor : Control
{
- static SyntheticEditor() {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(SyntheticEditor), new FrameworkPropertyMetadata(typeof(SyntheticEditor)));
+ static ExecutionStrategyEditor() {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(ExecutionStrategyEditor), new FrameworkPropertyMetadata(typeof(ExecutionStrategyEditor)));
}
public interface IParameterViewMetadata {
@@ -29,13 +33,24 @@ namespace mbts.ui.spark
}
#region SyntheticName
- public static readonly DependencyProperty SyntheticNameProperty = DependencyProperty.Register("SyntheticName", typeof(string), typeof(SyntheticEditor),
+ public static readonly DependencyProperty SyntheticNameProperty = DependencyProperty.Register("SyntheticName", typeof(string), typeof(ExecutionStrategyEditor),
new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
public string SyntheticName { get => GetValue(SyntheticNameProperty) as string; set => SetValue(SyntheticNameProperty, value); }
#endregion
+ #region IsNew
+ public static readonly DependencyProperty IsNewProperty = DependencyProperty.Register(nameof(IsNew), typeof(bool), typeof(ExecutionStrategyEditor), new PropertyMetadata(false));
+ public bool IsNew { get => (bool)GetValue(IsNewProperty); set => SetValue(IsNewProperty, value); }
+ #endregion
+
+ #region IsNewLegPopupOpen
+ public static readonly DependencyProperty IsNewLegPopupOpenProperty = DependencyProperty.Register("IsNewLegPopupOpen", typeof(bool), typeof(ExecutionStrategyEditor),
+ new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
+ public bool IsNewLegPopupOpen { get => (bool)GetValue(IsNewLegPopupOpenProperty); set => SetValue(IsNewLegPopupOpenProperty, value); }
+ #endregion
+
#region PriceCalc
- public static readonly DependencyProperty PriceCalcProperty = DependencyProperty.Register("PriceCalc", typeof(SyntheticContract.Types.PriceCalc), typeof(SyntheticEditor),
+ public static readonly DependencyProperty PriceCalcProperty = DependencyProperty.Register("PriceCalc", typeof(SyntheticContract.Types.PriceCalc), typeof(ExecutionStrategyEditor),
new FrameworkPropertyMetadata(SyntheticContract.Types.PriceCalc.Diff, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
public SyntheticContract.Types.PriceCalc PriceCalc { get => (SyntheticContract.Types.PriceCalc)GetValue(PriceCalcProperty); set => SetValue(PriceCalcProperty, value); }
@@ -43,18 +58,18 @@ namespace mbts.ui.spark
#endregion
#region LegTuples
- public static readonly DependencyProperty LegTuplesProperty = DependencyProperty.Register("LegTuples", typeof(IReadOnlyCollection), typeof(SyntheticEditor),
+ public static readonly DependencyProperty LegTuplesProperty = DependencyProperty.Register("LegTuples", typeof(IReadOnlyCollection), typeof(ExecutionStrategyEditor),
new FrameworkPropertyMetadata(new LegSpreaderParamsTuple[0], FrameworkPropertyMetadataOptions.AffectsMeasure, SyncColumns, CoerceLegTuples));
- private static object CoerceLegTuples(DependencyObject d, object baseValue) {
+ static object CoerceLegTuples(DependencyObject d, object baseValue) {
return baseValue is IReadOnlyCollection ? baseValue : new List();
}
public IReadOnlyCollection LegTuples { get => GetValue(LegTuplesProperty) as IReadOnlyCollection; set => SetValue(LegTuplesProperty, value); }
#endregion
#region ParameterRows
- public static readonly DependencyProperty ParameterRowsProperty = DependencyProperty.Register("ParameterRows", typeof(IEnumerable), typeof(SyntheticEditor),
+ public static readonly DependencyProperty ParameterRowsProperty = DependencyProperty.Register("ParameterRows", typeof(IEnumerable), typeof(ExecutionStrategyEditor),
new PropertyMetadata(Enumerable.Empty(), OnParameterRowsChanged));
- private static void OnParameterRowsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
+ static void OnParameterRowsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
var rows = e.NewValue as IEnumerable;
if (rows != null) {
var prv = CollectionViewSource.GetDefaultView(rows);
@@ -67,63 +82,81 @@ namespace mbts.ui.spark
#endregion
#region ParameterRowsView (ReadOnly)
- private static readonly DependencyPropertyKey ParameterRowsViewPropertyKey = DependencyProperty.RegisterReadOnly("ParameterRowsView", typeof(ICollectionView), typeof(SyntheticEditor),
+ static readonly DependencyPropertyKey ParameterRowsViewPropertyKey = DependencyProperty.RegisterReadOnly("ParameterRowsView", typeof(ICollectionView), typeof(ExecutionStrategyEditor),
new PropertyMetadata());
public static readonly DependencyProperty ParameterRowsViewProperty = ParameterRowsViewPropertyKey.DependencyProperty;
- public ICollectionView ParameterRowsView { get => GetValue(ParameterRowsViewProperty) as ICollectionView; private set => SetValue(ParameterRowsViewPropertyKey, value); }
+ public ICollectionView ParameterRowsView { get => GetValue(ParameterRowsViewProperty) as ICollectionView; set => SetValue(ParameterRowsViewPropertyKey, value); }
#endregion
#region ParameterCellTemplateConverter
- public static readonly DependencyProperty ParameterCellTemplateConverterProperty = DependencyProperty.Register("ParameterCellTemplateConverter", typeof(IValueConverter), typeof(SyntheticEditor),
+ public static readonly DependencyProperty ParameterCellTemplateConverterProperty = DependencyProperty.Register("ParameterCellTemplateConverter", typeof(IValueConverter), typeof(ExecutionStrategyEditor),
new PropertyMetadata(SyncColumns));
public IValueConverter ParameterCellTemplateConverter { get => GetValue(ParameterCellTemplateConverterProperty) as IValueConverter; set => SetValue(ParameterCellTemplateConverterProperty, value); }
#endregion
#region ParameterCellEditingTemplateConverter
- public static readonly DependencyProperty ParameterCellEditingTemplateConverterProperty = DependencyProperty.Register("ParameterCellEditingTemplateConverter", typeof(IValueConverter), typeof(SyntheticEditor),
+ public static readonly DependencyProperty ParameterCellEditingTemplateConverterProperty = DependencyProperty.Register("ParameterCellEditingTemplateConverter", typeof(IValueConverter), typeof(ExecutionStrategyEditor),
new PropertyMetadata(SyncColumns));
public IValueConverter ParameterCellEditingTemplateConverter { get => GetValue(ParameterCellEditingTemplateConverterProperty) as IValueConverter; set => SetValue(ParameterCellEditingTemplateConverterProperty, value); }
#endregion
#region RowHasError
- public static readonly DependencyProperty RowHasErrorsProperty = DependencyProperty.RegisterAttached("RowHasErrors", typeof(bool), typeof(SyntheticEditor), new PropertyMetadata(false));
+ public static readonly DependencyProperty RowHasErrorsProperty = DependencyProperty.RegisterAttached("RowHasErrors", typeof(bool), typeof(ExecutionStrategyEditor), new PropertyMetadata(false));
public static bool GetRowHasErrors(DependencyObject d) { return (bool)d.GetValue(RowHasErrorsProperty); }
public static void SetRowHasErrors(DependencyObject d, bool value) { d.SetValue(RowHasErrorsProperty, value); }
#endregion
#region CellDataType
- public static readonly DependencyProperty CellDataTypeProperty = DependencyProperty.RegisterAttached("CellDataType", typeof(Type), typeof(SyntheticEditor), new PropertyMetadata(null));
+ public static readonly DependencyProperty CellDataTypeProperty = DependencyProperty.RegisterAttached("CellDataType", typeof(Type), typeof(ExecutionStrategyEditor), new PropertyMetadata(null));
public static Type GetCellDataType(DependencyObject d) { return d.GetValue(CellDataTypeProperty) as Type; }
public static void SetCellDataType(DependencyObject d, Type value) { d.SetValue(CellDataTypeProperty, value); }
#endregion
- private static void SyncColumns(DependencyObject d, DependencyPropertyChangedEventArgs e) { ((SyntheticEditor)d)._sync_columns(); }
+ #region RemoveLegCommand
+ public static readonly DependencyProperty RemoveLegCommandProperty = DependencyProperty.Register("RemoveLegCommand", typeof(ICommand), typeof(ExecutionStrategyEditor));
+ public ICommand RemoveLegCommand { get => GetValue(RemoveLegCommandProperty) as ICommand; set => SetValue(RemoveLegCommandProperty, value); }
+ #endregion
+
+ #region ContractPickerModel
+ public static readonly DependencyProperty ContractPickerModelProperty = DependencyProperty.Register(nameof(ContractPickerModel), typeof(mbts.spark.ContractPickerModel), typeof(ExecutionStrategyEditor));
+ public mbts.spark.ContractPickerModel ContractPickerModel { get => GetValue(ContractPickerModelProperty) as mbts.spark.ContractPickerModel; set => SetValue(ContractPickerModelProperty, value); }
+ #endregion
+
+ static void SyncColumns(DependencyObject d, DependencyPropertyChangedEventArgs e) { ((ExecutionStrategyEditor)d)._sync_columns(); }
public override void OnApplyTemplate() { _sync_columns(); }
- private SyntheticEditorGridLineAdorner _dg_line_adorner;
+ ExecutionStrategyGridLineAdorner _dg_line_adorner;
+ IDisposable _legs_collection_changed_sub;
- private void _sync_columns() {
+ void _sync_columns() {
_dg_line_adorner?.Dispose();
+ _legs_collection_changed_sub?.Dispose();
var dg = (DataGridEx)GetTemplateChild("PART_DataGrid");
if (dg != null) {
- dg.Columns.SetItems(LegTuples.Select(l => {
- var col = new DataGridColumnInternal(l.leg.Security, ParameterCellTemplateConverter, ParameterCellEditingTemplateConverter) { Width = 75 };
- DataGridEx.SetRightBorder(col, new DataGridExVerticalLine(false, true, System.Windows.Media.Colors.DarkGray, 1));
- return col;
- }));
- _dg_line_adorner = new SyntheticEditorGridLineAdorner(dg);
+ var legs = LegTuples;
+ dg.Columns.SetItems(legs.Select(_column_factory));
+ if (IsNew) dg.Columns.Add((DataGridColumn)FindResource("AddColumnPlaceholder"));
+ _dg_line_adorner = new ExecutionStrategyGridLineAdorner(dg);
+ _legs_collection_changed_sub = (legs as INotifyCollectionChanged)?.Subscribe((s, e) => dg.Columns.ReflectChange(legs, _column_factory, e));
}
}
+ DataGridColumn _column_factory(LegSpreaderParamsTuple l) {
+ var col = new DataGridColumnInternal(l.leg.Security, ParameterCellTemplateConverter, ParameterCellEditingTemplateConverter) { Width = 75, };
+ if (IsNew) col.HeaderTemplate = (DataTemplate)FindResource("RemovableColumnHeaderTemplate");
+ DataGridEx.SetRightBorder(col, new DataGridExVerticalLine(false, true, Colors.DarkGray, 1));
+ return col;
+ }
+
private class DataGridColumnInternal : DataGridDynamicColumn {
public DataGridColumnInternal(Security security, IValueConverter cell_template_converter, IValueConverter cell_editing_template_converter) {
- Header = security.ToString(null);
+ Header = security;
SetValue(DataGridEx.CellKeyProperty, security);
_cell_template_converter = cell_template_converter;
_cell_editing_template_converter = cell_editing_template_converter;
}
- private readonly IValueConverter _cell_template_converter, _cell_editing_template_converter;
+ readonly IValueConverter _cell_template_converter, _cell_editing_template_converter;
// I decided this was an easy and simple enough solution to justify breaking the mvvm paradigm
// The alternative - within strict bounds of the paradigm - is to change the DataGridParameterCellTemplateConverter into an IMultiValueConverter, bound to data_type AND read_only
@@ -134,7 +167,7 @@ namespace mbts.ui.spark
protected override FrameworkElement generate_element_internal() { return _generate_element(_cell_template_converter); }
protected override FrameworkElement generate_editing_element_internal() { return _generate_element(_cell_editing_template_converter); }
- private FrameworkElement _generate_element(IValueConverter cell_template_converter) {
+ FrameworkElement _generate_element(IValueConverter cell_template_converter) {
var rv = new ContentControl();
rv.SetBinding(ContentControl.ContentProperty, new Binding());
rv.SetBinding(ContentControl.ContentTemplateProperty, new Binding("data_type") { Converter = cell_template_converter });
@@ -144,7 +177,7 @@ namespace mbts.ui.spark
}
[ValueConversion(typeof(int), typeof(Thickness))]
- internal class RowHeaderGroupIndentConverter : IValueConverter {
+ class RowHeaderGroupIndentConverter : IValueConverter {
public double Indent { get; set; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
return new Thickness(((int)value + 1) * Indent, 0, 0, 0);
@@ -155,7 +188,7 @@ namespace mbts.ui.spark
}
[ValueConversion(typeof(Type), typeof(DataTemplate))]
- internal class DataGridParameterCellTemplateConverter : IValueConverter {
+ class DataGridParameterCellTemplateConverter : IValueConverter {
public DataTemplate DoubleTemplate { get; set; }
public DataTemplate BooleanTemplate { get; set; }
public DataTemplate IntTemplate { get; set; }
diff --git a/src/client/spark/Modules/Spreader/SyntheticEditorGridLineAdorner.cs b/src/client/spark/Modules/Spreader/ExecutionStrategyGridLineAdorner.cs
similarity index 69%
rename from src/client/spark/Modules/Spreader/SyntheticEditorGridLineAdorner.cs
rename to src/client/spark/Modules/Spreader/ExecutionStrategyGridLineAdorner.cs
index ee1019239..c739aea82 100644
--- a/src/client/spark/Modules/Spreader/SyntheticEditorGridLineAdorner.cs
+++ b/src/client/spark/Modules/Spreader/ExecutionStrategyGridLineAdorner.cs
@@ -8,12 +8,11 @@ using System.Windows.Media;
namespace mbts.ui.spark
{
- internal partial class SyntheticEditor : Control {
- internal class SyntheticEditorGridLineAdorner : DataGridExVerticalLineAdorner
- {
- public SyntheticEditorGridLineAdorner(DataGridEx grid) : base(grid) { }
+ internal partial class ExecutionStrategyEditor : Control {
+ internal class ExecutionStrategyGridLineAdorner : DataGridExVerticalLineAdorner {
+ public ExecutionStrategyGridLineAdorner(DataGridEx grid) : base(grid) { }
- private ItemsPresenter _items_presenter;
+ ItemsPresenter _items_presenter;
protected override IEnumerable get_other_hooks() {
_items_presenter = _grid.visual_children_where(el => el is ItemsPresenter).Cast().FirstOrDefault();
@@ -23,7 +22,7 @@ namespace mbts.ui.spark
}
}
- private void _items_presenter_SizeChanged(object sender, SizeChangedEventArgs e) { InvalidateVisual(); }
+ void _items_presenter_SizeChanged(object sender, SizeChangedEventArgs e) { InvalidateVisual(); }
protected override void draw_vertical_line(DrawingContext dc, double x, DataGridExVerticalLine line) {
if (_items_presenter != null) dc.DrawLine(line.pen.Value, new Point(x - 10, 58), new Point(x - 10, _items_presenter.ActualHeight + 58));
diff --git a/src/client/spark/Modules/Spreader/ShowSyntheticEditorHandler.cs b/src/client/spark/Modules/Spreader/ShowSyntheticEditorHandler.cs
index b1a605fad..b3091612f 100644
--- a/src/client/spark/Modules/Spreader/ShowSyntheticEditorHandler.cs
+++ b/src/client/spark/Modules/Spreader/ShowSyntheticEditorHandler.cs
@@ -28,20 +28,20 @@ namespace bts.shell
IDisposable _dispose;
- async void _show_synthetic_editor(SecurityCriteria security_criteria) =>
- _show_synthetic_editor((await security_criteria.securities(_bus)).ToList());
+ async void _show_synthetic_create(SecurityCriteria security_criteria) =>
+ _show_synthetic_create((await security_criteria.securities(_bus)).ToList());
- void _show_synthetic_editor(IReadOnlyCollection securities) {
+ void _show_synthetic_create(IReadOnlyCollection securities) {
if (securities.Count == 1) {
var sec = securities.First();
switch (sec.ContractCase) {
- case Security.ContractOneofCase.Future: _show_synthetic_editor(new ContractLegImmutable[] { SyntheticDataHelper.Defaults.ContractLeg(sec) }); break;
- case Security.ContractOneofCase.Spread: _show_synthetic_editor(sec.Spread.Legs); break;
+ case Security.ContractOneofCase.Future: _show_synthetic_create(new ContractLegImmutable[] { SyntheticDataHelper.Defaults.ContractLeg(sec) }); break;
+ case Security.ContractOneofCase.Spread: _show_synthetic_create(sec.Spread.Legs); break;
case Security.ContractOneofCase.Synthetic: _show_synthetic_strategy_async(sec).ignore(); break;
default: Logger.warn(log.Subsystem.Ui, $"{GetType()} unable to process security: {sec}"); break;
}
} else
- _show_synthetic_editor(securities.Select(s => new ContractLegImmutable(SyntheticDataHelper.Defaults.ContractLeg(s))));
+ _show_synthetic_create(securities.Select(s => new ContractLegImmutable(SyntheticDataHelper.Defaults.ContractLeg(s))));
}
void _show_synthetic_strategy(SecurityImmutable security) {
@@ -53,19 +53,19 @@ namespace bts.shell
async Task _show_synthetic_strategy_async(SecurityImmutable verified_synthetic) {
var lookup = await _model.lookup_strategy_async(verified_synthetic);
- if (lookup.success) _show_synthetic_editor(verified_synthetic, lookup.result.CloneToMutable());
+ if (lookup.success) _show_synthetic_create(verified_synthetic, lookup.result.CloneToMutable());
}
- void _show_synthetic_editor(IEnumerable legs) {
+ void _show_synthetic_create(IEnumerable legs) {
var syn = new SyntheticContract();
foreach (var l in legs) syn.Legs.Add(l.CloneToMutable());
var sec = new SecurityImmutable(new Security { Synthetic = syn });
- _show_synthetic_editor(sec, SyntheticDataHelper.Defaults.ExecutionStrategy(sec));
+ _show_synthetic_create(sec, SyntheticDataHelper.Defaults.ExecutionStrategy(sec));
}
- void _show_synthetic_editor(SecurityImmutable synthetic, ExecutionStrategy strategy) {
- new SyntheticEditorDialog {
- DataContext = new SyntheticEditorVM(_model, synthetic, strategy)
+ void _show_synthetic_create(SecurityImmutable synthetic, ExecutionStrategy strategy) {
+ new SyntheticCreationDialog {
+ DataContext = new SyntheticEditorVM(_bus, _model, synthetic, strategy)
}.Show(-250, -200, true);
}
@@ -76,7 +76,7 @@ namespace bts.shell
void IInitializable.initialize() {
Disposable.dispose(ref _dispose);
_dispose = Disposable.Create(
- _bus.subscribe(SparkTags.ShowSyntheticCreateTag).ObserveOnDispatcher().Subscribe(_show_synthetic_editor),
+ _bus.subscribe(SparkTags.ShowSyntheticCreateTag).ObserveOnDispatcher().Subscribe(_show_synthetic_create),
_bus.subscribe(SparkTags.ShowSyntheticStrategyTag).ObserveOnDispatcher().Subscribe(_show_synthetic_strategy)
);
}
diff --git a/src/client/spark/Modules/Spreader/SpreaderModel.cs b/src/client/spark/Modules/Spreader/SpreaderModel.cs
index 498698ec7..12aec4bee 100644
--- a/src/client/spark/Modules/Spreader/SpreaderModel.cs
+++ b/src/client/spark/Modules/Spreader/SpreaderModel.cs
@@ -1,5 +1,4 @@
using bts.api;
-using bts.api.core;
using bts.api.synthetic;
using bts.spark;
using System;
@@ -7,6 +6,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.Composition;
using System.Reactive.Linq;
+using System.Reactive.Subjects;
using System.Threading.Tasks;
namespace mbts.spark
@@ -19,22 +19,28 @@ namespace mbts.spark
_bus = bus;
_service = service;
_error = error;
- _dispose = Disposable.Create(
- _bus.subscribe(SparkTags.SecuritiesTag).ObserveOnDispatcher().Subscribe(md => _md = md),
- _bus.subscribe(SparkTags.SyntheticSecuritiesTag).ObserveOnDispatcher().Subscribe(sm => _strategy_map = sm)
- );
+ _md_root = _bus.subscribe(SparkTags.SecuritiesTag).Select(md => _md = md).Publish();
+ _strategy_root = _bus.subscribe(SparkTags.SyntheticSecuritiesTag).Select(s => _strategy = s).Publish();
+ _dispose = Disposable.Create(_md_root.Connect(), _strategy_root.Connect());
}
readonly IBus _bus;
readonly SyntheticSecurityService _service;
readonly ErrorReporter _error;
+ readonly IConnectableObservable> _md_root;
+ readonly IConnectableObservable> _strategy_root;
IDisposable _dispose;
IReadOnlyDictionary _md = new ReadOnlyDictionary(new Dictionary());
- IReadOnlyDictionary _strategy_map = new ReadOnlyDictionary(new Dictionary());
+ IReadOnlyDictionary _strategy = new ReadOnlyDictionary(new Dictionary());
+
+ public IObservable> md => _md_root.StartWith(_md);
+ public IObservable> strategy => _strategy_root.StartWith(_strategy);
+ public IObservable> strategy_tuple =>
+ _md_root.CombineLatest(_strategy_root, (md, strategy_map) => strategy_map.MergeSubset(md)).StartWith(_strategy.MergeSubset(_md));
public async Task<(ExecutionStrategyImmutable result, bool success)> lookup_strategy_async(SecurityImmutable security) {
- var lookup = await WorkLoop.LookupAsync(() => _strategy_map, security.Id, sesi => sesi.ExecutionStrategy);
+ var lookup = await WorkLoop.LookupAsync(() => _strategy, security.Id, sesi => sesi.ExecutionStrategy);
if (!lookup.success)
_error.report_error($"Could not find strategy for synthetic: {security}.", "Synthetic").ignore();
return lookup;
@@ -50,11 +56,11 @@ namespace mbts.spark
return _error.handle_error(result, "Error saving execution strategy: {0}", r => r.Error, e => e == UpdateResult.Types.Error.Ok);
}
- uint? _handle_error(Result result, string template) =>
- _error.handle_error(result, template, r => r.Error, e => e == CreateResult.Types.Error.Ok, r => new uint?(r.Key));
+ //uint? _handle_error(Result result, string template) =>
+ // _error.handle_error(result, template, r => r.Error, e => e == CreateResult.Types.Error.Ok, r => new uint?(r.Key));
- bool _handle_error(Result result, string template) =>
- _error.handle_error(result, template, r => r.Error, e => e == UpdateResult.Types.Error.Ok);
+ //bool _handle_error(Result result, string template) =>
+ // _error.handle_error(result, template, r => r.Error, e => e == UpdateResult.Types.Error.Ok);
#region IDisposable
diff --git a/src/client/spark/Modules/Spreader/SpreaderShellModule.cs b/src/client/spark/Modules/Spreader/SpreaderShellModule.cs
index 9cac31c43..8d1b3fa16 100644
--- a/src/client/spark/Modules/Spreader/SpreaderShellModule.cs
+++ b/src/client/spark/Modules/Spreader/SpreaderShellModule.cs
@@ -1,29 +1,26 @@
-using mbts.ui;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using bts.api;
using bts.spark;
-using System.IO;
-using System.Windows.Media;
-using System.ComponentModel.Composition;
-using bts.api;
-using mbts.ui.shell;
using mbts;
using mbts.spark;
+using mbts.ui;
+using mbts.ui.shell;
+using System.Collections.Generic;
+using System.ComponentModel.Composition;
+using System.IO;
+using System.Threading.Tasks;
+using System.Windows.Media;
namespace bts.shell
{
[Export(typeof(IShellModule))]
class SpreaderShellModule : IShellModule {
- SyntheticSpreadsShellWindowFactory _sswf;
+ SyntheticManagementWindowFactory _smwf;
LatencyReportWindowFactory _lrwf;
SpreaderModel _model;
[ImportingConstructor]
public SpreaderShellModule(IBus bus, SpreaderModel spreader_model) {
- _sswf = new SyntheticSpreadsShellWindowFactory(this, bus);
+ _smwf = new SyntheticManagementWindowFactory(this, bus, spreader_model);
_lrwf = new LatencyReportWindowFactory(this, bus);
_model = spreader_model;
}
@@ -34,23 +31,23 @@ namespace bts.shell
public int priority => 30;
public IEnumerable actions => new[] {
- SparkCommands.ShowSyntheticSpreads,
- SparkCommands.PickSyntheticCreate
+ SparkCommands.ShowSyntheticManagement,
+ SparkCommands.PickSyntheticCreate,
//SparkCommands.ShowLatencyReport
};
public Task create(Stream load_stream) {
if (ProtoBufSerializationHelper.try_deserialize(load_stream, out ShellSerializationHeader header)) {
- if (header.name == _sswf.name) return _sswf.load_window(load_stream, header.version);
+ if (header.name == _smwf.name) return _smwf.load_window(load_stream, header.version);
if (header.name == _lrwf.name) return _lrwf.load_window(load_stream, header.version);
}
return null;
}
public void Dispose() {
- Disposable.dispose(ref _sswf);
+ Disposable.dispose(ref _smwf);
Disposable.dispose(ref _lrwf);
Disposable.dispose(ref _model);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/client/spark/Modules/Spreader/SyntheticEditorDialog.xaml b/src/client/spark/Modules/Spreader/SyntheticCreationDialog.xaml
similarity index 57%
rename from src/client/spark/Modules/Spreader/SyntheticEditorDialog.xaml
rename to src/client/spark/Modules/Spreader/SyntheticCreationDialog.xaml
index ccc7e2ed1..cf308bd2c 100644
--- a/src/client/spark/Modules/Spreader/SyntheticEditorDialog.xaml
+++ b/src/client/spark/Modules/Spreader/SyntheticCreationDialog.xaml
@@ -1,4 +1,4 @@
-
-
+
@@ -19,7 +19,15 @@
-
+
diff --git a/src/client/spark/Modules/Spreader/SyntheticCreationDialog.xaml.cs b/src/client/spark/Modules/Spreader/SyntheticCreationDialog.xaml.cs
new file mode 100644
index 000000000..9c035b3eb
--- /dev/null
+++ b/src/client/spark/Modules/Spreader/SyntheticCreationDialog.xaml.cs
@@ -0,0 +1,14 @@
+using System.Windows;
+
+namespace mbts.ui.spark
+{
+ ///
+ /// Interaction logic for SyntheticCreationDialog.xaml
+ ///
+ public partial class SyntheticCreationDialog : Window
+ {
+ public SyntheticCreationDialog() {
+ InitializeComponent();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/client/spark/Modules/Spreader/SyntheticEditorDialog.xaml.cs b/src/client/spark/Modules/Spreader/SyntheticEditorDialog.xaml.cs
deleted file mode 100644
index 7dc5bfb47..000000000
--- a/src/client/spark/Modules/Spreader/SyntheticEditorDialog.xaml.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System.Windows;
-
-namespace mbts.ui.spark
-{
- ///
- /// Interaction logic for SyntheticEditorDialog.xaml
- ///
- public partial class SyntheticEditorDialog : Window
- {
- public SyntheticEditorDialog() {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/src/client/spark/Modules/Spreader/SyntheticManagementView.xaml b/src/client/spark/Modules/Spreader/SyntheticManagementView.xaml
new file mode 100644
index 000000000..23e1a9f6a
--- /dev/null
+++ b/src/client/spark/Modules/Spreader/SyntheticManagementView.xaml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/client/spark/Modules/Spreader/SyntheticManagementView.xaml.cs b/src/client/spark/Modules/Spreader/SyntheticManagementView.xaml.cs
new file mode 100644
index 000000000..258089998
--- /dev/null
+++ b/src/client/spark/Modules/Spreader/SyntheticManagementView.xaml.cs
@@ -0,0 +1,13 @@
+using System.Windows.Controls;
+
+namespace mbts.ui.spark
+{
+ ///
+ /// Interaction logic for SyntheticManagementView.xaml
+ ///
+ public partial class SyntheticManagementView : UserControl
+ {
+ public SyntheticManagementView() =>
+ InitializeComponent();
+ }
+}
\ No newline at end of file
diff --git a/src/client/spark/Modules/Spreader/SyntheticManagementWindow.cs b/src/client/spark/Modules/Spreader/SyntheticManagementWindow.cs
new file mode 100644
index 000000000..62b1ad41f
--- /dev/null
+++ b/src/client/spark/Modules/Spreader/SyntheticManagementWindow.cs
@@ -0,0 +1,55 @@
+using bts.api;
+using bts.shell;
+using bts.spark;
+using mbts.ui;
+using mbts.ui.spark;
+using mbts.utils;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reactive.Linq;
+using System.Windows;
+
+namespace mbts.spark
+{
+ class SyntheticManagementWindow : SparkWindow
+ {
+ public static SyntheticManagementWindow create(SyntheticManagementWindowFactory factory, IBus bus, SpreaderModel model, SyntheticManagementWindowFactory.StartupData state) {
+ var window = new SyntheticManagementWindow(factory, bus, model);
+ window.initialize(state);
+ return window;
+ }
+
+ SyntheticManagementWindow(SyntheticManagementWindowFactory factory, IBus bus, SpreaderModel model) : base("Synthetic Management", bus, factory, SparkCommands.ShowSyntheticManagement.icon) {
+ _model = model;
+ Commands = new SparkCommand[] {
+ SparkCommand.create("Add", Icons.AddEncircled, SparkTags.ShowSyntheticCreateTag).complete(_vm.Observable.SelectMany(vm => vm.selected_securities_observable()), secs => secs.Count > 0, secs => new SecurityCriteria(secs)),
+ SparkCommand.create("Remove", Icons.Trash2, SparkTags.NotImplemented),
+ SparkCommand.create("Change", Icons.Knight, SparkTags.ShowSyntheticStrategyTag).complete(_vm.Observable.SelectMany(vm => vm.current_security_observable), s => s.HasValue, s => s.Value),
+ SparkCommands.ShowLadder.complete(_vm.Observable.SelectMany(vm => vm.current_security_md), md => md.HasValue, md => md.Value),
+ };
+ }
+
+ SingleValuePump _vm = new SingleValuePump();
+ SyntheticManagementWindowFactory.StartupData _state;
+ SpreaderModel _model;
+ SyntheticManagementView _view;
+
+ public void initialize(SyntheticManagementWindowFactory.StartupData state) {
+ Logger.notnull(state);
+ _state = state;
+ _vm.Push(new SyntheticManagementVM(_bus, _model, state.sorting_criteria, state.filters));
+ if (_view == null) _view = new SyntheticManagementView { DataContext = _vm.Current };
+ else _view.DataContext = _vm.Current;
+ }
+
+ public override UIElement Content => _view;
+ public override IEnumerable Commands { get; }
+ public override SyntheticManagementWindowFactory.StartupData SaveState => _state = new SyntheticManagementWindowFactory.StartupData(_vm.Current.rows_view.GetSortingCriteria(), _vm.Current.get_filter_states());
+
+ public override void Dispose() {
+ Disposable.dispose(ref _vm);
+ foreach (var c in Commands.OfType()) c.Dispose();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/client/spark/Modules/Spreader/SyntheticManagementWindowFactory.cs b/src/client/spark/Modules/Spreader/SyntheticManagementWindowFactory.cs
new file mode 100644
index 000000000..32e2561f5
--- /dev/null
+++ b/src/client/spark/Modules/Spreader/SyntheticManagementWindowFactory.cs
@@ -0,0 +1,58 @@
+using bts.api;
+using mbts.spark;
+using mbts.ui;
+using ProtoBuf;
+using System;
+using System.Collections.Generic;
+using System.Reactive.Linq;
+using System.Threading.Tasks;
+using static mbts.spark.DataGridColumnFilters;
+
+namespace bts.shell
+{
+ class SyntheticManagementWindowFactory : ShellWindowFactory
+ {
+ public SyntheticManagementWindowFactory(SpreaderShellModule module, IBus bus, SpreaderModel model) : base(module, "SyntheticManagement") {
+ _bus = bus;
+ _model = model;
+ _dispose = bus.subscribe(SparkTags.ShowSyntheticManagementTag).ObserveOnDispatcher().Subscribe(show);
+ }
+
+ readonly IBus _bus;
+ readonly SpreaderModel _model;
+
+ public override Task load(StartupData state) =>
+ Task.FromResult(SyntheticManagementWindow.create(this, _bus, _model, state));
+
+ public async void show(SparkTags.Nothing nothing) =>
+ _bus.post(SparkTags.ShowWindow, await load(new StartupData()));
+
+ [ProtoContract]
+ public class StartupData
+ {
+ public const int Version = 1;
+ public StartupData() : this(new List(), null) { }
+ public StartupData(List sorting_criteria, FilterStates filters) {
+ this.sorting_criteria = sorting_criteria;
+ this.filters = filters;
+ }
+ [ProtoMember(1)]
+ public readonly List sorting_criteria;
+ [ProtoMember(2)]
+ public readonly FilterStates filters;
+ }
+
+ [ProtoContract]
+ public class FilterStates
+ {
+ [ProtoMember(1)]
+ public SecurityCriteria security;
+ [ProtoMember(2)]
+ public TimeFilterState create_time;
+ [ProtoMember(3)]
+ public string name;
+ [ProtoMember(4)]
+ public IntMinMaxState n_legs;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/client/spark/Modules/Spreader/VM/RowModel.cs b/src/client/spark/Modules/Spreader/VM/RowModel.cs
index 2222048ed..39884b1e8 100644
--- a/src/client/spark/Modules/Spreader/VM/RowModel.cs
+++ b/src/client/spark/Modules/Spreader/VM/RowModel.cs
@@ -9,7 +9,7 @@ using System.Reactive.Linq;
namespace mbts.spark
{
internal partial class SyntheticEditorVM {
- internal interface IRowModel : SyntheticEditor.IParameterViewMetadata {
+ internal interface IRowModel : ExecutionStrategyEditor.IParameterViewMetadata {
string display_name { get; }
bool has_errors(IReadOnlyCollection leg_tups);
ICell create_cell(LegSpreaderParamsTuple leg_tup);
diff --git a/src/client/spark/Modules/Spreader/VM/RowVM.cs b/src/client/spark/Modules/Spreader/VM/RowVM.cs
index 6c2289a75..4f4d20d89 100644
--- a/src/client/spark/Modules/Spreader/VM/RowVM.cs
+++ b/src/client/spark/Modules/Spreader/VM/RowVM.cs
@@ -1,30 +1,29 @@
using bts.api;
+using mbts.collections;
using mbts.ui.controls;
using mbts.ui.spark;
+using mbts.utils;
using System;
-using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
namespace mbts.spark
{
- internal partial class SyntheticEditorVM
- {
- internal class RowVM : DataGridExRow, SyntheticEditor.IParameterViewMetadata, IDisposable {
- public RowVM(IRowModel model, IReadOnlyCollection legs) {
+ internal partial class SyntheticEditorVM {
+ internal class RowVM : DataGridExRow, ExecutionStrategyEditor.IParameterViewMetadata, IDisposable {
+ readonly ObservantDictionary _cells;
+ readonly Property _has_errors;
+
+ public RowVM(IRowModel model, ObservableCollection legs) {
display_name = model.display_name;
section_path = model.section_path;
read_only = model.read_only;
_has_errors = backing(nameof(has_errors), false);
- _cells = new ReadOnlyDictionary(legs.ToDictionary(l => l.leg.Security, model.create_cell));
- foreach (var c in _cells.Values) {
- c.value_changed += () => _has_errors.set(model.has_errors(legs));
- }
+ _cells = ObservantDictionary.Create(legs, l => l.leg.Security, model.create_cell, EqualityComparer.Create(s => s.Id));
+ _cells.ValueDestroyed += c => (c as IDisposable)?.Dispose();
+ foreach (var c in _cells.Values) c.value_changed += () => _has_errors.set(model.has_errors(legs));
}
- private readonly IReadOnlyDictionary _cells;
- private readonly Property _has_errors;
-
public string display_name { get; }
public string[] section_path { get; }
public int section_count => section_path.Length;
@@ -32,7 +31,10 @@ namespace mbts.spark
public override object get_cell(Security col_key) { return _cells[col_key]; }
public string this[string section_no] => int.TryParse(section_no, out int i) && i < section_path.Length ? section_path[i] : null;
public bool has_errors => _has_errors.Value;
- public void Dispose() { foreach (var c in _cells.Values.OfType()) c.Dispose(); }
+
+ public void Dispose() {
+ foreach (var c in _cells.Values.OfType()) c.Dispose();
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs b/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs
index 2e76245b1..30a0694ea 100644
--- a/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs
+++ b/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs
@@ -1,9 +1,12 @@
using bts.api;
using bts.spark;
+using mbts.spark.utilities;
using mbts.ui;
+using mbts.ui.shell;
using mbts.ui.spark;
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Input;
using System.Windows.Media;
@@ -13,20 +16,29 @@ namespace mbts.spark
///
/// The view model designed to serve as the DataContext for the SyntheticEditor2 control
///
- internal partial class SyntheticEditorVM : IDisposable {
+ internal partial class SyntheticEditorVM : ViewModelBase, IDisposable {
///
- /// Initializes a new instance of SyntheticEditorVM2 class. The commit command will create a new Synthetic if synthetic's Id is 0, otherwise it will modify the existing synthetic's strategy.
+ /// Initializes a new instance of SyntheticEditorVM class. The commit command will create a new Synthetic if synthetic's Id is 0, otherwise it will modify the existing synthetic's strategy.
///
/// The application bus
/// The new synthetic security to create, or existing synthetic security who's strategy to modify, on commit
/// The new strategy to create, or existing strategy to modify, on commit
- public SyntheticEditorVM(SpreaderModel model, SecurityImmutable synthetic, ExecutionStrategy strategy) {
+ public SyntheticEditorVM(IBus bus, SpreaderModel model, SecurityImmutable synthetic, ExecutionStrategy strategy) {
_synthetic = synthetic.CloneToMutable();
- leg_tuples = _synthetic.Synthetic.Legs.Select(l => new LegSpreaderParamsTuple(l, strategy.LegParamsMap[l.Security.Id])).ToList();
- bool is_new = synthetic.Id == 0;
+ leg_tuples = new ObservableCollection(_synthetic.Synthetic.Legs.Select(l => new LegSpreaderParamsTuple(l, strategy.LegParamsMap[l.Security.Id])));
+ is_new = synthetic.Id == 0;
if (is_new) {
title = "Create Synthetic Spread";
icon = Icons.Tetris;
+ contract_picker_model = new ContractPickerModel(bus, false, null);
+ contract_picker_model.close_action = () => {
+ if (!leg_tuples.Any(l => l.leg.Security.Id == contract_picker_model.result.security.Id)) {
+ leg_tuples.Add(new LegSpreaderParamsTuple(SyntheticDataHelper.Defaults.ContractLeg(contract_picker_model.result.security), SyntheticDataHelper.Defaults.LegSpreaderParams));
+ is_new_leg_popup_open = false;
+ RaisePropertyChanged(nameof(is_new_leg_popup_open));
+ }
+ };
+ remove_leg = new DelegateCommand(s => leg_tuples.removeFirst(l => l.leg.Security.Id == s.Id));
commit = new DelegateCommand(async () => {
uint? id = await model.create_synthetic(synthetic);
if (id.HasValue)
@@ -58,18 +70,22 @@ namespace mbts.spark
new PostHedgePriceBasedCrossMarketTicks(),
new PostHedgeTimeBasedCrossTicks(),
new PostHedgeTimeBasedCrossMarketTicks()
- }.Select(m => new RowVM(m, leg_tuples)).ToList();
+ }.Select(m => new RowVM(m, leg_tuples)).ToList();
}
- private readonly Security _synthetic;
+ readonly Security _synthetic;
public string title { get; }
public ImageSource icon { get; }
public string name { get => _synthetic.Synthetic.Name; set => _synthetic.Synthetic.Name = value; }
+ public bool is_new { get; }
+ public bool is_new_leg_popup_open { get; set; }
public SyntheticContract.Types.PriceCalc price_calc { get => _synthetic.Synthetic.PriceCalc; set => _synthetic.Synthetic.PriceCalc = value; }
- public IReadOnlyCollection leg_tuples { get; }
+ public ObservableCollection leg_tuples { get; }
public IReadOnlyCollection rows { get; }
public ICommand commit { get; }
+ public ICommand remove_leg { get; }
+ public ContractPickerModel contract_picker_model { get; }
public void Dispose() {
foreach (var r in rows) r.Dispose();
diff --git a/src/client/spark/Modules/Spreader/VM/SyntheticManagementDialogVM.cs b/src/client/spark/Modules/Spreader/VM/SyntheticManagementDialogVM.cs
new file mode 100644
index 000000000..aa2a4ff38
--- /dev/null
+++ b/src/client/spark/Modules/Spreader/VM/SyntheticManagementDialogVM.cs
@@ -0,0 +1,53 @@
+using bts.api;
+using bts.spark;
+using mbts.ui;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reactive.Linq;
+using static bts.shell.SyntheticManagementWindowFactory;
+using static mbts.spark.DataGridColumnFilters;
+
+namespace mbts.spark
+{
+ class SyntheticManagementVM : SecurityMDGrid
+ {
+ public SyntheticManagementVM(IBus bus, SpreaderModel model) : this(bus, model, null, null) { }
+ public SyntheticManagementVM(IBus bus, SpreaderModel model, IReadOnlyCollection sorting, FilterStates filters)
+ : base(model.strategy_tuple.Select(map => map.Values), sorting) {
+ _model = model;
+ security_filter = new DiscreteValuesOneof(r => r.security.Synthetic.Legs.Select(l => l.Security), secs => new SecurityCriteria(secs), sc => sc.securities(bus), nameof(Row.security));
+ }
+
+ readonly SpreaderModel _model;
+
+ protected override Row row_factory((SyntheticExecutionStrategyImmutable strategy, SecurityMD md) row_model) => new Row(row_model.md, row_model.strategy);
+
+ #region Filters
+ public IDataGridColumnPersistentFilter create_time_filter { get; } = new Time(r => r.create_time, nameof(Row.create_time));
+ public IDataGridColumnPersistentFilter name_filter { get; } = new RegexFinder(r => r.name, nameof(Row.name));
+ public IDataGridColumnPersistentFilter security_filter { get; }
+ public IDataGridColumnPersistentFilter n_legs_filter { get; } = new IntMinMax(r => r.n_legs, nameof(Row.n_legs));
+
+ public FilterStates get_filter_states() =>
+ new FilterStates {
+ security = security_filter.get_state(),
+ create_time = create_time_filter.get_state(),
+ name = name_filter.get_state(),
+ n_legs = n_legs_filter.get_state()
+ };
+ #endregion
+
+ public class Row : SecurityMDRow
+ {
+ public Row(SecurityMD security_md, SyntheticExecutionStrategyImmutable strategy) : base(security_md) =>
+ _strategy = strategy;
+
+ readonly SyntheticExecutionStrategyImmutable _strategy;
+
+ public DateTime create_time => DateTime.Now;
+ public string name => security.Synthetic.Name;
+ public int n_legs => _strategy.Security.Synthetic.Legs.Count();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/client/spark/Modules/Trading/Fills/FillsWindow.cs b/src/client/spark/Modules/Trading/Fills/FillsWindow.cs
index 670be2a47..3b0a8d062 100644
--- a/src/client/spark/Modules/Trading/Fills/FillsWindow.cs
+++ b/src/client/spark/Modules/Trading/Fills/FillsWindow.cs
@@ -34,7 +34,7 @@ namespace mbts.spark
SparkCommands.ShowMarketView.complete(_vm.Observable.SelectMany(vm => vm.selected_securities_observable()), secs => secs.Count > 0, secs => new SecurityCriteria(secs)),
// SpreadMatrix ??
// SyntheticCreate
- SparkCommands.ShowSyntheticSpreads,
+ SparkCommands.ShowSyntheticManagement,
// ModifyOrder - await orders
// CancelOrdersRoot ?
//SparkCommands.CancelBuyOrders,
diff --git a/src/client/spark/core/Bus/SparkCommands.cs b/src/client/spark/core/Bus/SparkCommands.cs
index 3c844306f..dc9ea3cbb 100644
--- a/src/client/spark/core/Bus/SparkCommands.cs
+++ b/src/client/spark/core/Bus/SparkCommands.cs
@@ -8,7 +8,7 @@ using System.Collections.Generic;
namespace bts.spark
{
static class SparkCommands
- {
+ {
// Market
public static PartialCommand ShowMarketView =>
SparkCommand.create("Market View", Icons.Sheets, SparkTags.ShowMarketViewTag);
@@ -55,12 +55,12 @@ namespace bts.spark
public static PartialCommand ShowSyntheticStrategy =>
SparkCommand.create("Execution Strategy", Icons.Knight, SparkTags.ShowSyntheticStrategyTag);
- public static SparkCommand ShowSyntheticSpreads =>
- SparkCommand.create("Synthetic Spreads", Icons.Spreads, SparkTags.NotImplemented);
+ public static SparkCommand ShowSyntheticManagement =>
+ SparkCommand.create("Synthetic Management", Icons.Spreads, SparkTags.ShowSyntheticManagementTag);
public static SparkCommand ShowLatencyReport =>
SparkCommand.create("Latency Report", Icons.Analytics, SparkTags.NotImplemented);
-
+
// Settings
public static SparkCommand ShowWorkspaces =>
SparkCommand.create("Workspaces", Icons.FavoriteWindow, SparkTags.ShowWorkspaces);
@@ -92,6 +92,5 @@ namespace bts.spark
SparkCommand.create("Cancel Sells", Icons.CancelSells, SparkTags.CancelOrders);
public static PartialCommand ShowModifyOrder =>
SparkCommand.create("Modify", Icons.ModifyOrder, SparkTags.ShowModifyOrderTag);
-
}
}
diff --git a/src/client/spark/core/Bus/SparkTags.cs b/src/client/spark/core/Bus/SparkTags.cs
index 150354a59..ee52717a1 100644
--- a/src/client/spark/core/Bus/SparkTags.cs
+++ b/src/client/spark/core/Bus/SparkTags.cs
@@ -40,11 +40,12 @@ namespace mbts.spark
public static ITag ShowOrderDetailsTag { get; } = new SparkTag(nameof(ShowOrderDetailsTag));
public static ITag ShowOrderModifyTag { get; } = new SparkTag(nameof(ShowOrderModifyTag));
public static ITag ShowOrderTicketFromSecurityTag = new SparkTag(nameof(ShowOrderTicketFromSecurityTag));
- public static ITag<(OrderDefinitionImmutable def, double price, uint size)> ShowOrderTicketTag = new SparkTag<(OrderDefinitionImmutable def, double price, uint size)> (nameof(ShowOrderTicketTag));
+ public static ITag<(OrderDefinitionImmutable def, double price, uint size)> ShowOrderTicketTag = new SparkTag<(OrderDefinitionImmutable def, double price, uint size)>(nameof(ShowOrderTicketTag));
public static ITag ShowPositionsTag { get; } = new SparkTag(nameof(ShowPositionsTag));
public static ITag ShowSpreadMatrixTag { get; } = new SparkTag(nameof(ShowSpreadMatrixTag));
public static ITag ShowSyntheticCreateTag { get; } = new SparkTag(nameof(ShowSyntheticCreateTag));
public static ITag ShowSyntheticStrategyTag { get; } = new SparkTag(nameof(ShowSyntheticStrategyTag));
+ public static ITag ShowSyntheticManagementTag { get; } = new SparkTag(nameof(ShowSyntheticManagementTag));
public static ITag ShowTimeAndSalesTag { get; } = new SparkTag("Show TimeAndSales");
public static ITag ShowWorkspaces { get; } = new SparkTag(nameof(ShowWorkspaces));
diff --git a/src/client/spark/core/GlobalExtensions/GenericCollectionExtensions.cs b/src/client/spark/core/GlobalExtensions/GenericCollectionExtensions.cs
index e5a8dcb34..10f9ce85e 100644
--- a/src/client/spark/core/GlobalExtensions/GenericCollectionExtensions.cs
+++ b/src/client/spark/core/GlobalExtensions/GenericCollectionExtensions.cs
@@ -87,6 +87,26 @@ namespace System.Collections.Generic
if (!target.TryGetValue(k1, out d)) target.Add(k1, d = Activator.CreateInstance());
d[k2] = value;
}
+
+ public static IReadOnlyDictionary MergeSubset(this IReadOnlyDictionary dictionary, IReadOnlyDictionary merge_target) =>
+ MergeSubset(dictionary, merge_target, (v1, v2) => (v1, v2));
+
+ public static IReadOnlyDictionary MergeSubset(this IReadOnlyDictionary dictionary, IReadOnlyDictionary merge_target, Func select) {
+ var iks = dictionary.Keys.Intersect(merge_target.Keys);
+ return new ReadOnlyDictionary(iks.ToDictionary(k => k, k => select(dictionary[k], merge_target[k])));
+ }
+
+ public static IReadOnlyDictionary MergeSuperset(this IReadOnlyDictionary dictionary, IReadOnlyDictionary merge_target) {
+ var eks1 = dictionary.Keys.Except(merge_target.Keys);
+ var eks2 = merge_target.Keys.Except(dictionary.Keys);
+ var iks = dictionary.Keys.Intersect(merge_target.Keys);
+ return new ReadOnlyDictionary(eks1
+ .Select(k => (k, dictionary[k], default(TValue2)))
+ .Concat(eks2.Select(k => (k, default(TValue1), merge_target[k])))
+ .Concat(iks.Select(k => (k, dictionary[k], merge_target[k])))
+ .ToDictionary(vals => vals.k, vals => (vals.Item2, vals.Item3))
+ );
+ }
}
public static class ListExtensions
diff --git a/src/client/spark/core/GlobalExtensions/GlobalExtensions.cs b/src/client/spark/core/GlobalExtensions/GlobalExtensions.cs
index 8d142273a..d888735d3 100644
--- a/src/client/spark/core/GlobalExtensions/GlobalExtensions.cs
+++ b/src/client/spark/core/GlobalExtensions/GlobalExtensions.cs
@@ -466,9 +466,20 @@ namespace System.Reactive.Linq
return dead.Merge(alive).DistinctUntilChanged();
}
- public static IObservable<(TSource prev, TSource curr)> PairWithPrevious(this IObservable source) {
- return source.Scan((default(TSource), default(TSource)), (last, next) => (last.curr, next));
- }
+ public static IObservable<(TSource prev, TSource curr)> PairWithPrevious(this IObservable source) =>
+ source.Scan((default(TSource), default(TSource)), (last, next) => (last.curr, next));
+
+ public static async Task FirstAsyncTask(this IObservable source) =>
+ await source.FirstAsync();
+
+ public static async Task FirstAsyncTask(this IObservable source, Func predicate) =>
+ await source.FirstAsync(predicate);
+
+ public static async Task<(T result, bool success)> FirstAsyncTask(this IObservable source, TimeSpan timeout) =>
+ await source.Select(val => (val, true)).Merge(Observable.Return((default(T), false)).Delay(timeout)).FirstAsync();
+
+ public static async Task<(T result, bool success)> FirstAsyncTask(this IObservable source, Func predicate, TimeSpan timeout) =>
+ await source.Where(predicate).Select(val => (val, true)).Merge(Observable.Return((default(T), false)).Delay(timeout)).FirstAsync();
}
}
diff --git a/src/client/spark/core/Utility/ObservantDictionary.cs b/src/client/spark/core/Utility/ObservantDictionary.cs
new file mode 100644
index 000000000..cd05ae51d
--- /dev/null
+++ b/src/client/spark/core/Utility/ObservantDictionary.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
+using System.Linq;
+
+namespace mbts.collections
+{
+ public static class ObservantDictionary {
+ public static ObservantDictionary Create(ObservableCollection models, Func key_selector, Func value_selector) =>
+ new ObservantDictionary(models, key_selector, value_selector);
+
+ public static ObservantDictionary Create(ObservableCollection models, Func key_selector, Func view_selector, IEqualityComparer comparer) =>
+ new ObservantDictionary(models, key_selector, view_selector, comparer);
+ }
+
+ public class ObservantDictionary : Dictionary {
+ readonly ObservableCollection _models;
+ readonly Func _key;
+ readonly Func _value;
+
+ public ObservantDictionary(ObservableCollection models, Func key_selector, Func view_selector)
+ : this(models, key_selector, view_selector, EqualityComparer.Default) { }
+
+ public ObservantDictionary(ObservableCollection models, Func key_selector, Func value_selector, IEqualityComparer comparer) : base(comparer) {
+ _key = key_selector;
+ _value = value_selector;
+ _models = models;
+ foreach (TModel m in _models) _add(m);
+ _models.CollectionChanged += _models_CollectionChanged;
+ }
+
+ public event Action ValueCreated;
+ public event Action ValueDestroyed;
+
+ void _models_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) {
+ switch (e.Action) {
+ case NotifyCollectionChangedAction.Add: foreach (TModel m in e.NewItems) _add(m); break;
+ case NotifyCollectionChangedAction.Remove: foreach (TModel m in e.OldItems) _remove(m); break;
+ case NotifyCollectionChangedAction.Replace:
+ foreach (TModel m in e.NewItems) _add(m);
+ foreach (TModel m in e.OldItems) _remove(m);
+ break;
+ case NotifyCollectionChangedAction.Reset:
+ var old_views = Values.ToLArray();
+ Clear();
+ foreach (TValue v in old_views) ValueDestroyed?.Invoke(v);
+ foreach (TModel m in _models) _add(m);
+ break;
+ }
+ }
+
+ void _add(TModel m) {
+ TKey k = _key(m);
+ TValue v = _value(m);
+ Add(k, v);
+ ValueCreated?.Invoke(v, m);
+ }
+
+ void _remove(TModel m) {
+ TKey k = _key(m);
+ TValue v = this[k];
+ Remove(k);
+ ValueDestroyed?.Invoke(v);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/client/spark/view/Controls/DataGridEx/DataGridEx.cs b/src/client/spark/view/Controls/DataGridEx/DataGridEx.cs
index 5322323c3..4e931d9dc 100644
--- a/src/client/spark/view/Controls/DataGridEx/DataGridEx.cs
+++ b/src/client/spark/view/Controls/DataGridEx/DataGridEx.cs
@@ -34,25 +34,39 @@ namespace mbts.ui.controls
#region DataContextChanged
- private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e) {
- Disposable.dispose(ref _cell_selection_handler);
+ void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e) {
+ Disposable.dispose(ref _selection_handler);
var hcs = e.NewValue as IHandleCellSelection;
- if (hcs != null) _cell_selection_handler = new MyCellSelectionHandler(this, hcs);
+ if (hcs != null) _selection_handler = new CellSelectionHandler(this, hcs);
+ else {
+ var hrs = e.NewValue as IHandleRowSelection;
+ if (hrs != null) _selection_handler = new RowSelectionHandler(this, hrs);
+ }
}
- private MyCellSelectionHandler _cell_selection_handler;
+ IDisposable _selection_handler;
- private class MyCellSelectionHandler : IDisposable
- {
- public MyCellSelectionHandler(DataGridEx owner, IHandleCellSelection vm) {
+ private class CellSelectionHandler : IDisposable {
+ public CellSelectionHandler(DataGridEx owner, IHandleCellSelection vm) {
_vm = vm;
_owner = owner;
_owner.SelectedCellsChanged += OnSelectedCellsChanged;
}
- private readonly DataGridEx _owner;
- private readonly IHandleCellSelection _vm;
- private void OnSelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e) { _vm.cell_selection_changed(e.AddedCells, e.RemovedCells); }
- public void Dispose() { _owner.SelectedCellsChanged -= OnSelectedCellsChanged; }
+ readonly DataGridEx _owner;
+ readonly IHandleCellSelection _vm;
+ void OnSelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e) => _vm.cell_selection_changed(e.AddedCells, e.RemovedCells);
+ public void Dispose() => _owner.SelectedCellsChanged -= OnSelectedCellsChanged;
+ }
+
+ private class RowSelectionHandler : IDisposable {
+ public RowSelectionHandler(DataGridEx owner, IHandleRowSelection vm) {
+ _vm = vm;
+ (_owner = owner).SelectionChanged += OnSelectionChanged;
+ }
+ readonly DataGridEx _owner;
+ readonly IHandleRowSelection _vm;
+ void OnSelectionChanged(object sender, SelectionChangedEventArgs e) => _vm.row_selection_changed(e);
+ public void Dispose() => _owner.SelectionChanged -= OnSelectionChanged;
}
#endregion
diff --git a/src/client/spark/view/Controls/DataGridEx/Filters/IDataGridColumnFilter.cs b/src/client/spark/view/Controls/DataGridEx/Filters/IDataGridColumnFilter.cs
index 0da18cb4e..e687900c4 100644
--- a/src/client/spark/view/Controls/DataGridEx/Filters/IDataGridColumnFilter.cs
+++ b/src/client/spark/view/Controls/DataGridEx/Filters/IDataGridColumnFilter.cs
@@ -340,7 +340,7 @@ namespace mbts.spark
readonly Func, TState> _get_state;
readonly ObservableCollectionEx _selected_items = new ObservableCollectionEx();
- void _selected_items_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { _raise_filter_changed(); }
+ void _selected_items_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) => _raise_filter_changed();
protected override bool _get_active() => _selected_items.Count > 0;
protected override bool _filter(TValue value) => selected_items.Contains(value);
@@ -369,6 +369,43 @@ namespace mbts.spark
}
#endregion
+ #region DiscreteValuesOneof
+ public class DiscreteValuesOneof : FilterBase, TState>
+ {
+ //public DiscreteValuesOneof
+ public DiscreteValuesOneof(Func> get_row_vals, Func, TState> get_state, Func>> load_state, string prop_name) : base(get_row_vals, prop_name) {
+ _get_row_vals = get_row_vals;
+ _get_state = get_state;
+ _load_state = load_state;
+ }
+
+ readonly Func>> _load_state;
+ readonly Func, TState> _get_state;
+ readonly Func> _get_row_vals;
+ readonly ObservableCollectionEx _selected_items = new ObservableCollectionEx();
+
+ void _selected_items_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) => _raise_filter_changed();
+
+ protected override bool _get_active() => _selected_items.Count > 0;
+ protected override bool _filter(IEnumerable value) => value.Any(_selected_items.Contains);
+ public override async void load_state(TState state) {
+ if (state != null) {
+ _selected_items.CollectionChanged -= _selected_items_CollectionChanged;
+ int n_tries = 0;
+ var e_items = await _load_state(state);
+ var l_items = e_items.ToList();
+ while (!l_items.All(items.Contains) && ++n_tries < 50) await Task.Delay(100);
+ _selected_items.sync_with(l_items);
+ _raise_filter_changed();
+ _selected_items.CollectionChanged += _selected_items_CollectionChanged;
+ }
+ }
+ public override TState get_state() => _get_state(_selected_items);
+ public ObservableCollection items { get; set; }
+ public IObservableCollectionEx selected_items => _selected_items;
+ }
+ #endregion
+
#region RegexFinder
public class RegexFinder : FilterBase
{
diff --git a/src/client/spark/view/Controls/DataGridEx/Model/IHandleCellSelection.cs b/src/client/spark/view/Controls/DataGridEx/Model/IHandleCellSelection.cs
index 169625bb2..ab696123a 100644
--- a/src/client/spark/view/Controls/DataGridEx/Model/IHandleCellSelection.cs
+++ b/src/client/spark/view/Controls/DataGridEx/Model/IHandleCellSelection.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Windows.Controls;
namespace mbts.ui.controls
@@ -10,7 +11,12 @@ namespace mbts.ui.controls
public static class CellSelectionMapper
{
- public static void apply_changes(ref IDictionary> selection_map, IList added, IList removed) where TRow : class {
+ public static void apply_changes(IDictionary> selection_map, IList added, IList removed, ObservableCollection selected_rows) where TRow : class {
+ apply_changes(selection_map, added, removed);
+ selected_rows.sync_with(selection_map.Keys);
+ }
+
+ public static void apply_changes(IDictionary> selection_map, IList added, IList removed) where TRow : class {
foreach (var cell_info in removed) {
var row = cell_info.Item as TRow;
if (row != null) {
diff --git a/src/client/spark/view/Controls/DataGridEx/Model/IHandleRowSelection.cs b/src/client/spark/view/Controls/DataGridEx/Model/IHandleRowSelection.cs
new file mode 100644
index 000000000..78e0a12ee
--- /dev/null
+++ b/src/client/spark/view/Controls/DataGridEx/Model/IHandleRowSelection.cs
@@ -0,0 +1,18 @@
+using System.Collections.Generic;
+using System.Windows.Controls;
+
+namespace mbts.ui.controls
+{
+ interface IHandleRowSelection
+ {
+ void row_selection_changed(SelectionChangedEventArgs e);
+ }
+
+ static class RowSelectionHelper
+ {
+ public static void apply_changes(ICollection selected_rows, SelectionChangedEventArgs e) {
+ if (e.RemovedItems != null) foreach (TRow row in e.RemovedItems) selected_rows.Remove(row);
+ if (e.AddedItems != null) foreach (TRow row in e.AddedItems) selected_rows.Add(row);
+ }
+ }
+}
\ 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 4b27ff865..0f65ba4ed 100644
--- a/src/client/spark/view/Controls/DialogSkirts/DialogSkirtOKCancel.xaml
+++ b/src/client/spark/view/Controls/DialogSkirts/DialogSkirtOKCancel.xaml
@@ -26,7 +26,7 @@
IsDefault="{TemplateBinding IsOkDefault}"
Command="{TemplateBinding OKCommand}"
CommandParameter="{TemplateBinding OKCommandParameter}"
- u:Behavior.CloseWindow="True"
+ u:Behavior.CloseWindow="{TemplateBinding CloseOnOK}"
Style="{DynamicResource CommonButton}" />
+
+
+
@@ -303,7 +306,7 @@
-
-
+
-
+