| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 | using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.ComponentModel;using System.Linq;namespace PRSDesktop{        public class DocumentSetNode : INotifyPropertyChanged    {        private DocumentSetNodes _owner = null;                public ObservableCollection<DocumentSetNode> Children => _owner.GetChilden(_id);                private Guid _id;        public Guid ID         {            get { return _id; }            set            {                _id = value;                RaisedOnPropertyChanged("ID");            }        }                private Guid _parent;        public Guid Parent         {            get { return _parent; }            set            {                _parent = value;                RaisedOnPropertyChanged("Parent");            }        }                private string _description;        public string Description        {            get { return _description; }            set            {                _description = value;                RaisedOnPropertyChanged("Description");            }        }                        private string _details;        public string Details        {            get { return _details; }            set            {                _details = value;                RaisedOnPropertyChanged("Details");            }        }                public Dictionary<String,String> Blocks { get; private set; }                public event PropertyChangedEventHandler PropertyChanged;        public void RaisedOnPropertyChanged(string propertyName)        {            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));        }        public DocumentSetNode(DocumentSetNodes owner)        {            _owner = owner;            Blocks = new Dictionary<String,String>();            foreach (var column in owner.Columns)                Blocks[column] = "";        }                public DocumentSetNode(DocumentSetNodes owner, Guid id, Guid parent) : this(owner)        {            _id = id;            _parent = parent;        }    }    public class DocumentSetNodes     {        private List<DocumentSetNode> _nodes = null;        public ObservableCollection<DocumentSetNode> Nodes => new ObservableCollection<DocumentSetNode>(_nodes.Where(x=>x.Parent == Guid.Empty));        public IEnumerable<String> Columns { get; private set; }                public DocumentSetNodes(IEnumerable<String> columns)        {            _nodes = new List<DocumentSetNode>();            Columns = columns;        }        public DocumentSetNode Add(Guid id, Guid parent)        {            var node = new DocumentSetNode(this, id, parent);            _nodes.Add(node);            return node;        }        public ObservableCollection<DocumentSetNode> GetChilden(Guid id)        {            return new ObservableCollection<DocumentSetNode>(_nodes.Where(x => x.Parent.Equals(id) && (x.ID != id)));        }          public DocumentSetNode? GetNode(Guid id)        {            return _nodes.FirstOrDefault(x => x.ID == id);        }            }}
 |