diff --git a/src/client/spark/Modules/Spreader/SyntheticManagementView.xaml b/src/client/spark/Modules/Spreader/SyntheticManagementView.xaml index b1b4a9890..ae6e6b70e 100644 --- a/src/client/spark/Modules/Spreader/SyntheticManagementView.xaml +++ b/src/client/spark/Modules/Spreader/SyntheticManagementView.xaml @@ -11,21 +11,21 @@ - + - - - + diff --git a/src/client/spark/Modules/Spreader/SyntheticManagementWindow.cs b/src/client/spark/Modules/Spreader/SyntheticManagementWindow.cs index 86976c8a3..7a65f7cd1 100644 --- a/src/client/spark/Modules/Spreader/SyntheticManagementWindow.cs +++ b/src/client/spark/Modules/Spreader/SyntheticManagementWindow.cs @@ -44,6 +44,7 @@ namespace mbts.spark { 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 double MinWidth => 700; public override void Dispose() { Disposable.dispose(ref _vm); diff --git a/src/client/spark/Modules/Spreader/SyntheticManagementWindowFactory.cs b/src/client/spark/Modules/Spreader/SyntheticManagementWindowFactory.cs index e1b055305..ccfb86e01 100644 --- a/src/client/spark/Modules/Spreader/SyntheticManagementWindowFactory.cs +++ b/src/client/spark/Modules/Spreader/SyntheticManagementWindowFactory.cs @@ -8,19 +8,17 @@ using System.Reactive.Linq; using System.Threading.Tasks; using static mbts.spark.DataGridColumnFilters; -namespace bts.shell -{ - class SyntheticManagementWindowFactory : ShellWindowFactory - { +namespace bts.shell { + class SyntheticManagementWindowFactory : ShellWindowFactory { + readonly IBus _bus; + readonly SpreaderModel _model; + 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)); @@ -28,8 +26,7 @@ namespace bts.shell _bus.post(SparkTags.ShowWindow, await load(new StartupData())); [ProtoContract] - public class StartupData - { + public class StartupData { public const int Version = 1; public StartupData() : this(new List(), null) { } public StartupData(List sorting_criteria, FilterStates filters) { @@ -43,10 +40,9 @@ namespace bts.shell } [ProtoContract] - public class FilterStates - { + public class FilterStates { [ProtoMember(1)] - public SecurityCriteria security; + public string description; [ProtoMember(2)] public TimeFilterTuple create_time; [ProtoMember(3)] diff --git a/src/client/spark/Modules/Spreader/VM/SyntheticManagementDialogVM.cs b/src/client/spark/Modules/Spreader/VM/SyntheticManagementDialogVM.cs index 6fc40f9d3..4d0b10452 100644 --- a/src/client/spark/Modules/Spreader/VM/SyntheticManagementDialogVM.cs +++ b/src/client/spark/Modules/Spreader/VM/SyntheticManagementDialogVM.cs @@ -5,55 +5,55 @@ using System; using System.Collections.Generic; using System.Linq; using System.Reactive.Linq; +using static bts.api.SecurityFormatter; using static bts.shell.SyntheticManagementWindowFactory; using static mbts.spark.DataGridColumnFilters; -namespace mbts.spark -{ - class SyntheticManagementVM : SecurityMDGrid - { +namespace mbts.spark { + class SyntheticManagementVM : SecurityMDGrid { + readonly SpreaderModel _model; + 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) { + : base(model.strategy_tuple.Select(map => map.Values), sorting) => _model = model; - security_filter = new DiscreteValuesOneof( - filters.security.subscribe(bus), - sc => sc.subscribe(bus), - secs => new SecurityCriteria(secs), - r => r.security.Synthetic.Legs.Select(l => l.Security), - nameof(Row.security) - ); - } - - readonly SpreaderModel _model; protected override Row row_factory((ExecutionStrategyImmutable 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 description_filter { get; } = new RegexFinder(r => r.description, nameof(Row.description)); 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(), + description = description_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, ExecutionStrategyImmutable strategy) : base(security_md) => - _strategy = strategy; - + public class Row : SecurityMDRow { + static readonly PartFormattingTuple[] _desc_parts = new[] { + new PartFormattingTuple(ContractParts.Quantity), + new PartFormattingTuple(ContractParts.Symbol), + new PartFormattingTuple(ContractParts.RawExp, "l") + }; readonly ExecutionStrategyImmutable _strategy; - public DateTime create_time => DateTime.Now; - public string name => security.Synthetic.Name; - public int n_legs => security.Synthetic.Legs.Count(); + public Row(SecurityMD security_md, ExecutionStrategyImmutable strategy) : base(security_md) { + _strategy = strategy; + name = security.Synthetic.Name; + n_legs = security.Synthetic.Legs.Count(); + description = Format(security, _desc_parts); + } + + public DateTime create_time => DateTime.MinValue; //TODO + public string name { get; } + public int n_legs { get; } + public string description { get; } } } } \ No newline at end of file