42 lines
2.2 KiB
C#
42 lines
2.2 KiB
C#
using bts.spark;
|
|
using mbts.spark.utilities;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
|
|
namespace mbts.ui.spark.algo
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for PriceOffsetControl.xaml
|
|
/// </summary>
|
|
public class PriceOffsetControl : Control
|
|
{
|
|
static PriceOffsetControl() {
|
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(PriceOffsetControl), new FrameworkPropertyMetadata(typeof(PriceOffsetControl)));
|
|
}
|
|
|
|
#region PriceOffset
|
|
public static readonly DependencyProperty PriceOffsetProperty = DependencyProperty.Register("PriceOffset", typeof(PriceOffset), typeof(PriceOffsetControl), new PropertyMetadata(null, OnPriceOffsetChanged, CoercePriceOffset));
|
|
private static object CoercePriceOffset(DependencyObject d, object baseValue) { return baseValue is PriceOffset ? baseValue : OrderDataHelper.Defaults.PriceOffset; }
|
|
private static void OnPriceOffsetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { d.SetValue(PriceOffsetVMPropertyKey, new PriceOffsetVM((PriceOffset)e.NewValue)); }
|
|
public PriceOffset PriceOffset { get => GetValue(PriceOffsetProperty) as PriceOffset; set => SetValue(PriceOffsetProperty, value); }
|
|
#endregion
|
|
|
|
#region PriceOffsetVM (ReadOnly)
|
|
private static readonly DependencyPropertyKey PriceOffsetVMPropertyKey = DependencyProperty.RegisterReadOnly("PriceOffsetVM", typeof(PriceOffsetVM), typeof(PriceOffsetControl), new PropertyMetadata(null));
|
|
internal static readonly DependencyProperty PriceOffsetVMProperty = PriceOffsetVMPropertyKey.DependencyProperty;
|
|
internal PriceOffsetVM PriceOffsetVM { get => GetValue(PriceOffsetVMProperty) as PriceOffsetVM; private set => SetValue(PriceOffsetVMPropertyKey, value); }
|
|
#endregion
|
|
}
|
|
|
|
public class PriceOffsetVM
|
|
{
|
|
public PriceOffsetVM(PriceOffset model) {
|
|
_model = model;
|
|
}
|
|
|
|
private readonly PriceOffset _model;
|
|
|
|
public int ticks { get => _model.OffsetInTicks; set => _model.OffsetInTicks = value; }
|
|
public PriceType.Types.Status price_type { get => _model.PriceType.Status; set => _model.PriceType.Status = value; }
|
|
}
|
|
} |