private void AddContextMenuToTreeView(TreeViewBase treeView) { treeView.RightClickMenuRequested = () => { var menu = new GenericMenu(); menu.AddItem(new GUIContent("Create"), false, () => _rightClickCreateMenuClickedSubject.OnNext(Empty.Default)); if (treeView.HasSelection() && treeView.GetRows().Count >= 2) { menu.AddItem(new GUIContent("Remove"), false, () => _rightClickRemoveMenuClickedSubject.OnNext(Empty.Default)); } else { menu.AddDisabledItem(new GUIContent("Remove")); } return(menu); }; }
public static IObservable <IList <int> > OnSelectionChangedAsObservable(this TreeViewBase self) { return(new AnonymousObservable <IList <int> >(observer => { void OnNext(IList <int> ids) { try { observer.OnNext(ids); } catch (Exception e) { observer.OnError(e); } } self.OnSelectionChanged += OnNext; return new Disposable(() => self.OnSelectionChanged -= OnNext); })); }
public static IObservable <Empty> OnItemClearedAsObservable(this TreeViewBase self) { return(new AnonymousObservable <Empty>(observer => { void OnNext() { try { observer.OnNext(Empty.Default); } catch (Exception e) { observer.OnError(e); } } self.OnItemsCleared += OnNext; return new Disposable(() => self.OnItemsCleared -= OnNext); })); }
public static IObservable <TreeViewItem> OnItemRemovedAsObservable(this TreeViewBase self) { return(new AnonymousObservable <TreeViewItem>(observer => { void OnNext(TreeViewItem item) { try { observer.OnNext(item); } catch (Exception e) { observer.OnError(e); } } self.OnItemRemoved += OnNext; return new Disposable(() => self.OnItemRemoved -= OnNext); })); }