Beispiel #1
0
 void ParentGraph_AfterPinsConnected(DaggerLib.Core.DaggerOutputPin output, DaggerLib.Core.DaggerInputPin input)
 {
     if (_videoWindow != null)
     {
         _videoWindow.InitVideoWindow();
     }
 }
Beispiel #2
0
        /// <summary>
        /// Create a new subnode from a serialized graph
        /// </summary>
        /// <param name="buffer"></param>
        public DaggerSubNode(string name, byte[] buffer)
            : base()
        {
            MemoryStream    ms         = new MemoryStream(buffer);
            BinaryFormatter bformatter = new BinaryFormatter();

            _subNodeGraph = (DaggerGraph)bformatter.Deserialize(ms);
            _subNodeName  = name;
            _subNodeGraph._parentSubNode = this;

            // reflect imported/exported pins to input/output pins
            foreach (DaggerOutputPin pin in _subNodeGraph.ImportedPins)
            {
                DaggerInputPin inpin = new DaggerInputPin();
                inpin.Name     = pin.Name;
                inpin.DataType = pin.DataType;
                InputPins.Add(inpin);
            }
            foreach (DaggerInputPin pin in _subNodeGraph.ExportedPins)
            {
                DaggerOutputPin outpin = new DaggerOutputPin();
                outpin.Name     = pin.Name;
                outpin.DataType = pin.DataType;
                OutputPins.Add(outpin);
            }

            AssociatedUINode = "IDaggerUISubNode";
        }
        public void Remove(DaggerInputPin Pin)
        {
            List.Remove(Pin);

            if (PinRemoved != null)
            {
                PinRemoved(this, Pin);
            }

            Pin._parentNode  = null;
            Pin._parentGraph = null;
        }
        public int Add(DaggerInputPin Pin)
        {
            int i;

            i = List.Add(Pin);
            Pin._parentNode  = _parentNode;
            Pin._parentGraph = _parentGraph;

            if (PinAdded != null)
            {
                PinAdded(this, Pin);
            }
            return(i);
        }
        public DaggerTypeConstantNode(Type constantType)
        {
            inpin          = new DaggerInputPin();
            inpin.DataType = constantType;
            inpin.Name     = "Constant Input";
            InputPins.Add(inpin);

            outpin          = new DaggerOutputPin();
            outpin.DataType = constantType;
            OutputPins.Add(outpin);

            AssociatedUINode = typeof(TypeConstantNodeUI);
            DoProcessing    += new ProcessHandler(DaggerTypeConstantNode_DoProcessing);
        }
        /// <summary>
        /// Get a pin by it's name
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public DaggerInputPin this[string name]
        {
            get
            {
                DaggerInputPin outpin = null;

                foreach (DaggerInputPin pin in List)
                {
                    if (name == pin.Name)
                    {
                        outpin = pin;
                        break;
                    }
                }

                return(outpin);
            }
        }
        /// <summary>
        /// Get a pin by it's guid
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        internal DaggerInputPin this[Guid guid]
        {
            get
            {
                DaggerInputPin outpin = null;

                foreach (DaggerInputPin pin in List)
                {
                    if (guid == pin.InstanceGuid)
                    {
                        outpin = pin;
                        break;
                    }
                }

                return(outpin);
            }
        }
        /// <summary>
        /// Deserialization Constructor
        /// </summary>
        /// <param name="info"></param>
        /// <param name="ctxt"></param>
        protected DaggerTypeConstantNode(SerializationInfo info, StreamingContext ctxt)
            : base(info, ctxt)
        {
            if (info == null)
            {
                throw new System.ArgumentNullException("info");
            }

            DataType = (Type)info.GetValue("DataType", typeof(Type));

            inpin = (DaggerInputPin)info.GetValue("InPin", typeof(DaggerInputPin));
            InputPins.Add(inpin);

            outpin = (DaggerOutputPin)info.GetValue("OutPin", typeof(DaggerOutputPin));
            OutputPins.Add(outpin);

            AssociatedUINode = typeof(TypeConstantNodeUI);
            DoProcessing    += new ProcessHandler(DaggerTypeConstantNode_DoProcessing);
        }
Beispiel #9
0
        public DaggerSubNode(DaggerGraph graph)
            : base()
        {
            _subNodeGraph = graph;
            _subNodeGraph._parentSubNode = this;

            AssociatedUINode = "IDaggerUISubNode";

            foreach (DaggerOutputPin pin in _subNodeGraph.ImportedPins)
            {
                DaggerInputPin inpin = new DaggerInputPin();
                inpin.Name     = pin.Name;
                inpin.DataType = pin.DataType;
                InputPins.Add(inpin);
            }

            foreach (DaggerInputPin pin in _subNodeGraph.ExportedPins)
            {
                DaggerOutputPin outpin = new DaggerOutputPin();
                outpin.Name     = pin.Name;
                outpin.DataType = pin.DataType;
                OutputPins.Add(outpin);
            }
        }
Beispiel #10
0
 public virtual bool IsCompatibleDataTypes(DaggerInputPin inpin, DaggerOutputPin outpin)
 {
     return(IsCompatibleDataTypes(inpin.DataType, outpin.DataType));
 }
 public bool Contains(DaggerInputPin Pin)
 {
     return(List.Contains(Pin));
 }
Beispiel #12
0
 public DaggerInterfacePin AddInputPin(DaggerInputPin pin)
 {
     return(AddInputPin(pin.Name, pin.DataType));
 }
Beispiel #13
0
        /// <summary>
        /// Connect this pin to Input Pin
        /// </summary>
        /// <param name="input">pin to connect to</param>
        /// <returns>true if succeded</returns>
        public bool ConnectToInput(DaggerInputPin input)
        {
            DaggerGraph outputpincontainer = (_parentNode != null) ? _parentNode.ParentGraph : _parentGraph;
            DaggerGraph inputpincontainer  = (input._parentNode != null) ? input._parentNode.ParentGraph : input._parentGraph;

            if (outputpincontainer == null)
            {
                throw new InvalidOperationException("Output pin is not associated with a DaggerGraph");
            }

            if (inputpincontainer == null)
            {
                throw new InvalidOperationException("Input pin is not associated with a DaggerGraph");
            }

            if (inputpincontainer != outputpincontainer)
            {
                throw new InvalidOperationException("Input pin and Output pin are not associated with the same DaggerGraph");
            }

            if (input.IsConnected)
            {
                // disconnect the input pin from it's previous connection
                if (!input.Disconnect(false))
                {
                    return(false);
                }
            }

            //call the before connect event to see if we can connect them
            if (outputpincontainer.OnBeforePinsConnected(this, input))
            {
                //connect the two pins
                _connectedTo.Add(input);
                input._connectedTo = this;

                //if we have data, give it to the input
                if (_data != null)
                {
                    input.Data = _data;
                }

                // let the graph know they are connected
                outputpincontainer.OnPinsConnected(this, input);

                // if the input pin is marked as autoclone, create a duplicate pin
                if (input.AutoClone)
                {
                    // Don't AutoClone during the deserialization process
                    if (!input._parentNode.ParentGraph._isDeserializing)
                    {
                        DaggerInputPin newpin = new DaggerInputPin();
                        newpin.Name       = input.Name;
                        newpin.DataType   = input.DataType;
                        newpin.AutoClone  = true;
                        newpin._wasCloned = true;
                        input.ParentNode.InputPins.Add(newpin);
                    }
                }

                // refresh the UINodes if they are attached
                if (_parentNode != null && _parentNode.UINode != null)
                {
                    _parentNode.UINode.CalculateLayout();
                }
                if (input._parentNode != null && input._parentNode.UINode != null)
                {
                    input._parentNode.UINode.CalculateLayout();
                }

                // if we autocloned, refresh the UIGraph to re-align the noodles
                if (input._autoClone && input._parentNode.UINode != null)
                {
                    input._parentNode.UINode.ParentUIGraph.UpdateNoodles(input._parentNode);
                }

                // call the AfterPinConnected event
                if (PinConnected != null)
                {
                    PinConnected(this, new EventArgs());
                }
                input.InvokeAfterConnect();

                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #14
0
        /// <summary>
        /// Disconnect link going to input
        /// </summary>
        /// <param name="input">Input pin to disconnect from</param>
        /// <param name="forceDisconnect">if true, ignore pre-disconnect testing</param>
        /// <returns>true if disconnect succeded</returns>
        public bool Disconnect(DaggerInputPin input, bool forceDisconnect)
        {
            //get the parent graph of this pin
            DaggerGraph parentGraph = (_parentGraph == null) ? _parentNode.ParentGraph : _parentGraph;

            if (parentGraph == null)
            {
                throw new InvalidOperationException("Output pin is not associated with a DaggerGraph");
            }

            //do we have this input pin?
            if (_connectedTo.Contains(input))
            {
                // call the before connect event to see if we can disconnect them
                if (parentGraph.OnBeforePinsDisconnected(this, input) || forceDisconnect)
                {
                    _connectedTo.Remove(input);
                    input._connectedTo = null;

                    //let the container know they are disonnected
                    parentGraph.OnPinsDisonnected(this, input);

                    //if the input was autocloned or is marked AutoClone, remove it from the node
                    DaggerNode inputParentNode = input._parentNode;
                    if (input._wasCloned || input._autoClone)
                    {
                        inputParentNode.InputPins.Remove(input);

                        //refresh the ui
                        if (inputParentNode.UINode != null)
                        {
                            inputParentNode.UINode.CalculateLayout();
                            inputParentNode.UINode.ParentUIGraph.UpdateNoodles(inputParentNode);
                        }
                    }

                    //if the input was marked AutoClone, pass the torch to the next compatible pin
                    if (input._autoClone)
                    {
                        foreach (DaggerInputPin pin in inputParentNode.InputPins)
                        {
                            if (pin.DataType == input.DataType)
                            {
                                pin._autoClone = true;
                                break;
                            }
                        }
                    }

                    // raise the AfterPinDisconnected event
                    if (PinDisconnected != null)
                    {
                        PinDisconnected(this, new EventArgs());
                    }
                    input.InvokeAfterDisconnect();

                    return(true);
                }
                else
                {
                    //we failed to disconnect them
                    return(false);
                }
            }
            else
            {
                // raise the AfterPinDisconnected event
                if (PinDisconnected != null)
                {
                    PinDisconnected(this, new EventArgs());
                }
                input.InvokeAfterDisconnect();

                //since we were never connected to this pin, they are technically disconnected
                return(true);
            }
        }