public void Setup(EntryRulesEditorWindow window) { ClearDisposables(); _window = window; _treeView = window.TreeView; _entryRulesService.HasUnsavedChanges.Subscribe(OnUnsavedFlagChanged).DisposeWith(_disposables); var rules = _entryRulesService.GetState(); rules.ObservableAdd.Subscribe(x => OnRuleAdded(x.Value)).DisposeWith(_disposables); rules.ObservableRemove.Subscribe(x => OnRuleRemoved(x.Value)).DisposeWith(_disposables); rules.ObservableClear.Subscribe(x => OnRuleCleared()).DisposeWith(_disposables); foreach (var rule in rules) { AddTreeViewItem(rule); } }
public void Setup(EntryRulesEditorWindow window) { ClearDisposables(); _window = window; _treeView = window.TreeView; _window.SaveButtonClickedAsObservable.Subscribe(_ => OnSaveButtonClicked()).DisposeWith(_disposables); _window.SaveShortcutExecutedAsObservable.Subscribe(_ => OnSaveShortcutExecuted()).DisposeWith(_disposables); _window.OnDisableExecuteAsObservable.Subscribe(_ => OnDisableExecuted()).DisposeWith(_disposables); _window.UndoShortcutExecutedAsObservable.Subscribe(_ => Undo()); _window.RedoShortcutExecutedAsObservable.Subscribe(_ => Redo()); _window.CreateButtonClickedAsObservable.Subscribe(_ => OnCreateButtonClicked()).DisposeWith(_disposables); _window.RightClickCreateMenuClickedAsObservable.Subscribe(_ => OnRightClickCreateMenuClicked()) .DisposeWith(_disposables); _window.RightClickRemoveMenuClickedAsObservable.Subscribe(_ => OnRightClickRemoveMenuClicked()) .DisposeWith(_disposables); _treeView.OnItemAddedAsObservable().Subscribe(OnTreeViewItemAdded).DisposeWith(_disposables); _treeView.OnItemRemovedAsObservable().Subscribe(OnTreeViewItemRemoved).DisposeWith(_disposables); _treeView.OnItemClearedAsObservable().Subscribe(OnTreeViewItemsCleared).DisposeWith(_disposables); }
private void OnEnable() { if (_treeViewState == null) { _treeViewState = new TreeViewState(); } TreeView = new EntryRulesEditorTreeView(_treeViewState); var menu = new GenericMenu(); menu.AddItem(new GUIContent("Create New"), false, () => _rightClickCreateMenuClickedSubject.OnNext(Empty.Default)); menu.AddItem(new GUIContent("Remove Selected"), false, () => _rightClickRemoveMenuClickedSubject.OnNext(Empty.Default)); menu.ShowAsContext(); TreeView.RightClickMenu = menu; _searchField = new TreeViewSearchField(TreeView); _compositionRoot = CompositionRoot.RequestInstance(); _controller = _compositionRoot.EntryRulesEditorController; _controller.Setup(this); _presenter = _compositionRoot.EntryRulesEditorPresenter; _presenter.Setup(this); }