Пример #1
0
        public void SaveLogicViewInfor()//写入设计数据
        {
            if (LogicDiagram == null)
            {
                return;
            }
            LogicDiagram.Width  = Width;
            LogicDiagram.Height = Height;

            LogicDiagram.NodeItemList.Clear();
            LogicDiagram.RelationItemList.Clear();
            foreach (FrameworkElement fe in DeseignCanvas.Children)
            {
                IDesignNode ino = fe as IDesignNode;
                if (ino != null)
                {
                    ino.SaveLogicViewInfor();
                    LogicDiagram.NodeItemList.Add(ino.LogicViewObject);
                }
                IDesignRelation iro = fe as IDesignRelation;
                if (iro != null)
                {
                    iro.SaveLogicViewInfor();
                    LogicDiagram.RelationItemList.Add(iro.LogicViewObject);
                }
                object UItag = fe.Tag;
                if ((UItag != null) && (UItag is IDesignRelation))
                {
                    IDesignRelation tagR = UItag as IDesignRelation;
                    tagR.SaveLogicViewInfor();
                    LogicDiagram.RelationItemList.Add(tagR.LogicViewObject);
                }
            }
        }
Пример #2
0
        public void AddExistNode(string id)//添加一个现存的Node,并且自动寻找适合的关联线,一旦有也同步添加,由于是从实体层添加的,因此关联添加
        {
            IDesignNode idn = getNewNodeControl(null, id);

            if (idn == null)
            {
                return;
            }
            AddExistNode(idn);
            if (idn.ObjectID != null)
            {
                List <IDesignRelation> rl = getAllowedRelationListByNodeID(null, idn.ObjectID);
                foreach (IDesignRelation r in rl)
                {
                    if (r.SourceID == null || r.TargetID == null)
                    {
                        continue;
                    }                                                          //直接进入下次循环
                    List <IDesignNode> tnl = NodeList.Where(n => n.ObjectID == r.SourceID || n.ObjectID == r.TargetID).ToList();
                    if (tnl.Count != 0)
                    {
                        AddExistRelation(r.ObjectID);
                    }
                }
            }
        }
Пример #3
0
        public void AddExistRelation(IDesignRelation idr)//添加关联,自行判断是否有关联控件存在
        {
            if (idr == null)
            {
                return;
            }
            if (NodeList.Count == 0)
            {
                return;
            }
            idr.designCanvas = this;
            IDesignNode sdn = null, tdn = null;

            if (idr.SourceID != null)
            {
                List <IDesignNode> rl = NodeList.Where(n => n.ObjectID == idr.SourceID).ToList();
                if (rl.Count > 0)
                {
                    sdn = rl[0];
                }
            }
            if (idr.TargetID != null)
            {
                List <IDesignNode> rl = NodeList.Where(n => n.ObjectID == idr.SourceID).ToList();
                if (rl.Count > 0)
                {
                    tdn = rl[0];
                }
            }
            if (sdn != null)
            {
                idr.StartAnchorPoint = sdn.getDefaultAnchorPoint();
                idr.StartPoint       = idr.StartAnchorPoint.getDesignCanvasPoint();
            }
            else
            {
                idr.StartAnchorPoint = null;
                idr.StartPoint       = new Point(DeseignCanvas.Width / 2 - (new Random()).Next(50), DeseignCanvas.Height / 2 - (new Random()).Next(50));
            }
            if (tdn != null)
            {
                idr.EndAnchorPoint = tdn.getDefaultAnchorPoint();
                idr.EndPoint       = idr.EndAnchorPoint.getDesignCanvasPoint();
            }
            else
            {
                idr.EndAnchorPoint = null;
                idr.EndPoint       = new Point(DeseignCanvas.Width / 2 + (new Random()).Next(150), DeseignCanvas.Height / 2 + (new Random()).Next(150));
            }
            FrameworkElement fe = idr.getControl();

            DeseignCanvas.Children.Add(fe);

            idr.DrawRelationLine(idr.StartPoint, idr.EndPoint);
            sendObjectOperationEvent(idr, DesignOperationFlag.CreateRelation);//提示设计图增加了节点对象
            RelationList.Add(idr);
        }
Пример #4
0
        public void AddExistNode(IDesignNode idn, Point p)//添加一个指定的新设计对象,不进行关联添加
        {
            DeseignCanvas.Children.Add(idn.getControl());
            idn.designCanvas = this;
            Canvas.SetLeft(idn.getControl(), p.X);//指定位置
            Canvas.SetTop(idn.getControl(), p.Y);

            NodeList.Add(idn);
        }
Пример #5
0
        public void RemoveControl(IDesignObject ido)
        {
            if (ido == null)
            {
                return;
            }

            FrameworkElement fe = ido.getControl();

            if ((fe != null) && (DeseignCanvas.Children.Contains(fe)))
            {
                DeseignCanvas.Children.Remove(fe);
            }
            //if (DesignObjectList.Contains(ido)) { DesignObjectList.Remove(ido); }
            if (ido is IDesignNode)
            {
                IDesignNode idn = fe as IDesignNode;
                foreach (IDesignAnchorPoint ap in idn.AnchorPointList)
                {
                    foreach (IDesignRelation tdr in ap.InRelationList)
                    {
                        tdr.RemoveRelationLine();
                    }
                    foreach (IDesignRelation tdr in ap.OutRelationList)
                    {
                        tdr.RemoveRelationLine();
                    }
                }
                sendObjectOperationEvent(idn, DesignOperationFlag.DeleteObject);//提示设计图增加了节点对象
                //idn.DisableControlMove();//不再响应事件
            }
            if (ido is IDesignRelation)
            {
                IDesignRelation tdr = ido as IDesignRelation;
                tdr.RemoveRelationLine();
                sendObjectOperationEvent(ido, DesignOperationFlag.DeleteRelation);//提示设计图增加了节点对象
            }
            ido.designCanvas = null;
            ido.ClearAllEvent();
        }
Пример #6
0
        public void AddExistRelation(IDesignRelation idr, IDesignNode sdn, IDesignNode tdn)//在指定的起始节点和终止节点之间添加一个关联控件
        {
            if (idr == null)
            {
                return;
            }
            if (NodeList.Count == 0)
            {
                return;
            }
            idr.designCanvas = this;
            if (sdn != null)
            {
                idr.StartAnchorPoint = sdn.getDefaultAnchorPoint();
                idr.StartPoint       = idr.StartAnchorPoint.getDesignCanvasPoint();
            }
            else
            {
                idr.StartAnchorPoint = null;
                idr.StartPoint       = new Point(DeseignCanvas.Width / 2 - (new Random()).Next(50), DeseignCanvas.Height / 2 - (new Random()).Next(50));
            }
            if (tdn != null)
            {
                idr.EndAnchorPoint = tdn.getDefaultAnchorPoint();
                idr.EndPoint       = idr.EndAnchorPoint.getDesignCanvasPoint();
            }
            else
            {
                idr.EndAnchorPoint = null;
                idr.EndPoint       = new Point(DeseignCanvas.Width / 2 + (new Random()).Next(150), DeseignCanvas.Height / 2 + (new Random()).Next(150));
            }
            FrameworkElement fe = idr.getControl();

            DeseignCanvas.Children.Add(fe);

            idr.DrawRelationLine(idr.StartPoint, idr.EndPoint);
            sendObjectOperationEvent(idr, DesignOperationFlag.CreateRelation);//提示设计图增加了节点对象
            RelationList.Add(idr);
        }
Пример #7
0
 public void AddExistNode(IDesignNode idn)                                                                                                              //添加一个指定的新设计对象,不进行关联添加
 {
     AddExistNode(idn, new Point(DeseignCanvas.ActualWidth / 2 - (new Random()).Next(150), DeseignCanvas.ActualHeight / 2 - (new Random()).Next(150))); //在距离中心一定范围内随机布置
 }
Пример #8
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);
                    }
                }
            }
        }
Пример #9
0
 {                                                                      //锚点只有激活的时候会挂载事件和数据,这个由Node决定。绘制结束后,仅仅保持关联。
     public LynxAnchorPoint(IDesignNode idn)                            //直接在设计节点对象里面
     {
         InitializeComponent();
         InitBrush();
         ParentConnectControl = idn;
     }