예제 #1
0
        private void LinkAction(object sender, DragEventArgs args)
        {
            if (args.Data.GetDataPresent(typeof(ViewEdgePreview)))
            {
                var viewEdgePreview = args.Data.GetData(typeof(ViewEdgePreview)) as ViewEdgePreview;

                if (viewEdgePreview.StartNode == null)
                {
                    return;
                }
                if (viewEdgePreview.DropPosition.HasValue == false)
                {
                    return;
                }

                var canvas = (viewEdgePreview.StartNode.Parent as Canvas);

                foreach (FrameworkElement child in canvas.Children)
                {
                    var top    = Canvas.GetTop(child);
                    var left   = Canvas.GetLeft(child);
                    var bottom = top + child.DesiredSize.Height;
                    var right  = left + child.DesiredSize.Width;


                    var boundingBox = new Rect(
                        new Point(left, top), new Size(child.DesiredSize.Width, child.DesiredSize.Height)
                        );

                    if (boundingBox.Contains(viewEdgePreview.DropPosition.Value))
                    {
                        var newEdge = new ViewEdge();
                        newEdge.Connect(viewEdgePreview.StartNode, (child as ViewNodeControl));
                        EdgesList.Add(newEdge);
                        return;
                    }
                }
            }
        }
예제 #2
0
 public ViewEdge AddEdge(ViewEdge viewEdge)
 {
     EdgesList.Add(viewEdge);
     return(viewEdge);
 }