From 5320e16088bc96bc43cbcdac484cb3619a553701 Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Wed, 26 Dec 2018 11:02:07 -0600 Subject: [PATCH] commenting out anything having to do w/ window width and height since that interaction is still mysterious; fixing scale factor restortation --- .../spark/view/Spark/Ladder/LadderVM.cs | 12 +++++----- .../spark/view/Spark/Ladder/LadderView.xaml | 7 ++++-- .../view/Spark/Ladder/LadderView.xaml.cs | 22 ++++++++++++++++++- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/client/spark/view/Spark/Ladder/LadderVM.cs b/src/client/spark/view/Spark/Ladder/LadderVM.cs index cf037804f..4b7528808 100644 --- a/src/client/spark/view/Spark/Ladder/LadderVM.cs +++ b/src/client/spark/view/Spark/Ladder/LadderVM.cs @@ -25,7 +25,7 @@ namespace mbts.spark { readonly IBus _bus; readonly LadderModel _model; readonly Property _high, _low, _change, _open, _settlement, _position, _left_panel_width, _zoom_factor; - readonly Property _window_width, _window_height; + //readonly Property _window_width, _window_height; readonly Property _orders_column_width, _bid_column_width, _price_column_width, _ask_column_width, _last_column_width, _volume_column_width; readonly Property _volume; readonly Property _auto_clear, _show_day, _show_high, _show_low, _show_open, _show_settle, _show_volume, _show_account, @@ -59,6 +59,7 @@ namespace mbts.spark { _last_column_width = backing(nameof(last_column_width), ws.last_column_width); _volume_column_width = backing(nameof(volume_column_width), ws.volume_column_width); _left_panel_width = backing(nameof(left_panel_width), ws.order_entry_panel_width); + _zoom_factor = backing(nameof(zoom_factor), ws.zoom_factor); // remember: account_positions needs to subscribe to selected_account; both the sub and account_positions need to be disposed var account_positions = new KeyDrivenObservableSeries(a => _model.order_gateway.security_total_position(security.Id, a)); _position = backing(nameof(position), account_positions.OnDispatcher()); @@ -96,9 +97,8 @@ namespace mbts.spark { backing(name, settings_manager.subscribe_current().OnDispatcher(), get_bool); // - _zoom_factor = backing(nameof(zoom_factor), settings_manager.subscribe_current().OnDispatcher().Select(s => s.zoom_factor), LadderSettings.Default.zoom_factor); - _window_height = backing(nameof(window_height), settings_manager.subscribe_current().OnDispatcher().Select(s => s.zoom_factor), (scale) => scale * 600); - _window_width = backing(nameof(window_width), settings_manager.subscribe_current().OnDispatcher().Select(s => s.zoom_factor), (scale) => scale * 420); + //_window_height = backing(nameof(window_height), settings_manager.subscribe_current().OnDispatcher().Select(s => s.zoom_factor), (scale) => scale * 600); + //_window_width = backing(nameof(window_width), settings_manager.subscribe_current().OnDispatcher().Select(s => s.zoom_factor), (scale) => scale * 420); position_click_command = new DelegateCommand(() => size_calculator.value = DoubleHelper.safe_convert_to_uint(Math.Abs(position))); send_order_command = new DelegateCommand<(double price, Side? side, bool size_from_alternate)>(send_order); cancel_command = new AsyncCommand(_model.cancel_orders, true); @@ -292,8 +292,8 @@ namespace mbts.spark { public bool show_zoom { get => _show_zoom.Value; set => _show_zoom.set(value); } public double left_panel_width { get => _left_panel_width.Value; set => _left_panel_width.set(value); } public double zoom_factor { get => _zoom_factor.Value; set => _zoom_factor.set(value); } - public double window_height { get => _window_height.Value; set => _window_height.set(value); } - public double window_width { get => _window_width.Value; set => _window_width.set(value); } + //public double window_height { get => _window_height.Value; set => _window_height.set(value); } + //public double window_width { get => _window_width.Value; set => _window_width.set(value); } public uint orders_column_width { get => _orders_column_width.Value; set => _orders_column_width.set(value); } public uint bid_column_width { get => _bid_column_width.Value; set => _bid_column_width.set(value); } public uint price_column_width { get => _price_column_width.Value; set => _price_column_width.set(value); } diff --git a/src/client/spark/view/Spark/Ladder/LadderView.xaml b/src/client/spark/view/Spark/Ladder/LadderView.xaml index 3303569c9..65b738d80 100644 --- a/src/client/spark/view/Spark/Ladder/LadderView.xaml +++ b/src/client/spark/view/Spark/Ladder/LadderView.xaml @@ -9,6 +9,7 @@ xmlns:uag="clr-namespace:mbts.ui.spark.algo" xmlns:converters="clr-namespace:mbts.ui.converters" xmlns:txt="clr-namespace:mbts.ui.utility.text" + xmlns:sys="clr-namespace:System;assembly=mscorlib" Height="600" Width="420" Background="{x:Static mbts:BTSColors.common_background_brush}" @@ -273,6 +274,8 @@ + 1.5 + 0.5 @@ -306,8 +309,8 @@ diff --git a/src/client/spark/view/Spark/Ladder/LadderView.xaml.cs b/src/client/spark/view/Spark/Ladder/LadderView.xaml.cs index 0ea0860ef..273bb4d9a 100644 --- a/src/client/spark/view/Spark/Ladder/LadderView.xaml.cs +++ b/src/client/spark/view/Spark/Ladder/LadderView.xaml.cs @@ -9,6 +9,8 @@ using System.Windows.Input; namespace mbts.spark { partial class LadderView : UserControl { + readonly double _max_zoom, _min_zoom; + internal LadderView(LadderVM vm) { InitializeComponent(); _column_headers_presenter.Columns = new GridViewColumnCollection(); @@ -17,6 +19,19 @@ namespace mbts.spark { this.vm = vm; DataContext = vm; DataContextChanged += datacontext_changed; + if (TryFindResource("MaxZoomFactor") is double found_max) { + _max_zoom = found_max; + } else { + // is there a better way of not specifying the constant twice ? + // once in the resource dictionary here and again in the xaml, seems like there has to be a better way + _max_zoom = 1.5; + } + // ditto + if (TryFindResource("MinZoomFactor") is double found_min) { + _min_zoom = found_min; + } else { + _min_zoom = 0.5; + } _ui_scaler.MouseDoubleClick += _ui_scaler_MouseDoubleClick; this.PreviewMouseWheel += LadderView_PreviewMouseWheel; this.PreviewMouseDown += LadderView_PreviewMouseDown; @@ -29,7 +44,12 @@ namespace mbts.spark { private void LadderView_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e) { base.OnPreviewMouseWheel(e); if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { - _ui_scaler.Value += (e.Delta > 0) ? 0.1 : -0.1; + var delta = (e.Delta > 0) ? 0.1 : -0.1; + var proposed_scaler_value = _ui_scaler.Value + delta; + // Here we enforce the same contraints that are on the gui slider regarding min and max + if (_min_zoom < proposed_scaler_value && proposed_scaler_value < _max_zoom) { + _ui_scaler.Value = proposed_scaler_value; + } } }