Ejemplo n.º 1
0
        private void TraceNodes(TracePanel start, TracePanel dest, ref List <TracePanel> traceNodes, List <TracePanel> curTraceNodes)
        {
            if (curTraceNodes.Contains(start))//如果当前路径中已经包含该节点,则返回,防止类似A-B,陷入无限循环中
            {
                return;
            }
            curTraceNodes.Add(start);
            if (!traceNodes.IsNullOrEmpty() && traceNodes.Count <= curTraceNodes.Count)//如果当前路径长度大于记录路径,则直接返回
            {
                return;
            }
            if (start == dest) //如果已经到达最终节点
            {
                if (traceNodes.Count == 0 || traceNodes.Count > curTraceNodes.Count)
                {
                    traceNodes.Clear();
                    traceNodes = new List <TracePanel>(curTraceNodes);
                }
            }
            else//遍历子节点
            {
                List <TracePanel> anchorTotal = (from ae in start.AnchorTop where ae.Intersectioned select ae.Anchor).ToList();
                anchorTotal.AddRange(from ae in start.AnchorBottom where ae.Intersectioned select ae.Anchor);
                anchorTotal.AddRange(from ae in start.AnchorLeft where ae.Intersectioned select ae.Anchor);
                anchorTotal.AddRange(from ae in start.AnchorRight where ae.Intersectioned select ae.Anchor);

                foreach (TracePanel tpChild in anchorTotal)
                {
                    List <TracePanel> nexTracePanels = new List <TracePanel>(curTraceNodes);
                    TraceNodes(tpChild, dest, ref traceNodes, nexTracePanels);
                }
            }
        }
Ejemplo n.º 2
0
 public void AddAnchor(TracePanel tc, AnchorStyles orientation, bool intersectioned)
 {
     if (null == tc)
     {
         return;
     }
     if (orientation == AnchorStyles.Left)
     {
         AnchorLeft.Add(new AnchorEntity {
             Anchor = tc, Intersectioned = intersectioned
         });
     }
     else if (orientation == AnchorStyles.Right)
     {
         AnchorRight.Add(new AnchorEntity {
             Anchor = tc, Intersectioned = intersectioned
         });
     }
     else if (orientation == AnchorStyles.Top)
     {
         AnchorTop.Add(new AnchorEntity {
             Anchor = tc, Intersectioned = intersectioned
         });
     }
     else if (orientation == AnchorStyles.Bottom)
     {
         AnchorBottom.Add(new AnchorEntity {
             Anchor = tc, Intersectioned = intersectioned
         });
     }
 }
Ejemplo n.º 3
0
        public bool TraceFromTo(String entity, String start, String dest)
        {
            TracePanel tpStart = _tracePanelColl.First(o => o.Name == start);
            TracePanel tpDest  = _tracePanelColl.First(o => o.Name == dest);

            return(TraceFromTo(entity, tpStart, tpDest));
        }
Ejemplo n.º 4
0
 private void AddTracePanel(TracePanel traceAdd, Point offset)
 {
     if (null == _tracePanelColl)
         return;
     if (_tracePanelColl.Contains(traceAdd))
         return;
     traceAdd.Offset = offset;
     _tracePanelColl.Add(traceAdd);
 }
Ejemplo n.º 5
0
        public bool AddMonitor(string tcName, TraceMonitorPoint hint)
        {
            TracePanel target = _tracePanelColl.First(o => o.Name == tcName);

            if (null == target)
            {
                return(false);
            }
            target.AddMonitor(hint);
            return(true);
        }
Ejemplo n.º 6
0
 private void AddTracePanel(TracePanel traceAdd, Point offset)
 {
     if (null == _tracePanelColl)
     {
         return;
     }
     if (_tracePanelColl.Contains(traceAdd))
     {
         return;
     }
     traceAdd.Offset = offset;
     _tracePanelColl.Add(traceAdd);
 }
Ejemplo n.º 7
0
        public void AddTraceChain(String entity, TracePanel pre, TracePanel next)
        {
            if ((null == pre && null == next) || string.IsNullOrEmpty(entity))
            {
                return;
            }
            TraceChain tc = new TraceChain {
                PreviousCtrl = pre, NextCtrl = next, Entity = entity
            };

            if (!_traceChains.Contains(tc))
            {
                _traceChains.Add(tc);
            }
        }
Ejemplo n.º 8
0
        private void AddTrace(String entity, List <TracePanel> traceNodes)
        {
            if (String.IsNullOrEmpty(entity) || traceNodes.IsNullOrEmpty())
            {
                return;
            }
            if (_traceChainEntityHashtable.Contains(entity))
            {
                List <TracePanel> entityTraceNodes = (List <TracePanel>)_traceChainEntityHashtable[entity];
                if (traceNodes.First(p => true) == entityTraceNodes.Last(p => true))
                {
                    traceNodes.RemoveAt(0);
                    entityTraceNodes.AddRange(traceNodes);
                    _traceChainEntityHashtable[entity] = entityTraceNodes;
                }
                else
                {
                    return;
                }
            }
            else
            {
                _traceChainEntityHashtable.Add(entity, traceNodes);
            }

            traceNodes = (List <TracePanel>)_traceChainEntityHashtable[entity];
            foreach (TracePanel tp in traceNodes)
            {
                tp.ClearTrace(entity);
            }
            for (int i = 0; i < traceNodes.Count; i++)
            {
                TracePanel tpPre  = null;
                TracePanel tpNext = null;
                if (i > 0)
                {
                    tpPre = traceNodes[i - 1];
                }
                if (i < traceNodes.Count - 1)
                {
                    tpNext = traceNodes[i + 1];
                }
                traceNodes[i].AddTraceChain(entity, tpPre, tpNext);
                traceNodes[i].Refresh();
            }
        }
Ejemplo n.º 9
0
        public bool TraceFromTo(String entity, TracePanel start, TracePanel dest)
        {
            if (string.IsNullOrEmpty(entity) || null == start || dest == null)
            {
                return(false);
            }

            List <TracePanel> traceNodes = new List <TracePanel>();

            TraceNodes(start, dest, ref traceNodes, new List <TracePanel>());
            if (traceNodes.Count <= 0 || !traceNodes.Contains(dest))
            {
                return(false);
            }
            AddTrace(entity, traceNodes);
            return(true);
        }
Ejemplo n.º 10
0
        private Point GetAnchorPoint(TracePanel anchor)
        {
            Point anchorPoint = new Point();

            if (null != anchor)
            {
                if (AnchorTop.Contains(new AnchorEntity {
                    Anchor = anchor, Intersectioned = true
                }))
                {
                    int overlapLeft  = Math.Max(Offset.X + Left + (int)(OpenStart * Width), anchor.Offset.X + anchor.Left + (int)(anchor.OpenStart * anchor.Width));
                    int overlapRight = Math.Min(Offset.X + Left + (int)((OpenStart + OpenRatio) * Width), anchor.Offset.X + anchor.Left + (int)((anchor.OpenStart + anchor.OpenRatio) * anchor.Width));
                    anchorPoint = new Point(overlapLeft + (overlapRight - overlapLeft) / 2 - Offset.X, Top);
                }
                else if (AnchorBottom.Contains(new AnchorEntity {
                    Anchor = anchor, Intersectioned = true
                }))
                {
                    int overlapLeft  = Math.Max(Offset.X + Left + (int)(OpenStart * Width), anchor.Offset.X + anchor.Left + (int)(anchor.OpenStart * anchor.Width));
                    int overlapRight = Math.Min(Offset.X + Left + (int)((OpenStart + OpenRatio) * Width), anchor.Offset.X + anchor.Left + (int)((anchor.OpenStart + anchor.OpenRatio) * anchor.Width));
                    anchorPoint = new Point(overlapLeft + (overlapRight - overlapLeft) / 2 - Offset.X, Bottom);
                }
                else if (AnchorLeft.Contains(new AnchorEntity {
                    Anchor = anchor, Intersectioned = true
                }))
                {
                    int overlapTop    = Math.Max(Offset.Y + Top + (int)(OpenStart * Height), anchor.Offset.Y + anchor.Top + (int)(anchor.OpenStart * anchor.Height));
                    int overlapBottom = Math.Min(Offset.Y + Top + (int)((OpenStart + OpenRatio) * Height), anchor.Offset.Y + anchor.Top + (int)((anchor.OpenStart + anchor.OpenRatio) * anchor.Height));
                    anchorPoint = new Point(Left, overlapTop + (overlapBottom - overlapTop) / 2 - Offset.Y);
                }
                else if (AnchorRight.Contains(new AnchorEntity {
                    Anchor = anchor, Intersectioned = true
                }))
                {
                    int overlapTop    = Math.Max(Offset.Y + Top + (int)(OpenStart * Height), anchor.Offset.Y + anchor.Top + (int)(anchor.OpenStart * anchor.Height));
                    int overlapBottom = Math.Min(Offset.Y + Top + (int)((OpenStart + OpenRatio) * Height), anchor.Offset.Y + anchor.Top + (int)((anchor.OpenStart + anchor.OpenRatio) * anchor.Height));
                    anchorPoint = new Point(Right, overlapTop + (overlapBottom - overlapTop) / 2 - Offset.Y);
                }
            }
            return(anchorPoint);
        }
Ejemplo n.º 11
0
 public void AddAnchor(TracePanel tc, AnchorStyles orientation, bool intersectioned)
 {
     if (null == tc)
         return;
     if (orientation == AnchorStyles.Left)
     {
         AnchorLeft.Add(new AnchorEntity { Anchor = tc,Intersectioned = intersectioned});
     }
     else if (orientation == AnchorStyles.Right)
     {
         AnchorRight.Add(new AnchorEntity { Anchor = tc, Intersectioned = intersectioned });
     }
     else if (orientation == AnchorStyles.Top)
     {
         AnchorTop.Add(new AnchorEntity { Anchor = tc, Intersectioned = intersectioned });
     }
     else if (orientation == AnchorStyles.Bottom)
     {
         AnchorBottom.Add(new AnchorEntity { Anchor = tc, Intersectioned = intersectioned });
     }
 }
Ejemplo n.º 12
0
 public void AddTraceChain(String entity, TracePanel pre, TracePanel next)
 {
     if ((null == pre && null == next) || string.IsNullOrEmpty(entity))
         return;
     TraceChain tc = new TraceChain { PreviousCtrl=pre, NextCtrl = next,Entity = entity };
     if (!_traceChains.Contains(tc))
         _traceChains.Add(tc);
 }
Ejemplo n.º 13
0
 private Point GetAnchorPoint(TracePanel anchor)
 {
     Point anchorPoint = new Point();
     if (null != anchor)
     {
         if (AnchorTop.Contains(new AnchorEntity {Anchor = anchor,Intersectioned = true}))
         {
             int overlapLeft = Math.Max(Offset.X + Left + (int)(OpenStart * Width), anchor.Offset.X + anchor.Left + (int)(anchor.OpenStart * anchor.Width));
             int overlapRight = Math.Min(Offset.X + Left + (int)((OpenStart + OpenRatio) * Width), anchor.Offset.X+anchor.Left + (int)((anchor.OpenStart + anchor.OpenRatio) * anchor.Width));
             anchorPoint = new Point(overlapLeft + (overlapRight - overlapLeft) / 2 - Offset.X, Top);
         }
         else if (AnchorBottom.Contains(new AnchorEntity { Anchor = anchor, Intersectioned = true }))
         {
             int overlapLeft = Math.Max(Offset.X + Left + (int)(OpenStart * Width), anchor.Offset.X + anchor.Left + (int)(anchor.OpenStart * anchor.Width));
             int overlapRight = Math.Min(Offset.X + Left + (int)((OpenStart + OpenRatio) * Width), anchor.Offset.X + anchor.Left + (int)((anchor.OpenStart + anchor.OpenRatio) * anchor.Width));
             anchorPoint = new Point(overlapLeft + (overlapRight - overlapLeft) / 2 - Offset.X, Bottom);
         }
         else if (AnchorLeft.Contains(new AnchorEntity { Anchor = anchor, Intersectioned = true }))
         {
             int overlapTop = Math.Max(Offset.Y + Top + (int)(OpenStart * Height), anchor.Offset.Y + anchor.Top + (int)(anchor.OpenStart * anchor.Height));
             int overlapBottom = Math.Min(Offset.Y + Top + (int)((OpenStart + OpenRatio) * Height), anchor.Offset.Y + anchor.Top + (int)((anchor.OpenStart + anchor.OpenRatio) * anchor.Height));
             anchorPoint = new Point(Left, overlapTop + (overlapBottom - overlapTop) / 2 - Offset.Y);
         }
         else if (AnchorRight.Contains(new AnchorEntity { Anchor = anchor, Intersectioned = true }))
         {
             int overlapTop = Math.Max(Offset.Y + Top + (int)(OpenStart * Height), anchor.Offset.Y + anchor.Top + (int)(anchor.OpenStart * anchor.Height));
             int overlapBottom = Math.Min(Offset.Y + Top + (int)((OpenStart + OpenRatio) * Height), anchor.Offset.Y + anchor.Top + (int)((anchor.OpenStart + anchor.OpenRatio) * anchor.Height));
             anchorPoint = new Point(Right, overlapTop + (overlapBottom - overlapTop) / 2 - Offset.Y);
         }
     }
     return anchorPoint;
 }
Ejemplo n.º 14
0
        private void TraceNodes(TracePanel start, TracePanel dest, ref List<TracePanel> traceNodes, List<TracePanel> curTraceNodes)
        {
            if (curTraceNodes.Contains(start))//如果当前路径中已经包含该节点,则返回,防止类似A-B,陷入无限循环中
                return;
            curTraceNodes.Add(start);
            if (!traceNodes.IsNullOrEmpty() && traceNodes.Count <= curTraceNodes.Count)//如果当前路径长度大于记录路径,则直接返回
                return;
            if (start == dest) //如果已经到达最终节点
            {
                if (traceNodes.Count==0 || traceNodes.Count > curTraceNodes.Count)
                {
                    traceNodes.Clear();
                    traceNodes = new List<TracePanel>(curTraceNodes);
                }
            }
            else//遍历子节点
            {
                List<TracePanel> anchorTotal = (from ae in start.AnchorTop where ae.Intersectioned select ae.Anchor).ToList();
                anchorTotal.AddRange(from ae in start.AnchorBottom where ae.Intersectioned select ae.Anchor);
                anchorTotal.AddRange(from ae in start.AnchorLeft where ae.Intersectioned select ae.Anchor);
                anchorTotal.AddRange(from ae in start.AnchorRight where ae.Intersectioned select ae.Anchor);

                foreach (TracePanel tpChild in anchorTotal)
                {
                    List<TracePanel> nexTracePanels = new List<TracePanel>(curTraceNodes);
                    TraceNodes(tpChild, dest, ref traceNodes, nexTracePanels);
                }
            }
        }
Ejemplo n.º 15
0
        public bool TraceFromTo(String entity, TracePanel start, TracePanel dest)
        {
            if (string.IsNullOrEmpty(entity) || null == start || dest == null)
                return false;

            List<TracePanel> traceNodes = new List<TracePanel>();
            TraceNodes(start, dest, ref traceNodes, new List<TracePanel>());
            if (traceNodes.Count <= 0 || !traceNodes.Contains(dest))
                return false;
            AddTrace(entity,traceNodes);
            return true;
        }