コード例 #1
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;
        }
コード例 #2
0
        public void LoadLogicViewInfor()//读取设计数据
        {
            if (LogicDiagram == null)
            {
                return;
            }
            Width  = LogicDiagram.Width;
            Height = LogicDiagram.Height;

            DeseignCanvas.Children.Clear();
            LFCDataService lfcs = new LFCDataService();

            foreach (ViewItem vi in LogicDiagram.NodeItemList)
            {
                IDesignNode dn = getNewNodeControl(vi.DataObjectType, vi.DataObjectID);
                if (dn == null)            //表示委托方法没有能够完成加载一个数据对应的设计节点,此时建立空节点
                {
                    dn.IsErrorData = true; //决定显示时候是红色
                    Type t = Type.GetType(vi.ControlType);
                    if (t != null)
                    {
                        object co = Activator.CreateInstance(t);
                        if (co != null && co is IDesignNode)
                        {
                            dn = co as IDesignNode;
                        }
                    }
                }
                if (dn == null)
                {
                    dn             = new LynxDefaultNode();
                    dn.IsErrorData = true;
                }

                DeseignCanvas.Children.Add(dn.getControl());
                dn.LogicViewObject = vi;
                dn.LoadLogicViewInfor();
                dn.designCanvas = this;
            }
            foreach (ViewLineItem vl in LogicDiagram.RelationItemList)
            {
                IDesignRelation l = null;
                if (!getNewRelationControlByID.Equals(null))
                {
                    l = getNewRelationControl(vl.DataObjectType, vl.DataObjectID);
                }

                if (l == null)
                {
                    l             = new LynxConnectLine();
                    l.IsErrorData = true;
                }
                l.designCanvas    = this;
                l.LogicViewObject = vl;
                l.LoadLogicViewInfor();
                l.DrawRelationLine(l.StartPoint, l.EndPoint);

                List <FrameworkElement> fel = null;
                fel = getControlList(l.SourceID);
                foreach (FrameworkElement fe in fel)
                {
                    IDesignNode idn = fe as IDesignNode;
                    if (idn != null)
                    {
                        idn.AddRelationAsSourceObject(l);
                    }
                }
                fel = getControlList(l.TargetID);
                foreach (FrameworkElement fe in fel)
                {
                    IDesignNode idn = fe as IDesignNode;
                    if (idn != null)
                    {
                        idn.AddRelationAsTargetObject(l);
                    }
                }
            }
        }