public override void SetPosition(double _FromX, double _FromY, double _ToX, double _ToY, bool isSelfRelation, double selfRelationX, double selfRelationY)
        {
            FromX = _FromX;
            FromY = _FromY;
            ToX   = _ToX;
            ToY   = _ToY;

            base.SetPosition(FromX, FromY, ToX, ToY, isSelfRelation, selfRelationX, selfRelationY);

            if (MetaDiagramItem == null)
            {
                return;
            }

            PointCollection pc = new PointCollection();

            if (isSelfRelation)
            {
            }
            else
            {
                Point p = new Point(FromX + ((ToX - FromX) / 2), FromY + ((ToY - FromY) / 2));
                pc.Add(p);
                pc.Add(MetaDiagramItem.GetLineAnchorLocation(null, p, 1, 1, false));

                MetaLine.Points = pc;
            }
        }
Beispiel #2
0
        protected void UpdateDiagramLines(DiagramItemBase toItem)
        {
            List <DiagramLineBase> sameToItemLines = new List <DiagramLineBase>();

            if (GetDiagramLinesToDiagramItemDictionary().ContainsKey(toItem.Vertex))
            {
                foreach (DiagramLineBase l in GetDiagramLinesToDiagramItemDictionary()[toItem.Vertex])
                {
                    sameToItemLines.Add(l);
                }
            }

            /*foreach (DiagramLineBase l in DiagramLines) // OOO
             *  if (l.Vertex.Get("ToDiagramItem:") == toItem.Vertex)
             *      sameToItemLines.Add(l);*/

            List <DiagramLineBase> sameFromItemLinesTo = new List <DiagramLineBase>();

            if (toItem.GetDiagramLinesToDiagramItemDictionary().ContainsKey(this.Vertex))
            {
                foreach (DiagramLineBase l in toItem.GetDiagramLinesToDiagramItemDictionary()[this.Vertex])
                {
                    sameFromItemLinesTo.Add(l);
                }
            }

            /*foreach (DiagramLineBase l in toItem.DiagramLines) // OOO
             *  if (l.Vertex.Get("ToDiagramItem:") == this.Vertex)
             *      sameFromItemLinesTo.Add(l);*/

            int allCnt = sameToItemLines.Count() + sameFromItemLinesTo.Count();

            int cnt = 0;

            if (toItem == this)
            {
                allCnt = allCnt / 2;
            }

            foreach (DiagramLineBase l in sameToItemLines)
            {
                Point start = GetLineAnchorLocation(toItem, new Point(), allCnt, cnt, toItem == this);

                Point end = toItem.GetLineAnchorLocation(this, new Point(), allCnt, cnt, false);

                if (toItem == this)
                {
                    l.SetPosition(start.X, start.Y, end.X, end.Y, true, Canvas.GetLeft(this) + this.ActualWidth + 25 * (allCnt - cnt), Canvas.GetTop(this) - 25 * ((allCnt - cnt)));
                }
                else
                {
                    l.SetPosition(start.X, start.Y, end.X, end.Y, false, 0, 0);
                }

                cnt++;
            }

            foreach (DiagramLineBase l in sameFromItemLinesTo)
            {
                Point end = GetLineAnchorLocation(toItem, new Point(), allCnt, cnt, false);

                Point start = toItem.GetLineAnchorLocation(this, new Point(), allCnt, cnt, false);

                if (toItem != this)
                {
                    l.SetPosition(start.X, start.Y, end.X, end.Y, false, 0, 0);
                }

                cnt++;
            }
        }