fix build: Update protobuf namespaces in c#
This commit is contained in:
1 parent
103892e65a
commit
b169bedbb2
47 files changed
+173
-63
No files matched your search
@@ -1,7 +1,7 @@
|
||||
#nullable enable
|
||||
|
||||
namespace mbts.spark {
|
||||
using bts.api.domain;
|
||||
using bts.domain.protobufs;
|
||||
|
||||
using mbts.analytics;
|
||||
using mbts.ui.shell;
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace bts.ui {
|
||||
enable_crash_on_dblclick(about);
|
||||
if (about != null) {
|
||||
about.DataContext = new {
|
||||
Version = Configuration.get<bts.config.SystemConfig>().Version,
|
||||
Version = Configuration.get<system.protobufs.SystemConfig>().Version,
|
||||
User = _user
|
||||
};
|
||||
about.Topmost = true;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace bts.spark {
|
||||
void handle_unclean_shutdown(ErrorReporter e, int oldpid) {
|
||||
string extra = "";
|
||||
try {
|
||||
var conf = mbts.config.Configuration.get<bts.config.SystemConfig>();
|
||||
var conf = mbts.config.Configuration.get<system.protobufs.SystemConfig>();
|
||||
extra = JsonConvert.SerializeObject(conf, Formatting.Indented);
|
||||
} catch { }
|
||||
Task.Run(() => e.report_silently(
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace bts.perf {
|
||||
[ImportingConstructor]
|
||||
public ShellLatencyDaemon(ShellLatencyService service, Lazy<UserTuple> user) {
|
||||
_service = service;
|
||||
_version = Configuration.get<bts.config.SystemConfig>().Version;
|
||||
_version = Configuration.get<system.protobufs.SystemConfig>().Version;
|
||||
_username = user.Value.name;
|
||||
_hostname = Environment.MachineName;
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace bts.perf {
|
||||
|
||||
async void _forever_ping_host(Ping pinger) {
|
||||
var config = Configuration.get<bts.config.ShellPingOptions>();
|
||||
string server_ip = Configuration.get<bts.config.SystemConfig>().ConfigIp;
|
||||
string server_ip = Configuration.get<system.protobufs.SystemConfig>().ConfigIp;
|
||||
int delay = config.WorkloopMillisecondsInterval;
|
||||
int _current_missed_ping_count = 0;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace bts.shell {
|
||||
}
|
||||
}
|
||||
bool check_version() {
|
||||
string current = Configuration.get<bts.config.SystemConfig>().Version;
|
||||
string current = Configuration.get<system.protobufs.SystemConfig>().Version;
|
||||
if (!string.IsNullOrWhiteSpace(current) && current != "private") {
|
||||
using (var key = Registry.CurrentUser.CreateSubKey(@"Software\BTS")) {
|
||||
var value = key.GetValue("version");
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
namespace mbts.spark {
|
||||
using bts.api;
|
||||
using bts.api.core;
|
||||
using bts.api.domain;
|
||||
using bts.api.orderman;
|
||||
using bts.api.position;
|
||||
using bts.collections;
|
||||
using bts.domain.protobufs;
|
||||
using bts.utils;
|
||||
|
||||
using mbts.analytics;
|
||||
@@ -31,8 +31,6 @@
|
||||
using System.Reactive.Linq;
|
||||
using System.Windows.Input;
|
||||
|
||||
using TickFactors = bts.api.domain.TickFactorsImmutable;
|
||||
|
||||
partial class MarketViewVM {
|
||||
public class Row : DisposableViewModelBase, IEquatable<Row>, DIYGrid.IRowVM, DIYGrid.IActionableRowVM {
|
||||
readonly IBus _bus;
|
||||
@@ -486,7 +484,7 @@
|
||||
OrderDataHelper.CompareUtils.ask_price_comparer,
|
||||
OrderDataHelper.CompareUtils.order_record_id_eq_comparer);
|
||||
|
||||
readonly TickFactors _tick_factors;
|
||||
readonly TickFactorsImmutable _tick_factors;
|
||||
|
||||
double _best_bid_working_qty;
|
||||
double _best_ask_working_qty;
|
||||
@@ -494,7 +492,7 @@
|
||||
double _working_bid_qty;
|
||||
double _working_ask_qty;
|
||||
|
||||
public MyOrderSummarizer(TickFactors tick_factors) =>
|
||||
public MyOrderSummarizer(TickFactorsImmutable tick_factors) =>
|
||||
_tick_factors = tick_factors;
|
||||
|
||||
// bid
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#nullable enable
|
||||
namespace bts.shell.time_and_sales {
|
||||
using bts.co2;
|
||||
using bts.domain.protobufs;
|
||||
using bts.utils;
|
||||
|
||||
using mbts.spark.filters;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace bts.shell.time_and_sales {
|
||||
using bts.api;
|
||||
using bts.api.domain;
|
||||
using bts.co2;
|
||||
using bts.domain.protobufs;
|
||||
using bts.utils;
|
||||
|
||||
using mbts;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
namespace bts.shell.time_and_sales {
|
||||
using bts.api;
|
||||
using bts.co2;
|
||||
using bts.collections;
|
||||
using bts.domain.protobufs;
|
||||
using bts.utils;
|
||||
|
||||
using mbts;
|
||||
@@ -14,7 +13,6 @@
|
||||
using mbts.ui.settings;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.utility;
|
||||
using mbts.user.settings;
|
||||
using mbts.utils;
|
||||
|
||||
using Spark.Core;
|
||||
@@ -141,13 +139,13 @@
|
||||
static string fmt_time(TimeAndSalesRowVM row) => row.time.ToString("h:mm:ss.ffffff");
|
||||
static string fmt_price(TimeAndSalesRowVM row) => row.security.spec_or_default().format(row.price);
|
||||
static string fmt_aggressor(TimeAndSalesRowVM row) => row.aggressor_side.ToString();
|
||||
static string fmt_volume(TimeAndSalesRowVM row) => new TickFactors(1, 100).format(row.volume);
|
||||
static string fmt_vol(TimeAndSalesRowVM row) => new TickFactors(1, 100).format(row.display_vol);
|
||||
static string fmt_volume(TimeAndSalesRowVM row) => new mbts.user.settings.TickFactors(1, 100).format(row.volume);
|
||||
static string fmt_vol(TimeAndSalesRowVM row) => new mbts.user.settings.TickFactors(1, 100).format(row.display_vol);
|
||||
static string fmt_driver(TimeAndSalesRowVM row) => row.security.spec_or_default().format(row.driver);
|
||||
static string fmt_theo(TimeAndSalesRowVM row) => row.security.spec_or_default().format(row.theo);
|
||||
static string fmt_buy_edge(TimeAndSalesRowVM row) => row.security.spec_or_default().format(row.buy_edge);
|
||||
static string fmt_sell_edge(TimeAndSalesRowVM row) => row.security.spec_or_default().format(row.sell_edge);
|
||||
static string fmt_delta(TimeAndSalesRowVM row) => new TickFactors(1, 100).format(row.display_delta);
|
||||
static string fmt_delta(TimeAndSalesRowVM row) => new mbts.user.settings.TickFactors(1, 100).format(row.display_delta);
|
||||
static string fmt_sec_key(TimeAndSalesRowVM row) => row.security_key.ToString();
|
||||
|
||||
void add_col(
|
||||
|
||||
@@ -44,8 +44,8 @@ namespace bts.shell {
|
||||
string uristr = uri.ToString();
|
||||
string http_base =
|
||||
"http://{0}:{1}/".fmt(
|
||||
Configuration.get<bts.config.SystemConfig>().ConfigHost,
|
||||
Configuration.get<bts.config.SystemConfig>().ConfigPort);
|
||||
Configuration.get<system.protobufs.SystemConfig>().ConfigHost,
|
||||
Configuration.get<system.protobufs.SystemConfig>().ConfigPort);
|
||||
string temp = uristr;
|
||||
if (uristr.StartsWith("bts://m/")) {
|
||||
temp = uristr.Replace("bts://m/", http_base + "docs/");
|
||||
@@ -94,7 +94,7 @@ namespace bts.shell {
|
||||
emulation_key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(ke_name);
|
||||
}
|
||||
|
||||
var process_name = Configuration.get<bts.config.SystemConfig>().ProcessName;
|
||||
var process_name = Configuration.get<system.protobufs.SystemConfig>().ProcessName;
|
||||
emulation_key.SetValue(process_name, 11001); // IE11
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -73,8 +73,8 @@ namespace Spark.Trading {
|
||||
public double pos_theta => trade.pos_theta;
|
||||
public double pos_oev => trade.pos_oev;
|
||||
|
||||
public bts.api.domain.TickDisplaySettingsImmutable price_display(
|
||||
bts.api.domain.SecurityMetadataItemImmutable? meta = null) {
|
||||
public bts.domain.protobufs.TickDisplaySettingsImmutable price_display(
|
||||
bts.domain.protobufs.SecurityMetadataItemImmutable? meta = null) {
|
||||
var rv = meta.HasValue && meta.Value.HasValue && meta.Value.Value.HasPriceDisplay ?
|
||||
meta.Value.Value.PriceDisplay : Security.Defaults.price_display_settingsi;
|
||||
if (security.HasValue) {
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Spark.Trading {
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using TickDisplaySettingsImmutable = bts.api.domain.TickDisplaySettingsImmutable;
|
||||
using TickDisplaySettingsImmutable = bts.domain.protobufs.TickDisplaySettingsImmutable;
|
||||
|
||||
class DayFillsRowVM : DisposableViewModelBase, DIYGrid.IRowVM, IEquatable<DayFillsRowVM> {
|
||||
// guarentees deterministic sorting if the rows in the collection have unique row_keys
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#nullable enable
|
||||
namespace mbts.spark {
|
||||
using bts.api;
|
||||
using bts.api.domain;
|
||||
using bts.api.orderman;
|
||||
using bts.domain.protobufs;
|
||||
using bts.spark;
|
||||
using bts.utils;
|
||||
|
||||
|
||||
@@ -402,7 +402,7 @@ namespace mbts.spark {
|
||||
|
||||
int _row_count => _price_list?.Count ?? 0;
|
||||
|
||||
bts.api.domain.TickDisplaySettingsImmutable _qty_display =>
|
||||
bts.domain.protobufs.TickDisplaySettingsImmutable _qty_display =>
|
||||
_vm is null ?
|
||||
Security.Defaults.quantity_display_settingsi :
|
||||
_vm.model.security_md.quantity_display;
|
||||
|
||||
@@ -15,7 +15,7 @@ using System.Reactive.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using TickDisplaySettingsImmutable = bts.api.domain.TickDisplaySettingsImmutable;
|
||||
using TickDisplaySettingsImmutable = bts.domain.protobufs.TickDisplaySettingsImmutable;
|
||||
|
||||
namespace bts.shell.manual_fills {
|
||||
class ManualFillRow : DisposableViewModelBase, ISelectable, IEquatable<ManualFillRow> {
|
||||
|
||||
@@ -67,8 +67,8 @@ namespace Spark.Trading {
|
||||
}
|
||||
}
|
||||
|
||||
public bts.api.domain.TickDisplaySettingsImmutable price_display(
|
||||
bts.api.domain.SecurityMetadataItemImmutable? meta = null) {
|
||||
public bts.domain.protobufs.TickDisplaySettingsImmutable price_display(
|
||||
bts.domain.protobufs.SecurityMetadataItemImmutable? meta = null) {
|
||||
var rv = meta.HasValue && meta.Value.HasValue && meta.Value.Value.HasPriceDisplay ?
|
||||
meta.Value.Value.PriceDisplay : Security.Defaults.price_display_settingsi;
|
||||
if (security.HasValue) {
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Spark.Trading {
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using TickDisplaySettingsImmutable = bts.api.domain.TickDisplaySettingsImmutable;
|
||||
using TickDisplaySettingsImmutable = bts.domain.protobufs.TickDisplaySettingsImmutable;
|
||||
|
||||
class OpenOrdersRowVM : DisposableViewModelBase, DIYGrid.IRowVM, IEquatable<OpenOrdersRowVM> {
|
||||
// guarentees deterministic sorting if the rows in the collection have unique row_keys
|
||||
|
||||
@@ -1255,7 +1255,7 @@ namespace mbts.spark {
|
||||
TickUpDownNullableDouble.ValueProperty, nameof(OrderBookRowVM.prospective_quantity));
|
||||
tick_up_down.SetBinding(
|
||||
TickUpDownNullableDouble.IncrementProperty, new Binding(nameof(OrderBookRowVM.quantity_display_settings)) {
|
||||
Converter = ValueConverter.create<bts.api.domain.TickDisplaySettingsImmutable, double>(
|
||||
Converter = ValueConverter.create<bts.domain.protobufs.TickDisplaySettingsImmutable, double>(
|
||||
t => t.HasTickFactors ? t.TickFactors.to_tick_factors().tick_unit_frac() : 1D)
|
||||
});
|
||||
tick_up_down.InputBindings.Add(_create_keyinput_binding(Key.Enter, nameof(OrderBookRowVM.modify_order_cmd)));
|
||||
|
||||
@@ -21,7 +21,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
using Columns = mbts.spark.OrderBookGridView.ColumnKeys;
|
||||
using TickDisplaySettingsImmutable = bts.api.domain.TickDisplaySettingsImmutable;
|
||||
using TickDisplaySettingsImmutable = bts.domain.protobufs.TickDisplaySettingsImmutable;
|
||||
|
||||
namespace mbts.spark {
|
||||
partial class OrderBookRowVM : IEquatable<OrderBookRowVM>, DIYGrid.IRowVM, IHierarchicalRow<OrderRecordTupleWithRoot>, INotifyPropertyChanged {
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace mbts.spark {
|
||||
using System.Windows.Input;
|
||||
|
||||
using CompositeDisposable = System.Reactive.Disposables.CompositeDisposable;
|
||||
using TickDisplaySettingsImmutable = bts.api.domain.TickDisplaySettingsImmutable;
|
||||
using TickDisplaySettingsImmutable = bts.domain.protobufs.TickDisplaySettingsImmutable;
|
||||
|
||||
class OrderParamsVM : DisposableViewModelBase {
|
||||
readonly OrdersModel _model;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using bts.api.domain;
|
||||
using bts.domain.protobufs;
|
||||
using bts.utils;
|
||||
|
||||
using mbts.spark;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace bts.shell.pnl {
|
||||
readonly ISecurityMetadataStore _sec_meta_store;
|
||||
bool _refresh_normalized_data = true, _is_selected;
|
||||
PNLNormalizedData _normalized_data;
|
||||
api.domain.TickDisplaySettingsImmutable? _quantity_display_backing;
|
||||
domain.protobufs.TickDisplaySettingsImmutable? _quantity_display_backing;
|
||||
|
||||
public PNLRowVM(
|
||||
PNLRowData data,
|
||||
@@ -291,7 +291,7 @@ namespace bts.shell.pnl {
|
||||
public PNLCellVM<PNLRowData, double> pnl_price { get; }
|
||||
|
||||
// display
|
||||
public api.domain.TickDisplaySettingsImmutable quantity_display {
|
||||
public domain.protobufs.TickDisplaySettingsImmutable quantity_display {
|
||||
get {
|
||||
if (_quantity_display_backing.HasValue) {
|
||||
return _quantity_display_backing.Value;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
namespace Spark.Trading {
|
||||
using bts;
|
||||
using bts.api;
|
||||
using bts.api.domain;
|
||||
using bts.api.orderman;
|
||||
using bts.api.position;
|
||||
using bts.domain.protobufs;
|
||||
using bts.utils;
|
||||
|
||||
using mbts;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Spark.Trading {
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using TickDisplaySettingsImmutable = bts.api.domain.TickDisplaySettingsImmutable;
|
||||
using TickDisplaySettingsImmutable = bts.domain.protobufs.TickDisplaySettingsImmutable;
|
||||
|
||||
class ReconcileReportRowVM : DisposableViewModelBase, DIYGrid.IRowVM, IEquatable<ReconcileReportRowVM> {
|
||||
// key comparer guarentees deterministic sorting
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace BCG
|
||||
}
|
||||
|
||||
private readonly bool _is_remoted =
|
||||
mbts.config.Configuration.get<bts.config.SystemConfig>().IsRemoteApp;
|
||||
mbts.config.Configuration.get<bts.system.protobufs.SystemConfig>().IsRemoteApp;
|
||||
|
||||
[Category("Grid Lines")]
|
||||
[DisplayName("Row Seperator Line Color")]
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace BCG {
|
||||
}
|
||||
|
||||
private readonly bool _is_remoted =
|
||||
mbts.config.Configuration.get<bts.config.SystemConfig>().IsRemoteApp;
|
||||
mbts.config.Configuration.get<bts.system.protobufs.SystemConfig>().IsRemoteApp;
|
||||
private readonly PerfStatsLogger _recorder = new PerfStatsLogger();
|
||||
private System.ComponentModel.Container components = null;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using bts.api;
|
||||
using bts.api.domain;
|
||||
using bts.api.orderman;
|
||||
using bts.domain.protobufs;
|
||||
using bts.spark;
|
||||
using bts.utils;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using bts;
|
||||
using bts.api;
|
||||
using bts.api.domain;
|
||||
using bts.api.orderman;
|
||||
using bts.domain.protobufs;
|
||||
|
||||
using mbts.ui;
|
||||
using mbts.ui.shell;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using bts;
|
||||
using bts.api;
|
||||
using bts.api.domain;
|
||||
using bts.api.orderman;
|
||||
using bts.domain.protobufs;
|
||||
|
||||
using mbts.ui;
|
||||
using mbts.ui.shell;
|
||||
|
||||
@@ -20,7 +20,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using OrderPair = System.ValueTuple<bts.api.SecurityImmutable?, bts.api.orderman.OrderRecordImmutable>;
|
||||
using TickDisplaySettingsImmutable = bts.api.domain.TickDisplaySettingsImmutable;
|
||||
using TickDisplaySettingsImmutable = bts.domain.protobufs.TickDisplaySettingsImmutable;
|
||||
|
||||
namespace bts.spark {
|
||||
internal class Activity {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using bts.api;
|
||||
using bts.api.domain;
|
||||
using bts.api.orderman;
|
||||
using bts.domain.protobufs;
|
||||
|
||||
using mbts.ui.shell;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using bts;
|
||||
using bts.api;
|
||||
using bts.api.domain;
|
||||
using bts.api.orderman;
|
||||
using bts.domain.protobufs;
|
||||
using bts.spark;
|
||||
|
||||
using mbts.ui;
|
||||
@@ -65,8 +65,8 @@ namespace mbts.spark {
|
||||
OrderRecordImmutable order,
|
||||
double? new_price = null,
|
||||
double? new_quantity = null,
|
||||
bts.api.domain.TickDisplaySettingsImmutable? price_display = null,
|
||||
bts.api.domain.TickDisplaySettingsImmutable? quantity_display = null) =>
|
||||
bts.domain.protobufs.TickDisplaySettingsImmutable? price_display = null,
|
||||
bts.domain.protobufs.TickDisplaySettingsImmutable? quantity_display = null) =>
|
||||
OrdersExtensions.update_description(
|
||||
order, new_price, new_quantity, price_display, quantity_display);
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace mbts.analytics {
|
||||
}
|
||||
}
|
||||
|
||||
public bts.api.domain.TickDisplaySettingsImmutable tick_display_settings { get; }
|
||||
public bts.domain.protobufs.TickDisplaySettingsImmutable tick_display_settings { get; }
|
||||
|
||||
public bool show_commas {
|
||||
get => top_selected_greek?.result?.show_commas ?? false;
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace mbts.analytics {
|
||||
}
|
||||
}
|
||||
|
||||
public bts.api.domain.TickDisplaySettingsImmutable tick_display_settings { get; }
|
||||
public bts.domain.protobufs.TickDisplaySettingsImmutable tick_display_settings { get; }
|
||||
|
||||
public PriceDisplayFactors result => _result.Value;
|
||||
|
||||
|
||||
@@ -547,7 +547,7 @@ namespace mbts.analytics {
|
||||
}
|
||||
|
||||
public static HashSet<bts.api.SecurityTuple> get_sec_tups(
|
||||
bts.api.domain.SecurityCriteriaImmutable sc) {
|
||||
bts.domain.protobufs.SecurityCriteriaImmutable sc) {
|
||||
var rv = new HashSet<bts.api.SecurityTuple>();
|
||||
foreach (var c in sc.Clauses)
|
||||
foreach (var s in c.Symbols)
|
||||
|
||||
@@ -202,7 +202,7 @@ namespace mbts.ui.native {
|
||||
private static extern bool SetWorkArea_SystemParametersInfo(SPI action, uint zero, Win32Rect param, uint winini);
|
||||
|
||||
public static void SetWorkArea(Rect workarea) {
|
||||
var dpi_ratio = config.Configuration.get<bts.config.SystemConfig>().DpiRatio;
|
||||
var dpi_ratio = config.Configuration.get<bts.system.protobufs.SystemConfig>().DpiRatio;
|
||||
workarea = new Rect(workarea.Left * dpi_ratio, workarea.Top * dpi_ratio, (workarea.Right - workarea.Left) * dpi_ratio, (workarea.Bottom - workarea.Top) * dpi_ratio);
|
||||
//const uint SPIF_SENDWININICHANGE = 2;
|
||||
const uint SPIF_UPDATEINIFILE = 1;
|
||||
@@ -220,7 +220,7 @@ namespace mbts.ui.native {
|
||||
// Get the work area for monitor where the specified window is currently.
|
||||
// The work area is the area of the window not covered by the task bar or a docked shell
|
||||
public static Rect GetWorkArea(IntPtr window) {
|
||||
var dpi_ratio = config.Configuration.get<bts.config.SystemConfig>().DpiRatio;
|
||||
var dpi_ratio = config.Configuration.get<bts.system.protobufs.SystemConfig>().DpiRatio;
|
||||
IntPtr monitor = MonitorFromWindow(window, MONITOR_DEFAULTONNEAREST);
|
||||
MONITORINFO info = new MONITORINFO();
|
||||
info.cbSize = Marshal.SizeOf(info);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#nullable enable
|
||||
namespace mbts.ui.controls {
|
||||
using bts.api.domain;
|
||||
using bts.domain.protobufs;
|
||||
using bts.utils;
|
||||
|
||||
using System;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#nullable enable
|
||||
namespace mbts.ui.controls {
|
||||
using bts.api.domain;
|
||||
using bts.domain.protobufs;
|
||||
using bts.utils;
|
||||
|
||||
using mbts.ui.extensions;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace mbts.ui.converters {
|
||||
}
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) {
|
||||
var price = get_val<double>(values, 0);
|
||||
if (values.Length == 2 && values[1] is bts.api.domain.TickDisplaySettingsImmutable tdsi) {
|
||||
if (values.Length == 2 && values[1] is bts.domain.protobufs.TickDisplaySettingsImmutable tdsi) {
|
||||
return tdsi.to_tick_display_settings().format(price);
|
||||
}
|
||||
var spec = get_val<ContractSpecificationImmutable?>(values, 1);
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace mbts.ui.dpi {
|
||||
public static readonly float fdpi_ratio;
|
||||
|
||||
static HighDpiExtensions() {
|
||||
dpi_ratio = Configuration.get<bts.config.SystemConfig>().DpiRatio;
|
||||
dpi_ratio = Configuration.get<bts.system.protobufs.SystemConfig>().DpiRatio;
|
||||
pixel_unit = 1.0 / dpi_ratio;
|
||||
fdpi_ratio = (float)dpi_ratio;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
namespace mbts.ui;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Media;
|
||||
|
||||
[MarkupExtensionReturnType(typeof(Brush))]
|
||||
public class BrushBlendExtension : MarkupExtension {
|
||||
public BrushBlendExtension() { }
|
||||
|
||||
public BrushBlendExtension(string Expression) =>
|
||||
this.Expression = Expression;
|
||||
|
||||
[ConstructorArgument(nameof(Expression))]
|
||||
public string Expression { get; set; }
|
||||
|
||||
public override object ProvideValue(IServiceProvider serviceProvider) {
|
||||
if (string.IsNullOrEmpty(Expression)) {
|
||||
throw new InvalidOperationException("Expression is null/empty");
|
||||
}
|
||||
var parts = Expression.Split("+").Select(parseWeightedColor).ToList();
|
||||
var totalWeight = parts.Select(p => p.Weight * (double)p.Color.A / byte.MaxValue).Sum();
|
||||
var blend = parts.Aggregate(Colors.Transparent, (b, p) => {
|
||||
var weightPct = (double)p.Weight / totalWeight;
|
||||
var weightedAlpha = (byte)(p.Color.A * weightPct);
|
||||
var rv = b.blend(p.Color.with(alpha: weightedAlpha));
|
||||
var tmp = b.blend(p.Color.with(alpha: weightedAlpha));
|
||||
return rv;
|
||||
});
|
||||
return new SolidColorBrush(blend);
|
||||
|
||||
static (Color Color, int Weight) parseWeightedColor(string term) {
|
||||
var parts = term?.Split('*') ?? Array.Empty<string>();
|
||||
return parts.Length switch {
|
||||
1 => (get_core_color(parts[0]), 1),
|
||||
2 => (get_core_color(parts[1]), int.Parse(parts[0])),
|
||||
_ => (Colors.Transparent, 0),
|
||||
};
|
||||
}
|
||||
|
||||
static Color get_core_color(string name) {
|
||||
if (string.IsNullOrEmpty(name)) return Colors.Black;
|
||||
string ln = name.ToLower();
|
||||
foreach (var tup in DefinedColors.known_colors.Value) {
|
||||
if (tup.Item1.ToLower() == ln) {
|
||||
return tup.Item2;
|
||||
}
|
||||
}
|
||||
foreach (var tup in DefinedColors.known_btscolors.Value) {
|
||||
if (tup.Item1.ToLower() == ln) {
|
||||
return tup.Item2;
|
||||
}
|
||||
}
|
||||
return BTSColorExtension.get_color(name) ?? Colors.Black;
|
||||
}
|
||||
// static Color get_core_color(string name) {
|
||||
// if (string.IsNullOrEmpty(name)) {
|
||||
// return Colors.Black;
|
||||
// }
|
||||
// return DefinedColors.known_colors.Value.Concat(DefinedColors.known_btscolors.Value)
|
||||
// .FirstOrDefault(tup => string.Equals(tup.Item1, name, StringComparison.CurrentCultureIgnoreCase))
|
||||
// ?.Item2
|
||||
// ?? Colors.Black;
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
namespace mbts.ui;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Media;
|
||||
|
||||
[MarkupExtensionReturnType(typeof(Color))]
|
||||
public class ColorBlendExtension : MarkupExtension {
|
||||
public ColorBlendExtension() { }
|
||||
|
||||
public ColorBlendExtension(string Expression) =>
|
||||
this.Expression = Expression;
|
||||
|
||||
[ConstructorArgument(nameof(Expression))]
|
||||
public string Expression { get; set; }
|
||||
|
||||
public override object ProvideValue(IServiceProvider serviceProvider) {
|
||||
if (string.IsNullOrEmpty(Expression)) {
|
||||
throw new InvalidOperationException("Expression is null/empty");
|
||||
}
|
||||
var parts = Expression.Split("+").Select(parseWeightedColor);
|
||||
var totalWeight = parts.Select(p => p.Weight).Sum();
|
||||
var blend = parts.Aggregate(Colors.Transparent, (b, p) =>
|
||||
b.blend(p.Color.with(alpha: (byte)((double)(p.Weight / totalWeight) * byte.MaxValue))));
|
||||
return blend;
|
||||
|
||||
static (Color Color, int Weight) parseWeightedColor(string term) {
|
||||
var parts = term?.Split('*') ?? Array.Empty<string>();
|
||||
return parts.Length switch {
|
||||
1 => (get_core_color(parts[0]), 1),
|
||||
2 => (get_core_color(parts[1]), int.Parse(parts[0])),
|
||||
_ => (Colors.Transparent, 0),
|
||||
};
|
||||
}
|
||||
|
||||
static Color get_core_color(string name) {
|
||||
if (string.IsNullOrEmpty(name)) {
|
||||
return Colors.Black;
|
||||
}
|
||||
return DefinedColors.known_colors.Value.Concat(DefinedColors.known_btscolors.Value)
|
||||
.FirstOrDefault(tup => string.Equals(tup.Item1, name, StringComparison.CurrentCultureIgnoreCase))
|
||||
?.Item2
|
||||
?? Colors.Black;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@
|
||||
.WithParts(types)
|
||||
.WithDefaultConventions(rules);
|
||||
|
||||
string plugin_path = Configuration.get<bts.config.SystemConfig>().DataPath + "/plugins/";
|
||||
string plugin_path = Configuration.get<bts.system.protobufs.SystemConfig>().DataPath + "/plugins/";
|
||||
if (Directory.Exists(plugin_path)) {
|
||||
var assemblies = Directory.GetFiles(plugin_path, "*.dll")
|
||||
.Select(AssemblyLoadContext.Default.LoadFromAssemblyPath);
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace mbts.ui.shell {
|
||||
#region Static local save methods
|
||||
|
||||
private static string local_workspace_path() {
|
||||
var system = Configuration.get<bts.config.SystemConfig>();
|
||||
var system = Configuration.get<bts.system.protobufs.SystemConfig>();
|
||||
return @"{0}/{1}/{2}".fmt(system.DataPath, WORKSPACE_NAMESPACE, "recover_workspace");
|
||||
}
|
||||
private static void save_workspace_locally(WorkspaceDefinition workspace) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace mbts.spark {
|
||||
using bts.api;
|
||||
using bts.api.domain;
|
||||
using bts.domain.protobufs;
|
||||
using bts.utils;
|
||||
|
||||
using mbts.ui;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using bts.api;
|
||||
using bts.api.domain;
|
||||
using bts.domain.protobufs;
|
||||
using bts.utils;
|
||||
|
||||
using mbts.co2;
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace mbts.ui.utility {
|
||||
}
|
||||
|
||||
static Int32Rect screen_size() {
|
||||
var config = Configuration.get<bts.config.SystemConfig>();
|
||||
var config = Configuration.get<bts.system.protobufs.SystemConfig>();
|
||||
var dpi = config.DpiRatio;
|
||||
return new Int32Rect(
|
||||
(int)(SystemParameters.VirtualScreenLeft * dpi),
|
||||
|
||||
Reference in new issue
Block a user