public override bool Equals(object obj) { Node objNode = (Node)obj; if (!Parent.Equals(objNode.Parent)) { return(false); } if (!LeftChildren.Equals(objNode.LeftChildren)) { return(false); } if (!RightChildren.Equals(objNode.RightChildren)) { return(false); } return(true); }
public MindMapRoot(string title, IEnumerable <XElement> content) { Title = title; Content = new ReactiveList <XElement>(content); var subscription = Children.Changed.Subscribe(x => { using (var leftSupression = LeftChildren.SuppressChangeNotifications()) using (var rightSupression = RightChildren.SuppressChangeNotifications()) { LeftChildren.Clear(); RightChildren.Clear(); int halfway = Children.Count / 2; for (int i = 0; i < Children.Count; i++) { var mindMapElement = Children[i]; if (i <= halfway) { RightChildren.Add(mindMapElement); } else { LeftChildren.Add(mindMapElement); } } } }); _subscriptions.Add(subscription); var hasSelectedItem = this.WhenAnyValue(x => x.SelectedElement).Select(x => x != null); AddChild = ReactiveCommand.Create(DoAddChild); DeleteChild = ReactiveCommand.Create(DoDeleteChild, hasSelectedItem); var selectedElementDepth = this.WhenAnyValue(x => x.SelectedElement).Select(x => x?.Depth ?? -1); var canPromote = selectedElementDepth.Select(x => x > 1); PromoteSelectedElement = ReactiveCommand.Create(DoPromoteSelectedElement, canPromote); var canDemote = this.WhenAnyValue(x => x.SelectedElement).Select(x => { if (x == null) { return(false); } return(x.Index > 0 && x.Index < x.Parent.Children.Count - 1); }); DemoteSelectedElement = ReactiveCommand.Create(DoDemoteSelectedElement, canDemote); var selectedElementIndex = this.WhenAnyValue(x => x.SelectedElement).Select(x => x?.Index ?? -1); var canMoveUp = selectedElementIndex.Select(x => x > 0); MoveUpSelectedElement = ReactiveCommand.Create(DoMoveUpSelectedElement, canMoveUp); var canMoveDown = selectedElementIndex.Select(x => x != -1 && SelectedElement.Parent.Children.Count > x); MoveDownSelectedElement = ReactiveCommand.Create(DoMoveDownSelectedElement, canMoveDown); }