List <Tuple <Guid, Guid, object> > FilterExistLink(List <Tuple <Guid, Guid, object> > ol) { var rl = new List <object>(); var vm = DataContext as DesignCanvasViewModel; vm.LinkList.ForEach(l => { ol.ForEach(v => { var id = CommonProc.GetID(v.Item3); if (id != Guid.Empty && l.TargetObjectID == id) { rl.Add(v); } }); }); var list = new List <Tuple <Guid, Guid, object> >(); ol.ForEach(v => { if (!rl.Contains(v.Item3)) { list.Add(v); } }); return(list); }
List <Tuple <Guid, Guid, object> > GetConnectionList(FrameworkElement currentControl) { if (DesignManager.GetConnection == null) { return(null); } List <Tuple <Guid, Guid, object> > ol = new List <Tuple <Guid, Guid, object> >(); List <Guid> idl = new List <Guid>(); List <Guid> linkidl = new List <Guid>(); if (currentControl == null || (currentControl as DesignControl) == null || ((currentControl as DesignControl).DataContext) == null) { return(ol); } var sitem = (currentControl as DesignControl).DataContext as DesignItem; if (sitem == null) { return(ol); } var id = sitem.TargetObjectID; if (id == null) { return(ol); } foreach (var c in TargetDesignCanvas.Children) { if (c is ArrowCurveSegment) { var linkVM = (c as ArrowCurveSegment).DataContext as DesignLink; linkidl.Add(linkVM.DesignLinkID); } } foreach (var c in TargetDesignCanvas.Children) { if (c is DesignControl) { var controlVM = (c as DesignControl).DataContext as DesignItem; if (controlVM != null && controlVM.TargetObjectID != null) { var l = DesignManager.GetConnection(id.Value, controlVM.TargetObjectID.Value); if (l != null) { l.ForEach(v => { var tid = CommonProc.GetID(v); if (tid != null && !idl.Contains(tid.Value) && !linkidl.Contains(tid.Value)) { ol.Add(new Tuple <Guid, Guid, object>(id.Value, controlVM.TargetObjectID.Value, v)); idl.Add(tid.Value); } }); } l = DesignManager.GetConnection(controlVM.TargetObjectID.Value, id.Value); if (l != null) { l.ForEach(v => { var tid = CommonProc.GetID(v); if (tid != null && !idl.Contains(tid.Value) && !linkidl.Contains(tid.Value)) { ol.Add(new Tuple <Guid, Guid, object>(controlVM.TargetObjectID.Value, id.Value, v)); idl.Add(tid.Value); } }); } } } } return(FilterExistLink(ol)); }