public void AddInRelation(IDesignRelation ir) { if (!InRelationList.Contains(ir)) { InRelationList.Add(ir); } }
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); } } }
public void AddOutRelation(IDesignRelation or) { if (!OutRelationList.Contains(or)) { OutRelationList.Add(or); } }
public void DeleteRelation(IDesignRelation IRelation)//删除任何指定的关联 { for (int i = 0; i < AnchorPointList.Count; i++) { IDesignAnchorPoint dap = AnchorPointList[i]; dap.RemoveRelation(IRelation); } }
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); }
public void AddRelationAsTargetObject(IDesignRelation IRelation) { IDesignAnchorPoint Anchor = getNearAnchorPoint(IRelation.EndPoint); if (Anchor == null) { return; } Anchor.AddInRelation(IRelation); }
public void AddRelationAsSourceObject(IDesignRelation IRelation) { IDesignAnchorPoint Anchor = getNearAnchorPoint(IRelation.StartPoint); if (Anchor == null) { return; } Anchor.AddOutRelation(IRelation); }
public void RemoveRelation(IDesignRelation dr) { if (OutRelationList.Contains(dr)) { OutRelationList.Remove(dr); } if (InRelationList.Contains(dr)) { InRelationList.Remove(dr); } }
void DeseignCanvas_RelationDesignPointerReleased(object sender, PointerRoutedEventArgs e) { if (CurrentConnectPoint != null) { IDesignRelation l = CurrentConnectPoint.ConnectRelation; if (l == null) { EndRelationDesign(); return; } if (EndAnchor != null) //表示拖放链接点,并且进入了锚点区域 { if (CurrentConnectPoint.PointType == ConnectPointType.BeginPoint) //拖拽的是连接的起始点 { l.StartAnchorPoint = EndAnchor; EndAnchor.OutRelationList.Add(l); l.SourceID = EndAnchor.ParentConnectControl.ObjectID; } if (CurrentConnectPoint.PointType == ConnectPointType.EndPoint) { l.EndAnchorPoint = EndAnchor; EndAnchor.InRelationList.Add(l); l.TargetID = EndAnchor.ParentConnectControl.ObjectID; } if (l.DataObject.ObjectID == "" || l.DataObject.ObjectID == null) { l.DataObject.ObjectID = SilverlightLFC.common.Environment.getGUID(); } } else//移除任何的锚点 { if (CurrentConnectPoint.PointType == ConnectPointType.BeginPoint)//拖拽的是连接的起始点 { if (l.StartAnchorPoint != null) { l.StartAnchorPoint.OutRelationList.Remove(l); l.StartAnchorPoint = null; } l.SourceID = null; } if (CurrentConnectPoint.PointType == ConnectPointType.EndPoint) { if (l.EndAnchorPoint != null) { l.EndAnchorPoint.InRelationList.Remove(l); l.EndAnchorPoint = null; } l.TargetID = null; } } } EndRelationDesign(); }
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; }
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(); }
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); }
public void AddExistRelation(string id) //添加现有的关联,自动寻找两侧锚点位置 { IDesignRelation idr = getNewRelationControl(null, id); if (idr == null) { return; } List <IDesignNode> snl = new List <IDesignNode>(); List <IDesignNode> tnl = new List <IDesignNode>(); if (idr.SourceID != null) { snl = NodeList.Where(n => n.ObjectID == idr.SourceID).ToList(); } if (idr.TargetID != null) { tnl = NodeList.Where(n => n.ObjectID == idr.TargetID).ToList(); } if (tnl.Count > 0 && snl.Count > 0) { foreach (IDesignNode sdn in snl) { foreach (IDesignNode tdn in tnl) { IDesignRelation dr = getNewRelationControl(null, id); if (dr == null) { return; } AddExistRelation(dr, sdn, tdn); } } } if (snl.Count == 0 && tnl.Count > 0) { foreach (IDesignNode tdn in tnl) { IDesignRelation dr = getNewRelationControl(null, id); if (dr == null) { return; } AddExistRelation(dr, null, tdn); } } if (tnl.Count == 0 && snl.Count > 0) { foreach (IDesignNode sdn in snl) { IDesignRelation dr = getNewRelationControl(null, id); if (dr == null) { return; } AddExistRelation(dr, sdn, null); } } if (snl.Count == 0 && tnl.Count == 0) { IDesignRelation dr = getNewRelationControl(null, id); if (dr == null) { return; } AddExistRelation(dr, null, null); } }
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); } } } }
public void setRelation(IDesignRelation ir, ConnectPointType pt) { PointType = pt; _ConnectRelation = ir; }