AlgoStudioVM - remove unused 'save_op_begin/end' events
This commit is contained in:
1 parent
938cd9064c
commit
04cc3e8747
2 files changed
-30
No files matched your search
@@ -43,33 +43,10 @@ namespace mbts.ui.spark {
|
||||
class Controller : IAlgoStudioViewController {
|
||||
readonly AlgoStudioVM _vm;
|
||||
readonly TreeView _tree_view;
|
||||
/// During a save op, unpersisted items may be replaced with persisted ones.
|
||||
/// Consequently, the the selection state will be lost if an unpersisted item was selected.
|
||||
/// When a save op begins the selected indices are stored in the field below, so that when it ends, the new persisted items can be reselected
|
||||
/// Note: <see cref="_vm"/> is reponsible for inserting the new items in the proper index.
|
||||
(int? selected_def_index, int? selected_tmp_index)? _active_save_op;
|
||||
|
||||
public Controller(AlgoStudioVM vm, TreeView tree_view) {
|
||||
_vm = vm;
|
||||
_tree_view = tree_view;
|
||||
_vm.save_op_started += _vm_save_op_started;
|
||||
_vm.save_op_ended += _vm_save_op_ended;
|
||||
}
|
||||
|
||||
void _vm_save_op_started() =>
|
||||
_active_save_op = AlgoPersistenceHelper.selection_snapshot(_vm.definitions, _vm.selected_definition, _vm.selected_template);
|
||||
|
||||
void _vm_save_op_ended() {
|
||||
if (_active_save_op.HasValue) {
|
||||
(int? def_index, int? tmp_index) = _active_save_op.Value;
|
||||
if (def_index is int di && _vm.definitions.check_index(di)) {
|
||||
var new_def = _vm.definitions[di];
|
||||
if (tmp_index is int ti && new_def.templates.check_index(ti)) {
|
||||
select_template(new_def.templates[ti]);
|
||||
} else select_definition(new_def);
|
||||
}
|
||||
_active_save_op = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void add_definition() {
|
||||
|
||||
@@ -107,15 +107,8 @@ namespace mbts.spark {
|
||||
}
|
||||
}
|
||||
|
||||
public event Action save_op_started, save_op_ended;
|
||||
event Action<(AlgoDefinitionVM definition, AlgoDefinitionTemplateVM template)> _selected_changed;
|
||||
|
||||
void blah() {
|
||||
save_op_ended?.Invoke();
|
||||
save_op_started?.Invoke();
|
||||
|
||||
}
|
||||
|
||||
public ObservableCollection<AlgoDefinitionVM> definitions => _definitions;
|
||||
public AlgoDefinitionVM selected_definition { get => _selected_definition.Value; set => _selected_definition.set(value); }
|
||||
public AlgoDefinitionTemplateVM selected_template { get => _selected_template.Value; set => _selected_template.set(value); }
|
||||
|
||||
Reference in new issue
Block a user