refactor: Drop 'Simplified' from vs grid/column class names
This commit is contained in:
1 parent
be8bc54e46
commit
230e02014c
6 files changed
+111
-102
No files matched your search
@@ -14,7 +14,7 @@ namespace mbts.ui {
|
||||
if (!cell.HasValue || DIYGrid.RowUtils.column_index(_column_layout, cell.Value) < _grid.FrozenColumnCount) {
|
||||
return;
|
||||
}
|
||||
_row.context_menu.column = (VolSurfaceSimplifiedColumn)cell.Value.column;
|
||||
_row.context_menu.column = (VolSurfaceColumn)cell.Value.column;
|
||||
_row.context_menu.super_header = cell.Value.super_column;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
BTSGraphVM _vol_curve_graph_vm => _vm?.vol_curve_vm?.graph_vm;
|
||||
|
||||
public static IMultiValueConverter cell_vm_converter =>
|
||||
ValueConverter.create<VolSurfaceRowContext, VolSurfaceSimplifiedColumn, object>(
|
||||
ValueConverter.create<VolSurfaceRowContext, VolSurfaceColumn, object>(
|
||||
(row, col) => row?.get_cell(col.volsurface_column));
|
||||
|
||||
public static string TimeDecayTemplateKey => "Decay";
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
namespace mbts.spark.VolSurface {
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.converters;
|
||||
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Controls;
|
||||
|
||||
enum VolSurfaceColumnType {
|
||||
RowHeader,
|
||||
ReadOnly,
|
||||
ReadWriteTick
|
||||
}
|
||||
|
||||
class VolSurfaceColumn : DIYGrid.FrameworkElementColumnBase<string> {
|
||||
public VolSurfaceColumn(VolSurfaceColumnType type, string header, VolSurfaceDisplayGridColumn c)
|
||||
: base(c?.unique_col_name ?? "Expiration") {
|
||||
this.type = type;
|
||||
volsurface_column = c;
|
||||
Header = header;
|
||||
is_visible = true;
|
||||
Width = 80;
|
||||
id = key ?? throw new InvalidOperationException("Column key cannot be null");
|
||||
}
|
||||
|
||||
public VolSurfaceColumnType type { get; private set; }
|
||||
public VolSurfaceDisplayGridColumn volsurface_column { get; private set; }
|
||||
|
||||
IValueConverter _data_context_converter =>
|
||||
ValueConverter.create<VolSurfaceRowContext, object>(row => row?.get_cell(volsurface_column));
|
||||
|
||||
public override FrameworkElement view_factory() {
|
||||
switch (type) {
|
||||
case VolSurfaceColumnType.RowHeader: {
|
||||
var view = new TextBlock {
|
||||
FontWeight = FontWeights.Bold
|
||||
};
|
||||
view.SetBinding(TextBlock.TextProperty, new Binding(nameof(VolSurfaceRowContext.expiration)));
|
||||
return view;
|
||||
}
|
||||
case VolSurfaceColumnType.ReadOnly: {
|
||||
var view = new TextBlock {
|
||||
Foreground = Brushes.Blue
|
||||
};
|
||||
view.SetBinding(FrameworkElement.DataContextProperty, new Binding() {
|
||||
Converter = _data_context_converter
|
||||
});
|
||||
view.SetBinding(TextBlock.TextProperty, new Binding(nameof(VolGridCellVM.committed_value)) {
|
||||
Converter = ValueConverter.create(volsurface_column.format)
|
||||
});
|
||||
return view;
|
||||
}
|
||||
case VolSurfaceColumnType.ReadWriteTick: {
|
||||
var view = new VolSurfaceCellView();
|
||||
view.SetCurrentValue(DIYGrid.ColumnProperty, this);
|
||||
|
||||
view.CommandBindings.Add(new CommandBinding(VolSurfaceCellView.BeginEditCommand, VolSurfaceCellView.BeginEditExecuted));
|
||||
view.CommandBindings.Add(new CommandBinding(VolSurfaceCellView.EndEditCommand, VolSurfaceCellView.EndEditExecuted));
|
||||
view.CommandBindings.Add(new CommandBinding(VolSurfaceCellView.CancelEditCommand, VolSurfaceCellView.CancelEditExecuted));
|
||||
|
||||
view.InputBindings.Add(new MouseBinding(VolSurfaceCellView.BeginEditCommand, new MouseGesture(MouseAction.LeftClick)));
|
||||
view.InputBindings.Add(new KeyBinding(VolSurfaceCellView.EndEditCommand, new KeyGesture(Key.Return)));
|
||||
view.InputBindings.Add(new KeyBinding(VolSurfaceCellView.CancelEditCommand, new KeyGesture(Key.Escape)));
|
||||
|
||||
view.SetBinding(FrameworkElement.DataContextProperty, new Binding() {
|
||||
Converter = _data_context_converter
|
||||
});
|
||||
view.SetBinding(VolSurfaceCellView.CommittedValueProperty, new Binding(nameof(VolGridCellVM.committed_value)) {
|
||||
Mode = BindingMode.OneWay,
|
||||
Converter = ValueConverter.create(volsurface_column.format)
|
||||
});
|
||||
view.SetBinding(VolSurfaceCellView.CandidateValueProperty, new Binding(nameof(VolGridCellVM.candidate_value)) {
|
||||
Mode = BindingMode.TwoWay,
|
||||
Converter = ValueConverter.create(volsurface_column.format, volsurface_column.parse)
|
||||
});
|
||||
view.SetBinding(VolSurfaceCellView.TickDownCommandProperty, new Binding(nameof(VolGridTickCellVM.tick_down_cmd)));
|
||||
view.SetBinding(VolSurfaceCellView.TickUpCommandProperty, new Binding(nameof(VolGridTickCellVM.tick_up_cmd)));
|
||||
return view;
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
-88
@@ -6,7 +6,6 @@
|
||||
using mbts.collections;
|
||||
using mbts.ui;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.converters;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.utility;
|
||||
|
||||
@@ -14,91 +13,13 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Controls;
|
||||
|
||||
enum VolSurfaceSimplifiedColumnType {
|
||||
RowHeader,
|
||||
ReadOnly,
|
||||
ReadWriteTick
|
||||
}
|
||||
|
||||
class VolSurfaceSimplifiedColumn : DIYGrid.FrameworkElementColumnBase<string> {
|
||||
public VolSurfaceSimplifiedColumn(VolSurfaceSimplifiedColumnType type, string header, VolSurfaceDisplayGridColumn c)
|
||||
: base(c?.unique_col_name ?? "Expiration") {
|
||||
this.type = type;
|
||||
volsurface_column = c;
|
||||
Header = header;
|
||||
is_visible = true;
|
||||
Width = 80;
|
||||
id = key ?? throw new InvalidOperationException("Column key cannot be null");
|
||||
}
|
||||
|
||||
public VolSurfaceSimplifiedColumnType type { get; private set; }
|
||||
public VolSurfaceDisplayGridColumn volsurface_column { get; private set; }
|
||||
|
||||
IValueConverter _data_context_converter =>
|
||||
ValueConverter.create<VolSurfaceRowContext, object>(row => row?.get_cell(volsurface_column));
|
||||
|
||||
public override FrameworkElement view_factory() {
|
||||
switch (type) {
|
||||
case VolSurfaceSimplifiedColumnType.RowHeader: {
|
||||
var view = new TextBlock {
|
||||
FontWeight = FontWeights.Bold
|
||||
};
|
||||
view.SetBinding(TextBlock.TextProperty, new Binding(nameof(VolSurfaceRowContext.expiration)));
|
||||
return view;
|
||||
}
|
||||
case VolSurfaceSimplifiedColumnType.ReadOnly: {
|
||||
var view = new TextBlock {
|
||||
Foreground = Brushes.Blue
|
||||
};
|
||||
view.SetBinding(FrameworkElement.DataContextProperty, new Binding() {
|
||||
Converter = _data_context_converter
|
||||
});
|
||||
view.SetBinding(TextBlock.TextProperty, new Binding(nameof(VolGridCellVM.committed_value)) {
|
||||
Converter = ValueConverter.create(volsurface_column.format)
|
||||
});
|
||||
return view;
|
||||
}
|
||||
case VolSurfaceSimplifiedColumnType.ReadWriteTick: {
|
||||
var view = new VolSurfaceCellView();
|
||||
view.SetCurrentValue(DIYGrid.ColumnProperty, this);
|
||||
|
||||
view.CommandBindings.Add(new CommandBinding(VolSurfaceCellView.BeginEditCommand, VolSurfaceCellView.BeginEditExecuted));
|
||||
view.CommandBindings.Add(new CommandBinding(VolSurfaceCellView.EndEditCommand, VolSurfaceCellView.EndEditExecuted));
|
||||
view.CommandBindings.Add(new CommandBinding(VolSurfaceCellView.CancelEditCommand, VolSurfaceCellView.CancelEditExecuted));
|
||||
|
||||
view.InputBindings.Add(new MouseBinding(VolSurfaceCellView.BeginEditCommand, new MouseGesture(MouseAction.LeftClick)));
|
||||
view.InputBindings.Add(new KeyBinding(VolSurfaceCellView.EndEditCommand, new KeyGesture(Key.Return)));
|
||||
view.InputBindings.Add(new KeyBinding(VolSurfaceCellView.CancelEditCommand, new KeyGesture(Key.Escape)));
|
||||
|
||||
view.SetBinding(FrameworkElement.DataContextProperty, new Binding() {
|
||||
Converter = _data_context_converter
|
||||
});
|
||||
view.SetBinding(VolSurfaceCellView.CommittedValueProperty, new Binding(nameof(VolGridCellVM.committed_value)) {
|
||||
Mode = BindingMode.OneWay,
|
||||
Converter = ValueConverter.create(volsurface_column.format)
|
||||
});
|
||||
view.SetBinding(VolSurfaceCellView.CandidateValueProperty, new Binding(nameof(VolGridCellVM.candidate_value)) {
|
||||
Mode = BindingMode.TwoWay,
|
||||
Converter = ValueConverter.create(volsurface_column.format, volsurface_column.parse)
|
||||
});
|
||||
view.SetBinding(VolSurfaceCellView.TickDownCommandProperty, new Binding(nameof(VolGridTickCellVM.tick_down_cmd)));
|
||||
view.SetBinding(VolSurfaceCellView.TickUpCommandProperty, new Binding(nameof(VolGridTickCellVM.tick_up_cmd)));
|
||||
return view;
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VolSurfaceSimplifiedGridVM : DisposableViewModelBase {
|
||||
class VolSurfaceGridVM : DisposableViewModelBase {
|
||||
readonly VolSurfaceVM _parent;
|
||||
readonly ObservableCollection<VolSurfaceDisplayGridExpiration> _expirations = new();
|
||||
readonly ObservableCollection<VolSurfaceDisplayGridColumn> _internal_columns = new();
|
||||
@@ -107,7 +28,7 @@
|
||||
ISet<VolSurfaceExpiration> _hidden_expirations;
|
||||
IDisposable _shift_editor;
|
||||
|
||||
public VolSurfaceSimplifiedGridVM(VolSurfaceVM vm, VolSurfaceDisplayModel model,
|
||||
public VolSurfaceGridVM(VolSurfaceVM vm, VolSurfaceDisplayModel model,
|
||||
ISet<string> hidden_columns, ISet<VolSurfaceExpiration> hidden_expirations) {
|
||||
Log.assert(hidden_columns != null);
|
||||
Log.assert(hidden_expirations != null);
|
||||
@@ -137,7 +58,7 @@
|
||||
|
||||
_dispose = Disposable.Create(
|
||||
ObservableAutoWrapper.connect(_expirations, rows, exp => new VolSurfaceRowContext(this, exp), row => row.Dispose()),
|
||||
ObservableAutoWrapper.connect(_internal_columns, data_columns, c => new VolSurfaceSimplifiedColumn(_map(c.type), c.header, c)),
|
||||
ObservableAutoWrapper.connect(_internal_columns, data_columns, c => new VolSurfaceColumn(_map(c.type), c.header, c)),
|
||||
ObservableAggregateCollection.connect(
|
||||
columns, new ObservableCollection<DIYGrid.ColumnBase> { create_exp_column_view() }, data_columns),
|
||||
Disposable.Create(() => {
|
||||
@@ -147,7 +68,7 @@
|
||||
Disposable.dispose(ref _shift_editor);
|
||||
}));
|
||||
|
||||
VolSurfaceSimplifiedColumn create_exp_column_view() {
|
||||
VolSurfaceColumn create_exp_column_view() {
|
||||
var filter = new ComboCheckBox() { HeaderContent = "Expirations" };
|
||||
filter.Foreground = Brushes.Black;
|
||||
filter.SetBinding(ItemsControl.ItemsSourceProperty, new Binding(nameof(rows)) {
|
||||
@@ -158,7 +79,7 @@
|
||||
Source = this,
|
||||
Mode = BindingMode.OneWay
|
||||
});
|
||||
return new VolSurfaceSimplifiedColumn(VolSurfaceSimplifiedColumnType.RowHeader, null, null) { Header = filter };
|
||||
return new VolSurfaceColumn(VolSurfaceColumnType.RowHeader, null, null) { Header = filter };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,11 +181,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
static VolSurfaceSimplifiedColumnType _map(DataGridKnownColumnType type) =>
|
||||
static VolSurfaceColumnType _map(DataGridKnownColumnType type) =>
|
||||
type switch {
|
||||
DataGridKnownColumnType.ReadOnly or DataGridKnownColumnType.ReadOnlyDiff => VolSurfaceSimplifiedColumnType.ReadOnly,
|
||||
DataGridKnownColumnType.ReadWriteDiff or DataGridKnownColumnType.ReadWriteTick or DataGridKnownColumnType.ReadWrite => VolSurfaceSimplifiedColumnType.ReadWriteTick,
|
||||
_ => VolSurfaceSimplifiedColumnType.ReadOnly,
|
||||
DataGridKnownColumnType.ReadOnly or DataGridKnownColumnType.ReadOnlyDiff => VolSurfaceColumnType.ReadOnly,
|
||||
DataGridKnownColumnType.ReadWriteDiff or DataGridKnownColumnType.ReadWriteTick or DataGridKnownColumnType.ReadWrite => VolSurfaceColumnType.ReadWriteTick,
|
||||
_ => VolSurfaceColumnType.ReadOnly,
|
||||
};
|
||||
|
||||
static string _short_header(string header) =>
|
||||
@@ -20,7 +20,7 @@ namespace mbts.spark.VolSurface {
|
||||
}
|
||||
|
||||
class VolSurfaceRowContext : DisposableViewModelBase, ISelectable, IFormatCellsToClipboard, DIYGrid.IRowVM {
|
||||
readonly VolSurfaceSimplifiedGridVM _parent;
|
||||
readonly VolSurfaceGridVM _parent;
|
||||
readonly VolSurfaceDisplayGridExpiration _exp;
|
||||
/// TODO: remove _text_cache when we are sure that the new row view
|
||||
/// (<see cref="VolSurfaceRowView"/>) is solid. It must remain in place
|
||||
@@ -31,7 +31,7 @@ namespace mbts.spark.VolSurface {
|
||||
MenuContext _context_menu;
|
||||
bool _is_selected;
|
||||
|
||||
public VolSurfaceRowContext(VolSurfaceSimplifiedGridVM parent, VolSurfaceDisplayGridExpiration exp) {
|
||||
public VolSurfaceRowContext(VolSurfaceGridVM parent, VolSurfaceDisplayGridExpiration exp) {
|
||||
_parent = parent;
|
||||
_exp = exp;
|
||||
_dispose = Disposable.Create(() => {
|
||||
@@ -93,7 +93,7 @@ namespace mbts.spark.VolSurface {
|
||||
|
||||
public string[] get_cell_clipboard_strings() =>
|
||||
new[] { _exp.ToString() }.Concat(
|
||||
_parent.columns.OfType<VolSurfaceSimplifiedColumn>()
|
||||
_parent.columns.OfType<VolSurfaceColumn>()
|
||||
.Skip(1)
|
||||
.Select(c => _parent.current_grid.read(_exp, c.volsurface_column)))
|
||||
.ToArray();
|
||||
@@ -112,11 +112,11 @@ namespace mbts.spark.VolSurface {
|
||||
internal class EditContext : ViewModelBase {
|
||||
readonly VolSurfaceDisplayGridColumn _col;
|
||||
readonly VolSurfaceDisplayGridExpiration _exp;
|
||||
readonly VolSurfaceSimplifiedGridVM _parent;
|
||||
readonly VolSurfaceGridVM _parent;
|
||||
string _current_value;
|
||||
int _tick_count;
|
||||
|
||||
public EditContext(VolSurfaceSimplifiedGridVM grid, VolSurfaceDisplayGridExpiration exp, VolSurfaceDisplayGridColumn column) {
|
||||
public EditContext(VolSurfaceGridVM grid, VolSurfaceDisplayGridExpiration exp, VolSurfaceDisplayGridColumn column) {
|
||||
_parent = grid;
|
||||
_exp = exp;
|
||||
_col = column;
|
||||
@@ -174,9 +174,9 @@ namespace mbts.spark.VolSurface {
|
||||
|
||||
public class MenuContext : ViewModelBase {
|
||||
readonly VolSurfaceRowContext _row;
|
||||
readonly VolSurfaceSimplifiedGridVM _parent;
|
||||
readonly VolSurfaceGridVM _parent;
|
||||
|
||||
VolSurfaceSimplifiedColumn _col;
|
||||
VolSurfaceColumn _col;
|
||||
DIYGridSuperHeader _supercol;
|
||||
|
||||
ICommand _revert_command;
|
||||
@@ -192,7 +192,7 @@ namespace mbts.spark.VolSurface {
|
||||
ICommand _import_csv_command;
|
||||
|
||||
public MenuContext(
|
||||
VolSurfaceSimplifiedGridVM parent,
|
||||
VolSurfaceGridVM parent,
|
||||
VolSurfaceRowContext row) {
|
||||
_parent = parent;
|
||||
_row = row;
|
||||
@@ -201,7 +201,7 @@ namespace mbts.spark.VolSurface {
|
||||
public string column_name => _col.volsurface_column.display_name;
|
||||
public string group_name => _supercol.FullHeader;
|
||||
public string expiration_name => _row.ToString();
|
||||
public VolSurfaceSimplifiedColumn column {
|
||||
public VolSurfaceColumn column {
|
||||
get => _col;
|
||||
set => Set(ref _col, value);
|
||||
}
|
||||
@@ -255,7 +255,7 @@ namespace mbts.spark.VolSurface {
|
||||
}
|
||||
}
|
||||
|
||||
public bool is_input_cell => _col.type == VolSurfaceSimplifiedColumnType.ReadWriteTick;
|
||||
public bool is_input_cell => _col.type == VolSurfaceColumnType.ReadWriteTick;
|
||||
|
||||
public ICommand main_settings_command => _parent.main_settings_command;
|
||||
public ICommand advanced_settings_command => _parent.advanced_settings_command;
|
||||
|
||||
@@ -112,11 +112,11 @@ namespace mbts.spark {
|
||||
// }
|
||||
// }));
|
||||
};
|
||||
grid = new VolSurfaceSimplifiedGridVM(this, _model, _grid_settings.hidden_cols(), new HashSet<VolSurfaceExpiration>(startup_data.hidden_exps ?? Enumerable.Empty<VolSurfaceExpiration>()));
|
||||
grid = new VolSurfaceGridVM(this, _model, _grid_settings.hidden_cols(), new HashSet<VolSurfaceExpiration>(startup_data.hidden_exps ?? Enumerable.Empty<VolSurfaceExpiration>()));
|
||||
grid.on_selection_changed += _on_grid_selection_changed;
|
||||
}
|
||||
|
||||
public VolSurfaceSimplifiedGridVM grid { get; private set; }
|
||||
public VolSurfaceGridVM grid { get; private set; }
|
||||
public VolSurfaceGraphVM vol_curve_vm { get; private set; }
|
||||
public VolTermsGraphVM vol_terms_vm { get; private set; }
|
||||
public VolSurfaceMacroActionsVM macro_actions { get; private set; }
|
||||
|
||||
Reference in new issue
Block a user