auto close popup when no orders remain
This commit is contained in:
1 parent
ac88586c8f
commit
d18caa7ba1
2 files changed
+30
-11
No files matched your search
@@ -34,6 +34,7 @@ namespace mbts.spark {
|
||||
readonly IWindowSettingsManager<OrderBookGridSettings> _settings_manager;
|
||||
readonly List<IDisposable> _resources;
|
||||
OrderBookStartupData _state;
|
||||
bool _is_row_collection_populated;
|
||||
|
||||
public OrderBookVM(IObservable<string> owner_title, IBus bus, INotificationService notification_service, OrdersModel model, IWindowSettingsManager<OrderBookGridSettings> settings_manager, bool rows_are_initially_expanded = false) {
|
||||
_bus = bus;
|
||||
@@ -43,6 +44,7 @@ namespace mbts.spark {
|
||||
// we use an ObservableAppendCollection b/c the mini-ob needs a cancel column at the front
|
||||
columns = new ObservableAppendCollection<DIYGrid.ColumnBase>(_columns);
|
||||
_row_collection = new OrderBookRowCollection(ort => new OrderBookRowVM(this, ort, rows_are_initially_expanded), _columns.get_sorting_data().comparer) { filter = _columns.get_filter() };
|
||||
_row_collection.CollectionChanged += _row_collection_CollectionChanged;
|
||||
_current_row = backing<OrderBookRowVM>(nameof(current_row));
|
||||
_columns.filter_changed += on_filter_changed;
|
||||
collapse_all_rows_command = new DelegateCommand(_row_collection.collapse_all);
|
||||
@@ -53,6 +55,7 @@ namespace mbts.spark {
|
||||
grid_settings_manager,
|
||||
Disposable.Create(() => {
|
||||
_columns.filter_changed -= on_filter_changed;
|
||||
_row_collection.CollectionChanged -= _row_collection_CollectionChanged;
|
||||
Disposable.dispose(_row_collection);
|
||||
}),
|
||||
_columns
|
||||
@@ -63,6 +66,10 @@ namespace mbts.spark {
|
||||
void on_filter_changed() => _row_collection.filter = _columns.get_filter();
|
||||
}
|
||||
|
||||
private void _row_collection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) {
|
||||
is_row_collection_populated = _row_collection.Count != 0;
|
||||
}
|
||||
|
||||
public event Action<OrderRecordImmutable?> selected_order_changed;
|
||||
public event Action<bool> OnDisposed;
|
||||
|
||||
@@ -76,6 +83,16 @@ namespace mbts.spark {
|
||||
public ICommand collapse_all_rows_command { get; }
|
||||
public ICommand expand_all_rows_command { get; }
|
||||
|
||||
public bool is_row_collection_populated {
|
||||
get => _is_row_collection_populated;
|
||||
set {
|
||||
if (value != _is_row_collection_populated) {
|
||||
_is_row_collection_populated = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void row_selection_changed(SelectionChangedEventArgs e) {
|
||||
if (e.RemovedItems != null) {
|
||||
foreach (var row_vm in e.RemovedItems.Cast<OrderBookRowVM>()) {
|
||||
|
||||
@@ -130,20 +130,22 @@ namespace mbts.spark {
|
||||
// create the new popup window in here
|
||||
var obvm = order.orderbook_vm;
|
||||
var view = new MiniOrderBookView(obvm);
|
||||
var popup = new System.Windows.Controls.Primitives.Popup();
|
||||
// we only keep the obvm around assigned to the DataContext so that we can
|
||||
// properly Dispose of it later when the popup is closed.
|
||||
popup.DataContext = obvm;
|
||||
popup.Child = view;
|
||||
popup.StaysOpen = false;
|
||||
popup.PlacementTarget = popup_placement_target;
|
||||
popup.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
|
||||
popup.VerticalOffset = 5;
|
||||
popup.IsOpen = true;
|
||||
var popup = new System.Windows.Controls.Primitives.Popup {
|
||||
// we only keep the obvm around assigned to the DataContext so that we can
|
||||
// properly Dispose of it later when the popup is closed.
|
||||
DataContext = obvm,
|
||||
Child = view,
|
||||
StaysOpen = false,
|
||||
PlacementTarget = popup_placement_target,
|
||||
Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom,
|
||||
VerticalOffset = 5
|
||||
};
|
||||
popup.SetBinding(System.Windows.Controls.Primitives.Popup.IsOpenProperty,
|
||||
nameof(OrderBookVM.is_row_collection_populated)
|
||||
);
|
||||
popup.Closed += (sender, event_args) => (popup.DataContext as IDisposable)?.Dispose();
|
||||
b.Popup = popup;
|
||||
|
||||
|
||||
// close context menu after command executed
|
||||
//if (curr_order != null) {
|
||||
// Action command_executed = null;
|
||||
|
||||
Reference in new issue
Block a user