示例#1
0
        /// <summary>
        /// Prior to this call, you must have created the connector using the
        /// </summary>
        /// <param name="self"></param>
        /// <param name="deserializationContext"></param>
        public void LoadFromXElement(XElement self, DeserializationContext deserializationContext)
        {
            IModel model            = null;
            string connectorName    = self.Attribute("connectorName").Value;
            string connectorDesc    = self.Attribute("connectorDesc").Value;
            Guid   connectorGuidWas = XmlConvert.ToGuid(self.Attribute("connectorGuid").Value);
            Guid   connectorGuidIs  = Guid.NewGuid();

            deserializationContext.SetNewGuidForOldGuid(connectorGuidWas, connectorGuidIs);
            IMOHelper.Initialize(ref m_model, model, ref m_name, connectorName, ref m_description, connectorDesc, ref m_guid, connectorGuidIs);
            IMOHelper.RegisterWithModel(this);

            XElement    source = self.Element("Source");
            Guid        upstreamOwnerGuidWas = XmlConvert.ToGuid(source.Attribute("guid").Value);
            Guid        upstreamOwnerGuidIs  = Guid.NewGuid();
            string      upstreamPortName     = source.Attribute("name").Value;
            IPortOwner  usmb         = (IPortOwner)deserializationContext.GetModelObjectThatHad(upstreamOwnerGuidWas);
            IOutputPort upstreamPort = (IOutputPort)usmb.Ports[upstreamPortName];

            XElement   destination            = self.Element("Destination");
            Guid       downstreamOwnerGuidWas = XmlConvert.ToGuid(destination.Attribute("guid").Value);
            Guid       downstreamOwnerGuidIs  = Guid.NewGuid();
            string     downstreamPortName     = destination.Attribute("name").Value;
            IPortOwner dsmb           = (IPortOwner)deserializationContext.GetModelObjectThatHad(downstreamOwnerGuidWas);
            IInputPort downstreamPort = (IInputPort)dsmb.Ports[downstreamPortName];

            Connect(upstreamPort, downstreamPort);
        }
        /// <summary>
        /// Factory method that creates a parameter for the given port that tries to match the provided location
        /// in absolute world coordinates.
        /// </summary>
        /// <remarks>While you are free to return arbitrary implementations of <see cref="IPortLocationModelParameter"/>, you usually want to
        /// use a specialized implementation that corresponds to your model, here we return <see cref="MyNodePortLocationModelParameter"/> instances. Note that
        /// for discrete port models, you'll want to use some discretization of the coordinate space. This means that retrieving the actual location with
        /// <see cref="GetLocation"/> with the returned value does not necessarily have to provide the original coordinates <paramref name="location"/>
        /// still, the actual location should probably
        /// be included in the coordinate subset that is mapped to the return value (otherwise behaviour will be very confusing)</remarks>
        /// <param name="portOwner">The port owner that will own the port for which the parameter shall be created.</param>
        /// <param name="location">The location in the world coordinate system that should be matched as best as possible.</param>
        /// <returns>A new instance that can be used to describe the location of an <see cref="IPort"/> at the given
        /// <paramref name="portOwner"/>.</returns>
        public IPortLocationModelParameter CreateParameter(IPortOwner portOwner, PointD location)
        {
            var ownerNode = portOwner as INode;

            if (ownerNode != null)
            {
                //determine the distance of the specified location to the node layout center
                var delta = location - ownerNode.Layout.GetCenter();
                if (delta.VectorLength < 0.25d * Math.Min(ownerNode.Layout.Width, ownerNode.Layout.Height))
                {
                    //nearer to the center than to the border => map to center
                    return(CreateParameter(PortLocation.Center));
                }
                else
                {
                    //map to a location on the side
                    if (Math.Abs(delta.X) > Math.Abs(delta.Y))
                    {
                        return(CreateParameter(delta.X > 0 ? PortLocation.East : PortLocation.West));
                    }
                    else
                    {
                        return(CreateParameter(delta.Y > 0 ? PortLocation.South : PortLocation.North));
                    }
                }
            }
            else
            {
                //Just return  a fallback  - GetLocation will ignore this anyway if the owner is null or not a node.
                return(CreateParameter(PortLocation.Center));
            }
        }
示例#3
0
        /// <summary>
        /// Services needs in the first dependency-sequenced round of initialization.
        /// </summary>
        /// <param name="model">The model in which the initialization is taking place.</param>
        /// <param name="p">The array of objects that take part in this round of initialization.</param>
        public void _Initialize(IModel model, object[] p)
        {
            IPortOwner ipo = (IPortOwner)model.ModelObjects[p[0]];

            m_input = ipo.Ports[(string)p[1]];
            IPortOwner opo = (IPortOwner)model.ModelObjects[p[2]];

            m_output = ipo.Ports[(string)p[3]];
            Connect(m_input, m_output);
        }
示例#4
0
        public EventPortIn(IPortOwner owner)
            : base(owner)
        {
            this.Size    = new System.Drawing.Size(ComponentIconEvent.PortSize, ComponentIconEvent.PortSize);
            LabelVisible = false;
            //
            Control c = owner as Control;

            Owner   = c;
            c.Move += new EventHandler(c_Move);
        }
        /// <summary>
        /// Creates a parameter that matches <paramref name="location"/>
        /// </summary>
        /// <remarks>
        /// This implementation undoes the rotation by the <paramref name="portOwner"/>, creates a parameter for this location in
        /// <see cref="Wrapped"/> and wraps this into a model specific parameter.
        /// </remarks>
        /// <param name="portOwner"></param>
        /// <param name="location">The actual coordinates</param>
        /// <returns></returns>
        public IPortLocationModelParameter CreateParameter(IPortOwner portOwner, PointD location)
        {
            double angle     = 0;
            var    ownerNode = portOwner as INode;

            if (ownerNode != null)
            {
                angle = GetAngle(ownerNode);
            }
            if (ownerNode != null && Math.Abs(angle) >= Eps)
            {
                //Undo the rotation by the ownerNode so that we can create a core parameter for the unrotated layout.
                var center = ownerNode.Layout.GetCenter();
                var result = RotateAt(angle, center, location);
                location = new PointD(result.X, result.Y);
            }
            return(new RotatablePortLocationModelDecoratorParameter(Wrapped.CreateParameter(portOwner, location), this));
        }
示例#6
0
 public IConnector Connect(IPortOwner from, string fromPortName, IPortOwner to, string toPortName)
 {
     throw new Exception("The method or operation is not implemented.");
 }
 /// <summary>
 /// Accepts all port owners that are supported by the wrapped parameter.
 /// </summary>
 public bool Supports(IPortOwner portOwner)
 {
     return(wrapped.Supports(portOwner));
 }
 /// <summary>
 /// Predicate that checks if this parameter instance may be used to describe ports for <paramref name="owner"/>
 /// </summary>
 /// <remarks>Our model/parameter implementation only makes sense when used for <see cref="INode"/>s.</remarks>
 public bool Supports(IPortOwner owner)
 {
     return(owner is INode);
 }
示例#9
0
 public bool Supports(IPortOwner owner)
 {
     return(true);
 }
示例#10
0
 /// <inheritdoc/>
 public IPortLocationModelParameter CreateParameter(IPortOwner owner, PointD location)
 {
     return(CreateParameter(location));
 }
 public IPortLocationModelParameter CreateParameter(IPortOwner owner, PointD location)
 {
     return(new PointPortLocationModelParameter {
         Location = location, Model = this
     });
 }
示例#12
0
 public static IPortStyle CreatePortStyle(this IGraph graph, IPortOwner owner)
 {
     return(owner is INode?graph.NodeDefaults.Ports.GetStyleInstance(owner) : graph.EdgeDefaults.Ports.GetStyleInstance(owner));
 }
 public ActionPortIn(IPortOwner owner)
     : base(owner)
 {
     this.Size    = new System.Drawing.Size(11, 11);
     LabelVisible = false;
 }
示例#14
0
 public ProgramNewOutPort(IPortOwner owner)
     : base(owner)
 {
     this.LabelVisible = false;
 }
示例#15
0
 /// <summary>
 /// property reference for the port
 /// </summary>
 /// <param name="owner">it should be a ProgramEntity</param>
 public ProgramOutPort(IPortOwner owner)
     : base(owner)
 {
 }
示例#16
0
 public EventPortInFireEvent(IPortOwner owner)
     : base(owner)
 {
 }