diff --git a/src/client/spark/Bus/SparkCommands.cs b/src/client/spark/Bus/SparkCommands.cs index 88dcfb82a..1754126a6 100644 --- a/src/client/spark/Bus/SparkCommands.cs +++ b/src/client/spark/Bus/SparkCommands.cs @@ -31,7 +31,6 @@ namespace bts.spark public static SparkCommand ShowOrderTicket { get; } = SparkCommand.create("Order Ticket", Icons.Ticket, SparkTags.ShowOrderTicketTag); - // Spreader public static SparkCommand ShowSyntheticSpreads { get; } = SparkCommand.create("Synthetic Spreads", Icons.Spreads, SparkTags.NotImplemented); @@ -47,11 +46,15 @@ namespace bts.spark // Support public static SparkCommand ShowManual { get; } = - SparkCommand.create("Manual", Icons.Book, SparkTags.ShowUri, new Uri("bts://manual")); + SparkCommand.create("Manual", Icons.Book, SparkTags.ShowUri, new Uri("bts://m/")); public static SparkCommand ShowAuditLogs { get; } + public static SparkCommand ShowDiagnostics { get; } - public static SparkCommand ShowAboutSpans { get; } + public static SparkCommand ShowAboutSpark { get; } = + SparkCommand.create("Contact Support", Icons.Support, SparkTags.Support); + public static SparkCommand ShowReportIssue { get; } = + SparkCommand.create("Contact Support", Icons.Support, SparkTags.Support); } } diff --git a/src/client/spark/Bus/SparkTags.cs b/src/client/spark/Bus/SparkTags.cs index 532a51e84..3618b04d4 100644 --- a/src/client/spark/Bus/SparkTags.cs +++ b/src/client/spark/Bus/SparkTags.cs @@ -52,6 +52,8 @@ namespace mbts.spark { public static ITag> ShowPickMultiple { get; } = new SparkTag>("PickN"); public static ITag> ShowPickOne { get; } = new SparkTag>("Pick1"); + public static ITag Support { get; } = new SparkTag(nameof(Support)); + #endregion #region Action diff --git a/src/client/spark/Modules/Market/MarketShellModule.cs b/src/client/spark/Modules/Market/MarketShellModule.cs index 7ad45c3bc..dc62e82f7 100644 --- a/src/client/spark/Modules/Market/MarketShellModule.cs +++ b/src/client/spark/Modules/Market/MarketShellModule.cs @@ -22,7 +22,7 @@ namespace bts.shell MarketWindowFactory _mvf; [ImportingConstructor] - public MarketShellModule(IBus bus, SecuritySource ssrc, IWindowManager wm, [Import("username")]string user_name, WorkspacesModel m) { + public MarketShellModule(IBus bus, SecuritySource ssrc, IWindowManager wm, [Import("username")]string user_name) { _tsf = new TimeAndSalesWindowFactory(this, bus, ssrc); _mvf = new MarketWindowFactory(this, bus, ssrc, wm); } diff --git a/src/client/spark/Modules/Settings/SettingsShellModule.cs b/src/client/spark/Modules/Settings/SettingsShellModule.cs index 2b8cd145a..7d47e015a 100644 --- a/src/client/spark/Modules/Settings/SettingsShellModule.cs +++ b/src/client/spark/Modules/Settings/SettingsShellModule.cs @@ -1,17 +1,25 @@ using mbts.ui; using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading.Tasks; using bts.spark; using System.IO; using System.Windows.Media; -using mbts.spark; +using bts.api; +using System.ComponentModel.Composition; +using mbts.ui.shell; -namespace bts.ui -{ +namespace bts.ui { + [Export(typeof(IShellModule))] class SettingsShellModule : IShellModule { + readonly IBus _bus; + + [ImportingConstructor] + public SettingsShellModule(IBus bus, WorkspacesModel ws) { + // todo: Create workspaces dialog + // todo: settings dialog + _bus = bus; + } public ImageSource icon => Icons.Admin; public string name => "Settings"; diff --git a/src/client/spark/Modules/Spreader/LatencyReportWindowFactory.cs b/src/client/spark/Modules/Spreader/LatencyReportWindowFactory.cs new file mode 100644 index 000000000..41f501be3 --- /dev/null +++ b/src/client/spark/Modules/Spreader/LatencyReportWindowFactory.cs @@ -0,0 +1,23 @@ +using System.Threading.Tasks; +using bts.api; +using mbts.ui; + +namespace bts.shell { + internal class LatencyReportWindowFactory : ShellWindowFactory { + IShellModule _owner; + IBus _bus; + + public LatencyReportWindowFactory(IShellModule owner, IBus bus) : base("LatencyReport") { + _owner = owner; + _bus = bus; + } + + public override Task load(LatencyReportSaveState state) { + throw new System.NotImplementedException(); + } + } + + [ProtoBuf.ProtoContract] + public class LatencyReportSaveState { + } +} \ No newline at end of file diff --git a/src/client/spark/Modules/Spreader/SpreaderShellModule.cs b/src/client/spark/Modules/Spreader/SpreaderShellModule.cs index 117d483a8..6e6e27bd6 100644 --- a/src/client/spark/Modules/Spreader/SpreaderShellModule.cs +++ b/src/client/spark/Modules/Spreader/SpreaderShellModule.cs @@ -7,10 +7,23 @@ using System.Threading.Tasks; using bts.spark; using System.IO; using System.Windows.Media; +using System.ComponentModel.Composition; +using bts.api; +using mbts.ui.shell; +using mbts; namespace bts.shell { + [Export(typeof(IShellModule))] class SpreaderShellModule : IShellModule { + SyntheticSpreadsShellWindowFactory _sswf; + LatencyReportWindowFactory _lrwf; + + [ImportingConstructor] + public SpreaderShellModule(IBus bus) { + _sswf = new SyntheticSpreadsShellWindowFactory(this, bus); + _lrwf = new LatencyReportWindowFactory(this, bus); + } public ImageSource icon => Icons.Cube3d; public string name => "Spreader"; @@ -23,10 +36,16 @@ namespace bts.shell }; public Task create(Stream load_stream) { - throw new NotImplementedException(); + 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 == _lrwf.name) return _lrwf.load_window(load_stream, header.version); + } + return null; } public void Dispose() { + Disposable.dispose(ref _sswf); + Disposable.dispose(ref _lrwf); } } } diff --git a/src/client/spark/Modules/Spreader/SyntheticSpreadsShellWindowFactory.cs b/src/client/spark/Modules/Spreader/SyntheticSpreadsShellWindowFactory.cs new file mode 100644 index 000000000..375770a52 --- /dev/null +++ b/src/client/spark/Modules/Spreader/SyntheticSpreadsShellWindowFactory.cs @@ -0,0 +1,27 @@ +using System.Threading.Tasks; +using bts.api; +using mbts.ui; +using mbts.spark; + +namespace bts.shell { + internal class SyntheticSpreadsShellWindowFactory : ShellWindowFactory { + IShellModule _owner; + IBus _bus; + + public SyntheticSpreadsShellWindowFactory(IShellModule owner, IBus bus) : base ("SyntheticSpreads") { + _owner = owner; + _bus = bus; + + // Not sure what this does + //_dispose = bus.subscribe(SparkTags.showsyn + } + + public override Task load(SyntheticSpreadsSaveState state) { + throw new System.NotImplementedException(); + } + } + + [ProtoBuf.ProtoContract] + public class SyntheticSpreadsSaveState { + } +} \ No newline at end of file diff --git a/src/client/spark/Modules/Support/SupportShellModule.cs b/src/client/spark/Modules/Support/SupportShellModule.cs index 2e5a23931..625f97fd2 100644 --- a/src/client/spark/Modules/Support/SupportShellModule.cs +++ b/src/client/spark/Modules/Support/SupportShellModule.cs @@ -1,12 +1,49 @@ -using System; +using mbts.ui; +using System; using System.Collections.Generic; +using System.ComponentModel.Composition; using System.Linq; using System.Text; using System.Threading.Tasks; +using bts.spark; +using System.IO; +using System.Windows.Media; +using bts.api; +using mbts; +using mbts.spark; -namespace bts.Modules.Support -{ - class SupportShellModule - { - } +namespace bts.Modules.Support { + [Export(typeof(IShellModule))] + class SupportShellModule : IShellModule { + IDisposable _dispose; + + [ImportingConstructor] + public SupportShellModule(IBus bus, IBrowserWindowManager browser) { + + _dispose = Disposable.Create( + bus.subscribe(SparkTags.ShowUri).Subscribe(u => browser.Pages.Add(u)) + ); + } + + public ImageSource icon => Icons.Support; + + public string name => "Support"; + + public int priority => 50; + + public IEnumerable actions => new[] { + SparkCommands.ShowManual, + SparkCommands.ShowAuditLogs, + SparkCommands.ShowDiagnostics, + SparkCommands.ShowReportIssue, + SparkCommands.ShowAboutSpark + }; + + public Task create(Stream load_stream) { + throw new NotImplementedException(); + } + + public void Dispose() { + } + } } diff --git a/src/client/spark/Modules/Trading/TradingShellModule.cs b/src/client/spark/Modules/Trading/TradingShellModule.cs index 27382d2df..03e30f46f 100644 --- a/src/client/spark/Modules/Trading/TradingShellModule.cs +++ b/src/client/spark/Modules/Trading/TradingShellModule.cs @@ -14,6 +14,8 @@ using bts.api; using mbts.spark; namespace bts.shell { + + [Export(typeof(IShellModule))] class TradingShellModule : IShellModule { LadderWindowFactory _lwf; OrderBookWindowFactory _obwf; @@ -30,7 +32,6 @@ namespace bts.shell { _order_tickets = new ShowOrderTicketHandler(bus); } - public ImageSource icon => Icons.Trades; public string name => "Trading"; diff --git a/src/client/spark/mspark/Shell/MarketModule.cs b/src/client/spark/mspark/Shell/MarketModule.cs deleted file mode 100644 index 212421f5c..000000000 --- a/src/client/spark/mspark/Shell/MarketModule.cs +++ /dev/null @@ -1,114 +0,0 @@ -//using bts.api; -//using bts.spark; -//using mbts.spark.menu_items; -//using mbts.spark.utilities; -//using mbts.ui; -//using mbts.ui.spark; -//using System; -//using System.Collections.Generic; -//using System.ComponentModel.Composition; -//using System.IO; -//using System.Linq; -//using System.Reactive.Linq; -//using System.Threading.Tasks; -//using System.Windows; -//using System.Windows.Media; -//using static mbts.spark.SparkBusData; -//using static mbts.spark.SparkTags; -//using static mbts.ui.shell.ProtoBufSerializationHelper; -//using SecurityKey = System.UInt32; - -//namespace mbts.spark -//{ -// [Export(typeof(IShellModule))] -// internal class MarketModule : IShellModule { -// [ImportingConstructor] -// public MarketModule(IBus bus, SecuritySource ssrc, IWindowManager wm, [Import("username")]string user_name) { -// _bus = bus; -// _ssrc = ssrc; -// _wm = wm; -// _user_name = user_name; -// _dispose = Disposable.Create( -// _bus.subscribe(SyntheticSecuritiesTag).ObserveOnDispatcher().Subscribe(ssm => _synthetic_strategy_map = ssm.data), -// _bus.subscribe(ShowSpreadMatrixTag).ObserveOnDispatcher().Subscribe(show_spread_matrix), -// _bus.subscribe(ShowOrderModifyTag).ObserveOnDispatcher().Subscribe(show_order_modify), -// _bus.subscribe(ShowOrderTicketTag).ObserveOnDispatcher().Subscribe(show_order_ticket), -// _bus.subscribe(ShowOrderTicketTag).ObserveOnDispatcher().Subscribe(show_linked_order_ticket), -// _bus.subscribe(ShowSyntheticCreateTag).ObserveOnDispatcher().Subscribe(show_synthetic_create_editor), -// _bus.subscribe(ShowSyntheticStrategyTag).ObserveOnDispatcher().Subscribe(show_synthetic_strategy_editor) -// ); -// } - -// public IShellWindow launch_ui => new LaunchMenu { -// DataContext = new LaunchMenuVM( -// _ssrc, -// new MarketViewMenuItem(_bus), -// new SpreadMatrixMenuItem(_bus), -// new LadderMenuItem(_bus), -// new OrderTicketMenuItem(new DemoOrdersModel(_bus)), -// MenuItemFactory.Create("Security Browser...", "sb", Icons.Coins, execute: show_security_browser)) -// }; - -// #region SpreadMatrix -// private void show_spread_matrix(ShowSpreadMatrixMessage msg) { } -// #endregion - -// #region OrderTicket -// private void show_order_modify(ShowOrderModifyMessage msg) { show_order_ticket(msg.data, true); } -// private void show_order_ticket(ShowOrderTicketMessage msg) { show_order_ticket(msg.data, false); } -// private void show_order_ticket(IReadOnlyCollection orders, bool is_modify) { -// foreach (var o in orders) { -// if (_securities.TryGetValue(o.Security.Id, out SecurityMD smd)) { -// if (string.IsNullOrEmpty(o.User)) o.User = _user_name; -// var vm = new OrderTicketVM(new DemoOrdersModel(_bus), o, _get_ladder_settings(), _bus); -// (is_modify ? (Window)new OrderModificationDialog { DataContext = vm } : new OrderTicket { DataContext = vm }).Show(-200, -160, true); -// } -// } -// } -// private void show_linked_order_ticket(ShowLinkedOrderTicketMessage msg) { -// new OrderTicket { -// DataContext = new OrderTicketVM(new DemoOrdersModel(_bus), msg.data, _get_ladder_settings(), _bus) -// }.Show(-200, -160, true); -// } -// #endregion - -// #region Synthentic -// private void show_synthetic_create_editor(ShowSyntheticCreateMessage msg) { -// var securities = msg.data; -// if (securities.Count == 0) return; -// Security synthetic = null; -// ExecutionStrategy strategy = null; -// if (securities.Count == 1) { -// var s = securities.First(); -// synthetic = SyntheticDataHelper.Defaults.Security(find_unique_synthetic_name(), s); -// strategy = _synthetic_strategy_map.TryGetValue(s.Id, out SyntheticExecutionStrategy ses) ? ses.ExecutionStrategy.Clone() : SyntheticDataHelper.Defaults.ExecutionStrategy(s); -// } else { -// synthetic = SyntheticDataHelper.Defaults.Security(find_unique_synthetic_name(), securities.Ordered(SecurityDataHelper.Comparer.Instance)); -// strategy = SyntheticDataHelper.Defaults.ExecutionStrategy(securities); -// } -// show_synthetic_editor(synthetic, strategy); -// } -// private void show_synthetic_strategy_editor(ShowSyntheticStrategyMessage msg) { -// if (msg.data.ContractCase != Security.ContractOneofCase.Synthetic) show_synthetic_editor_warning($"{msg.data} is not a synthetic security."); -// else if (!_synthetic_strategy_map.TryGetValue(msg.data.Id, out SyntheticExecutionStrategy ses)) { -// string warn_msg = $"Did not find execution strategy for {msg.data}"; -// Logger.warn(bts.log.Subsystem.Ui, warn_msg); -// show_synthetic_editor_warning(warn_msg); -// } else show_synthetic_editor(msg.data.CloneToMutable(), ses.ExecutionStrategy); -// } -// private void show_synthetic_editor_warning(string warn_msg) { -// 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); -// } -// private string find_unique_synthetic_name() { -// int i = 1; -// string rv = "Synthetic{0}".fmt(i); -// var synth_names = _securities.Values.Select(smd => smd.security).Where(s => s.ContractCase == Security.ContractOneofCase.Synthetic).Select(s => s.Synthetic.Name).ToList(); -// while (synth_names.Contains(rv)) rv = "Synthetic{0}".fmt(++i); -// return rv; -// } -// #endregion -// } -//} \ No newline at end of file diff --git a/src/client/spark/mspark/Shell/TradesModule.cs b/src/client/spark/mspark/Shell/TradesModule.cs deleted file mode 100644 index ae165f1b4..000000000 --- a/src/client/spark/mspark/Shell/TradesModule.cs +++ /dev/null @@ -1,75 +0,0 @@ -//using mbts.ui; -//using System; -//using System.Collections.Generic; -//using System.Linq; -//using System.Text; -//using System.Threading.Tasks; -//using System.IO; -//using System.Windows.Media; -//using bts.api; -//using System.ComponentModel.Composition; -//using mbts.ui.spark; -//using System.Reactive.Linq; -//using static mbts.spark.SparkBusData; -//using static mbts.spark.SparkTags; -//using static mbts.ui.shell.ProtoBufSerializationHelper; -//using mbts.spark.menu_items; - -//namespace mbts.spark -//{ -// [Export(typeof(IShellModule))] -// internal class TradesModule : IShellModule -// { -// [ImportingConstructor] -// public TradesModule(IBus bus, IWindowManager wm, SecuritySource ssrc) { -// _bus = bus; -// _ssrc = ssrc; -// _wm = wm; -// _dispose = Disposable.Create( -// _bus.subscribe(ShowFillsTag).ObserveOnDispatcher().Subscribe(show_fills), -// _bus.subscribe(ShowAuditLogsTag).ObserveOnDispatcher().Subscribe(show_audit_log), -// _bus.subscribe(ShowPositionsTag).ObserveOnDispatcher().Subscribe(show_positions), -// _bus.subscribe(ShowTimeAndSalesTag).ObserveOnDispatcher().Subscribe(show_time_and_sales) -// ); -// } - -// private readonly IBus _bus; -// readonly SecuritySource _ssrc; -// private readonly IWindowManager _wm; -// private readonly IDisposable _dispose; - -// public int priority => 1; -// public string name => "Trades"; -// public ImageSource icon => Icons.Trades; -// public IShellWindow launch_ui => new LaunchMenu { -// DataContext = new LaunchMenuVM( -// _ssrc, -// new OrderBookMenuItem(_bus), -// new FillsMenuItem(_bus), -// new AuditLogsMenuItem(_bus), -// new PositionsMenuItem(_bus), -// new TimeAndSalesMenuItem(_bus)) -// }; -// public void load_state(Stream state = null) { } -// public void get_state(Stream save_here) { } -// public Task create(Stream load_stream) { -// var header = ProtoBuf.Serializer.DeserializeWithLengthPrefix(load_stream, ProtoBuf.PrefixStyle.Fixed32); -// switch(header?.name) { -// case TimeAndSalesVM.SAVE_NAME: { if (try_deserialize(load_stream, out TimeAndSalesVM.StartupData state)) return Task.FromResult(new TimeAndSalesWindow(this, _bus, state, _ssrc)); break; } -// } -// return Task.FromResult(null); -// } -// public void start() { } -// public void Dispose() { _dispose.Dispose(); } - -// private IShellWindow create_order_book_window(OrderBookState state) { -// var vm = new OrderBookVM(_bus, new DemoOrdersModel(_bus), state, Observable.Return(new OrderBookSettings())); -// var view = new OrderBookView(vm) { Width = 1526, Height = 800 }; -// return ShellWindow.create(this, "Order Book", view, vm.get_state); -// } - -// private void show_audit_log(ShowAuditLogsMessage msg) { } -// private void show_positions(ShowPositionsMessage msg) { } -// private void show_time_and_sales(ShowTimeAndSalesMessage msg) { _wm.Windows.Add(new TimeAndSalesWindow(this, _bus, msg.data, _ssrc)); } -// } -//} \ No newline at end of file diff --git a/src/client/spark/uicore/Images/Icons.cs b/src/client/spark/uicore/Images/Icons.cs index 2a10c2667..1cd4be3ad 100644 --- a/src/client/spark/uicore/Images/Icons.cs +++ b/src/client/spark/uicore/Images/Icons.cs @@ -88,5 +88,7 @@ namespace mbts.ui public static ImageSource Target { get { return (DrawingImage)_resources["Target"]; } } public static ImageSource Tetris { get { return (DrawingImage)_resources["Tetris"]; } } public static ImageSource Wrench { get { return (DrawingImage)_resources["Wrench"]; } } + + public static ImageSource Support => (DrawingImage)_resources["SupportIcon"]; } } \ No newline at end of file