ladder won't send order if resizing column
This commit is contained in:
1 parent
98112386fa
commit
beb6bd000c
4 files changed
+28
-27
No files matched your search
@@ -4,10 +4,8 @@ using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace mbts.ui.extensions
|
||||
{
|
||||
public static class UIElementExtensions
|
||||
{
|
||||
namespace mbts.ui.extensions {
|
||||
public static class UIElementExtensions {
|
||||
public static T ChildAtPoint<T>(this UIElement target, Point pt) where T : DependencyObject {
|
||||
var source = target.InputHitTest(pt) as UIElement;
|
||||
if (source == null) return null;
|
||||
@@ -60,10 +58,14 @@ namespace mbts.ui.extensions
|
||||
target.DragLeave += callback;
|
||||
return Disposable.Create(() => target.DragLeave -= callback);
|
||||
}
|
||||
|
||||
public static IDisposable SubscribePreviewMouseDown(this UIElement target, MouseButtonEventHandler callback) {
|
||||
target.PreviewMouseDown += callback;
|
||||
return Disposable.Create(() => target.PreviewMouseDown -= callback);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ScrollViewerExtensions
|
||||
{
|
||||
public static class ScrollViewerExtensions {
|
||||
public static IDisposable SubscribeScrollChanged(this ScrollViewer target, ScrollChangedEventHandler callback) {
|
||||
target.ScrollChanged += callback;
|
||||
return Disposable.Create(() => target.ScrollChanged -= callback);
|
||||
|
||||
@@ -70,16 +70,16 @@ namespace mbts.spark {
|
||||
|
||||
Column[] columns { get; set; } = new Column[0];
|
||||
|
||||
internal int row_for_point(Point point) {
|
||||
int row_for_point(Point point) {
|
||||
var row_offset = (_scrollViewer.ContentVerticalOffset / _settings.row_height);
|
||||
var click_offset = point.Y / _settings.row_height;
|
||||
return (int)(row_offset + click_offset);
|
||||
}
|
||||
private double price_for_row(int row) => _price_list == null ? double.NaN : _price_list[row];
|
||||
double price_for_row(int row) => _price_list == null ? double.NaN : _price_list[row];
|
||||
internal double price_for_point(Point point) => price_for_row(row_for_point(point));
|
||||
|
||||
protected ushort? bid_size_from_row(int row) => size_from_row(row, _price_list, _bids, _vm.security.ContractSpec);
|
||||
protected ushort? ask_size_from_row(int row) => size_from_row(row, _price_list, _asks, _vm.security.ContractSpec);
|
||||
ushort? bid_size_from_row(int row) => size_from_row(row, _price_list, _bids, _vm.security.ContractSpec);
|
||||
ushort? ask_size_from_row(int row) => size_from_row(row, _price_list, _asks, _vm.security.ContractSpec);
|
||||
static ushort? size_from_row(int row, double[] price_list, NativePriceSize[] depth, ContractSpecificationImmutable spec) {
|
||||
if (row <= price_list.Length)
|
||||
return size_from_price(price_list[row], depth, spec);
|
||||
@@ -93,7 +93,7 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
protected override async void OnMouseDown(MouseButtonEventArgs e) {
|
||||
if (_settings != null) {
|
||||
if (_settings != null && !_tactile_adorner.is_resizing_column) {
|
||||
var point = e.GetPosition(this);
|
||||
var price = price_for_point(point);
|
||||
var column = column_for_point(point);
|
||||
@@ -274,7 +274,7 @@ namespace mbts.spark {
|
||||
if (_price_dirty || _prices_out_of_range()) {
|
||||
_price_list = LadderRender.render_prices(_pricevis, mid, _rowcount, _settings.row_height, _settings.price_column, _spec);
|
||||
_ordershost.update_settings(_price_list, _settings.row_height, _settings.orders_column);
|
||||
LadderRender.render_grid(_gridvis, _price_list, SystemParameters.FullPrimaryScreenWidth, _rowcount, _settings.row_height, _settings.grid_line_color);
|
||||
LadderRender.render_grid(_gridvis, _price_list, _rowcount, _settings.row_height, _settings.grid_line_color);
|
||||
}
|
||||
Logger.assert_d(_price_list != null);
|
||||
var midIndex = LadderRender.index_of(_price_list, mid);
|
||||
@@ -283,7 +283,7 @@ namespace mbts.spark {
|
||||
|
||||
if (mid != _last_mid) {
|
||||
_last_mid = mid;
|
||||
LadderRender.render_mid(_midvis, midIndex, _settings.row_height, SystemParameters.FullPrimaryScreenWidth);
|
||||
LadderRender.render_mid(_midvis, midIndex, _settings.row_height);
|
||||
}
|
||||
|
||||
ulong unused = 0;
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace mbts.spark {
|
||||
_hooks = new List<IDisposable> {
|
||||
_host.SubscribeMouseEnter(_host_MouseEnter),
|
||||
_host.SubscribeMouseLeave(_host_MouseLeave),
|
||||
_host.SubscribeMouseDown(_host_MouseDown),
|
||||
_host.SubscribePreviewMouseDown(_host_PreviewMouseDown),
|
||||
_host.SubscribeMouseUp(_host_MouseUp),
|
||||
_host.SubscribeMouseMove(_host_MouseMove),
|
||||
scroll_viewer.SubscribeScrollChanged(_scroll_viewer_ScrollChanged),
|
||||
@@ -73,6 +73,8 @@ namespace mbts.spark {
|
||||
this.attach();
|
||||
}
|
||||
|
||||
public bool is_resizing_column => _width_adjustment_start.HasValue;
|
||||
|
||||
public IDisposable show_busy(int row, ColumnType col_type) {
|
||||
if (!_busy_cells.TryGetValue(row, out Dictionary<ColumnType, int> cols))
|
||||
_busy_cells.Add(row, cols = new Dictionary<ColumnType, int> { { col_type, 1 } });
|
||||
@@ -168,7 +170,7 @@ namespace mbts.spark {
|
||||
InvalidateVisual();
|
||||
}
|
||||
|
||||
void _host_MouseDown(object sender, MouseButtonEventArgs e) {
|
||||
void _host_PreviewMouseDown(object sender, MouseButtonEventArgs e) {
|
||||
_is_mouse_down = true;
|
||||
if (_is_mouse_within_resize_range)
|
||||
_width_adjustment_start = e.GetPosition(_host);
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
using bts.api;
|
||||
using mbts.co2;
|
||||
using mbts.ui;
|
||||
using mbts.utils;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
using mbts.ui;
|
||||
using System.Windows;
|
||||
using System.Collections.Concurrent;
|
||||
using mbts.utils;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace mbts.spark {
|
||||
static class LadderRender {
|
||||
|
||||
static IComparer<double> s_reverse_double = new ReverseComparer<double>(Comparer<double>.Default);
|
||||
public static int index_of(double[] prices, double price) {
|
||||
return Array.BinarySearch(prices, price, s_reverse_double);
|
||||
@@ -86,13 +83,13 @@ namespace mbts.spark {
|
||||
|
||||
}
|
||||
|
||||
public static void render_grid(DrawingVisual dv, double[] prices, double width, double rowcount, double row_height, UInt32 line_color) {
|
||||
public static void render_grid(DrawingVisual dv, double[] prices, double rowcount, double row_height, UInt32 line_color) {
|
||||
var height = rowcount * row_height;
|
||||
var pen = new Pen(new SolidColorBrush(line_color.rgb_color()), 1.0);
|
||||
using (var dc = dv.RenderOpen()) {
|
||||
for (int row = 1; row < rowcount; ++row) {
|
||||
double y = row * row_height;
|
||||
dc.DrawLine(pen, new Point(0, y), new Point(width, y));
|
||||
dc.DrawLine(pen, new Point(0, y), new Point(SystemParameters.FullPrimaryScreenWidth, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,10 +156,10 @@ namespace mbts.spark {
|
||||
}
|
||||
}
|
||||
|
||||
public static void render_mid(DrawingVisual dv, int midIndex, double row_height, double width) {
|
||||
public static void render_mid(DrawingVisual dv, int midIndex, double row_height) {
|
||||
using (var dc = dv.RenderOpen()) {
|
||||
dc.DrawRectangle(Brushes.Black, null, new Rect(0, midIndex * row_height - 1, width, 3));
|
||||
dc.DrawRectangle(Brushes.Black, null, new Rect(0, midIndex * row_height - 1, SystemParameters.FullPrimaryScreenWidth, 3));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user