diff --git a/src/client/spark/App.xaml.cs b/src/client/spark/App.xaml.cs index a44a6eaaf..196a404c2 100644 --- a/src/client/spark/App.xaml.cs +++ b/src/client/spark/App.xaml.cs @@ -15,6 +15,7 @@ using System.Windows.Navigation; using System.Windows.Shapes; using System.Globalization; using mbts.ui.native; +using bts; namespace mbts.ui.shell { @@ -90,13 +91,13 @@ namespace mbts.ui.shell else { // Second instance. Activate the main window and return NativeMethods.PostMessage(NativeMethods.HWND_BROADCAST, (WM)NativeMethods.WM_SHOWME, IntPtr.Zero, IntPtr.Zero); - Logger.log(bts.log.Level.Info, bts.log.Subsystem.Ui, "Starting a second shell is not allowed. Attempting to bring the original shell to the foreground."); + Log.Ui.info("Starting a second shell is not allowed. Attempting to bring the original shell to the foreground."); } return 0; } } catch (AbandonedMutexException ame) { - Logger.log(bts.log.Level.Warn, bts.log.Subsystem.Ui, "Shell mutex was abandoned. Releasing the mutex and trying again. \n" + ame.ToString()); + Log.Ui.warn("Shell mutex was abandoned. Releasing the mutex and trying again. \n" + ame.ToString()); _mutex.ReleaseMutex(); // Try agai until stack overflow return Run(); diff --git a/src/client/spark/Daemons/DeleteSyntheticDaemon.cs b/src/client/spark/Daemons/DeleteSyntheticDaemon.cs index 87a9219df..197c9c390 100644 --- a/src/client/spark/Daemons/DeleteSyntheticDaemon.cs +++ b/src/client/spark/Daemons/DeleteSyntheticDaemon.cs @@ -1,5 +1,4 @@ using bts.api; -using bts.log; using mbts; using mbts.spark; using mbts.ui; @@ -28,9 +27,9 @@ namespace bts { async void _delete_synthetic(uint id) { var (orders, orders_success) = await _orders_model.on_orders.FirstAsyncTask(SparkUtils.DefaultTimeOut); if (!orders_success) { - Logger.warn(Subsystem.Ui, $"Ignoring request to delete synthetic security ({id}) because the orders lookup timed out (must confirm no working orders)."); + Log.Ui.warn($"Ignoring request to delete synthetic security ({id}) because the orders lookup timed out (must confirm no working orders)."); } else if (orders.state.Values.Any(o => o.Def.SecurityKey == id && o.is_non_terminal())) { - Logger.warn(Subsystem.Ui, $"Ignoring request to delete synthetic security ({id}) because non-terminal-orders were detected."); + Log.Ui.warn($"Ignoring request to delete synthetic security ({id}) because non-terminal-orders were detected."); } else { var (strategy, strategy_success) = await _orders_model.spreader.lookup_strategy_async(id); if (strategy_success) { diff --git a/src/client/spark/Daemons/MDDaemon.cs b/src/client/spark/Daemons/MDDaemon.cs index c32527c69..32bc59eff 100644 --- a/src/client/spark/Daemons/MDDaemon.cs +++ b/src/client/spark/Daemons/MDDaemon.cs @@ -1,6 +1,5 @@ using bts.api; using bts.api.synthetic; -using bts.log; using mbts; using mbts.co2; using mbts.spark; @@ -14,9 +13,10 @@ using System.Linq; using SecurityKey = System.UInt32; namespace bts { - [Export(typeof(IShellDaemon))] - class MDSource : IObserver>, IShellDaemon, IDisposable { - readonly IBus _bus; + [Export(typeof(IInitializable))] + class MDSource : IObserver>, IInitializable, IDisposable { + readonly Lazy _bus; + readonly Lazy _ss; readonly MDConsumer _consumer = new MDConsumer(); readonly Co2RelayControl _relay; HashSet _deleted_synthetics = new HashSet(); @@ -24,17 +24,20 @@ namespace bts { IReadOnlyDictionary _exchange_sec_map = new Dictionary(); [ImportingConstructor] - public MDSource(IBus bus, SyntheticSecurityService ss) { + public MDSource(Lazy bus, Lazy ss) { _bus = bus; + _ss = ss; _relay = new Co2RelayControl(_consumer); _relay.preload_securities((co2.MDRequest.Types.Flags)0xff).ignore(); _dispose.Add(_consumer.on_security.Subscribe(this)); + } + public void initialize() { _dispose.Add( - ss.subscribei_metadata() + _ss.Value.subscribei_metadata() .Select(upd => upd.all.ToDictionary(i => i.SecurityKey, i => i.Strategy)) .Subscribe(t => { _deleted_synthetics = new HashSet(t.Where(kv => kv.Value.Deleted).Select(kv => kv.Key)); - _bus.post(SparkTags.SyntheticstrategiesTag, t); + bus.post(SparkTags.SyntheticstrategiesTag, t); })); Task.Run(run); } @@ -42,8 +45,11 @@ namespace bts { [Export] MDConsumer consumer => _consumer; + public int priority => 55; + IBus bus => _bus.Value; + public void OnCompleted() { } - public void OnError(Exception error) => Logger.error(Subsystem.gen, error.ToString()); + public void OnError(Exception error) => Log.Md.error(error.ToString()); public void OnNext(List values) { if (values.Count > 0) { var temp = _exchange_sec_map.ToDictionary(k => k.Key, k => k.Value); @@ -55,7 +61,6 @@ namespace bts { } public void Dispose() => Disposable.dispose(_dispose); - async Task run() { int exch_sec_count = 0, deleted_synth_count = 0; while (true) { @@ -66,14 +71,15 @@ namespace bts { deleted_synth_count = deleted_synths.Count; exch = exch.Where(kv => !deleted_synths.Contains(kv.Key)).ToDictionary(); try { - Logger.log(Level.Info, Subsystem.gen, String.Format("MDSource publishing {0} securities", exch.Count)); - _bus.post(SparkTags.SecuritiesTag, exch); + Log.Md.info($"MDSource publishing {exch.Count} securities"); + bus.post(SparkTags.SecuritiesTag, exch); } catch (Exception e) { - Logger.error(Subsystem.md, $"Error in publish_securities: {e}"); + Log.Md.error($"Error in publish_securities: {e}"); } } await Task.Delay(TimeSpan.FromSeconds(1)); } } + } } \ No newline at end of file diff --git a/src/client/spark/Daemons/SecurityPickerDaemon.cs b/src/client/spark/Daemons/SecurityPickerDaemon.cs index 8d712c4aa..5b066f206 100644 --- a/src/client/spark/Daemons/SecurityPickerDaemon.cs +++ b/src/client/spark/Daemons/SecurityPickerDaemon.cs @@ -1,17 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using bts.api; +using bts.api; +using bts.spark; +using mbts; using mbts.spark; using mbts.ui; +using System; using System.ComponentModel.Composition; -using mbts; -using System.Windows; -using System.Windows.Input; -using bts.spark; using System.Reactive.Linq; +using System.Windows; namespace bts { [Export, Export(typeof(IShellDaemon))] @@ -29,102 +24,57 @@ namespace bts { bus.subscribe(SparkTags.ShowAndEditPickMultiple).OnDispatcher().Subscribe(show_and_edit_pick_multiple) ); } - - void show_pick_one(PartialCommand message) { - var vm = new ContractPickerModel(_bus, false, null); - var view = new ContractPickerView(vm); - - Window picker = new Window { - Content = view, - Title = $"Select a Security for {message.title}", - Icon = message.icon, - Height = view.Height, - Width = view.Width - }; - picker.Style = picker.TryFindResource("BTSWindow") as Style; - view.Height = Double.NaN; - view.Width = Double.NaN; - - vm.ok_action = () => { - picker.Close(); - message.complete(vm.result).execute(_bus); - }; - picker.move_to_mouse(); - picker.Show(); - } - - void show_filtered_pick_one((PartialCommand message, SecurityCriteria global_filter) message_and_filter) { - var vm = new ContractPickerModel(_bus, false, null, message_and_filter.global_filter); - var view = new ContractPickerView(vm); - - Window picker = new Window { - Content = view, - Title = $"Select a Security for {message_and_filter.message.title}", - Icon = message_and_filter.message.icon, - Height = view.Height, - Width = view.Width - }; - picker.Style = picker.TryFindResource("BTSWindow") as Style; - view.Height = Double.NaN; - view.Width = Double.NaN; - - vm.ok_action = () => { - picker.Close(); - message_and_filter.message.complete(vm.result).execute(_bus); - }; - picker.move_to_mouse(); - picker.Show(); - } - - void show_pick_multiple(PartialCommand message) { - var vm = new ContractPickerModel(_bus, true, null); - var view = new ContractPickerView(vm); - - Window picker = new Window - { - Content = view, - Title = $"Select Securities for {message.title}", - Icon = message.icon, - Height = view.Height, - Width = view.Width, - }; - picker.Style = picker.TryFindResource("BTSWindow") as Style; - view.Height = Double.NaN; - view.Width = Double.NaN; - - vm.ok_action = () => { - picker.Close(); - message.complete(vm.result_criteria).execute(_bus); - }; - picker.move_to_mouse(); - picker.Show(); - } - - void show_and_edit_pick_multiple((PartialCommand message, SecurityCriteria existing_criteria) message_and_data) { - var vm = new ContractPickerModel(_bus, true, message_and_data.existing_criteria); - var view = new ContractPickerView(vm); - - Window picker = new Window { - Content = view, - Title = $" {message_and_data.message.title} security selection", - Icon = message_and_data.message.icon, - Height = view.Height, - Width = view.Width, - }; - picker.Style = picker.TryFindResource("BTSWindow") as Style; - view.Height = Double.NaN; - view.Width = Double.NaN; - - vm.ok_action = () => { - picker.Close(); - message_and_data.message.complete(vm.result_criteria).execute(_bus); - }; - picker.move_to_mouse(); - picker.Show(); - } - - public void Dispose() { + + public void Dispose() => Disposable.dispose(ref _dispose); + + void show_pick_one(PartialCommand message) => + _show_picker(message, _fmt_pick_one_title, new ContractPickerModel(_bus, false, null), vm => vm.result); + + void show_filtered_pick_one((PartialCommand message, SecurityCriteria global_filter) message_and_filter) => + _show_picker(message_and_filter.message, _fmt_pick_one_title, new ContractPickerModel(_bus, false, null, message_and_filter.global_filter), vm => vm.result); + + void show_pick_multiple(PartialCommand message) => + _show_picker(message, _fmt_pick_multiple_title, new ContractPickerModel(_bus, true, null), vm => vm.result_criteria); + + void show_and_edit_pick_multiple((PartialCommand message, SecurityCriteria existing_criteria) message_and_data) => + _show_picker(message_and_data.message, _fmt_pick_multiple_title, new ContractPickerModel(_bus, true, message_and_data.existing_criteria), vm => vm.result_criteria); + + static string _fmt_pick_one_title(string message_title) => $"Select a Security for {message_title}"; + static string _fmt_pick_multiple_title(string message_title) => $"Select Securities for {message_title}"; + + void _show_picker(PartialCommand message, Func fmt_title, ContractPickerModel vm, Func select_result) { + var icon = message.icon; + if (icon == null) { + // not neccessary grind to hault just bc the icon is null, but it is most likely a dev-mistake that should be addressed. + handle_bad_icon("a null icon"); + } else if (!icon.IsFrozen) { + handle_bad_icon("an icon that wasn't frozen (not threadsafe)"); + } + // + void handle_bad_icon(string icon_error_desc) { + Log.Api.warn($"{nameof(SecurityPickerDaemon)} received a message '{message.title}' with {icon_error_desc}, will use {nameof(Icons.AdminFrozen)}."); + icon = Icons.AdminFrozen; + } + // + var cpv = new ContractPickerView(vm); + var window = new Window { + Content = cpv, + Title = fmt_title(message.title), + Icon = message.icon, + Height = cpv.Height, + Width = cpv.Width, + }; + window.Style = window.TryFindResource("BTSWindow") as Style; + cpv.Width = double.NaN; + cpv.Height = double.NaN; + + vm.ok_action = () => { + window.Close(); + message.complete(select_result(vm)).execute(_bus); + }; + window.move_to_mouse(); + window.Show(); } } -} +} \ No newline at end of file diff --git a/src/client/spark/Images/Icons.cs b/src/client/spark/Images/Icons.cs index a4bd1d091..cc9ebe874 100644 --- a/src/client/spark/Images/Icons.cs +++ b/src/client/spark/Images/Icons.cs @@ -1,5 +1,7 @@ -using System; +using bts; +using System; using System.Collections.Generic; +using System.Linq; using System.Windows; using System.Windows.Media; using System.Windows.Media.Imaging; @@ -7,10 +9,19 @@ using System.Windows.Media.Imaging; namespace mbts.ui { public class Icons { public const string - PaymentGeometryKey = nameof(PaymentGeometryKey), + GearGeometryKey = nameof(GearGeometryKey), OrdersGeometryKey = nameof(OrdersGeometryKey), + PaymentGeometryKey = nameof(PaymentGeometryKey), + PlayGeometryKey = nameof(PlayGeometryKey), ToolsGeometryKey = nameof(ToolsGeometryKey); + static Icons() { + // TODO: probably do this for all icons, only reason for holding back is the uncertainity of any unexpected impacts + AdminFrozen = Admin.frozen(); + } + + public static Geometry PlayGeometry => Geometry.Parse(_get_geometric_path(PlayGeometryKey).FirstOrDefault() ?? string.Empty); + static readonly string base_uri = "pack://application:,,,/Images/Icons/"; private static ResourceDictionary _resources = (ResourceDictionary)Application.LoadComponent(new Uri("/Images/Vector/Icons.xaml", UriKind.RelativeOrAbsolute)); @@ -26,6 +37,7 @@ namespace mbts.ui { #pragma warning disable CS0618 // Type or member is obsolete public static ImageSource Logo { get { return load_image("logo.ico"); } } public static ImageSource Admin { get { return (DrawingImage)_resources["Admin"]; } } + public static ImageSource AdminFrozen { get; } public static ImageSource Analytics { get { return (DrawingImage)_resources["Analytics"]; } } public static ImageSource Sheets { get { return (DrawingImage)_resources["Sheets"]; } } public static ImageSource Trades { get { return (DrawingImage)_resources["Trades"]; } } @@ -102,6 +114,7 @@ namespace mbts.ui { public static ImageSource Filter { get { return (DrawingImage)_resources["Filter"]; } } public static ImageSource FilterActive { get { return (DrawingImage)_resources["FilterActive"]; } } public static ImageSource FilterError { get { return (DrawingImage)_resources["FilterError"]; } } + public static ImageSource Gear => create_icon(GearGeometryKey); public static ImageSource Import => (DrawingImage)_resources["Import"]; public static ImageSource Knight { get { return (DrawingImage)_resources["Knight"]; } } public static ImageSource Payment => create_icon(PaymentGeometryKey); @@ -111,21 +124,15 @@ namespace mbts.ui { public static ImageSource Tools => create_icon(ToolsGeometryKey); public static ImageSource ViewSettings => (DrawingImage)_resources["ViewSettings"]; public static ImageSource Wrench { get { return (DrawingImage)_resources["Wrench"]; } } - public static ImageSource UpArrow { get { return (DrawingImage)_resources["UpArrow"]; } } - + public static ImageSource RightArrow { get { return ((DrawingImage)_resources["RightArrow"]); } } + public static ImageSource DownArrow { get { return ((DrawingImage)_resources["DownArrow"]); } } public static ImageSource Support => (DrawingImage)_resources["SupportIcon"]; - public static ImageSource create_icon(string geometric_path_key) => create_icon(geometric_path_key, Brushes.Black); - public static ImageSource create_icon(string geometric_path_key, Brush brush, Pen pen = null) { - object obj = _resources[geometric_path_key]; - if (obj is string path) { - if (string.IsNullOrEmpty(path)) - throw new ArgumentException($"Resource lookup of '{geometric_path_key}' did not return a valid string.", nameof(geometric_path_key)); - return _create_icon(new[] { path }, brush, pen); - } else if (obj is string[] paths) { - return _create_icon(paths, brush, pen); - } else return null; - } + public static ImageSource create_icon(string geometric_path_key) => + create_icon(geometric_path_key, Brushes.Black); + + public static ImageSource create_icon(string geometric_path_key, Brush brush, Pen pen = null) => + _create_icon(_get_geometric_path(geometric_path_key), brush, pen); static ImageSource _create_icon(IEnumerable paths, Brush brush, Pen pen = null) { var drawing_group = new DrawingGroup(); @@ -134,5 +141,18 @@ namespace mbts.ui { } return new DrawingImage(drawing_group); } + + static IEnumerable _get_geometric_path(string geometric_path_key) { + object obj = _resources[geometric_path_key]; + if (obj is string path) { + if (string.IsNullOrEmpty(path)) { + Log.Api.error($"Resource lookup of '{geometric_path_key}' did not return a valid string.", nameof(geometric_path_key)); + path = string.Empty; + } + return new[] { path }; + } else if (obj is string[] paths) { + return paths.Where(p => !string.IsNullOrEmpty(p)).ToArray(); + } else return null; + } } } \ No newline at end of file diff --git a/src/client/spark/Images/Vector/Icons.xaml b/src/client/spark/Images/Vector/Icons.xaml index 487fb4425..3fd3e8aa9 100644 --- a/src/client/spark/Images/Vector/Icons.xaml +++ b/src/client/spark/Images/Vector/Icons.xaml @@ -5,6 +5,10 @@ xmlns:mbts="clr-namespace:mbts.ui" xmlns:sys="clr-namespace:System;assembly=mscorlib" > + + M16.000015,9.6000061C12.500012,9.6000061 9.5999844,12.5 9.5999844,16 9.5999844,19.5 12.500012,22.399994 16.000015,22.399994 19.500019,22.399994 22.400015,19.5 22.400015,16 22.400015,12.5 19.500019,9.6000061 16.000015,9.6000061z M14.199995,0L17.800005,0C18.199999,0,18.599993,0.29998779,18.599993,0.79998779L18.599993,4.7999878C19.900013,5.1000061,21.000019,5.6000061,22.099997,6.2999878L25.000023,3.3999939C25.099999,3.2999878 25.300011,3.1999817 25.500025,3.1999817 25.700007,3.1999817 25.900019,3.2999878 26.000025,3.3999939L28.600033,6C28.900021,6.2999878,28.900021,6.7999878,28.600033,7.1000061L25.700007,10C26.400019,11.100006,26.900019,12.299988,27.200007,13.5L31.20001,13.5C31.600037,13.5,31.999998,13.799988,31.999998,14.299988L31.999998,17.899994C31.999998,18.299988,31.700012,18.699982,31.20001,18.699982L27.200007,18.699982C26.900019,20,26.400019,21.100006,25.700007,22.199982L28.600033,25.100006C28.700009,25.199982 28.799984,25.399994 28.799984,25.600006 28.799984,25.799988 28.700009,26 28.600033,26.100006L26.000025,28.600006C25.900019,28.699982 25.700007,28.799988 25.500025,28.799988 25.300011,28.799988 25.099999,28.699982 25.000023,28.600006L22.099997,25.699982C21.000019,26.399994,19.800007,26.899994,18.599993,27.199982L18.599993,31.199982C18.599993,31.600006,18.300005,32,17.800005,32L14.199995,32C13.8,32,13.400006,31.699982,13.400006,31.199982L13.400006,27.199982C12.099987,26.899994,11.000011,26.399994,9.9000027,25.699982L7.0000064,28.600006C6.9000003,28.699982 6.6999881,28.799988 6.5000059,28.799988 6.2999937,28.799988 6.099981,28.699982 6.0000054,28.600006L3.3999967,26C3.0999784,25.699982,3.0999784,25.199982,3.3999967,24.899994L6.2999937,22C5.5999805,20.899994,5.0999801,19.699982,4.7999923,18.5L0.79998828,18.5C0.39999409,18.5,-1.933513E-07,18.199982,0,17.699982L0,14.100006C-1.933513E-07,13.699982,0.2999879,13.299988,0.79998828,13.299988L4.7999923,13.299988C5.0999801,12,5.5999805,10.899994,6.2999937,9.7999878L3.3999967,7C3.2999908,6.8999939 3.1999845,6.6999817 3.1999845,6.5 3.1999845,6.2999878 3.2999908,6.1000061 3.3999967,6L6.0000054,3.3999939C6.099981,3.2999878 6.2999937,3.1999817 6.5000059,3.1999817 6.6999881,3.1999817 6.9000003,3.2999878 7.0000064,3.3999939L9.9000027,6.2999878C11.000011,5.6000061,12.199993,5.1000061,13.400006,4.7999878L13.400006,0.79998779C13.400006,0.29998779,13.8,0,14.199995,0z + + M50.14375,33.389126C50.416863,33.394688,50.653496,33.587773,50.705998,33.864617L50.015995,45.114388C49.810295,46.291462,49.130394,45.097489,49.130394,45.097489L47.65659,42.640538C42.747776,49.635197 34.633152,54.221001 25.433924,54.221001 14.884193,54.221001 5.7437552,48.204125 1.2449617,39.419205 0.80087067,38.552021 0.21358696,37.705738 0.052086769,36.736958 -0.49735315,33.490925 3.4507786,32.901036 4.8049124,34.432404 5.3674143,35.067692 6.034036,36.16407 6.5079177,37.026051 10.106778,43.799416 17.2321,48.413819 25.433924,48.413819 32.656544,48.413819 39.026364,44.826695 42.903977,39.351506L40.229367,38.854115C40.229367,38.854115,38.677464,38.647118,39.742466,37.996033L50.024895,33.398526C50.064972,33.391365,50.104733,33.388333,50.14375,33.389126z M23.030291,9.0310004L27.889918,9.0310004 27.889918,13.028299C30.539786,13.205498,32.324932,13.958096,33.464161,14.528294L33.964176,14.775793 32.417435,20.038878 31.706417,19.68068C30.579987,19.11958 28.839241,18.244583 26.149073,18.244583 24.006916,18.244583 22.723183,19.122181 22.723183,20.590876 22.723183,21.894272 23.943314,22.804369 27.551308,24.187165 32.706444,26.124659 34.911,28.702853 34.911,32.817341 34.911,36.892929 32.090527,40.05172 27.673611,40.989117L27.673611,45.540001 22.767485,45.540001 22.767485,41.330414C20.252919,41.155815,17.695551,40.424118,16.101811,39.404721L15.683999,39.137619 17.221739,33.731438 17.969059,34.180634C19.088988,34.851235 21.402748,35.97873 24.340325,35.97873 26.734886,35.97873 28.276728,34.921635 28.276728,33.291336 28.276728,31.986641 27.547409,30.853846 23.986016,29.57255 20.083815,28.144253 16.095511,26.04406 16.095511,21.239174 16.095511,17.280985 18.737379,14.291395 23.030291,13.329098z M25.268765,0C35.819447,2.7347414E-07 44.961449,6.0155495 49.458798,14.804573 49.902695,15.669173 50.490094,16.516972 50.651287,17.48427 51.198281,20.734265 47.255726,21.318962 45.901341,19.789065 45.336346,19.153567 44.669552,18.051968 44.19566,17.19517 40.5957,10.421881 33.473275,5.8072398 25.268765,5.8072393 18.047545,5.8072398 11.678013,9.3918336 7.8003562,14.867073L10.474627,15.367072C10.474627,15.367072,12.026909,15.574172,10.962921,16.223872L0.67933281,20.826762C0.36037083,20.880062,0.057029126,20.669165,0.00099972012,20.354063L0.69093342,9.1118043C0.89552094,7.9296158,1.5738537,9.124924,1.5738539,9.124924L3.0452772,11.583379C7.9566038,4.584462,16.073666,2.7347414E-07,25.268765,0z @@ -13,9 +17,17 @@ M28.000001,6.0000026L28.000001,15 6.0010006,15 6.0010006,17.000003 30.001,17.000003 30.001,6.0000026z M14.231,2.9540056L14.979999,2.9540056 14.979999,3.987005C15.704998,4.009005,16.200997,4.178005,16.550998,4.3600049L16.248998,5.0620046C15.994998,4.9340047 15.499998,4.7010047 14.725999,4.7010047 13.796,4.7010047 13.445001,5.1900046 13.445001,5.6160046 13.445001,6.1710043 13.893,6.4470041 14.943999,6.8310037 16.187998,7.2780037 16.816998,7.8320036 16.816998,8.7800031 16.816998,9.6210027 16.151998,10.409003 14.907999,10.591002L14.907999,11.698002 14.146,11.698002 14.146,10.622003C13.445001,10.611002,12.720001,10.420002,12.297002,10.154003L12.587001,9.4400029C13.022001,9.696003 13.651,9.8980026 14.328,9.8980026 15.185999,9.8980026 15.765998,9.4620028 15.765998,8.8540034 15.765998,8.2680035 15.293999,7.9060035 14.4,7.5870035 13.167001,7.1610038 12.406001,6.6710041 12.406001,5.7440041 12.406001,4.8600047 13.119,4.189005 14.231,4.0290052z M2,2.0000002L2,13 26.000001,13 26.000001,2.0000002z M0,0L28.000001,0 28.000001,4.0000031 32.001,4.0000031 32.001,19.000003 4.0010006,19.000003 4.0010006,15 0,15z + + M0,0L25.194,16 0,32z + + M4.9629898,25.440168C4.564003,25.440168 4.0650101,25.640182 3.7659989,25.939165 3.0680008,26.638176 3.0680008,27.635191 3.7659989,28.3342 4.4639969,29.032204 5.4620133,29.032204 6.1600113,28.3342 6.8589859,27.635191 6.8589859,26.638176 6.1600113,25.939165 5.760994,25.640182 5.3620072,25.440168 4.9629898,25.440168z M18.432014,18.457121L22.422005,22.447138 24.816994,22.946165 29.107002,29.431192 27.509987,31.027212 21.025002,26.737175 20.526985,24.343178 16.535988,20.352123z M8.1560135,18.357115L13.643013,23.84415C11.048988,26.638176 8.9539872,28.932196 7.9560013,29.930189 6.359993,31.526207 3.6659928,31.626215 2.070015,29.930189 0.47400668,28.3342 0.47400668,25.640182 2.070015,24.044165z M2.967995,6.7840408C2.768013,6.7840408 2.5690079,6.8840479 2.4690018,6.9840545 2.1699906,7.2830371 2.1699906,7.7820638 2.4690018,8.0810469L11.746986,17.359123C12.047005,17.659113 12.544991,17.659113 12.845009,17.359123 13.14399,17.06011 13.14399,16.561113 12.845009,16.2621L3.5659867,6.9840545C3.3670121,6.8840479,3.1669998,6.7840408,2.967995,6.7840408z M5.2620011,4.4890431C5.0629959,4.4890431 4.8630143,4.5890192 4.7640152,4.6890262 4.3649979,4.9880394 4.3649979,5.4870356 4.7640152,5.8860554L14.042,15.164101C14.341011,15.46409 14.840004,15.46409 15.139015,15.164101 15.439003,14.865087 15.439003,14.366092 15.139015,14.067109L5.8610001,4.6890262C5.661995,4.5890192,5.4620133,4.4890431,5.2620011,4.4890431z M4.3649979,2.3940283C5.4620133,2.3940281,6.5589981,2.7930175,7.3580094,3.5920337L19.328987,15.46409 13.342995,21.450153 1.2720107,9.6770657C-0.42400357,7.9810704 -0.42400357,5.2880291 1.2720107,3.6910337 2.1699906,2.7930175 3.267006,2.3940281 4.3649979,2.3940283z M24.217995,0C25.31501,-8.5992724E-08,26.312996,0.20001344,27.211006,0.59900296L23.021004,4.7890328C22.223,5.5870422,22.223,6.7840408,23.021004,7.4820436L24.617012,9.079069C25.414986,9.8770789,26.612007,9.8770789,27.311012,9.079069L31.501015,4.9880394C31.799995,5.8860554 32.000008,6.7840408 32.000008,7.7820638 32.000008,12.07207 28.508003,15.564097 24.217995,15.564097 19.927986,15.564097 16.436012,12.07207 16.436012,7.7820638 16.436012,3.4920272 19.927986,-8.5992724E-08 24.217995,0z + + + F1 M 78.1398,324.18L 52.5865,298.626C 51.6892,297.728 50.3385,297.459 49.1678,297.946C 47.9971,298.43 47.2305,299.574 47.2305,300.843L 60.6385,326.398L 47.2305,351.952C 47.2305,353.223 47.9971,354.364 49.1678,354.848C 49.5558,355.011 49.9638,355.09 50.3678,355.09C 51.1838,355.09 51.9852,354.77 52.5865,354.171L 78.1398,328.616C 78.7238,328.032 79.0598,327.224 79.0598,326.398C 79.0598,325.572 78.7238,324.764 78.1398,324.18 Z + @@ -488,17 +500,6 @@ M0,0L63.999001,0 63.999001,48.792999 0,48.792999z"> - - - - - - - - - - @@ -759,20 +760,39 @@ M0,0L63.999001,0 63.999001,48.792999 0,48.792999z"> - + - + + + + + + + + + + + + + + + + + + + + + + - - - - - + + - Play Sound - - + + + + + + Play + + + + - + diff --git a/src/client/spark/view/Controls/DataGridEx/Filters/VM/TupleFilterVM.cs b/src/client/spark/view/Controls/DataGridEx/Filters/VM/TupleFilterVM.cs index 53f4c2e4d..796fc455f 100644 --- a/src/client/spark/view/Controls/DataGridEx/Filters/VM/TupleFilterVM.cs +++ b/src/client/spark/view/Controls/DataGridEx/Filters/VM/TupleFilterVM.cs @@ -1,4 +1,5 @@ -using mbts.ui; +using bts; +using mbts.ui; using mbts.ui.shell; using System; using System.Windows.Input; @@ -17,7 +18,7 @@ namespace mbts.spark.filters { FilterVMBase filter2, Func get_filter2_state, Func get_state) { - Logger.assert(filter1.prop_name == filter2.prop_name); + Log.assert(filter1.prop_name == filter2.prop_name); prop_name = filter1.prop_name; _filter1 = filter1; _filter2 = filter2; diff --git a/src/client/spark/view/Controls/Dialogs/SupportRequestWindow.xaml.cs b/src/client/spark/view/Controls/Dialogs/SupportRequestWindow.xaml.cs index c2aeece0c..5f4638b6b 100644 --- a/src/client/spark/view/Controls/Dialogs/SupportRequestWindow.xaml.cs +++ b/src/client/spark/view/Controls/Dialogs/SupportRequestWindow.xaml.cs @@ -62,7 +62,7 @@ namespace bts.view.controls { var reply = await _service.send_report_async(_base.with( user_description: _text.Value, contact: user_contact, - log: include_logs ? Logger.read_logs() : "", + log: include_logs ? LogUtil.read_logs() : "", image: screenshot )); if (reply.success) { diff --git a/src/client/spark/view/Controls/HelpButton.cs b/src/client/spark/view/Controls/HelpButton.cs index 3ba54ee2f..7a42224f8 100644 --- a/src/client/spark/view/Controls/HelpButton.cs +++ b/src/client/spark/view/Controls/HelpButton.cs @@ -12,6 +12,7 @@ namespace mbts.ui.controls { static HelpButton() { DefaultStyleKeyProperty.OverrideMetadata(typeof(HelpButton), new FrameworkPropertyMetadata(typeof(HelpButton))); + ToolTipService.ShowDurationProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(int.MaxValue)); } const string base_uri = "bts://m/"; @@ -21,7 +22,7 @@ namespace mbts.ui.controls public string ManPage { get { return (string)GetValue(CommandParameterProperty); } - set { SetValue(CommandParameterProperty, value); } + set { SetValue(CommandParameterProperty, value); } } } } diff --git a/src/client/spark/view/Controls/MultiSelectDropDown.xaml.cs b/src/client/spark/view/Controls/MultiSelectDropDown.xaml.cs index 770b7377b..640bdddd5 100644 --- a/src/client/spark/view/Controls/MultiSelectDropDown.xaml.cs +++ b/src/client/spark/view/Controls/MultiSelectDropDown.xaml.cs @@ -8,6 +8,7 @@ using System.Windows.Threading; using NUnit.Framework; using System.Collections.Generic; using System.Collections; +using bts; namespace mbts.ui.controls { @@ -92,7 +93,7 @@ namespace mbts.ui.controls var target = (MultiSelectDropDown)s; var old_collection = e.OldValue as ObservableCollection; var new_collection = e.NewValue as ObservableCollection; - Logger.assert(new_collection != null); + Log.assert(new_collection != null); if (old_collection != null) { old_collection.CollectionChanged -= target.SelectedItems_CollectionChanged; if (new_collection.Count == 0) { @@ -106,7 +107,7 @@ namespace mbts.ui.controls // CoerceValueCallback (s, value) => { var result = value ?? new ObservableCollection(); - Logger.assert(result is ObservableCollection, "SelectedItems must (unfortunately) always be of type ObservableCollection"); + Log.assert(result is ObservableCollection, "SelectedItems must (unfortunately) always be of type ObservableCollection"); return result; })); @@ -125,7 +126,7 @@ namespace mbts.ui.controls old.CollectionChanged -= on_itemssource_collection_changed; } if (neww != null) { - neww.CollectionChanged += on_itemssource_collection_changed; + neww.CollectionChanged += on_itemssource_collection_changed; } } diff --git a/src/client/spark/view/Controls/Order/OrderDetailsPopupControl.xaml b/src/client/spark/view/Controls/Order/OrderDetailsPopupControl.xaml index 2adbb7390..d9a5c66b9 100644 --- a/src/client/spark/view/Controls/Order/OrderDetailsPopupControl.xaml +++ b/src/client/spark/view/Controls/Order/OrderDetailsPopupControl.xaml @@ -56,7 +56,7 @@ Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" - Content="{Binding SelectedItem, RelativeSource={RelativeSource TemplatedParent}}" + Content="{Binding SelectedItem, RelativeSource={RelativeSource TemplatedParent}}" IsOpen="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}}" Visibility="{Binding HasEditableProperties, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BoolToVisibility}}" > @@ -182,7 +182,7 @@ - + @@ -192,7 +192,7 @@ Cross Thresh - + Cross Ticks Max Chase Ticks @@ -210,7 +210,7 @@ /> - + @@ -243,7 +243,7 @@ /> - + @@ -260,7 +260,7 @@ - + @@ -269,9 +269,9 @@ Join Thresh - + Enable Hedge - Hedge Ticks + Hedge Ticks Hedge + /> Initial Tick Offset Child @@ -311,7 +311,7 @@ - + @@ -320,9 +320,9 @@ Top Thresh - + Enable Hedge - Hedge Ticks + Hedge Ticks Hedge + /> Watch Levels Child @@ -345,7 +345,7 @@ /> - + @@ -356,7 +356,7 @@ - + @@ -364,7 +364,7 @@ - Hedge Ticks + Hedge Ticks Hedge + /> Child - + @@ -397,14 +397,25 @@ - + + + + Trigger Condition + + - Price Type + + Price Type + + + - + + + + Trigger Action + + @@ -426,9 +443,16 @@ - - Child - + + + + Child + + + - + + + + Price + + + @@ -472,7 +502,7 @@ VerticalContentAlignment="Center" IsChecked="{Binding use_fixed_price, Converter={StaticResource NotConverter}, Mode=TwoWay}" > - Payup/less + Payup @@ -501,7 +531,13 @@ - + + + + Trigger Exit + + + @@ -524,7 +560,7 @@ - + @@ -550,7 +586,7 @@ /> - + @@ -606,7 +642,7 @@ - + Child - + diff --git a/src/client/spark/view/Converters/CellPathConverter.cs b/src/client/spark/view/Converters/CellPathConverter.cs index 95eaa9a98..1f0f91a10 100644 --- a/src/client/spark/view/Converters/CellPathConverter.cs +++ b/src/client/spark/view/Converters/CellPathConverter.cs @@ -9,6 +9,7 @@ using System.Runtime.CompilerServices; using System.Windows; using System.Windows.Data; using System.Linq; +using bts; namespace mbts.ui.converters { @@ -60,8 +61,8 @@ namespace mbts.ui.converters try { return _get_property(((IDataGridCellCollection)target).get_cell(key), remaining_path.Skip(1)); } catch (Exception ex) { - Logger.error(bts.log.Subsystem.Ui, "CellPathConverter bad property lookup({0}): {1}.".fmt(key == null ? "null" : key, ex)); - Logger.assert(false, "CellPathConverter bad property assert: {0}".fmt(ex)); + Log.Ui.error("CellPathConverter bad property lookup({0}): {1}.".fmt(key == null ? "null" : key, ex)); + Log.assert(false, "CellPathConverter bad property assert: {0}".fmt(ex)); return null; } } else { diff --git a/src/client/spark/view/Converters/GridLengthConverter.cs b/src/client/spark/view/Converters/GridLengthConverter.cs index 6dc06f34e..9c1e25f5c 100644 --- a/src/client/spark/view/Converters/GridLengthConverter.cs +++ b/src/client/spark/view/Converters/GridLengthConverter.cs @@ -1,4 +1,5 @@ -using System; +using bts; +using System; using System.Collections.Generic; using System.Globalization; using System.Linq; @@ -21,7 +22,7 @@ namespace mbts.ui.converters public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { if (value is GridLength) { - Logger.assert_d(((GridLength)value).GridUnitType == UnitType); + Log.assert_d(((GridLength)value).GridUnitType == UnitType); return ((GridLength)value).Value; } return double.NaN; diff --git a/src/client/spark/view/Converters/Numeric/DoubleTextConverter.cs b/src/client/spark/view/Converters/Numeric/DoubleTextConverter.cs index 15bcec2e7..d474c763a 100644 --- a/src/client/spark/view/Converters/Numeric/DoubleTextConverter.cs +++ b/src/client/spark/view/Converters/Numeric/DoubleTextConverter.cs @@ -13,18 +13,17 @@ namespace mbts.ui.converters Minimum = Double.NaN; Maximum = Double.NaN; Multiplier = Double.NaN; - HideNaN = true; } public double Minimum { get; set; } public double Maximum { get; set; } public double Multiplier { get; set; } public string Format { get; set; } - public bool HideNaN { get; set; } + public string NaNText { get; set; } = string.Empty; public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { var text = (value as string ?? string.Empty).Trim().ToLower(); - if (text == string.Empty || text == "nan") return double.NaN; + if (text == string.Empty || text == "nan" || text == NaNText) return double.NaN; if (double.TryParse(text, out double d) && !double.IsNaN(d)) { if ((!double.IsNaN(Minimum) && d < Minimum) || (!double.IsNaN(Maximum) && d > Maximum)) return new ValidationResult(false, null); return double.IsNaN(Multiplier) ? d : d / Multiplier; @@ -40,7 +39,7 @@ namespace mbts.ui.converters return string.IsNullOrEmpty(Format) ? d.ToString() : d.ToString(Format); } } - return HideNaN ? string.Empty : "NaN"; + return NaNText; } } diff --git a/src/client/spark/view/DragDrop/DragDropDocumentPreview.xaml.cs b/src/client/spark/view/DragDrop/DragDropDocumentPreview.xaml.cs index f2f1bd8b7..af6520811 100644 --- a/src/client/spark/view/DragDrop/DragDropDocumentPreview.xaml.cs +++ b/src/client/spark/view/DragDrop/DragDropDocumentPreview.xaml.cs @@ -1,23 +1,13 @@ using System; -using System.Collections.Generic; -using System.Linq; -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; using System.Windows.Threading; +using bts; using mbts.ui.native; -namespace mbts.ui.shell -{ +namespace mbts.ui.shell { /// /// Interaction logic for DragDropDocumentPreview.xaml /// @@ -81,7 +71,7 @@ namespace mbts.ui.shell return bitmap; } else { - Logger.log(bts.log.Level.Warn, bts.log.Subsystem.Ui, "Unexpected document type in TabDocument: {0}".fmt(document.Content.GetType())); + Log.Ui.warn("Unexpected document type in TabDocument: {0}".fmt(document.Content.GetType())); return Icons.Logo; } } diff --git a/src/client/spark/view/DragDrop/DragDropHelper.cs b/src/client/spark/view/DragDrop/DragDropHelper.cs index 6b9daf298..62af0f66d 100644 --- a/src/client/spark/view/DragDrop/DragDropHelper.cs +++ b/src/client/spark/view/DragDrop/DragDropHelper.cs @@ -9,7 +9,7 @@ using System.Windows.Controls.Primitives; using System.Windows.Input; using System.Windows.Media; using System.Windows.Threading; -using bts.log; +using bts; using mbts.ui.native; using mbts.ui.shell; @@ -44,7 +44,7 @@ namespace mbts.ui public static void attach_dragdrop_events(ItemsControl container) { FloatingWindow window = Window.GetWindow(container) as FloatingWindow; - Logger.assert_d(window != null); + Log.assert_d(window != null); container.PreviewMouseDown += (s, e) => container_PreviewMouseDown(container, window, e); container.PreviewMouseUp += (s, e) => container_PreviewMouseUp(container, e); // If this was "window" it might be easier to drag off @@ -104,7 +104,7 @@ namespace mbts.ui try { var effect = DragDrop.DoDragDrop(_source, data, DragDropEffects.Move); } - catch (Exception error) { Logger.log(Level.Warn, Subsystem.Ui, "Dragdrop failed: " + error.ToString()); } + catch (Exception error) { Log.Ui.warn("Dragdrop failed: " + error.ToString()); } show_document(_source, _source_window, true); _source = null; _source_window = null; diff --git a/src/client/spark/view/Extensions/Command/AsyncDialogCommand.cs b/src/client/spark/view/Extensions/Command/AsyncDialogCommand.cs index 05ccbfe86..c20424db2 100644 --- a/src/client/spark/view/Extensions/Command/AsyncDialogCommand.cs +++ b/src/client/spark/view/Extensions/Command/AsyncDialogCommand.cs @@ -1,4 +1,4 @@ -using bts.log; +using bts; using mbts.ui.utility; using System; using System.Collections.Generic; @@ -54,13 +54,13 @@ namespace mbts.ui if(w != null) try { w.Close(); w = null; } catch (Exception ex) { - Logger.warn(Subsystem.Ui, "{0} error while attempting to Close window of Type {1} on Dispose: {2}".fmt(GetType(), typeof(TWindow), ex.Message)); + Log.Ui.warn("{0} error while attempting to Close window of Type {1} on Dispose: {2}".fmt(GetType(), typeof(TWindow), ex.Message)); } }); } } catch (Exception ex){ - Logger.warn(Subsystem.Ui, "{0} error while attempting to launch window of type {1}: {2}".fmt(GetType(), typeof(TWindow), ex.Message)); + Log.Ui.warn("{0} error while attempting to launch window of type {1}: {2}".fmt(GetType(), typeof(TWindow), ex.Message)); } finally { _is_executing = false; diff --git a/src/client/spark/view/Extensions/WPFExtensions.cs b/src/client/spark/view/Extensions/WPFExtensions.cs index 5fa4abc6b..5aa34a548 100644 --- a/src/client/spark/view/Extensions/WPFExtensions.cs +++ b/src/client/spark/view/Extensions/WPFExtensions.cs @@ -1,4 +1,5 @@ -using mbts.utils; +using bts; +using mbts.utils; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -102,6 +103,11 @@ namespace mbts.ui { return pen; } + public static ImageSource frozen(this ImageSource image_source) { + image_source.Freeze(); + return image_source; + } + // Perform a breadth first traversal of all children returning any that match the predicate. // Matching children are *not* further traversed public static IEnumerable visual_children_where(this FrameworkElement v, Func match) { @@ -235,7 +241,7 @@ namespace mbts.ui { } public static IObservable Observe(this DependencyObject instance, DependencyProperty property) { - Logger.assert(typeof(T) == instance.GetType()); + Log.assert(typeof(T) == instance.GetType()); return Observable.Create(observer => { return instance.ObserveProperty(property, (o, e) => { observer.OnNext((T)instance.GetValue(property)); diff --git a/src/client/spark/view/Resources/Buttons.xaml b/src/client/spark/view/Resources/Buttons.xaml index bb439a758..bb74779f5 100644 --- a/src/client/spark/view/Resources/Buttons.xaml +++ b/src/client/spark/view/Resources/Buttons.xaml @@ -281,6 +281,62 @@ + + #40DD40 + #B8B8B8 + + + + +