public void RemoveChild(LayersTreeViewItem item)
 {
     // Fix memory leak. http://www.ranorex.com/forum/memory-leak-in-target-silverlight-app-via-automatonpeer-objs-t6963.html
     // The item will be kept in memory up to 3 minutes after being reomved.
     item.RelatedLayer = null;
     ChildItems.Remove(item);
 }
Beispiel #2
0
        //public int GetTextsToRoot()
        //{
        //    foreach (var child in ChildItems)
        //        if (child.HasData)
        //            return 1;
        //        else
        //            return child.GetTextsToRoot()
        //    return this.ParentItem.GetTextsToRoot().Append(this.Text);
        //}


        public ModelTreeItem VirtualizeChildrenByTextPrefix(string virtualNodeText, string textPrefix)
        {
            var           selectedChildren = ChildItems.Where(c => c.Text.StartsWith(textPrefix)).ToArray();
            ModelTreeItem newNode          = new ModelTreeItem(this.Level + 1, virtualNodeText, imageFunc: this._ImageFunc)
            {
                IsVirtual = true, ParentItem = this
            };

            if (!selectedChildren.Any())
            {
                return(newNode);
            }

            //int oldIndexInChildItems = this.ChildItems.IndexOf(selectedChildren.First());

            foreach (var selectedChild in selectedChildren)
            {
                ChildItems.Remove(selectedChild);
                selectedChild.ParentItem = newNode;
                selectedChild.IncreaseLevelRecursive(1);
                newNode.ChildItems.Add(selectedChild);
            }

            //this.ChildItems.Insert(oldIndexInChildItems, newNode);
            this.ChildItems.Add(newNode);
            return(newNode);
        }
Beispiel #3
0
        /// <summary>
        /// 更新组下所有设备的参数 位置  增删改等
        /// </summary>
        private void UpdateChildPara()
        {
            var child = Wlst.Sr.SlusglInfoHold.Services.SluSglFieldGrpHold.MySlef.Get(NodeId);

            if (child == null)
            {
                this.ChildItems.Clear();
                return;
            }
            var lst = (from t in child where t.CtrlLst.Count > 0 select t.GrpId).ToList();

            //delete
            var dlt = (from t in ChildItems where lst.Contains(t.NodeId) == false select t).ToList();

            foreach (var f in dlt)
            {
                if (ChildItems.Contains(f))
                {
                    ChildItems.Remove(f);
                }
            }

            var dic = new List <int>();

            //update setinfo
            foreach (var f in ChildItems)
            {
                f.UpdateShowInfo();
                dic.Add(f.NodeId);
            }

            //newadd
            foreach (var f in lst)
            {
                if (dic.Contains(f))
                {
                    continue;
                }
                ChildItems.Add(new FieldGrpNodeItem(NodeId, f));
            }
            this.Sort(lst);

            ////add  and  sort
            //for (int i = 0; i < lst.Count; i++)
            //{
            //    int cur = lst[i];
            //    if (ChildItems.Count < i + 1) ChildItems.Add(dic[cur]);
            //    else if (ChildItems[i].NodeId != cur) ChildItems.Insert(i, dic[cur]);
            //}

            //for (int i = ChildItems.Count - 1; i >= 0; i--)
            //{
            //    if (ChildItems[i].ChildItems.Count == 0) ChildItems.RemoveAt(i);
            //}
        }
        public void Sort(List <int> sortlst)
        {
            var slsdfs = (from t in ChildItems where sortlst.Contains(t.NodeId) select t.NodeId).ToList();
            var st     = (from t in sortlst where slsdfs.Contains(t) select t).Distinct().ToList();
            var notex  = (from t in ChildItems where st.Contains(t.NodeId) == false select t).ToList();

            foreach (var f in notex)
            {
                if (ChildItems.Contains(f))
                {
                    ChildItems.Remove(f);
                }
            }


            for (int i = 0; i < ChildItems.Count; i++)
            {
                if (ChildItems[i].NodeId == st[i])
                {
                    continue;
                }
                foreach (var l in ChildItems)
                {
                    if (l.NodeId == st[i])
                    {
                        var tmp = l;
                        ChildItems.Remove(l);
                        ChildItems.Insert(i, tmp);
                        break;
                    }
                }
            }
            foreach (var f in notex)
            {
                ChildItems.Add(f);
            }
        }
Beispiel #5
0
        private void UpdateChildPara()
        {
            var allgrp = this.ChildItems[0];

            allgrp.SortIndex = 0;
            //allgrp.UpdateShowInfo();

            var spegrp = this.ChildItems[ChildItems.Count - 1];

            spegrp.SortIndex = 99999;

            //spegrp.UpdateShowInfo();



            var grpLst =
                (from t in Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.InfoGroups
                 where t.Key.Item1 == AreaId
                 orderby t.Value.Index
                 select t.Value.GroupId).ToList();

            //var tmlLst =
            //       (from t in Wlst.Sr.SlusglInfoHold.Services.SluSglFieldHold.MySlef.Info
            //        where t.Value.AreaId == AreaId && lstneworder.Contains(t.Key)
            //        select t.Key).ToList();


            //delete
            var dlt = (from t in ChildItems where t.NodeId != 0 && grpLst.Contains(t.NodeId) == false select t).ToList();

            foreach (var f in dlt)
            {
                if (ChildItems.Contains(f))
                {
                    ChildItems.Remove(f);
                }
            }


            //update setinfo
            foreach (var f in ChildItems)
            {
                f.UpdateShowInfo();
            }



            //newadd
            var ex     = (from t in ChildItems select t.NodeId).ToList();
            var newadd = (from t in grpLst where ex.Contains(t) == false select t).ToList();

            foreach (var f in newadd)
            {
                ChildItems.Add(new RtuGrpItem(AreaId, f, 2));
            }

            grpLst.Insert(0, 0);
            grpLst.Add(99999);
            this.Sort(grpLst);


            ////sort
            //var dic = new Dictionary<int, int>();
            //for (int i = 0; i <= grpLst.Count; i++)
            //{
            //    if (dic.ContainsKey(grpLst[i]) == false) dic.Add(grpLst[i], i + 3);
            //}
            //foreach (var f in ChildItems)
            //{
            //    if (dic.ContainsKey(f.NodeId)) f.SortIndex = dic[f.NodeId];
            //}

            //this.ChildItems = (from t in ChildItems orderby t.SortIndex ascending select t).ToList();

            for (int i = ChildItems.Count - 1; i >= 0; i--)
            {
                if (ChildItems[i].ChildItems.Count == 0)
                {
                    ChildItems.RemoveAt(i);
                }
            }
        }
Beispiel #6
0
        //1、区域,2、分组,3、全部设备,4、特殊设备
        private void UpdateChildPara()
        {
            var lstneworder = new List <int>();

            if (NodeType == 2) //grp
            {
                var grp = Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.GetGroupInfomation(AreaId,
                                                                                                             NodeId);
                if (grp != null)
                {
                    lstneworder =
                        Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.GetRtuOrGrpIndex(grp.LstTml);
                }
            }

            if (NodeType == 3) //all
            {
                var grp = Wlst.Sr.EquipmentInfoHolding.Services.AreaInfoHold.MySlef.GetAreaInfo(AreaId);
                if (grp != null)
                {
                    var gprs =
                        Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.GetRtuOrGrpIndex(grp.LstTml,
                                                                                                         AreaId, true);

                    foreach (var f in gprs.Item1)
                    {
                        lstneworder.AddRange(gprs.Item1);
                    }
                    lstneworder.AddRange(
                        Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.GetRtuOrGrpIndex(gprs.Item2));
                }
            }
            if (NodeType == 4) //spe
            {
                var grp = Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.GetRtuNotInAnyGroup(AreaId);
                if (grp.Count == 0)
                {
                    return;
                }
                lstneworder.AddRange(
                    Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.GetRtuOrGrpIndex(grp));
            }
            if (NodeType >= 2 && NodeType <= 4)
            {
                var tmlLst =
                    (from t in Wlst.Sr.SlusglInfoHold.Services.SluSglInfoHold.MySlef.Info
                     where t.Value.AreaId == AreaId && lstneworder.Contains(t.Key)
                     select t.Key).ToList();


                //delete
                var dlt = (from t in ChildItems where tmlLst.Contains(t.NodeId) == false select t).ToList();
                foreach (var f in dlt)
                {
                    if (ChildItems.Contains(f))
                    {
                        ChildItems.Remove(f);
                    }
                }

                var dic = new List <int>();
                //update setinfo
                foreach (var f in ChildItems)
                {
                    f.UpdateShowInfo();
                    dic.Add(f.NodeId);
                }

                //newadd
                foreach (var f in tmlLst)
                {
                    if (dic.Contains(f))
                    {
                        continue;
                    }
                    ChildItems.Add(new FieldNodeItem(f));
                }
                this.Sort(tmlLst);


                ////add  and  sort
                //for (int i = 0; i < tmlLst.Count; i++)
                //{
                //    int cur = tmlLst[i];
                //    if (ChildItems.Count < i + 1) ChildItems.Add(dic[cur]);
                //    else if (ChildItems[i].NodeId != cur) ChildItems.Insert(i, dic[cur]);
                //}
            }

            for (int i = ChildItems.Count - 1; i >= 0; i--)
            {
                if (ChildItems[i].ChildItems.Count == 0)
                {
                    ChildItems.RemoveAt(i);
                }
            }
        }