diff --git a/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml b/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml
index 6055d5bfe..0094ac79f 100644
--- a/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml
+++ b/src/client/spark/Modules/Spreader/ExecutionStrategyEditor.xaml
@@ -14,6 +14,7 @@
+
285
16
@@ -365,20 +366,11 @@
Grid.Column="2" VerticalAlignment="Center" Margin="6,0,0,0" Text="Ticks" IsEnabled="{TemplateBinding IsNew}"
Visibility="{Binding LegTuples.Count, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource IntNotZeroVisibilityConverter}}"
/>
-
-
-
-
-
-
-
-
-
-
+ />
Pricing
GetValue(TickFactorsProperty) as TickFactors; set => SetValue(TickFactorsProperty, value); }
#endregion
- #region AvailableTickFactors
- public static readonly DependencyProperty AvailableTickFactorsProperty = DependencyProperty.Register(
- nameof(AvailableTickFactors), typeof(IEnumerable), typeof(ExecutionStrategyEditor), new PropertyMetadata(new TickFactors[0]));
-
- public IEnumerable AvailableTickFactors { get => GetValue(AvailableTickFactorsProperty) as IEnumerable; set => SetValue(AvailableTickFactorsProperty, value); }
- #endregion
-
#region IsNew
public static readonly DependencyProperty IsNewProperty =
DependencyProperty.Register(
@@ -253,11 +246,11 @@ namespace mbts.ui.spark {
class ExecutionStrategyErrorAdorner : NotifyDataErrorAdorner, IDisposable {
readonly ChildProperty _name_text_box;
- readonly ChildProperty _tick_combo_box;
+ readonly ChildProperty _tick_factors_picker;
public ExecutionStrategyErrorAdorner(ExecutionStrategyEditor editor) : base(editor) {
_name_text_box = child_property("PART_Name_TextBox");
- _tick_combo_box = child_property("PART_Tick_ComboBox");
+ _tick_factors_picker = child_property("PART_TickFactorsPicker");
}
protected override void OnRender(DrawingContext drawing_context) {
@@ -269,7 +262,7 @@ namespace mbts.ui.spark {
if (_vm != null && _vm.GetErrors(nameof(SyntheticEditorVM.name)).Cast().Any())
this.draw_border(drawing_context, _name_text_box.value, null, new Pen(Brushes.Red, 1));
if (_vm != null && _vm.GetErrors(nameof(SyntheticEditorVM.tick_factors)).Cast().Any())
- this.draw_border(drawing_context, _tick_combo_box.value, null, new Pen(Brushes.Red, 1));
+ this.draw_border(drawing_context, _tick_factors_picker.value, null, new Pen(Brushes.Red, 1));
string error_text = string.Join(", ", _vm.AllErrors);
this.draw_relative_text(RelativePosition.Below, error_text, drawing_context, _name_text_box.value, BTSColors.header_error_text_brush, 0, y_offset);
}
diff --git a/src/client/spark/Modules/Spreader/SyntheticEditorView.xaml b/src/client/spark/Modules/Spreader/SyntheticEditorView.xaml
index 704959c14..a14c6b8f0 100644
--- a/src/client/spark/Modules/Spreader/SyntheticEditorView.xaml
+++ b/src/client/spark/Modules/Spreader/SyntheticEditorView.xaml
@@ -23,7 +23,6 @@
HorizontalAlignment="Stretch" Margin="6"
SyntheticName="{Binding name}"
TickFactors="{Binding tick_factors}"
- AvailableTickFactors="{Binding available_tick_factors_view}"
IsNew="{Binding is_new}"
CanUserAddNewLeg="{Binding can_add_leg}"
IsNewLegPopupOpen="{Binding is_new_leg_popup_open}"
diff --git a/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs b/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs
index 60e6bae60..5336a62ea 100644
--- a/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs
+++ b/src/client/spark/Modules/Spreader/VM/SyntheticEditorVM.cs
@@ -1,6 +1,7 @@
using bts.api;
using bts.shell;
using bts.spark;
+using mbts.spark.utilities;
using mbts.ui;
using mbts.ui.shell;
using mbts.ui.spark;
@@ -10,11 +11,9 @@ using mbts.utils;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
-using System.ComponentModel;
using System.Linq;
using System.Reactive.Linq;
using System.Threading.Tasks;
-using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
@@ -23,7 +22,6 @@ namespace mbts.spark {
/// The view model designed to serve as the DataContext for the SyntheticEditorView
///
partial class SyntheticEditorVM : DisposableViewModelBase, IRequestViewClose, IRequestBindingSourceUpdate, IDisposable {
- readonly ObservableCollection _available_tick_factors = new ObservableCollection(TickUtils.all_present_ticks());
readonly QuantityModel _quantity_model;
readonly PriceMultiplierModel _price_mult_model;
readonly List _resources = new List();
@@ -121,7 +119,7 @@ namespace mbts.spark {
flash_error_msg("Name already taken", SparkUtils.UI.MessageFlashDuration, nameof(name)).ignore();
valid = false;
}
- if (_tick_factors == null || !_tick_factors.is_valid() || !_available_tick_factors.Contains(_tick_factors)) {
+ if (_tick_factors == null || !_tick_factors.is_valid()) {
flash_error_msg("Please select ticks", SparkUtils.UI.MessageFlashDuration, nameof(tick_factors)).ignore();
valid = false;
}
@@ -133,6 +131,8 @@ namespace mbts.spark {
_synthetic.ContractSpec.LowTick = tick_frac;
_synthetic.ContractSpec.HighTick = tick_frac;
_synthetic.ContractSpec.PriceBreak = double.MaxValue;
+ _synthetic.ContractSpec.MainFraction = (uint)MathUtils.factor_out(_tick_factors.tick_base, 10);
+ _synthetic.ContractSpec.PriceDisplayFormat = (uint)_tick_factors.display_digits();
uint? id = await model.create_synthetic(_synthetic);
if (id.HasValue && id != 0) {
if (await model.save_strategy(id.Value, get_strategy())) {
@@ -152,8 +152,6 @@ namespace mbts.spark {
_set_ticks_automatically = is_new;
_set_quantities_automatically = is_new;
_set_price_mults_automatically = is_new;
- available_tick_factors_view = CollectionViewSource.GetDefaultView(_available_tick_factors);
- available_tick_factors_view.GroupDescriptions.Add(new PropertyGroupDescription(nameof(TickFactors.tick_base)));
_quantity_model = new QuantityModel(!is_new);
_price_mult_model = new PriceMultiplierModel(!is_new);
@@ -245,9 +243,11 @@ namespace mbts.spark {
public TickFactors tick_factors {
get => _tick_factors;
set {
- _tick_factors = value;
- _set_ticks_automatically = false;
- RaisePropertyChanged();
+ if (_tick_factors != value) {
+ _tick_factors = value;
+ _set_ticks_automatically = false;
+ RaisePropertyChanged();
+ }
}
}
public bool has_working_orders => _has_working_orders.Value;
@@ -261,7 +261,6 @@ namespace mbts.spark {
public IRaiseCanExecuteChangedCommand commit { get; }
public ICommand remove_leg { get; }
public ContractPickerModel contract_picker_model { get; }
- public ICollectionView available_tick_factors_view { get; }
public ExecutionStrategyImmutable get_strategy() {
var mutable_strategy = _strategy.CloneToMutable();
@@ -328,8 +327,6 @@ namespace mbts.spark {
void _deduce_ticks() {
_tick_factors = TickUtils.deduce_ticks(leg_tuples.Select(l => l.leg.Security.ContractSpec));
- if (_tick_factors != null && !_available_tick_factors.Contains(tick_factors))
- _available_tick_factors.Add(_tick_factors);
RaisePropertyChanged(nameof(tick_factors));
}
diff --git a/src/client/spark/core/GlobalExtensions/TickExtensions.cs b/src/client/spark/core/GlobalExtensions/TickExtensions.cs
index 7468f9903..8400fc04b 100644
--- a/src/client/spark/core/GlobalExtensions/TickExtensions.cs
+++ b/src/client/spark/core/GlobalExtensions/TickExtensions.cs
@@ -17,8 +17,10 @@ namespace mbts {
public static double tick_unit_frac(this TickFactors tick) =>
tick.tick_unit / tick.tick_base;
+ public static double reduced_base(this TickFactors tick) => factor_out(tick.tick_base, 10);
+
public static string format(this TickFactors tick, double value) =>
- format(tick, value, double.NaN, true, _nan_text);
+ format(tick, value, double.NaN, false, _nan_text);
public static string format(this TickFactors tick, double value, bool show_commas) =>
format(tick, value, double.NaN, show_commas, _nan_text);
@@ -176,9 +178,10 @@ namespace mbts {
if (DoubleHelper.IsNaNOrInfinity(input)) return input;
return input <= regional_tick.low_tick_inclusive_end ? regional_tick.low_tick.round(input) : regional_tick.high_tick.round(input);
}
+ public static int display_digits(this TickFactors tick) => display_digits(tick.tick_base);
#endregion
- public static int n_display_digits(double tick_base) {
+ public static int display_digits(double tick_base) {
double log_tick_base = Math.Log10(tick_base);
int floor = (int)Math.Floor(log_tick_base);
double dec = log_tick_base - floor;
@@ -216,7 +219,7 @@ namespace mbts {
if (numerator_part >= tick_base) numerator_part /= Math.Pow(10, Math.Ceiling(Math.Log10(numerator_part) - Math.Log10(tick_base)));
else {
//e.g [tick_base 640] 1989-8 == 1989-80, or 1989-32 == 1989-320
- int ndd_diff = n_display_digits(tick_base) - numerator_text.Length;
+ int ndd_diff = display_digits(tick_base) - numerator_text.Length;
if (ndd_diff > 0) numerator_part *= Math.Pow(10, ndd_diff);
if (numerator_part >= tick_base) numerator_part /= 10;
}
@@ -255,16 +258,21 @@ namespace mbts {
double numerator_dec = value - integer_part;
double unit_frac = tick.tick_unit / tick.tick_base;
int n_units = (int)Math.Round(numerator_dec / unit_frac);
- if (n_units == tick.tick_base) return (integer_part + 1).ToString() + tick.separator() + new string('0', n_display_digits(tick.tick_base));
+ if (n_units == tick.tick_base) return (integer_part + 1).ToString() + tick.separator() + new string('0', display_digits(tick.tick_base));
double decimal_part = n_units * tick.tick_unit;
if (decimal_part == tick.tick_base) {
++integer_part;
decimal_part = 0;
+ } else {
+ // some ticks are not formatted with 100% precision, using less than the required display_digits
+ // for such cases, we need to truncate the decimal part rather than round it.
+ decimal_part = Math.Floor(decimal_part);
}
string integer_part_text = show_commas ? integer_part.ToString("#,0") : integer_part.ToString();
- return integer_part_text + tick.separator() + decimal_part.ToString(new string('0', n_display_digits(tick.tick_base)));
+ return integer_part_text + tick.separator() + decimal_part.ToString(new string('0', display_digits(tick.tick_base)));
}
- } catch (OverflowException ex) {
+ }
+ catch (OverflowException ex) {
Logger.warn(bts.log.Subsystem.Ui, $"Arithmetic overflow exception in format_tick (tick:{tick}, value:{value}):{ex}");
return "Overflow";
}
@@ -272,7 +280,7 @@ namespace mbts {
private static double _round_tick(double tick_unit_frac, double input) {
return input - Math.IEEERemainder(input, tick_unit_frac);
- }
+ }
#endregion
}
}
\ No newline at end of file
diff --git a/src/client/spark/core/Utility/AnonymousEqualityComparer.cs b/src/client/spark/core/Utility/AnonymousEqualityComparer.cs
index 99b86c440..ce4b27e89 100644
--- a/src/client/spark/core/Utility/AnonymousEqualityComparer.cs
+++ b/src/client/spark/core/Utility/AnonymousEqualityComparer.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections;
using System.Collections.Generic;
namespace mbts.utils {
@@ -25,6 +26,9 @@ namespace mbts.utils {
public static IEqualityComparer CreateNullable(Func equals) where T : struct =>
new AnonymousEqualityComparer((a, b) => a.HasValue ? b.HasValue && equals(a.Value, b.Value) : !b.HasValue);
+ public static IEqualityComparer to_non_generic(this IEqualityComparer comparer) =>
+ new AnonymousEqualityComparer(comparer.Equals, comparer.GetHashCode);
+
public static bool NullCheckEquals(T x, T y, Func non_null_equals) where T : class, IEquatable =>
x == null ? y == null :
y != null &&
@@ -55,7 +59,7 @@ namespace mbts.utils {
static void _accumulate_hash(ref int aggregate_hash, ref int item_hash) =>
aggregate_hash = aggregate_hash * _hash_multiplier + item_hash;
- private class AnonymousEqualityComparer : IEqualityComparer {
+ private class AnonymousEqualityComparer : IEqualityComparer, IEqualityComparer {
readonly Func _equals;
readonly Func _get_hash_code;
@@ -67,6 +71,9 @@ namespace mbts.utils {
public bool Equals(T x, T y) => _equals(x, y);
public int GetHashCode(T obj) => _get_hash_code(obj);
+
+ bool IEqualityComparer.Equals(object x, object y) => x is T xt && y is T yt && _equals(xt, yt);
+ int IEqualityComparer.GetHashCode(object obj) => throw new NotImplementedException();
}
}
}
\ No newline at end of file
diff --git a/src/client/spark/core/Utility/CompareUtils.cs b/src/client/spark/core/Utility/CompareUtils.cs
index 8e714db66..790078c40 100644
--- a/src/client/spark/core/Utility/CompareUtils.cs
+++ b/src/client/spark/core/Utility/CompareUtils.cs
@@ -1,4 +1,6 @@
using System;
+using System.Collections;
+using System.Collections.Generic;
namespace mbts.utils {
public static class CompareUtils {
@@ -19,5 +21,22 @@ namespace mbts.utils {
b.HasValue ? compare(a.Value, b.Value) : 1 :
b.HasValue ? -1 : 0;
#endregion
+
+ #region Comparer
+ public static IComparer to_non_generic(this IComparer comparer) =>
+ new NonGenericComparerWrapper(comparer);
+
+ public static IComparer wrap(this IComparer inner_comparer, Func selector) =>
+ Comparer.Create((a, b) => inner_comparer.Compare(a == null ? default : selector(a), b == null ? default : selector(b)));
+
+ class NonGenericComparerWrapper : IComparer {
+ readonly IComparer _comparer;
+
+ public NonGenericComparerWrapper(IComparer comparer) => _comparer = comparer;
+
+ public int Compare(object x, object y) =>
+ _comparer.Compare(ObjectHelper.try_convert(x), ObjectHelper.try_convert(y));
+ }
+ #endregion
}
}
\ No newline at end of file
diff --git a/src/client/spark/core/Utility/IValueFactoryVM.cs b/src/client/spark/core/Utility/IValueFactoryVM.cs
new file mode 100644
index 000000000..68322105e
--- /dev/null
+++ b/src/client/spark/core/Utility/IValueFactoryVM.cs
@@ -0,0 +1,6 @@
+namespace mbts.spark {
+ interface IValueFactoryVM {
+ T create();
+ void load_from(T value);
+ }
+}
\ No newline at end of file
diff --git a/src/client/spark/view/Controls/Order/OrderDetailsPopupControl.xaml b/src/client/spark/view/Controls/Order/OrderDetailsPopupControl.xaml
index fe7082c06..0e8969a2a 100644
--- a/src/client/spark/view/Controls/Order/OrderDetailsPopupControl.xaml
+++ b/src/client/spark/view/Controls/Order/OrderDetailsPopupControl.xaml
@@ -375,7 +375,6 @@
DataContext="{Binding strategy_editor}"
SyntheticName="{Binding name}"
TickFactors="{Binding tick_factors}"
- AvailableTickFactors="{Binding available_tick_factors_view}"
IsNew="False"
IsNewLegPopupOpen="{Binding is_new_leg_popup_open}"
PriceCalc="{Binding price_calc}"
diff --git a/src/client/spark/view/Controls/PriceEntryControl.xaml.cs b/src/client/spark/view/Controls/PriceEntryControl.xaml.cs
index 52cb3a8ac..b02202ec9 100644
--- a/src/client/spark/view/Controls/PriceEntryControl.xaml.cs
+++ b/src/client/spark/view/Controls/PriceEntryControl.xaml.cs
@@ -41,7 +41,7 @@ namespace mbts.ui.spark {
#region ContractSpec
public static readonly DependencyProperty ContractSpecProperty = DependencyProperty.Register("ContractSpec", typeof(ContractSpecificationImmutable), typeof(PriceEntryControl),
- new PropertyMetadata(SecurityDataHelper.Defaults.ContractSpecificationImmutable, OnContractSpecChanged));
+ new PropertyMetadata(SecurityDataHelper.Defaults.ContractSpecificationImmutablePennies, OnContractSpecChanged));
static void OnContractSpecChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => ((PriceEntryControl)d)._update_text_binding();
public ContractSpecificationImmutable? ContractSpec { get => GetValue(ContractSpecProperty) as ContractSpecificationImmutable?; set => SetValue(ContractSpecProperty, value); }
#endregion
diff --git a/src/client/spark/view/Controls/TickFactorsPicker/TickFactorsPicker.xaml b/src/client/spark/view/Controls/TickFactorsPicker/TickFactorsPicker.xaml
new file mode 100644
index 000000000..204ea5bb9
--- /dev/null
+++ b/src/client/spark/view/Controls/TickFactorsPicker/TickFactorsPicker.xaml
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/client/spark/view/Controls/TickFactorsPicker/TickFactorsPicker.xaml.cs b/src/client/spark/view/Controls/TickFactorsPicker/TickFactorsPicker.xaml.cs
new file mode 100644
index 000000000..a9ff8fd3c
--- /dev/null
+++ b/src/client/spark/view/Controls/TickFactorsPicker/TickFactorsPicker.xaml.cs
@@ -0,0 +1,157 @@
+using mbts.spark;
+using mbts.spark.utilities;
+using mbts.ui.converters;
+using mbts.ui.shell;
+using mbts.ui.utility;
+using mbts.user.settings;
+using mbts.utils;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+
+namespace mbts.ui.controls {
+ ///
+ /// Interaction logic for TickPicker.xaml
+ ///
+ class TickFactorsPicker : Control {
+ readonly ObservableCollection _tick_unit_presets = new ObservableCollection();
+
+ static TickFactorsPicker() =>
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(TickFactorsPicker), new FrameworkPropertyMetadata(typeof(TickFactorsPicker)));
+
+ public TickFactorsPicker() {
+ Controller = new TickFactorsController(this);
+ TickBasePresetsView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(TickBaseVM.reduced_base_group)));
+ ((ListCollectionView)TickBasePresetsView).CustomSort = TickUtils.CompareUtils.base_comparer.wrap(vm => vm.value).to_non_generic();
+ TickUnitPresetsView = CollectionViewSource.GetDefaultView(new ObservableAutoWrapper(_tick_unit_presets, v => new TickUnitVM(v)));
+ TickUnitPresetsView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(TickUnitVM.reduced_unit_group)));
+ ((ListCollectionView)TickUnitPresetsView).CustomSort = Comparer.Default.wrap(vm => vm.value).to_non_generic();
+ }
+
+ public static IEnumerable TickBasePresets =>
+ new [] {
+ 8, 16, 32, 64, 100
+ }.SelectMany(i => Enumerable.Range(0, 4).Select(log10 => i * Math.Pow(10, log10)));
+
+ public static IMultiValueConverter TickUnitVisibleTextConverter =>
+ ValueConverter.create((double tick_base, double tick_unit) => {
+ int display_digits = TickExtensions.display_digits(tick_base);
+ return ((int)(tick_unit)).ToString(new string('0', display_digits));
+ });
+
+ public static IValueConverter TickUnitHiddenTextConverter =>
+ ValueConverter.create((double tick_unit) => new string(tick_unit.ToString().SkipWhile(c => c != '.').ToArray()));
+
+ public static readonly DependencyProperty SelectedTickFactorsProperty =
+ WPFHelper.create_dp(
+ nameof(SelectedTickFactors),
+ FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
+ (o, v) => o.Controller.load_from(v),
+ new TickFactors());
+
+ public TickFactors SelectedTickFactors {
+ get => GetValue(SelectedTickFactorsProperty) as TickFactors;
+ set => SetValue(SelectedTickFactorsProperty, value);
+ }
+
+ public TickFactorsController Controller { get; }
+
+ public ICollectionView TickBasePresetsView { get; } = CollectionViewSource.GetDefaultView(TickBasePresets.Select(v => new TickBaseVM(v)).ToList());
+ public ICollectionView TickUnitPresetsView { get; }
+
+ static IEnumerable _get_tick_unit_presets(double tick_base) {
+ double reduced_base = MathUtils.factor_out(tick_base, 10, out int base_log10);
+ return reduced_base == 1 ?
+ _get_dbased_tick_unit_presets(base_log10) :
+ _get_2based_tick_unit_presets((int)Math.Log(reduced_base, 2), base_log10);
+ }
+
+ static IEnumerable _get_2based_tick_unit_presets(int log2, int log10) =>
+ (log10 == 0 ? new[] { 1.0 } : _get_dbased_tick_unit_presets(log10)).Concat(
+ Enumerable.Range(1, log2 - 1).SelectMany(pow2 => {
+ double root = Math.Pow(2, pow2);
+ return Enumerable.Range(0, log10 + 1).Select(pow10 => root * Math.Pow(10, pow10));
+ }));
+
+ static IEnumerable _get_dbased_tick_unit_presets(int log10) =>
+ Enumerable.Range(0, log10).SelectMany(_coins);
+
+ static IEnumerable _coins(int pow10) {
+ double d = Math.Pow(10, pow10);
+ yield return d;
+ yield return 1.25 * d;
+ yield return 2.5 * d;
+ yield return 5.0 * d;
+ }
+
+ public class TickFactorsController : ViewModelBase, IValueFactoryVM {
+ readonly TickFactorsPicker _view;
+ readonly Property _tick_base, _tick_unit;
+
+ public TickFactorsController(TickFactorsPicker view) {
+ var init = (_view = view).SelectedTickFactors;
+ _tick_base = backing(nameof(tick_base), init.tick_base);
+ _tick_unit = backing(nameof(tick_unit), init.tick_unit);
+ }
+
+ public double tick_base {
+ get => _tick_base.Value;
+ set {
+ _tick_base.set(value);
+ WPFHelper.set_current_if_changed(_view, SelectedTickFactorsProperty, new TickFactors(value, tick_unit));
+ _view._tick_unit_presets.sync_with(_get_tick_unit_presets(value));
+ }
+ }
+ public double tick_unit {
+ get => _tick_unit.Value;
+ set {
+ _tick_unit.set(value);
+ WPFHelper.set_current_if_changed(_view, SelectedTickFactorsProperty, new TickFactors(tick_base, value));
+ }
+ }
+
+ public TickFactors create() => new TickFactors(tick_base, tick_unit);
+ public void load_from(TickFactors value) {
+ if (value != null) {
+ _tick_base.set(value.tick_base);
+ _tick_unit.set(value.tick_unit);
+ }
+ }
+ }
+
+ public class TickBaseVM : IEquatable {
+ public TickBaseVM(double value) =>
+ this.value = value;
+
+ public double value { get; }
+ public double reduced_base_group => MathUtils.factor_out(value, 10);
+
+ public bool Equals(TickBaseVM other) => other != null && value == other.value;
+ public override bool Equals(object obj) => Equals(obj as TickBaseVM);
+ public override int GetHashCode() => value.GetHashCode();
+ }
+
+ public class TickUnitVM : IEquatable {
+ public TickUnitVM(double value) =>
+ this.value = value;
+
+ public double value { get; }
+ public double reduced_unit_group {
+ get {
+ if (!MathUtils.is_int(value))
+ return 1;
+ else return MathUtils.factor_out(value, 10, 5);
+ }
+ }
+
+ public bool Equals(TickUnitVM other) => other != null && value == other.value;
+ public override bool Equals(object obj) => Equals(obj as TickUnitVM);
+ public override int GetHashCode() => value.GetHashCode();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/client/spark/view/Converters/AnonymousValueConverter.cs b/src/client/spark/view/Converters/AnonymousValueConverter.cs
index 28aab2c2c..5b7a396f5 100644
--- a/src/client/spark/view/Converters/AnonymousValueConverter.cs
+++ b/src/client/spark/view/Converters/AnonymousValueConverter.cs
@@ -2,8 +2,15 @@
using System.Globalization;
using System.Windows.Data;
-namespace mbts.ui.converters
-{
+namespace mbts.ui.converters {
+ static class ValueConverter {
+ public static IValueConverter create(Func convert) =>
+ new AnonymousValueConverter(convert);
+
+ public static IMultiValueConverter create(Func convert) =>
+ new AnonymousMultiValueConverter(convert);
+ }
+
public class AnonymousValueConverter : IValueConverter {
public AnonymousValueConverter(Func