コード例 #1
0
        Point getAnchorPointCenter(IDesignAnchorPoint ap)
        {
            double x = Canvas.GetLeft(this) + Canvas.GetLeft(ap.ParentConnectControl.getControl()) + ap.ParentConnectControl.getControl().Width / 2;
            double y = Canvas.GetTop(this) + Canvas.GetTop(ap.ParentConnectControl.getControl()) + ap.ParentConnectControl.getControl().Height / 2;

            return(new Point(x, y));
        }
コード例 #2
0
 public void DeleteRelation(IDesignRelation IRelation)//删除任何指定的关联
 {
     for (int i = 0; i < AnchorPointList.Count; i++)
     {
         IDesignAnchorPoint dap = AnchorPointList[i];
         dap.RemoveRelation(IRelation);
     }
 }
コード例 #3
0
        public void AddRelationAsTargetObject(IDesignRelation IRelation)
        {
            IDesignAnchorPoint Anchor = getNearAnchorPoint(IRelation.EndPoint);

            if (Anchor == null)
            {
                return;
            }
            Anchor.AddInRelation(IRelation);
        }
コード例 #4
0
        public void AddRelationAsSourceObject(IDesignRelation IRelation)
        {
            IDesignAnchorPoint Anchor = getNearAnchorPoint(IRelation.StartPoint);

            if (Anchor == null)
            {
                return;
            }
            Anchor.AddOutRelation(IRelation);
        }
コード例 #5
0
        void DeseignCanvas_DesignPointerReleased(object sender, PointerRoutedEventArgs e)
        {
            HideDesignLine();

            DeseignCanvas.PointerMoved    -= new PointerEventHandler(DeseignCanvas_DesignPointerMoved);
            DeseignCanvas.PointerReleased -= new PointerEventHandler(DeseignCanvas_DesignPointerReleased);


            IDesignRelation l = null;

            if ((StartAnchor != null) && (EndAnchor != null) && (EndAnchor != StartAnchor))
            {
                l = null;
                if (!getNewRelationControlByID.Equals(null))//新建关联
                {
                    l = getNewRelationControl(null, null);
                }
                if (l == null)//新建失败使用默认关联
                {
                    l             = new LynxConnectLine();
                    l.IsErrorData = true;
                }
                if (l != null)
                {
                    l.designCanvas = this;

                    l.StartAnchorPoint = StartAnchor;
                    l.EndAnchorPoint   = EndAnchor;
                    StartAnchor.OutRelationList.Add(l);
                    EndAnchor.InRelationList.Add(l);
                    l.SourceID = StartAnchor.ParentConnectControl.ObjectID;
                    l.TargetID = EndAnchor.ParentConnectControl.ObjectID;
                }
            }

            if (l == null)
            {
                return;
            }                                                                //没有能够创立链接
            sendObjectOperationEvent(l, DesignOperationFlag.CreateRelation); //建立新的连接
            l.ReadFromObject();

            DeActiveAll();

            l.DrawRelationLine(StartPoint.Value, e.GetCurrentPoint(getCanvas()).Position);
            RelationList.Add(l);
            ActiveDesignObject(l);
            EndAnchor           = null;
            StartAnchor         = null;
            CurrentConnectPoint = null;
        }
コード例 #6
0
        public IDesignAnchorPoint getNearAnchorPoint(Point DiagramPosition)
        {
            if (this.AnchorPointList.Count == 0)
            {
                return(null);
            }
            double             min    = getDistance(DiagramPosition, getAnchorPointCenter(AnchorPointList[0]));
            IDesignAnchorPoint Anchor = AnchorPointList[0];

            for (int i = 1; i < AnchorPointList.Count; i++)
            {
                IDesignAnchorPoint dap = AnchorPointList[i];
                double             td  = getDistance(DiagramPosition, getAnchorPointCenter(dap));
                if (td < min)
                {
                    min    = td;
                    Anchor = dap;
                }
            }
            return(Anchor);
        }