コード例 #1
0
ファイル: DSFilterNodeUI.cs プロジェクト: manuag/DSGraphEdit
        /// <summary>
        /// User has clicked on a render pin menu item
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void renderPinMenuItem_Click(object sender, EventArgs e)
        {
            int hr = 0;

            // get the DaggerPin
            DSOutputPin pin = (sender as ToolStripMenuItem).Tag as DSOutputPin;

            // get the Parent UIGraph
            DSDaggerUIGraph parentui = this.Parent as DSDaggerUIGraph;

            // get the FilterGraph
            IGraphBuilder graph = parentui._Graph as IGraphBuilder;

            // atempt to render the pin
            try
            {
                hr = graph.Render(pin._pin);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error rendering pin");
            }

            Point dropstart = parentui.PointToClient(this.PointToScreen((pin.PinUIElements as PinUI).PinLocation));

            parentui._dropLocation = new Point(dropstart.X + 25, dropstart.Y);

            // Sync the graphs
            parentui.SyncGraphs(null);

            if (hr != 0)
            {
                MessageBox.Show(DsError.GetErrorText(hr));
            }
        }
コード例 #2
0
ファイル: DSFilterNodeUI.cs プロジェクト: manuag/DSGraphEdit
        /// <summary>
        /// User has clicked on a pin properties menu item
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void tmi_Click(object sender, EventArgs e)
        {
            // if this pin implements ISpecifyPropertyPages, show that instead
            PropertiesDialog pd;
            IPin             pin = null;
            string           pinname;

            // get the DaggerPin
            DSOutputPin opin = (sender as ToolStripMenuItem).Tag as DSOutputPin;

            if (opin != null)
            {
                // it's an output pin
                pin     = opin._pin;
                pinname = opin.Name;
            }
            else
            {
                // it's an input pin
                pin     = ((sender as ToolStripMenuItem).Tag as DSInputPin)._pin;
                pinname = ((sender as ToolStripMenuItem).Tag as DSInputPin).Name;
            }

            ISpecifyPropertyPages proppage = pin as ISpecifyPropertyPages;
            bool displayed = false;

            if (proppage != null)
            {
                // display the pin's property pages
                displayed = DirectShowLib.Utils.FilterGraphTools.ShowPinFilterPropertyPage(pin, this.TopLevelControl.Handle, pinname);
            }

            // if ShowPinFilterPropertyPage failed, or there's no ISpecifyPropertyPages, show the default pin info
            if (!displayed)
            {
                pd = new PropertiesDialog(pinname, pin);
                pd.ShowDialog();
                pd.Dispose();
                pd = null;
            }
        }
コード例 #3
0
        /// <summary>
        /// Add or remove DaggerBasePins depending on the IPins in the filter
        /// </summary>
        public void SyncPins()
        {
            bool altered = false;

            // get the pins and convert to DaggerBasePins if they dont exisit yet
            _pins = GetPins();
            foreach (IPin pin in _pins)
            {
                PinDirection pd;
                pin.QueryDirection(out pd);
                if (pd == PinDirection.Input)
                {
                    if (GetDaggerPin(pin) == null)
                    {
                        DSInputPin inpin = new DSInputPin(pin);
                        InputPins.Add(inpin);
                        altered = true;
                    }
                }
                else
                {
                    if (GetDaggerPin(pin) == null)
                    {
                        DSOutputPin outpin = new DSOutputPin(pin);
                        OutputPins.Add(outpin);
                        altered = true;
                    }
                }
            }

            // remove any DaggerDSPins that may have vanished
            for (int i = InputPins.Count - 1; i > -1; i--)
            {
                if (!_pins.Contains((InputPins[i] as DSInputPin)._pin))
                {
                    // force the disconnect
                    InputPins[i].Disconnect(true);
                    Marshal.ReleaseComObject((InputPins[i] as DSInputPin)._pin);
                    (InputPins[i] as DSInputPin)._pin = null;
                    InputPins.Remove(InputPins[i]);
                    altered = true;
                }

                // check the major media format of the pin and set it's data type
                Type majorType = typeof(PinDataTypes.Unknown);
                bool whoops    = false;
                try
                {
                    majorType = GetPinMajorMediaType((InputPins[i] as DSInputPin)._pin);
                }
                catch
                {
                    // the pin was removed by directshow, ignore changing the data type
                    whoops = true;
                }
                finally
                {
                    if (!whoops)
                    {
                        if (InputPins[i].DataType != majorType)
                        {
                            InputPins[i].DataType = majorType;
                            altered = true;
                        }
                    }
                }
            }

            for (int i = OutputPins.Count - 1; i > -1; i--)
            {
                if (!_pins.Contains((OutputPins[i] as DSOutputPin)._pin))
                {
                    // force the disconnect
                    OutputPins[i].Disconnect(true);
                    Marshal.ReleaseComObject((OutputPins[i] as DSOutputPin)._pin);
                    (OutputPins[i] as DSOutputPin)._pin = null;
                    OutputPins.Remove(OutputPins[i]);
                    altered = true;
                }

                // check the major media format of the pin and set it's data type
                Type majorType = typeof(PinDataTypes.Unknown);
                bool whoops    = false;
                try
                {
                    majorType = GetPinMajorMediaType((OutputPins[i] as DSOutputPin)._pin);
                }
                catch
                {
                    // the pin was removed by directshow, ignore changing the data type
                    whoops = true;
                }
                finally
                {
                    if (!whoops)
                    {
                        if (OutputPins[i].DataType != majorType)
                        {
                            OutputPins[i].DataType = majorType;
                            altered = true;
                        }
                    }
                }
            }

            // if we altered anything, update the filter's ui elements and redraw the graph
            if (altered)
            {
                if (this.UINode != null)
                {
                    UINode.CalculateLayout();
                    if ((UINode as DaggerUINode).Parent != null)
                    {
                        // update the graph ui if the uinode is still part of a uigraph
                        (UINode as DaggerUINode).Parent.Invalidate();
                    }
                }
            }

            // tell the ui node to update any pin property pages
            if (UINode != null && UINode is DSFilterNodeUI)
            {
                (UINode as DSFilterNodeUI).SyncPinPropertyPages(null);
            }
        }