Exemple #1
0
        public JisonsTreeIter <T> AddTreeViewItem(JisonsTreeIter <T> parent, T data)
        {
            this.IsDoSelf = true;
            var jti = this.TreeView.AddViewItem(parent.TreeIter, data);

            this.IsDoSelf = false;
            return(jti);
        }
Exemple #2
0
        public void AddJisonsTreeIterToParent(JisonsTreeIter <T> jiter)
        {
            var parentjisonstree = GetParentJisonsTreeIter(jiter);

            if (parentjisonstree != null && RootTreeIter.GetTreeViewChildren(parentjisonstree.Data) != null &&
                this.RootTreeIter.GetTreeViewChildren(parentjisonstree.Data).FirstOrDefault(i => this.RootTreeIter.GetTreeViewChildren(i).Equals(this.RootTreeIter.GetTreeViewChildren(jiter.Data))) == null)
            {
                this.RootTreeIter.GetTreeViewChildren(parentjisonstree.Data).Add(jiter.Data);
            }
        }
Exemple #3
0
        /// <summary> 获取指定节点所具有的所有子级数据 JisonsTreeIter<T> </summary>
        /// <param name="jiter"></param>
        /// <returns></returns>
        public IEnumerable <JisonsTreeIter <T> > GetAllChilerenTreeIters(JisonsTreeIter <T> jiter)
        {
            var children = this.RootTreeIter.GetTreeViewChildren(jiter.Data);

            if (children != null && children.Count != 0)
            {
                foreach (var item in this.RootTreeIter.GetTreeViewChildren(jiter.Data))
                {
                    foreach (var jti in GetAllChilerenTreeIters(this.GetJisonsTreeIter(item)))
                    {
                        yield return(jti);
                    }
                }
            }

            yield return(jiter);
        }
Exemple #4
0
        /// <summary> 创建子项模版 </summary>
        /// <param name="parent"></param>
        /// <param name="viewdata"></param>
        /// <param name="iscreatself"></param>
        private void CreateViewTreeItem(TreeIter parent, T viewdata, JisonsTreeIter <T> jiterself = null)
        {
            if (jiterself == null)
            {
                jiterself = this.AddViewItem(parent, viewdata);
            }

            if (jiterself != null && this.RootTreeIter.GetTreeViewChildren(viewdata) != null)
            {
                foreach (var childitem in this.RootTreeIter.GetTreeViewChildren(viewdata))
                {
                    if (childitem != null)
                    {
                        CreateViewTreeItem(jiterself.TreeIter, childitem);
                    }
                }
            }
        }
Exemple #5
0
        public bool DeleteJisonsTreeIter(JisonsTreeIter <T> jiter)
        {
            if (JisonsTreeIters.Contains(jiter))
            {
                var items = GetAllChilerenTreeIters(jiter);
                foreach (var item in items)
                {
                    if (item != null)
                    {
                        JisonsTreeIters.Remove(item);
                    }
                }

                var deletetreeiter = jiter.TreeIter;
                return(this.TreeStore.Remove(ref deletetreeiter));
            }
            return(false);
        }
Exemple #6
0
        public JisonsTreeIter <T> AddViewItem(TreeIter parent, T data, int position = -1)
        {
            if (!this.RootTreeIter.CanAddViewItem(data))
            {
                return(null);
            }

            var insertiter = parent.Equals(TreeIter.Zero) ? this.TreeStore.AppendNode() : this.TreeStore.InsertNode(parent, position);
            var jiter      = new JisonsTreeIter <T>(data, insertiter);

            this.TreeStore.SetValues(insertiter, this.RootTreeIter.GetData(data).Values);

            JisonsTreeIters.Add(jiter);


            var expand = this.GetParentExpand(data);

            if (expand)
            {
                // 展开父级
                var jtiparent = this.RootTreeIter.GetParentPart(data);
                if (jtiparent != null)
                {
                    bool isexpanded = this.RootTreeIter.GetExpanded(jtiparent);
                    if (isexpanded)
                    {
                        this.ExpandToPath(this.GetTreePath(jiter.TreeIter));
                    }
                }
            }

            //展开子集
            //bool isexpanded = this.RootTreeIter.GetExpanded(jiter.Data);
            //if (isexpanded)
            //{
            //    this.ExpandToPath(this.GetTreePath(jiter.TreeIter));
            //}

            return(jiter);
        }
Exemple #7
0
        public JisonsTreeIter <T> GetParentJisonsTreeIter(JisonsTreeIter <T> jti)
        {
            var parent = this.GetParentTreeIter(jti.TreeIter);

            return(this.GetJisonsTreeIter(parent));
        }
Exemple #8
0
 public void DeleteTreeViewItem(JisonsTreeIter <T> jti)
 {
     this.IsDoSelf = true;
     this.TreeView.DeleteViewItem(jti.TreeIter);
     this.IsDoSelf = false;
 }