Exemple #1
0
        private void AddUntouchedLoop(SectorConstrainedOSMAreaGraph map, List <Way> superLoop)
        {
            List <AreaNode> newNodes = new List <AreaNode>();
            var             broken   = BreakDownSuperLoop(superLoop);

            for (int i = 0; i < broken.Count - 1; i++) // since our loops end in a duplicate
            {
                AreaNode curr = new AreaNode()
                {
                    id = broken[i]
                };
                newNodes.Add(curr);
                if (!map.nodes.ContainsKey(broken[i]))
                {
                    map.nodes[broken[i]] = new List <AreaNode>();
                }
                map.nodes[broken[i]].Add(curr);
            }
            for (int i = 0; i < newNodes.Count; i++)
            {
                AreaNode prev = newNodes[i];
                AreaNode next = newNodes[(i + 1) % newNodes.Count];
                prev.next = next;
                next.prev = prev;
            }
        }
Exemple #2
0
    private void DoGetPersonTreeAsync(Action <AreaNode> callback)
    {
        Log.Info("GetPersonTreeAsync Start >>>>>>>>>>");
        var clet = GetServiceClient();
        //Debug.LogError("BeginGetPersonTreeAsync........");
        int view = 2; //0:基本数据; 1:设备信息; 2:人员信息; 3:设备信息 + 人员信息

        clet.BeginGetPhysicalTopologyTreeNode(view, (ar) =>
        {
            AreaNode result = null;
            try
            {
                LocationServiceClient client = ar.AsyncState as LocationServiceClient;
                //Debug.LogError("EndGetPersonTreeAsync........");
                result = client.EndGetPhysicalTopologyTreeNode(ar);
                client.Close();//异步方式用完Close
            }
            catch (Exception ex)
            {
                LogError("CommunicationObject", ex.ToString());
            }
            DoCallBack(callback, result);
            if (result == null)
            {
                LogError("GetPersonTreeAsync", "result == null");
            }
            Log.Info("GetPersonTreeAsync End <<<<<<<<");
        }, clet);
        //clet.Close();
    }
 private void RemoveEmptyNodes(AreaNode node)
 {
     try
     {
         if (node == null)
         {
             return;
         }
         if (node.Children != null)
         {
             for (int i = 0; i < node.Children.Count; i++)
             {
                 AreaNode subNode = node.Children[i];
                 if (subNode.IsSelftEmpty())
                 {
                     node.Children.RemoveAt(i);
                     i--;
                 }
                 else
                 {
                     RemoveEmptyNodes(subNode);
                     if (subNode.IsSelftEmpty())
                     {
                         node.Children.RemoveAt(i);
                         i--;
                     }
                 }
             }
         }
     }
     catch (System.Exception ex)
     {
         Log.Error(tag, "RemoveEmptyNodes", ex.ToString());
     }
 }
        /// <summary>
        /// 遍历并计算数量
        /// </summary>
        /// <param name="node"></param>
        private void SumNodeCount(AreaNode node)
        {
            if (node == null)
            {
                return;
            }
            if (node.Persons != null)
            {
                node.TotalPersonCount = node.Persons.Count;
            }
            if (node.LeafNodes != null)
            {
                node.TotalDevCount = node.LeafNodes.Count;
            }

            if (node.Children != null)
            {
                for (int i = 0; i < node.Children.Count; i++)
                {
                    AreaNode subNode = node.Children[i];
                    SumNodeCount(subNode);
                    node.TotalPersonCount += subNode.TotalPersonCount;
                    node.TotalDevCount    += subNode.TotalDevCount;
                }
            }
        }
Exemple #5
0
    /// <summary>
    /// 添加子节点
    /// </summary>
    /// <param name="topoNode"></param>
    /// <param name="treeNode"></param>
    public void AddNodes(AreaNode topoNode, TreeNode <TreeViewItem> treeNode)
    {
        treeNode.Nodes = new ObservableList <TreeNode <TreeViewItem> >();
        if (topoNode.Children != null)
        {
            foreach (AreaNode child in topoNode.Children)
            {
                var node = CreateTopoNode(child);
                treeNode.Nodes.Add(node);
                AddNodes(child, node);

                if (IsExpandAll)
                {
                    node.IsExpanded = true;
                }
            }
        }
        if (topoNode.Persons != null)//添加子节点的子节点
        {
            foreach (var child in topoNode.Persons)
            {
                var node = CreatePersonnalNode(child);
                if (node != null)
                {
                    treeNode.Nodes.Add(node);
                }
            }
        }
        if (topoNode.Persons != null)
        {
            SetParentNodepersonnelNum(treeNode.Parent, topoNode.Persons.Length);
        }
    }
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                for (int i = 0; i < m_OpenRows.Length; ++i)
                {
                    Row row = m_OpenRows[i];
                    if (row != null)
                    {
                        row.Release();
                    }
                }
                m_OpenRows = null;

                AreaNode area = m_FirstUnpartitionedArea;
                while (area != null)
                {
                    AreaNode temp = area.next;
                    area.Release();
                    area = temp;
                }
                m_FirstUnpartitionedArea = null;
            }
            else
            {
                UnityEngine.UIElements.DisposeHelper.NotifyMissingDispose(this);
            }

            disposed = true;
        }
Exemple #7
0
    /// <summary>
    /// Merges Nodes int the graph into a new node
    /// </summary>
    /// <param name="mergeNodeIDs">the nodes to be merged</param>
    /// <param name="newAreaTheyCreated">the area they craeated in the map, wiht the new id for the new node</param>
    public void MergeNodesIntoNewNode(List <uint> mergeNodeIDs, uint newNodeID)
    {
        // remove all edges that link to the nodes that need to be merged
        // and store nodes that have edges to this node
        // when they are not to be removed themself
        HashSet <uint> NodesThatHadEdgeToMergingNode = new HashSet <uint>();

        foreach (AreaNode nod in Graph.Values)
        {
            foreach (uint nodeToMergeID in mergeNodeIDs)
            {
                // remove edge and add to nodes that had edge if not already contained
                // or contained in nodes to merge
                if (nod.RemoveEdge(nodeToMergeID) &&
                    !mergeNodeIDs.Contains(nod.NodeID))
                {
                    NodesThatHadEdgeToMergingNode.Add(nod.NodeID);
                }
            }
        }
        int      color         = (int)Graph[mergeNodeIDs[0]].GetColor();
        AreaNode newMergedNode = new AreaNode(newNodeID, NodesThatHadEdgeToMergingNode, color);

        // remove all nodes that need to be merged
        foreach (uint nodeToMergeID in mergeNodeIDs)
        {
            Graph.Remove(nodeToMergeID);
        }
        Graph.Add(newNodeID, newMergedNode);
    }
Exemple #8
0
    /// <summary>
    /// 创建节点
    /// </summary>
    /// <param name="topoNode"></param>
    /// <returns></returns>
    private TreeNode <TreeViewItem> CreateTopoNode(AreaNode topoNode)
    {
        string title = topoNode.Name;

        if (topoNode.Persons != null)
        {
            title = string.Format("{0} ({1})", topoNode.Name, topoNode.Persons.Length);
        }
        Sprite icon = GetRoomIcon(topoNode);
        var    item = new TreeViewItem(title, icon);

        item.Tag = topoNode;
        var node = new TreeNode <TreeViewItem>(item);

        if (AreaDic.ContainsKey(topoNode.Id))
        {
            Debug.LogError(topoNode.Name);
        }
        else
        {
            AreaDic.Add(topoNode.Id, node);
        }

        return(node);
    }
Exemple #9
0
        /// <summary>
        /// Forward-match an area name
        /// </summary>
        /// <param name="ptr">source string, where we want to find an area name from</param>
        /// <param name="node">area tree object</param>
        /// <param name="curIndex">current index char in the 'ptr', which to be matched</param>
        /// <param name="result">match succeed -> matched string; otherwise the origin value of 'result'</param>
        public unsafe static void Area_Match(char *ptr, AreaNode node, ref int curIndex, ref string result)
        {
            char c = ptr[curIndex];

            if (c == '省' || c == '市' || c == '县')
            {
                result = String_Extract(ptr, curIndex);
                return;
            }

            if (!node.Areas.Any())
            {
                result = String_Extract(ptr, curIndex);
                return;
            }
            // (c != ' ' && !node.Areas.ContainsKey(c))
            if (c == '\0' || !node.Areas.ContainsKey(c) || curIndex > 5)
            {
                return;
            }


            curIndex++;
            Area_Match(ptr, node.Areas[c], ref curIndex, ref result);
        }
        /// <summary>
        /// Virtually expands the atlas from its initial size to its maximum size.
        /// </summary>
        /// <remarks>
        /// The areas are built by doubling horizontally and vertically, over and over. Consider the following example,
        /// where the initial atlas size is 64x64 and the maximum size is 256x256. The resulting 5 areas would be:
        /// 1: First area determined by the initial atlas size
        /// 2: Area generated by horizontal expansion
        /// 3: Area generated by vertical expansion
        /// 4: Area generated by horizontal expansion
        /// 5: Area generated by vertical expansion - final expansion
        ///  _______________________
        /// |                       |
        /// |                       |
        /// |           5           |
        /// |                       |
        /// |                       |
        /// |_______________________|
        /// |           |           |
        /// |     3     |           |
        /// |___________|     4     |
        /// |     |     |           |
        /// |  1  |  2  |           |
        /// |_____|_____|___________|
        ///
        /// Because of the exponential nature of this process, we don't need to worry about very large textures. For
        /// example, from 64x64 to 4096x4096, only 12 iterations are required, leading to 13 areas.
        /// </remarks>
        private void BuildAreas()
        {
            AreaNode current = m_FirstUnpartitionedArea;

            while (virtualWidth < maxAtlasSize || virtualHeight < maxAtlasSize)
            {
                RectInt newArea;
                if (virtualWidth > virtualHeight)
                {
                    // Double Vertically.
                    newArea        = new RectInt(0, virtualHeight, virtualWidth, virtualHeight);
                    virtualHeight *= 2;
                }
                else
                {
                    // Double Horizontally.
                    newArea       = new RectInt(virtualWidth, 0, virtualWidth, virtualHeight);
                    virtualWidth *= 2;
                }

                var newAreaNode = AreaNode.Acquire(newArea);
                newAreaNode.AddAfter(current);
                current = newAreaNode;
            }
        }
        /// <summary>
        /// 遍历并计算数量
        /// </summary>
        /// <param name="node"></param>
        private void SumNodeCount(AreaNode node)
        {
            try
            {
                if (node == null)
                {
                    return;
                }
                if (node.Persons != null)
                {
                    node.TotalPersonCount = node.Persons.Count;
                }
                if (node.LeafNodes != null)
                {
                    node.TotalDevCount = node.LeafNodes.Count;
                }

                if (node.Children != null)
                {
                    for (int i = 0; i < node.Children.Count; i++)
                    {
                        AreaNode subNode = node.Children[i];
                        SumNodeCount(subNode);
                        node.TotalPersonCount += subNode.TotalPersonCount;
                        node.TotalDevCount    += subNode.TotalDevCount;
                    }
                }
            }
            catch (System.Exception ex)
            {
                Log.Error(tag, "SumNodeCount", ex.ToString());
            }
        }
Exemple #12
0
    /// <summary>
    /// 获取区域数据
    /// </summary>
    public void GetTopoTree(Action callback)
    {
        if (isRefresh)
        {
            return;
        }
        isRefresh = true;

        CommunicationObject.Instance.GetPersonTree((topoRoot) =>
        {
            isRefresh = false;
            if (topoRoot == null)
            {
                return;
            }

            rootAreaNode = topoRoot;
            StructureTree(topoRoot);
            if (PersonList == null)
            {
                PersonList = new List <PersonNode>();
            }
            PersonList = GetPersonNode(topoRoot);
            if (callback != null)
            {
                callback();
            }
        });
    }
 private void SetChildrenNull(AreaNode node)
 {
     try
     {
         if (node == null)
         {
             return;
         }
         if (node.Children != null)
         {
             foreach (var subNode in node.Children)
             {
                 SetChildrenNull(subNode);
             }
             if (node.Children != null && node.Children.Count == 0)
             {
                 node.Children = null;
             }
             if (node.Persons != null && node.Persons.Count == 0)
             {
                 node.Persons = null;
             }
             if (node.LeafNodes != null && node.LeafNodes.Count == 0)
             {
                 node.Children = null;
             }
         }
     }
     catch (System.Exception ex)
     {
         Log.Error(tag, "SetChildrenNull", ex.ToString());
     }
 }
Exemple #14
0
 private void SetChildrenNull(AreaNode node)
 {
     if (node == null)
     {
         return;
     }
     if (node.Children != null)
     {
         foreach (var subNode in node.Children)
         {
             SetChildrenNull(subNode);
         }
         if (node.Children != null && node.Children.Count == 0)
         {
             node.Children = null;
         }
         if (node.Persons != null && node.Persons.Count == 0)
         {
             node.Persons = null;
         }
         if (node.LeafNodes != null && node.LeafNodes.Count == 0)
         {
             node.Children = null;
         }
     }
 }
Exemple #15
0
    /// <summary>
    /// 编辑区域: 新增区域时,添加树子节点
    /// </summary>
    /// <param name="areaid"></param>
    /// <param name="childp"></param>
    public void RemoveAreaChild(int areaid)
    {
        TreeNode <TreeViewItem> treeNode = PersonnelTreeManage.Instance.FindAreaNode(areaid);

        AreaNode areaNode       = (AreaNode)treeNode.Item.Tag;
        AreaNode parentAreaNode = null;

        if (areaNode.ParentId == 2)//当等于2时,就是四会电厂区域根节点
        {
            parentAreaNode = rootAreaNode;
        }
        else
        {
            if (treeNode.Parent.Item != null && treeNode.Parent.Item.Tag != null)
            {
                parentAreaNode = (AreaNode)treeNode.Parent.Item.Tag;
            }
        }
        if (parentAreaNode != null)
        {
            List <AreaNode> areaNodeChildrenList = new List <AreaNode>(parentAreaNode.Children);

            //if(areaNodeChildrenList.)
            AreaNode areaNodeT = areaNodeChildrenList.Find((i) => i.Id == areaid);
            if (areaNodeT != null)
            {
                areaNodeChildrenList.Remove(areaNodeT);
            }
            parentAreaNode.Children = areaNodeChildrenList.ToArray();
        }
        treeNode.Parent.Nodes.Remove(treeNode);
    }
Exemple #16
0
        /// <param name="initialAtlasSize">Initial size of the atlas (POT).</param>
        /// <param name="maxAtlasSize">Maximum size of the atlas (POT).</param>
        public UIRAtlasAllocator(int initialAtlasSize, int maxAtlasSize, int sidePadding = 1)
        {
            // Validate Size Coherence.
            Assert.IsTrue(initialAtlasSize > 0 && initialAtlasSize <= maxAtlasSize);

            // Validate POT
            Assert.IsTrue(initialAtlasSize == Mathf.NextPowerOfTwo(initialAtlasSize));
            Assert.IsTrue(maxAtlasSize == Mathf.NextPowerOfTwo(maxAtlasSize));

            m_1SidePadding    = sidePadding;
            m_2SidePadding    = sidePadding << 1;
            this.maxAtlasSize = maxAtlasSize;
            maxImageWidth     = maxAtlasSize;
            maxImageHeight    = (initialAtlasSize == maxAtlasSize) ? maxAtlasSize / 2 + m_2SidePadding : maxAtlasSize / 4 + m_2SidePadding;
            virtualWidth      = initialAtlasSize;
            virtualHeight     = initialAtlasSize;

            int maxOpenRows = GetLog2OfNextPower(maxAtlasSize) + 1;

            m_OpenRows = new Row[maxOpenRows];

            var area = new RectInt(0, 0, initialAtlasSize, initialAtlasSize);

            m_FirstUnpartitionedArea = AreaNode.Acquire(area);
            BuildAreas();
        }
Exemple #17
0
    /// <summary>
    /// 编辑区域: 新增区域时,添加树子节点
    /// </summary>
    /// <param name="parentAreaid"></param>
    /// <param name="childp"></param>
    public void AddAreaChild(PhysicalTopology parentp, PhysicalTopology childp)
    {
        int      parentAreaid  = parentp.Id;
        AreaNode childareaNode = PhysicalTopologyToAreaNode(childp);
        var      node          = CreateTopoNode(childareaNode);
        AreaNode parentNode;

        if (parentp.Type == AreaTypes.园区)//当等于2时,就是四会电厂区域根节点
        {
            parentNode = rootAreaNode;
            nodes.Add(node);
        }
        else
        {
            TreeNode <TreeViewItem> parentTreeNode = PersonnelTreeManage.Instance.FindAreaNode(parentAreaid);
            parentTreeNode.Nodes.Add(node);
            parentNode = (AreaNode)parentTreeNode.Item.Tag;
        }

        //AreaNode parentNode = (AreaNode)parentTreeNode.Item.Tag;
        List <AreaNode> parentNodeChildrenList;

        if (parentNode.Children != null)
        {
            parentNodeChildrenList = new List <AreaNode>(parentNode.Children);
        }
        else
        {
            parentNodeChildrenList = new List <AreaNode>();
        }
        parentNodeChildrenList.Add(childareaNode);

        parentNode.Children = parentNodeChildrenList.ToArray();
    }
Exemple #18
0
 private void RemoveEmptyNodes(AreaNode node)
 {
     if (node == null)
     {
         return;
     }
     if (node.Children != null)
     {
         for (int i = 0; i < node.Children.Count; i++)
         {
             AreaNode subNode = node.Children[i];
             if (subNode.IsSelftEmpty())
             {
                 node.Children.RemoveAt(i);
                 i--;
             }
             else
             {
                 RemoveEmptyNodes(subNode);
                 if (subNode.IsSelftEmpty())
                 {
                     node.Children.RemoveAt(i);
                     i--;
                 }
             }
         }
     }
 }
Exemple #19
0
    private void SelectAreaNode(TreeNode <TreeViewItem> node)
    {
        AreaNode togR = (AreaNode)node.Item.Tag;

        if (togR.Name == "厂区内")
        {
            RoomFactory.Instance.FocusNode(FactoryDepManager.Instance);
        }
        else
        {
            try
            {
                DepNode NodeRoom = RoomFactory.Instance.GetDepNodeById(togR.Id);
                if (NodeRoom != null)
                {
                    RoomFactory.Instance.FocusNode(NodeRoom);
                }
                else
                {
                    Debug.LogError("AreaDivideTree.SelectAreaNode NodeRoom==null");
                }
            }
            catch (Exception ex)
            {
                Debug.LogError("AreaDivideTree.NodeSelected:" + ex);
            }
        }
    }
Exemple #20
0
        public OperationResult <List <Area> > GetAreaInformation()
        {
            try
            {
                var Result = new OperationResult <List <Area> >();
                Result.Result = new List <Area>();

                foreach (XmlNode AreaNode in AreasXml.DocumentElement.SelectNodes("area"))
                {
                    var Area = __GetArea(AreaNode);
                    if (Area == null)
                    {
                        continue;
                    }

                    foreach (XmlNode EstwNode in AreaNode.SelectNodes("estw"))
                    {
                        __GetEstw(EstwNode, Area);
                    }

                    Result.Result.Add(Area);
                }

                Result.Succeeded = true;
                return(Result);
            }
            catch (Exception ex)
            {
                return(new OperationResult <List <Area> > {
                    Message = ex.Message
                });
            }
        }
        /// <remarks>
        /// If the provided area is large enough, the lower part of the area is partitioned to host the row and the
        /// lower bound of the area moves upwards. When the area becomes empty, it is removed from the chain of
        /// unpartitioned areas to avoid spending time on it during future allocations.
        /// </remarks>
        private bool TryPartitionArea(AreaNode areaNode, int rowIndex, int rowHeight, int minWidth)
        {
            RectInt area = areaNode.rect;

            if (area.height < rowHeight || area.width < minWidth)
            {
                return(false);
            }

            var row = m_OpenRows[rowIndex];

            if (row != null)
            {
                row.Release();
            }
            row = Row.Acquire(area.x, area.y, area.width, rowHeight);
            m_OpenRows[rowIndex] = row;
            area.y      += rowHeight;
            area.height -= rowHeight;

            if (area.height == 0)
            {
                if (areaNode == m_FirstUnpartitionedArea)
                {
                    m_FirstUnpartitionedArea = areaNode.next;
                }
                areaNode.RemoveFromChain();
                areaNode.Release();
            }
            else
            {
                areaNode.rect = area;
            }
            return(true);
        }
            public static AreaNode Acquire(RectInt rect)
            {
                AreaNode node = s_Pool.Get();

                node.rect     = rect;
                node.previous = null;
                node.next     = null;
                return(node);
            }
Exemple #23
0
        private void AddAreaNode(TreeNode appNode)
        {
            if (appNode != null && appNode.Name == MyConst.View.KnxAppType)
            {
                AreaNode node = new AreaNode();
                appNode.Nodes.Add(node);

                TreeViewChangedEventNotify(node, EventArgs.Empty);
            }
        }
Exemple #24
0
        /// <summary>
        /// 导入 JSON 文件,生成 Treeview 节点
        /// </summary>
        /// <param name="app"></param>
        /// <param name="tvwAppdata"></param>
        public static AppNode ImportNode(KNXApp app /*, TreeView tv, UIEditor.Entity.ViewNode.PropertiesChangedDelegate proChangedDelegate*/)
        {
            AppNode appNode = null;

            if (app != null)
            {
                //tvwAppdata.BeginUpdate();
                //tvwAppdata.Nodes.Clear();

                appNode = new AppNode(app);

                //tvwAppdata.Nodes.Add(appNode);

                if (app.Areas != null && app.Areas.Count > 0)
                {
                    foreach (KNXArea itemArea in app.Areas)
                    {
                        var areaNode = new AreaNode(itemArea);
                        appNode.Nodes.Add(areaNode);

                        if (itemArea.Rooms != null && itemArea.Rooms.Count > 0)
                        {
                            foreach (KNXRoom itemRoom in itemArea.Rooms)
                            {
                                var roomNode = new RoomNode(itemRoom);
                                areaNode.Nodes.Add(roomNode);

                                if (itemRoom.Pages != null && itemRoom.Pages.Count > 0)
                                {
                                    foreach (KNXPage itemPage in itemRoom.Pages)
                                    {
                                        var pageNode = new PageNode(itemPage);
                                        //pageNode.PropertiesChangedEvent += proChangedDelegate;
                                        roomNode.Nodes.Add(pageNode);

                                        // 给页面添加控件
                                        if (itemPage.Controls != null && itemPage.Controls.Count > 0)
                                        {
                                            foreach (var item in itemPage.Controls)
                                            {
                                                AddControlNode(pageNode, item /*, proChangedDelegate*/);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                //tvwAppdata.EndUpdate();
            }

            return(appNode);
        }
Exemple #25
0
        public void LoadData(PhysicalTopology tree1, Department tree2, AreaNode tree3 = null)
        {
            TopoTreeView1.LoadData(tree1);
            TopoTreeView1.ExpandLevel(2);
            TopoTreeView1.SelectFirst();

            DepTreeView1.LoadData(tree2);
            TopoTreeView1.ExpandLevel(2);

            PersonTreeView1.LoadData(tree3);
        }
Exemple #26
0
    public void moveShipToLocation(AreaNode node)
    {
        Sequence sequence = DOTween.Sequence();



        sequence.Append(_ship.transform.DOMove(new Vector3(node.transform.position.x, node.transform.position.y, 0), 0.5f, false));
        sequence.OnComplete(() =>
        {
            _ship.GetComponent <Ship> ().setPosition(node.transform.position);
        });
    }
Exemple #27
0
    // Use this for initialization
    void Start()
    {
        _areaNodes = FindObjectsOfType(typeof(AreaNode)) as AreaNode[];

        if (_areaNodes != null)
        {
            _currentNode = _areaNodes[0];


            _ship.transform.position = _currentNode.transform.position;
        }
    }
Exemple #28
0
 /// <summary>
 /// 设置父节点的数量
 /// </summary>
 /// <param name="parentNode"></param>
 /// <param name="num"></param>
 public void SetParentNodepersonnelNum(TreeNode <TreeViewItem> parentNode, int num)
 {
     if (parentNode != null)
     {
         int currentNum = 0;
         var nodeNum    = "";
         if (parentNode.Item != null)
         {
             nodeNum = parentNode.Item.Name;
         }
         var array = nodeNum.Split(new char[2] {
             '(', ')'
         });
         //1.父节点原本就有人
         if (array != null && array.Length > 2)
         {
             try
             {
                 string parentName = array[array.Length - 2];
                 currentNum = int.Parse(parentName);
             }
             catch
             {
             }
             if (parentNode.Item.Tag is AreaNode)
             {
                 AreaNode anode = parentNode.Item.Tag as AreaNode;//取出区域的名称
                 parentNode.Item.Name = string.Format("{0} ({1})", anode.Name, currentNum + num);
             }
         }
         else
         {
             //2.父节点原来没人,直接把子节点的加上
             if (parentNode.Item.Tag is AreaNode)
             {
                 AreaNode anode = parentNode.Item.Tag as AreaNode;//取出区域的名称
                 parentNode.Item.Name = string.Format("{0} ({1})", anode.Name, currentNum + num);
             }
         }
         if (parentNode.Parent != null)
         {
             try
             {
                 SetParentNodepersonnelNum(parentNode.Parent, num);
             }
             catch
             {
                 int i = 1;
             }
         }
     }
 }
Exemple #29
0
    /// <summary>
    /// 展示树信息
    /// </summary>
    /// <param name="root"></param>
    public void StructureTree(AreaNode root)
    {
        if (root == null)
        {
            Log.Error("AreaDeviceTree.StructureTree", "root == null");
            return;
        }

        Log.Info("AreaDeviceTree.StructureTree", "root:" + root.Name);
        personDic.Clear();
        AreaDic.Clear();
        nodes = new ObservableList <TreeNode <TreeViewItem> >();
        CreateTreeNodes(root);
    }
Exemple #30
0
    /// <summary>
    /// 区域划分,选中节点
    /// </summary>
    /// <param name="personnelT"></param>
    /// <param name="nodesT"></param>
    /// <returns></returns>
    public TreeNode <TreeViewItem> AreaFindNodeById(object AreaT, IObservableList <TreeNode <TreeViewItem> > nodesT)
    {
        TreeNode <TreeViewItem> node = null;

        if (nodesT != null)
        {
            foreach (TreeNode <TreeViewItem> nodeT in nodesT)
            {
                try
                {
                    if (nodeT.Item.Tag is AreaNode)
                    {
                        AreaNode tagp  = (AreaNode)nodeT.Item.Tag;
                        int      tagId = tagp.Id;
                        if (tagp.Name == "锅炉补给水处理车间0层")
                        {
                            string name = tagp.Name;
                        }
                        if (tagId.ToString() == AreaT.ToString())
                        {
                            node = nodeT;
                            break;
                        }
                    }
                    if (nodeT.Nodes != null)
                    {
                        try
                        {
                            node = AreaFindNodeById(AreaT, nodeT.Nodes);
                            if (node != null)
                            {
                                break;
                            }
                        }
                        catch
                        {
                            int i = 0;
                        }
                    }
                }
                catch
                {
                    int It = 0;
                    return(null);
                }
            }
        }
        return(node);
    }