コード例 #1
0
        /// <summary>
        /// Process the graph from a given node
        /// </summary>
        /// <param name="node"></param>
        public void ProcessGraph(DaggerNode node)
        {
            node.DoProcessing();

            foreach (DaggerNode n in node._descendents)
            {
                n.DoProcessing();
            }
        }
コード例 #2
0
ファイル: DSFilterNodeUI.cs プロジェクト: manuag/DSGraphEdit
        void node_AfterNodeRemoved(DaggerLib.Core.DaggerNode node)
        {
            //get rid of the property pages etc
            if (_properties != null)
            {
                _properties.Apply();
                _properties.Parent = null;
                _properties.CloseInterfaces();
                _properties = null;
            }

            // deinitialize the video window
            if (_videoWindow != null)
            {
                _videoWindow.Dispose();
                _videoWindow = null;
            }
        }
コード例 #3
0
        /// <summary>
        /// Process the graph from a given node
        /// </summary>
        /// <param name="node"></param>
        public void ProcessGraph(DaggerNode node)
        {
            node.DoProcessing();

            // if the node has a UINode attached, call it's DoUIProcessing method
            if (node.UINode != null)
            {
                node.UINode.DoUIProcessing();
            }

            foreach (DaggerNode n in node._descendents)
            {
                n.DoProcessing();

                // if the node has a UINode attached, call it's DoUIProcessing method
                if (n.UINode != null)
                {
                    n.UINode.DoUIProcessing();
                }
            }
        }
コード例 #4
0
ファイル: DaggerInterface.cs プロジェクト: rocee/DSGraphEdit
        /// <summary>
        /// Contruct a DaggerInterface from an existing DaggerNode
        /// </summary>
        /// <param name="node"></param>
        public DaggerInterface(DaggerNode node)
        {
            _inputPins = new List <DaggerInterfacePin>();
            foreach (DaggerInputPin pin in node.InputPins)
            {
                DaggerInterfacePin newpin = AddInputPin(pin);
                if (newpin == null)
                {
                    throw new InvalidOperationException("Interface already contains an Input Pin named " + pin.Name);
                }
            }

            _outputPins = new List <DaggerInterfacePin>();
            foreach (DaggerOutputPin pin in node.OutputPins)
            {
                DaggerInterfacePin newpin = AddOutputPin(pin);
                if (newpin == null)
                {
                    throw new InvalidOperationException("Interface already contains an Output Pin named " + pin.Name);
                }
            }
        }
コード例 #5
0
        public DaggerNode CreateNode()
        {
            DaggerNode node = (DaggerNode)Activator.CreateInstance(NodeType);

            node.InputPins.Clear();
            node.OutputPins.Clear();

            //set it'a InstanceGuid
            node.InstanceGuid = NodeInstanceGuid;

            //give it the pins
            foreach (DaggerInputPin pin in InputPins)
            {
                node.InputPins.Add(pin);
            }

            foreach (DaggerOutputPin pin in OutputPins)
            {
                node.OutputPins.Add(pin);
            }

            // put pins into thier reflected fields
            foreach (DaggerInputPin pin in InputPins)
            {
                foreach (FieldInfo fi in pin._reflectedTargets)
                {
                    fi.SetValue(node, pin);
                }
            }
            foreach (DaggerOutputPin pin in OutputPins)
            {
                foreach (FieldInfo fi in pin._reflectedTargets)
                {
                    fi.SetValue(node, pin);
                }
            }

            return(node);
        }
コード例 #6
0
        public DaggerNodeNonSerializationAssistant(DaggerNode node)
        {
            NodeType = node.GetType();

            NodeInstanceGuid = node.InstanceGuid;

            InputPins = new List <DaggerInputPin>();
            foreach (DaggerInputPin pin in node.InputPins)
            {
                InputPins.Add(pin);
            }

            OutputPins = new List <DaggerOutputPin>();
            foreach (DaggerOutputPin pin in node.OutputPins)
            {
                OutputPins.Add(pin);
            }

            FieldInfo[] fi = NodeType.GetFields();

            for (int i = 0; i < fi.Length; i++)
            {
                if (fi[i].FieldType.IsSubclassOf(typeof(DaggerBasePin)))
                {
                    DaggerBasePin val = (DaggerBasePin)fi[i].GetValue(node);

                    if (val != null)
                    {
                        //if this pin is stored in the collection, serialize it's reflected FieldInfo
                        if (node.InputPins[val.InstanceGuid] != null || node.OutputPins[val.InstanceGuid] != null)
                        {
                            val._reflectedTargets.Add(fi[i]);
                        }
                    }
                }
            }
        }
コード例 #7
0
 public DaggerInputPinCollection(DaggerNode parentNode)
 {
     _parentNode = parentNode;
 }
コード例 #8
0
 public DaggerPinCollection(DaggerNode parentNode)
 {
     _parentNode = parentNode;
     innerList   = new List <T>();
 }
コード例 #9
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);
            }
        }
コード例 #10
0
ファイル: DSFilterNodeUI.cs プロジェクト: manuag/DSGraphEdit
        /// <summary>
        /// Event that is raised after a DaggerNode has been created and associated to the UI element
        /// </summary>
        /// <param name="node"></param>
        void DSFilterNodeUI_DaggerNodeAttached(DaggerLib.Core.DaggerNode node)
        {
            _dsfilternode = (DSFilterNode)node;
            CaptionText   = node.ToString();

            // hook the AfterNodeRemoved event to dispose of any directshow interfaces
            node.AfterNodeRemoved += new DaggerLib.Core.AfterNodeRemoveHandler(node_AfterNodeRemoved);

            // get the IBaseFilter from the DSFilterNode
            IBaseFilter filter = _dsfilternode._filter;

            // only grab the video window or EVR if it was manually added to the graph via the UI
            if (_dsfilternode._manualAdded || (_dsfilternode.ParentGraph.ParentUIGraph as DSDaggerUIGraph)._filterGraphCreated)
            {
                // if it supports IVideoWindow create a VideoInternalWindow for it
                IVideoWindow vw = filter as IVideoWindow;
                if (vw != null)
                {
                    try
                    {
                        _videoWindow         = new VideoInternalWindow(CaptionText, filter);
                        _videoWindow.Dock    = DockStyle.Fill;
                        _videoWindow.Visible = true;
                        InternalControl.Controls.Add(_videoWindow);

                        // only nodes with video windows are resizeable
                        Resizable = true;

                        // hook the connection events to init/deinit the video window
                        node.ParentGraph.AfterPinsConnected += new DaggerLib.Core.PinAfterConnectedHandler(ParentGraph_AfterPinsConnected);
                    }
                    catch (Exception ex)
                    {
#if DEBUG
                        MessageBox.Show(ex.Message);
#endif
                        _videoWindow = null;
                    }
                }

                // if it's an Enhaced Video Renderer create a VideoInternalWindow for it
                // (see docs for Windows Media Foundation)
                IMFGetService mfgs = filter as IMFGetService;
                if (mfgs != null)
                {
                    // this is a video horse of a different color
                    // create a video clipping window for the Media Foundation Enhanced Video Renderer
                    try
                    {
                        // get the IMFVideoDisplayControl for the EVR filter
                        object o = null;
                        mfgs.GetService(MediaFoundation.MFServices.MR_VIDEO_RENDER_SERVICE,
                                        typeof(IMFVideoDisplayControl).GUID,
                                        out o
                                        );
                        m_pVideoDisplay = o as IMFVideoDisplayControl;

                        // if the Video Size is 0,0 the EVR hasn't been initialized/connected yet
                        MediaFoundation.Misc.SIZE videoSize = new MediaFoundation.Misc.SIZE();
                        MediaFoundation.Misc.SIZE ar        = new MediaFoundation.Misc.SIZE();
                        m_pVideoDisplay.GetNativeVideoSize(videoSize, ar);

                        if (videoSize.cx == 0 && videoSize.cy == 0)
                        {
                            // You only get one chance to set the number of pins in an EVR filter.
                            PinsComboBoxForm pcf = new PinsComboBoxForm();
                            if (pcf.ShowDialog() == DialogResult.OK)
                            {
                                (filter as IEVRFilterConfig).SetNumberOfStreams(pcf.Value);
                            }
                            pcf.Dispose();
                        }

                        _videoWindow         = new VideoInternalWindow(CaptionText, m_pVideoDisplay);
                        _videoWindow.Dock    = DockStyle.Fill;
                        _videoWindow.Visible = true;
                        InternalControl.Controls.Add(_videoWindow);

                        // only nodes with video windows are resizeable
                        Resizable = true;

                        // hook the connection events to init/deinit the video window
                        node.ParentGraph.AfterPinsConnected += new DaggerLib.Core.PinAfterConnectedHandler(ParentGraph_AfterPinsConnected);
                    }
                    catch (InvalidCastException)
                    {
                        m_pVideoDisplay = null;
                    }
                }
            }

            // if it's a DMO, create the DMO properties page for it
            if ((filter as IDMOWrapperFilter) != null)
            {
                // set the caption to show it's a DMO
                CaptionText           = "DMO - " + CaptionText;
                CaptionColor          = Color.Green;
                CaptionColorUnfocused = Color.LightGreen;
            }

            // remove clock button if it doesn't support IReferenceClock
            _referenceClock = filter as IReferenceClock;
            if (_referenceClock == null)
            {
                CaptionButtons.RemoveAt(CaptionButtons.AllButtons.IndexOf(_clockButton));
            }
            else
            {
                // see if this filter is the reference clock for the graph
                IReferenceClock graphClock = null;
                filter.GetSyncSource(out graphClock);
                _clockButton.Tag = false;
                _clockButton.MouseOutsideTint = Color.DarkGray;
                if (graphClock != null)
                {
                    if (graphClock == _referenceClock)
                    {
                        _clockButton.MouseOutsideTint = Color.Yellow;
                        _clockButton.Tag = true;
                    }
                    Marshal.ReleaseComObject(graphClock);
                }
            }

            // remove video window button if it's not a video window
            if (_videoWindow == null)
            {
                CaptionButtons.RemoveAt(CaptionButtons.AllButtons.IndexOf(_detachVideoWindowButton));
            }

            // Sync the pins to the Pin Property Pages
            SyncPinPropertyPages(null);

            // set it to the smallest possible size.  DaggerLib uses InternalControlMinimumSize
            // to prevent the UI node from being smaller than designated
            this.Size = new Size(1, 1);
        }