Exemplo n.º 1
0
        private void restoreConnectionLines(MainWindow mw)
        {
            List <ConnectionLine> connections = ConnectorFinder.find(owner.canvas.Children, owner);

            foreach (ConnectionLine cl in connections)
            {
                // can use ==, because it's same object instance
                UIEntity connectedTo = cl.SourcePort.Owner != owner ? cl.SourcePort.Owner : cl.DestinationPort.Owner;
                PortType srcPortType = cl.SourcePort.Owner != owner ? cl.SourcePort.PortType : cl.DestinationPort.PortType;
                PortType dstPortType = cl.SourcePort.Owner != owner ? cl.DestinationPort.PortType : cl.SourcePort.PortType;

                if (!(ParameterProccesor.newResource.GetType() == typeof(MaterialResource) && PortType.BOTTOM_RESOURCE.Equals(dstPortType)))
                {
                    ConnectionLine newCl = new ConnectionLine(owner.canvas);

                    newCl.SetBinding(ConnectionLine.SourceProperty, new Binding()
                    {
                        Source = connectedTo.findPort(srcPortType),
                        Path   = new PropertyPath(Port.AnchorPointProperty)
                    });
                    newCl.SetBinding(ConnectionLine.DestinationProperty, new Binding()
                    {
                        Source = ParameterProccesor.newResource.findPort(dstPortType),
                        Path   = new PropertyPath(Port.AnchorPointProperty)
                    });


                    newCl.MouseLeftButtonDown += mw.Shape_MouseLeftButtonDown;
                    newCl.MouseLeftButtonUp   += mw.Shape_MouseLeftButtonUp;

                    ZIndexUtil.setCorrectZIndex(newCl.canvas, newCl);

                    owner.canvas.Children.Add(newCl);
                }
            }
        }