merge qa to feature branch
This commit is contained in:
commit
2e6aa8b54d
143 files changed
+1731
-1150
No files matched your search
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<List<SecurityAndHandle>>, IShellDaemon, IDisposable {
|
||||
readonly IBus _bus;
|
||||
[Export(typeof(IInitializable))]
|
||||
class MDSource : IObserver<List<SecurityAndHandle>>, IInitializable, IDisposable {
|
||||
readonly Lazy<IBus> _bus;
|
||||
readonly Lazy<SyntheticSecurityService> _ss;
|
||||
readonly MDConsumer _consumer = new MDConsumer();
|
||||
readonly Co2RelayControl _relay;
|
||||
HashSet<SecurityKey> _deleted_synthetics = new HashSet<SecurityKey>();
|
||||
@@ -24,17 +24,20 @@ namespace bts {
|
||||
IReadOnlyDictionary<SecurityKey, SecurityMD> _exchange_sec_map = new Dictionary<SecurityKey, SecurityMD>();
|
||||
|
||||
[ImportingConstructor]
|
||||
public MDSource(IBus bus, SyntheticSecurityService ss) {
|
||||
public MDSource(Lazy<IBus> bus, Lazy<SyntheticSecurityService> 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<uint>(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<SecurityAndHandle> 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));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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<SecurityMD> 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<SecurityMD> 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<SecurityCriteria> 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<SecurityCriteria> 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<SecurityMD> message) =>
|
||||
_show_picker(message, _fmt_pick_one_title, new ContractPickerModel(_bus, false, null), vm => vm.result);
|
||||
|
||||
void show_filtered_pick_one((PartialCommand<SecurityMD> 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<SecurityCriteria> message) =>
|
||||
_show_picker(message, _fmt_pick_multiple_title, new ContractPickerModel(_bus, true, null), vm => vm.result_criteria);
|
||||
|
||||
void show_and_edit_pick_multiple((PartialCommand<SecurityCriteria> 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<T>(PartialCommand<T> message, Func<string, string> fmt_title, ContractPickerModel vm, Func<ContractPickerModel, T> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<string> 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<string> _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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,10 @@
|
||||
xmlns:mbts="clr-namespace:mbts.ui"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
>
|
||||
<sys:String x:Key="{x:Static mbts:Icons.GearGeometryKey}">
|
||||
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
|
||||
</sys:String>
|
||||
|
||||
<sys:String x:Key="{x:Static mbts:Icons.OrdersGeometryKey}">
|
||||
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
|
||||
</sys:String>
|
||||
@@ -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
|
||||
</sys:String>
|
||||
|
||||
<sys:String x:Key="{x:Static mbts:Icons.PlayGeometryKey}">
|
||||
M0,0L25.194,16 0,32z
|
||||
</sys:String>
|
||||
|
||||
<sys:String x:Key="{x:Static mbts:Icons.ToolsGeometryKey}">
|
||||
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
|
||||
</sys:String>
|
||||
|
||||
<Geometry x:Key="arrow_geometry">
|
||||
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
|
||||
</Geometry>
|
||||
|
||||
<DrawingImage x:Key="Bookmarks">
|
||||
<DrawingImage.Drawing>
|
||||
@@ -488,17 +500,6 @@ M0,0L63.999001,0 63.999001,48.792999 0,48.792999z">
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
|
||||
<DrawingImage x:Key="PlayIcon">
|
||||
<DrawingImage.Drawing>
|
||||
<DrawingGroup>
|
||||
<DrawingGroup.Children>
|
||||
<GeometryDrawing Brush="Black"
|
||||
Geometry="M0,0L25.194,16 0,32z" />
|
||||
</DrawingGroup.Children>
|
||||
</DrawingGroup>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
|
||||
<!-- help / support -->
|
||||
<DrawingImage x:Key="SupportIcon">
|
||||
<DrawingImage.Drawing>
|
||||
@@ -759,20 +760,39 @@ M0,0L63.999001,0 63.999001,48.792999 0,48.792999z">
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
|
||||
<DrawingImage x:Key="UpArrow" x:Shared="False">
|
||||
<DrawingImage x:Key="RightArrow" x:Shared="False">
|
||||
<DrawingImage.Drawing>
|
||||
<DrawingGroup>
|
||||
<DrawingGroup.Children>
|
||||
<GeometryDrawing
|
||||
Brush="Black"
|
||||
Geometry="M16,0L32,19.745 0,19.745z"
|
||||
/>
|
||||
<GeometryDrawing Geometry="{StaticResource arrow_geometry}">
|
||||
<GeometryDrawing.Pen>
|
||||
<Pen Thickness="3" Brush="Black"/>
|
||||
</GeometryDrawing.Pen>
|
||||
</GeometryDrawing>
|
||||
</DrawingGroup.Children>
|
||||
</DrawingGroup>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
|
||||
<DrawingImage x:Key="DownArrow" x:Shared="False">
|
||||
<DrawingImage.Drawing>
|
||||
<DrawingGroup>
|
||||
<DrawingGroup.Children>
|
||||
<GeometryDrawing Geometry="{StaticResource arrow_geometry}">
|
||||
<GeometryDrawing.Pen>
|
||||
<Pen Thickness="3" Brush="Black"/>
|
||||
</GeometryDrawing.Pen>
|
||||
</GeometryDrawing>
|
||||
</DrawingGroup.Children>
|
||||
<DrawingGroup.Transform>
|
||||
<RotateTransform Angle="90"/>
|
||||
</DrawingGroup.Transform>
|
||||
</DrawingGroup>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
|
||||
<!-- Pin
|
||||
|
||||
<!-- Pin
|
||||
<Path Data="F1M3,11L3,7 0,7 0,6 1,6 1,1 1,0 6,0 6,1 6,6 7,6 7,7 4,7 4,11 3,11z M2,1L2,6 4,6 4,1 2,1z" />
|
||||
Unpin
|
||||
<Path Data="F1M0,3L4,3 4,0 5,0 5,1 10,1 11,1 11,6 10,6 5,6 5,7 4,7 4,4 0,4 0,3z M10,2L5,2 5,4 10,4 10,2z" />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using bts.api;
|
||||
using bts;
|
||||
using bts.api;
|
||||
using bts.shell;
|
||||
using bts.spark;
|
||||
using mbts.ui;
|
||||
@@ -12,7 +13,7 @@ using System.Windows;
|
||||
|
||||
namespace mbts.spark {
|
||||
class MarketViewWindow : SparkWindow<MarketViewWindowFactory.StartupData>, ISharedWindow {
|
||||
const string _window_type = "MarketView", _thread_id = "MarketView";
|
||||
const string _window_type = "MarketView", _thread_id = "MarketView", _window_type_display_name = "Market View";
|
||||
readonly OrdersModel _orders_model;
|
||||
readonly AllowOnce _init_guard = new AllowOnce("MarketView");
|
||||
MarketViewVM _vm;
|
||||
@@ -39,14 +40,12 @@ namespace mbts.spark {
|
||||
|
||||
public void thread_init() {
|
||||
_init_guard.check_access();
|
||||
Logger.notnull(_state);
|
||||
Log.notnull(_state);
|
||||
var state_src = Observable.FromEvent<Action<MarketViewWindowFactory.StartupData>, MarketViewWindowFactory.StartupData>(cb => _state_changed += cb, cb => _state_changed -= cb).StartWith(_state);
|
||||
_vm = new MarketViewVM(_bus, _orders_model, state_src);
|
||||
_view = new MarketViewView { DataContext = _vm };
|
||||
var update_securities_tag = new SparkTags.SparkTag<SecurityCriteria>("MarketView Callback");
|
||||
var update_securities_cmd = SparkCommand.create("Update Market View", Icon, update_securities_tag);
|
||||
var update_securities_cmd = SparkCommands.change_securities_callback(_window_type_display_name);
|
||||
_commands = new List<SparkCommand> {
|
||||
SparkCommand.create("Change Securities", Icons.Admin, SparkTags.ShowAndEditPickMultiple, () => (update_securities_cmd, _state.security_criteria)),
|
||||
SparkCommands.ShowLadders.complete(_vm.selected_security_mds_observable(), smds => smds.Count > 0),
|
||||
SparkCommands.ShowOrderTicketFromSecurity.complete(_vm.current_security_md, md => md.HasValue, ObjectHelper.ValueOrDefault),
|
||||
SparkCommands.ShowFills.complete(_vm.selected_securities_observable(), _ => true,
|
||||
@@ -55,9 +54,10 @@ namespace mbts.spark {
|
||||
})
|
||||
),
|
||||
SparkCommands.ShowTimeAndSales.complete(_vm.selected_securities_observable(), _ => true, secs => secs.Count > 0 ? new SecurityCriteria(secs) : _state.security_criteria),
|
||||
SparkCommands.ShowSyntheticCreate.complete(_vm.selected_securities_observable(), secs => secs.Count > 0 && secs.Count <= 24, secs => new SecurityCriteria(secs))
|
||||
SparkCommands.ShowSyntheticCreate.complete(_vm.selected_securities_observable(), secs => secs.Count > 0 && secs.Count <= 24, secs => new SecurityCriteria(secs)),
|
||||
SparkCommands.change_securities_command(() => (update_securities_cmd, _state.security_criteria))
|
||||
};
|
||||
_subscriptions = _bus.subscribe(update_securities_tag).OnDispatcher().Subscribe(c =>
|
||||
_subscriptions = _bus.subscribe(update_securities_cmd.tag).OnDispatcher().Subscribe(c =>
|
||||
_state_changed?.Invoke(_state = new MarketViewWindowFactory.StartupData(c, _vm.rows_view.GetSortingCriteria(), _vm.get_filter_states())));
|
||||
}
|
||||
|
||||
@@ -67,4 +67,4 @@ namespace mbts.spark {
|
||||
Commands.OfType<IDisposable>().DisposeAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using bts.api;
|
||||
using bts;
|
||||
using bts.api;
|
||||
using bts.shell;
|
||||
using bts.spark;
|
||||
using mbts.co2;
|
||||
@@ -16,7 +17,7 @@ using static mbts.ui.controls.DIYGrid;
|
||||
|
||||
namespace mbts.spark {
|
||||
class TimeAndSalesWindow : SparkWindow<StartupData>, ISlowWindow {
|
||||
const string _window_type = "TimeAndSales";
|
||||
const string _window_type = "TimeAndSales", _window_type_display_name = "Time And Sales";
|
||||
readonly MDConsumer _consumer;
|
||||
readonly TimeAndSalesWindowFactory _factory;
|
||||
SingleValuePump<TimeAndSalesVM> _vm;
|
||||
@@ -27,7 +28,7 @@ namespace mbts.spark {
|
||||
|
||||
public TimeAndSalesWindow(TimeAndSalesWindowFactory factory, IBus bus, MDConsumer consumer, StartupData state, ImageSource icon)
|
||||
: base("Time And Sales", bus, factory, SparkCommands.ShowTimeAndSales.icon) {
|
||||
Logger.assert(state != null);
|
||||
Log.assert(state != null);
|
||||
_consumer = consumer;
|
||||
_factory = factory;
|
||||
_state = state;
|
||||
@@ -55,18 +56,17 @@ namespace mbts.spark {
|
||||
public void thread_init() {
|
||||
_dispose_resources();
|
||||
_vm = new SingleValuePump<TimeAndSalesVM>();
|
||||
var update_securities_tag = new SparkTags.SparkTag<SecurityCriteria>("TimeAndSales Callback");
|
||||
var update_securities_cmd = SparkCommand.create("Update Time and Sales", Icon, update_securities_tag);
|
||||
var update_securities_cmd = SparkCommands.change_securities_callback(_window_type_display_name);
|
||||
var current_smd_source = _vm.observable.SelectMany(vm => vm.current_security_md_observable(_bus)).OnDispatcher();
|
||||
var selected_secs_source = _vm.observable.SelectMany(vm => vm.selected_securities_observable()).OnDispatcher();
|
||||
_commands = new SparkCommand[] {
|
||||
SparkCommand.create("Change Securities", Icons.Admin, SparkTags.ShowAndEditPickMultiple, () => (update_securities_cmd, _state.security_criteria)),
|
||||
SparkCommands.ShowLadder.complete(current_smd_source, md => md.HasValue, ObjectHelper.ValueOrDefault),
|
||||
SparkCommands.ShowOrderTicketFromSecurity.complete(current_smd_source, md => md.HasValue, ObjectHelper.ValueOrDefault),
|
||||
SparkCommands.ShowFills.complete(selected_secs_source, always_true, get_fills_startup_data),
|
||||
SparkCommands.ShowMarketView.complete(selected_secs_source, always_true, secs => secs.Count > 0 ? new SecurityCriteria(secs) : _state.security_criteria)
|
||||
SparkCommands.ShowMarketView.complete(selected_secs_source, always_true, secs => secs.Count > 0 ? new SecurityCriteria(secs) : _state.security_criteria),
|
||||
SparkCommands.change_securities_command(() => (update_securities_cmd, _state.security_criteria))
|
||||
};
|
||||
_subscriptions = _bus.subscribe(update_securities_tag).OnDispatcher().Subscribe(update_criteria);
|
||||
_subscriptions = _bus.subscribe(update_securities_cmd.tag).OnDispatcher().Subscribe(update_criteria);
|
||||
_initialize();
|
||||
|
||||
bool always_true<T>(T _) => true;
|
||||
|
||||
@@ -12,6 +12,7 @@ using bts.api;
|
||||
using System.ComponentModel.Composition;
|
||||
using mbts.ui.spark;
|
||||
using mbts.persist;
|
||||
using mbts.config;
|
||||
|
||||
namespace bts.ui {
|
||||
[Export(typeof(IShellModule))]
|
||||
@@ -25,6 +26,11 @@ namespace bts.ui {
|
||||
public SettingsShellModule(IBus bus, UserSettingsHub settings_hub, WorkspacesModel ws) {
|
||||
// todo: settings dialog
|
||||
ws_model = ws;
|
||||
var actions_list = new List<SparkCommand>(2) { SparkCommands.ShowWorkspaces };
|
||||
if (Configuration.get<bts.config.toggles.ToastNotifications>().enabled) {
|
||||
actions_list.Add(SparkCommands.ShowSettings);
|
||||
}
|
||||
actions = actions_list;
|
||||
_dispose = Disposable.Create(
|
||||
bus.subscribe(SparkTags.ShowWorkspaces).Subscribe(_ => show_workspaces_dialog()),
|
||||
bus.subscribe(SparkTags.ShowSettings).Subscribe(_ => {
|
||||
@@ -36,16 +42,13 @@ namespace bts.ui {
|
||||
|
||||
_bus = bus;
|
||||
}
|
||||
public ImageSource icon => Icons.Admin;
|
||||
public ImageSource icon => Icons.AdminFrozen;
|
||||
|
||||
public string name => "Settings";
|
||||
|
||||
public int priority => 40;
|
||||
|
||||
public IEnumerable<SparkCommand> actions => new SparkCommand[]{
|
||||
SparkCommands.ShowWorkspaces,
|
||||
SparkCommands.ShowSettings
|
||||
};
|
||||
public IEnumerable<SparkCommand> actions { get; }
|
||||
|
||||
public Task<IShellWindow> create(Stream load_stream) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
@@ -32,13 +32,13 @@ namespace mbts.ui.spark {
|
||||
AddColumnPlaceholderKey = "AddColumnPlaceholder";
|
||||
public const double GroupLevelIndent = 18;
|
||||
|
||||
static ExecutionStrategyEditor() =>
|
||||
static ExecutionStrategyEditor() {
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(ExecutionStrategyEditor), new FrameworkPropertyMetadata(typeof(ExecutionStrategyEditor)));
|
||||
|
||||
public ExecutionStrategyEditor() {
|
||||
AdornerHelper.attach_continuously_on_loaded(() => new ExecutionStrategyErrorAdorner(this), this);
|
||||
ToolTipService.ShowDurationProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(Int32.MaxValue));
|
||||
}
|
||||
|
||||
public ExecutionStrategyEditor() =>
|
||||
AdornerHelper.attach_continuously_on_loaded(() => new ExecutionStrategyErrorAdorner(this), this);
|
||||
|
||||
#region SyntheticName
|
||||
public static readonly DependencyProperty SyntheticNameProperty = DependencyProperty.Register("SyntheticName", typeof(string), typeof(ExecutionStrategyEditor),
|
||||
new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace bts.shell {
|
||||
case Security.ContractOneofCase.Future: _show_synthetic_create(new ContractLeg[] { SyntheticDataHelper.Defaults.ContractLeg(sec) }); break;
|
||||
case Security.ContractOneofCase.Spread: _show_synthetic_create(sec.Spread.Legs.Select(l => l.CloneToMutable())); break;
|
||||
case Security.ContractOneofCase.Synthetic: _show_synthetic_create(sec.Synthetic.Legs.Select(l => l.CloneToMutable())); break;
|
||||
default: Logger.warn(log.Subsystem.Ui, $"{GetType()} unable to process security: {sec}"); break;
|
||||
default: Log.Ui.warn($"{GetType()} unable to process security: {sec}"); break;
|
||||
}
|
||||
} else
|
||||
_show_synthetic_create(securities.Select(s => new ContractLeg(SyntheticDataHelper.Defaults.ContractLeg(s))));
|
||||
@@ -61,7 +61,7 @@ namespace bts.shell {
|
||||
|
||||
void _show_synthetic_strategy(SecurityImmutable security) {
|
||||
if (security.ContractCase != Security.ContractOneofCase.Synthetic)
|
||||
Logger.warn(log.Subsystem.Ui, $"{GetType()} observed a non-synthetic-security posted on {nameof(SparkTags.ShowSyntheticStrategyTag)}: {security}");
|
||||
Log.Ui.warn($"{GetType()} observed a non-synthetic-security posted on {nameof(SparkTags.ShowSyntheticStrategyTag)}: {security}");
|
||||
else
|
||||
_show_synthetic_strategy_async(security).ignore();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using bts.api;
|
||||
using bts;
|
||||
using bts.api;
|
||||
using bts.shell;
|
||||
using bts.spark;
|
||||
using mbts.ui;
|
||||
@@ -63,7 +64,7 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
public void initialize(StartupData state) {
|
||||
Logger.notnull(state);
|
||||
Log.notnull(state);
|
||||
_state = state;
|
||||
_vm.value = new SyntheticManagementDialogVM(_bus, _orders_model, state.sorting_criteria, state.filters ?? new FilterStates());
|
||||
if (_view == null) _view = new SyntheticManagementView { DataContext = _vm.value };
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace mbts.spark {
|
||||
IDictionary<uint, bool> _value_store = new Dictionary<uint, bool>();
|
||||
|
||||
public override string display_name { get; } = "Hidden";
|
||||
public override string help_text { get; } = string.Empty;
|
||||
public override string help_text { get; } = "A hidden quote is not sent out until the market crosses the computed quoting price. When that happens, the quote is sent out as an IOC order. This continues until the synthetic spreader order is fully filled, or cancelled.";
|
||||
public override string man_page { get; } = string.Empty;
|
||||
public override ParameterSection[] section_path { get; } = new[] { Sections.Quote };
|
||||
public FontWeight font_weight => FontWeights.SemiBold;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace bts.shell {
|
||||
_dispose = Disposable.Create(
|
||||
bus.subscribe(SparkTags.ShowActivityLog).Subscribe(show_log),
|
||||
messages.Connect(),
|
||||
messages.Subscribe(msg => Logger.info(log.Subsystem.Ui, msg.message))
|
||||
messages.Subscribe(msg => Log.Ui.info(msg.message))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace mbts.spark {
|
||||
#region Filters
|
||||
public IDataGridColumnPersistentFilter<Row, TimeFilterTuple> fill_time_filter { get; } = new TimeFilterVM<Row>(r => r.fill_time, nameof(Row.fill_time));
|
||||
public IDataGridColumnPersistentFilter<Row, TimeInForce[]> time_in_force_filter { get; } = DiscreteValuesFilterVM.Create<Row, TimeInForce>(EnumHelper.get_values<TimeInForce>().ToLArray(), r => r.time_in_force, nameof(Row.time_in_force));
|
||||
public IDataGridColumnPersistentFilter<Row, OrderType[]> order_type_filter { get; } = DiscreteValuesFilterVM.Create<Row, OrderType>(EnumHelper.get_values<OrderType>().ToLArray(), r => r.order_type, nameof(Row.order_type));
|
||||
public IDataGridColumnPersistentFilter<Row, OrderType[]> order_type_filter { get; } = DiscreteValuesFilterVM.Create<Row, OrderType>(OrderFactory.all_order_types, r => r.order_type, nameof(Row.order_type));
|
||||
public IDataGridColumnPersistentFilter<Row, string[]> account_filter { get; }
|
||||
public IDataGridColumnPersistentFilter<Row, string[]> user_filter { get; }
|
||||
public IDataGridColumnPersistentFilter<Row, Venue[]> exchange_filter { get; } = DiscreteValuesFilterVM.Create<Row, Venue>(EnumHelper.get_values<Venue>().ToLArray(), r => r.exchange, nameof(Row.exchange));
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using bts.api;
|
||||
using bts;
|
||||
using bts.api;
|
||||
using bts.shell;
|
||||
using bts.spark;
|
||||
using mbts.ui;
|
||||
@@ -30,7 +31,7 @@ namespace mbts.spark {
|
||||
|
||||
public void thread_init() {
|
||||
_init_guard.check_access();
|
||||
Logger.notnull(_state);
|
||||
Log.notnull(_state);
|
||||
_vm = new FillsVM(_bus, _orders_model, _state);
|
||||
_view = new FillsView { DataContext = _vm };
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ using LadderSettings = mbts.spark.LadderSettings;
|
||||
namespace bts.shell {
|
||||
class LadderWindowFactory : ShellWindowFactory<LadderSaveState> {
|
||||
const string _window_type = "ladder";
|
||||
readonly TimeSpan _security_timeout;
|
||||
readonly IBus _bus;
|
||||
readonly IWindowManager _wm;
|
||||
readonly UserSettingsHub _settings_hub;
|
||||
@@ -30,7 +31,9 @@ namespace bts.shell {
|
||||
_wm = wm;
|
||||
_settings_hub = settings_hub;
|
||||
_orders_model = orders_model;
|
||||
_max_ladders_open = (int)(Configuration.get<bts.config.LadderKnobs>().max_open_ladders);
|
||||
var knobs = Configuration.get<bts.config.LadderKnobs>();
|
||||
_max_ladders_open = (int)(knobs.max_open_ladders);
|
||||
_security_timeout = TimeSpan.FromSeconds(Math.Max(15, knobs.security_timeout_secs));
|
||||
_dispose = Disposable.Create(
|
||||
bus.subscribe(SparkTags.SecuritiesTag).Subscribe(s => _securities = s),
|
||||
bus.subscribe(SparkTags.ShowLadderTag).OnDispatcher().Subscribe(s => show_windows(new[] { s })),
|
||||
@@ -39,7 +42,7 @@ namespace bts.shell {
|
||||
}
|
||||
|
||||
public async override Task<IShellWindow> load(LadderSaveState state) {
|
||||
await Wait.until_true(() => _securities.ContainsKey(state.security_key), TimeSpan.FromSeconds(15));
|
||||
await Wait.until_true(() => _securities.ContainsKey(state.security_key), _security_timeout);
|
||||
if (_securities.TryGetValue(state.security_key, out SecurityMD security)) {
|
||||
return create_ladder_window(security, state.settings);
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace mbts.spark {
|
||||
// order type
|
||||
Add(order_type_column = new OrderBookOrderTypeColumn(
|
||||
DiscreteValuesFilterVM.Create<OrderBookRowVM, OrderType>(
|
||||
EnumHelper.get_values_except(OrderType.None).ToList(),
|
||||
utilities.OrderFactory.all_order_types,
|
||||
r => r.order_type.value,
|
||||
value_path(nameof(OrderBookRowVM.order_type)))));
|
||||
// order sub type
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using bts.api;
|
||||
using bts;
|
||||
using bts.api;
|
||||
using bts.api.orderman;
|
||||
using bts.spark;
|
||||
using mbts.ui;
|
||||
@@ -266,8 +267,8 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
public void update_order(OrderRecordImmutable order) {
|
||||
Logger.assert(order.ParentKey == _order.ParentKey, "Parent Keys can change?");
|
||||
Logger.assert(order.Key == _order.Key, "Keys can change?");
|
||||
Log.assert(order.ParentKey == _order.ParentKey, "Parent Keys can change?");
|
||||
Log.assert(order.Key == _order.Key, "Keys can change?");
|
||||
var old_data = current_data;
|
||||
_order = order;
|
||||
if (_update_partial(_dynamic_render_cells))
|
||||
|
||||
@@ -52,13 +52,15 @@ namespace mbts.spark {
|
||||
cvls.LiveFilteringProperties.AddRange(nameof(OrderBookRowVM.is_visible), nameof(OrderBookRowVM.passes_filter));
|
||||
_current_row = backing<OrderBookRowVM>(nameof(current_row));
|
||||
|
||||
bool expand_collapse_all_status = false;
|
||||
expand_collapse_all_rows_command = new DelegateCommand(
|
||||
collapse_all_rows_command = new DelegateCommand(
|
||||
() => {
|
||||
foreach (var r in _order_rows.Where(r => r.is_visible && r.passes_filter)) {
|
||||
r.is_expanded = !expand_collapse_all_status;
|
||||
}
|
||||
expand_collapse_all_status = !expand_collapse_all_status;
|
||||
foreach (var r in _order_rows.Where(r => r.is_visible && r.passes_filter))
|
||||
r.is_expanded = false;
|
||||
});
|
||||
expand_all_rows_command = new DelegateCommand(
|
||||
() => {
|
||||
foreach (var r in _order_rows.Where(r => r.is_visible && r.passes_filter))
|
||||
r.is_expanded = true;
|
||||
});
|
||||
|
||||
grid_settings_manager = _create_grid_settings_manager(owner_title, bus, notification_service, model, _order_rows, rows_view, columns);
|
||||
@@ -218,7 +220,8 @@ namespace mbts.spark {
|
||||
public IEnumerable<OrderRecordImmutable> selected_orders => _selected_rows.Select(r => r.order);
|
||||
|
||||
public GridSettingsManager<OrderBookRowVM, OrderRecordTuple, INotificationServiceDataCache, OrderRecordTuplePredicate> grid_settings_manager { get; }
|
||||
public ICommand expand_collapse_all_rows_command { get; }
|
||||
public ICommand collapse_all_rows_command { get; }
|
||||
public ICommand expand_all_rows_command { get; }
|
||||
|
||||
public void row_selection_changed(SelectionChangedEventArgs e) {
|
||||
RowSelectionHelper.apply_changes(_selected_rows, e);
|
||||
|
||||
@@ -28,10 +28,10 @@ namespace mbts.spark {
|
||||
, _cancel_all_orders_command
|
||||
, _cancel_selected_orders_command
|
||||
, _recreate_selected_orders_command
|
||||
, _toggle_collapse_expand_all_command
|
||||
, _toggle_collapse_all_command
|
||||
, _toggle_expand_all_command
|
||||
, _show_grid_settings_command;
|
||||
|
||||
|
||||
public OrderBookWindow(OrdersModel model, OrderBookWindowFactory factory, IBus bus, INotificationService notification_service, OrderBookWindowFactory.OrderBookStartupData state, ImageSource icon)
|
||||
: base("Order Book", bus, factory, SparkCommands.ShowOrders.icon) {
|
||||
_model = model;
|
||||
@@ -98,11 +98,15 @@ namespace mbts.spark {
|
||||
can_execute: () => _vm.selected_orders.Any(x => _passes_recreate_search_criteria(x))
|
||||
);
|
||||
|
||||
_toggle_collapse_expand_all_command = new SparkCommandCommand("Expand / Collapse All",
|
||||
Icons.UpArrow,
|
||||
_vm.expand_collapse_all_rows_command);
|
||||
_toggle_collapse_all_command = new SparkCommandCommand("Collapse All",
|
||||
Icons.RightArrow,
|
||||
_vm.collapse_all_rows_command);
|
||||
|
||||
_show_grid_settings_command = SparkCommands.grid_settings_command(_vm.grid_settings_manager.launch_settings_editor);
|
||||
_toggle_expand_all_command = new SparkCommandCommand("Expand All",
|
||||
Icons.DownArrow,
|
||||
_vm.expand_all_rows_command);
|
||||
|
||||
_show_grid_settings_command = SparkCommands.window_settings_command(_vm.grid_settings_manager.launch_settings_editor);
|
||||
|
||||
_commands = new SparkCommand[] {
|
||||
_show_fills_command,
|
||||
@@ -112,7 +116,8 @@ namespace mbts.spark {
|
||||
_cancel_sell_orders_command,
|
||||
_cancel_all_orders_command,
|
||||
_recreate_selected_orders_command,
|
||||
_toggle_collapse_expand_all_command,
|
||||
_toggle_collapse_all_command,
|
||||
_toggle_expand_all_command,
|
||||
_show_grid_settings_command
|
||||
};
|
||||
_vm.selected_order_changed += _vm_selected_order_changed;
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
using bts.api;
|
||||
using bts;
|
||||
using bts.api;
|
||||
using bts.shell;
|
||||
using bts.spark;
|
||||
using mbts.collections.extensions;
|
||||
using mbts.config;
|
||||
using mbts.persist;
|
||||
using mbts.spark;
|
||||
using mbts.ui.extensions;
|
||||
using mbts.ui.utility;
|
||||
using NAudio.Wave;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -50,7 +53,7 @@ namespace mbts.ui {
|
||||
ToastNotificationController _toast_controller;
|
||||
SoundNotificationPlayer _sound_player;
|
||||
Dispatcher _dispatcher;
|
||||
bool _toast_notifications_enabled, _sound_notifications_enabled;
|
||||
bool _toast_notifications_enabled, _sound_notifications_enabled = NotificationSettings.Default.sound_notification.enabled;
|
||||
|
||||
[ImportingConstructor]
|
||||
public Notifier(IBus bus, UserSettingsHub settings_hub) {
|
||||
@@ -68,27 +71,29 @@ namespace mbts.ui {
|
||||
if (_disposer.has_dispose_started)
|
||||
return;
|
||||
_sound_player = SoundNotificationPlayer.create();
|
||||
_toast_controller = new ToastNotificationController(bus);
|
||||
_settings_sub = settings_hub.subscribe_default_settings().StartWith(settings_hub.current).OnDispatcher().Subscribe(s => {
|
||||
if (s == null || _disposer.has_dispose_started)
|
||||
return;
|
||||
_sound_notifications_enabled = s.notification.sound_notification.enabled;
|
||||
switch (s.notification.toast_notification.mode) {
|
||||
case ToastNotificationSettings.Mode.Disabled:
|
||||
_toast_notifications_enabled = false;
|
||||
_toast_controller.hide();
|
||||
break;
|
||||
case ToastNotificationSettings.Mode.Flash:
|
||||
_toast_notifications_enabled = true;
|
||||
_toast_controller.flash_duration = s.notification.toast_notification.duration ?? _fallback_flash_duration;
|
||||
break;
|
||||
case ToastNotificationSettings.Mode.ManualClose:
|
||||
_toast_notifications_enabled = true;
|
||||
_toast_controller.flash_duration = null;
|
||||
break;
|
||||
}
|
||||
_toast_controller.max_height = Math.Max(s.notification.toast_notification.max_height, _toast_notification_box_min_height);
|
||||
});
|
||||
if (Configuration.get<bts.config.toggles.ToastNotifications>().enabled) {
|
||||
_toast_controller = new ToastNotificationController(bus);
|
||||
_settings_sub = settings_hub.subscribe_default_settings().StartWith(settings_hub.current).OnDispatcher().Subscribe(s => {
|
||||
if (s == null || _disposer.has_dispose_started)
|
||||
return;
|
||||
_sound_notifications_enabled = s.notification.sound_notification.enabled;
|
||||
switch (s.notification.toast_notification.mode) {
|
||||
case ToastNotificationSettings.Mode.Disabled:
|
||||
_toast_notifications_enabled = false;
|
||||
_toast_controller.hide();
|
||||
break;
|
||||
case ToastNotificationSettings.Mode.Flash:
|
||||
_toast_notifications_enabled = true;
|
||||
_toast_controller.flash_duration = s.notification.toast_notification.duration ?? _fallback_flash_duration;
|
||||
break;
|
||||
case ToastNotificationSettings.Mode.ManualClose:
|
||||
_toast_notifications_enabled = true;
|
||||
_toast_controller.flash_duration = null;
|
||||
break;
|
||||
}
|
||||
_toast_controller.max_height = Math.Max(s.notification.toast_notification.max_height, _toast_notification_box_min_height);
|
||||
});
|
||||
}
|
||||
// it is possible that dispose was called on another thread while we were initializing things above.
|
||||
if (_disposer.has_dispose_started) {
|
||||
Disposable.dispose(ref _settings_sub);
|
||||
@@ -97,9 +102,8 @@ namespace mbts.ui {
|
||||
(_dispatcher = Dispatcher.CurrentDispatcher).UnhandledException += _on_dispatcher_UnhandledException;
|
||||
Dispatcher.Run();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Logger.assert(false, $"Exception in {Thread.CurrentThread.Name} thread: {ex}");
|
||||
} catch (Exception ex) {
|
||||
Log.assert(false, $"Exception in {Thread.CurrentThread.Name} thread: {ex}");
|
||||
_disposer.Dispose();
|
||||
}
|
||||
}
|
||||
@@ -144,7 +148,7 @@ namespace mbts.ui {
|
||||
static void _on_dispatcher_UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) {
|
||||
BTSApplicationBootstrapper.CurrentDispatcher_HandleClipboardError(sender, e);
|
||||
if (!e.Handled) {
|
||||
Logger.error(bts.log.Subsystem.Ui, $"Unhandled Exception in ToastNotification dispatcher: {e.Exception}");
|
||||
Log.Ui.error($"Unhandled Exception in ToastNotification dispatcher: {e.Exception}");
|
||||
if (!e.Dispatcher.HasShutdownStarted) {
|
||||
e.Dispatcher.BeginInvokeShutdown(DispatcherPriority.Send);
|
||||
}
|
||||
@@ -170,16 +174,7 @@ namespace mbts.ui {
|
||||
}
|
||||
|
||||
static IReadOnlyDictionary<SoundNotification.SystemSound, NAudioPlayer> _all_players() =>
|
||||
new Dictionary<SoundNotification.SystemSound, NAudioPlayer> {
|
||||
{ SoundNotification.SystemSound.GameCorrect, new NAudioPlayer(bts.Properties.Resources.game_sound_correct) },
|
||||
{ SoundNotification.SystemSound.GameIncorrect, new NAudioPlayer(bts.Properties.Resources.game_sound_wrong) },
|
||||
{ SoundNotification.SystemSound.GameOverArcade, new NAudioPlayer(bts.Properties.Resources.game_over_arcade) },
|
||||
{ SoundNotification.SystemSound.Whistle, new NAudioPlayer(bts.Properties.Resources.whistle) },
|
||||
{ SoundNotification.SystemSound.BellCounter, new NAudioPlayer(bts.Properties.Resources.bell_counter) },
|
||||
{ SoundNotification.SystemSound.Powerup, new NAudioPlayer(bts.Properties.Resources.powerup) },
|
||||
{ SoundNotification.SystemSound.CashRegister, new NAudioPlayer(bts.Properties.Resources.cash_register_purchase) },
|
||||
{ SoundNotification.SystemSound.Reload, new NAudioPlayer(bts.Properties.Resources.reload_1911) }
|
||||
};
|
||||
EnumHelper.get_values<SoundNotification.SystemSound>().ToReadOnlyDictionary(s => s, NAudioPlayer.create);
|
||||
}
|
||||
|
||||
// This class adopts to role of view-controller in the mvc paradigm, rather than view-model in mvvm.
|
||||
@@ -287,7 +282,7 @@ namespace mbts.ui {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Logger.warn(bts.log.Subsystem.Ui, $"ToastNotifier had an unexpected {nameof(_notification_box)}.CollectionChanged Action ({e.Action}), will clear all notifications to get a clean slate.");
|
||||
Log.Ui.warn($"ToastNotifier had an unexpected {nameof(_notification_box)}.CollectionChanged Action ({e.Action}), will clear all notifications to get a clean slate.");
|
||||
_notifications.Clear();
|
||||
_notification_box.Visibility = Visibility.Hidden;
|
||||
break;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using bts.shell;
|
||||
using mbts.ui.utility;
|
||||
using NAudio.Wave;
|
||||
using System;
|
||||
using System.IO;
|
||||
@@ -9,21 +10,26 @@ namespace mbts.ui {
|
||||
// number of milliseconds to delay playing sound,
|
||||
// during which time all subsequent requests to play the same sound will be ignored.
|
||||
const int _delay_ms = 75;
|
||||
readonly int _start_position;
|
||||
WaveOutEvent _wave_out = new WaveOutEvent();
|
||||
WaveFileReader _wave_reader;
|
||||
bool _is_playing, _is_play_requested;
|
||||
|
||||
public NAudioPlayer(Stream uwave_stream) {
|
||||
public NAudioPlayer(Stream uwave_stream, int start_position = 0) {
|
||||
var ms = new MemoryStream();
|
||||
uwave_stream.CopyTo(ms);
|
||||
ms.Position = 0;
|
||||
_wave_reader = new WaveFileReader(ms);
|
||||
_wave_reader.Position = _start_position = (start_position < _wave_reader.Length ? start_position : 0);
|
||||
_wave_out.Init(_wave_reader);
|
||||
_wave_out.PlaybackStopped += _on_playback_stopped;
|
||||
}
|
||||
|
||||
public static NAudioPlayer create(SoundNotification.SystemSound system_sound) =>
|
||||
new NAudioPlayer(_get_stream(system_sound));
|
||||
public static NAudioPlayer create(SoundNotification.SystemSound system_sound) {
|
||||
var stream = _get_stream(system_sound);
|
||||
var sb = EnumHelper.get_attribute<SoundNotification.SystemSound, SilenceBufferAttribute>(system_sound);
|
||||
return sb != null ? new NAudioPlayer(stream, sb.start_position) : new NAudioPlayer(stream);
|
||||
}
|
||||
|
||||
public void play() {
|
||||
if (_is_playing) {
|
||||
@@ -36,7 +42,7 @@ namespace mbts.ui {
|
||||
}
|
||||
|
||||
void _on_playback_stopped(object sender, StoppedEventArgs e) {
|
||||
_wave_reader.Position = 0;
|
||||
_wave_reader.Position = _start_position;
|
||||
if (_is_play_requested) {
|
||||
_is_play_requested = false;
|
||||
_play_core();
|
||||
|
||||
@@ -25,6 +25,13 @@ namespace bts.shell {
|
||||
}
|
||||
}
|
||||
|
||||
class SilenceBufferAttribute : Attribute {
|
||||
public readonly int start_position;
|
||||
|
||||
public SilenceBufferAttribute(int start_position) =>
|
||||
this.start_position = start_position;
|
||||
}
|
||||
|
||||
[ProtoContract]
|
||||
class SoundNotification {
|
||||
SystemSound? _system_sound;
|
||||
@@ -37,10 +44,12 @@ namespace bts.shell {
|
||||
GameIncorrect,
|
||||
[License(LicenseType.PublicDomain, "Game Over Arcade", "myfox14", link: "https://freesound.org/people/myfox14/sounds/")]
|
||||
GameOverArcade,
|
||||
[SilenceBuffer(100000)]
|
||||
[License(LicenseType.PublicDomain, "Whistle", "zstewart09", link: "https://freesound.org/people/zstewart09/sounds")]
|
||||
Whistle,
|
||||
[License(LicenseType.PublicDomain, "Powerup", "kianda", link: "https://freesound.org/people/kianda/sounds/")]
|
||||
Powerup,
|
||||
[SilenceBuffer(130000)]
|
||||
[License(LicenseType.AttributionLicense, "Bell, Counter, A", "Inspectorj of Freesound.org", link: "https://www.jshaw.co.uk")]
|
||||
BellCounter,
|
||||
[License(LicenseType.PublicDomain, "Cash Register Purchase", "Zott820", link: "https://freesound.org/people/Zott820/sounds/")]
|
||||
|
||||
@@ -20,14 +20,12 @@ namespace mbts.spark {
|
||||
key = new FillTupleKey(fill.FillKey, order.HasValue ? order.Value.Key : 0u, security_md.HasValue ? security_md.Value.security.Id : 0u);
|
||||
}
|
||||
|
||||
// the TrimEnd is very important b/c the server currently does not trim,
|
||||
// but the account is part of the group, so this is necessary
|
||||
public string account {
|
||||
get {
|
||||
var trimmed_account_string = string.Empty;
|
||||
if (fill.FillKind != FillKind.Sod && order.HasValue && order.Value.HasDef) trimmed_account_string = order.Value.Def.Account;
|
||||
else trimmed_account_string = fill.Account;
|
||||
return trimmed_account_string == null ? string.Empty : trimmed_account_string.Trim();
|
||||
var account_string = string.Empty;
|
||||
if (fill.FillKind != FillKind.Sod && order.HasValue && order.Value.HasDef) account_string = order.Value.Def.Account;
|
||||
else account_string = fill.Account;
|
||||
return account_string == null ? string.Empty : account_string;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace mbts.spark {
|
||||
var scheduler = ThreadPoolScheduler.Instance;
|
||||
var interval = TimeSpan.FromMilliseconds(100);
|
||||
on_orders = _service.subscribei_orders().Naggle(interval, scheduler).Table().Cache();
|
||||
on_positions = _position_service.subscribei_position_data().Table().Cache();
|
||||
on_positions = _position_service.subscribei_position_data().Naggle(interval, scheduler).Table().Cache();
|
||||
working_orders =
|
||||
on_orders.Scan(
|
||||
ImmutableDictionary<uint,OrderRecordImmutable>.Empty,
|
||||
@@ -206,9 +206,11 @@ namespace mbts.spark {
|
||||
public static IObservable<double> security_total_position(this OrdersModel orders_model, uint security_key, string account) =>
|
||||
// PositionUnit.Account is actually the clearing account; this code assumes that clearing account and account are equivalent.
|
||||
// However, it still must match account to PositionUnit.Account.Trimmed() because the exchange likes to slap spaces on the end.
|
||||
orders_model.on_security_positions(security_key).filter(p => p.Account == account).Scan(0.0, (pos, table) =>
|
||||
// the state should always have 1 element, since the PositionUnit-identity is security + account
|
||||
pos + (table.added.Sum(p => p.total_pos()) - table.removed.Sum(p => p.total_pos())));
|
||||
orders_model.on_security_positions(security_key)
|
||||
.filter(p => p.Account == account)
|
||||
// the state should always have 1 element, since the PositionUnit-identity is security + account
|
||||
.Scan(0.0, (pos, table) => pos + (table.added.Sum(p => p.total_pos()) - table.removed.Sum(p => p.total_pos())))
|
||||
.StartWith(double.NaN);
|
||||
|
||||
public static IObservable<ITableUpdateTransform<OrderRecordImmutable, uint>> on_security_root_orders(this OrdersModel orders_model, uint security_key) =>
|
||||
orders_model.on_security_orders(security_key).Scan(new RootOrderData(), (rod, table) => {
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace mbts {
|
||||
public static bool check_order_transition_trigger(OrderRecordTuple order, Func<OrderRecordImmutable, bool> order_predicate_core, IPredicate<SecurityImmutable> security_predicate, INotificationServiceDataCache data_cache, out OrderRecordTuple oldval) {
|
||||
if (check_security_predicate(order, security_predicate) && order_predicate_core(order.order)) {
|
||||
oldval = data_cache.get_previous_order_state(order.order.Key);
|
||||
return oldval == null ? !data_cache.is_first_order_update : order_predicate_core(oldval.order);
|
||||
return oldval == null ? !data_cache.is_first_order_update : !order_predicate_core(oldval.order);
|
||||
}
|
||||
oldval = null;
|
||||
return false;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using mbts.collections.extensions;
|
||||
using mbts.config;
|
||||
using mbts.spark;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.spark;
|
||||
@@ -31,6 +32,8 @@ namespace mbts.ui.settings {
|
||||
}
|
||||
|
||||
static class PredicateBuilderVMWrapper {
|
||||
static readonly bool _toast_notifications_enabled_global = Configuration.get<bts.config.toggles.ToastNotifications>().enabled;
|
||||
|
||||
public static ITemplatedPropertyWrapperVM<TSource> wrap_child_oneof<TSource, TChild, TChildOneof>(
|
||||
Func<TSource, TChild> get, Action<TSource, TChild> set, Func<TChild, TChildOneof> get_child_oneof, Dictionary<TChildOneof, ITemplatedPropertyWrapperVM<TChild>> oneof_vms)
|
||||
where TChildOneof : struct
|
||||
@@ -104,8 +107,9 @@ namespace mbts.ui.settings {
|
||||
}
|
||||
}
|
||||
public ITemplatedPropertyWrapperVM<TPredicate> selected_predicate => _selected_predicate.Value;
|
||||
public bool can_enable_toast_notifications => _can_enable_toast_notifications.Value;
|
||||
public bool can_enable_toast_notifications => _toast_notifications_enabled_global && _can_enable_toast_notifications.Value;
|
||||
public bool toast_notifications_enabled { get => _toast_notifications_enabled.Value; set => _toast_notifications_enabled.set(value); }
|
||||
public bool is_root => true;
|
||||
string ITemplateSelectorKey.key => PredicateTemplateKeys.Recursive;
|
||||
|
||||
protected override void Dispose(bool disposing) =>
|
||||
@@ -161,6 +165,7 @@ namespace mbts.ui.settings {
|
||||
}
|
||||
}
|
||||
public ITemplatedPropertyWrapperVM<TChild> selected_predicate => _selected_predicate.Value;
|
||||
public bool is_root => false;
|
||||
string ITemplateSelectorKey.key => _template_key;
|
||||
|
||||
protected override void Dispose(bool disposing) {
|
||||
|
||||
@@ -15,6 +15,7 @@ using mbts.ui.shell;
|
||||
using NUnit.Framework;
|
||||
using mbts.config;
|
||||
using bts.core;
|
||||
using bts;
|
||||
|
||||
namespace mbts.ui.tests
|
||||
{
|
||||
@@ -43,7 +44,7 @@ namespace mbts.ui.tests
|
||||
finally {
|
||||
gonow.Set();
|
||||
}
|
||||
Logger.log(bts.log.Level.Info, bts.log.Subsystem.Ui, "Init Application");
|
||||
Log.Ui.info("Init Application");
|
||||
Dispatcher.Run();
|
||||
});
|
||||
t.Name = "Application Thread";
|
||||
@@ -72,7 +73,7 @@ namespace mbts.ui.tests
|
||||
Assert.IsNotNull(Application.Current);
|
||||
// Run the logic of this test on the "Main" thread
|
||||
Application.Current.Dispatcher.Invoke(() => {
|
||||
Logger.log(bts.log.Level.Info, bts.log.Subsystem.Ui, "Begin: test_windows_disposed");
|
||||
Log.Ui.info("Begin: test_windows_disposed");
|
||||
// Make sure that an IShellWindow and ISlowWindow added to the Windows collection is eventually disposed
|
||||
var thread_factory = new ShellThreadFactory();
|
||||
IWindowManager wm = new WindowManager(thread_factory, new Lazy<ISettingsCollector>(() => new TestSettingsCollector()), new TestSavedWindowFactory(), null, new SimpleBus());
|
||||
@@ -97,7 +98,7 @@ namespace mbts.ui.tests
|
||||
public void test_slow_windows_disposed() {
|
||||
Assert.IsNotNull(Application.Current);
|
||||
Application.Current.Dispatcher.Invoke(() => {
|
||||
Logger.log(bts.log.Level.Info, bts.log.Subsystem.Ui, "Begin: test_slow_windows_disposed");
|
||||
Log.Ui.info("Begin: test_slow_windows_disposed");
|
||||
// Make sure that an IShellWindow and ISlowWindow added to the Windows collection is eventually disposed
|
||||
var thread_factory = new ShellThreadFactory();
|
||||
IWindowManager wm = new WindowManager(thread_factory, new Lazy<ISettingsCollector>(() => new TestSettingsCollector()), new TestSavedWindowFactory(), null, new SimpleBus());
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace bts.core
|
||||
subject<T>(tag).OnNext(data);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Logger.error(log.Subsystem.Ui, $"Exception posting to '{tag}': {e}");
|
||||
Log.Ui.error($"Exception posting to '{tag}': {e}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace bts.spark
|
||||
return _get_parameter();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Logger.warn(log.Subsystem.Ui, $"Error retrieving parameter for '{title}' - Exception: '{e}'");
|
||||
Log.Ui.warn($"Error retrieving parameter for '{title}' - Exception: '{e}'");
|
||||
return default;
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,7 @@ namespace bts.spark
|
||||
bus.post(tag, arg);
|
||||
}
|
||||
catch (Exception e) {
|
||||
Logger.warn(log.Subsystem.Ui, $"Error invoking command '{title}' - Exception: '{e}'");
|
||||
Log.Ui.warn($"Error invoking command '{title}' - Exception: '{e}'");
|
||||
}
|
||||
}
|
||||
public override bool canExecute() {
|
||||
@@ -205,7 +205,7 @@ namespace bts.spark
|
||||
try {
|
||||
bus.post(_tag, _parameter);
|
||||
} catch (Exception e) {
|
||||
Logger.warn(log.Subsystem.Ui, $"Error invoking command '{title}' - Exception: '{e}'");
|
||||
Log.Ui.warn($"Error invoking command '{title}' - Exception: '{e}'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace bts.spark
|
||||
public static SparkCommand ShowWorkspaces =>
|
||||
SparkCommand.create("Workspaces", Icons.FavoriteWindow, SparkTags.ShowWorkspaces);
|
||||
public static SparkCommand ShowSettings =>
|
||||
SparkCommand.create("Settings", Icons.Admin, SparkTags.ShowSettings);
|
||||
SparkCommand.create("Settings", Icons.AdminFrozen, SparkTags.ShowSettings);
|
||||
|
||||
// Support
|
||||
public static SparkCommand ShowManual =>
|
||||
@@ -111,7 +111,14 @@ namespace bts.spark
|
||||
public static PartialCommand<IEnumerable<(OrderDefinitionImmutable, double, uint)>> RecreateSelectedOrders =>
|
||||
SparkCommand.create("Recreate", Icons.Beaker, SparkTags.RecreateOrder);
|
||||
|
||||
public static SparkCommand grid_settings_command(IDialogCommand launch_settings_editor) =>
|
||||
new SparkCommandWrapper("Window Settings", Icons.Tools, launch_settings_editor);
|
||||
// TODO: remove this method, eventually want all windows to use window_settings_command()
|
||||
public static SparkCommand change_securities_command(Func<(PartialCommand<SecurityCriteria>, SecurityCriteria)> get_param) =>
|
||||
SparkCommand.create("Settings", Icons.AdminFrozen, SparkTags.ShowAndEditPickMultiple, get_param);
|
||||
|
||||
public static PartialCommand<SecurityCriteria> change_securities_callback(string window_name) =>
|
||||
SparkCommand.create(window_name, Icons.AdminFrozen, new SparkTags.SparkTag<SecurityCriteria>($"Change {window_name} securities callback"));
|
||||
|
||||
public static SparkCommand window_settings_command(IDialogCommand launch_settings_editor) =>
|
||||
new SparkCommandWrapper("Settings", Icons.AdminFrozen, launch_settings_editor);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using bts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
@@ -186,7 +187,7 @@ namespace mbts.expression
|
||||
if (t[x] is CompareOperator) {
|
||||
CompareOperator b = (CompareOperator)t[x];
|
||||
if (b.Left != null) {
|
||||
Logger.assert(b.Right != null);
|
||||
Log.assert(b.Right != null);
|
||||
continue;
|
||||
}
|
||||
b.Left = t[x - 1];
|
||||
@@ -202,7 +203,7 @@ namespace mbts.expression
|
||||
if (t[x] is JoinOperator) {
|
||||
JoinOperator j = (JoinOperator)t[x];
|
||||
if (j.Left != null) {
|
||||
Logger.assert(j.Right != null);
|
||||
Log.assert(j.Right != null);
|
||||
continue;
|
||||
}
|
||||
j.Left = t[x - 1];
|
||||
@@ -213,7 +214,7 @@ namespace mbts.expression
|
||||
}
|
||||
}
|
||||
|
||||
Logger.assert(t.Count == 1);
|
||||
Log.assert(t.Count == 1);
|
||||
return t.First();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Windows;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Media;
|
||||
using System.Reflection;
|
||||
using bts;
|
||||
|
||||
namespace mbts.ui
|
||||
{
|
||||
@@ -114,7 +115,7 @@ namespace mbts.ui
|
||||
}
|
||||
else
|
||||
{ // if the color is not in the dictionary then throw an exception
|
||||
Logger.assert_d(false, "The color '{0}' could not be found".fmt(Name));
|
||||
Log.assert_d(false, "The color '{0}' could not be found".fmt(Name));
|
||||
throw new ColorNotFoundException();
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace mbts.ui {
|
||||
public static BTSColor disabled_text { get { return BTSCoreColors.gray_light; } }
|
||||
|
||||
public static BTSColor pinkalicious { get { return new BTSColor(0xff, 0x33, 0x99); } }
|
||||
public static BTSColor bluealicious { get { return new BTSColor(0, 89, 179); } }
|
||||
|
||||
// Grid column colors
|
||||
|
||||
@@ -91,7 +92,7 @@ namespace mbts.ui {
|
||||
public static BTSColor bid { get; }
|
||||
public static BTSColor bid_alt { get { return BTSCoreColors.blue_light; } }
|
||||
public static BTSColor ask { get; }
|
||||
public static BTSColor ask_alt { get { return BTSCoreColors.red_light_dark; } }
|
||||
public static BTSColor ask_alt { get { return new BTSColor(255,180,180); } }
|
||||
public static BTSColor last { get { return BTSCoreColors.black; } }
|
||||
public static BTSColor bid_ask_alt_blend => BTSCoreColors.purple_light;
|
||||
|
||||
@@ -207,10 +208,12 @@ namespace mbts.ui {
|
||||
public static BTSColor straddle_theovsmarket_positive { get { return BTSCoreColors.green_light; } }
|
||||
|
||||
// Order Types
|
||||
public static BTSColor tick_order { get { return BTSColors.purple.rgb_color();}}
|
||||
public static BTSColor lean_order { get { return BTSColors.purple.rgb_color();}}
|
||||
public static BTSColor join_order { get { return BTSColors.purple.rgb_color();}}
|
||||
public static BTSColor top_order { get { return BTSColors.purple.rgb_color();}}
|
||||
public static BTSColor tick_order { get { return BTSColors.purple.rgb_color(); } }
|
||||
public static BTSColor lean_order { get { return new BTSColor(255, 170, 210); } }
|
||||
public static BTSColor join_order { get { return new BTSColor(200, 171, 232); } }
|
||||
public static BTSColor cover_order { get { return new BTSColor(134, 232, 224); } }
|
||||
public static BTSColor trigger_order { get { return new BTSColor(172, 255, 179); } }
|
||||
public static BTSColor top_order { get { return BTSColors.purple.rgb_color(); } }
|
||||
}
|
||||
|
||||
public static class AW2 {
|
||||
|
||||
@@ -15,6 +15,7 @@ using System.Windows.Threading;
|
||||
using System.Collections.Specialized;
|
||||
using mbts.spark;
|
||||
using bts.api;
|
||||
using bts;
|
||||
|
||||
namespace mbts
|
||||
{
|
||||
@@ -155,7 +156,7 @@ namespace mbts
|
||||
//this overloaded declaration, (as opposed to one function with comp = null) allows observable_collection.sync_with to be passed into functions as a parameterless Action
|
||||
public static void sync_with<T>(this IList<T> dest, IEnumerable<T> src) { dest.sync_with(src, EqualityComparer<T>.Default); }
|
||||
public static void sync_with<T>(this IList<T> dest, IEnumerable<T> src, IEqualityComparer<T> comp) {
|
||||
Logger.notnull(dest);
|
||||
Log.notnull(dest);
|
||||
if (src == null) {
|
||||
dest.Clear();
|
||||
return;
|
||||
@@ -189,8 +190,8 @@ namespace mbts
|
||||
public static bool sync_with_setwise<T>(this ObservableCollection<T> dest, IEnumerable<T> src) { return dest.sync_with_setwise(src, EqualityComparer<T>.Default); }
|
||||
public static bool sync_with_setwise<T>(this ObservableCollection<T> dest, IEnumerable<T> src, IEqualityComparer<T> comp) {
|
||||
if (!src.is_distinct(comp)) {
|
||||
Logger.assert_d(false);
|
||||
Logger.error(bts.log.Subsystem.Ui, "sync_with_setwise requires input to be distinct. Error in input of type {0}.".fmt(typeof(T).Name));
|
||||
Log.assert_d(false);
|
||||
Log.Ui.error($"sync_with_setwise requires input to be distinct. Error in input of type {typeof(T).Name}.");
|
||||
}
|
||||
IEnumerable<T> added, removed;
|
||||
dest.difference(src, out added, out removed, comp);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using mbts.user.settings;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using bts;
|
||||
using static bts.utils.MathUtils;
|
||||
|
||||
namespace mbts {
|
||||
@@ -273,7 +274,7 @@ namespace mbts {
|
||||
}
|
||||
}
|
||||
catch (OverflowException ex) {
|
||||
Logger.warn(bts.log.Subsystem.Ui, $"Arithmetic overflow exception in format_tick (tick:{tick}, value:{value}):{ex}");
|
||||
Log.Ui.warn($"Arithmetic overflow exception in format_tick (tick:{tick}, value:{value}):{ex}");
|
||||
return "Overflow";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using bts;
|
||||
|
||||
namespace mbts.ui.native
|
||||
{
|
||||
@@ -211,7 +212,7 @@ namespace mbts.ui.native
|
||||
// Since we want to do that during shutdown this could cause a long delay.
|
||||
bool result = SetWorkArea_SystemParametersInfo(SPI.SETWORKAREA, 1, rect, SPIF_UPDATEINIFILE);
|
||||
if (!result) {
|
||||
Logger.log(bts.log.Level.Error, bts.log.Subsystem.Ui, "Failed to set work area. {0} - {1}".fmt(Marshal.GetLastWin32Error(), new System.ComponentModel.Win32Exception().Message));
|
||||
Log.Ui.error("Failed to set work area. {0} - {1}".fmt(Marshal.GetLastWin32Error(), new System.ComponentModel.Win32Exception().Message));
|
||||
}
|
||||
SendNotifyMessage(HWND_BROADCAST, WM.SETTINGCHANGE, (Int64)SPI.SETWORKAREA, 0);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using bts;
|
||||
using mbts.ui.shell;
|
||||
|
||||
namespace mbts.ui.settings
|
||||
@@ -36,7 +37,7 @@ namespace mbts.ui.settings
|
||||
} while (count < 100 && changed);
|
||||
|
||||
if (count == 100) {
|
||||
Logger.log(bts.log.Level.Error, bts.log.Subsystem.Persist, "Error: Window state migration still changing after 100 iterations. Please check IShellWindowMigrationRule logic.");
|
||||
Log.Persist.error("Error: Window state migration still changing after 100 iterations. Please check IShellWindowMigrationRule logic.");
|
||||
}
|
||||
|
||||
return restore(window.owner, window.app_data, window.position);
|
||||
@@ -55,7 +56,7 @@ namespace mbts.ui.settings
|
||||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
Logger.log(bts.log.Level.Error, bts.log.Subsystem.Persist, "Exception running compat rule {0}.\n{1}".fmt(test.GetType().Name, e.ToString()));
|
||||
Log.Persist.error("Exception running compat rule {0}.\n{1}".fmt(test.GetType().Name, e.ToString()));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -64,7 +65,7 @@ namespace mbts.ui.settings
|
||||
private async Task<IShellWindow> restore(string owner_name, byte[] state, WindowPosition windowPosition) {
|
||||
IShellModule owner = _modules.SingleOrDefault(m => m.key() == owner_name);
|
||||
if (owner == null) {
|
||||
Logger.log(bts.log.Level.Warn, bts.log.Subsystem.Ui, "Could not locate module '{0}'".fmt(owner_name));
|
||||
Log.Ui.warn("Could not locate module '{0}'".fmt(owner_name));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -74,31 +75,15 @@ namespace mbts.ui.settings
|
||||
IShellWindow window = await task;
|
||||
if (window != null) {
|
||||
window.set_start_position(windowPosition);
|
||||
Logger.log(bts.log.Level.Info, bts.log.Subsystem.Ui, $"Restoring window {owner_name} - {window.diagnostic_name()}.");
|
||||
Log.Ui.info($"Restoring window {owner_name} - {window.diagnostic_name()}.");
|
||||
}
|
||||
return window;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
Logger.log(bts.log.Level.Error, bts.log.Subsystem.Ui,
|
||||
"Failure to re-create window for module {0}. Error: {1}".fmt(owner_name, e.Message));
|
||||
Log.Ui.error("Failure to re-create window for module {0}. Error: {1}".fmt(owner_name, e.Message));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//private static async Task<T> await_with_timeout<T>(Task<T> task) {
|
||||
// if (task.IsCompleted) {
|
||||
// return task.Result;
|
||||
// }
|
||||
// else {
|
||||
// if (await Task.WhenAny(task, Task.Delay(4096)) == task) {
|
||||
// return task.Result;
|
||||
// }
|
||||
// else {
|
||||
// Logger.log(bts.log.Level.Warn, bts.log.Subsystem.ui, "Timed out waiting to load saved window");
|
||||
// }
|
||||
// }
|
||||
// return default(T);
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using bts.log;
|
||||
using bts;
|
||||
using mbts.ui.shell;
|
||||
|
||||
namespace mbts.ui.settings
|
||||
@@ -80,7 +80,7 @@ namespace mbts.ui.settings
|
||||
return state;
|
||||
}
|
||||
catch (Exception e) {
|
||||
Logger.log(Level.Error, Subsystem.Ui, "Error saving window state for type {0}.\n {1}".fmt(window.GetType(), e.Message));
|
||||
Log.Ui.error("Error saving window state for type {0}.\n {1}".fmt(window.GetType(), e.Message));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ namespace mbts.spark {
|
||||
|
||||
[ProtoMember(1)]
|
||||
LadderSettings _ladder;
|
||||
[ProtoMember(2)]
|
||||
// removing NotificationSettings these from proto-serialization, since they are disabled by default for now.
|
||||
// This way, when they are enabled, there won't be any backwards compatability issues to worry about, as no clients will have persisted them yet.
|
||||
NotificationSettings _notification;
|
||||
|
||||
public UserSettings() { }
|
||||
|
||||
@@ -2,8 +2,8 @@ using System;
|
||||
using System.Windows;
|
||||
using System.Collections.Generic;
|
||||
using mbts.ui.native;
|
||||
using bts.log;
|
||||
using System.Windows.Threading;
|
||||
using bts;
|
||||
|
||||
namespace mbts.ui
|
||||
{
|
||||
@@ -26,9 +26,9 @@ namespace mbts.ui
|
||||
|
||||
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) {
|
||||
var exception = e.ExceptionObject as Exception;
|
||||
Logger.log(Level.Error, Subsystem.Ui, $"Unhandled Exception: {e.ExceptionObject} {exception?.StackTrace}");
|
||||
Log.Ui.error($"Unhandled Exception: {e.ExceptionObject} {exception?.StackTrace}");
|
||||
if (e.IsTerminating) {
|
||||
Logger.system_is_crashing("Unhandled exception", e.ExceptionObject);
|
||||
Log.system_is_crashing("Unhandled exception", e.ExceptionObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using bts;
|
||||
using bts.api;
|
||||
|
||||
namespace mbts.ui.utility
|
||||
@@ -83,7 +84,7 @@ namespace mbts.ui.utility
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
mbts.Logger.log(bts.log.Level.Error, bts.log.Subsystem.Ui, String.Format("Exception message = {0}", ex.Message));
|
||||
Log.Ui.error(String.Format("Exception message = {0}", ex.Message));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Reactive.Subjects;
|
||||
|
||||
namespace mbts.utils {
|
||||
class KeyDrivenObservable<TKey, TValue> : ISubject<TKey, TValue>, IDisposable {
|
||||
readonly Func<TKey, IObservable<TValue>> _selector;
|
||||
Subject<TValue> _value_subject = new Subject<TValue>();
|
||||
IDisposable _current_key_sub;
|
||||
|
||||
public KeyDrivenObservable(Func<TKey, IObservable<TValue>> selector) =>
|
||||
_selector = selector;
|
||||
|
||||
public void OnCompleted() => Disposable.dispose(ref _current_key_sub);
|
||||
public void OnError(Exception error) { }
|
||||
public void OnNext(TKey key) {
|
||||
Disposable.dispose(ref _current_key_sub);
|
||||
_current_key_sub = _selector(key)?.Subscribe(_value_subject);
|
||||
}
|
||||
|
||||
public IDisposable Subscribe(IObserver<TValue> observer) => _value_subject.Subscribe(observer);
|
||||
|
||||
public void Dispose() {
|
||||
Disposable.dispose(ref _current_key_sub);
|
||||
Disposable.dispose(ref _value_subject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Threading;
|
||||
using bts;
|
||||
using System.Threading;
|
||||
|
||||
namespace mbts.utils {
|
||||
class ThreadSafeCounter {
|
||||
@@ -14,9 +15,9 @@ namespace mbts.utils {
|
||||
public AllowOnce(string name) => _name = name;
|
||||
|
||||
/// <summary>
|
||||
/// After this method is called once, subsequent calls will result in the Application being terminated via Logger.assert.
|
||||
/// After this method is called once, subsequent calls will result in the Application being terminated via Log.assert.
|
||||
/// </summary>
|
||||
public void check_access() =>
|
||||
Logger.assert(_counter.increment() == 1, $"AllowOnce '{_name}' check_access was called twice.");
|
||||
Log.assert(_counter.increment() == 1, $"AllowOnce '{_name}' check_access was called twice.");
|
||||
}
|
||||
}
|
||||
@@ -649,9 +649,12 @@ namespace mbts.ui.shell
|
||||
}
|
||||
} else {
|
||||
_items.sync_with(value);
|
||||
if (_is_user_selected_item)
|
||||
if (_is_user_selected_item) {
|
||||
_is_user_selected_item = _items.Contains(_selected_item);
|
||||
_try_auto_select();
|
||||
}
|
||||
if (!_is_user_selected_item) {
|
||||
_try_auto_select();
|
||||
}
|
||||
}
|
||||
}
|
||||
void IObserver<IEnumerable<T>>.OnError(Exception error) { }
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using mbts.spark.filters;
|
||||
using bts;
|
||||
using mbts.spark.filters;
|
||||
using mbts.ui.controls.adorners;
|
||||
using mbts.ui.extensions;
|
||||
using mbts.ui.utility;
|
||||
@@ -414,7 +415,7 @@ namespace mbts.ui.controls {
|
||||
// Called when items are added or removed from the columns collection
|
||||
private void on_columns_changed(object sender, NotifyCollectionChangedEventArgs e) {
|
||||
if (sender is ObservableCollection<ColumnBase> columns) {
|
||||
Logger.assert(sender == _visible_columns, "DIYGrid.on_columns_changed callback expects the sender to be the grid's _visible_columns (or null).");
|
||||
Log.assert(sender == _visible_columns, "DIYGrid.on_columns_changed callback expects the sender to be the grid's _visible_columns (or null).");
|
||||
// frozen_column_count is with respect to all columns, visible or not,
|
||||
// need to account for the fact that a "frozen" column might not be visible
|
||||
var all_columns = Columns;
|
||||
@@ -764,7 +765,7 @@ namespace mbts.ui.controls {
|
||||
|
||||
_scroll_horizontal = (ScrollBar)GetTemplateChild("_scroll_horiz");
|
||||
_row_presenter = (ListBox)GetTemplateChild("_row_presenter");
|
||||
Logger.assert_d(!_row_presenter.IsLoaded);
|
||||
Log.assert_d(!_row_presenter.IsLoaded);
|
||||
_try_set_row_style();
|
||||
_row_presenter.Loaded += (o, e) => {
|
||||
var sv = _row_presenter.descendants_of_type<ScrollViewer>().FirstOrDefault();
|
||||
@@ -773,10 +774,10 @@ namespace mbts.ui.controls {
|
||||
}
|
||||
};
|
||||
_header_scroll_viewer = (ScrollViewer)GetTemplateChild("_header_scroll_viewer");
|
||||
Logger.assert_d(!_header_scroll_viewer.IsLoaded);
|
||||
Log.assert_d(!_header_scroll_viewer.IsLoaded);
|
||||
_header_scroll_viewer.Loaded += (o,e) => {
|
||||
_header_horizontal_scroll_bar = get_scrollbar(_header_scroll_viewer, Orientation.Horizontal);
|
||||
Logger.assert(_header_horizontal_scroll_bar != null);
|
||||
Log.assert(_header_horizontal_scroll_bar != null);
|
||||
Action<DependencyProperty> bind =
|
||||
prop => _scroll_horizontal.SetBinding(prop, new Binding(prop.Name) { Source = _header_horizontal_scroll_bar });
|
||||
bind(ScrollBar.SmallChangeProperty);
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<u:WindowStyle.TitleContentTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Image Margin="3,1" Source="{x:Static u:Icons.Tools}"/>
|
||||
<Image Margin="3,1" Source="{x:Static u:Icons.Admin}"/>
|
||||
<TextBlock Text="{Binding owner_title, StringFormat='{}\'{0}\' Window Settings'}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
@@ -133,12 +133,12 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
public class PredicateRowAnimationVM : DisposableViewModelBase, IValueFactory<(TPredicateBuilder predicate, IEnumerable<RowAnimation> animations, IEnumerable<SoundNotification> sounds)> {
|
||||
readonly Property<bool> _show_animations, _play_sound;
|
||||
readonly Property<bool> _show_animations/*, _play_sound*/;
|
||||
|
||||
public PredicateRowAnimationVM(IPropertyWrapperVM<TPredicateBuilder> predicate) {
|
||||
this.predicate = predicate;
|
||||
_show_animations = backing(nameof(show_animations), true);
|
||||
_play_sound = backing(nameof(play_sound), true);
|
||||
//_play_sound = backing(nameof(play_sound), true);
|
||||
animations = new ObservableEditableCollection<RowAnimationVM>(() => {
|
||||
var vm = new RowAnimationVM();
|
||||
vm.selected_animation_type = vm.animation_types.FirstOrDefault();
|
||||
@@ -152,13 +152,14 @@ namespace mbts.spark {
|
||||
public ObservableEditableCollection<RowAnimationVM> animations { get; }
|
||||
public IEnumerable<CellAnimation.AnimationTypeOneofCase> animation_types { get; } = EnumHelper.get_values_except(CellAnimation.AnimationTypeOneofCase.None);
|
||||
public bool show_animations { get => _show_animations.Value; set => _show_animations.set(value); }
|
||||
public bool play_sound { get => _play_sound.Value; set => _play_sound.set(value); }
|
||||
//public bool play_sound { get => _play_sound.Value; set => _play_sound.set(value); }
|
||||
public IPropertyWrapperVM<SoundNotification> sound { get; } = SoundAnimationVM.create_system_sound_vm();
|
||||
|
||||
public (TPredicateBuilder predicate, IEnumerable<RowAnimation> animations, IEnumerable<SoundNotification> sounds) create() =>
|
||||
(predicate.create_assigned(),
|
||||
animations.Select(a => a.create_assigned()),
|
||||
EnumerableExtensions.return_if(play_sound, () => sound.create_assigned()));
|
||||
new[] { sound.create_assigned() });
|
||||
//EnumerableExtensions.return_if(play_sound, () => sound.create_assigned()));
|
||||
|
||||
public void load_from((TPredicateBuilder predicate, IEnumerable<RowAnimation> animations, IEnumerable<SoundNotification> sounds) args) {
|
||||
predicate.load_from(args.predicate);
|
||||
@@ -169,9 +170,9 @@ namespace mbts.spark {
|
||||
}));
|
||||
var en = args.sounds.GetEnumerator();
|
||||
if (en.MoveNext()) {
|
||||
_play_sound.set(true);
|
||||
//_play_sound.set(true);
|
||||
sound.load_from(en.Current);
|
||||
} else _play_sound.set(false);
|
||||
} //else _play_sound.set(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
<sys:Double x:Key="HorizontalSplit">8.0</sys:Double>
|
||||
<sys:Double x:Key="HorizontalGap">16.0</sys:Double>
|
||||
<sys:Double x:Key="ControlNormalWidth">140</sys:Double>
|
||||
<sys:Double x:Key="PredicateRootColumnWidth">176</sys:Double>
|
||||
<sys:Double x:Key="ControlLongWidth">240</sys:Double>
|
||||
<sys:Double x:Key="ComboBoxShortWidth">70</sys:Double>
|
||||
<sys:Double x:Key="ComboBoxNormalWidth">88</sys:Double>
|
||||
@@ -133,7 +134,16 @@
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource HorizontalPush}}"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ComboBox x:Name="PART_Predicates" Style="{StaticResource PredicateTypeComboBoxStyle}">
|
||||
<ComboBox x:Name="PART_Predicates">
|
||||
<ComboBox.Style>
|
||||
<Style TargetType="ComboBox" BasedOn="{StaticResource PredicateTypeComboBoxStyle}">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding is_root}" Value="{u:True}">
|
||||
<Setter Property="Width" Value="{StaticResource PredicateRootColumnWidth}"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ComboBox.Style>
|
||||
<ComboBox.GroupStyle>
|
||||
<GroupStyle ContainerStyle="{StaticResource ComboBox.DelineatedGroupContainerStyle}"/>
|
||||
</ComboBox.GroupStyle>
|
||||
@@ -446,38 +456,44 @@
|
||||
Grid.Row="4"
|
||||
Grid.Column="1"
|
||||
>
|
||||
<Grid.RowDefinitions>
|
||||
<!--<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="{Binding Source={StaticResource VerticalPush}}"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
</Grid.RowDefinitions>-->
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource HorizontalGap}}"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource HorizontalSplit}}"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource PredicateRootColumnWidth}}"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource HorizontalPush}}"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<CheckBox Grid.Column="1" VerticalAlignment="Center" IsChecked="{Binding play_sound}">Play Sound</CheckBox>
|
||||
<ComboBox
|
||||
Grid.Column="3"
|
||||
ItemsSource="{Binding sound.items}"
|
||||
SelectedItem="{Binding sound.value}"
|
||||
ItemTemplate="{StaticResource EnumDescriptionTemplate}"
|
||||
Visibility="{Binding play_sound, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
/>
|
||||
<ComboBox
|
||||
Grid.Column="3"
|
||||
<Grid HorizontalAlignment="Stretch">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource HorizontalPush}}"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock VerticalAlignment="Center">Play</TextBlock>
|
||||
<ComboBox
|
||||
Grid.Column="2"
|
||||
ItemsSource="{Binding sound.items}"
|
||||
SelectedItem="{Binding sound.value}"
|
||||
ItemTemplate="{StaticResource EnumDescriptionTemplate}"
|
||||
/>
|
||||
</Grid>
|
||||
<!--<CheckBox Grid.Column="1" VerticalAlignment="Center" IsChecked="{Binding play_sound}">Play Sound</CheckBox>-->
|
||||
<!--<ComboBox
|
||||
Grid.Column="1"
|
||||
Visibility="{Binding play_sound, Converter={StaticResource FalseVisibilityConverter}}"
|
||||
Style="{StaticResource DisabledPlaceholderComboBox}"
|
||||
/>
|
||||
/>-->
|
||||
<Button
|
||||
Grid.Column="4"
|
||||
Grid.Column="2"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="2,0,0,0"
|
||||
Command="{x:Static c:SoundAnimationView.PreviewSoundCommand}"
|
||||
CommandParameter="{Binding sound.value}"
|
||||
Visibility="{Binding play_sound, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
Style="{StaticResource HelpButtonBaseStyle}"
|
||||
Style="{StaticResource RoundPlayButton}"
|
||||
ToolTip="{Binding sound.value, Converter={x:Static c:SoundAnimationView.LicenseInfoTextConverter}}"
|
||||
>
|
||||
<Button.CommandBindings>
|
||||
@@ -499,9 +515,9 @@
|
||||
</MouseBinding>
|
||||
</Button.InputBindings>
|
||||
</Button>
|
||||
<CheckBox Grid.Row="2" Grid.Column="1" IsEnabled="{Binding predicate.can_enable_toast_notifications}" IsChecked="{Binding predicate.toast_notifications_enabled}">
|
||||
<!--<CheckBox Grid.Row="2" Grid.Column="1" IsEnabled="{Binding predicate.can_enable_toast_notifications}" IsChecked="{Binding predicate.toast_notifications_enabled}">
|
||||
Show Notification
|
||||
</CheckBox>
|
||||
</CheckBox>-->
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
@@ -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<TRow, TValue2, TState2> filter2,
|
||||
Func<TCompoundState, TState2> get_filter2_state,
|
||||
Func<TState1, TState2, TCompoundState> 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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<object>;
|
||||
var new_collection = e.NewValue as ObservableCollection<object>;
|
||||
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<object>();
|
||||
Logger.assert(result is ObservableCollection<object>, "SelectedItems must (unfortunately) always be of type ObservableCollection<object>");
|
||||
Log.assert(result is ObservableCollection<object>, "SelectedItems must (unfortunately) always be of type ObservableCollection<object>");
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="4" />
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="4" />
|
||||
<RowDefinition Height="4" />
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -192,7 +192,7 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="1" VerticalAlignment="Center">Cross Thresh</TextBlock>
|
||||
<uag:QuantityMeasureControl Grid.Row="1" Grid.Column="2" QuantityMeasure="{Binding cross_threshold}"/>
|
||||
|
||||
|
||||
<TextBlock Grid.Row="3" VerticalAlignment="Center">Cross Ticks</TextBlock>
|
||||
<c:TickUpDownUInt Grid.Row="3" Grid.Column="2" Value="{Binding cross_ticks}"/>
|
||||
<TextBlock Grid.Row="5" VerticalAlignment="Center">Max Chase Ticks</TextBlock>
|
||||
@@ -210,7 +210,7 @@
|
||||
/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</usp:OrderModificationTemplateSelector.TickOrderTemplate>
|
||||
</usp:OrderModificationTemplateSelector.TickOrderTemplate>
|
||||
<usp:OrderModificationTemplateSelector.LeanOrderTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
@@ -243,7 +243,7 @@
|
||||
/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</usp:OrderModificationTemplateSelector.LeanOrderTemplate>
|
||||
</usp:OrderModificationTemplateSelector.LeanOrderTemplate>
|
||||
<usp:OrderModificationTemplateSelector.JoinOrderTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
@@ -260,7 +260,7 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="4" />
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="4" />
|
||||
<RowDefinition Height="4" />
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -269,9 +269,9 @@
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="1" VerticalAlignment="Center">Join Thresh</TextBlock>
|
||||
<uag:QuantityMeasureControl Grid.Row="1" Grid.Column="2" QuantityMeasure="{Binding join_threshold}"/>
|
||||
<uag:QuantityMeasureControl Grid.Row="1" Grid.Column="2" QuantityMeasure="{Binding join_threshold}"/>
|
||||
<CheckBox Grid.Row="3" Grid.Column="2" VerticalAlignment="Center" Margin="0,0,0,0" IsChecked="{Binding enable_hedge}">Enable Hedge</CheckBox>
|
||||
<TextBlock Grid.Row="5" VerticalAlignment="Center">Hedge Ticks</TextBlock>
|
||||
<TextBlock Grid.Row="5" VerticalAlignment="Center">Hedge Ticks</TextBlock>
|
||||
<c:TickUpDownInt Grid.Row="5" Grid.Column="2" Value="{Binding hedge_ticks}"/>
|
||||
<TextBlock Grid.Row="7">Hedge</TextBlock>
|
||||
<uag:OrderDetailsPopupControl
|
||||
@@ -281,7 +281,7 @@
|
||||
ItemsSource="{Binding hedge_order_types}"
|
||||
SelectedItem="{Binding hedge_order}"
|
||||
HasEditableProperties="{Binding hedge_order.has_editable_properties, FallbackValue=False}"
|
||||
/>
|
||||
/>
|
||||
<TextBlock Grid.Row="9" VerticalAlignment="Center">Initial Tick Offset</TextBlock>
|
||||
<c:TickUpDownUInt Grid.Row="9" Grid.Column="2" Value="{Binding tick_offset_on_deploy}"/>
|
||||
<TextBlock Grid.Row="11">Child</TextBlock>
|
||||
@@ -311,7 +311,7 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="4" />
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="4" />
|
||||
<RowDefinition Height="4" />
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -320,9 +320,9 @@
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="1" VerticalAlignment="Center">Top Thresh</TextBlock>
|
||||
<uag:QuantityMeasureControl Grid.Row="1" Grid.Column="2" QuantityMeasure="{Binding top_threshold}"/>
|
||||
<uag:QuantityMeasureControl Grid.Row="1" Grid.Column="2" QuantityMeasure="{Binding top_threshold}"/>
|
||||
<CheckBox Grid.Row="3" Grid.Column="2" VerticalAlignment="Center" Margin="0,0,0,0" IsChecked="{Binding enable_hedge}">Enable Hedge</CheckBox>
|
||||
<TextBlock Grid.Row="5" VerticalAlignment="Center" IsEnabled="{Binding enable_hedge}" >Hedge Ticks</TextBlock>
|
||||
<TextBlock Grid.Row="5" VerticalAlignment="Center" IsEnabled="{Binding enable_hedge}" >Hedge Ticks</TextBlock>
|
||||
<c:TickUpDownInt Grid.Row="5" Grid.Column="2" IsEnabled="{Binding enable_hedge}" Value="{Binding hedge_ticks}"/>
|
||||
<TextBlock Grid.Row="7">Hedge</TextBlock>
|
||||
<uag:OrderDetailsPopupControl
|
||||
@@ -332,7 +332,7 @@
|
||||
ItemsSource="{Binding hedge_order_types}"
|
||||
SelectedItem="{Binding hedge_order}"
|
||||
HasEditableProperties="{Binding hedge_order.has_editable_properties, FallbackValue=False}"
|
||||
/>
|
||||
/>
|
||||
<TextBlock Grid.Row="9" VerticalAlignment="Center">Watch Levels</TextBlock>
|
||||
<c:TickUpDownUInt Grid.Row="9" Grid.Column="2" Value="{Binding watch_level_tick_offset}"/>
|
||||
<TextBlock Grid.Row="11">Child</TextBlock>
|
||||
@@ -345,7 +345,7 @@
|
||||
/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</usp:OrderModificationTemplateSelector.TopOrderTemplate>
|
||||
</usp:OrderModificationTemplateSelector.TopOrderTemplate>
|
||||
<usp:OrderModificationTemplateSelector.CoverOrderTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
@@ -356,7 +356,7 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="4" />
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="4" />
|
||||
<RowDefinition Height="4" />
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -364,7 +364,7 @@
|
||||
<ColumnDefinition Width="12"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="1" VerticalAlignment="Center" IsEnabled="{Binding enable_hedge}" >Hedge Ticks</TextBlock>
|
||||
<TextBlock Grid.Row="1" VerticalAlignment="Center" IsEnabled="{Binding enable_hedge}" >Hedge Ticks</TextBlock>
|
||||
<c:TickUpDownInt Grid.Row="1" Grid.Column="2" IsEnabled="{Binding enable_hedge}" Value="{Binding hedge_ticks}"/>
|
||||
<TextBlock Grid.Row="3">Hedge</TextBlock>
|
||||
<uag:OrderDetailsPopupControl
|
||||
@@ -373,7 +373,7 @@
|
||||
ItemsSource="{Binding hedge_order_types}"
|
||||
SelectedItem="{Binding hedge_order}"
|
||||
HasEditableProperties="{Binding hedge_order.has_editable_properties, FallbackValue=False}"
|
||||
/>
|
||||
/>
|
||||
<TextBlock Grid.Row="5">Child</TextBlock>
|
||||
<uag:OrderDetailsPopupControl
|
||||
Grid.Row="5" Grid.Column="2"
|
||||
@@ -384,7 +384,7 @@
|
||||
/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</usp:OrderModificationTemplateSelector.CoverOrderTemplate>
|
||||
</usp:OrderModificationTemplateSelector.CoverOrderTemplate>
|
||||
<usp:OrderModificationTemplateSelector.TriggerOrderTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Grid.IsSharedSizeScope="True">
|
||||
@@ -397,14 +397,25 @@
|
||||
<RowDefinition Height="{Binding Source={StaticResource VerticalPush}}"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<GroupBox Header="Trigger Condition" HeaderTemplate="{StaticResource BoldHeaderTemplate}">
|
||||
<GroupBox>
|
||||
<GroupBox.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock FontWeight="Bold" Margin="0,0,4,0">Trigger Condition</TextBlock>
|
||||
</StackPanel>
|
||||
</GroupBox.Header>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition SharedSizeGroup="c0"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource HorizontalPush}}"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="1" VerticalAlignment="Center">Price Type</TextBlock>
|
||||
<StackPanel
|
||||
Orientation="Horizontal"
|
||||
Grid.Row="1"
|
||||
>
|
||||
<TextBlock VerticalAlignment="Center">Price Type</TextBlock>
|
||||
<c:HelpButton Margin="4,0,0,0" ToolTip="This is the side of the market that is observed for the trigger condition. When this market touches (or penetrates the trigger price), the child order is sent to the market." />
|
||||
</StackPanel>
|
||||
<ComboBox
|
||||
Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
@@ -412,9 +423,15 @@
|
||||
ItemTemplate="{StaticResource EnumDescriptionTemplate}"
|
||||
SelectedItem="{Binding trigger_price_type}"
|
||||
/>
|
||||
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<GroupBox Grid.Row="2" Header="Trigger Action" HeaderTemplate="{StaticResource BoldHeaderTemplate}">
|
||||
<GroupBox Grid.Row="2">
|
||||
<GroupBox.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock FontWeight="Bold" Margin="0,0,4,0">Trigger Action</TextBlock>
|
||||
</StackPanel>
|
||||
</GroupBox.Header>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition SharedSizeGroup="c0"/>
|
||||
@@ -426,9 +443,16 @@
|
||||
<RowDefinition Height="{Binding Source={StaticResource VerticalPush}}"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0">
|
||||
Child
|
||||
</TextBlock>
|
||||
|
||||
<StackPanel
|
||||
Orientation="Horizontal"
|
||||
Grid.Row="0"
|
||||
>
|
||||
<TextBlock VerticalAlignment="Center">
|
||||
Child
|
||||
</TextBlock>
|
||||
<c:HelpButton Margin="4,0,0,0" ToolTip="This is the type of the child order algo" />
|
||||
</StackPanel>
|
||||
<uag:OrderDetailsPopupControl
|
||||
Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
@@ -437,7 +461,13 @@
|
||||
SelectedItem="{Binding child_order}"
|
||||
HasEditableProperties="{Binding child_order.has_editable_properties, FallbackValue=False}"
|
||||
/>
|
||||
<GroupBox Grid.Row="2" Grid.ColumnSpan="3" Header="Price" HeaderTemplate="{StaticResource SemiBoldHeaderTemplate}">
|
||||
<GroupBox Grid.Row="2" Grid.ColumnSpan="3">
|
||||
<GroupBox.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock FontWeight="SemiBold" Margin="0,0,4,0">Price</TextBlock>
|
||||
<c:HelpButton ToolTip="The child order, resulting from the trigger condition being met, can be sent either at a specified price specified price (Fixed) price or payup/less ticks from the Trigger Price" />
|
||||
</StackPanel>
|
||||
</GroupBox.Header>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
@@ -472,7 +502,7 @@
|
||||
VerticalContentAlignment="Center"
|
||||
IsChecked="{Binding use_fixed_price, Converter={StaticResource NotConverter}, Mode=TwoWay}"
|
||||
>
|
||||
Payup/less
|
||||
Payup
|
||||
</RadioButton>
|
||||
<Grid Grid.Row="2" Grid.Column="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -501,7 +531,13 @@
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<GroupBox Grid.Row="4" Header="Trigger Exit" HeaderTemplate="{StaticResource BoldHeaderTemplate}">
|
||||
<GroupBox Grid.Row="4" >
|
||||
<GroupBox.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock FontWeight="Bold" Margin="0,0,4,0">Trigger Exit</TextBlock>
|
||||
<c:HelpButton ToolTip="The trigger order can be canceled after a specified amount of time (Timeout) or conditionally (Price Conditional) if the trigger condition ceases to hold." />
|
||||
</StackPanel>
|
||||
</GroupBox.Header>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition SharedSizeGroup="c0"/>
|
||||
@@ -524,7 +560,7 @@
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</usp:OrderModificationTemplateSelector.TriggerOrderTemplate>
|
||||
</usp:OrderModificationTemplateSelector.TriggerOrderTemplate>
|
||||
<usp:OrderModificationTemplateSelector.IcebergOrderTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
@@ -550,7 +586,7 @@
|
||||
/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</usp:OrderModificationTemplateSelector.IcebergOrderTemplate>
|
||||
</usp:OrderModificationTemplateSelector.IcebergOrderTemplate>
|
||||
<usp:OrderModificationTemplateSelector.SpreaderTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
@@ -606,7 +642,7 @@
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ItemsControl>
|
||||
<TextBlock Grid.Row="3">Child</TextBlock>
|
||||
<uag:OrderDetailsPopupControl
|
||||
Grid.Row="3" Grid.Column="2"
|
||||
@@ -617,7 +653,7 @@
|
||||
/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</usp:OrderModificationTemplateSelector.DynamicOrderTemplate>
|
||||
</usp:OrderModificationTemplateSelector.DynamicOrderTemplate>
|
||||
</usp:OrderModificationTemplateSelector>
|
||||
</c:PopupControl.ContentTemplateSelector>
|
||||
</c:PopupControl>
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
/// <summary>
|
||||
/// Interaction logic for DragDropDocumentPreview.xaml
|
||||
/// </summary>
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<FrameworkElement> visual_children_where(this FrameworkElement v, Func<FrameworkElement, bool> match) {
|
||||
@@ -235,7 +241,7 @@ namespace mbts.ui {
|
||||
}
|
||||
|
||||
public static IObservable<T> Observe<T>(this DependencyObject instance, DependencyProperty property) {
|
||||
Logger.assert(typeof(T) == instance.GetType());
|
||||
Log.assert(typeof(T) == instance.GetType());
|
||||
return Observable.Create<T>(observer => {
|
||||
return instance.ObserveProperty(property, (o, e) => {
|
||||
observer.OnNext((T)instance.GetValue(property));
|
||||
|
||||
@@ -281,6 +281,62 @@
|
||||
|
||||
</Style>
|
||||
|
||||
<!--PlayButtonRed/Blue are commented out bc they are not referenced anywhere.
|
||||
However, RoundPlayButton is a new style, and liable to change; these are good potential alternatives.
|
||||
<Color x:Key="PlayButtonRedColor">#DD4040</Color>
|
||||
<Color x:Key="PlayButtonBlueColor">#8E8EDD</Color>-->
|
||||
<Color x:Key="PlayButtonGreenColor">#40DD40</Color>
|
||||
<Color x:Key="PlayButtonGrayColor">#B8B8B8</Color>
|
||||
<!--<SolidColorBrush x:Key="PlayButtonRedBrush" Color="{StaticResource PlayButtonRedColor}"/>
|
||||
<SolidColorBrush x:Key="PlayButtonBlueBrush" Color="{StaticResource PlayButtonBlueColor}"/>-->
|
||||
<SolidColorBrush x:Key="PlayButtonGreenBrush" Color="{StaticResource PlayButtonGreenColor}"/>
|
||||
<SolidColorBrush x:Key="PlayButtonGrayBrush" Color="{StaticResource PlayButtonGrayColor}"/>
|
||||
<Style x:Key="RoundPlayButton" TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="{StaticResource PlayButtonGrayBrush}"/>
|
||||
<Setter Property="Padding" Value="5,4,4,4"/>
|
||||
<Setter Property="Width" Value="18" />
|
||||
<Setter Property="Height" Value="18" />
|
||||
<Setter Property="OverridesDefaultStyle" Value="True" />
|
||||
<Setter Property="Focusable" Value="False" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Grid Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
|
||||
<Ellipse HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Fill="{TemplateBinding Background}" x:Name="_el" />
|
||||
<Image Margin="{TemplateBinding Padding}" Stretch="Uniform">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Brush="White" Geometry="{x:Static mbts:Icons.PlayGeometry}"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Trigger.EnterActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<ColorAnimation Storyboard.TargetName="_el" Storyboard.TargetProperty="Fill.Color" To="{StaticResource PlayButtonGreenColor}" Duration="0:0:0.025"/>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</Trigger.EnterActions>
|
||||
<Trigger.ExitActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<ColorAnimation Storyboard.TargetName="_el" Storyboard.TargetProperty="Fill.Color" To="{StaticResource PlayButtonGrayColor}" Duration="0:0:0.1"/>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</Trigger.ExitActions>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="RoundCloseButton" TargetType="{x:Type Button}">
|
||||
<Setter Property="Width" Value="14" />
|
||||
<Setter Property="Height" Value="14" />
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using bts;
|
||||
using mbts.ui.native;
|
||||
|
||||
namespace mbts.ui {
|
||||
@@ -33,7 +34,7 @@ namespace mbts.ui {
|
||||
try {
|
||||
_execute_on_window(sender, action);
|
||||
} catch (Exception err) {
|
||||
Logger.log(bts.log.Level.Warn, bts.log.Subsystem.Ui, $"Exception {action_name} window : {err}");
|
||||
Log.Ui.warn($"Exception {action_name} window : {err}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,7 +196,7 @@ namespace mbts.ui {
|
||||
|
||||
private static void set_resize_window_events(FrameworkElement border, Window window) {
|
||||
HookWndProc(window);
|
||||
Logger.assert(border != null);
|
||||
Log.assert(border != null);
|
||||
var restore_on_move = false;
|
||||
border.MouseLeftButtonDown += (s, e) => {
|
||||
FrameworkElement fe = e.OriginalSource as FrameworkElement;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using bts.shell;
|
||||
using bts;
|
||||
using bts.shell;
|
||||
using mbts.ui.settings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -109,7 +110,7 @@ namespace mbts.ui.shell
|
||||
|
||||
// if is_loaded is true, will NOT set width/height
|
||||
public async void add_document(TabDocument document, int index, bool is_loaded=false) {
|
||||
Logger.assert(document.Parent == null);
|
||||
Log.assert(document.Parent == null);
|
||||
// Manually copy over the initial size if this is a new Window
|
||||
if (_tabs.Items.Count == 0 && !is_loaded)
|
||||
await _size_to_content(document);
|
||||
|
||||
@@ -15,6 +15,7 @@ using mbts.utils;
|
||||
using bts.co2;
|
||||
using bts.api.user;
|
||||
using bts.api.persistence;
|
||||
using bts;
|
||||
|
||||
namespace mbts.ui.shell
|
||||
{
|
||||
@@ -84,7 +85,7 @@ namespace mbts.ui.shell
|
||||
|
||||
// The final username
|
||||
public User get_user() {
|
||||
Logger.assert_d(!string.IsNullOrEmpty(_user.name));
|
||||
Log.assert_d(!string.IsNullOrEmpty(_user.name));
|
||||
return _user;
|
||||
}
|
||||
public string get_workspace() {
|
||||
@@ -151,8 +152,8 @@ namespace mbts.ui.shell
|
||||
}
|
||||
|
||||
private void set_authenticated_user(User user) {
|
||||
Logger.assert(!string.IsNullOrEmpty(user.name));
|
||||
Logger.assert(Users.Select(u => u.name).Contains(user.name));
|
||||
Log.assert(!string.IsNullOrEmpty(user.name));
|
||||
Log.assert(Users.Select(u => u.name).Contains(user.name));
|
||||
_user = user;
|
||||
Environment.SetEnvironmentVariable("BTS_USER", user.name);
|
||||
_frame.Continue = false;
|
||||
|
||||
@@ -3,13 +3,11 @@ using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using mbts.ui.native;
|
||||
using System.Windows.Threading;
|
||||
using bts;
|
||||
|
||||
namespace mbts.ui.shell
|
||||
{
|
||||
namespace mbts.ui.shell {
|
||||
public partial class LoginView : Window
|
||||
{
|
||||
public LoginView(LoginViewModel model) {
|
||||
@@ -62,7 +60,7 @@ namespace mbts.ui.shell
|
||||
}
|
||||
this.Activate();
|
||||
handled = true;
|
||||
Logger.log(bts.log.Level.Info, bts.log.Subsystem.Ui, "Login window brought to the foreground by attempt to re-launch the bts_shell.");
|
||||
Log.Ui.info("Login window brought to the foreground by attempt to re-launch the bts_shell.");
|
||||
}
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using bts.api;
|
||||
using bts;
|
||||
using bts.api;
|
||||
using bts.shell;
|
||||
using Google.Protobuf;
|
||||
using ProtoBuf;
|
||||
@@ -20,7 +21,7 @@ namespace mbts.ui.shell
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Logger.warn(bts.log.Subsystem.gen, "try_deserialize failed for type {0}: {1}".fmt(typeof(T).FullName, ex.Message));
|
||||
Log.Gen.warn("try_deserialize failed for type {0}: {1}".fmt(typeof(T).FullName, ex.Message));
|
||||
result = default(T);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using mbts.config;
|
||||
using bts.config;
|
||||
using bts.log;
|
||||
using bts;
|
||||
|
||||
namespace mbts.ui
|
||||
{
|
||||
@@ -65,7 +65,7 @@ namespace mbts.ui
|
||||
|
||||
private void PerformMEFComposition() {
|
||||
// Initialize MEF to populate Modules and windows
|
||||
Logger.log(Level.Info, Subsystem.Ui, "Beginning bts_shell module composition.");
|
||||
Log.Ui.info("Beginning bts_shell module composition.");
|
||||
|
||||
// Add specific instances
|
||||
Container.ComposeExportedValue<ShellModel>(this);
|
||||
@@ -78,10 +78,10 @@ namespace mbts.ui
|
||||
message.AppendLine("============================");
|
||||
message.AppendLine(e.ToString());
|
||||
}
|
||||
Logger.assert(false, message.ToString());
|
||||
Log.assert(false, message.ToString());
|
||||
}
|
||||
catch (CompositionException cex) {
|
||||
Logger.assert(false, cex.Message);
|
||||
Log.assert(false, cex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace mbts.ui
|
||||
|
||||
private void InitInitializers() {
|
||||
foreach (IInitializable i in _initializers.OrderBy(i => i.priority)) {
|
||||
Logger.log(Level.Info, Subsystem.Ui, "Initializing {0} prority {1}".fmt(i.GetType().ToString(), i.priority));
|
||||
Log.Ui.info("Initializing {0} prority {1}".fmt(i.GetType().ToString(), i.priority));
|
||||
i.initialize();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using bts;
|
||||
using mbts.ui.shell;
|
||||
|
||||
namespace mbts.ui
|
||||
@@ -44,7 +45,7 @@ namespace mbts.ui
|
||||
_undo();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Logger.log(bts.log.Level.Error, bts.log.Subsystem.Ui, "Failed to undo : {0} - {1}".fmt(Name, e.ToString()));
|
||||
Log.Ui.error("Failed to undo : {0} - {1}".fmt(Name, e.ToString()));
|
||||
throw;
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -1,26 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using mbts.config;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.native;
|
||||
using mbts.ui.utility;
|
||||
using bts.support;
|
||||
using bts.view.controls;
|
||||
using bts.api;
|
||||
using bts.spark;
|
||||
using bts;
|
||||
|
||||
namespace mbts.ui.shell
|
||||
{
|
||||
namespace mbts.ui.shell {
|
||||
[Export(typeof(ILauncher))]
|
||||
public class LauncherVM : ViewModelBase, ILauncher
|
||||
{
|
||||
@@ -108,7 +98,7 @@ namespace mbts.ui.shell
|
||||
}
|
||||
|
||||
public void set_position(WindowPosition pos) {
|
||||
Logger.assert(_window == null);
|
||||
Log.assert(_window == null);
|
||||
_window = new Launcher(this);
|
||||
|
||||
// WindowPosition
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using bts.config;
|
||||
using bts.log;
|
||||
using bts;
|
||||
using bts.config;
|
||||
using mbts.config;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
@@ -29,7 +29,7 @@ namespace mbts.ui.shell
|
||||
public ShellThreadFactory() { }
|
||||
|
||||
private UIThreadData get(string name) {
|
||||
Logger.assert(!string.IsNullOrEmpty(name));
|
||||
Log.assert(!string.IsNullOrEmpty(name));
|
||||
UIThreadData uid;
|
||||
if (_shared_threads.TryGetValue(name, out uid)) {
|
||||
return uid;
|
||||
@@ -43,11 +43,10 @@ namespace mbts.ui.shell
|
||||
Dispatcher.Run();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Logger.assert(false, e.ToString());
|
||||
Log.assert(false, e.ToString());
|
||||
}
|
||||
finally {
|
||||
Logger.log(bts.log.Level.Info, bts.log.Subsystem.Ui,
|
||||
"Disposing slow {0} and cleaning up background thread.".fmt(name));
|
||||
Log.Ui.info("Disposing slow {0} and cleaning up background thread.".fmt(name));
|
||||
UIThreadData unused;
|
||||
_shared_threads.TryRemove(name, out unused);
|
||||
Disposable.dispose(ref uid);
|
||||
@@ -82,7 +81,7 @@ namespace mbts.ui.shell
|
||||
return uid.dispatcher;
|
||||
}
|
||||
public void emergency_shutdown() {
|
||||
//Logger.assert(Configuration.get<bts.config.System>().unittest_environment);
|
||||
//Log.assert(Configuration.get<bts.config.System>().unittest_environment);
|
||||
var temp = _shared_threads.Values.ToList();
|
||||
_shared_threads.Clear();
|
||||
foreach (var uid in temp) {
|
||||
|
||||
@@ -13,6 +13,7 @@ using mbts.ui.settings;
|
||||
using System.Windows.Interop;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
using bts;
|
||||
|
||||
namespace mbts.ui.shell
|
||||
{
|
||||
@@ -26,7 +27,7 @@ namespace mbts.ui.shell
|
||||
|
||||
|
||||
public ShellWindowVM(IShellWindow model, IWindowManager wm, IShellThreadFactory threads, string host = "") {
|
||||
Logger.assert(model != null);
|
||||
Log.assert(model != null);
|
||||
_model = model;
|
||||
_model.TitleChanged += () => { if (!HasCustomTitle) RaisePropertyChanged("Title"); };
|
||||
_model.IconChanged += () => { _icon = null; RaisePropertyChanged("Icon"); };
|
||||
@@ -133,7 +134,7 @@ namespace mbts.ui.shell
|
||||
}
|
||||
catch (Exception e) {
|
||||
error_text = e.Message;
|
||||
Logger.log(bts.log.Level.Error, bts.log.Subsystem.Ui, "Error getting window contents. " + e.ToString());
|
||||
Log.Ui.error("Error getting window contents. " + e.ToString());
|
||||
}
|
||||
}, DispatcherPriority.Send);
|
||||
|
||||
@@ -153,7 +154,7 @@ namespace mbts.ui.shell
|
||||
RaisePropertyChanged("Title");
|
||||
}
|
||||
|
||||
Logger.assert(document != null);
|
||||
Log.assert(document != null);
|
||||
if (document.Content != null) {
|
||||
// WPF
|
||||
if (IsSlow || IsShared) {
|
||||
@@ -213,7 +214,7 @@ namespace mbts.ui.shell
|
||||
}
|
||||
else if (IsSlow) {
|
||||
// Terminating the background thread will dispose the model on that thread
|
||||
Logger.log(bts.log.Level.Info, bts.log.Subsystem.Ui, "Beginning asyncronous dispose of slow window {0} .".fmt(_model.GetType().ToString()));
|
||||
Log.Ui.info("Beginning asyncronous dispose of slow window {0} .".fmt(_model.GetType().ToString()));
|
||||
_dispatcher.BeginInvokeShutdown(DispatcherPriority.Background);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using bts.api;
|
||||
using bts;
|
||||
using bts.api;
|
||||
using mbts.spark;
|
||||
using mbts.ui.settings;
|
||||
using System;
|
||||
@@ -93,7 +94,7 @@ namespace mbts.ui.shell {
|
||||
public async Task add(IShellWindow window) {
|
||||
if (!Application.Current.Dispatcher.CheckAccess())
|
||||
await Application.Current.Dispatcher.InvokeAsync(() => add(window));
|
||||
Logger.info(bts.log.Subsystem.Ui, $"Opening window {window.diagnostic_name()}.");
|
||||
Log.Ui.info($"Opening window {window.diagnostic_name()}.");
|
||||
lock (_lock) {
|
||||
_documents[window] = _create_document(window);
|
||||
}
|
||||
@@ -162,7 +163,7 @@ namespace mbts.ui.shell {
|
||||
pos.custom_title = doc?.ViewModel?.TitleOverride;
|
||||
return pos;
|
||||
}
|
||||
Logger.log(bts.log.Level.Warn, bts.log.Subsystem.Ui, "IShellWindow '{0}' does not have a valid position. It may not be displayed".fmt(shell_window.Title));
|
||||
Log.Ui.warn("IShellWindow '{0}' does not have a valid position. It may not be displayed".fmt(shell_window.Title));
|
||||
return new WindowPosition();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ using mbts.ui.settings;
|
||||
using mbts.utils;
|
||||
using ProtoBuf;
|
||||
using mbts.persist;
|
||||
using bts;
|
||||
|
||||
namespace mbts.ui.shell
|
||||
{
|
||||
@@ -69,20 +70,20 @@ namespace mbts.ui.shell
|
||||
if (initial_workspace == ACTIVE_WORKSPACE_NAME) {
|
||||
var localws = load_local_workspace();
|
||||
if (localws != null) {
|
||||
Logger.log(bts.log.Level.Info, bts.log.Subsystem.Ui, "Loading workspace from disk");
|
||||
Log.Ui.info("Loading workspace from disk");
|
||||
await load_workspace(localws, position_shell: true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (to_load != null) {
|
||||
Logger.log(bts.log.Level.Info, bts.log.Subsystem.Ui, "Loading initial workspace '{0}'".fmt(to_load.key));
|
||||
Log.Ui.info("Loading initial workspace '{0}'".fmt(to_load.key));
|
||||
// Only load the launcher position if this is a private workspace
|
||||
await load_workspace(to_load.value, to_load.key, undo:false, position_shell: !to_load.value.is_shared);
|
||||
}
|
||||
else {
|
||||
// Show launcher at default position
|
||||
Logger.log(bts.log.Level.Info, bts.log.Subsystem.Ui, "Showing launcher without loading initial workspace.");
|
||||
Log.Ui.info("Showing launcher without loading initial workspace.");
|
||||
_launcher.set_position(null);
|
||||
}
|
||||
}
|
||||
@@ -104,7 +105,7 @@ namespace mbts.ui.shell
|
||||
_wm.clear();
|
||||
task.Wait(TimeSpan.FromSeconds(90));
|
||||
if (!task.IsCompleted) {
|
||||
Logger.log(bts.log.Level.Error, bts.log.Subsystem.Ui, "Failed to save workspace during UI shutdown");
|
||||
Log.Ui.error("Failed to save workspace during UI shutdown");
|
||||
// The server is gone! Save the state to the local disk.
|
||||
save_workspace_locally(workspace);
|
||||
}
|
||||
@@ -126,7 +127,7 @@ namespace mbts.ui.shell
|
||||
}
|
||||
}
|
||||
catch {
|
||||
Logger.log(bts.log.Level.Error, bts.log.Subsystem.Ui, "The settings server is gone and I can't write to disk either. Shell is not having a good day.");
|
||||
Log.Ui.error("The settings server is gone and I can't write to disk either. Shell is not having a good day.");
|
||||
}
|
||||
}
|
||||
private static WorkspaceDefinition load_local_workspace() {
|
||||
@@ -192,8 +193,9 @@ namespace mbts.ui.shell
|
||||
}
|
||||
|
||||
public async Task load_workspace(WorkspaceDefinition def, string name="", bool undo=true, bool position_shell=false) {
|
||||
Logger.assert(def != null);
|
||||
|
||||
Log.assert(def != null);
|
||||
Log.Ui.info("Loading workspace '{0}'".fmt(name));
|
||||
var sw = System.Diagnostics.Stopwatch.StartNew();
|
||||
if (undo && !string.IsNullOrEmpty(name)) {
|
||||
var current_workspace = await get_workspace_async();
|
||||
_undo.push("Undo Load workspace '{0}'".fmt(name), async () => {
|
||||
@@ -221,6 +223,7 @@ namespace mbts.ui.shell
|
||||
}
|
||||
if (def.windows != null) {
|
||||
foreach (var window in def.windows) {
|
||||
Log.Ui.info("Loading window '{0}'".fmt(window.title));
|
||||
var new_shell_window = await _window_restore.restore(window);
|
||||
// user can close the launcher from the taskbar while a workspace is loading
|
||||
if (_closing) {
|
||||
@@ -230,6 +233,8 @@ namespace mbts.ui.shell
|
||||
}
|
||||
}
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Ui.info($"Time to load workspace '{name}': {sw.Elapsed}");
|
||||
|
||||
_bookmarks.clear();
|
||||
if (def.named_windows != null) {
|
||||
@@ -245,7 +250,7 @@ namespace mbts.ui.shell
|
||||
public Task delete_workspace(string name, WorkspaceDefinition def) {
|
||||
var to_remove = Workspaces.SingleOrDefault(x => x.Name == name && x.IsShared == def.is_shared);
|
||||
if (to_remove != null) {
|
||||
Logger.assert_d(def == null || to_remove.Definition == def);
|
||||
Log.assert_d(def == null || to_remove.Definition == def);
|
||||
Workspaces.Remove(to_remove);
|
||||
_undo.push("Restore workspace: '{0}'".fmt(name), () => {
|
||||
Workspaces.Add(new WorkspaceViewModel(this, name, def));
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using bts.api;
|
||||
using bts;
|
||||
using bts.api;
|
||||
using bts.api.core;
|
||||
using bts.api.position;
|
||||
using mbts.collections.extensions;
|
||||
@@ -81,12 +82,13 @@ namespace mbts.spark {
|
||||
|
||||
public static void lazy_assert(bool test, Func<string> get_msg) {
|
||||
if (!test)
|
||||
Logger.assert(false, get_msg());
|
||||
Log.assert(false, get_msg());
|
||||
}
|
||||
|
||||
public static void lazy_warn(bool test, Func<string> get_msg, bts.log.Subsystem system = bts.log.Subsystem.Ui) {
|
||||
if (!test)
|
||||
Logger.warn(system, get_msg());
|
||||
public static void lazy_warn(bool test, Func<string> get_msg) {
|
||||
if (!test) {
|
||||
Log.Gen.warn(get_msg());
|
||||
}
|
||||
}
|
||||
|
||||
#region Extensions
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using bts.api;
|
||||
using bts;
|
||||
using bts.api;
|
||||
using bts.utils;
|
||||
using mbts.co2;
|
||||
using mbts.ui;
|
||||
@@ -425,7 +426,7 @@ namespace mbts.spark {
|
||||
LadderRender.render_last(_last_vis_tup.visual, _last_vis_tup.glyph_context, _last_trade, last_index, _settings.row_height, _settings.last_column);
|
||||
}
|
||||
if (depth_changed) {
|
||||
Logger.assert_d(_price_list != null);
|
||||
Log.assert_d(_price_list != null);
|
||||
int origin_index = LadderRender.index_of(_price_list, _mkt_break_lines.origin, _price_comparer);
|
||||
LadderRender.render_sizes(_bid_vis_tup.visual, _bid_vis_tup.glyph_context, origin_index, _price_list, _bids, _settings.row_height, security.ContractSpec, _settings.bid_column);
|
||||
LadderRender.render_sizes(_ask_vis_tup.visual, _ask_vis_tup.glyph_context, origin_index, _price_list, _asks, _settings.row_height, security.ContractSpec, _settings.ask_column);
|
||||
@@ -467,14 +468,14 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
void _refresh_sizes() {
|
||||
Logger.assert_d(_price_list != null);
|
||||
Log.assert_d(_price_list != null);
|
||||
int origin_index = LadderRender.index_of(_price_list, _mkt_break_lines.origin, _price_comparer);
|
||||
LadderRender.render_sizes(_bid_vis_tup.visual, _bid_vis_tup.glyph_context, origin_index, _price_list, _bids, _settings.row_height, security.ContractSpec, _settings.bid_column);
|
||||
LadderRender.render_sizes(_ask_vis_tup.visual, _ask_vis_tup.glyph_context, origin_index, _price_list, _asks, _settings.row_height, security.ContractSpec, _settings.ask_column);
|
||||
}
|
||||
|
||||
void _refresh_depth() {
|
||||
Logger.assert_d(_price_list != null);
|
||||
Log.assert_d(_price_list != null);
|
||||
int origin_index = LadderRender.index_of(_price_list, _mkt_break_lines.origin, _price_comparer);
|
||||
LadderRender.render_sizes(_bid_vis_tup.visual, _bid_vis_tup.glyph_context, origin_index, _price_list, _bids, _settings.row_height, security.ContractSpec, _settings.bid_column);
|
||||
LadderRender.render_sizes(_ask_vis_tup.visual, _ask_vis_tup.glyph_context, origin_index, _price_list, _asks, _settings.row_height, security.ContractSpec, _settings.ask_column);
|
||||
@@ -519,9 +520,9 @@ namespace mbts.spark {
|
||||
_row_count = Math.Min(_max_row_count, desired_row_count);
|
||||
if (_row_count != prev_row_count) {
|
||||
if (desired_row_count > _max_row_count)
|
||||
Logger.warn(bts.log.Subsystem.Ui, fmt_log_msg($"ticks between market range ({low} - {high}) exceeds the maximum number of rows allowed ({_max_row_count})"));
|
||||
Log.Ui.warn(fmt_log_msg($"ticks between market range ({low} - {high}) exceeds the maximum number of rows allowed ({_max_row_count})"));
|
||||
else
|
||||
Logger.info(bts.log.Subsystem.Ui, fmt_log_msg($"increase row count to {_row_count} to accomodate market range ({low} - {high})"));
|
||||
Log.Ui.info(fmt_log_msg($"increase row count to {_row_count} to accomodate market range ({low} - {high})"));
|
||||
prices_changed = true;
|
||||
_reset_height();
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using bts.api;
|
||||
using bts;
|
||||
using bts.api;
|
||||
using mbts.co2;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -24,7 +25,7 @@ namespace mbts.spark {
|
||||
case CancelType.Bids: return _order_gateway.cancel_security_buy_orders(security.Id);
|
||||
case CancelType.Asks: return _order_gateway.cancel_security_sell_orders(security.Id);
|
||||
}
|
||||
Logger.warn(bts.log.Subsystem.Ui, $"Well, this is odd, {nameof(LadderModel)} has encountered an unexpected {nameof(CancelType)} request: {ct}");
|
||||
Log.Ui.warn($"Well, this is odd, {nameof(LadderModel)} has encountered an unexpected {nameof(CancelType)} request: {ct}");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
//public void update(OrderRecordImmutable neworder) {
|
||||
// Logger.assert(neworder.Key == id, $"OrderVM.update was called with an order with a different Key({neworder.Key}) from original({id})");
|
||||
// Log.assert(neworder.Key == id, $"OrderVM.update was called with an order with a different Key({neworder.Key}) from original({id})");
|
||||
// using (detect_property_changes()) {
|
||||
// _init(neworder);
|
||||
// }
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using mbts.ui;
|
||||
using bts;
|
||||
using mbts.ui;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.extensions;
|
||||
using System;
|
||||
@@ -68,7 +69,7 @@ namespace mbts.spark {
|
||||
}
|
||||
}
|
||||
} //else
|
||||
//Logger.warn(bts.log.Subsystem.Ui, $"Failed to remove order ({order.id}): order not in {nameof(LadderOrdersHost)}'s {nameof(_orders)}.");
|
||||
//Log.Ui.warn($"Failed to remove order ({order.id}): order not in {nameof(LadderOrdersHost)}'s {nameof(_orders)}.");
|
||||
}
|
||||
|
||||
public void clear_orders() {
|
||||
@@ -95,7 +96,7 @@ namespace mbts.spark {
|
||||
panel.Children.Add(mkbadge(order));
|
||||
}
|
||||
} //else {
|
||||
//Logger.warn(bts.log.Subsystem.Ui, $"Failed to add order ({order.id}): order already in {nameof(LadderGridHost)}'s {nameof(_orders)}.");
|
||||
//Log.Ui.warn($"Failed to add order ({order.id}): order already in {nameof(LadderGridHost)}'s {nameof(_orders)}.");
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -125,7 +126,7 @@ namespace mbts.spark {
|
||||
b.ContextMenu.IsOpen = false;
|
||||
curr_order.command_executed -= command_executed;
|
||||
} catch (Exception ex) {
|
||||
Logger.warn(bts.log.Subsystem.Ui, $"Error in {typeof(LadderGridHost)}'s {typeof(Badge)} {nameof(LadderOrderVM.command_executed)} local handler: {ex}");
|
||||
Log.Ui.warn($"Error in {typeof(LadderGridHost)}'s {typeof(Badge)} {nameof(LadderOrderVM.command_executed)} local handler: {ex}");
|
||||
}
|
||||
};
|
||||
curr_order.command_executed += command_executed;
|
||||
@@ -171,7 +172,7 @@ namespace mbts.spark {
|
||||
if (e.Data.GetDataPresent(typeof(LadderOrderVM))) {
|
||||
LadderOrderVM vm = e.Data.GetData(typeof(LadderOrderVM)) as LadderOrderVM;
|
||||
if (vm != null && vm.security_key == security_key) {
|
||||
Logger.info(bts.log.Subsystem.Ui, "Drop - " + vm.summary);
|
||||
Log.Ui.info("Drop - " + vm.summary);
|
||||
double price = _parent.price_for_point(e.GetPosition(_parent));
|
||||
if (price != vm.price) {
|
||||
foreach (var order in vm.orders) {
|
||||
@@ -213,7 +214,7 @@ namespace mbts.spark {
|
||||
return CursorHelper.create_cursor(dv, sz);
|
||||
}
|
||||
|
||||
void _log(string msg) => Logger.diag(bts.log.Subsystem.Ui, $"{typeof(LadderGridHost)} {msg}");
|
||||
void _log(string msg) => Log.Ui.diag($"{typeof(LadderGridHost)} {msg}");
|
||||
|
||||
void _orders_MouseRightButtonDown(object sender, MouseButtonEventArgs e) {
|
||||
var pt = e.GetPosition(_orders_host);
|
||||
|
||||
@@ -7,6 +7,7 @@ using mbts.persist;
|
||||
using mbts.ui;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.utility;
|
||||
using mbts.utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -42,9 +43,9 @@ namespace mbts.spark {
|
||||
_change = backing(nameof(change), double.NaN);
|
||||
_open = backing(nameof(open), double.NaN);
|
||||
_settlement = backing(nameof(settlement), double.NaN);
|
||||
_position = backing(nameof(position), order_properties_vm.observe_account(true).Select(a => a.name)
|
||||
.SelectMany(a => _model.order_gateway.security_total_position(security.Id, a))
|
||||
.OnDispatcher());
|
||||
// remember: account_positions needs to subscribe to selected_account; both the sub and account_positions need to be disposed
|
||||
var account_positions = new KeyDrivenObservable<string, double>(a => _model.order_gateway.security_total_position(security.Id, a));
|
||||
_position = backing(nameof(position), account_positions.OnDispatcher());
|
||||
_volume = backing(nameof(volume), 0ul);
|
||||
_auto_clear = backing(nameof(auto_clear), false);
|
||||
_status = backing(nameof(status_message), "");
|
||||
@@ -77,6 +78,8 @@ namespace mbts.spark {
|
||||
_dispose = Disposable.Create(
|
||||
settings_command,
|
||||
order_properties_vm,
|
||||
order_properties_vm.observe_account(true).Select(a => a.name).Subscribe(account_positions),
|
||||
account_positions,
|
||||
size_calculator = new CalculatorLogic(0, _settings_manager.subscribe_current().Select(s => s.calculator_buttons)),
|
||||
bus.subscribe(SparkTags.LogActivity).OnDispatcher().Subscribe(status_update),
|
||||
model.order_gateway.working_orders.OnDispatcher().Subscribe(working => {
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
</converters:BooleanToObjectConverter.ValueForFalse>
|
||||
</converters:BooleanToObjectConverter>
|
||||
<converters:EnumCharacterCasingConverter x:Key="casing_converter"/>
|
||||
<converters:DoubleTextConverter x:Key="PositionTextConverter" Format="0" NaNText="-"/>
|
||||
<Style TargetType="GridViewColumnHeader">
|
||||
<Setter Property="Background" Value="{mbts:BTSColor header}"/>
|
||||
<Setter Property="Foreground" Value="{mbts:BTSColor header_text}"/>
|
||||
@@ -375,7 +376,7 @@
|
||||
<Button
|
||||
Margin="2"
|
||||
Command="{Binding position_click_command}"
|
||||
Content="{Binding position}"
|
||||
Content="{Binding position, Converter={StaticResource PositionTextConverter}}"
|
||||
FontWeight="Bold"
|
||||
Foreground="{Binding position, Converter={StaticResource NumericSignBrushConverter}}"
|
||||
>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using bts.api;
|
||||
using bts;
|
||||
using bts.api;
|
||||
using mbts.co2;
|
||||
using mbts.ui;
|
||||
using mbts.ui.controls;
|
||||
@@ -59,7 +60,7 @@ namespace mbts.spark {
|
||||
|
||||
public static double[] gen_prices(double mid, int row_count, ContractSpecificationImmutable spec) {
|
||||
// require odd number
|
||||
Logger.assert(row_count % 2 == 1);
|
||||
Log.assert(row_count % 2 == 1);
|
||||
var result = new double[row_count];
|
||||
int range = row_count / 2;
|
||||
int middle = row_count / 2;
|
||||
|
||||
@@ -22,8 +22,12 @@ namespace mbts.spark.utilities {
|
||||
// OrdersModel imports and exposes OrderFactory as a public property
|
||||
[Export(typeof(OrderFactory))]
|
||||
class OrderFactory : IDisposable {
|
||||
static readonly OrderMetadata _default_order_metadata = new OrderMetadata { KeyBinding = "", Color = BTSColors.pinkalicious };
|
||||
static readonly OrderMetadata _default_order_metadata = new OrderMetadata { KeyBinding = "", Color = BTSColors.bluealicious };
|
||||
static readonly CustomOrderDefinition.CustomOneofCase[]
|
||||
// The following standard types are not yet ready for production use:
|
||||
// CustomOrderDefinition.CustomOneofCase.Tick,
|
||||
// CustomOrderDefinition.CustomOneofCase.Top,
|
||||
// CustomOrderDefinition.CustomOneofCase.Dynamic,
|
||||
_standard_types = new[] {
|
||||
CustomOrderDefinition.CustomOneofCase.Market,
|
||||
CustomOrderDefinition.CustomOneofCase.Limit,
|
||||
@@ -31,20 +35,21 @@ namespace mbts.spark.utilities {
|
||||
CustomOrderDefinition.CustomOneofCase.StopLimit,
|
||||
CustomOrderDefinition.CustomOneofCase.Iceberg,
|
||||
CustomOrderDefinition.CustomOneofCase.TimeBox,
|
||||
CustomOrderDefinition.CustomOneofCase.Tick,
|
||||
CustomOrderDefinition.CustomOneofCase.Lean,
|
||||
CustomOrderDefinition.CustomOneofCase.Join,
|
||||
CustomOrderDefinition.CustomOneofCase.Top,
|
||||
CustomOrderDefinition.CustomOneofCase.Cover,
|
||||
CustomOrderDefinition.CustomOneofCase.Trigger,
|
||||
CustomOrderDefinition.CustomOneofCase.Dynamic,
|
||||
}, _spreader_types = new[] {
|
||||
},
|
||||
// The following spreader types are not yet ready for production use:
|
||||
// CustomOrderDefinition.CustomOneofCase.Dynamic,
|
||||
_spreader_types = new[] {
|
||||
CustomOrderDefinition.CustomOneofCase.Spreader,
|
||||
CustomOrderDefinition.CustomOneofCase.Iceberg,
|
||||
CustomOrderDefinition.CustomOneofCase.TimeBox,
|
||||
CustomOrderDefinition.CustomOneofCase.Trigger,
|
||||
CustomOrderDefinition.CustomOneofCase.Dynamic,
|
||||
};
|
||||
public static readonly CustomOrderDefinition.CustomOneofCase[] all_order_types = _standard_types.Union(_spreader_types).ToArray();
|
||||
|
||||
readonly AdminModel _admin_model;
|
||||
IDisposable _dispose;
|
||||
|
||||
@@ -249,8 +254,8 @@ namespace mbts.spark.utilities {
|
||||
case CustomOrderDefinition.CustomOneofCase.Lean: return new OrderMetadata { KeyBinding = "L", Color = BTSColors.Orders.lean_order };
|
||||
case CustomOrderDefinition.CustomOneofCase.Join: return new OrderMetadata { KeyBinding = "J", Color = BTSColors.Orders.join_order };
|
||||
case CustomOrderDefinition.CustomOneofCase.Top: return new OrderMetadata { KeyBinding = "D", Color = BTSColors.Orders.top_order };
|
||||
case CustomOrderDefinition.CustomOneofCase.Cover: return new OrderMetadata { KeyBinding = "C", Color = BTSColors.Orders.top_order };
|
||||
case CustomOrderDefinition.CustomOneofCase.Trigger: return new OrderMetadata { KeyBinding = "T", Color = BTSColors.Orders.top_order };
|
||||
case CustomOrderDefinition.CustomOneofCase.Cover: return new OrderMetadata { KeyBinding = "C", Color = BTSColors.Orders.cover_order };
|
||||
case CustomOrderDefinition.CustomOneofCase.Trigger: return new OrderMetadata { KeyBinding = "T", Color = BTSColors.Orders.trigger_order };
|
||||
case CustomOrderDefinition.CustomOneofCase.Spreader: goto default;
|
||||
case CustomOrderDefinition.CustomOneofCase.Dynamic: return new OrderMetadata { KeyBinding = "", Color = BTSColors.Orders.top_order };
|
||||
case CustomOrderDefinition.CustomOneofCase.None: goto default;
|
||||
@@ -269,8 +274,8 @@ namespace mbts.spark.utilities {
|
||||
case OrderState.CustomOneofCase.Lean: return new OrderMetadata { KeyBinding = "L", Color = BTSColors.Orders.lean_order };
|
||||
case OrderState.CustomOneofCase.Join: return new OrderMetadata { KeyBinding = "J", Color = BTSColors.Orders.join_order };
|
||||
case OrderState.CustomOneofCase.Top: return new OrderMetadata { KeyBinding = "D", Color = BTSColors.Orders.top_order };
|
||||
case OrderState.CustomOneofCase.Cover: return new OrderMetadata { KeyBinding = "C", Color = BTSColors.Orders.top_order };
|
||||
case OrderState.CustomOneofCase.Trigger: return new OrderMetadata { KeyBinding = "T", Color = BTSColors.Orders.top_order };
|
||||
case OrderState.CustomOneofCase.Cover: return new OrderMetadata { KeyBinding = "C", Color = BTSColors.Orders.cover_order };
|
||||
case OrderState.CustomOneofCase.Trigger: return new OrderMetadata { KeyBinding = "T", Color = BTSColors.Orders.trigger_order };
|
||||
case OrderState.CustomOneofCase.Spreader: goto default;
|
||||
case OrderState.CustomOneofCase.Dynamic: return new OrderMetadata { KeyBinding = "T", Color = BTSColors.Orders.top_order };
|
||||
case OrderState.CustomOneofCase.None: goto default;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using mbts.utils;
|
||||
using bts;
|
||||
using mbts.utils;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Threading;
|
||||
@@ -64,7 +65,7 @@ namespace mbts.spark {
|
||||
stop_watch.Stop();
|
||||
var cycle_ms = (stop_watch.Elapsed - elapsed_total).TotalMilliseconds;
|
||||
if (cycle_ms > excessive_cycle_ms)
|
||||
Logger.warn(bts.log.Subsystem.Ui, $"{name} DispatcherTimer took {cycle_ms}ms to complete {sample_cycle_size} cycles.");
|
||||
Log.Ui.warn($"{name} DispatcherTimer took {cycle_ms}ms to complete {sample_cycle_size} cycles, target rate is 1 per {interval.Milliseconds}ms.");
|
||||
elapsed_total = stop_watch.Elapsed;
|
||||
}
|
||||
work();
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media.Imaging;
|
||||
using bts;
|
||||
using mbts.config;
|
||||
using mbts.ui.native;
|
||||
|
||||
@@ -25,7 +26,7 @@ namespace mbts.ui.utility
|
||||
}
|
||||
|
||||
public static Stream capture_encoded(string format, int width, int height) {
|
||||
Logger.log(bts.log.Level.Info, bts.log.Subsystem.Ui, "Capturing screenshot ({0})".fmt(format));
|
||||
Log.Ui.info("Capturing screenshot ({0})".fmt(format));
|
||||
|
||||
BitmapEncoder encoder = get_encoder(format);
|
||||
BitmapSource bmp;
|
||||
|
||||
@@ -252,6 +252,7 @@ namespace bts.api.core {
|
||||
cache = null;
|
||||
}
|
||||
if (update != null) {
|
||||
Log.Api.diag($"Naggle- {update}");
|
||||
observer.OnNext(update);
|
||||
}
|
||||
if (finished) {
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace bts {
|
||||
enum Level {
|
||||
Diag,
|
||||
Info,
|
||||
Warn,
|
||||
Error,
|
||||
Fatal,
|
||||
Sys
|
||||
}
|
||||
|
||||
enum Subsystem {
|
||||
gen,
|
||||
Config,
|
||||
QBus,
|
||||
Log,
|
||||
Jetfix,
|
||||
md,
|
||||
Api,
|
||||
Persist,
|
||||
User,
|
||||
OrderMan,
|
||||
Assert,
|
||||
Engine,
|
||||
Ui,
|
||||
ExSim,
|
||||
Mercury,
|
||||
Testing
|
||||
// Please keep this list in sync with logging.h/logging.cpp
|
||||
}
|
||||
readonly struct Logger {
|
||||
readonly Subsystem _sys;
|
||||
public Logger(Subsystem sys) {
|
||||
_sys = sys;
|
||||
}
|
||||
|
||||
public void diag(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) {
|
||||
Logger_log(Level.Diag, _sys, message, file, line);
|
||||
}
|
||||
public void info(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) {
|
||||
Logger_log(Level.Info, _sys, message, file, line);
|
||||
}
|
||||
public void warn(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) {
|
||||
Logger_log(Level.Warn, _sys, message, file, line);
|
||||
}
|
||||
public void error(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) {
|
||||
Logger_log(Level.Error, _sys, message, file, line);
|
||||
}
|
||||
public void fatal(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) {
|
||||
Logger_log(Level.Fatal, _sys, message, file, line);
|
||||
}
|
||||
|
||||
[DllImport("libspark")]
|
||||
static extern void Logger_log (Level level, Subsystem subsystem, string message, string file, int line);
|
||||
}
|
||||
|
||||
static class Log {
|
||||
public static Logger Gen => new Logger(Subsystem.gen);
|
||||
public static Logger Config => new Logger(Subsystem.Config);
|
||||
public static Logger QBus => new Logger(Subsystem.QBus);
|
||||
public static Logger Md => new Logger(Subsystem.md);
|
||||
public static Logger Api => new Logger(Subsystem.Api);
|
||||
public static Logger Persist => new Logger(Subsystem.Persist);
|
||||
public static Logger User => new Logger(Subsystem.User);
|
||||
public static Logger OrderMan => new Logger(Subsystem.OrderMan);
|
||||
public static Logger Assert => new Logger(Subsystem.Assert);
|
||||
public static Logger Ui => new Logger(Subsystem.Ui);
|
||||
public static Logger Testing => new Logger(Subsystem.Testing);
|
||||
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
public static void assert_d(bool test, string message = "", [CallerFilePath] string file = "assert", [CallerLineNumber] int line = 0) {
|
||||
assert(test, message, file, line);
|
||||
}
|
||||
|
||||
public static void assert(bool test, string message = "", [CallerFilePath] string file = "assert", [CallerLineNumber] int line = 0) {
|
||||
if (!test) {
|
||||
Assert.fatal(message, file, line);
|
||||
Debug.Assert(test, message);
|
||||
if (Debugger.IsAttached) {
|
||||
Debugger.Break();
|
||||
}
|
||||
system_is_crashing($"Fatal Assert: {message} at {file}:{line}", new StackTrace());
|
||||
Environment.Exit(-1);
|
||||
}
|
||||
}
|
||||
public static void notnull<T>(T o) where T : class {
|
||||
assert(o != null);
|
||||
}
|
||||
public static void isnull<T>(T o) where T : class {
|
||||
assert(o == null);
|
||||
}
|
||||
delegate void on_crash_callback([MarshalAs(UnmanagedType.LPStr)]string msg, [MarshalAs(UnmanagedType.LPStr)] string details);
|
||||
public static void system_is_crashing(string message, object details) {
|
||||
OnSystemCrashing?.Invoke(message, details);
|
||||
}
|
||||
public static event Action<string, object> OnSystemCrashing;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using bts.api;
|
||||
using bts;
|
||||
|
||||
namespace mbts.co2
|
||||
{
|
||||
@@ -14,11 +15,11 @@ namespace mbts.co2
|
||||
IntPtr _relay;
|
||||
public Co2RelayControl(MDConsumer consumer) {
|
||||
_consumer = consumer;
|
||||
Logger.assert(consumer.native_pointer() != IntPtr.Zero);
|
||||
Log.assert(consumer.native_pointer() != IntPtr.Zero);
|
||||
_relay =
|
||||
Co2NativeMethods.start_private_relay(consumer.native_pointer(),
|
||||
config.Configuration.get<bts.md.RelayOptions>().naggle_ms);
|
||||
Logger.assert(_relay != IntPtr.Zero);
|
||||
Log.assert(_relay != IntPtr.Zero);
|
||||
}
|
||||
|
||||
public async Task preload_securities(MDRequest.Types.Flags flags=MDRequest.Types.Flags.Security) {
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using security_key = System.UInt32;
|
||||
using bts.api;
|
||||
using bts;
|
||||
|
||||
namespace mbts.co2
|
||||
{
|
||||
@@ -112,15 +113,15 @@ namespace mbts.co2
|
||||
|
||||
if (has_depth) {
|
||||
_hot_depth = (HotDepthEntry*)tuple.hot.ToPointer();
|
||||
Logger.assert(_hot_depth->key == _cold->security_key);
|
||||
Log.assert(_hot_depth->key == _cold->security_key);
|
||||
}
|
||||
else {
|
||||
_hot = (HotEntry*)tuple.hot.ToPointer();
|
||||
Logger.assert(_hot->key == _cold->security_key);
|
||||
Log.assert(_hot->key == _cold->security_key);
|
||||
}
|
||||
Logger.assert(_header != null);
|
||||
Logger.assert(_cold != null);
|
||||
Logger.assert(_hot != null || _hot_depth != null);
|
||||
Log.assert(_header != null);
|
||||
Log.assert(_cold != null);
|
||||
Log.assert(_hot != null || _hot_depth != null);
|
||||
}
|
||||
|
||||
private HotEntry* _hot;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using bts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -56,7 +57,7 @@ namespace mbts.co2
|
||||
|
||||
public static double pow10(int power) {
|
||||
int offset = power + s_max_abs_pow10;
|
||||
Logger.assert_d(offset >= 0 && offset < s_powers10.Length);
|
||||
Log.assert_d(offset >= 0 && offset < s_powers10.Length);
|
||||
if (offset >= 0 && offset < s_powers10.Length) {
|
||||
return s_powers10[offset];
|
||||
}
|
||||
|
||||
@@ -5,96 +5,13 @@ using System.Net.Mail;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using bts.log;
|
||||
using mbts.config;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace bts.log {
|
||||
public enum Level {
|
||||
Diag,
|
||||
Info,
|
||||
Warn,
|
||||
Error,
|
||||
Fatal,
|
||||
Sys
|
||||
}
|
||||
|
||||
public enum Subsystem {
|
||||
gen,
|
||||
Config,
|
||||
QBus,
|
||||
Log,
|
||||
Jetfix,
|
||||
md,
|
||||
Api,
|
||||
Persist,
|
||||
User,
|
||||
OrderMan,
|
||||
Assert,
|
||||
Engine,
|
||||
Ui,
|
||||
ExSim,
|
||||
Mercury,
|
||||
Testing
|
||||
// Please keep this list in sync with logging.h/logging.cpp
|
||||
}
|
||||
}
|
||||
|
||||
namespace mbts
|
||||
{
|
||||
public static class Logger
|
||||
{
|
||||
static Logger() {
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
// Sometimes when debugging you just want a quick, temporary, log message - use this. Don't forget to remove it.
|
||||
public static void log(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) {
|
||||
log(Level.Info, Subsystem.gen, message, file, line);
|
||||
}
|
||||
|
||||
public static void log(Level level, Subsystem system, string message, [CallerFilePath] string file = "c#", [CallerLineNumber] int line = 0)
|
||||
{
|
||||
Logger_log(level, system, message, file, line);
|
||||
}
|
||||
|
||||
public static void error(Subsystem system, string message, [CallerFilePath] string file = "C#", [CallerLineNumber] int line = 0) {
|
||||
log(Level.Error, system, message, file, line);
|
||||
}
|
||||
public static void warn(Subsystem system, string message, [CallerFilePath] string file = "C#", [CallerLineNumber] int line = 0) {
|
||||
log(Level.Warn, system, message, file, line);
|
||||
}
|
||||
public static void info(Subsystem system, string message, [CallerFilePath] string file = "C#", [CallerLineNumber] int line = 0) {
|
||||
log(Level.Info, system, message, file, line);
|
||||
}
|
||||
public static void diag(Subsystem system, string message, [CallerFilePath] string file = "C#", [CallerLineNumber] int line = 0) {
|
||||
log(Level.Diag, system, message, file, line);
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
public static void assert_d(bool test, string message = "", [CallerFilePath] string file = "assert", [CallerLineNumber] int line = 0) {
|
||||
assert(test, message, file, line);
|
||||
}
|
||||
|
||||
public static void assert(bool test, string message = "", [CallerFilePath] string file = "assert", [CallerLineNumber] int line = 0) {
|
||||
if (!test) {
|
||||
log(Level.Fatal, Subsystem.Assert, message, file, line);
|
||||
Debug.Assert(test, message);
|
||||
if (Debugger.IsAttached) {
|
||||
Debugger.Break();
|
||||
}
|
||||
system_is_crashing($"Fatal Assert: {message} at {file}:{line}", new StackTrace());
|
||||
Environment.Exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void notnull<T>(T o) where T : class {
|
||||
assert(o != null);
|
||||
}
|
||||
public static void isnull<T>(T o) where T : class {
|
||||
assert(o == null);
|
||||
}
|
||||
|
||||
public static class LogUtil {
|
||||
public static string read_logs() {
|
||||
var log_path = Path.Combine(Configuration.get<bts.config.System>().data_path, "logging", "log");
|
||||
if (File.Exists(log_path)) {
|
||||
@@ -111,13 +28,5 @@ namespace mbts
|
||||
return "Log file does not exist";
|
||||
}
|
||||
|
||||
[DllImport("libspark")]
|
||||
private static extern void Logger_log (Level level, Subsystem subsystem, string message, string file, int line);
|
||||
|
||||
delegate void on_crash_callback([MarshalAs(UnmanagedType.LPStr)]string msg, [MarshalAs(UnmanagedType.LPStr)] string details);
|
||||
public static void system_is_crashing(string message, object details) {
|
||||
OnSystemCrashing?.Invoke(message, details);
|
||||
}
|
||||
public static event Action<string, object> OnSystemCrashing;
|
||||
}
|
||||
}
|
||||
@@ -4,18 +4,18 @@
|
||||
<name>Blue Trading Systems</name>
|
||||
</customer>
|
||||
<period>
|
||||
<since>2017-04-24</since>
|
||||
<till>2018-08-29</till>
|
||||
<since>2018-08-30</since>
|
||||
<till>2019-10-16</till>
|
||||
</period>
|
||||
<dotNetProducts>
|
||||
<product id="41" name="FIX Analyser" />
|
||||
</dotNetProducts>
|
||||
<dotNetCheckSum>jqN4XONnMeiDSJIAa6CK9m9SitquhMq3MhJW97fG26Fp+GPog9ObMLS2elPvippdZsRWmJGsjTmFxAg8d41Vr+tpNgObi3VT3DtfYjGESTmi+u4vvJ9PNi8tQWQ7HPYBJe1X6j84ijhe5e1jHEcaXZ08ExDbESebn2ndHb4Phv4=</dotNetCheckSum>
|
||||
<dotNetCheckSum>6O68+aAtrLqRaXxY9hLigajhC2ZunVeIev3NbyEXFjHk61WFrNmRTjy6tEduDtFUvGXvS6VUW3VXASaMTLrRgYteZBzfp7+dFTfVIVbzv6cn7c7dnSxWCGO5zPrjXw9cxMXlFz9cshyue6U/DRR5J36ThOhgt2kpY/OP9cgXWJo=</dotNetCheckSum>
|
||||
<products>
|
||||
<product id="1" name="OnixS FIX Engine for C++" />
|
||||
<product id="4" name="CME Market Data Handler for C++" />
|
||||
<product id="7" name="ICE iMpact Multicast Price Feed Handler for C++" />
|
||||
<product id="13" name="NYSE ArcaBook Multicast for Equities Handler for C++" />
|
||||
</products>
|
||||
<checksum>F5502F3BD9CE954022ABCBF94A7E4052</checksum>
|
||||
<checksum>18F98ED1E0A87B4B11DA322403D7BDDD</checksum>
|
||||
</license>
|
||||
@@ -320,21 +320,7 @@ void AdminServiceUtils::validate_account_exchange_data (
|
||||
result.set_error_text("CME account can not be more "
|
||||
"12 characters long");
|
||||
}
|
||||
if(cme_account_data.clearing_account() != account.name()){
|
||||
result.set_is_success(false);
|
||||
result.set_error_text("Clearing account name has to "
|
||||
"match the account name");
|
||||
}
|
||||
}
|
||||
if (account.exchange_account_data().has_sim_account_data()){
|
||||
const bts::api::admin::SIMAccountData& sim_account_data =
|
||||
account.exchange_account_data().sim_account_data();
|
||||
if(sim_account_data.clearing_account() != account.name()){
|
||||
result.set_is_success(false);
|
||||
result.set_error_text("Clearing account name has to "
|
||||
"match the account name");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bts::api::orderman::RoutingRecord AdminServiceUtils::get_routing_record(const bts::api::admin::AdminData& data,
|
||||
|
||||
@@ -202,7 +202,8 @@ message Fill {
|
||||
double last_shares = 6;
|
||||
string fill_key = 7 [(bts.api.key)=true];
|
||||
google.protobuf.Timestamp timestamp = 8;
|
||||
|
||||
uint32 internal_account_id = 11;
|
||||
|
||||
enum FillKind {
|
||||
FILL_KIND_STANDARD = 0;
|
||||
FILL_KIND_LEG = 1;
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
DynamicOrderList {
|
||||
value {
|
||||
dynamic_orders
|
||||
{
|
||||
type_name: 'DynamicOrder1'
|
||||
parameter_keys: 'param1'
|
||||
parameter_keys: 'param2'
|
||||
}
|
||||
# dynamic_orders
|
||||
# {
|
||||
# type_name: 'DynamicOrder1'
|
||||
# parameter_keys: 'param1'
|
||||
# parameter_keys: 'param2'
|
||||
# }
|
||||
# dynamic_orders
|
||||
# {
|
||||
# type_name: 'DynamicOrder2'
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
FillsSoftCleanupCutoff {
|
||||
value {
|
||||
sod_hh: 21
|
||||
sod_mm: 30
|
||||
}
|
||||
}
|
||||
|
||||
OrdersSoftCleanupCutoff {
|
||||
value {
|
||||
extra_days: 1
|
||||
sod_hh: 21
|
||||
sod_mm: 30
|
||||
}
|
||||
}
|
||||
@@ -55,4 +55,5 @@ message LadderKnobs {
|
||||
optional double interval_ms = 2 [default = 100];
|
||||
optional uint32 seconds_to_recenter = 3 [default = 300];
|
||||
optional uint32 max_open_ladders = 4 [default = 75];
|
||||
optional uint32 security_timeout_secs = 5 [default = 60];
|
||||
}
|
||||
@@ -1,17 +1,8 @@
|
||||
syntax='proto2';
|
||||
package bts.config;
|
||||
|
||||
message FillsSoftCleanupCutoff{
|
||||
// utc time
|
||||
optional uint32 sod_hh = 20 [default=21];
|
||||
optional uint32 sod_mm = 30 [default=30];
|
||||
}
|
||||
|
||||
message OrdersSoftCleanupCutoff{
|
||||
optional uint32 extra_days = 10 [default=1];
|
||||
// utc time
|
||||
optional uint32 sod_hh = 20 [default=21];
|
||||
optional uint32 sod_mm = 30 [default=30];
|
||||
}
|
||||
|
||||
message SODTime{
|
||||
|
||||
@@ -12,10 +12,6 @@ message LaddersOnThreads {
|
||||
optional bool enabled = 1 [default = true];
|
||||
}
|
||||
|
||||
message CVOrderBook {
|
||||
optional bool enabled = 1 [default = true];
|
||||
}
|
||||
|
||||
message FilterOrdersWithDanglingSecurities {
|
||||
optional bool enabled = 1 [default = true];
|
||||
}
|
||||
@@ -27,3 +23,7 @@ message FillsSoftCleanup{
|
||||
message OrdersSoftCleanup{
|
||||
optional bool enabled = 1 [default = true];
|
||||
}
|
||||
|
||||
message ToastNotifications {
|
||||
optional bool enabled = 1 [default = false];
|
||||
}
|
||||
Loaded 100 of 143 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user